Rev 4538 | Rev 5272 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4538 | Rev 5270 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
Line 3... | Line 3... | ||
3 | #ifndef __SYSCALL_H__ |
3 | #ifndef __SYSCALL_H__ |
4 | #define __SYSCALL_H__ |
4 | #define __SYSCALL_H__ |
Line -... | Line 5... | ||
- | 5 | ||
- | 6 | typedef u32 addr_t; |
|
- | 7 | typedef u32 count_t; |
|
5 | 8 | ||
Line 6... | Line 9... | ||
6 | /////////////////////////////////////////////////////////////////////////////// |
9 | /////////////////////////////////////////////////////////////////////////////// |
7 | 10 | ||
Line 23... | Line 26... | ||
23 | 26 | ||
Line 24... | Line 27... | ||
24 | 27 | ||
25 | void* STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace"); |
28 | void* STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace"); |
26 | void STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace"); |
29 | void STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace"); |
27 | addr_t STDCALL MapIoMem(addr_t base, size_t size, u32_t flags)__asm__("MapIoMem"); |
30 | addr_t STDCALL MapIoMem(addr_t base, size_t size, u32 flags)__asm__("MapIoMem"); |
28 | void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc"); |
31 | void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc"); |
29 | void* STDCALL KernelFree(void *mem)__asm__("KernelFree"); |
32 | void* STDCALL KernelFree(void *mem)__asm__("KernelFree"); |
30 | void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc"); |
33 | void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc"); |
Line 31... | Line 34... | ||
31 | int STDCALL UserFree(void *mem)__asm__("UserFree"); |
34 | int STDCALL UserFree(void *mem)__asm__("UserFree"); |
Line 32... | Line 35... | ||
32 | 35 | ||
Line 33... | Line 36... | ||
33 | void* STDCALL GetDisplay(void)__asm__("GetDisplay"); |
36 | void* STDCALL GetDisplay(void)__asm__("GetDisplay"); |
34 | 37 | ||
35 | u32_t IMPORT GetTimerTicks(void)__asm__("GetTimerTicks"); |
38 | u32 IMPORT GetTimerTicks(void)__asm__("GetTimerTicks"); |
36 | 39 | ||
37 | addr_t STDCALL AllocPage(void)__asm__("AllocPage"); |
40 | addr_t STDCALL AllocPage(void)__asm__("AllocPage"); |
Line 38... | Line 41... | ||
38 | addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages"); |
41 | addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages"); |
Line 39... | Line 42... | ||
39 | void IMPORT __attribute__((regparm(1))) |
42 | void IMPORT __attribute__((regparm(1))) |
Line 40... | Line 43... | ||
40 | FreePage(addr_t page)__asm__("FreePage"); |
43 | FreePage(addr_t page)__asm__("FreePage"); |
Line 41... | Line 44... | ||
41 | void STDCALL MapPage(void *vaddr, addr_t paddr, u32_t flags)__asm__("MapPage"); |
44 | void STDCALL MapPage(void *vaddr, addr_t paddr, u32 flags)__asm__("MapPage"); |
42 | 45 | ||
43 | 46 | ||
Line 44... | Line 47... | ||
44 | void* STDCALL CreateRingBuffer(size_t size, u32_t map)__asm__("CreateRingBuffer"); |
47 | void* STDCALL CreateRingBuffer(size_t size, u32 map)__asm__("CreateRingBuffer"); |
45 | 48 | ||
Line 46... | Line 49... | ||
46 | u32_t STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService"); |
49 | u32 STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService"); |
47 | 50 | ||
Line 48... | Line 51... | ||
48 | int STDCALL AttachIntHandler(int irq, void *handler, u32_t access) __asm__("AttachIntHandler"); |
51 | int STDCALL AttachIntHandler(int irq, void *handler, u32 access) __asm__("AttachIntHandler"); |
Line 65... | Line 68... | ||
65 | 68 | ||
Line 66... | Line 69... | ||
66 | void STDCALL SetMouseData(int btn, int x, int y, |
69 | void STDCALL SetMouseData(int btn, int x, int y, |
67 | int z, int h)__asm__("SetMouseData"); |
70 | int z, int h)__asm__("SetMouseData"); |
Line 68... | Line 71... | ||
68 | 71 | ||
Line 69... | Line 72... | ||
69 | void FASTCALL SetKeyboardData(u32_t data)__asm__("SetKeyboardData"); |
72 | void FASTCALL SetKeyboardData(u32 data)__asm__("SetKeyboardData"); |
70 | 73 | ||
71 | 74 | ||
Line 72... | Line 75... | ||
72 | u8_t STDCALL PciRead8 (u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead8"); |
75 | u8 STDCALL PciRead8 (u32 bus, u32 devfn, u32 reg)__asm__("PciRead8"); |
73 | u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16"); |
76 | u16 STDCALL PciRead16(u32 bus, u32 devfn, u32 reg)__asm__("PciRead16"); |
74 | u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32"); |
77 | u32 STDCALL PciRead32(u32 bus, u32 devfn, u32 reg)__asm__("PciRead32"); |
Line 75... | Line 78... | ||
75 | 78 | ||
76 | u32_t STDCALL PciWrite8 (u32_t bus, u32_t devfn, u32_t reg,u8_t val) __asm__("PciWrite8"); |
79 | u32 STDCALL PciWrite8 (u32 bus, u32 devfn, u32 reg,u8 val) __asm__("PciWrite8"); |
Line 77... | Line 80... | ||
77 | u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16"); |
80 | u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16"); |
Line 156... | Line 159... | ||
156 | return pid; |
159 | return pid; |
157 | }; |
160 | }; |
158 | 161 | ||
Line 159... | Line 162... | ||
159 | 162 | ||
160 | static inline evhandle_t CreateEvent(kevent_t *ev, u32_t flags) |
163 | static inline evhandle_t CreateEvent(kevent_t *ev, u32 flags) |
161 | { |
164 | { |
Line 162... | Line 165... | ||
162 | evhandle_t evh; |
165 | evhandle_t evh; |
163 | 166 | ||
Line 170... | Line 173... | ||
170 | 173 | ||
Line 171... | Line 174... | ||
171 | return evh; |
174 | return evh; |
172 | }; |
175 | }; |
Line 173... | Line 176... | ||
173 | 176 | ||
174 | static inline void RaiseEvent(evhandle_t evh, u32_t flags, kevent_t *ev) |
177 | static inline void RaiseEvent(evhandle_t evh, u32 flags, kevent_t *ev) |
175 | { |
178 | { |
176 | __asm__ __volatile__ ( |
179 | __asm__ __volatile__ ( |
177 | "call *__imp__RaiseEvent" |
180 | "call *__imp__RaiseEvent" |
178 | ::"a"(evh.handle),"b"(evh.euid),"d"(flags),"S" (ev) |
181 | ::"a"(evh.handle),"b"(evh.euid),"d"(flags),"S" (ev) |
Line 207... | Line 210... | ||
207 | ::"a"(evh.handle),"b"(evh.euid)); |
210 | ::"a"(evh.handle),"b"(evh.euid)); |
208 | __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi"); |
211 | __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi"); |
209 | }; |
212 | }; |
210 | 213 | ||
Line 211... | Line 214... | ||
211 | static inline u32_t GetEvent(kevent_t *ev) |
214 | static inline u32 GetEvent(kevent_t *ev) |
212 | { |
215 | { |
213 | u32_t handle; |
216 | u32 handle; |
Line 214... | Line 217... | ||
214 | 217 | ||
215 | __asm__ __volatile__ ( |
218 | __asm__ __volatile__ ( |
216 | "call *__imp__GetEvent" |
219 | "call *__imp__GetEvent" |
217 | :"=a"(handle) |
220 | :"=a"(handle) |
Line 251... | Line 254... | ||
251 | :"a"(61), "b"(3)); |
254 | :"a"(61), "b"(3)); |
252 | return retval; |
255 | return retval; |
253 | } |
256 | } |
254 | 257 | ||
Line 255... | Line 258... | ||
255 | static inline u32_t GetPgAddr(void *mem) |
258 | static inline u32 GetPgAddr(void *mem) |
256 | { |
259 | { |
257 | u32_t retval; |
260 | u32 retval; |
Line 258... | Line 261... | ||
258 | 261 | ||
259 | __asm__ __volatile__ ( |
262 | __asm__ __volatile__ ( |
260 | "call *__imp__GetPgAddr \n\t" |
263 | "call *__imp__GetPgAddr \n\t" |
261 | :"=a" (retval) |
264 | :"=a" (retval) |
262 | :"a" (mem) ); |
265 | :"a" (mem) ); |
263 | return retval; |
266 | return retval; |
Line 264... | Line 267... | ||
264 | }; |
267 | }; |
265 | 268 | ||
266 | static inline void CommitPages(void *mem, u32_t page, u32_t size) |
269 | static inline void CommitPages(void *mem, u32 page, u32 size) |
267 | { |
270 | { |
268 | size = (size+4095) & ~4095; |
271 | size = (size+4095) & ~4095; |
269 | __asm__ __volatile__ ( |
272 | __asm__ __volatile__ ( |
Line 282... | Line 285... | ||
282 | :"edx"); |
285 | :"edx"); |
283 | __asm__ __volatile__ ("":::"eax","ecx"); |
286 | __asm__ __volatile__ ("":::"eax","ecx"); |
284 | }; |
287 | }; |
285 | 288 | ||
Line 286... | Line 289... | ||
286 | static inline void usleep(u32_t delay) |
289 | static inline void usleep(u32 delay) |
287 | { |
290 | { |
288 | if( !delay ) |
291 | if( !delay ) |
289 | delay++; |
292 | delay++; |
290 | delay*= 500; |
293 | delay*= 500; |
Line 295... | Line 298... | ||
295 | "cpuid \n\t" |
298 | "cpuid \n\t" |
296 | :::"eax","ebx","ecx","edx"); |
299 | :::"eax","ebx","ecx","edx"); |
297 | }; |
300 | }; |
298 | 301 | ||
Line 299... | Line 302... | ||
299 | static inline void udelay(u32_t delay) |
302 | static inline void udelay1(u32 delay) |
300 | { |
303 | { |
301 | if(!delay) delay++; |
304 | if(!delay) delay++; |
302 | delay*= 100; |
305 | delay*= 100; |
Line 303... | Line 306... | ||
303 | 306 | ||
Line 309... | Line 312... | ||
309 | :::"eax","ebx","ecx","edx" ); |
312 | :::"eax","ebx","ecx","edx" ); |
310 | } |
313 | } |
311 | } |
314 | } |
312 | 315 | ||
Line 313... | Line 316... | ||
313 | static inline void msleep(unsigned int msecs) |
316 | static inline void msleep1(unsigned int msecs) |
314 | { |
317 | { |
315 | msecs /= 10; |
318 | msecs /= 10; |
316 | if(!msecs) msecs = 1; |
319 | if(!msecs) msecs = 1; |
Line 317... | Line 320... | ||
317 | 320 | ||
Line 322... | Line 325... | ||
322 | "":::"ebx"); |
325 | "":::"ebx"); |
323 | 326 | ||
Line 324... | Line 327... | ||
324 | }; |
327 | }; |
Line 325... | Line 328... | ||
325 | 328 | ||
326 | static inline void mdelay(u32_t time) |
329 | static inline void mdelay1(u32 time) |
327 | { |
330 | { |
328 | time /= 10; |
331 | time /= 10; |
Line 329... | Line 332... | ||
329 | if(!time) time = 1; |
332 | if(!time) time = 1; |
Line 335... | Line 338... | ||
335 | "":::"ebx"); |
338 | "":::"ebx"); |
336 | 339 | ||
Line 337... | Line 340... | ||
337 | }; |
340 | }; |
Line 338... | Line 341... | ||
338 | 341 | ||
339 | static inline u32_t __PciApi(int cmd) |
342 | static inline u32 __PciApi(int cmd) |
340 | { |
343 | { |
Line 341... | Line 344... | ||
341 | u32_t retval; |
344 | u32 retval; |
342 | 345 | ||
343 | __asm__ __volatile__ ( |
346 | __asm__ __volatile__ ( |
344 | "call *__imp__PciApi \n\t" |
347 | "call *__imp__PciApi \n\t" |
Line 349... | Line 352... | ||
349 | 352 | ||
Line 350... | Line 353... | ||
350 | return retval; |
353 | return retval; |
351 | }; |
354 | }; |
Line 352... | Line 355... | ||
352 | 355 | ||
353 | static inline void* __CreateObject(u32_t pid, size_t size) |
356 | static inline void* __CreateObject(u32 pid, size_t size) |
354 | { |
357 | { |
Line 355... | Line 358... | ||
355 | void *retval; |
358 | void *retval; |
356 | 359 | ||
Line 372... | Line 375... | ||
372 | "" |
375 | "" |
373 | :::"eax","ebx","ecx","edx","esi","edi","cc","memory"); |
376 | :::"eax","ebx","ecx","edx","esi","edi","cc","memory"); |
374 | } |
377 | } |
375 | 378 | ||
Line 376... | Line 379... | ||
376 | static inline u32_t GetService(const char *name) |
379 | static inline u32 GetService(const char *name) |
377 | { |
380 | { |
378 | u32_t handle; |
381 | u32 handle; |
Line 379... | Line 382... | ||
379 | 382 | ||
380 | __asm__ __volatile__ |
383 | __asm__ __volatile__ |
381 | ( |
384 | ( |
382 | "pushl %%eax \n\t" |
385 | "pushl %%eax \n\t" |
Line 387... | Line 390... | ||
387 | ); |
390 | ); |
388 | return handle; |
391 | return handle; |
389 | }; |
392 | }; |
390 | 393 | ||
Line 391... | Line 394... | ||
391 | static inline u32_t safe_cli(void) |
394 | static inline u32 safe_cli(void) |
392 | { |
395 | { |
393 | u32_t ifl; |
396 | u32 ifl; |
394 | __asm__ __volatile__ ( |
397 | __asm__ __volatile__ ( |
395 | "pushf\n\t" |
398 | "pushf\n\t" |
396 | "popl %0\n\t" |
399 | "popl %0\n\t" |
397 | "cli\n" |
400 | "cli\n" |
398 | : "=r" (ifl)); |
401 | : "=r" (ifl)); |
399 | return ifl; |
402 | return ifl; |
400 | } |
403 | } |
Line 401... | Line 404... | ||
401 | 404 | ||
402 | static inline void safe_sti(u32_t efl) |
405 | static inline void safe_sti(u32 efl) |
403 | { |
406 | { |
404 | if (efl & (1<<9)) |
407 | if (efl & (1<<9)) |
405 | __asm__ __volatile__ ("sti"); |
408 | __asm__ __volatile__ ("sti"); |
Line 406... | Line 409... | ||
406 | } |
409 | } |
407 | 410 | ||
408 | static inline u32_t get_eflags(void) |
411 | static inline u32 get_eflags(void) |
409 | { |
412 | { |
410 | u32_t val; |
413 | u32 val; |
411 | asm volatile ( |
414 | asm volatile ( |
412 | "pushfl\n\t" |
415 | "pushfl\n\t" |
413 | "popl %0\n" |
416 | "popl %0\n" |
414 | : "=r" (val)); |
417 | : "=r" (val)); |
Line 415... | Line 418... | ||
415 | return val; |
418 | return val; |
416 | } |
419 | } |
417 | 420 | ||
418 | static inline void __clear (void * dst, unsigned len) |
421 | static inline void __clear (void * dst, unsigned len) |
419 | { |
422 | { |
420 | u32_t tmp; |
423 | u32 tmp; |
421 | __asm__ __volatile__ ( |
424 | __asm__ __volatile__ ( |
422 | "cld \n\t" |
425 | "cld \n\t" |
423 | "rep stosb \n" |
426 | "rep stosb \n" |
424 | :"=c"(tmp),"=D"(tmp) |
427 | :"=c"(tmp),"=D"(tmp) |
Line 425... | Line 428... | ||
425 | :"a"(0),"c"(len),"D"(dst)); |
428 | :"a"(0),"c"(len),"D"(dst)); |
426 | __asm__ __volatile__ ("":::"ecx","edi"); |
429 | __asm__ __volatile__ ("":::"ecx","edi"); |
427 | }; |
430 | }; |
428 | 431 | ||
429 | static inline void out8(const u16_t port, const u8_t val) |
432 | static inline void out8(const u16 port, const u8 val) |
Line 430... | Line 433... | ||
430 | { |
433 | { |
431 | __asm__ __volatile__ |
434 | __asm__ __volatile__ |
432 | ("outb %1, %0\n" : : "dN"(port), "a"(val)); |
435 | ("outb %1, %0\n" : : "dN"(port), "a"(val)); |
433 | } |
436 | } |
434 | 437 | ||
Line 435... | Line 438... | ||
435 | static inline void out16(const u16_t port, const u16_t val) |
438 | static inline void out16(const u16 port, const u16 val) |
436 | { |
439 | { |
437 | __asm__ __volatile__ |
440 | __asm__ __volatile__ |
438 | ("outw %1, %0\n" : : "dN"(port), "a"(val)); |
441 | ("outw %1, %0\n" : : "dN"(port), "a"(val)); |
439 | } |
442 | } |
Line 440... | Line 443... | ||
440 | 443 | ||
441 | static inline void out32(const u16_t port, const u32_t val) |
444 | static inline void out32(const u16 port, const u32 val) |
442 | { |
445 | { |
443 | __asm__ __volatile__ |
446 | __asm__ __volatile__ |
444 | ("outl %1, %0\n" : : "dN"(port), "a"(val)); |
447 | ("outl %1, %0\n" : : "dN"(port), "a"(val)); |
445 | } |
448 | } |
446 | 449 | ||
Line 447... | Line 450... | ||
447 | static inline u8_t in8(const u16_t port) |
450 | static inline u8 in8(const u16 port) |
448 | { |
451 | { |
449 | u8_t tmp; |
452 | u8 tmp; |
450 | __asm__ __volatile__ |
453 | __asm__ __volatile__ |
451 | ("inb %1, %0\n" : "=a"(tmp) : "dN"(port)); |
454 | ("inb %1, %0\n" : "=a"(tmp) : "dN"(port)); |
452 | return tmp; |
455 | return tmp; |
453 | }; |
456 | }; |
Line 454... | Line 457... | ||
454 | 457 | ||
455 | static inline u16_t in16(const u16_t port) |
458 | static inline u16 in16(const u16 port) |
456 | { |
459 | { |
457 | u16_t tmp; |
460 | u16 tmp; |
458 | __asm__ __volatile__ |
461 | __asm__ __volatile__ |
459 | ("inw %1, %0\n" : "=a"(tmp) : "dN"(port)); |
462 | ("inw %1, %0\n" : "=a"(tmp) : "dN"(port)); |
460 | return tmp; |
463 | return tmp; |
Line 497... | Line 500... | ||
497 | } |
500 | } |
498 | 501 | ||
Line 499... | Line 502... | ||
499 | int drm_order(unsigned long size); |
502 | int drm_order(unsigned long size); |
Line 500... | Line 503... | ||
500 | 503 | ||
501 | static inline void __iomem *ioremap(uint32_t offset, size_t size) |
504 | static inline void __iomem *ioremap(u32 offset, size_t size) |
502 | { |
505 | { |
503 | return (void __iomem*) MapIoMem(offset, size, PG_SW|PG_NOCACHE|0x100); |
506 | return (void __iomem*) MapIoMem(offset, size, PG_SW|PG_NOCACHE|0x100); |
Line 504... | Line 507... | ||
504 | } |
507 | } |
505 | 508 | ||
506 | static inline void __iomem *ioremap_wc(uint32_t offset, size_t size) |
509 | static inline void __iomem *ioremap_wc(u32 offset, size_t size) |
507 | { |
510 | { |