Subversion Repositories Kolibri OS

Rev

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

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