Subversion Repositories Kolibri OS

Rev

Rev 808 | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. #define OS_BASE   0x80000000
  3.  
  4. #include "xmd.h"
  5.  
  6. #define NULL (void*)(0)
  7.  
  8. #define FALSE   0
  9. #define TRUE    1
  10.  
  11. typedef void *pointer;
  12.  
  13. typedef unsigned int   Bool;
  14.  
  15. typedef unsigned char  u8;
  16. typedef unsigned short u16;
  17. typedef unsigned int   u32;
  18.  
  19. typedef unsigned char   u8_t;
  20. typedef unsigned short u16_t;
  21. typedef unsigned int   u32_t;
  22.  
  23. typedef unsigned int memType;
  24. typedef unsigned int size_t;
  25.  
  26. typedef struct { float hi, lo; } range;
  27.  
  28. typedef struct
  29. {
  30.   unsigned      handle;
  31.   unsigned      io_code;
  32.   void          *input;
  33.   int           inp_size;
  34.   void          *output;
  35.   int           out_size;
  36. }ioctl_t;
  37.  
  38. typedef int (_stdcall *srv_proc_t)(ioctl_t *);
  39.  
  40. u32 __stdcall drvEntry(int)__asm__("_drvEntry");
  41.  
  42. ///////////////////////////////////////////////////////////////////////////////
  43.  
  44. #define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport))
  45. #define IMPORT __attribute__ ((dllimport))
  46.  
  47. ///////////////////////////////////////////////////////////////////////////////
  48.  
  49. #define PG_SW       0x003
  50. #define PG_NOCACHE  0x018
  51.  
  52. CARD32 STDCALL AllocKernelSpace(unsigned size)__asm__("AllocKernelSpace");
  53. void*  STDCALL KernelAlloc(unsigned size)__asm__("KernelAlloc");
  54. int KernelFree(void *);
  55.  
  56. void* STDCALL CreateRingBuffer(size_t size, u32 map)__asm__("CreateRingBuffer");
  57.  
  58. u32 STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService");
  59.  
  60. //void *CreateObject(u32 pid, size_t size);
  61. //void *DestroyObject(void *obj);
  62.  
  63. CARD32 STDCALL MapIoMem(CARD32 Base,CARD32 size,CARD32 flags)__asm__("MapIoMem");
  64.  
  65. static inline u32 GetPgAddr(void *mem)
  66. {
  67.   u32 retval;
  68.  
  69.         asm volatile (
  70.     "call *__imp__GetPgAddr \n\t"
  71.     :"=eax" (retval)
  72.     :"a" (mem)
  73.         );
  74.   return retval;
  75. }
  76.  
  77. ///////////////////////////////////////////////////////////////////////////////
  78.  
  79. u32 PciApi(int cmd);
  80.  
  81. u8  STDCALL PciRead8 (u32 bus, u32 devfn, u32 reg)__asm__("PciRead8");
  82. u16 STDCALL PciRead16(u32 bus, u32 devfn, u32 reg)__asm__("PciRead16");
  83. u32 STDCALL PciRead32(u32 bus, u32 devfn, u32 reg)__asm__("PciRead32");
  84.  
  85. u32 STDCALL PciWrite8 (u32 bus, u32 devfn, u32 reg,u8 val) __asm__("PciWrite8");
  86. u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16");
  87. u32 STDCALL PciWrite32(u32 bus, u32 devfn, u32 reg,u32 val)__asm__("PciWrite32");
  88.  
  89. ///////////////////////////////////////////////////////////////////////////////
  90.  
  91. #define SysMsgBoardStr  __SysMsgBoardStr
  92. #define PciApi          __PciApi
  93. //#define RegService      __RegService
  94. #define CreateObject    __CreateObject
  95. #define DestroyObject   __DestroyObject
  96.  
  97. ///////////////////////////////////////////////////////////////////////////////
  98.  
  99. void *malloc(size_t);
  100. void *calloc( size_t num, size_t size );
  101. void *realloc(void*, size_t);
  102. void free(void*);
  103.  
  104. #define kmalloc malloc
  105. #define kfree   free
  106.  
  107. ///////////////////////////////////////////////////////////////////////////////
  108.  
  109. int memcmp(const void *s1, const void *s2, size_t n);
  110. void * memcpy(void * _dest, const void *_src, size_t _n);
  111. char * strcpy(char *to, const char *from);
  112. char * strcat(char *s, const char *append);
  113. int strcmp(const char *s1, const char *s2);
  114. size_t strlen(const char *str);
  115. char * strdup(const char *_s);
  116. char * strchr(const char *s, int c);
  117.  
  118. ///////////////////////////////////////////////////////////////////////////////
  119.  
  120. int snprintf(char *s, size_t n, const char *format, ...);
  121. int printf(const char* format, ...);
  122. int dbg_open(char *path);
  123. int dbgprintf(const char* format, ...);
  124.  
  125. ///////////////////////////////////////////////////////////////////////////////
  126.  
  127.  
  128. void usleep(u32 delay);
  129.  
  130. static int __attribute__ ((always_inline))
  131. abs (int i)
  132. {
  133.   return i < 0 ? -i : i;
  134. };
  135.  
  136. static void __attribute__ ((always_inline))
  137. __clear (void * dst, unsigned len)
  138. { u32 tmp;
  139.   asm __volatile__
  140.   (
  141.     "xorl %%eax, %%eax \n\t"
  142.     "cld \n\t"
  143.     "rep stosb \n"
  144.     :"=c"(tmp),"=D"(tmp)
  145.     :"c"(len),"D"(dst)
  146.     :"memory","eax","cc"
  147.   );
  148. };
  149.  
  150.  
  151. static inline u32 safe_cli(void)
  152. {
  153.   u32 tmp;
  154.         asm volatile (
  155.                 "pushf\n\t"
  156.                 "popl %0\n\t"
  157.                 "cli\n"
  158.     : "=r" (tmp)
  159.         );
  160.   return tmp;
  161. }
  162.  
  163. static inline void safe_sti(u32 ipl)
  164. {
  165.         asm volatile (
  166.                 "pushl %0\n\t"
  167.                 "popf\n"
  168.                 : : "r" (ipl)
  169.         );
  170. }
  171.  
  172. ///////////////////////////////////////////////////////////////////////////////
  173.  
  174. int _stdcall srv_cursor(ioctl_t *io);
  175. int _stdcall srv_2d(ioctl_t *io);
  176.  
  177.  
  178.