reg_access_test.c 642 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright 2014, Michael Ellerman, IBM Corp.
  3. * Licensed under GPLv2.
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include "ebb.h"
  8. #include "reg.h"
  9. /*
  10. * Test basic access to the EBB regs, they should be user accessible with no
  11. * kernel interaction required.
  12. */
  13. int reg_access(void)
  14. {
  15. uint64_t val, expected;
  16. expected = 0x8000000100000000ull;
  17. mtspr(SPRN_BESCR, expected);
  18. val = mfspr(SPRN_BESCR);
  19. FAIL_IF(val != expected);
  20. expected = 0x0000000001000000ull;
  21. mtspr(SPRN_EBBHR, expected);
  22. val = mfspr(SPRN_EBBHR);
  23. FAIL_IF(val != expected);
  24. return 0;
  25. }
  26. int main(void)
  27. {
  28. return test_harness(reg_access, "reg_access");
  29. }