4 * arch/i386/include/arch.h
10 #define KERNEL_BASE 0xC0000000
12 #define PAGE_SIZE 0x1000
14 #define INVLPTR ((void*)-1)
16 // Allow nested spinlocks?
17 #define STACKED_LOCKS 2 // 0: No, 1: Per-CPU, 2: Per-Thread
18 #define LOCK_DISABLE_INTS 1
20 // - Processor/Machine Specific Features
21 #if ARCH != x86 && ARCH != x86_smp
22 # error "Unknown architecture '" #ARCH "'"
37 #define __ASM__ __asm__ __volatile__
41 * \brief Short Spinlock structure
43 struct sShortSpinlock {
44 #if STACKED_LOCKS == 2
45 volatile void *Lock; //!< Lock value
47 volatile int Lock; //!< Lock value
51 int IF; //!< Interrupt state on call to SHORTLOCK
60 * \brief Halt the CPU (shorter version of yield)
65 __asm__ __volatile__ ("pushf;pop %0" : "=a"(flags)); \
66 if( !(flags & 0x200) ) Panic("HALT called with interrupts disabled"); \
67 __asm__ __volatile__ ("hlt"); \
70 #define HALT() __asm__ __volatile__ ("hlt")
73 * \brief Fire a magic breakpoint (bochs)
75 #define MAGIC_BREAK() __asm__ __volatile__ ("xchg %bx, %bx")
78 typedef unsigned int Uint; // Unsigned machine native integer
79 typedef unsigned char Uint8;
80 typedef unsigned short Uint16;
81 typedef unsigned long Uint32;
82 typedef unsigned long long Uint64;
83 typedef signed int Sint; // Signed Machine Native integer
84 typedef signed char Sint8;
85 typedef signed short Sint16;
86 typedef signed long Sint32;
87 typedef signed long long Sint64;
91 typedef Uint32 tPAddr;
92 typedef Uint32 tVAddr;
95 Uint32 gs, fs, es, ds;
96 Uint32 edi, esi, ebp, kesp;
97 Uint32 ebx, edx, ecx, eax;
98 Uint32 int_num, err_code;
100 Uint32 eflags, esp, ss;
104 Uint Resvd1[4]; // GS, FS, ES, DS
105 Uint Arg4, Arg5; // EDI, ESI
107 Uint Resvd2[1]; // Kernel ESP
114 Uint RetHi; // High 32 bits of ret
121 Uint Resvd3[5]; // Int, Err, Eip, CS, ...
122 Uint StackPointer; // ESP
123 Uint Resvd4[1]; // SS
136 Uint32 UserCS, UserEIP;
140 extern void Debug_PutCharDebug(char ch);
141 extern void Debug_PutStringDebug(const char *String);
143 extern int IS_LOCKED(struct sShortSpinlock *Lock);
144 extern int CPU_HAS_LOCK(struct sShortSpinlock *Lock);
145 extern void SHORTLOCK(struct sShortSpinlock *Lock);
146 extern void SHORTREL(struct sShortSpinlock *Lock);
148 #endif // !defined(_ARCH_H_)