Subversion Repositories Kolibri OS

Rev

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

Rev 6588 Rev 7143
1
#ifndef __SYSCALL_H__
1
#ifndef __SYSCALL_H__
2
#define __SYSCALL_H__
2
#define __SYSCALL_H__
3
 
3
 
4
#include 
4
#include 
5
 
5
 
6
typedef u32 addr_t;
6
typedef u32 addr_t;
7
typedef u32 count_t;
7
typedef u32 count_t;
8
 
8
 
9
typedef struct
9
typedef struct
10
{
10
{
11
  int width;
11
  int width;
12
  int height;
12
  int height;
13
  int bpp;
13
  int bpp;
14
  int freq;
14
  int freq;
15
}videomode_t;
15
}videomode_t;
16
 
16
 
17
struct kos32_pdev
17
struct kos32_pdev
18
{
18
{
19
    struct kos32_pdev *prev;
19
    struct kos32_pdev *prev;
20
    struct kos32_pdev *next;
20
    struct kos32_pdev *next;
21
    u32 devid;
21
    u32 devid;
22
    u32 class;
22
    u32 class;
23
    u8  devfn;
23
    u8  devfn;
24
    u8  bus;
24
    u8  bus;
25
    u8  reserved[2];
25
    u8  reserved[2];
26
    u32 owner;
26
    u32 owner;
27
} __attribute__((packed));
27
} __attribute__((packed));
28
 
28
 
29
///////////////////////////////////////////////////////////////////////////////
29
///////////////////////////////////////////////////////////////////////////////
30
 
30
 
31
#define STDCALL  __attribute__ ((stdcall)) __attribute__ ((dllimport))
31
#define STDCALL  __attribute__ ((stdcall)) __attribute__ ((dllimport))
32
#define FASTCALL __attribute__ ((fastcall)) __attribute__ ((dllimport))
32
#define FASTCALL __attribute__ ((fastcall)) __attribute__ ((dllimport))
33
 
33
 
34
#define IMPORT   __attribute__ ((dllimport))
34
#define IMPORT   __attribute__ ((dllimport))
35
 
35
 
36
///////////////////////////////////////////////////////////////////////////////
36
///////////////////////////////////////////////////////////////////////////////
37
 
37
 
38
#define SysMsgBoardStr  __SysMsgBoardStr
38
#define SysMsgBoardStr  __SysMsgBoardStr
39
#define PciApi          __PciApi
39
#define PciApi          __PciApi
40
#define CreateObject    __CreateObject
40
#define CreateObject    __CreateObject
41
#define DestroyObject   __DestroyObject
41
#define DestroyObject   __DestroyObject
42
 
42
 
43
#define _alloca(x) __builtin_alloca((x))
43
#define _alloca(x) __builtin_alloca((x))
44
 
44
 
45
///////////////////////////////////////////////////////////////////////////////
45
///////////////////////////////////////////////////////////////////////////////
46
 
46
 
47
 
47
 
48
void*  STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
48
void*  STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
49
void   STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace");
49
void   STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace");
50
addr_t STDCALL MapIoMem(addr_t base, size_t size, u32 flags)__asm__("MapIoMem");
50
addr_t STDCALL MapIoMem(addr_t base, size_t size, u32 flags)__asm__("MapIoMem");
51
void*  STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
51
void*  STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
52
void*  STDCALL KernelFree(const void *mem)__asm__("KernelFree");
52
void*  STDCALL KernelFree(const void *mem)__asm__("KernelFree");
53
void*  STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
53
void*  STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
54
int    STDCALL UserFree(void *mem)__asm__("UserFree");
54
int    STDCALL UserFree(void *mem)__asm__("UserFree");
55
 
55
 
56
void*  STDCALL GetDisplay(void)__asm__("GetDisplay");
56
void*  STDCALL GetDisplay(void)__asm__("GetDisplay");
57
 
57
 
58
u32  IMPORT  GetTimerTicks(void)__asm__("GetTimerTicks");
58
u32  IMPORT  GetTimerTicks(void)__asm__("GetTimerTicks");
59
u64  IMPORT  GetClockNs(void)__asm__("GetClockNs");
59
u64  IMPORT  GetClockNs(void)__asm__("GetClockNs");
60
 
60
 
