4 * arch/i386/include/arch.h
10 #define KERNEL_BASE 0xC0000000
13 #define INVLPTR ((void*)-1)
15 // Allow nested spinlocks?
16 #define STACKED_LOCKS 2 // 0: No, 1: Per-CPU, 2: Per-Thread
17 #define LOCK_DISABLE_INTS 1
19 // - Processor/Machine Specific Features
20 #if ARCH != i386 && ARCH != i486 && ARCH != i586
21 # error "Unknown architecture '" #ARCH "'"
36 #define __ASM__ __asm__ __volatile__
40 * \brief Short Spinlock structure
42 struct sShortSpinlock {
43 #if STACKED_LOCKS == 2
44 volatile void *Lock; //!< Lock value
46 volatile int Lock; //!< Lock value
50 int IF; //!< Interrupt state on call to SHORTLOCK
59 * \brief Halt the CPU (shorter version of yield)
64 __asm__ __volatile__ ("pushf;pop %0" : "=a"(flags)); \
65 if( !(flags & 0x200) ) Panic("HALT called with interrupts disabled"); \
66 __asm__ __volatile__ ("hlt"); \
69 #define HALT() __asm__ __volatile__ ("hlt")
72 * \brief Fire a magic breakpoint (bochs)
74 #define MAGIC_BREAK() __asm__ __volatile__ ("xchg %bx, %bx")
77 typedef unsigned int Uint; // Unsigned machine native integer
78 typedef unsigned char Uint8;
79 typedef unsigned short Uint16;
80 typedef unsigned long Uint32;
81 typedef unsigned long long Uint64;
82 typedef signed int Sint; // Signed Machine Native integer
83 typedef signed char Sint8;
84 typedef signed short Sint16;
85 typedef signed long Sint32;
86 typedef signed long long Sint64;
90 typedef Uint32 tPAddr;
91 typedef Uint32 tVAddr;
94 Uint32 gs, fs, es, ds;
95 Uint32 edi, esi, ebp, kesp;
96 Uint32 ebx, edx, ecx, eax;
97 Uint32 int_num, err_code;
99 Uint32 eflags, esp, ss;
103 Uint Resvd1[4]; // GS, FS, ES, DS
104 Uint Arg4, Arg5; // EDI, ESI
106 Uint Resvd2[1]; // Kernel ESP
113 Uint RetHi; // High 32 bits of ret
120 Uint Resvd3[5]; // Int, Err, Eip, CS, ...
121 Uint StackPointer; // ESP
122 Uint Resvd4[1]; // SS
135 Uint32 UserCS, UserEIP;
139 extern void Debug_PutCharDebug(char ch);
140 extern void Debug_PutStringDebug(const char *String);
142 extern int IS_LOCKED(struct sShortSpinlock *Lock);
143 extern int CPU_HAS_LOCK(struct sShortSpinlock *Lock);
144 extern void SHORTLOCK(struct sShortSpinlock *Lock);
145 extern void SHORTREL(struct sShortSpinlock *Lock);
147 #endif // !defined(_ARCH_H_)