Subversion Repositories Kolibri OS

Rev

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

Rev 1179 Rev 1221
Line 40... Line 40...
40
#define PG_SW       0x003
40
#define PG_SW       0x003
41
#define PG_NOCACHE  0x018
41
#define PG_NOCACHE  0x018
Line 42... Line 42...
42
 
42
 
-
 
43
void*  STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
-
 
44
void   STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace");
43
void*  STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
45
addr_t STDCALL MapIoMem(addr_t base, size_t size, u32_t flags)__asm__("MapIoMem");
44
void*  STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
46
void*  STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
45
void*  STDCALL KernelFree(void *mem)__asm__("KernelFree");
47
void*  STDCALL KernelFree(void *mem)__asm__("KernelFree");
46
void*  STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
48
void*  STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
Line 54... Line 56...
54
 
56
 
Line 55... Line 57...
55
int   STDCALL AttachIntHandler(int irq, void *handler, u32_t access) __asm__("AttachIntHandler");
57
int   STDCALL AttachIntHandler(int irq, void *handler, u32_t access) __asm__("AttachIntHandler");
Line 56... Line -...
56
 
-
 
57
 
-
 
58
//void *CreateObject(u32 pid, size_t size);
-
 
59
//void *DestroyObject(void *obj);
-
 
60
 
-
 
61
addr_t STDCALL MapIoMem(addr_t base, size_t size, u32_t flags)__asm__("MapIoMem");
58
 
Line 62... Line 59...
62
 
59
 
63
///////////////////////////////////////////////////////////////////////////////
60
///////////////////////////////////////////////////////////////////////////////
Line 165... Line 162...
165
extern inline void usleep(u32_t delay)
162
extern inline void usleep(u32_t delay)
166
{
163
{
167
     if( !delay )
164
     if( !delay )
168
        delay++;
165
        delay++;
169
     delay*=1000;
166
     delay*= 128;
Line 170... Line 167...
170
 
167
 
-
 
168
     while(delay--)
171
     while(delay--)
169
     {
172
     __asm__ __volatile__ (
170
        __asm__ __volatile__(
173
     "xorl %%eax, %%eax \n\t"
171
        "xorl %%eax, %%eax \n\t"
-
 
172
        "cpuid \n\t"
174
     "cpuid \n\t"
173
        "xorl %%eax, %%eax"
-
 
174
        :::"ebx","ecx","edx");
175
        :::"eax","ebx","ecx","edx");
175
     };
Line 176... Line 176...
176
};
176
};
177
 
177
 
178
static inline void udelay(u32_t delay)
178
static inline void udelay(u32_t delay)
179
{
179
{
Line 180... Line 180...
180
    if(!delay) delay++;
180
    if(!delay) delay++;
181
    delay*=500;
181
    delay*= 128;
182
 
182
 
183
    while(delay--)
183
    while(delay--)
184
    {
184
    {
-
 
185
        __asm__ __volatile__(
185
        __asm__ __volatile__(
186
        "xorl %%eax, %%eax \n\t"
186
        "xorl %%eax, %%eax \n\t"
187
        "cpuid \n\t"
187
        "cpuid"
188
        "xorl %%eax, %%eax"
Line 188... Line 189...
188
        :::"eax","ebx","ecx","edx" );
189
        :::"ebx","ecx","edx" );
189
    }
190
    }
Line 202... Line 203...
202
 
203
 
Line 203... Line 204...
203
};
204
};
Line 204... Line 205...
204
 
205
 
205
 
206
 
206
extern inline u32_t __PciApi(int cmd)
207
static inline u32_t __PciApi(int cmd)
Line 207... Line 208...
207
{
208
{
208
     u32_t retval;
209
     u32_t retval;
Line 214... Line 215...
214
     :"memory");
215
     :"memory");
215
     return retval;
216
     return retval;
216
};
217
};
217
 
218
 
Line 218... Line 219...
218
extern inline void* __CreateObject(u32_t pid, size_t size)
219
static inline void* __CreateObject(u32_t pid, size_t size)
219
{
220
{
220
     void *retval;
221
     void *retval;
Line 221... Line 222...
221
 
222
 
222
     __asm__ __volatile__ (
223
     __asm__ __volatile__ (
Line 226... Line 227...
226
     :"esi","edi", "memory");
227
     :"esi","edi", "memory");
227
     return retval;
228
     return retval;
228
}
229
}
229
 
230
 