61
addr_t STDCALL AllocPage(void)__asm__("AllocPage");
61
addr_t STDCALL AllocPage(void)__asm__("AllocPage");
62
addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages");
62
addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages");
63
void   IMPORT  __attribute__((regparm(1)))
63
void   IMPORT  __attribute__((regparm(1)))
64
               FreePage(addr_t page)__asm__("FreePage");
64
               FreePage(addr_t page)__asm__("FreePage");
65
void   STDCALL MapPage(void *vaddr, addr_t paddr, u32 flags)__asm__("MapPage");
65
void   STDCALL MapPage(void *vaddr, addr_t paddr, u32 flags)__asm__("MapPage");
66
 
66
 
67
 
67
 
68
void* STDCALL CreateRingBuffer(size_t size, u32 map)__asm__("CreateRingBuffer");
68
void* STDCALL CreateRingBuffer(size_t size, u32 map)__asm__("CreateRingBuffer");
69
 
69
 
70
u32 STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService");
70
u32 STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService");
71
 
71
 
72
int   STDCALL AttachIntHandler(int irq, void *handler, u32 access) __asm__("AttachIntHandler");
72
int   STDCALL AttachIntHandler(int irq, void *handler, u32 access) __asm__("AttachIntHandler");
73
 
73
 
74
void  FASTCALL MutexInit(struct mutex*)__asm__("MutexInit");
74
void  FASTCALL MutexInit(struct mutex*)__asm__("MutexInit");
75
void  FASTCALL MutexLock(struct mutex*)__asm__("MutexLock");
75
void  FASTCALL MutexLock(struct mutex*)__asm__("MutexLock");
76
void  FASTCALL MutexUnlock(struct mutex*)__asm__("MutexUnlock");
76
void  FASTCALL MutexUnlock(struct mutex*)__asm__("MutexUnlock");
77
 
77
 
78
void  FASTCALL InitRwsem(struct rw_semaphore *sem)__asm__("InitRwsem");
78
void  FASTCALL InitRwsem(struct rw_semaphore *sem)__asm__("InitRwsem");
79
void  FASTCALL DownRead(struct rw_semaphore *sem)__asm__("DownRead");
79
void  FASTCALL DownRead(struct rw_semaphore *sem)__asm__("DownRead");
80
void  FASTCALL DownWrite(struct rw_semaphore *sem)__asm__("DownWrite");
80
void  FASTCALL DownWrite(struct rw_semaphore *sem)__asm__("DownWrite");
81
void  FASTCALL UpRead(struct rw_semaphore *sem)__asm__("UpRead");
81
void  FASTCALL UpRead(struct rw_semaphore *sem)__asm__("UpRead");
82
void  FASTCALL UpWrite(struct rw_semaphore *sem)__asm__("UpWrite");
82
void  FASTCALL UpWrite(struct rw_semaphore *sem)__asm__("UpWrite");
83
 
83
 
84
addr_t IMPORT  GetStackBase(void)__asm__("GetStackBase");
84
addr_t IMPORT  GetStackBase(void)__asm__("GetStackBase");
85
u32  IMPORT  GetPid(void)__asm__("GetPid");
85
u32  IMPORT  GetPid(void)__asm__("GetPid");
86
 
86
 
87
u32 STDCALL TimerHS(u32 delay, u32 interval,
87
u32 STDCALL TimerHS(u32 delay, u32 interval,
88
                    void *fn, void *data)asm("TimerHS");
88
                    void *fn, void *data)asm("TimerHS");
89
 
89
 
90
void STDCALL CancelTimerHS(u32 handle)asm("CancelTimerHS");
90
void STDCALL CancelTimerHS(u32 handle)asm("CancelTimerHS");
91
 
91
 
92
u64 IMPORT GetCpuFreq()__asm__("GetCpuFreq");
92
u64 IMPORT GetCpuFreq()__asm__("GetCpuFreq");
93
 
93
 
94
///////////////////////////////////////////////////////////////////////////////
94
///////////////////////////////////////////////////////////////////////////////
95
 
95
 
96
void   STDCALL SetMouseData(int btn, int x, int y,
96
void   STDCALL SetMouseData(int btn, int x, int y,
97
                            int z, int h)__asm__("SetMouseData");
97
                            int z, int h)__asm__("SetMouseData");
98
 
98
 
99
void   FASTCALL SetKeyboardData(u32 data)__asm__("SetKeyboardData");
99
void   FASTCALL SetKeyboardData(u32 data)__asm__("SetKeyboardData");
100
 
