Untested work on physical mm setup
[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 Uint64  size_t;
32
33 typedef volatile int    tSpinlock;
34 #define IS_LOCKED(lockptr)      (!!(*(tSpinlock*)lockptr))
35 #define LOCK(lockptr)   do {int v=1;\
36         while(v)\
37         __asm__ __volatile__("lock xchgl %0, (%2)":"=r"(v):"r"(1),"r"(lockptr));\
38         }while(0)
39 #define RELEASE(lockptr)        __asm__ __volatile__("lock andl $0, (%0)"::"r"(lockptr));
40 #define HALT()  __asm__ __volatile__ ("hlt")
41
42 // Systemcall Registers
43 // TODO: Fix this structure
44 typedef struct sSyscallRegs
45 {
46         union {
47                 Uint    Num;
48                 Uint    Return;
49         };      // RAX
50         Uint    Arg4;   // RCX
51         Uint    Arg3;   // RDX
52         Uint    Error;  // RBX
53         Uint    Resvd1[2];      // Kernel RSP, RBP
54         Uint    Arg2;   // RSI
55         Uint    Arg1;   // RDI
56         Uint    Arg5;   // R8
57         Uint    Arg6;   // R9
58         Uint    Resvd2[6];      // R10 - R15
59         Uint    Resvd3[5];      // IntNum, ErrCode, RIP, CS, RFLAGS
60         
61         Uint    Resvd4[5];      // Int, Err, rip, CS, ...
62         Uint    StackPointer;   // RSP
63         Uint    Resvd5[1];      // SS   
64 }       tSyscallRegs;
65
66 #endif
67

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