4 * arch/x86/include/arch.h
10 #define KERNEL_BASE 0xC0000000
12 #define PAGE_SIZE 0x1000
14 #define INVLPTR ((void*)-1)
16 // Allow nested spinlocks?
17 #define LOCK_DISABLE_INTS 1
19 // - Processor/Machine Specific Features
20 #if ARCH != x86 && ARCH != x86_smp
21 # error "Unknown architecture '" #ARCH "'"
36 #define __ASM__ __asm__ __volatile__
40 * \brief Short Spinlock structure
42 struct sShortSpinlock {
43 volatile int Lock; //!< Lock value
46 int IF; //!< Interrupt state on call to SHORTLOCK
53 * \brief Halt the CPU (shorter version of yield)
58 __asm__ __volatile__ ("pushf;pop %0" : "=a"(flags)); \
59 if( !(flags & 0x200) ) Panic("HALT called with interrupts disabled"); \
60 __asm__ __volatile__ ("hlt"); \
63 #define HALT() __asm__ __volatile__ ("hlt")
66 * \brief Fire a magic breakpoint (bochs)
68 #define MAGIC_BREAK() __asm__ __volatile__ ("xchg %bx, %bx")
69 // TODO: SMP halt request too
70 #define HALT_CPU() for(;;) { __asm__ __volatile__ ("cli; hlt"); }
73 typedef unsigned int Uint; // Unsigned machine native integer
74 typedef unsigned char Uint8;
75 typedef unsigned short Uint16;
76 typedef unsigned long Uint32;
77 typedef unsigned long long Uint64;
78 typedef signed int Sint; // Signed Machine Native integer
79 typedef signed char Sint8;
80 typedef signed short Sint16;
81 typedef signed long Sint32;
82 typedef signed long long Sint64;
85 typedef Uint32 tPAddr;
86 typedef Uint32 tVAddr;
89 Uint32 gs, fs, es, ds;
90 Uint32 edi, esi, ebp, kesp;
91 Uint32 ebx, edx, ecx, eax;
92 Uint32 int_num, err_code;
94 Uint32 eflags, esp, ss;
98 Uint Resvd1[4]; // GS, FS, ES, DS
99 Uint Arg4, Arg5; // EDI, ESI
101 Uint Resvd2[1]; // Kernel ESP
108 Uint RetHi; // High 32 bits of ret
115 Uint Resvd3[5]; // Int, Err, Eip, CS, ...
116 Uint StackPointer; // ESP
117 Uint Resvd4[1]; // SS
121 extern void Debug_PutCharDebug(char ch);
122 extern void Debug_PutStringDebug(const char *String);
124 extern int IS_LOCKED(struct sShortSpinlock *Lock);
125 extern int CPU_HAS_LOCK(struct sShortSpinlock *Lock);
126 extern void SHORTLOCK(struct sShortSpinlock *Lock);
127 extern void SHORTREL(struct sShortSpinlock *Lock);
129 #endif // !defined(_ARCH_H_)