100
 
101
struct kos32_pdev* IMPORT GetPCIList()__asm__("GetPCIList");
101
struct kos32_pdev* IMPORT GetPCIList()__asm__("GetPCIList");
102
 
102
 
103
u8  STDCALL PciRead8 (u32 bus, u32 devfn, u32 reg)__asm__("PciRead8");
103
u8  STDCALL PciRead8 (u32 bus, u32 devfn, u32 reg)__asm__("PciRead8");
104
u16 STDCALL PciRead16(u32 bus, u32 devfn, u32 reg)__asm__("PciRead16");
104
u16 STDCALL PciRead16(u32 bus, u32 devfn, u32 reg)__asm__("PciRead16");
105
u32 STDCALL PciRead32(u32 bus, u32 devfn, u32 reg)__asm__("PciRead32");
105
u32 STDCALL PciRead32(u32 bus, u32 devfn, u32 reg)__asm__("PciRead32");
106
 
106
 
107
u32 STDCALL PciWrite8 (u32 bus, u32 devfn, u32 reg,u8 val) __asm__("PciWrite8");
107
u32 STDCALL PciWrite8 (u32 bus, u32 devfn, u32 reg,u8 val) __asm__("PciWrite8");
108
u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16");
108
u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16");
109
u32 STDCALL PciWrite32(u32 bus, u32 devfn, u32 reg,u32 val)__asm__("PciWrite32");
109
u32 STDCALL PciWrite32(u32 bus, u32 devfn, u32 reg,u32 val)__asm__("PciWrite32");
110
 
110
 
111
#define pciReadByte(tag, reg) \
111
#define pciReadByte(tag, reg) \
112
        PciRead8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
112
        PciRead8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
113
 
113
 
114
#define pciReadWord(tag, reg) \
114
#define pciReadWord(tag, reg) \
115
        PciRead16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
115
        PciRead16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
116
 
116
 
117
#define pciReadLong(tag, reg) \
117
#define pciReadLong(tag, reg) \
118
        PciRead32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
118
        PciRead32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
119
 
119
 
120
#define pciWriteByte(tag, reg, val) \
120
#define pciWriteByte(tag, reg, val) \
121
        PciWrite8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
121
        PciWrite8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
122
 
122
 
123
#define pciWriteWord(tag, reg, val) \
123
#define pciWriteWord(tag, reg, val) \
124
        PciWrite16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
124
        PciWrite16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
125
 
125
 
126
#define pciWriteLong(tag, reg, val) \
126
#define pciWriteLong(tag, reg, val) \
127
        PciWrite32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
127
        PciWrite32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
128
 
128
 
129
 
129
 
130
///////////////////////////////////////////////////////////////////////////////
130
///////////////////////////////////////////////////////////////////////////////
131
 
131
 
132
int dbg_open(char *path);
132
int dbg_open(char *path);
133
int dbgprintf(const char* format, ...);
133
int dbgprintf(const char* format, ...);
134
 
134
 
135
///////////////////////////////////////////////////////////////////////////////
135
///////////////////////////////////////////////////////////////////////////////
136
 
136
 
137
static inline int CreateKernelThread(void *entry)
137
static inline int CreateKernelThread(void *entry)
138
{
138
{
139
    int pid;
139
    int pid;
140
     __asm__ __volatile__ (
140
     __asm__ __volatile__ (
141
     "call *__imp__CreateThread"
141
     "call *__imp__CreateThread"
142
     :"=a"(pid)
142
     :"=a"(pid)
143
     :"b"(1),"c"(entry),"d"(0)
143
     :"b"(1),"c"(entry),"d"(0)
144
     :"memory");
144
     :"memory");
145
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
145
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
146
     return pid;
146
     return pid;
147
};
147
};
148
 
148
 
149
 
149
 
150
static inline evhandle_t CreateEvent(kevent_t *ev, u32 flags)
150
static inline evhandle_t CreateEvent(kevent_t *ev, u32 flags)
151
{
151
{
152
     evhandle_t evh;
152
     evhandle_t evh;
153
 
153
 
154
     __asm__ __volatile__ (
154
     __asm__ __volatile__ (
155
     "call *__imp__CreateEvent"
155
     "call *__imp__CreateEvent"
156
     :"=A"(evh.raw)
156
     :"=A"(evh.raw)
157
     :"S" (ev), "c"(flags)
157
     :"S" (ev), "c"(flags)
158
     :"memory");
158
     :"memory");
159
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi", "edi");
159
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi", "edi");
160
 
160
 
161
     return evh;
161
     return evh;
162
};
162
};
163
 
