Rev 1613 | Rev 1630 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1613 | Rev 1616 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef __SYSCALL_H__ |
1 | #ifndef __SYSCALL_H__ |
2 | #define __SYSCALL_H__ |
2 | #define __SYSCALL_H__ |
Line 3... | Line -... | ||
3 | - | ||
4 | - | ||
5 | #define OS_BASE 0x80000000 |
- | |
6 | - | ||
7 | typedef struct |
- | |
8 | { |
- | |
9 | u32_t code; |
- | |
10 | u32_t data[5]; |
- | |
11 | }kevent_t; |
- | |
12 | - | ||
13 | typedef struct |
- | |
14 | { |
- | |
15 | u32_t handle; |
- | |
16 | u32_t io_code; |
- | |
17 | void *input; |
- | |
18 | int inp_size; |
- | |
19 | void *output; |
- | |
20 | int out_size; |
- | |
21 | }ioctl_t; |
- | |
22 | - | ||
23 | typedef int (__stdcall *srv_proc_t)(ioctl_t *); |
- | |
24 | - | ||
25 | #define ERR_OK 0 |
- | |
26 | #define ERR_PARAM -1 |
- | |
27 | - | ||
28 | - | ||
29 | u32_t drvEntry(int, char *)__asm__("_drvEntry"); |
- | |
30 | 3 | ||
Line 31... | Line 4... | ||
31 | /////////////////////////////////////////////////////////////////////////////// |
4 | /////////////////////////////////////////////////////////////////////////////// |
32 | 5 | ||
Line 38... | Line 11... | ||
38 | /////////////////////////////////////////////////////////////////////////////// |
11 | /////////////////////////////////////////////////////////////////////////////// |
Line 39... | Line 12... | ||
39 | 12 | ||
40 | #define SysMsgBoardStr __SysMsgBoardStr |
13 | #define SysMsgBoardStr __SysMsgBoardStr |
41 | #define PciApi __PciApi |
- | |
42 | //#define RegService __RegService |
14 | #define PciApi __PciApi |
43 | #define CreateObject __CreateObject |
15 | #define CreateObject __CreateObject |
Line 44... | Line 16... | ||
44 | #define DestroyObject __DestroyObject |
16 | #define DestroyObject __DestroyObject |
Line 45... | Line -... | ||
45 | - | ||
46 | /////////////////////////////////////////////////////////////////////////////// |
- | |
Line 47... | Line 17... | ||
47 | 17 | ||
48 | #define PG_SW 0x003 |
18 | /////////////////////////////////////////////////////////////////////////////// |
49 | #define PG_NOCACHE 0x018 |
19 | |
50 | 20 | ||
Line 57... | Line 27... | ||
57 | int STDCALL UserFree(void *mem)__asm__("UserFree"); |
27 | int STDCALL UserFree(void *mem)__asm__("UserFree"); |
58 | 28 | ||
Line 59... | Line 29... | ||
59 | void* STDCALL GetDisplay(void)__asm__("GetDisplay"); |
29 | void* STDCALL GetDisplay(void)__asm__("GetDisplay"); |
Line -... | Line 30... | ||
- | 30 | ||
Line 60... | Line 31... | ||
60 | 31 | u32_t IMPORT GetTimerTicks(void)__asm__("GetTimerTicks"); |
|
61 | 32 | ||
Line 62... | Line 33... | ||
62 | addr_t STDCALL AllocPage(void)__asm__("AllocPage"); |
33 | addr_t STDCALL AllocPage(void)__asm__("AllocPage"); |
Line 76... | Line 47... | ||
76 | 47 | ||
Line 77... | Line 48... | ||
77 | void STDCALL SetMouseData(int btn, int x, int y, |
48 | void STDCALL SetMouseData(int btn, int x, int y, |
78 | int z, int h)__asm__("SetMouseData"); |
49 | int z, int h)__asm__("SetMouseData"); |
Line 79... | Line -... | ||
79 | - | ||
80 | static u32_t PciApi(int cmd); |
- | |
81 | 50 | ||
82 | u8_t STDCALL PciRead8 (u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead8"); |
51 | u8_t STDCALL PciRead8 (u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead8"); |
83 | u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16"); |
52 | u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16"); |
Line 84... | Line 53... | ||
84 | u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32"); |
53 | u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32"); |
Line 112... | Line 81... | ||
112 | int dbgprintf(const char* format, ...); |
81 | int dbgprintf(const char* format, ...); |
113 | 82 | ||
Line 114... | Line 83... | ||
114 | /////////////////////////////////////////////////////////////////////////////// |
83 | /////////////////////////////////////////////////////////////////////////////// |
Line 115... | Line -... | ||
115 | - | ||
116 | 84 | ||
117 | static inline u32_t CreateEvent(kevent_t *ev, u32_t flags, u32_t *uid) |
85 | static inline evhandle_t CreateEvent(kevent_t *ev, u32_t flags) |
118 | { |
- | |
119 | u32_t handle; |
86 | { |
Line 120... | Line 87... | ||
120 | u32_t euid; |
87 | evhandle_t evh; |
121 | 88 | ||
122 | __asm__ __volatile__ ( |
89 | __asm__ __volatile__ ( |
123 | "call *__imp__CreateEvent" |
90 | "call *__imp__CreateEvent" |
- | 91 | :"=A"(evh.raw) |
|
- | 92 | :"S" (ev), "c"(flags) |
|
- | 93 | :"memory"); |
|
- | 94 | __asm__ __volatile__ ("":::"ebx","ecx", "esi", "edi"); |
|
- | 95 | ||
- | 96 | return evh; |
|
- | 97 | }; |
|
- | 98 | ||
- | 99 | static inline void RaiseEvent(evhandle_t evh, u32_t flags, kevent_t *ev) |
|
- | 100 | { |
|
- | 101 | __asm__ __volatile__ ( |
|
- | 102 | "call *__imp__RaiseEvent" |
|
124 | :"=a"(handle),"=d"(euid) |
103 | ::"a"(evh.handle),"b"(evh.euid),"d"(flags),"S" (ev) |
Line -... | Line 104... | ||
- | 104 | :"memory"); |
|
- | 105 | __asm__ __volatile__ ("":::"ebx","ecx", "esi", "edi"); |
|
- | 106 | ||
- | 107 | }; |
|
- | 108 | ||
- | 109 | static inline void WaitEvent(u32_t handle, u32_t euid) |
|
125 | :"S" (ev), "c"(flags)); |
110 | { |
- | 111 | __asm__ __volatile__ ( |
|
- | 112 | "call *__imp__WaitEvent" |
|
Line -... | Line 113... | ||
- | 113 | ::"a"(handle),"b"(euid)); |
|
- | 114 | __asm__ __volatile__ ("":::"ecx","edx", "esi"); |
|
- | 115 | }; |
|
- | 116 | ||
- | 117 | static inline u32_t GetEvent(kevent_t *ev) |
|
- | 118 | { |
|
- | 119 | u32_t handle; |
|
- | 120 | ||
- | 121 | __asm__ __volatile__ ( |
|
- | 122 | "call *__imp__GetEvent" |
|
126 | __asm__ __volatile__ ("":::"ebx","ecx", "esi", "edi"); |
123 | :"=a"(handle) |
127 | 124 | :"D"(ev) |
|
Line -... | Line 125... | ||
- | 125 | :"memory"); |
|
128 | if(uid) *uid = euid; |
126 | __asm__ __volatile__ ("":::"ebx","ecx","edx", "esi","edi"); |
129 | 127 | return handle; |
|
130 | return handle; |
128 | }; |
Line 131... | Line 129... | ||
131 | }; |
129 | |
Line 236... | Line 234... | ||
236 | { |
234 | { |
237 | u32_t retval; |
235 | u32_t retval; |
238 | 236 | ||
Line 239... | Line 237... | ||
239 | __asm__ __volatile__ ( |
237 | __asm__ __volatile__ ( |
240 | "call *__imp__PciApi" |
238 | "call *__imp__PciApi \n\t" |
- | 239 | "movzxb %%al, %%eax" |
|
241 | :"=a" (retval) |
240 | :"=a" (retval) |
242 | :"a" (cmd) |
241 | :"a" (cmd) |
243 | :"memory"); |
242 | :"ebx","ecx","edx"); |
244 | return retval; |
243 | return retval; |
245 | }; |
244 | }; |
Line 246... | Line 245... | ||
246 | 245 | ||
247 | static inline void* __CreateObject(u32_t pid, size_t size) |
246 | static inline void* __CreateObject(u32_t pid, size_t size) |
Line 292... | Line 291... | ||
292 | : "=r" (ifl)); |
291 | : "=r" (ifl)); |
293 | return ifl; |
292 | return ifl; |
294 | } |
293 | } |
295 | 294 | ||
Line 296... | Line 295... | ||
296 | static inline void safe_sti(u32_t ifl) |
295 | static inline void safe_sti(u32_t efl) |
297 | { |
296 | { |
298 | __asm__ __volatile__ ( |
- | |
299 | "pushl %0\n\t" |
297 | if (efl & (1<<9)) |
300 | "popf\n" |
- | |
301 | : : "r" (ifl) |
298 | __asm__ __volatile__ ("sti"); |
302 | ); |
- | |
303 | } |
299 | } |
Line 304... | Line 300... | ||
304 | 300 | ||
305 | static inline u32_t get_eflags(void) |
301 | static inline u32_t get_eflags(void) |
306 | { |
302 | { |
Line 315... | Line 311... | ||
315 | static inline void __clear (void * dst, unsigned len) |
311 | static inline void __clear (void * dst, unsigned len) |
316 | { |
312 | { |
317 | u32_t tmp; |
313 | u32_t tmp; |
318 | __asm__ __volatile__ ( |
314 | __asm__ __volatile__ ( |
319 | // "xorl %%eax, %%eax \n\t" |
- | |
320 | "cld \n\t" |
315 | "cld \n\t" |
321 | "rep stosb \n" |
316 | "rep stosb \n" |
322 | :"=c"(tmp),"=D"(tmp) |
317 | :"=c"(tmp),"=D"(tmp) |
323 | :"a"(0),"c"(len),"D"(dst)); |
318 | :"a"(0),"c"(len),"D"(dst)); |
324 | __asm__ __volatile__ ("":::"ecx","edi"); |
319 | __asm__ __volatile__ ("":::"ecx","edi"); |
Line 409... | Line 404... | ||
409 | static inline void * |
404 | static inline void * |
410 | pci_alloc_consistent(struct pci_dev *hwdev, size_t size, |
405 | pci_alloc_consistent(struct pci_dev *hwdev, size_t size, |
411 | addr_t *dma_handle) |
406 | addr_t *dma_handle) |
412 | { |
407 | { |
- | 408 | ||
- | 409 | size = (size + 0x7FFF) & ~0x7FFF; |
|
- | 410 | ||
413 | *dma_handle = AllocPages(size >> 12); |
411 | *dma_handle = AllocPages(size >> 12); |
414 | return (void*)MapIoMem(*dma_handle, size, PG_SW+PG_NOCACHE); |
412 | return (void*)MapIoMem(*dma_handle, size, PG_SW+PG_NOCACHE); |
415 | } |
413 | } |
Line 416... | Line 414... | ||
416 | 414 |