Subversion Repositories Kolibri OS

Rev

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

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