163
 
164
static inline void RaiseEvent(evhandle_t evh, u32 flags, kevent_t *ev)
164
static inline void RaiseEvent(evhandle_t evh, u32 flags, kevent_t *ev)
165
{
165
{
166
     __asm__ __volatile__ (
166
     __asm__ __volatile__ (
167
     "call *__imp__RaiseEvent"
167
     "call *__imp__RaiseEvent"
168
     ::"a"(evh.handle),"b"(evh.euid),"d"(flags),"S" (ev)
168
     ::"a"(evh.handle),"b"(evh.euid),"d"(flags),"S" (ev)
169
     :"memory");
169
     :"memory");
170
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
170
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
171
 
171
 
172
};
172
};
173
 
173
 
174
static inline void WaitEvent(evhandle_t evh)
174
static inline void WaitEvent(evhandle_t evh)
175
{
175
{
176
     __asm__ __volatile__ (
176
     __asm__ __volatile__ (
177
     "call *__imp__WaitEvent"
177
     "call *__imp__WaitEvent"
178
     ::"a"(evh.handle),"b"(evh.euid));
178
     ::"a"(evh.handle),"b"(evh.euid));
179
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
179
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
180
};
180
};
181
 
181
 
182
static inline int WaitEventTimeout(evhandle_t evh, int timeout)
182
static inline int WaitEventTimeout(evhandle_t evh, int timeout)
183
{
183
{
184
    int retval;
184
    int retval;
185
    __asm__ __volatile__ (
185
    __asm__ __volatile__ (
186
    "call *__imp__WaitEventTimeout"
186
    "call *__imp__WaitEventTimeout"
187
    :"=a"(retval)
187
    :"=a"(retval)
188
    :"a"(evh.handle),"b"(evh.euid), "c"(timeout));
188
    :"a"(evh.handle),"b"(evh.euid), "c"(timeout));
189
    __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
189
    __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
190
    return retval;
190
    return retval;
191
};
191
};
192
 
192
 
193
static inline void DestroyEvent(evhandle_t evh)
193
static inline void DestroyEvent(evhandle_t evh)
194
{
194
{
195
     __asm__ __volatile__ (
195
     __asm__ __volatile__ (
196
     "call *__imp__DestroyEvent"
196
     "call *__imp__DestroyEvent"
197
     ::"a"(evh.handle),"b"(evh.euid));
197
     ::"a"(evh.handle),"b"(evh.euid));
198
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
198
     __asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
199
};
199
};
200
 
200
 
201
static inline u32 GetEvent(kevent_t *ev)
201
static inline u32 GetEvent(kevent_t *ev)
202
{
202
{
203
    u32  handle;
203
    u32  handle;
204
 
204
 
205
    __asm__ __volatile__ (
205
    __asm__ __volatile__ (
206
    "call *__imp__GetEvent"
206
    "call *__imp__GetEvent"
207
    :"=a"(handle)
207
    :"=a"(handle)
208
    :"D"(ev)
208
    :"D"(ev)
209
    :"memory");
209
    :"memory");
210
    __asm__ __volatile__ ("":::"ebx","ecx","edx", "esi","edi");
210
    __asm__ __volatile__ ("":::"ebx","ecx","edx", "esi","edi");
211
     return handle;
211
     return handle;
212
};
212
};
213
 
213
 
214
 
214
 
215
static inline int GetScreenSize(void)
215
static inline int GetScreenSize(void)
216
{
216
{
217
  int retval;
217
  int retval;
218
 
218
 
219
  asm("int $0x40"
219
  asm("int $0x40"
220
      :"=a"(retval)
220
      :"=a"(retval)
221
      :"a"(61), "b"(1));
221
      :"a"(61), "b"(1));
222
  return retval;
222
  return retval;
223
}
223
}
224
 
224
 
225
static inline int GetScreenBpp(void)
225
static inline int GetScreenBpp(void)
226
{
226
{
227
  int retval;
227
  int retval;
228
 
228
 
229
  asm("int $0x40"
229
  asm("int $0x40"
230
      :"=a"(retval)
230
      :"=a"(retval)
231
      :"a"(61), "b"(2));
231
      :"a"(61), "b"(2));
232
  return retval;
232
  return retval;
233
}
233
}
234
 
