Subversion Repositories Kolibri OS

Rev

Rev 1029 | Rev 1434 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1029 Rev 1408
Line -... Line 1...
-
 
1
#ifndef __SYSCALL_H__
-
 
2
#define __SYSCALL_H__
-
 
3
 
-
 
4
 
1
#define OS_BASE   0x80000000
5
#define OS_BASE   0x80000000
Line 2... Line 6...
2
 
6
 
3
typedef struct
7
typedef struct
4
{
8
{
Line 15... Line 19...
15
#define ERR_OK       0
19
#define ERR_OK       0
16
#define ERR_PARAM   -1
20
#define ERR_PARAM   -1
Line 17... Line 21...
17
 
21
 
Line 18... Line 22...
18
 
22
 
Line 19... Line 23...
19
u32_t __stdcall drvEntry(int)__asm__("_drvEntry");
23
u32_t drvEntry(int, char *)__asm__("_drvEntry");
20
 
24
 
Line 36... Line 40...
36
#define PG_SW       0x003
40
#define PG_SW       0x003
37
#define PG_NOCACHE  0x018
41
#define PG_NOCACHE  0x018
Line 38... Line 42...
38
 
42
 
-
 
43
void*  STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
-
 
44
void   STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace");
39
void*  STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
45
addr_t STDCALL MapIoMem(addr_t base, size_t size, u32_t flags)__asm__("MapIoMem");
40
void*  STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
46
void*  STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
41
void*  STDCALL KernelFree(void *mem)__asm__("KernelFree");
47
void*  STDCALL KernelFree(void *mem)__asm__("KernelFree");
42
void*  STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
48
void*  STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
Line -... Line 49...
-
 
49
int    STDCALL UserFree(void *mem)__asm__("UserFree");
-
 
50
 
-
 
51
void*  STDCALL GetDisplay()__asm__("GetDisplay");
-
 
52
 
43
int    STDCALL UserFree(void *mem)__asm__("UserFree");
53
 
Line 44... Line 54...
44
 
54
addr_t STDCALL AllocPage()__asm__("AllocPage");
Line 45... Line 55...
45
addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages");
55
addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages");
Line 46... Line 56...
46
 
56
 
Line 47... Line -...
47
void* STDCALL CreateRingBuffer(size_t size, u32_t map)__asm__("CreateRingBuffer");
-
 
48
 
-
 
49
u32_t STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService");
-
 
50
 
-
 
51
int   STDCALL AttachIntHandler(int irq, void *handler, u32_t access) __asm__("AttachIntHandler");
-
 
52
 
57
void* STDCALL CreateRingBuffer(size_t size, u32_t map)__asm__("CreateRingBuffer");
Line 53... Line 58...
53
 
58
 
54
//void *CreateObject(u32 pid, size_t size);
59
u32_t STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService");
Line 96... Line 101...
96
int dbgprintf(const char* format, ...);
101
int dbgprintf(const char* format, ...);
97
 
102
 
Line 98... Line 103...
98
///////////////////////////////////////////////////////////////////////////////
103
///////////////////////////////////////////////////////////////////////////////
Line 99... Line 104...
99
 
104
 
100
extern inline int GetScreenSize()
105
static inline int GetScreenSize()
101
{
106
{
Line 102... Line 107...
102
  int retval;
107
  int retval;
103
 
108
 
104
  asm("int $0x40"
109
  asm("int $0x40"
105
      :"=a"(retval)
110
      :"=a"(retval)
106
      :"a"(61), "b"(1));
111
      :"a"(61), "b"(1));
Line 107... Line 112...
107
  return retval;
112
  return retval;
108
}
113
}
109
 
114
 
Line 110... Line 115...
110
extern inline int GetScreenBpp()
115
static inline int GetScreenBpp()
111
{
116
{
112
  int retval;
117
  int retval;
113
 
118
 
114
  asm("int $0x40"
119
  asm("int $0x40"
Line 115... Line 120...
115
      :"=a"(retval)
120
      :"=a"(retval)
116
      :"a"(61), "b"(2));
121
      :"a"(61), "b"(2));
117
  return retval;
122
  return retval;
Line 118... Line 123...
118
}
123
}
119
 
124
 
120
extern inline int GetScreenPitch()
125
static inline int GetScreenPitch()
121
{
126
{
122
  int retval;
127
  int retval;
Line 123... Line 128...
123
 
128
 
124
  asm("int $0x40"
129
  asm("int $0x40"
125
      :"=a"(retval)
130
      :"=a"(retval)
Line 126... Line 131...
126
      :"a"(61), "b"(3));
131
      :"a"(61), "b"(3));
127
  return retval;
132
  return retval;
128
}
133
}
129
 
134
 
130
extern inline u32_t GetPgAddr(void *mem)
135
static inline u32_t GetPgAddr(void *mem)
131
{
136
{
Line 132... Line 137...
132
     u32_t retval;
137
     u32_t retval;
133
 
138
 
134
     __asm__ __volatile__ (
139
     __asm__ __volatile__ (
135
     "call *__imp__GetPgAddr \n\t"
140
     "call *__imp__GetPgAddr \n\t"
136
     :"=eax" (retval)
141
     :"=eax" (retval)
137
     :"a" (mem) );
142
     :"a" (mem) );
138
     return retval;
143
     return retval;
139
};
144
};
140
 
145
 
Line 141... Line 146...
141
extern inline void CommitPages(void *mem, u32_t page, u32_t size)
146
static inline void CommitPages(void *mem, u32_t page, u32_t size)
142
{
147
{
143
     size = (size+4095) & ~4095;
148
     size = (size+4095) & ~4095;
144
     __asm__ __volatile__ (
149
     __asm__ __volatile__ (
145
     "call *__imp__CommitPages"
150
     "call *__imp__CommitPages"
146
     ::"a" (page), "b"(mem),"c"(size>>12)
151
     ::"a" (page), "b"(mem),"c"(size>>12)
147
     :"edx" );
152
     :"edx" );
148
     __asm__ __volatile__ ("":::"eax","ebx","ecx");
153
     __asm__ __volatile__ ("":::"eax","ebx","ecx");
149
};
154
};
Line 150... Line 155...
150
 
155
 
151
extern inline void UnmapPages(void *mem, size_t size)
156
static inline void UnmapPages(void *mem, size_t size)
152
{
157
{
153
     size = (size+4095) & ~4095;
158
     size = (size+4095) & ~4095;
154
     __asm__ __volatile__ (
159
     __asm__ __volatile__ (
Line 155... Line 160...
155
     "call *__imp__UnmapPages"
160
     "call *__imp__UnmapPages"
156
     ::"a" (mem), "c"(size>>12)
161
     ::"a" (mem), "c"(size>>12)
157
     :"edx");
162
     :"edx");
158
     __asm__ __volatile__ ("":::"eax","ecx");
163
     __asm__ __volatile__ ("":::"eax","ecx");
159
};
164
};
160
 
165
 
Line -... Line 166...
-
 
166
static inline void usleep(u32_t delay)
-
 
167
{
-
 
168
     if( !delay )
-
 
169
        delay++;
-
 
170
     delay*= 500;
-
 
171
 
-
 
172
     while(delay--)
-
 
173
        __asm__ __volatile__(
-
 
174
        "xorl %%eax, %%eax \n\t"
-
 
175
        "cpuid \n\t"
-
 
176
        :::"eax","ebx","ecx","edx");
-
 
177
     };
-
 
178
 
-
 
179
static inline void udelay(u32_t delay)
-
 
180
{
-
 
181
    if(!delay) delay++;
-
 
182
    delay*= 500;
-
 
183
 
-
 
184
    while(delay--)
-
 
185
    {
-
 
186
        __asm__ __volatile__(
-
 
187
        "xorl %%eax, %%eax \n\t"
-
 
188
        "cpuid"
-
 
189
        :::"eax","ebx","ecx","edx" );
-
 
190
    }
-
 
191
}
-
 
192
 
-
 
193
static inline void mdelay(u32_t time)
161
extern inline void usleep(u32_t delay)
194
{
162
{
195
    time /= 10;
163
     if( !delay )
196
    if(!time) time = 1;
Line 164... Line 197...
164
        delay++;
197
 
165
     delay*=1000;
198
     __asm__ __volatile__ (
Line 182... Line 215...
182
     :"memory");
215
     :"memory");
183
     return retval;
216
     return retval;
184
};
217
};
185
 
218
 
Line 186... Line 219...
186
extern inline void* __CreateObject(u32_t pid, size_t size)
219
static inline void* __CreateObject(u32_t pid, size_t size)
187
{
220
{
188
     void *retval;
221
     void *retval;
Line 189... Line 222...
189
 
222
 
190
     __asm__ __volatile__ (
223
     __asm__ __volatile__ (
Line 194... Line 227...
194
     :"esi","edi", "memory");
227
     :"esi","edi", "memory");
195
     return retval;
228
     return retval;
196
}
229
}
197
 
230
 
Line 198... Line 231...
198
extern inline void *__DestroyObject(void *obj)
231
static inline void __DestroyObject(void *obj)
199
{
232
{
200
     __asm__ __volatile__ (
233
     __asm__ __volatile__ (
201
     "call *__imp__DestroyObject"
234
     "call *__imp__DestroyObject \n\t"
202
     :
235
     :
203
     :"a" (obj)
236
     :"a" (obj));
-
 
237
     __asm__ __volatile__ (
-
 
238
     ""
204
     :"ebx","edx","esi","edi", "memory");
239
     :::"eax","ebx","ecx","edx","esi","edi","cc","memory");
205
}
240
}
Line 206... Line 241...
206
 
241
 
207
 
242
 
Line 222... Line 257...
222
  return retval;
257
  return retval;
223
};
258
};
224
*/
259
*/
225
 
