More work on x86_64 port, near compiling now
[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, (%%rdi)":"=a"(v):"a"(1),"D"(lockptr));\
39         }while(0)
40 #define RELEASE(lockptr)        __asm__ __volatile__("lock andl $0, (%%rdi)"::"D"(lockptr));
41 #define HALT()  __asm__ __volatile__ ("hlt")
42
43 // Systemcall Registers
44 // TODO: Fix this structure
45 typedef struct sSyscallRegs
46 {
47         union {
48                 Uint    Num;
49                 Uint    Return;
50         };      // RAX
51         Uint    Arg4;   // RCX
52         Uint    Arg3;   // RDX
53         Uint    Error;  // RBX
54         Uint    Resvd1[2];      // Kernel RSP, RBP
55         Uint    Arg2;   // RSI
56         Uint    Arg1;   // RDI
57         Uint    Arg5;   // R8
58         Uint    Arg6;   // R9
59         Uint    Resvd2[6];      // R10 - R15
60         Uint    Resvd3[5];      // IntNum, ErrCode, RIP, CS, RFLAGS
61         
62         Uint    Resvd4[5];      // Int, Err, rip, CS, ...
63         Uint    StackPointer;   // RSP
64         Uint    Resvd5[1];      // SS   
65 }       tSyscallRegs;
66
67 #endif
68

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