234
 
235
static inline int GetScreenPitch(void)
235
static inline int GetScreenPitch(void)
236
{
236
{
237
  int retval;
237
  int retval;
238
 
238
 
239
  asm("int $0x40"
239
  asm("int $0x40"
240
      :"=a"(retval)
240
      :"=a"(retval)
241
      :"a"(61), "b"(3));
241
      :"a"(61), "b"(3));
242
  return retval;
242
  return retval;
243
}
243
}
244
 
244
 
245
static inline u32 GetPgAddr(void *mem)
245
static inline u32 GetPgAddr(void *mem)
246
{
246
{
247
     u32 retval;
247
     u32 retval;
248
 
248
 
249
     __asm__ __volatile__ (
249
     __asm__ __volatile__ (
250
     "call *__imp__GetPgAddr \n\t"
250
     "call *__imp__GetPgAddr \n\t"
251
     :"=a" (retval)
251
     :"=a" (retval)
252
     :"a" (mem) );
252
     :"a" (mem) );
253
     return retval;
253
     return retval;
254
};
254
};
255
 
255
 
256
static inline void CommitPages(void *mem, u32 page, u32 size)
256
static inline void CommitPages(void *mem, u32 page, u32 size)
257
{
257
{
258
     size = (size+4095) & ~4095;
258
     size = (size+4095) & ~4095;
259
     __asm__ __volatile__ (
259
     __asm__ __volatile__ (
260
     "call *__imp__CommitPages"
260
     "call *__imp__CommitPages"
261
     ::"a" (page), "b"(mem),"c"(size>>12)
261
     ::"a" (page), "b"(mem),"c"(size>>12)
262
     :"edx" );
262
     :"edx" );
263
     __asm__ __volatile__ ("":::"eax","ebx","ecx");
263
     __asm__ __volatile__ ("":::"eax","ebx","ecx");
264
};
264
};
265
 
265
 
266
static inline void UnmapPages(void *mem, size_t size)
266
static inline void UnmapPages(void *mem, size_t size)
267
{
267
{
268
     size = (size+4095) & ~4095;
268
     size = (size+4095) & ~4095;
269
     __asm__ __volatile__ (
269
     __asm__ __volatile__ (
270
     "call *__imp__UnmapPages"
270
     "call *__imp__UnmapPages"
271
     ::"a" (mem), "c"(size>>12)
271
     ::"a" (mem), "c"(size>>12)
272
     :"edx");
272
     :"edx");
273
     __asm__ __volatile__ ("":::"eax","ecx");
273
     __asm__ __volatile__ ("":::"eax","ecx");
274
};
274
};
275
 
275
 
276
static inline void usleep(u32 delay)
276
static inline void usleep(u32 delay)
277
{
277
{
278
     if( !delay )
278
     if( !delay )
279
        delay++;
279
        delay++;
280
     delay*= 500;
280
     delay*= 500;
281
 
281
 
282
     while(delay--)
282
     while(delay--)
283
        __asm__ __volatile__(
283
        __asm__ __volatile__(
284
        "xorl %%eax, %%eax \n\t"
284
        "xorl %%eax, %%eax \n\t"
285
        "cpuid \n\t"
285
        "cpuid \n\t"
286
        :::"eax","ebx","ecx","edx");
286
        :::"eax","ebx","ecx","edx");
287
     };
287
     };
288
 
288
 
289
static inline void udelay1(u32 delay)
289
static inline void udelay1(u32 delay)
290
{
290
{
291
    if(!delay) delay++;
291
    if(!delay) delay++;
292
    delay*= 100;
292
    delay*= 100;
293
 
293
 
294
    while(delay--)
294
    while(delay--)
295
    {
295
    {
296
        __asm__ __volatile__(
296
        __asm__ __volatile__(
297
        "xorl %%eax, %%eax \n\t"
297
        "xorl %%eax, %%eax \n\t"
298
        "cpuid"
298
        "cpuid"
299
        :::"eax","ebx","ecx","edx" );
299
        :::"eax","ebx","ecx","edx" );
300
    }
300
    }
301
}
301
}
302
 
302
 
