2 * Copyright 2016, Jack Miller, IBM Corp.
3 * Licensed under GPLv2.
12 #define SIZE (32 * 1024 * 1024) /* 32M */
13 #define LM_SIZE 0 /* Smallest encoding, 32M */
15 #define SECTIONS 64 /* 1 per bit in LMSER */
16 #define SECTION_SIZE (SIZE / SECTIONS)
17 #define SECTION_LONGS (SECTION_SIZE / sizeof(long))
19 static unsigned long *test_mem
;
21 static int lmr_count
= 0;
23 void ebb_lmr_handler(void)
28 void ldmx_full_section(unsigned long *mem
, int section
)
33 for (i
= 0; i
< SECTION_LONGS
; i
++) {
34 ptr
= &mem
[(SECTION_LONGS
* section
) + i
];
35 ldmx((unsigned long) &ptr
);
40 unsigned long section_masks
[] = {
50 int ebb_lmr_section_test(unsigned long *mem
)
52 unsigned long *mask
= section_masks
;
55 for (; *mask
; mask
++) {
56 mtspr(SPRN_LMSER
, *mask
);
57 printf("Testing mask 0x%016lx\n", mfspr(SPRN_LMSER
));
59 for (i
= 0; i
< 64; i
++) {
61 ldmx_full_section(mem
, i
);
62 if (*mask
& (1UL << (63 - i
)))
63 FAIL_IF(lmr_count
!= SECTION_LONGS
);
76 SKIP_IF(!lmr_is_supported());
78 setup_ebb_handler(ebb_lmr_handler
);
82 FAIL_IF(posix_memalign((void **)&test_mem
, SIZE
, SIZE
) != 0);
86 FAIL_IF(mfspr(SPRN_LMSER
) != 0);
88 mtspr(SPRN_LMRR
, ((unsigned long)test_mem
| LM_SIZE
));
90 FAIL_IF(mfspr(SPRN_LMRR
) != ((unsigned long)test_mem
| LM_SIZE
));
92 /* Read every single byte to ensure we get no false positives */
93 for (i
= 0; i
< SECTIONS
; i
++)
94 ldmx_full_section(test_mem
, i
);
96 FAIL_IF(lmr_count
!= 0);
98 /* Turn on the first section */
100 mtspr(SPRN_LMSER
, (1UL << 63));
101 FAIL_IF(mfspr(SPRN_LMSER
) != (1UL << 63));
103 /* Enable LM (BESCR) */
105 mtspr(SPRN_BESCR
, mfspr(SPRN_BESCR
) | BESCR_LME
);
106 FAIL_IF(!(mfspr(SPRN_BESCR
) & BESCR_LME
));
108 ldmx((unsigned long)&test_mem
);
110 FAIL_IF(lmr_count
!= 1); // exactly one exception
111 FAIL_IF(mfspr(SPRN_BESCR
) & BESCR_LME
); // LM now disabled
112 FAIL_IF(!(mfspr(SPRN_BESCR
) & BESCR_LMEO
)); // occurred bit set
114 printf("Simple LMR EBB OK\n");
116 /* This shouldn't cause an EBB since it's been disabled */
117 ldmx((unsigned long)&test_mem
);
118 FAIL_IF(lmr_count
!= 1);
120 printf("LMR disable on EBB OK\n");
124 /* This should cause an EBB or reset is broken */
125 ldmx((unsigned long)&test_mem
);
126 FAIL_IF(lmr_count
!= 2);
128 printf("LMR reset EBB OK\n");
132 return ebb_lmr_section_test(test_mem
);
137 int ret
= test_harness(ebb_lmr
, "ebb_lmr");
This page took 0.04616 seconds and 5 git commands to generate.