arm.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*****************************************************************
  2. * arm.h
  3. * by Zhiyi Huang, [email protected]
  4. * University of Otago
  5. *
  6. ********************************************************************/
  7. #define PSR_MODE_USR 0x00000010
  8. #define PSR_MODE_FIQ 0x00000011
  9. #define PSR_MODE_IRQ 0x00000012
  10. #define PSR_MODE_SVC 0x00000013
  11. #define PSR_MODE_MON 0x00000016
  12. #define PSR_MODE_ABT 0x00000017
  13. #define PSR_MODE_UND 0x0000001B
  14. #define PSR_MODE_SYS 0x0000001F
  15. #define PSR_MASK 0x0000001F
  16. #define USER_MODE 0x0
  17. #define PSR_DISABLE_IRQ 0x00000080
  18. #define PSR_DISABLE_FIQ 0x00000040
  19. #define PSR_V 0x10000000
  20. #define PSR_C 0x20000000
  21. #define PSR_Z 0x40000000
  22. #define PSR_N 0x80000000
  23. static inline uint
  24. inw(uint addr)
  25. {
  26. uint data;
  27. asm volatile("ldr %0,[%1]" : "=r"(data) : "r"(addr));
  28. return data;
  29. }
  30. static inline void
  31. outw(uint addr, uint data)
  32. {
  33. asm volatile("str %1,[%0]" : : "r"(addr), "r"(data));
  34. }
  35. // Layout of the trap frame built on the stack
  36. // by exception.s, and passed to trap().
  37. struct trapframe {
  38. uint sp; // user mode sp
  39. uint r0;
  40. uint r1;
  41. uint r2;
  42. uint r3;
  43. uint r4;
  44. uint r5;
  45. uint r6;
  46. uint r7;
  47. uint r8;
  48. uint r9;
  49. uint r10;
  50. uint r11;
  51. uint r12;
  52. uint r13;
  53. uint r14;
  54. uint trapno;
  55. uint ifar; // Instruction Fault Address Register (IFAR)
  56. uint cpsr;
  57. uint spsr; // saved cpsr from the trapped/interrupted mode
  58. uint pc; // return address of the interrupted code
  59. };