x86_64 support, requiring a slight refactor to the build system.
[tpg/acess2.git] / Kernel / arch / x86_64 / include / arch.h
1 /*
2  * Acess2 x86-64 Architecure Module
3  * - By John Hodge (thePowersGang)
4  */
5 #ifndef _ARCH_H_
6 #define _ARCH_H_
7
8 #include <stdint.h>
9 #define KERNEL_BASE     0xFFFF8000##00000000
10 #define BITS    64
11
12 // === Core Types ===
13 typedef signed char     Sint8;
14 typedef unsigned char   Uint8;
15 typedef signed short    Sint16;
16 typedef unsigned short  Uint16;
17 typedef signed int      Sint32;
18 typedef unsigned int    Uint32;
19 #if __WORDSIZE == 64
20 typedef signed long int Sint64;
21 typedef unsigned long int       Uint64;
22 #else
23 typedef signed long long int    Sint64;
24 typedef unsigned long long int  Uint64;
25 #endif
26
27 typedef Uint64  Uint;
28 typedef Uint64  tPAddr;
29 typedef Uint64  tVAddr;
30
31 //typedef unsigned int  size_t;
32 typedef Uint64  size_t;
33
34 typedef volatile int    tSpinlock;
35 #define IS_LOCKED(lockptr)      (!!(*(tSpinlock*)lockptr))
36 #define LOCK(lockptr)   do {int v=1;\
37         while(v)\
38         __asm__ __volatile__("lock xchgl %%eax, (%%edi)":"=a"(v):"a"(1),"D"(lockptr));\
39         }while(0)
40 #define RELEASE(lockptr)        __asm__ __volatile__("lock andl $0, (%%edi)"::"D"(lockptr));
41 #define HALT()  __asm__ __volatile__ ("hlt")
42
43 // Systemcall Registers
44 typedef struct sSyscallRegs
45 {
46         Uint    Arg4, Arg5;     // RDI, RSI
47         Uint    Arg6;   // RBP
48         Uint    Resvd2[1];      // Kernel RSP
49         union {
50                 Uint    Arg1;
51                 Uint    Error;
52         };      // RBX
53         union {
54                 Uint    Arg3;
55                 Uint    RetHi;  // High 64 bits of ret
56         };      // RDX
57         Uint    Arg2;   // RCX
58         union {
59                 Uint    Num;
60                 Uint    Return;
61         };      // RAX
62         Uint    Resvd3[5];      // Int, Err, rip, CS, ...
63         Uint    StackPointer;   // RSP
64         Uint    Resvd4[1];      // SS   
65 }       tSyscallRegs;
66
67 #endif
68

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