303
static inline void msleep1(unsigned int msecs)
303
static inline void msleep1(unsigned int msecs)
304
{
304
{
305
    msecs /= 10;
305
    msecs /= 10;
306
    if(!msecs) msecs = 1;
306
    if(!msecs) msecs = 1;
307
 
307
 
308
     __asm__ __volatile__ (
308
     __asm__ __volatile__ (
309
     "call *__imp__Delay"
309
     "call *__imp__Delay"
310
     ::"b" (msecs));
310
     ::"b" (msecs));
311
     __asm__ __volatile__ (
311
     __asm__ __volatile__ (
312
     "":::"ebx");
312
     "":::"ebx");
313
 
313
 
314
};
314
};
315
 
315
 
316
static inline void mdelay1(u32 time)
316
static inline void mdelay1(u32 time)
317
{
317
{
318
    time /= 10;
318
    time /= 10;
319
    if(!time) time = 1;
319
    if(!time) time = 1;
320
 
320
 
321
     __asm__ __volatile__ (
321
     __asm__ __volatile__ (
322
     "call *__imp__Delay"
322
     "call *__imp__Delay"
323
     ::"b" (time));
323
     ::"b" (time));
324
     __asm__ __volatile__ (
324
     __asm__ __volatile__ (
325
     "":::"ebx");
325
     "":::"ebx");
326
 
326
 
327
};
327
};
328
 
328
 
329
static inline u32 __PciApi(int cmd)
329
static inline u32 __PciApi(int cmd)
330
{
330
{
331
     u32 retval;
331
     u32 retval;
332
 
332
 
333
     __asm__ __volatile__ (
333
     __asm__ __volatile__ (
334
     "call *__imp__PciApi \n\t"
334
     "call *__imp__PciApi \n\t"
335
     "movzxb %%al, %%eax"
335
     "movzxb %%al, %%eax"
336
     :"=a" (retval)
336
     :"=a" (retval)
337
     :"a" (cmd)
337
     :"a" (cmd)
338
     :"cc");
338
     :"cc");
339
 
339
 
340
     return retval;
340
     return retval;
341
};
341
};
342
 
342
 
343
static inline void* __CreateObject(u32 pid, size_t size)
343
static inline void* __CreateObject(u32 pid, size_t size)
344
{
344
{
345
     void *retval;
345
     void *retval;
346
 
346
 
347
     __asm__ __volatile__ (
347
     __asm__ __volatile__ (
348
     "call *__imp__CreateObject \n\t"
348
     "call *__imp__CreateObject \n\t"
349
     :"=a" (retval)
349
     :"=a" (retval)
350
     :"a" (size),"b"(pid)
350
     :"a" (size),"b"(pid)
351
     :"esi","edi", "memory");
351
     :"esi","edi", "memory");
352
     return retval;
352
     return retval;
353
}
353
}
354
 
354
 
355
static inline void __DestroyObject(void *obj)
355
static inline void __DestroyObject(void *obj)
356
{
356
{
357
     __asm__ __volatile__ (
357
     __asm__ __volatile__ (
358
     "call *__imp__DestroyObject \n\t"
358
     "call *__imp__DestroyObject \n\t"
359
     :
359
     :
360
     :"a" (obj));
360
     :"a" (obj));
361
     __asm__ __volatile__ (
361
     __asm__ __volatile__ (
362
     ""
362
     ""
363
     :::"eax","ebx","ecx","edx","esi","edi","cc","memory");
363
     :::"eax","ebx","ecx","edx","esi","edi","cc","memory");
364
}
364
}
365
 
365
 
366
static inline u32 GetService(const char *name)
366
static inline u32 GetService(const char *name)
367
{
367
{
368
    u32 handle;
368
    u32 handle;
369
 
369
 
370
    __asm__ __volatile__
370
    __asm__ __volatile__
371
    (
371
    (
372
     "pushl %%eax \n\t"
372
     "pushl %%eax \n\t"
373
     "call *__imp__GetService"
373
     "call *__imp__GetService"
374
     :"=a" (handle)
374
     :"=a" (handle)
375
     :"a" (name)
375
     :"a" (name)
376
     :"ebx","ecx","edx","esi", "edi"
376
     :"ebx","ecx","edx","esi", "edi"
377
  );
377
  );
378
  return handle;
378
  return handle;
379
};
379
};
380
 
380
 
