Rev 1313 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1313 | Rev 1321 | ||
---|---|---|---|
1 | #ifndef __SYSCALL_H__ |
1 | #ifndef __SYSCALL_H__ |
2 | #define __SYSCALL_H__ |
2 | #define __SYSCALL_H__ |
3 | 3 | ||
4 | 4 | ||
5 | #define OS_BASE 0x80000000 |
5 | #define OS_BASE 0x80000000 |
6 | 6 | ||
7 | typedef struct |
7 | typedef struct |
8 | { |
8 | { |
9 | u32_t handle; |
9 | u32_t handle; |
10 | u32_t io_code; |
10 | u32_t io_code; |
11 | void *input; |
11 | void *input; |
12 | int inp_size; |
12 | int inp_size; |
13 | void *output; |
13 | void *output; |
14 | int out_size; |
14 | int out_size; |
15 | }ioctl_t; |
15 | }ioctl_t; |
16 | 16 | ||
17 | typedef int (__stdcall *srv_proc_t)(ioctl_t *); |
17 | typedef int (__stdcall *srv_proc_t)(ioctl_t *); |
18 | 18 | ||
19 | #define ERR_OK 0 |
19 | #define ERR_OK 0 |
20 | #define ERR_PARAM -1 |
20 | #define ERR_PARAM -1 |
21 | 21 | ||
22 | 22 | ||
23 | u32_t drvEntry(int, char *)__asm__("_drvEntry"); |
23 | u32_t drvEntry(int, char *)__asm__("_drvEntry"); |
24 | 24 | ||
25 | /////////////////////////////////////////////////////////////////////////////// |
25 | /////////////////////////////////////////////////////////////////////////////// |
26 | 26 | ||
27 | #define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport)) |
27 | #define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport)) |
28 | #define IMPORT __attribute__ ((dllimport)) |
28 | #define IMPORT __attribute__ ((dllimport)) |
29 | 29 | ||
30 | /////////////////////////////////////////////////////////////////////////////// |
30 | /////////////////////////////////////////////////////////////////////////////// |
31 | 31 | ||
32 | #define SysMsgBoardStr __SysMsgBoardStr |
32 | #define SysMsgBoardStr __SysMsgBoardStr |
33 | #define PciApi __PciApi |
33 | #define PciApi __PciApi |
34 | //#define RegService __RegService |
34 | //#define RegService __RegService |
35 | #define CreateObject __CreateObject |
35 | #define CreateObject __CreateObject |
36 | #define DestroyObject __DestroyObject |
36 | #define DestroyObject __DestroyObject |
37 | 37 | ||
38 | /////////////////////////////////////////////////////////////////////////////// |
38 | /////////////////////////////////////////////////////////////////////////////// |
39 | 39 | ||
40 | #define PG_SW 0x003 |
40 | #define PG_SW 0x003 |
41 | #define PG_NOCACHE 0x018 |
41 | #define PG_NOCACHE 0x018 |
42 | 42 | ||
43 | void* STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace"); |
43 | void* STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace"); |
44 | void STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace"); |
44 | void STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace"); |
45 | addr_t STDCALL MapIoMem(addr_t base, size_t size, u32_t flags)__asm__("MapIoMem"); |
45 | addr_t STDCALL MapIoMem(addr_t base, size_t size, u32_t flags)__asm__("MapIoMem"); |
46 | void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc"); |
46 | void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc"); |
47 | void* STDCALL KernelFree(void *mem)__asm__("KernelFree"); |
47 | void* STDCALL KernelFree(void *mem)__asm__("KernelFree"); |
48 | void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc"); |
48 | void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc"); |
49 | int STDCALL UserFree(void *mem)__asm__("UserFree"); |
49 | int STDCALL UserFree(void *mem)__asm__("UserFree"); |
50 | 50 | ||
51 | void* STDCALL GetDisplay()__asm__("GetDisplay"); |
51 | void* STDCALL GetDisplay()__asm__("GetDisplay"); |
52 | 52 | ||
53 | 53 | ||
54 | addr_t STDCALL AllocPage()__asm__("AllocPage"); |
54 | addr_t STDCALL AllocPage()__asm__("AllocPage"); |
55 | addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages"); |
55 | addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages"); |
56 | 56 | ||
57 | void* STDCALL CreateRingBuffer(size_t size, u32_t map)__asm__("CreateRingBuffer"); |
57 | void* STDCALL CreateRingBuffer(size_t size, u32_t map)__asm__("CreateRingBuffer"); |
58 | 58 | ||
59 | u32_t STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService"); |
59 | u32_t STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService"); |
60 | 60 | ||
61 | int STDCALL AttachIntHandler(int irq, void *handler, u32_t access) __asm__("AttachIntHandler"); |
61 | int STDCALL AttachIntHandler(int irq, void *handler, u32_t access) __asm__("AttachIntHandler"); |
62 | 62 | ||
63 | 63 | ||
64 | /////////////////////////////////////////////////////////////////////////////// |
64 | /////////////////////////////////////////////////////////////////////////////// |
65 | 65 | ||
66 | void STDCALL SetMouseData(int btn, int x, int y, |
66 | void STDCALL SetMouseData(int btn, int x, int y, |
67 | int z, int h)__asm__("SetMouseData"); |
67 | int z, int h)__asm__("SetMouseData"); |
68 | 68 | ||
69 | static u32_t PciApi(int cmd); |
69 | static u32_t PciApi(int cmd); |
70 | 70 | ||
71 | u8_t STDCALL PciRead8 (u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead8"); |
71 | u8_t STDCALL PciRead8 (u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead8"); |
72 | u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16"); |
72 | u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16"); |
73 | u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32"); |
73 | u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32"); |
74 | 74 | ||
75 | u32_t STDCALL PciWrite8 (u32_t bus, u32_t devfn, u32_t reg,u8_t val) __asm__("PciWrite8"); |
75 | u32_t STDCALL PciWrite8 (u32_t bus, u32_t devfn, u32_t reg,u8_t val) __asm__("PciWrite8"); |
76 | u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16"); |
76 | u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16"); |
77 | u32_t STDCALL PciWrite32(u32_t bus, u32_t devfn, u32_t reg,u32_t val)__asm__("PciWrite32"); |
77 | u32_t STDCALL PciWrite32(u32_t bus, u32_t devfn, u32_t reg,u32_t val)__asm__("PciWrite32"); |
78 | 78 | ||
79 | #define pciReadByte(tag, reg) \ |
79 | #define pciReadByte(tag, reg) \ |
80 | PciRead8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg)) |
80 | PciRead8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg)) |
81 | 81 | ||
82 | #define pciReadWord(tag, reg) \ |
82 | #define pciReadWord(tag, reg) \ |
83 | PciRead16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg)) |
83 | PciRead16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg)) |
84 | 84 | ||
85 | #define pciReadLong(tag, reg) \ |
85 | #define pciReadLong(tag, reg) \ |
86 | PciRead32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg)) |
86 | PciRead32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg)) |
87 | 87 | ||
88 | #define pciWriteByte(tag, reg, val) \ |
88 | #define pciWriteByte(tag, reg, val) \ |
89 | PciWrite8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val)) |
89 | PciWrite8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val)) |
90 | 90 | ||
91 | #define pciWriteWord(tag, reg, val) \ |
91 | #define pciWriteWord(tag, reg, val) \ |
92 | PciWrite16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val)) |
92 | PciWrite16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val)) |
93 | 93 | ||
94 | #define pciWriteLong(tag, reg, val) \ |
94 | #define pciWriteLong(tag, reg, val) \ |
95 | PciWrite32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val)) |
95 | PciWrite32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val)) |
96 | 96 | ||
97 | 97 | ||
98 | /////////////////////////////////////////////////////////////////////////////// |
98 | /////////////////////////////////////////////////////////////////////////////// |
99 | 99 | ||
100 | int dbg_open(char *path); |
100 | int dbg_open(char *path); |
101 | int dbgprintf(const char* format, ...); |
101 | int dbgprintf(const char* format, ...); |
102 | 102 | ||
103 | /////////////////////////////////////////////////////////////////////////////// |
103 | /////////////////////////////////////////////////////////////////////////////// |
104 | 104 | ||
105 | static inline int GetScreenSize() |
105 | static inline int GetScreenSize() |
106 | { |
106 | { |
107 | int retval; |
107 | int retval; |
108 | 108 | ||
109 | asm("int $0x40" |
109 | asm("int $0x40" |
110 | :"=a"(retval) |
110 | :"=a"(retval) |
111 | :"a"(61), "b"(1)); |
111 | :"a"(61), "b"(1)); |
112 | return retval; |
112 | return retval; |
113 | } |
113 | } |
114 | 114 | ||
115 | static inline int GetScreenBpp() |
115 | static inline int GetScreenBpp() |
116 | { |
116 | { |
117 | int retval; |
117 | int retval; |
118 | 118 | ||
119 | asm("int $0x40" |
119 | asm("int $0x40" |
120 | :"=a"(retval) |
120 | :"=a"(retval) |
121 | :"a"(61), "b"(2)); |
121 | :"a"(61), "b"(2)); |
122 | return retval; |
122 | return retval; |
123 | } |
123 | } |
124 | 124 | ||
125 | static inline int GetScreenPitch() |
125 | static inline int GetScreenPitch() |
126 | { |
126 | { |
127 | int retval; |
127 | int retval; |
128 | 128 | ||
129 | asm("int $0x40" |
129 | asm("int $0x40" |
130 | :"=a"(retval) |
130 | :"=a"(retval) |
131 | :"a"(61), "b"(3)); |
131 | :"a"(61), "b"(3)); |
132 | return retval; |
132 | return retval; |
133 | } |
133 | } |
134 | 134 | ||
135 | static inline u32_t GetPgAddr(void *mem) |
135 | static inline u32_t GetPgAddr(void *mem) |
136 | { |
136 | { |
137 | u32_t retval; |
137 | u32_t retval; |
138 | 138 | ||
139 | __asm__ __volatile__ ( |
139 | __asm__ __volatile__ ( |
140 | "call *__imp__GetPgAddr \n\t" |
140 | "call *__imp__GetPgAddr \n\t" |
141 | :"=eax" (retval) |
141 | :"=eax" (retval) |
142 | :"a" (mem) ); |
142 | :"a" (mem) ); |
143 | return retval; |
143 | return retval; |
144 | }; |
144 | }; |
145 | 145 | ||
146 | static inline void CommitPages(void *mem, u32_t page, u32_t size) |
146 | static inline void CommitPages(void *mem, u32_t page, u32_t size) |
147 | { |
147 | { |
148 | size = (size+4095) & ~4095; |
148 | size = (size+4095) & ~4095; |
149 | __asm__ __volatile__ ( |
149 | __asm__ __volatile__ ( |
150 | "call *__imp__CommitPages" |
150 | "call *__imp__CommitPages" |
151 | ::"a" (page), "b"(mem),"c"(size>>12) |
151 | ::"a" (page), "b"(mem),"c"(size>>12) |
152 | :"edx" ); |
152 | :"edx" ); |
153 | __asm__ __volatile__ ("":::"eax","ebx","ecx"); |
153 | __asm__ __volatile__ ("":::"eax","ebx","ecx"); |
154 | }; |
154 | }; |
155 | 155 | ||
156 | static inline void UnmapPages(void *mem, size_t size) |
156 | static inline void UnmapPages(void *mem, size_t size) |
157 | { |
157 | { |
158 | size = (size+4095) & ~4095; |
158 | size = (size+4095) & ~4095; |
159 | __asm__ __volatile__ ( |
159 | __asm__ __volatile__ ( |
160 | "call *__imp__UnmapPages" |
160 | "call *__imp__UnmapPages" |
161 | ::"a" (mem), "c"(size>>12) |
161 | ::"a" (mem), "c"(size>>12) |
162 | :"edx"); |
162 | :"edx"); |
163 | __asm__ __volatile__ ("":::"eax","ecx"); |
163 | __asm__ __volatile__ ("":::"eax","ecx"); |
164 | }; |
164 | }; |
165 | 165 | ||
166 | static inline void usleep(u32_t delay) |
166 | static inline void usleep(u32_t delay) |
167 | { |
167 | { |
168 | if( !delay ) |
168 | if( !delay ) |
169 | delay++; |
169 | delay++; |
170 | delay*= 500; |
170 | delay*= 500; |
171 | 171 | ||
172 | while(delay--) |
172 | while(delay--) |
173 | __asm__ __volatile__( |
173 | __asm__ __volatile__( |
174 | "xorl %%eax, %%eax \n\t" |
174 | "xorl %%eax, %%eax \n\t" |
175 | "cpuid \n\t" |
175 | "cpuid \n\t" |
176 | :::"eax","ebx","ecx","edx"); |
176 | :::"eax","ebx","ecx","edx"); |
177 | }; |
177 | }; |
178 | 178 | ||
179 | static inline void udelay(u32_t delay) |
179 | static inline void udelay(u32_t delay) |
180 | { |
180 | { |
181 | if(!delay) delay++; |
181 | if(!delay) delay++; |
182 | delay*= 500; |
182 | delay*= 500; |
183 | 183 | ||
184 | while(delay--) |
184 | while(delay--) |
185 | { |
185 | { |
186 | __asm__ __volatile__( |
186 | __asm__ __volatile__( |
187 | "xorl %%eax, %%eax \n\t" |
187 | "xorl %%eax, %%eax \n\t" |
188 | "cpuid" |
188 | "cpuid" |
189 | :::"eax","ebx","ecx","edx" ); |
189 | :::"eax","ebx","ecx","edx" ); |
190 | } |
190 | } |
191 | } |
191 | } |
192 | 192 | ||
193 | static inline void mdelay(u32_t time) |
193 | static inline void mdelay(u32_t time) |
194 | { |
194 | { |
195 | time /= 10; |
195 | time /= 10; |
196 | if(!time) time = 1; |
196 | if(!time) time = 1; |
197 | 197 | ||
198 | __asm__ __volatile__ ( |
198 | __asm__ __volatile__ ( |
199 | "call *__imp__Delay" |
199 | "call *__imp__Delay" |
200 | ::"b" (time)); |
200 | ::"b" (time)); |
201 | __asm__ __volatile__ ( |
201 | __asm__ __volatile__ ( |
202 | "":::"ebx"); |
202 | "":::"ebx"); |
203 | 203 | ||
204 | }; |
204 | }; |
205 | 205 | ||
206 | 206 | ||
207 | static inline u32_t __PciApi(int cmd) |
207 | static inline u32_t __PciApi(int cmd) |
208 | { |
208 | { |
209 | u32_t retval; |
209 | u32_t retval; |
210 | 210 | ||
211 | __asm__ __volatile__ ( |
211 | __asm__ __volatile__ ( |
212 | "call *__imp__PciApi" |
212 | "call *__imp__PciApi" |
213 | :"=a" (retval) |
213 | :"=a" (retval) |
214 | :"a" (cmd) |
214 | :"a" (cmd) |
215 | :"memory"); |
215 | :"memory"); |
216 | return retval; |
216 | return retval; |
217 | }; |
217 | }; |
218 | 218 | ||
219 | static inline void* __CreateObject(u32_t pid, size_t size) |
219 | static inline void* __CreateObject(u32_t pid, size_t size) |
220 | { |
220 | { |
221 | void *retval; |
221 | void *retval; |
222 | 222 | ||
223 | __asm__ __volatile__ ( |
223 | __asm__ __volatile__ ( |
224 | "call *__imp__CreateObject \n\t" |
224 | "call *__imp__CreateObject \n\t" |
225 | :"=a" (retval) |
225 | :"=a" (retval) |
226 | :"a" (size),"b"(pid) |
226 | :"a" (size),"b"(pid) |
227 | :"esi","edi", "memory"); |
227 | :"esi","edi", "memory"); |
228 | return retval; |
228 | return retval; |
229 | } |
229 | } |
230 | 230 | ||
231 | static inline void __DestroyObject(void *obj) |
231 | static inline void __DestroyObject(void *obj) |
232 | { |
232 | { |
233 | __asm__ __volatile__ ( |
233 | __asm__ __volatile__ ( |
234 | "call *__imp__DestroyObject" |
234 | "call *__imp__DestroyObject \n\t" |
235 | : |
235 | : |
236 | :"a" (obj)); |
236 | :"a" (obj)); |
237 | __asm__ __volatile__ ( |
237 | __asm__ __volatile__ ( |
238 | "" |
238 | "" |
239 | :::"eax","ebx","ecx","edx","esi","edi","cc","memory"); |
239 | :::"eax","ebx","ecx","edx","esi","edi","cc","memory"); |
240 | } |
240 | } |
241 | 241 | ||
242 | 242 | ||
243 | /* |
243 | /* |
244 | u32 __RegService(char *name, srv_proc_t proc) |
244 | u32 __RegService(char *name, srv_proc_t proc) |
245 | { |
245 | { |
246 | u32 retval; |
246 | u32 retval; |
247 | 247 | ||
248 | asm __volatile__ |
248 | asm __volatile__ |
249 | ( |
249 | ( |
250 | "pushl %%eax \n\t" |
250 | "pushl %%eax \n\t" |
251 | "pushl %%ebx \n\t" |
251 | "pushl %%ebx \n\t" |
252 | "call *__imp__RegService \n\t" |
252 | "call *__imp__RegService \n\t" |
253 | :"=eax" (retval) |
253 | :"=eax" (retval) |
254 | :"a" (proc), "b" (name) |
254 | :"a" (proc), "b" (name) |
255 | :"memory" |
255 | :"memory" |
256 | ); |
256 | ); |
257 | return retval; |
257 | return retval; |
258 | }; |
258 | }; |
259 | */ |
259 | */ |
260 | 260 | ||
261 | 261 | ||
262 | static inline u32_t GetService(const char *name) |
262 | static inline u32_t GetService(const char *name) |
263 | { |
263 | { |
264 | u32_t handle; |
264 | u32_t handle; |
265 | 265 | ||
266 | __asm__ __volatile__ |
266 | __asm__ __volatile__ |
267 | ( |
267 | ( |
268 | "pushl %%eax \n\t" |
268 | "pushl %%eax \n\t" |
269 | "call *__imp__GetService" |
269 | "call *__imp__GetService" |
270 | :"=eax" (handle) |
270 | :"=eax" (handle) |
271 | :"a" (name) |
271 | :"a" (name) |
272 | :"ebx","ecx","edx","esi", "edi" |
272 | :"ebx","ecx","edx","esi", "edi" |
273 | ); |
273 | ); |
274 | return handle; |
274 | return handle; |
275 | }; |
275 | }; |
276 | 276 | ||
277 | static inline u32_t safe_cli(void) |
277 | static inline u32_t safe_cli(void) |
278 | { |
278 | { |
279 | u32_t ifl; |
279 | u32_t ifl; |
280 | __asm__ __volatile__ ( |
280 | __asm__ __volatile__ ( |
281 | "pushf\n\t" |
281 | "pushf\n\t" |
282 | "popl %0\n\t" |
282 | "popl %0\n\t" |
283 | "cli\n" |
283 | "cli\n" |
284 | : "=r" (ifl)); |
284 | : "=r" (ifl)); |
285 | return ifl; |
285 | return ifl; |
286 | } |
286 | } |
287 | 287 | ||
288 | static inline void safe_sti(u32_t ifl) |
288 | static inline void safe_sti(u32_t ifl) |
289 | { |
289 | { |
290 | __asm__ __volatile__ ( |
290 | __asm__ __volatile__ ( |
291 | "pushl %0\n\t" |
291 | "pushl %0\n\t" |
292 | "popf\n" |
292 | "popf\n" |
293 | : : "r" (ifl) |
293 | : : "r" (ifl) |
294 | ); |
294 | ); |
295 | } |
295 | } |
296 | 296 | ||
297 | static inline void __clear (void * dst, unsigned len) |
297 | static inline void __clear (void * dst, unsigned len) |
298 | { |
298 | { |
299 | u32_t tmp; |
299 | u32_t tmp; |
300 | __asm__ __volatile__ ( |
300 | __asm__ __volatile__ ( |
301 | // "xorl %%eax, %%eax \n\t" |
301 | // "xorl %%eax, %%eax \n\t" |
302 | "cld \n\t" |
302 | "cld \n\t" |
303 | "rep stosb \n" |
303 | "rep stosb \n" |
304 | :"=c"(tmp),"=D"(tmp) |
304 | :"=c"(tmp),"=D"(tmp) |
305 | :"a"(0),"c"(len),"D"(dst)); |
305 | :"a"(0),"c"(len),"D"(dst)); |
306 | __asm__ __volatile__ ("":::"ecx","edi"); |
306 | __asm__ __volatile__ ("":::"ecx","edi"); |
307 | }; |
307 | }; |
308 | 308 | ||
309 | static inline void out8(const u16_t port, const u8_t val) |
309 | static inline void out8(const u16_t port, const u8_t val) |
310 | { |
310 | { |
311 | __asm__ __volatile__ |
311 | __asm__ __volatile__ |
312 | ("outb %1, %0\n" : : "dN"(port), "a"(val)); |
312 | ("outb %1, %0\n" : : "dN"(port), "a"(val)); |
313 | } |
313 | } |
314 | 314 | ||
315 | static inline void out16(const u16_t port, const u16_t val) |
315 | static inline void out16(const u16_t port, const u16_t val) |
316 | { |
316 | { |
317 | __asm__ __volatile__ |
317 | __asm__ __volatile__ |
318 | ("outw %1, %0\n" : : "dN"(port), "a"(val)); |
318 | ("outw %1, %0\n" : : "dN"(port), "a"(val)); |
319 | } |
319 | } |
320 | 320 | ||
321 | static inline void out32(const u16_t port, const u32_t val) |
321 | static inline void out32(const u16_t port, const u32_t val) |
322 | { |
322 | { |
323 | __asm__ __volatile__ |
323 | __asm__ __volatile__ |
324 | ("outl %1, %0\n" : : "dN"(port), "a"(val)); |
324 | ("outl %1, %0\n" : : "dN"(port), "a"(val)); |
325 | } |
325 | } |
326 | 326 | ||
327 | static inline u8_t in8(const u16_t port) |
327 | static inline u8_t in8(const u16_t port) |
328 | { |
328 | { |
329 | u8_t tmp; |
329 | u8_t tmp; |
330 | __asm__ __volatile__ |
330 | __asm__ __volatile__ |
331 | ("inb %1, %0\n" : "=a"(tmp) : "dN"(port)); |
331 | ("inb %1, %0\n" : "=a"(tmp) : "dN"(port)); |
332 | return tmp; |
332 | return tmp; |
333 | }; |
333 | }; |
334 | 334 | ||
335 | static inline u16_t in16(const u16_t port) |
335 | static inline u16_t in16(const u16_t port) |
336 | { |
336 | { |
337 | u16_t tmp; |
337 | u16_t tmp; |
338 | __asm__ __volatile__ |
338 | __asm__ __volatile__ |
339 | ("inw %1, %0\n" : "=a"(tmp) : "dN"(port)); |
339 | ("inw %1, %0\n" : "=a"(tmp) : "dN"(port)); |
340 | return tmp; |
340 | return tmp; |
341 | }; |
341 | }; |
342 | 342 | ||
343 | static inline u32_t in32(const u16_t port) |
343 | static inline u32_t in32(const u16_t port) |
344 | { |
344 | { |
345 | u32_t tmp; |
345 | u32_t tmp; |
346 | __asm__ __volatile__ |
346 | __asm__ __volatile__ |
347 | ("inl %1, %0\n" : "=a"(tmp) : "dN"(port)); |
347 | ("inl %1, %0\n" : "=a"(tmp) : "dN"(port)); |
348 | return tmp; |
348 | return tmp; |
349 | }; |
349 | }; |
350 | 350 | ||
351 | static inline void delay(int time) |
351 | static inline void delay(int time) |
352 | { |
352 | { |
353 | __asm__ __volatile__ ( |
353 | __asm__ __volatile__ ( |
354 | "call *__imp__Delay" |
354 | "call *__imp__Delay" |
355 | ::"b" (time)); |
355 | ::"b" (time)); |
356 | __asm__ __volatile__ ( |
356 | __asm__ __volatile__ ( |
357 | "":::"ebx"); |
357 | "":::"ebx"); |
358 | 358 | ||
359 | } |
359 | } |
360 | 360 | ||
361 | static inline void change_task() |
361 | static inline void change_task() |
362 | { |
362 | { |
363 | __asm__ __volatile__ ( |
363 | __asm__ __volatile__ ( |
364 | "call *__imp__ChangeTask"); |
364 | "call *__imp__ChangeTask"); |
365 | } |
365 | } |
366 | 366 | ||
367 | static inline sysSetScreen(int width, int height, int pitch) |
367 | static inline sysSetScreen(int width, int height, int pitch) |
368 | { |
368 | { |
369 | __asm__ __volatile__ |
369 | __asm__ __volatile__ |
370 | ( |
370 | ( |
371 | "call *__imp__SetScreen" |
371 | "call *__imp__SetScreen" |
372 | : |
372 | : |
373 | :"a" (width-1),"d"(height-1), "c"(pitch) |
373 | :"a" (width-1),"d"(height-1), "c"(pitch) |
374 | ); |
374 | ); |
375 | __asm__ __volatile__ |
375 | __asm__ __volatile__ |
376 | ("" :::"eax","ecx","edx"); |
376 | ("" :::"eax","ecx","edx"); |
377 | } |
377 | } |
378 | 378 | ||
379 | int drm_order(unsigned long size); |
379 | int drm_order(unsigned long size); |
380 | 380 | ||
381 | static inline void __iomem *ioremap(uint32_t offset, size_t size) |
381 | static inline void __iomem *ioremap(uint32_t offset, size_t size) |
382 | { |
382 | { |
383 | return (void __iomem*) MapIoMem(offset, size, 3); |
383 | return (void __iomem*) MapIoMem(offset, size, 3); |
384 | } |
384 | } |
385 | 385 | ||
386 | static inline void iounmap(void *addr) |
386 | static inline void iounmap(void *addr) |
387 | { |
387 | { |
388 | FreeKernelSpace(addr); |
388 | FreeKernelSpace(addr); |
389 | } |
389 | } |
390 | 390 | ||
391 | static inline void * |
391 | static inline void * |
392 | pci_alloc_consistent(struct pci_dev *hwdev, size_t size, |
392 | pci_alloc_consistent(struct pci_dev *hwdev, size_t size, |
393 | addr_t *dma_handle) |
393 | addr_t *dma_handle) |
394 | { |
394 | { |
395 | *dma_handle = AllocPages(size >> 12); |
395 | *dma_handle = AllocPages(size >> 12); |
396 | return (void*)MapIoMem(*dma_handle, size, PG_SW+PG_NOCACHE); |
396 | return (void*)MapIoMem(*dma_handle, size, PG_SW+PG_NOCACHE); |
397 | } |
397 | } |
398 | 398 | ||
399 | #endif |
399 | #endif |