Subversion Repositories Kolibri OS

Rev

Rev 1117 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1117 serge 1
 
2
#define __SYSCALL_H__
3
4
 
5
 
6
7
 
8
{
9
  u32_t      handle;
10
  u32_t      io_code;
11
  void       *input;
12
  int        inp_size;
13
  void       *output;
14
  int        out_size;
15
}ioctl_t;
16
17
 
18
19
 
20
#define ERR_PARAM   -1
21
22
 
23
 
1179 serge 24
1117 serge 25
 
26
27
 
28
#define IMPORT __attribute__ ((dllimport))
29
30
 
31
32
 
33
#define PciApi          __PciApi
34
//#define RegService      __RegService
35
#define CreateObject    __CreateObject
36
#define DestroyObject   __DestroyObject
37
38
 
39
40
 
41
#define PG_NOCACHE  0x018
42
43
 
44
void*  STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
45
void*  STDCALL KernelFree(void *mem)__asm__("KernelFree");
46
void*  STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
47
int    STDCALL UserFree(void *mem)__asm__("UserFree");
48
49
 
50
51
 
52
53
 
54
55
 
56
57
 
58
 
59
//void *DestroyObject(void *obj);
60
61
 
62
63
 
64
65
 
66
                            int z, int h)__asm__("SetMouseData");
67
68
 
69
70
 
71
u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16");
72
u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32");
73
74
 
75
u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16");
76
u32_t STDCALL PciWrite32(u32_t bus, u32_t devfn, u32_t reg,u32_t val)__asm__("PciWrite32");
77
78
 
79
        PciRead8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
80
81
 
82
        PciRead16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
83
84
 
85
        PciRead32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
86
87
 
88
        PciWrite8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
89
90
 
91
        PciWrite16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
92
93
 
94
        PciWrite32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
95
96
 
97
 
98
99
 
100
int dbgprintf(const char* format, ...);
101
102
 
103
104
 
105
{
106
  int retval;
107
108
 
109
      :"=a"(retval)
110
      :"a"(61), "b"(1));
111
  return retval;
112
}
113
114
 
115
{
116
  int retval;
117
118
 
119
      :"=a"(retval)
120
      :"a"(61), "b"(2));
121
  return retval;
122
}
123
124
 
125
{
126
  int retval;
127
128
 
129
      :"=a"(retval)
130
      :"a"(61), "b"(3));
131
  return retval;
132
}
133
134
 
135
{
136
     u32_t retval;
137
138
 
139
     "call *__imp__GetPgAddr \n\t"
140
     :"=eax" (retval)
141
     :"a" (mem) );
142
     return retval;
143
};
144
145
 
146
{
147
     size = (size+4095) & ~4095;
148
     __asm__ __volatile__ (
149
     "call *__imp__CommitPages"
150
     ::"a" (page), "b"(mem),"c"(size>>12)
151
     :"edx" );
152
     __asm__ __volatile__ ("":::"eax","ebx","ecx");
153
};
154
155
 
156
{
157
     size = (size+4095) & ~4095;
158
     __asm__ __volatile__ (
159
     "call *__imp__UnmapPages"
160
     ::"a" (mem), "c"(size>>12)
161
     :"edx");
162
     __asm__ __volatile__ ("":::"eax","ecx");
163
};
164
165
 
166
{
167
     if( !delay )
168
        delay++;
169
     delay*=1000;
170
171
 
172
     __asm__ __volatile__ (
173
     "xorl %%eax, %%eax \n\t"
174
     "cpuid \n\t"
175
        :::"eax","ebx","ecx","edx");
176
};
177
178
 
179
{
180
    if(!delay) delay++;
181
    delay*=500;
182
183
 
184
    {
185
        __asm__ __volatile__(
186
        "xorl %%eax, %%eax \n\t"
187
        "cpuid"
188
        :::"eax","ebx","ecx","edx" );
189
    }
190
}
191
192
 
193
{
194
    time /= 10;
195
    if(!time) time = 1;
196
197
 
198
     "call *__imp__Delay"
199
     ::"b" (time));
200
     __asm__ __volatile__ (
201
     "":::"ebx");
202
203
 
204
205
 
206
 
207
{
208
     u32_t retval;
209
210
 
211
     "call *__imp__PciApi"
212
     :"=a" (retval)
213
     :"a" (cmd)
214
     :"memory");
215
     return retval;
216
};
217
218
 
219
{
220
     void *retval;
221
222
 
223
     "call *__imp__CreateObject \n\t"
224
     :"=a" (retval)
225
     :"a" (size),"b"(pid)
226
     :"esi","edi", "memory");
227
     return retval;
228
}
229
230
 
231
{
232
     __asm__ __volatile__ (
233
     "call *__imp__DestroyObject"
234
     :
235
     :"a" (obj)
236
     :"ebx","edx","esi","edi", "memory");
237
}
238
239
 
240
 
241
u32 __RegService(char *name, srv_proc_t proc)
242
{
243
  u32 retval;
244
245
 
246
  (
247
    "pushl %%eax \n\t"
248
    "pushl %%ebx \n\t"
249
    "call *__imp__RegService \n\t"
250
    :"=eax" (retval)
251
    :"a" (proc), "b" (name)
252
    :"memory"
253
  );
254
  return retval;
255
};
256
*/
257
258
 
259
{
260
     u32_t ifl;
261
     __asm__ __volatile__ (
262
     "pushf\n\t"
263
     "popl %0\n\t"
264
     "cli\n"
265
     : "=r" (ifl));
266
    return ifl;
267
}
268
269
 
270
{
271
     __asm__ __volatile__ (
272
     "pushl %0\n\t"
273
     "popf\n"
274
     : : "r" (ifl)
275
	);
276
}
277
278
 
279
{
280
     u32_t tmp;
281
     __asm__ __volatile__ (
282
//     "xorl %%eax, %%eax \n\t"
283
     "cld \n\t"
284
     "rep stosb \n"
285
     :"=c"(tmp),"=D"(tmp)
286
     :"a"(0),"c"(len),"D"(dst));
287
     __asm__ __volatile__ ("":::"ecx","edi");
288
};
289
290
 
291
{
292
    __asm__ __volatile__
293
    ("outb  %1, %0\n" : : "dN"(port), "a"(val));
294
}
295
296
 
297
{
298
    __asm__ __volatile__
299
    ("outw  %1, %0\n" : : "dN"(port), "a"(val));
300
}
301
302
 
303
{
304
    __asm__ __volatile__
305
    ("outl  %1, %0\n" : : "dN"(port), "a"(val));
306
}
307
308
 
309
{
310
    u8_t tmp;
311
    __asm__ __volatile__
312
    ("inb %1, %0\n" : "=a"(tmp) : "dN"(port));
313
    return tmp;
314
};
315
316
 
317
{
318
    u16_t tmp;
319
    __asm__ __volatile__
320
    ("inw %1, %0\n" : "=a"(tmp) : "dN"(port));
321
    return tmp;
322
};
323
324
 
325
{
326
    u32_t tmp;
327
    __asm__ __volatile__
328
    ("inl %1, %0\n" : "=a"(tmp) : "dN"(port));
329
    return tmp;
330
};
331
332
 
333
{
334
     __asm__ __volatile__ (
335
     "call *__imp__Delay"
336
     ::"b" (time));
337
     __asm__ __volatile__ (
338
     "":::"ebx");
339
340
 
341
342
 
343
{
344
     __asm__ __volatile__ (
345
     "call *__imp__ChangeTask");
346
}
347
348
 
349
350
 
351