260
 
Line -... Line 261...
-
 
261
 
-
 
262
static inline u32_t GetService(const char *name)
-
 
263
{
-
 
264
    u32_t handle;
-
 
265
 
-
 
266
    __asm__ __volatile__
-
 
267
    (
-
 
268
     "pushl %%eax \n\t"
-
 
269
     "call *__imp__GetService"
-
 
270
     :"=eax" (handle)
-
 
271
     :"a" (name)
-
 
272
     :"ebx","ecx","edx","esi", "edi"
-
 
273
  );
-
 
274
  return handle;
-
 
275
};
-
 
276
 
226
extern inline u32_t safe_cli(void)
277
static inline u32_t safe_cli(void)
227
{
278
{
228
     u32_t ifl;
279
     u32_t ifl;
229
     __asm__ __volatile__ (
280
     __asm__ __volatile__ (
230
     "pushf\n\t"
281
     "pushf\n\t"
231
     "popl %0\n\t"
282
     "popl %0\n\t"
232
     "cli\n"
283
     "cli\n"
233
     : "=r" (ifl));
284
     : "=r" (ifl));
234
    return ifl;
285
    return ifl;
235
}
286
}
Line 236... Line 287...
236
 
287
 
237
extern inline void safe_sti(u32_t ifl)
288
static inline void safe_sti(u32_t ifl)
238
{
289
{
239
     __asm__ __volatile__ (
290
     __asm__ __volatile__ (
240
     "pushl %0\n\t"
291
     "pushl %0\n\t"
241
     "popf\n"
292
     "popf\n"
242
     : : "r" (ifl)
293
     : : "r" (ifl)
243
	);
294
	);
Line 244... Line 295...
244
}
295
}
245
 