381
static inline u32 safe_cli(void)
381
static inline u32 safe_cli(void)
382
{
382
{
383
     u32 ifl;
383
     u32 ifl;
384
     __asm__ __volatile__ (
384
     __asm__ __volatile__ (
385
     "pushf\n\t"
385
     "pushf\n\t"
386
     "popl %0\n\t"
386
     "popl %0\n\t"
387
     "cli\n"
387
     "cli\n"
388
     : "=r" (ifl));
388
     : "=r" (ifl));
389
    return ifl;
389
    return ifl;
390
}
390
}
391
 
391
 
392
static inline void safe_sti(u32 efl)
392
static inline void safe_sti(u32 efl)
393
{
393
{
394
     if (efl & (1<<9))
394
     if (efl & (1<<9))
395
        __asm__ __volatile__ ("sti");
395
        __asm__ __volatile__ ("sti");
396
}
396
}
397
 
397
 
398
static inline u32 get_eflags(void)
398
static inline u32 get_eflags(void)
399
{
399
{
400
    u32 val;
400
    u32 val;
401
    asm volatile (
401
    asm volatile (
402
    "pushfl\n\t"
402
    "pushfl\n\t"
403
    "popl %0\n"
403
    "popl %0\n"
404
    : "=r" (val));
404
    : "=r" (val));
405
    return val;
405
    return val;
406
}
406
}
407
 
407
 
408
static inline void __clear (void * dst, unsigned len)
408
static inline void __clear (void * dst, unsigned len)
409
{
409
{
410
     u32 tmp;
410
     u32 tmp;
411
     __asm__ __volatile__ (
411
     __asm__ __volatile__ (
412
     "cld \n\t"
412
     "cld \n\t"
413
     "rep stosb \n"
413
     "rep stosb \n"
414
     :"=c"(tmp),"=D"(tmp)
414
     :"=c"(tmp),"=D"(tmp)
415
     :"a"(0),"c"(len),"D"(dst));
415
     :"a"(0),"c"(len),"D"(dst));
416
     __asm__ __volatile__ ("":::"ecx","edi");
416
     __asm__ __volatile__ ("":::"ecx","edi");
417
};
417
};
418
 
418
 
419
static inline void out8(const u16 port, const u8 val)
419
static inline void out8(const u16 port, const u8 val)
420
{
420
{
421
    __asm__ __volatile__
421
    __asm__ __volatile__
422
    ("outb  %1, %0\n" : : "dN"(port), "a"(val));
422
    ("outb  %1, %0\n" : : "dN"(port), "a"(val));
423
}
423
}
424
 
424
 
425
static inline void out16(const u16 port, const u16 val)
425
static inline void out16(const u16 port, const u16 val)
426
{
426
{
427
    __asm__ __volatile__
427
    __asm__ __volatile__
428
    ("outw  %1, %0\n" : : "dN"(port), "a"(val));
428
    ("outw  %1, %0\n" : : "dN"(port), "a"(val));
429
}
429
}
430
 
430
 
431
static inline void out32(const u16 port, const u32 val)
431
static inline void out32(const u16 port, const u32 val)
432
{
432
{
433
    __asm__ __volatile__
433
    __asm__ __volatile__
434
    ("outl  %1, %0\n" : : "dN"(port), "a"(val));
434
    ("outl  %1, %0\n" : : "dN"(port), "a"(val));
435
}
435
}
436
 
436
 
437
static inline u8 in8(const u16 port)
437
static inline u8 in8(const u16 port)
438
{
438
{
439
    u8 tmp;
439
    u8 tmp;
440
    __asm__ __volatile__
440
    __asm__ __volatile__
441
    ("inb %1, %0\n" : "=a"(tmp) : "dN"(port));
441
    ("inb %1, %0\n" : "=a"(tmp) : "dN"(port));
442
    return tmp;
442
    return tmp;
443
};
443
};
444
 
444
 
445
static inline u16 in16(const u16 port)
445
static inline u16 in16(const u16 port)
446
{
446
{
447
    u16 tmp;
447
    u16 tmp;
448
    __asm__ __volatile__
448
    __asm__ __volatile__
449
    ("inw %1, %0\n" : "=a"(tmp) : "dN"(port));
449
    ("inw %1, %0\n" : "=a"(tmp) : "dN"(port));
450
    return tmp;
450
    return tmp;
451
};
451
};
452
 
452
 
