Revisão | caa8d70005e4e12392683c799b30790fc4c62166 (tree) |
---|---|
Hora | 2015-12-15 20:01:03 |
Autor | Nick Clifton <nickc@redh...> |
Commiter | Nick Clifton |
Add support for the MRS instruction to the AArch64 simulator.
* aarch64/simulator.c (system_get): New function. Provides read
access to the dczid system register.
(do_mrs): New function - implements the MRS instruction.
(dexSystem): Call do_mrs for the MRS instruction. Halt on
unimplemented system instructions.
@@ -1,3 +1,11 @@ | ||
1 | +2015-12-14 Nick Clifton <nickc@redhat.com> | |
2 | + | |
3 | + * aarch64/simulator.c (system_get): New function. Provides read | |
4 | + access to the dczid system register. | |
5 | + (do_mrs): New function - implements the MRS instruction. | |
6 | + (dexSystem): Call do_mrs for the MRS instruction. Halt on | |
7 | + unimplemented system instructions. | |
8 | + | |
1 | 9 | 2015-11-24 Nick Clifton <nickc@redhat.com> |
2 | 10 | |
3 | 11 | * configure.tgt: Add aarch64 entry. |
@@ -12783,6 +12783,44 @@ dexExcpnGen (sim_cpu *cpu) | ||
12783 | 12783 | HALT_UNALLOC; |
12784 | 12784 | } |
12785 | 12785 | |
12786 | +/* Stub for accessing system registers. | |
12787 | + We implement support for the DCZID register since this is used | |
12788 | + by the C library's memset function. */ | |
12789 | + | |
12790 | +static uint64_t | |
12791 | +system_get (sim_cpu *cpu, unsigned op0, unsigned op1, unsigned crn, | |
12792 | + unsigned crm, unsigned op2) | |
12793 | +{ | |
12794 | + if (crn == 0 && op1 == 3 && crm == 0 && op2 == 7) | |
12795 | + /* DCZID_EL0 - the Data Cache Zero ID register. | |
12796 | + We do not support DC ZVA at the moment, so | |
12797 | + we return a value with the disable bit set. */ | |
12798 | + return ((uint64_t) 1) << 4; | |
12799 | + | |
12800 | + HALT_NYI; | |
12801 | +} | |
12802 | + | |
12803 | +static void | |
12804 | +do_mrs (sim_cpu *cpu) | |
12805 | +{ | |
12806 | + /* instr[31:20] = 1101 01010 0011 | |
12807 | + instr[19] = op0 | |
12808 | + instr[18,16] = op1 | |
12809 | + instr[15,12] = CRn | |
12810 | + instr[11,8] = CRm | |
12811 | + instr[7,5] = op2 | |
12812 | + instr[4,0] = Rt */ | |
12813 | + unsigned sys_op0 = uimm (aarch64_get_instr (cpu), 19, 19) + 2; | |
12814 | + unsigned sys_op1 = uimm (aarch64_get_instr (cpu), 18, 16); | |
12815 | + unsigned sys_crn = uimm (aarch64_get_instr (cpu), 15, 12); | |
12816 | + unsigned sys_crm = uimm (aarch64_get_instr (cpu), 11, 8); | |
12817 | + unsigned sys_op2 = uimm (aarch64_get_instr (cpu), 7, 5); | |
12818 | + unsigned rt = uimm (aarch64_get_instr (cpu), 4, 0); | |
12819 | + | |
12820 | + aarch64_set_reg_u64 (cpu, rt, NO_SP, | |
12821 | + system_get (cpu, sys_op0, sys_op1, sys_crn, sys_crm, sys_op2)); | |
12822 | +} | |
12823 | + | |
12786 | 12824 | static void |
12787 | 12825 | dexSystem (sim_cpu *cpu) |
12788 | 12826 | { |
@@ -12842,9 +12880,7 @@ dexSystem (sim_cpu *cpu) | ||
12842 | 12880 | |
12843 | 12881 | switch (op2) |
12844 | 12882 | { |
12845 | - case 2: | |
12846 | - HALT_NYI; | |
12847 | - | |
12883 | + case 2: HALT_NYI; | |
12848 | 12884 | case 4: dsb (cpu); return; |
12849 | 12885 | case 5: dmb (cpu); return; |
12850 | 12886 | case 6: isb (cpu); return; |
@@ -12855,25 +12891,25 @@ dexSystem (sim_cpu *cpu) | ||
12855 | 12891 | |
12856 | 12892 | case 0x3B0: |
12857 | 12893 | /* MRS Wt, sys-reg. */ |
12858 | - /* FIXME: Ignore for now. */ | |
12894 | + do_mrs (cpu); | |
12859 | 12895 | return; |
12860 | 12896 | |
12861 | 12897 | case 0x3B4: |
12862 | 12898 | case 0x3BD: |
12863 | 12899 | /* MRS Xt, sys-reg. */ |
12864 | - /* FIXME: Ignore for now. */ | |
12900 | + do_mrs (cpu); | |
12865 | 12901 | return; |
12866 | 12902 | |
12867 | 12903 | case 0x0B7: |
12868 | 12904 | /* DC <type>, x<n>. */ |
12869 | - /* FIXME: Ignore for now. */ | |
12905 | + HALT_NYI; | |
12870 | 12906 | return; |
12871 | 12907 | |
12872 | 12908 | default: |
12873 | - if (uimm (aarch64_get_instr (cpu), 21, 20) == 0x1) | |
12874 | - /* MSR <sys-reg>, <Xreg>. */ | |
12875 | - return; | |
12909 | + /* if (uimm (aarch64_get_instr (cpu), 21, 20) == 0x1) | |
12910 | + MRS Xt, sys-reg. */ | |
12876 | 12911 | HALT_NYI; |
12912 | + return; | |
12877 | 12913 | } |
12878 | 12914 | } |
12879 | 12915 |