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"); }
72 #define ASM(v...) __asm__ __volatile__ (v)
75 typedef unsigned int Uint; // Unsigned machine native integer
76 typedef unsigned char Uint8;
77 typedef unsigned short Uint16;
78 typedef unsigned long Uint32;
79 typedef unsigned long long Uint64;
80 typedef signed int Sint; // Signed Machine Native integer
81 typedef signed char Sint8;
82 typedef signed short Sint16;
83 typedef signed long Sint32;
84 typedef signed long long Sint64;
87 typedef Uint32 tPAddr;
88 typedef Uint32 tVAddr;
91 Uint32 gs, fs, es, ds;
92 Uint32 edi, esi, ebp, kesp;
93 Uint32 ebx, edx, ecx, eax;
94 Uint32 int_num, err_code;
96 Uint32 eflags, esp, ss;
100 Uint Resvd1[4]; // GS, FS, ES, DS
101 Uint Arg4, Arg5; // EDI, ESI
103 Uint Resvd2[1]; // Kernel ESP
110 Uint RetHi; // High 32 bits of ret
117 Uint Resvd3[5]; // Int, Err, Eip, CS, ...
118 Uint StackPointer; // ESP
119 Uint Resvd4[1]; // SS
123 extern void Debug_PutCharDebug(char ch);
124 extern void Debug_PutStringDebug(const char *String);
126 extern int IS_LOCKED(struct sShortSpinlock *Lock);
127 extern int CPU_HAS_LOCK(struct sShortSpinlock *Lock);
128 extern void SHORTLOCK(struct sShortSpinlock *Lock);
129 extern void SHORTREL(struct sShortSpinlock *Lock);
131 #endif // !defined(_ARCH_H_)