296
 
246
extern inline void __clear (void * dst, unsigned len)
297
static inline void __clear (void * dst, unsigned len)
247
{
298
{
248
     u32_t tmp;
299
     u32_t tmp;
249
     __asm__ __volatile__ (
300
     __asm__ __volatile__ (
Line 254... Line 305...
254
     :"a"(0),"c"(len),"D"(dst));
305
     :"a"(0),"c"(len),"D"(dst));
255
     __asm__ __volatile__ ("":::"ecx","edi");
306
     __asm__ __volatile__ ("":::"ecx","edi");
256
};
307
};
257
 
308
 
Line 258... Line 309...
258
extern inline void out8(const u16_t port, const u8_t val)
309
static inline void out8(const u16_t port, const u8_t val)
259
{
310
{
260
    __asm__ __volatile__
311
    __asm__ __volatile__
261
    ("outb  %1, %0\n" : : "dN"(port), "a"(val));
312
    ("outb  %1, %0\n" : : "dN"(port), "a"(val));
262
}
313
}
Line 263... Line 314...
263
 
314
 
264
extern inline void out16(const u16_t port, const u16_t val)
315
static inline void out16(const u16_t port, const u16_t val)
265
{
316
{
266
    __asm__ __volatile__
317
    __asm__ __volatile__
267
    ("outw  %1, %0\n" : : "dN"(port), "a"(val));
318
    ("outw  %1, %0\n" : : "dN"(port), "a"(val));
Line 268... Line 319...
268
}
319
}
269
 
