Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
948 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
//void *DestroyObject(void *obj);
53
54
 
55
56
 
57
58
 
59
 
60
61
 
62
u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16");
63
u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32");
64
65
 
66
        PciRead32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
67
68
 
69
        PciRead8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
70
71
 
72
u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16");
73
u32_t STDCALL PciWrite32(u32_t bus, u32_t devfn, u32_t reg,u32_t val)__asm__("PciWrite32");
74
75
 
76
        PciWrite8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
77
78
 
79
        PciWrite16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
80
81
 
82
        PciWrite32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
83
84
 
85
 
86
87
 
88
int dbgprintf(const char* format, ...);
89
90
 
91
92
 
93
{
94
  int retval;
95
96
 
97
      :"=a"(retval)
98
      :"a"(61), "b"(1));
99
  return retval;
100
}
101
102
 
103
{
104
  int retval;
105
106
 
107
      :"=a"(retval)
108
      :"a"(61), "b"(2));
109
  return retval;
110
}
111
112
 
113
{
114
  int retval;
115
116
 
117
      :"=a"(retval)
118
      :"a"(61), "b"(3));
119
  return retval;
120
}
121
122
 
123
{
124
     u32_t retval;
125
126
 
127
     "call *__imp__GetPgAddr \n\t"
128
     :"=eax" (retval)
129
     :"a" (mem) );
130
     return retval;
131
};
132
133
 
134
{
135
     size = (size+4095) & ~4095;
136
     __asm__ __volatile__ (
137
     "call *__imp__CommitPages"
138
     ::"a" (page), "b"(mem),"c"(size>>12)
139
     :"edx" );
140
     __asm__ __volatile__ ("":::"eax","ebx","ecx");
141
};
142
143
 
144
{
145
     size = (size+4095) & ~4095;
146
     __asm__ __volatile__ (
147
     "call *__imp__UnmapPages"
148
     ::"a" (mem), "c"(size>>12)
149
     :"edx");
150
     __asm__ __volatile__ ("":::"eax","ecx");
151
};
152
153
 
154
{
155
     if( !delay )
156
        delay++;
157
     delay*=2000;
158
159
 
160
     "1:\n\t"
161
     "xorl %%eax, %%eax \n\t"
162
     "cpuid \n\t"
163
     "decl %%edi \n\t"
164
     "jnz 1b"
165
     :
166
     :"D"(delay)
167
     :"eax","ebx","ecx","edx");
168
};
169
170
 
171
{
172
     u32_t retval;
173
174
 
175
     "call *__imp__PciApi"
176
     :"=a" (retval)
177
     :"a" (cmd)
178
     :"memory");
179
     return retval;
180
};
181
182
 
183
{
184
     void *retval;
185
186
 
187
     "call *__imp__CreateObject \n\t"
188
     :"=a" (retval)
189
     :"a" (size),"b"(pid)
190
     :"esi","edi", "memory");
191
     return retval;
192
}
193
194
 
195
{
196
     __asm__ __volatile__ (
197
     "call *__imp__DestroyObject"
198
     :
199
     :"a" (obj)
200
     :"ebx","edx","esi","edi", "memory");
201
}
202
203
 
204
 
205
u32 __RegService(char *name, srv_proc_t proc)
206
{
207
  u32 retval;
208
209
 
210
  (
211
    "pushl %%eax \n\t"
212
    "pushl %%ebx \n\t"
213
    "call *__imp__RegService \n\t"
214
    :"=eax" (retval)
215
    :"a" (proc), "b" (name)
216
    :"memory"
217
  );
218
  return retval;
219
};
220
*/
221
222
 
223
{
224
     u32_t ifl;
225
     __asm__ __volatile__ (
226
     "pushf\n\t"
227
     "popl %0\n\t"
228
     "cli\n"
229
     : "=r" (ifl));
230
    return ifl;
231
}
232
233
 
234
{
235
     __asm__ __volatile__ (
236
     "pushl %0\n\t"
237
     "popf\n"
238
     : : "r" (ifl)
239
	);
240
}
241
242
 
243
{
244
     u32_t tmp;
245
     __asm__ __volatile__ (
246
//     "xorl %%eax, %%eax \n\t"
247
     "cld \n\t"
248
     "rep stosb \n"
249
     :"=c"(tmp),"=D"(tmp)
250
     :"a"(0),"c"(len),"D"(dst));
251
     __asm__ __volatile__ ("":::"ecx","edi");
252
};
253