4 * arch/i386/include/arch.h
10 #define KERNEL_BASE 0xC0000000
13 // - Processor/Machine Specific Features
14 #if ARCH != i386 && ARCH != i486 && ARCH != i586
15 # error "Unknown architecture '" #ARCH "'"
30 #define __ASM__ __asm__ __volatile__
33 typedef volatile int tSpinlock;
34 #define IS_LOCKED(lockptr) (!!(*(tSpinlock*)lockptr))
36 * \brief Inter-Process interrupt (does a Yield)
38 #define LOCK(lockptr) do {\
41 __ASM__("xchgl %%eax, (%%edi)":"=a"(v):"a"(1),"D"(lockptr));\
42 if(v) Threads_Yield();\
46 * \brief Tight spinlock (does a HLT)
48 #define TIGHTLOCK(lockptr) do{\
51 __ASM__("xchgl %%eax,(%%edi)":"=a"(v):"a"(1),"D"(lockptr));\
52 if(v) __ASM__("hlt");\
56 * \brief Very Tight spinlock (short inter-cpu lock)
58 #define VTIGHTLOCK(lockptr) do{\
60 while(v)__ASM__("xchgl %%eax,(%%edi)":"=a"(v):"a"(1),"D"(lockptr));\
63 * \brief Release a held spinlock
65 #define RELEASE(lockptr) __ASM__("lock andl $0, (%%edi)"::"D"(lockptr));
69 #define HALT() __asm__ __volatile__ ("hlt")
72 typedef unsigned int Uint; // Unsigned machine native integer
73 typedef unsigned char Uint8;
74 typedef unsigned short Uint16;
75 typedef unsigned long Uint32;
76 typedef unsigned long long Uint64;
77 typedef signed int Sint; // Signed Machine Native integer
78 typedef signed char Sint8;
79 typedef signed short Sint16;
80 typedef signed long Sint32;
81 typedef signed long long Sint64;
84 typedef Uint64 tPAddr;
85 typedef Uint32 tVAddr;
89 Uint edi, esi, ebp, kesp;
90 Uint ebx, edx, ecx, eax;
91 Uint int_num, err_code;
97 Uint Resvd1[4]; // GS, FS, ES, DS
98 Uint Arg4, Arg5; // EDI, ESI
100 Uint Resvd2[1]; // Kernel ESP
107 Uint RetHi; // High 32 bits of ret
114 Uint Resvd3[5]; // Int, Err, Eip, CS, ...
115 Uint StackPointer; // ESP
116 Uint Resvd4[1]; // SS
131 #endif // !defined(_ARCH_H_)