1 from openpower
.simulator
.program
import Program
2 from openpower
.decoder
.isa
.all
import ISA
3 from openpower
.endian
import bigendian
4 from openpower
.consts
import MSR
7 from openpower
.test
.common
import TestAccumulatorBase
, skip_case
11 class SPRTestCase(TestAccumulatorBase
):
13 def case_1_mfspr(self
):
14 lst
= ["mfspr 1, 26", # SRR0
18 initial_regs
= [0] * 32
19 initial_sprs
= {'SRR0': 0x12345678, 'SRR1': 0x5678, 'LR': 0x1234,
21 self
.add_case(Program(lst
, bigendian
),
22 initial_regs
, initial_sprs
)
24 def case_1_mtspr(self
):
25 lst
= ["mtspr 26, 1", # SRR0
29 initial_regs
= [0] * 32
30 initial_regs
[1] = 0x129518230011feed
31 initial_regs
[2] = 0x123518230011feed
32 initial_regs
[3] = 0xe00c0000
33 initial_regs
[4] = 0x1010101010101010
34 initial_sprs
= {'SRR0': 0x12345678, 'SRR1': 0x5678, 'LR': 0x1234,
36 self
.add_case(Program(lst
, bigendian
),
37 initial_regs
, initial_sprs
)
39 def case_2_mtspr_mfspr(self
):
40 lst
= ["mtspr 26, 1", # SRR0
45 "mfspr 3, 27", # and into reg 2
48 initial_regs
= [0] * 32
49 initial_regs
[1] = 0x129518230011feed
50 initial_regs
[2] = 0x123518230011feed
51 initial_regs
[3] = 0xe00c0000
52 initial_regs
[4] = 0x1010101010101010
53 initial_sprs
= {'SRR0': 0x12345678, 'SRR1': 0x5678, 'LR': 0x1234,
55 self
.add_case(Program(lst
, bigendian
),
56 initial_regs
, initial_sprs
)
59 @skip_case("spr does not have TRAP in it. has to be done another way")
60 def case_3_mtspr_priv(self
):
61 lst
= ["mtspr 26, 1", # SRR0
65 initial_regs
= [0] * 32
66 initial_regs
[1] = 0x129518230011feed
67 initial_regs
[2] = 0x123518230011feed
68 initial_regs
[3] = 0xe00c0000
69 initial_regs
[4] = 0x1010101010101010
70 initial_sprs
= {'SRR0': 0x12345678, 'SRR1': 0x5678, 'LR': 0x1234,
73 self
.add_case(Program(lst
, bigendian
),
74 initial_regs
, initial_sprs
, initial_msr
=msr
)
76 def case_4_mfspr_slow(self
):
77 lst
= ["mfspr 1, 272", # SPRG0
78 "mfspr 4, 273", ] # SPRG1
79 initial_regs
= [0] * 32
80 initial_sprs
= {'SPRG0_priv': 0x12345678, 'SPRG1_priv': 0x5678,
82 self
.add_case(Program(lst
, bigendian
),
83 initial_regs
, initial_sprs
)
85 def case_5_mtspr(self
):
86 lst
= ["mtspr 272, 1", # SPRG0
87 "mtspr 273, 2", # SPRG1
89 initial_regs
= [0] * 32
90 initial_regs
[1] = 0x129518230011feed
91 initial_regs
[2] = 0x123518230011fee0
92 initial_sprs
= {'SPRG0_priv': 0x12345678, 'SPRG1_priv': 0x5678,
94 self
.add_case(Program(lst
, bigendian
),
95 initial_regs
, initial_sprs
)
97 def case_6_set_tb(self
):
98 lst
= [ "mtspr 268, 2", # TB
105 initial_regs
= [0] * 32
106 initial_regs
[1] = 0x129518230011feed
107 initial_regs
[2] = 0x123518230011fee0
108 initial_sprs
= {'TB': 0x12345678,
110 self
.add_case(Program(lst
, bigendian
),
111 initial_regs
, initial_sprs
)