2010-02-12 21:11:35 +01:00
|
|
|
#ifndef __SYSCALL_H__
|
|
|
|
#define __SYSCALL_H__
|
|
|
|
|
2015-01-04 16:48:58 +01:00
|
|
|
#include <ddk.h>
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
typedef u32 addr_t;
|
|
|
|
typedef u32 count_t;
|
|
|
|
|
2016-01-20 05:19:53 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int bpp;
|
|
|
|
int freq;
|
|
|
|
}videomode_t;
|
|
|
|
|
2016-01-27 06:30:28 +01:00
|
|
|
struct kos32_pdev
|
|
|
|
{
|
|
|
|
struct kos32_pdev *prev;
|
|
|
|
struct kos32_pdev *next;
|
|
|
|
u32 devid;
|
|
|
|
u32 class;
|
|
|
|
u8 devfn;
|
|
|
|
u8 bus;
|
|
|
|
u8 reserved[2];
|
|
|
|
u32 owner;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2008-12-13 04:32:16 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-03-17 18:42:57 +01:00
|
|
|
#define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport))
|
|
|
|
#define FASTCALL __attribute__ ((fastcall)) __attribute__ ((dllimport))
|
|
|
|
|
|
|
|
#define IMPORT __attribute__ ((dllimport))
|
2008-12-13 04:32:16 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define SysMsgBoardStr __SysMsgBoardStr
|
|
|
|
#define PciApi __PciApi
|
|
|
|
#define CreateObject __CreateObject
|
|
|
|
#define DestroyObject __DestroyObject
|
|
|
|
|
2011-02-17 12:21:25 +01:00
|
|
|
#define _alloca(x) __builtin_alloca((x))
|
|
|
|
|
2008-12-13 04:32:16 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
void* STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
|
2010-02-12 21:11:35 +01:00
|
|
|
void STDCALL FreeKernelSpace(void *mem)__asm__("FreeKernelSpace");
|
2014-12-27 16:42:08 +01:00
|
|
|
addr_t STDCALL MapIoMem(addr_t base, size_t size, u32 flags)__asm__("MapIoMem");
|
2008-12-13 04:32:16 +01:00
|
|
|
void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
|
2016-02-27 21:06:12 +01:00
|
|
|
void* STDCALL KernelFree(const void *mem)__asm__("KernelFree");
|
2008-12-13 04:32:16 +01:00
|
|
|
void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
|
|
|
|
int STDCALL UserFree(void *mem)__asm__("UserFree");
|
|
|
|
|
2010-09-12 00:23:28 +02:00
|
|
|
void* STDCALL GetDisplay(void)__asm__("GetDisplay");
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 IMPORT GetTimerTicks(void)__asm__("GetTimerTicks");
|
2016-01-20 05:19:53 +01:00
|
|
|
u64 IMPORT GetClockNs(void)__asm__("GetClockNs");
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2010-09-12 00:23:28 +02:00
|
|
|
addr_t STDCALL AllocPage(void)__asm__("AllocPage");
|
2008-12-13 04:32:16 +01:00
|
|
|
addr_t STDCALL AllocPages(count_t count)__asm__("AllocPages");
|
2012-09-04 23:42:08 +02:00
|
|
|
void IMPORT __attribute__((regparm(1)))
|
|
|
|
FreePage(addr_t page)__asm__("FreePage");
|
2014-12-27 16:42:08 +01:00
|
|
|
void STDCALL MapPage(void *vaddr, addr_t paddr, u32 flags)__asm__("MapPage");
|
2012-09-04 23:42:08 +02:00
|
|
|
|
2008-12-13 04:32:16 +01:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
void* STDCALL CreateRingBuffer(size_t size, u32 map)__asm__("CreateRingBuffer");
|
2008-12-13 04:32:16 +01:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService");
|
2008-12-13 04:32:16 +01:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
int STDCALL AttachIntHandler(int irq, void *handler, u32 access) __asm__("AttachIntHandler");
|
2009-02-08 19:41:45 +01:00
|
|
|
|
2010-03-17 18:42:57 +01:00
|
|
|
void FASTCALL MutexInit(struct mutex*)__asm__("MutexInit");
|
|
|
|
void FASTCALL MutexLock(struct mutex*)__asm__("MutexLock");
|
|
|
|
void FASTCALL MutexUnlock(struct mutex*)__asm__("MutexUnlock");
|
2009-02-08 19:41:45 +01:00
|
|
|
|
2015-01-04 16:48:58 +01:00
|
|
|
void FASTCALL InitRwsem(struct rw_semaphore *sem)__asm__("InitRwsem");
|
|
|
|
void FASTCALL DownRead(struct rw_semaphore *sem)__asm__("DownRead");
|
|
|
|
void FASTCALL DownWrite(struct rw_semaphore *sem)__asm__("DownWrite");
|
|
|
|
void FASTCALL UpRead(struct rw_semaphore *sem)__asm__("UpRead");
|
|
|
|
void FASTCALL UpWrite(struct rw_semaphore *sem)__asm__("UpWrite");
|
|
|
|
|
2011-02-17 12:21:25 +01:00
|
|
|
addr_t IMPORT GetStackBase(void)__asm__("GetStackBase");
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 IMPORT GetPid(void)__asm__("GetPid");
|
2011-02-17 12:21:25 +01:00
|
|
|
|
2013-10-29 08:49:21 +01:00
|
|
|
u32 STDCALL TimerHS(u32 delay, u32 interval,
|
|
|
|
void *fn, void *data)asm("TimerHS");
|
|
|
|
|
|
|
|
void STDCALL CancelTimerHS(u32 handle)asm("CancelTimerHS");
|
2012-09-04 23:42:08 +02:00
|
|
|
|
2013-04-26 13:01:23 +02:00
|
|
|
u64 IMPORT GetCpuFreq()__asm__("GetCpuFreq");
|
|
|
|
|
2008-12-13 04:32:16 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void STDCALL SetMouseData(int btn, int x, int y,
|
|
|
|
int z, int h)__asm__("SetMouseData");
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
void FASTCALL SetKeyboardData(u32 data)__asm__("SetKeyboardData");
|
2011-02-17 12:21:25 +01:00
|
|
|
|
2016-01-27 06:30:28 +01:00
|
|
|
struct kos32_pdev* IMPORT GetPCIList()__asm__("GetPCIList");
|
2011-02-17 12:21:25 +01:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
u8 STDCALL PciRead8 (u32 bus, u32 devfn, u32 reg)__asm__("PciRead8");
|
|
|
|
u16 STDCALL PciRead16(u32 bus, u32 devfn, u32 reg)__asm__("PciRead16");
|
|
|
|
u32 STDCALL PciRead32(u32 bus, u32 devfn, u32 reg)__asm__("PciRead32");
|
2008-12-13 04:32:16 +01:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 STDCALL PciWrite8 (u32 bus, u32 devfn, u32 reg,u8 val) __asm__("PciWrite8");
|
|
|
|
u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16");
|
|
|
|
u32 STDCALL PciWrite32(u32 bus, u32 devfn, u32 reg,u32 val)__asm__("PciWrite32");
|
2008-12-13 04:32:16 +01:00
|
|
|
|
|
|
|
#define pciReadByte(tag, reg) \
|
|
|
|
PciRead8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
|
|
|
|
|
|
|
|
#define pciReadWord(tag, reg) \
|
|
|
|
PciRead16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
|
|
|
|
|
|
|
|
#define pciReadLong(tag, reg) \
|
|
|
|
PciRead32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
|
|
|
|
|
|
|
|
#define pciWriteByte(tag, reg, val) \
|
|
|
|
PciWrite8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
|
|
|
|
|
|
|
|
#define pciWriteWord(tag, reg, val) \
|
|
|
|
PciWrite16(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
|
|
|
|
|
|
|
|
#define pciWriteLong(tag, reg, val) \
|
|
|
|
PciWrite32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
|
2008-12-13 04:32:16 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
int dbg_open(char *path);
|
|
|
|
int dbgprintf(const char* format, ...);
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-10-27 05:51:01 +01:00
|
|
|
static inline int CreateKernelThread(void *entry)
|
|
|
|
{
|
|
|
|
int pid;
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__CreateThread"
|
|
|
|
:"=a"(pid)
|
|
|
|
:"b"(1),"c"(entry),"d"(0)
|
|
|
|
:"memory");
|
|
|
|
__asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
|
|
|
|
return pid;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline evhandle_t CreateEvent(kevent_t *ev, u32 flags)
|
2010-09-12 00:23:28 +02:00
|
|
|
{
|
2010-09-13 22:07:22 +02:00
|
|
|
evhandle_t evh;
|
2010-09-12 00:23:28 +02:00
|
|
|
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__CreateEvent"
|
2010-09-13 22:07:22 +02:00
|
|
|
:"=A"(evh.raw)
|
|
|
|
:"S" (ev), "c"(flags)
|
|
|
|
:"memory");
|
2011-07-17 18:57:53 +02:00
|
|
|
__asm__ __volatile__ ("":::"ebx","ecx","edx","esi", "edi");
|
2010-09-13 22:07:22 +02:00
|
|
|
|
|
|
|
return evh;
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void RaiseEvent(evhandle_t evh, u32 flags, kevent_t *ev)
|
2010-09-13 22:07:22 +02:00
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__RaiseEvent"
|
|
|
|
::"a"(evh.handle),"b"(evh.euid),"d"(flags),"S" (ev)
|
|
|
|
:"memory");
|
2011-07-17 18:57:53 +02:00
|
|
|
__asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
|
2010-09-12 00:23:28 +02:00
|
|
|
|
2010-09-13 22:07:22 +02:00
|
|
|
};
|
|
|
|
|
2011-07-17 18:57:53 +02:00
|
|
|
static inline void WaitEvent(evhandle_t evh)
|
2010-09-13 22:07:22 +02:00
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__WaitEvent"
|
2011-07-17 18:57:53 +02:00
|
|
|
::"a"(evh.handle),"b"(evh.euid));
|
|
|
|
__asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
|
2010-09-13 22:07:22 +02:00
|
|
|
};
|
|
|
|
|
2013-03-19 07:14:59 +01:00
|
|
|
static inline int WaitEventTimeout(evhandle_t evh, int timeout)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__WaitEventTimeout"
|
|
|
|
:"=a"(retval)
|
|
|
|
:"a"(evh.handle),"b"(evh.euid), "c"(timeout));
|
|
|
|
__asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
|
|
|
|
return retval;
|
|
|
|
};
|
|
|
|
|
2012-09-04 23:42:08 +02:00
|
|
|
static inline void DestroyEvent(evhandle_t evh)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__DestroyEvent"
|
|
|
|
::"a"(evh.handle),"b"(evh.euid));
|
|
|
|
__asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u32 GetEvent(kevent_t *ev)
|
2010-09-13 22:07:22 +02:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 handle;
|
2010-09-12 00:23:28 +02:00
|
|
|
|
2010-09-13 22:07:22 +02:00
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__GetEvent"
|
|
|
|
:"=a"(handle)
|
|
|
|
:"D"(ev)
|
|
|
|
:"memory");
|
|
|
|
__asm__ __volatile__ ("":::"ebx","ecx","edx", "esi","edi");
|
2010-09-12 00:23:28 +02:00
|
|
|
return handle;
|
|
|
|
};
|
|
|
|
|
2010-09-13 22:07:22 +02:00
|
|
|
|
2010-09-12 00:23:28 +02:00
|
|
|
static inline int GetScreenSize(void)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
asm("int $0x40"
|
|
|
|
:"=a"(retval)
|
|
|
|
:"a"(61), "b"(1));
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-09-12 00:23:28 +02:00
|
|
|
static inline int GetScreenBpp(void)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
asm("int $0x40"
|
|
|
|
:"=a"(retval)
|
|
|
|
:"a"(61), "b"(2));
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-09-12 00:23:28 +02:00
|
|
|
static inline int GetScreenPitch(void)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
asm("int $0x40"
|
|
|
|
:"=a"(retval)
|
|
|
|
:"a"(61), "b"(3));
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u32 GetPgAddr(void *mem)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 retval;
|
2008-12-13 04:32:16 +01:00
|
|
|
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__GetPgAddr \n\t"
|
2012-09-04 23:42:08 +02:00
|
|
|
:"=a" (retval)
|
2008-12-13 04:32:16 +01:00
|
|
|
:"a" (mem) );
|
|
|
|
return retval;
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void CommitPages(void *mem, u32 page, u32 size)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
size = (size+4095) & ~4095;
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__CommitPages"
|
|
|
|
::"a" (page), "b"(mem),"c"(size>>12)
|
|
|
|
:"edx" );
|
|
|
|
__asm__ __volatile__ ("":::"eax","ebx","ecx");
|
|
|
|
};
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
static inline void UnmapPages(void *mem, size_t size)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
size = (size+4095) & ~4095;
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__UnmapPages"
|
|
|
|
::"a" (mem), "c"(size>>12)
|
|
|
|
:"edx");
|
|
|
|
__asm__ __volatile__ ("":::"eax","ecx");
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void usleep(u32 delay)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
if( !delay )
|
|
|
|
delay++;
|
2010-02-12 21:11:35 +01:00
|
|
|
delay*= 500;
|
2008-12-13 04:32:16 +01:00
|
|
|
|
|
|
|
while(delay--)
|
2010-02-12 21:11:35 +01:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"xorl %%eax, %%eax \n\t"
|
|
|
|
"cpuid \n\t"
|
2008-12-13 04:32:16 +01:00
|
|
|
:::"eax","ebx","ecx","edx");
|
2010-02-12 21:11:35 +01:00
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void udelay1(u32 delay)
|
2010-02-12 21:11:35 +01:00
|
|
|
{
|
|
|
|
if(!delay) delay++;
|
2012-09-04 23:42:08 +02:00
|
|
|
delay*= 100;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
while(delay--)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"xorl %%eax, %%eax \n\t"
|
|
|
|
"cpuid"
|
|
|
|
:::"eax","ebx","ecx","edx" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void msleep1(unsigned int msecs)
|
2011-06-24 12:45:58 +02:00
|
|
|
{
|
|
|
|
msecs /= 10;
|
|
|
|
if(!msecs) msecs = 1;
|
|
|
|
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__Delay"
|
|
|
|
::"b" (msecs));
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"":::"ebx");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void mdelay1(u32 time)
|
2010-02-12 21:11:35 +01:00
|
|
|
{
|
|
|
|
time /= 10;
|
|
|
|
if(!time) time = 1;
|
|
|
|
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__Delay"
|
|
|
|
::"b" (time));
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"":::"ebx");
|
|
|
|
|
2008-12-13 04:32:16 +01:00
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u32 __PciApi(int cmd)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 retval;
|
2008-12-13 04:32:16 +01:00
|
|
|
|
|
|
|
__asm__ __volatile__ (
|
2010-09-13 22:07:22 +02:00
|
|
|
"call *__imp__PciApi \n\t"
|
|
|
|
"movzxb %%al, %%eax"
|
2008-12-13 04:32:16 +01:00
|
|
|
:"=a" (retval)
|
|
|
|
:"a" (cmd)
|
2010-09-28 00:55:59 +02:00
|
|
|
:"cc");
|
|
|
|
|
2008-12-13 04:32:16 +01:00
|
|
|
return retval;
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void* __CreateObject(u32 pid, size_t size)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
void *retval;
|
|
|
|
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__CreateObject \n\t"
|
|
|
|
:"=a" (retval)
|
|
|
|
:"a" (size),"b"(pid)
|
|
|
|
:"esi","edi", "memory");
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
static inline void __DestroyObject(void *obj)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
2010-02-12 21:11:35 +01:00
|
|
|
"call *__imp__DestroyObject \n\t"
|
2008-12-13 04:32:16 +01:00
|
|
|
:
|
2010-02-12 21:11:35 +01:00
|
|
|
:"a" (obj));
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
""
|
|
|
|
:::"eax","ebx","ecx","edx","esi","edi","cc","memory");
|
2008-12-13 04:32:16 +01:00
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u32 GetService(const char *name)
|
2010-02-12 21:11:35 +01:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 handle;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
__asm__ __volatile__
|
|
|
|
(
|
|
|
|
"pushl %%eax \n\t"
|
|
|
|
"call *__imp__GetService"
|
2012-09-04 23:42:08 +02:00
|
|
|
:"=a" (handle)
|
2010-02-12 21:11:35 +01:00
|
|
|
:"a" (name)
|
|
|
|
:"ebx","ecx","edx","esi", "edi"
|
|
|
|
);
|
|
|
|
return handle;
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u32 safe_cli(void)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 ifl;
|
2008-12-13 04:32:16 +01:00
|
|
|
__asm__ __volatile__ (
|
|
|
|
"pushf\n\t"
|
|
|
|
"popl %0\n\t"
|
|
|
|
"cli\n"
|
|
|
|
: "=r" (ifl));
|
|
|
|
return ifl;
|
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void safe_sti(u32 efl)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
2010-09-13 22:07:22 +02:00
|
|
|
if (efl & (1<<9))
|
|
|
|
__asm__ __volatile__ ("sti");
|
2008-12-13 04:32:16 +01:00
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u32 get_eflags(void)
|
2010-09-12 00:23:28 +02:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 val;
|
2010-09-12 00:23:28 +02:00
|
|
|
asm volatile (
|
|
|
|
"pushfl\n\t"
|
|
|
|
"popl %0\n"
|
|
|
|
: "=r" (val));
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
static inline void __clear (void * dst, unsigned len)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 tmp;
|
2008-12-13 04:32:16 +01:00
|
|
|
__asm__ __volatile__ (
|
|
|
|
"cld \n\t"
|
|
|
|
"rep stosb \n"
|
|
|
|
:"=c"(tmp),"=D"(tmp)
|
|
|
|
:"a"(0),"c"(len),"D"(dst));
|
|
|
|
__asm__ __volatile__ ("":::"ecx","edi");
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void out8(const u16 port, const u8 val)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__
|
|
|
|
("outb %1, %0\n" : : "dN"(port), "a"(val));
|
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void out16(const u16 port, const u16 val)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__
|
|
|
|
("outw %1, %0\n" : : "dN"(port), "a"(val));
|
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void out32(const u16 port, const u32 val)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__
|
|
|
|
("outl %1, %0\n" : : "dN"(port), "a"(val));
|
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u8 in8(const u16 port)
|
2009-02-08 19:41:45 +01:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u8 tmp;
|
2009-02-08 19:41:45 +01:00
|
|
|
__asm__ __volatile__
|
|
|
|
("inb %1, %0\n" : "=a"(tmp) : "dN"(port));
|
|
|
|
return tmp;
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u16 in16(const u16 port)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u16 tmp;
|
2008-12-13 04:32:16 +01:00
|
|
|
__asm__ __volatile__
|
|
|
|
("inw %1, %0\n" : "=a"(tmp) : "dN"(port));
|
|
|
|
return tmp;
|
|
|
|
};
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline u32 in32(const u16 port)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
2014-12-27 16:42:08 +01:00
|
|
|
u32 tmp;
|
2008-12-13 04:32:16 +01:00
|
|
|
__asm__ __volatile__
|
|
|
|
("inl %1, %0\n" : "=a"(tmp) : "dN"(port));
|
|
|
|
return tmp;
|
|
|
|
};
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
static inline void delay(int time)
|
2008-12-13 04:32:16 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__Delay"
|
|
|
|
::"b" (time));
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"":::"ebx");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-12 00:23:28 +02:00
|
|
|
static inline void change_task(void)
|
2009-02-11 07:52:01 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"call *__imp__ChangeTask");
|
|
|
|
}
|
|
|
|
|
2010-09-12 00:23:28 +02:00
|
|
|
static inline void sysSetScreen(int width, int height, int pitch)
|
2010-02-12 21:11:35 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__
|
|
|
|
(
|
|
|
|
"call *__imp__SetScreen"
|
|
|
|
:
|
|
|
|
:"a" (width-1),"d"(height-1), "c"(pitch)
|
|
|
|
);
|
|
|
|
__asm__ __volatile__
|
|
|
|
("" :::"eax","ecx","edx");
|
|
|
|
}
|
|
|
|
|
2016-03-13 07:45:57 +01:00
|
|
|
void FASTCALL sysSetFramebuffer(void *fb)__asm__("SetFramebuffer");
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void __iomem *ioremap(u32 offset, size_t size)
|
2010-02-12 21:11:35 +01:00
|
|
|
{
|
2014-01-27 21:08:29 +01:00
|
|
|
return (void __iomem*) MapIoMem(offset, size, PG_SW|PG_NOCACHE|0x100);
|
2010-02-12 21:11:35 +01:00
|
|
|
}
|
|
|
|
|
2016-01-20 05:19:53 +01:00
|
|
|
static inline void __iomem *ioremap_nocache(u32 offset, size_t size)
|
|
|
|
{
|
|
|
|
return (void __iomem*) MapIoMem(offset, size, PG_SW|PG_NOCACHE|0x100);
|
|
|
|
}
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
static inline void __iomem *ioremap_wc(u32 offset, size_t size)
|
2013-03-19 07:14:59 +01:00
|
|
|
{
|
2016-01-20 05:19:53 +01:00
|
|
|
return (void __iomem*) MapIoMem(offset, size, PG_SW|PG_WRITEC|0x100);
|
2013-03-19 07:14:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
static inline void iounmap(void *addr)
|
|
|
|
{
|
|
|
|
FreeKernelSpace(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __SysMsgBoardStr(char *text)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"call *__imp__SysMsgBoardStr"
|
|
|
|
::"S" (text));
|
|
|
|
};
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
static inline void *vzalloc(unsigned long size)
|
|
|
|
{
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
mem = KernelAlloc(size);
|
|
|
|
if(mem)
|
|
|
|
memset(mem, 0, size);
|
|
|
|
|
|
|
|
return mem;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-01-20 05:19:53 +01:00
|
|
|
static inline int power_supply_is_system_supplied(void) { return -1; };
|
2012-11-12 22:22:52 +01:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
#endif
|