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