Subversion Repositories Kolibri OS

Rev

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