Subversion Repositories Kolibri OS

Rev

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