453
static inline u32 in32(const u16 port)
453
static inline u32 in32(const u16 port)
454
{
454
{
455
    u32 tmp;
455
    u32 tmp;
456
    __asm__ __volatile__
456
    __asm__ __volatile__
457
    ("inl %1, %0\n" : "=a"(tmp) : "dN"(port));
457
    ("inl %1, %0\n" : "=a"(tmp) : "dN"(port));
458
    return tmp;
458
    return tmp;
459
};
459
};
460
 
460
 
461
static inline void delay(int time)
461
static inline void delay(int time)
462
{
462
{
463
     __asm__ __volatile__ (
463
     __asm__ __volatile__ (
464
     "call *__imp__Delay"
464
     "call *__imp__Delay"
465
     ::"b" (time));
465
     ::"b" (time));
466
     __asm__ __volatile__ (
466
     __asm__ __volatile__ (
467
     "":::"ebx");
467
     "":::"ebx");
468
 
468
 
469
}
469
}
470
 
470
 
471
static inline void change_task(void)
471
static inline void change_task(void)
472
{
472
{
473
     __asm__ __volatile__ (
473
     __asm__ __volatile__ (
474
     "call *__imp__ChangeTask");
474
     "call *__imp__ChangeTask");
475
}
475
}
476
 
476
 
477
static inline void sysSetScreen(int width, int height, int pitch)
477
static inline void sysSetScreen(int width, int height, int pitch)
478
{
478
{
479
    __asm__ __volatile__
479
    __asm__ __volatile__
480
    (
480
    (
481
        "call *__imp__SetScreen"
481
        "call *__imp__SetScreen"
482
        :
482
        :
483
        :"a" (width-1),"d"(height-1), "c"(pitch)
483
        :"a" (width-1),"d"(height-1), "c"(pitch)
484
    );
484
    );
485
    __asm__ __volatile__
485
    __asm__ __volatile__
486
    ("" :::"eax","ecx","edx");
486
    ("" :::"eax","ecx","edx");
487
}
487
}
488
 
488
 
489
void  FASTCALL sysSetFramebuffer(void *fb)__asm__("SetFramebuffer");
489
void  FASTCALL sysSetFramebuffer(void *fb)__asm__("SetFramebuffer");
490
 
-
 
491
static inline void __iomem *ioremap(u32 offset, size_t size)
-
 
492
{
-
 
493
    return (void __iomem*) MapIoMem(offset, size, PG_SW|PG_NOCACHE|0x100);
-
 
494
}
-
 
495
 
-
 
496
static inline void __iomem *ioremap_nocache(u32 offset, size_t size)
-
 
497
{
-
 
498
    return (void __iomem*) MapIoMem(offset, size, PG_SW|PG_NOCACHE|0x100);
-
 
499
}
-
 
500
 
-
 
501
static inline void __iomem *ioremap_wc(u32 offset, size_t size)
-
 
502
{
-
 
503
    return (void __iomem*) MapIoMem(offset, size, PG_SW|PG_WRITEC|0x100);
-
 
504
}
-
 
505
 
-
 
506
 
-
 
507
static inline void iounmap(void *addr)
-
 
508
{
-
 
509
    FreeKernelSpace(addr);
-
 
510
}
490
 
511
 
491
 
512
static inline void __SysMsgBoardStr(char *text)
492
static inline void __SysMsgBoardStr(char *text)
513
{
493
{
514
    __asm__ __volatile__(
494
    __asm__ __volatile__(
515
    "call *__imp__SysMsgBoardStr"
495
    "call *__imp__SysMsgBoardStr"
516
    ::"S" (text));
496
    ::"S" (text));
517
};
497
};
518
 
498
 
519
static inline void *vzalloc(unsigned long size)
499
static inline void *vzalloc(unsigned long size)
520
{
500
{
521
    void *mem;
501
    void *mem;
522
 
502
 
523
    mem = KernelAlloc(size);
503
    mem = KernelAlloc(size);
524
    if(mem)
504
    if(mem)
525
        memset(mem, 0, size);
505
        memset(mem, 0, size);
526
 
506
 
527
   return mem;
507
   return mem;
528
};
508
};
529
 
509
 
530
 
510
 
531
static inline int power_supply_is_system_supplied(void) { return -1; };
511
static inline int power_supply_is_system_supplied(void) { return -1; };
532
 
512
 
533
#endif
513
#endif
534
>
514
>
535
>
515
>