reg_access_test.c 674 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. SKIP_IF(!ebb_is_supported());
  17. expected = 0x8000000100000000ull;
  18. mtspr(SPRN_BESCR, expected);
  19. val = mfspr(SPRN_BESCR);
  20. FAIL_IF(val != expected);
  21. expected = 0x0000000001000000ull;
  22. mtspr(SPRN_EBBHR, expected);
  23. val = mfspr(SPRN_EBBHR);
  24. FAIL_IF(val != expected);
  25. return 0;
  26. }
  27. int main(void)
  28. {
  29. return test_harness(reg_access, "reg_access");
  30. }