home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / c / gcc233.lha / os-include / inline / battmem.h < prev    next >
C/C++ Source or Header  |  1992-12-29  |  2KB  |  78 lines

  1. #ifndef _INLINE_BATTMEM_H
  2. #define _INLINE_BATTMEM_H
  3.  
  4. #include <sys/cdefs.h>
  5. #include <inline/stubs.h>
  6.  
  7. __BEGIN_DECLS
  8.  
  9. #ifndef BASE_EXT_DECL
  10. #define BASE_EXT_DECL extern struct BattMemBase*  BattMemBase;
  11. #endif
  12. #ifndef BASE_PAR_DECL
  13. #define BASE_PAR_DECL
  14. #define BASE_PAR_DECL0 void
  15. #endif
  16. #ifndef BASE_NAME
  17. #define BASE_NAME BattMemBase
  18. #endif
  19.  
  20. static __inline void 
  21. ObtainBattSemaphore (BASE_PAR_DECL0)
  22. {
  23.   BASE_EXT_DECL
  24.   register struct BattMemBase* a6 __asm("a6") = BASE_NAME;
  25.   __asm __volatile ("jsr a6@(-0x6)"
  26.   : /* no output */
  27.   : "r" (a6)
  28.   : "a0","a1","d0","d1", "memory");
  29. }
  30. static __inline ULONG 
  31. ReadBattMem (BASE_PAR_DECL APTR buffer,unsigned long offset,unsigned long length)
  32. {
  33.   BASE_EXT_DECL
  34.   register ULONG  _res  __asm("d0");
  35.   register struct BattMemBase* a6 __asm("a6") = BASE_NAME;
  36.   register APTR a0 __asm("a0") = buffer;
  37.   register unsigned long d0 __asm("d0") = offset;
  38.   register unsigned long d1 __asm("d1") = length;
  39.   __asm __volatile ("jsr a6@(-0x12)"
  40.   : "=r" (_res)
  41.   : "r" (a6), "r" (a0), "r" (d0), "r" (d1)
  42.   : "a0","a1","d0","d1", "memory");
  43.   return _res;
  44. }
  45. static __inline void 
  46. ReleaseBattSemaphore (BASE_PAR_DECL0)
  47. {
  48.   BASE_EXT_DECL
  49.   register struct BattMemBase* a6 __asm("a6") = BASE_NAME;
  50.   __asm __volatile ("jsr a6@(-0xc)"
  51.   : /* no output */
  52.   : "r" (a6)
  53.   : "a0","a1","d0","d1", "memory");
  54. }
  55. static __inline ULONG 
  56. WriteBattMem (BASE_PAR_DECL APTR buffer,unsigned long offset,unsigned long length)
  57. {
  58.   BASE_EXT_DECL
  59.   register ULONG  _res  __asm("d0");
  60.   register struct BattMemBase* a6 __asm("a6") = BASE_NAME;
  61.   register APTR a0 __asm("a0") = buffer;
  62.   register unsigned long d0 __asm("d0") = offset;
  63.   register unsigned long d1 __asm("d1") = length;
  64.   __asm __volatile ("jsr a6@(-0x18)"
  65.   : "=r" (_res)
  66.   : "r" (a6), "r" (a0), "r" (d0), "r" (d1)
  67.   : "a0","a1","d0","d1", "memory");
  68.   return _res;
  69. }
  70. #undef BASE_EXT_DECL
  71. #undef BASE_PAR_DECL
  72. #undef BASE_PAR_DECL0
  73. #undef BASE_NAME
  74.  
  75. __END_DECLS
  76.  
  77. #endif /* _INLINE_BATTMEM_H */
  78.