privinst.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Copyright (C) 1996 Paul Mackerras.
  3.  *
  4.  *      This program is free software; you can redistribute it and/or
  5.  *      modify it under the terms of the GNU General Public License
  6.  *      as published by the Free Software Foundation; either version
  7.  *      2 of the License, or (at your option) any later version.
  8.  */
  9. #define GETREG(reg)
  10.     static inline unsigned long get_ ## reg (void)
  11. { unsigned long ret; asm volatile ("mf" #reg " %0" : "=r" (ret) :); return ret; }
  12. #define SETREG(reg)
  13.     static inline void set_ ## reg (unsigned long val)
  14. { asm volatile ("mt" #reg " %0" : : "r" (val)); }
  15. GETREG(msr)
  16. SETREG(msrd)
  17. GETREG(cr)
  18. #define GSETSPR(n, name)
  19.     static inline long get_ ## name (void) 
  20. { long ret; asm volatile ("mfspr %0," #n : "=r" (ret) : ); return ret; } 
  21.     static inline void set_ ## name (long val) 
  22. { asm volatile ("mtspr " #n ",%0" : : "r" (val)); }
  23. GSETSPR(0, mq)
  24. GSETSPR(1, xer)
  25. GSETSPR(4, rtcu)
  26. GSETSPR(5, rtcl)
  27. GSETSPR(8, lr)
  28. GSETSPR(9, ctr)
  29. GSETSPR(18, dsisr)
  30. GSETSPR(19, dar)
  31. GSETSPR(22, dec)
  32. GSETSPR(25, sdr1)
  33. GSETSPR(26, srr0)
  34. GSETSPR(27, srr1)
  35. GSETSPR(272, sprg0)
  36. GSETSPR(273, sprg1)
  37. GSETSPR(274, sprg2)
  38. GSETSPR(275, sprg3)
  39. GSETSPR(282, ear)
  40. GSETSPR(287, pvr)
  41. GSETSPR(528, bat0u)
  42. GSETSPR(529, bat0l)
  43. GSETSPR(530, bat1u)
  44. GSETSPR(531, bat1l)
  45. GSETSPR(532, bat2u)
  46. GSETSPR(533, bat2l)
  47. GSETSPR(534, bat3u)
  48. GSETSPR(535, bat3l)
  49. GSETSPR(1008, hid0)
  50. GSETSPR(1009, hid1)
  51. GSETSPR(1010, iabr)
  52. GSETSPR(1013, dabr)
  53. GSETSPR(1023, pir)
  54. static inline int get_sr(int n)
  55. {
  56. int ret;
  57. #if 0
  58. // DRENG does not assemble 
  59. asm (" mfsrin %0,%1" : "=r" (ret) : "r" (n << 28));
  60. #endif
  61. return ret;
  62. }
  63. static inline void set_sr(int n, int val)
  64. {
  65. #if 0
  66. // DRENG does not assemble 
  67. asm ("mtsrin %0,%1" : : "r" (val), "r" (n << 28));
  68. #endif
  69. }
  70. static inline void store_inst(void *p)
  71. {
  72. asm volatile ("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r" (p));
  73. }
  74. static inline void cflush(void *p)
  75. {
  76. asm volatile ("dcbf 0,%0; icbi 0,%0" : : "r" (p));
  77. }
  78. static inline void cinval(void *p)
  79. {
  80. asm volatile ("dcbi 0,%0; icbi 0,%0" : : "r" (p));
  81. }