Working on separating architecture dependent and independent stuff,
[tpg/acess2.git] / Kernel / arch / x86 / include / arch.h
1 /*
2  * Acess2
3  * - x86 Architecture
4  * arch/i386/include/arch.h
5  */
6 #ifndef _ARCH_H_
7 #define _ARCH_H_
8
9 // - Base Defintions
10 #define KERNEL_BASE     0xC0000000
11 #define BITS    32
12
13 // - Processor/Machine Specific Features
14 #if ARCH != i386 && ARCH != i486 && ARCH != i586
15 # error "Unknown architecture '" #ARCH "'"
16 #endif
17
18 #if USE_MP
19 # define        MAX_CPUS        8
20 #else
21 # define        MAX_CPUS        1
22 #endif
23
24 #if USE_PAE
25 # define        PHYS_BITS       48
26 #else
27 # define        PHYS_BITS       32
28 #endif
29
30 // === MACROS ===
31 typedef volatile int    tSpinlock;
32 #define IS_LOCKED(lockptr)      (!!(*(tSpinlock*)lockptr))
33 #define LOCK(lockptr)   do {int v=1;\
34         while(v)__asm__ __volatile__("lock xchgl %%eax, (%%edi)":"=a"(v):"a"(1),"D"(lockptr));}while(0)
35 #define RELEASE(lockptr)        __asm__ __volatile__("lock andl $0, (%%edi)"::"D"(lockptr));
36 #define HALT()  __asm__ __volatile__ ("hlt")
37
38 // === TYPES ===
39 typedef unsigned int    Uint;   // Unsigned machine native integer
40 typedef unsigned char   Uint8;
41 typedef unsigned short  Uint16;
42 typedef unsigned long   Uint32;
43 typedef unsigned long long      Uint64;
44 typedef signed int              Sint;   // Signed Machine Native integer
45 typedef signed char             Sint8;
46 typedef signed short    Sint16;
47 typedef signed long             Sint32;
48 typedef signed long long        Sint64;
49 typedef Uint    size_t;
50
51 typedef Uint64  tPAddr;
52 typedef Uint32  tVAddr;
53
54 typedef struct {
55     Uint        gs, fs, es, ds;
56     Uint        edi, esi, ebp, kesp;
57         Uint    ebx, edx, ecx, eax;
58     Uint        int_num, err_code;
59     Uint        eip, cs;
60         Uint    eflags, esp, ss;
61 } tRegs;
62
63 typedef struct {
64         Uint    Resvd1[4];      // GS, FS, ES, DS
65         Uint    Arg4, Arg5;     // EDI, ESI
66         Uint    Arg6;   // EBP
67         Uint    Resvd2[1];      // Kernel ESP
68         union {
69                 Uint    Arg1;
70                 Uint    Error;
71         };      // EBX
72         union {
73                 Uint    Arg3;
74                 Uint    RetHi;  // High 32 bits of ret
75         };      // EDX
76         Uint    Arg2;   // ECX
77         union {
78                 Uint    Num;
79                 Uint    Return;
80         };      // EAX
81         Uint    Resvd3[5];      // Int, Err, Eip, CS, ...
82         Uint    StackPointer;   // ESP
83         Uint    Resvd4[1];      // SS
84 } tSyscallRegs;
85
86 typedef struct {
87         #if USE_PAE
88         Uint    PDPT[4];
89         #else
90         Uint    CR3;
91         #endif
92 } tMemoryState;
93
94 typedef struct {
95         Uint    EIP, ESP, EBP;
96 } tTaskState;
97
98 #endif  // !defined(_ARCH_H_)

UCC git Repository :: git.ucc.asn.au