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 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
52 * \brief Halt the CPU (shorter version of yield)
57 __asm__ __volatile__ ("pushf;pop %0" : "=a"(flags)); \
58 if( !(flags & 0x200) ) Panic("HALT called with interrupts disabled"); \
59 __asm__ __volatile__ ("hlt"); \
62 #define HALT() __asm__ __volatile__ ("hlt")
65 * \brief Fire a magic breakpoint (bochs)
67 #define MAGIC_BREAK() __asm__ __volatile__ ("xchg %bx, %bx")
70 typedef unsigned int Uint; // Unsigned machine native integer
71 typedef unsigned char Uint8;
72 typedef unsigned short Uint16;
73 typedef unsigned long Uint32;
74 typedef unsigned long long Uint64;
75 typedef signed int Sint; // Signed Machine Native integer
76 typedef signed char Sint8;
77 typedef signed short Sint16;
78 typedef signed long Sint32;
79 typedef signed long long Sint64;
83 typedef Uint32 tPAddr;
84 typedef Uint32 tVAddr;
87 Uint32 gs, fs, es, ds;
88 Uint32 edi, esi, ebp, kesp;
89 Uint32 ebx, edx, ecx, eax;
90 Uint32 int_num, err_code;
92 Uint32 eflags, esp, ss;
96 Uint Resvd1[4]; // GS, FS, ES, DS
97 Uint Arg4, Arg5; // EDI, ESI
99 Uint Resvd2[1]; // Kernel ESP
106 Uint RetHi; // High 32 bits of ret
113 Uint Resvd3[5]; // Int, Err, Eip, CS, ...
114 Uint StackPointer; // ESP
115 Uint Resvd4[1]; // SS
119 extern void Debug_PutCharDebug(char ch);
120 extern void Debug_PutStringDebug(const char *String);
122 extern int IS_LOCKED(struct sShortSpinlock *Lock);
123 extern int CPU_HAS_LOCK(struct sShortSpinlock *Lock);
124 extern void SHORTLOCK(struct sShortSpinlock *Lock);
125 extern void SHORTREL(struct sShortSpinlock *Lock);
127 #endif // !defined(_ARCH_H_)