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__
32 #define LONGLOCK_NUM_THREADS 8
35 struct sShortSpinlock {
40 * \brief Determine if a short spinlock is locked
42 static inline int IS_LOCKED(struct sShortSpinlock *Lock) {
46 * \brief Acquire a Short Spinlock
47 * \note Stops interrupts, so be careful
49 static inline void SHORTLOCK(struct sShortSpinlock *Lock) {
51 __ASM__ ("pushf;\n\tpop %%eax" : "=a"(Lock->IF));
53 __ASM__ ("cli"); // Stop task switches
54 // Wait for another CPU to release
56 __ASM__("xchgl %%eax, (%%edi)":"=a"(v):"a"(1),"D"(&Lock->Lock));
59 * \brief Release a short lock
61 static inline void SHORTREL(struct sShortSpinlock *Lock) {
64 __ASM__ ("pushf;\n\tor %0, (%%esp);\n\tpopf" : : "a"(Lock->IF));
66 if(Lock->IF) __ASM__ ("sti");
72 #define HALT() __asm__ __volatile__ ("hlt")
73 #define MAGIC_BREAK() __asm__ __volatile__ ("xchg %bx, %bx")
76 typedef unsigned int Uint; // Unsigned machine native integer
77 typedef unsigned char Uint8;
78 typedef unsigned short Uint16;
79 typedef unsigned long Uint32;
80 typedef unsigned long long Uint64;
81 typedef signed int Sint; // Signed Machine Native integer
82 typedef signed char Sint8;
83 typedef signed short Sint16;
84 typedef signed long Sint32;
85 typedef signed long long Sint64;
88 typedef Uint64 tPAddr;
89 typedef Uint32 tVAddr;
93 Uint edi, esi, ebp, kesp;
94 Uint ebx, edx, ecx, eax;
95 Uint int_num, err_code;
101 Uint Resvd1[4]; // GS, FS, ES, DS
102 Uint Arg4, Arg5; // EDI, ESI
104 Uint Resvd2[1]; // Kernel ESP
111 Uint RetHi; // High 32 bits of ret
118 Uint Resvd3[5]; // Int, Err, Eip, CS, ...
119 Uint StackPointer; // ESP
120 Uint Resvd4[1]; // SS
135 #endif // !defined(_ARCH_H_)