Subversion Repositories Kolibri OS

Rev

Rev 2161 | Rev 2967 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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