Subversion Repositories Kolibri OS

Rev

Rev 1408 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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