320
 
270
extern inline void out32(const u16_t port, const u32_t val)
321
static inline void out32(const u16_t port, const u32_t val)
271
{
322
{
272
    __asm__ __volatile__
323
    __asm__ __volatile__
Line 273... Line 324...
273
    ("outl  %1, %0\n" : : "dN"(port), "a"(val));
324
    ("outl  %1, %0\n" : : "dN"(port), "a"(val));
274
}
325
}
275
 
326
 
276
extern inline u8_t in8(const u16_t port)
327
static inline u8_t in8(const u16_t port)
277
{
328
{
278
    u8_t tmp;
329
    u8_t tmp;
279
    __asm__ __volatile__
330
    __asm__ __volatile__
Line 280... Line 331...
280
    ("inb %1, %0\n" : "=a"(tmp) : "dN"(port));
331
    ("inb %1, %0\n" : "=a"(tmp) : "dN"(port));
281
    return tmp;
332
    return tmp;
282
};
333
};
283
 
334
 
284
extern inline u16_t in16(const u16_t port)
335
static inline u16_t in16(const u16_t port)
285
{
336
{
286
    u16_t tmp;
337
    u16_t tmp;
Line 287... Line 338...
287
    __asm__ __volatile__
338
    __asm__ __volatile__
288
    ("inw %1, %0\n" : "=a"(tmp) : "dN"(port));
339
    ("inw %1, %0\n" : "=a"(tmp) : "dN"(port));
289
    return tmp;
340
    return tmp;
290
};
341
};
291
 
342
 
292
extern inline u32_t in32(const u16_t port)
343
static inline u32_t in32(const u16_t port)
293
{
344
{
Line 294... Line 345...
294
    u32_t tmp;
345
    u32_t tmp;
295
    __asm__ __volatile__
346
    __asm__ __volatile__
296
    ("inl %1, %0\n" : "=a"(tmp) : "dN"(port));
347
    ("inl %1, %0\n" : "=a"(tmp) : "dN"(port));
297
    return tmp;
348
    return tmp;
298
};
349
};
299
 
350
 
300
extern inline void delay(int time)
351
static inline void delay(int time)
Line 301... Line 352...
301
{
352
{
Line 302... Line 353...
302
     __asm__ __volatile__ (
353
     __asm__ __volatile__ (
303
     "call *__imp__Delay"
354
     "call *__imp__Delay"
304
     ::"b" (time));
355
     ::"b" (time));
305
     __asm__ __volatile__ (
356
     __asm__ __volatile__ (
306
     "":::"ebx");
357
     "":::"ebx");
Line -... Line 358...
-
 
358
 
-
 
359
}
-
 
360
 
-
 
361
static inline void change_task()
-
 
362
{
-
 
363
     __asm__ __volatile__ (
-
 
364
     "call *__imp__ChangeTask");
-
 
365
}
-
 
366
 
-
 
367
static inline sysSetScreen(int width, int height, int pitch)
-
 
368
{
-
 
369
    __asm__ __volatile__
-
 
370
    (
-
 
371
        "call *__imp__SetScreen"
-
 
372
        :
-
 
373
        :"a" (width-1),"d"(height-1), "c"(pitch)
-
 
374
    );
-
 
375
    __asm__ __volatile__
-
 
376
    ("" :::"eax","ecx","edx");
-
 
377
}
-
 
378
 
-
 
379
int drm_order(unsigned long size);
-
 
380
 
-
 
381
static inline void __iomem *ioremap(uint32_t offset, size_t size)
-
 
382
{
-
 
383
    return (void __iomem*) MapIoMem(offset, size, 3);
-
 
384
}
-
 
385
 
-
 
386
static inline void iounmap(void *addr)
-
 
387
{
-
 
388
    FreeKernelSpace(addr);
-
 
389
}
-
 
390
 
-
 
391
static inline void *
-
 
392
pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-
 
393
                      addr_t *dma_handle)
-
 
394
{
-
 
395
    *dma_handle = AllocPages(size >> 12);
-
 
396
    return (void*)MapIoMem(*dma_handle, size, PG_SW+PG_NOCACHE);
-
 
397
}