Line 230... Line 231...
230
extern inline void *__DestroyObject(void *obj)
231
static inline void *__DestroyObject(void *obj)
231
{
232
{
232
     __asm__ __volatile__ (
233
     __asm__ __volatile__ (
233
     "call *__imp__DestroyObject"
234
     "call *__imp__DestroyObject"
234
     :
235
     :
235
     :"a" (obj)
236
     :"a" (obj)
Line 254... Line 255...
254
  return retval;
255
  return retval;
255
};
256
};
256
*/
257
*/
257
 
258
 
Line 258... Line 259...
258
extern inline u32_t safe_cli(void)
259
static inline u32_t safe_cli(void)
259
{
260
{
260
     u32_t ifl;
261
     u32_t ifl;
261
     __asm__ __volatile__ (
262
     __asm__ __volatile__ (
262
     "pushf\n\t"
263
     "pushf\n\t"
263
     "popl %0\n\t"
264
     "popl %0\n\t"
264
     "cli\n"
265
     "cli\n"
265
     : "=r" (ifl));
266
     : "=r" (ifl));
266
    return ifl;
267
    return ifl;
267
}
268
}
Line 268... Line 269...
268
 
269
 
269
extern inline void safe_sti(u32_t ifl)
270
static inline void safe_sti(u32_t ifl)
270
{
271
{
271
     __asm__ __volatile__ (
272
     __asm__ __volatile__ (
272
     "pushl %0\n\t"
273
     "pushl %0\n\t"
273
     "popf\n"
274
     "popf\n"
274
     : : "r" (ifl)
275
     : : "r" (ifl)
275
	);
276
	);
Line 276... Line 277...
276
}
277
}
277
 
278
 
278
extern inline void __clear (void * dst, unsigned len)
279
static inline void __clear (void * dst, unsigned len)
279
{
280
{
280
     u32_t tmp;
281
     u32_t tmp;
281
     __asm__ __volatile__ (
282
     __asm__ __volatile__ (
Line 286... Line 287...
286
     :"a"(0),"c"(len),"D"(dst));
287
     :"a"(0),"c"(len),"D"(dst));
287
     __asm__ __volatile__ ("":::"ecx","edi");
288
     __asm__ __volatile__ ("":::"ecx","edi");
288
};
289
};
289
 
290
 
Line 290... Line 291...
290
extern inline void out8(const u16_t port, const u8_t val)
291
static inline void out8(const u16_t port, const u8_t val)
291
{
292
{
292
    __asm__ __volatile__
293
    __asm__ __volatile__
293
    ("outb  %1, %0\n" : : "dN"(port), "a"(val));
294
    ("outb  %1, %0\n" : : "dN"(port), "a"(val));
294
}
295
}
Line 295... Line 296...
295
 
296
 
296
extern inline void out16(const u16_t port, const u16_t val)
297
static inline void out16(const u16_t port, const u16_t val)
297
{
298
{
298
    __asm__ __volatile__
299
    __asm__ __volatile__
299
    ("outw  %1, %0\n" : : "dN"(port), "a"(val));
300
    ("outw  %1, %0\n" : : "dN"(port), "a"(val));
Line 300... Line 301...
300
}
301
}
301
 
302
 
302
extern inline void out32(const u16_t port, const u32_t val)
303
static inline void out32(const u16_t port, const u32_t val)
303
{
304
{
304
    __asm__ __volatile__
305
    __asm__ __volatile__
Line 305... Line 306...
305
    ("outl  %1, %0\n" : : "dN"(port), "a"(val));
306
    ("outl  %1, %0\n" : : "dN"(port), "a"(val));
306
}
307
}
307
 
308
 
308
extern inline u8_t in8(const u16_t port)
309
static inline u8_t in8(const u16_t port)
309
{
310
{
310
    u8_t tmp;
311
    u8_t tmp;
311
    __asm__ __volatile__
312
    __asm__ __volatile__
Line 312... Line 313...
312
    ("inb %1, %0\n" : "=a"(tmp) : "dN"(port));
313
    ("inb %1, %0\n" : "=a"(tmp) : "dN"(port));
313
    return tmp;
314
    return tmp;
314
};
315
};
315
 
316
 
316
extern inline u16_t in16(const u16_t port)
317
static inline u16_t in16(const u16_t port)
317
{
318
{
318
    u16_t tmp;
319
    u16_t tmp;
Line 319... Line 320...
319
    __asm__ __volatile__
320
    __asm__ __volatile__
320
    ("inw %1, %0\n" : "=a"(tmp) : "dN"(port));
321
    ("inw %1, %0\n" : "=a"(tmp) : "dN"(port));
321
    return tmp;
322
    return tmp;
322
};
323
};
323
 
324
 
324
extern inline u32_t in32(const u16_t port)
325
static inline u32_t in32(const u16_t port)
325
{
326
{
Line 326... Line 327...
326
    u32_t tmp;
327
    u32_t tmp;
327
    __asm__ __volatile__
328
    __asm__ __volatile__
328
    ("inl %1, %0\n" : "=a"(tmp) : "dN"(port));
329
    ("inl %1, %0\n" : "=a"(tmp) : "dN"(port));
329
    return tmp;
330
    return tmp;
330
};
331
};
331
 
332
 
332
extern inline void delay(int time)
333
static inline void delay(int time)
Line 333... Line 334...
333
{
334
{
Line 334... Line 335...
334
     __asm__ __volatile__ (
335
     __asm__ __volatile__ (
335
     "call *__imp__Delay"
336
     "call *__imp__Delay"
336
     ::"b" (time));
337
     ::"b" (time));
337
     __asm__ __volatile__ (
338
     __asm__ __volatile__ (
338
     "":::"ebx");
339
     "":::"ebx");