diff --git a/tests/misc/head.S b/tests/misc/head.S index 9eb752c..b0acb7f 100644 --- a/tests/misc/head.S +++ b/tests/misc/head.S @@ -16,6 +16,7 @@ */ #define STACK_TOP 0x2000 +#define PVR 287 /* Load an immediate 64-bit value into a register */ #define LOAD_IMM64(r, e) \ @@ -100,3 +101,39 @@ test_addpcis_2: blr +/* Test reading the PVR */ +.global test_mfpvr +test_mfpvr: + mflr %r0 + std %r0, 16(%r1) + stdu %r1, -32(%r1) + + /* + * If r3 happened to already contain PVR_MICROWATT the test + * would succeed even if the PVR is not implemented. + */ + LOAD_IMM64(%r3, 0xdeadbeef) + mfpvr %r3 + + addi %r1, %r1, 32 + ld %r0, 16(%r1) + mtlr %r0 + + blr + +/* Test writing the PVR does nothing */ +.global test_mtpvr +test_mtpvr: + mflr %r0 + std %r0, 16(%r1) + stdu %r1, -32(%r1) + + LOAD_IMM64(%r3, 0xdeadbeef) + mtspr PVR, %r3 + mfpvr %r3 + + addi %r1, %r1, 32 + ld %r0, 16(%r1) + mtlr %r0 + + blr diff --git a/tests/misc/misc.c b/tests/misc/misc.c index f96203e..283ca7f 100644 --- a/tests/misc/misc.c +++ b/tests/misc/misc.c @@ -8,8 +8,12 @@ #define PASS "PASS\n" #define FAIL "FAIL\n" +#define PVR_MICROWATT 0x00630000 + extern long test_addpcis_1(void); extern long test_addpcis_2(void); +extern long test_mfpvr(void); +extern long test_mtpvr(void); // i < 100 void print_test_number(int i) @@ -40,5 +44,19 @@ int main(void) } else puts(PASS); + print_test_number(3); + if (test_mfpvr() != PVR_MICROWATT) { + fail = 1; + puts(FAIL); + } else + puts(PASS); + + print_test_number(4); + if (test_mtpvr() != PVR_MICROWATT) { + fail = 1; + puts(FAIL); + } else + puts(PASS); + return fail; } diff --git a/tests/privileged/privileged.c b/tests/privileged/privileged.c index 154e9b4..68e30bc 100644 --- a/tests/privileged/privileged.c +++ b/tests/privileged/privileged.c @@ -15,6 +15,7 @@ extern int call_with_msr(unsigned long arg, int (*fn)(unsigned long), unsigned l #define SRR1 27 #define PID 48 #define PRTBL 720 +#define PVR 287 static inline unsigned long mfspr(int sprnum) { @@ -186,6 +187,20 @@ int priv_fn_6(unsigned long x) return 0; } +int priv_fn_7(unsigned long x) +{ + mfspr(PVR); + __asm__ volatile("sc"); + return 0; +} + +int priv_fn_8(unsigned long x) +{ + mtspr(PVR, x); + __asm__ volatile("sc"); + return 0; +} + int priv_test(int (*fn)(unsigned long)) { unsigned long msr; @@ -239,6 +254,8 @@ int main(void) do_test(4, priv_fn_4); do_test(5, priv_fn_5); do_test(6, priv_fn_6); + do_test(7, priv_fn_7); + do_test(8, priv_fn_8); return fail; } diff --git a/tests/test_misc.bin b/tests/test_misc.bin index f080480..7e68e1c 100755 Binary files a/tests/test_misc.bin and b/tests/test_misc.bin differ diff --git a/tests/test_misc.console_out b/tests/test_misc.console_out index 9b718c5..2ff5a99 100644 --- a/tests/test_misc.console_out +++ b/tests/test_misc.console_out @@ -1,2 +1,4 @@ Test 01:PASS Test 02:PASS +Test 03:PASS +Test 04:PASS diff --git a/tests/test_privileged.bin b/tests/test_privileged.bin index e030f08..d89b34d 100755 Binary files a/tests/test_privileged.bin and b/tests/test_privileged.bin differ diff --git a/tests/test_privileged.console_out b/tests/test_privileged.console_out index a49bb9b..25e791c 100644 --- a/tests/test_privileged.console_out +++ b/tests/test_privileged.console_out @@ -4,3 +4,5 @@ test 03:PASS test 04:PASS test 05:PASS test 06:PASS +test 07:PASS +test 08:PASS