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)
61 #define HALT() __asm__ __volatile__ ("hlt")
63 * \brief Fire a magic breakpoint (bochs)
65 #define MAGIC_BREAK() __asm__ __volatile__ ("xchg %bx, %bx")
68 typedef unsigned int Uint; // Unsigned machine native integer
69 typedef unsigned char Uint8;
70 typedef unsigned short Uint16;
71 typedef unsigned long Uint32;
72 typedef unsigned long long Uint64;
73 typedef signed int Sint; // Signed Machine Native integer
74 typedef signed char Sint8;
75 typedef signed short Sint16;
76 typedef signed long Sint32;
77 typedef signed long long Sint64;
81 typedef Uint64 tPAddr;
82 typedef Uint32 tVAddr;
85 Uint32 gs, fs, es, ds;
86 Uint32 edi, esi, ebp, kesp;
87 Uint32 ebx, edx, ecx, eax;
88 Uint32 int_num, err_code;
90 Uint32 eflags, esp, ss;
94 Uint Resvd1[4]; // GS, FS, ES, DS
95 Uint Arg4, Arg5; // EDI, ESI
97 Uint Resvd2[1]; // Kernel ESP
104 Uint RetHi; // High 32 bits of ret
111 Uint Resvd3[5]; // Int, Err, Eip, CS, ...
112 Uint StackPointer; // ESP
113 Uint Resvd4[1]; // SS
126 Uint32 UserCS, UserEIP;
130 extern void Debug_PutCharDebug(char ch);
131 extern void Debug_PutStringDebug(const char *String);
133 extern int IS_LOCKED(struct sShortSpinlock *Lock);
134 extern int CPU_HAS_LOCK(struct sShortSpinlock *Lock);
135 extern void SHORTLOCK(struct sShortSpinlock *Lock);
136 extern void SHORTREL(struct sShortSpinlock *Lock);
138 #endif // !defined(_ARCH_H_)