Working on the x86 bit port (caused some changes to try and get it
[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 KERNEL_BASE     0xFFFFFFFF##80000000
11 #define BITS    64
12
13 //#define INT_MAX       0x7FFFFFFF
14 //#define UINT_MAX      0xFFFFFFFF
15
16 // === Core Types ===
17 typedef signed char     Sint8;
18 typedef unsigned char   Uint8;
19 typedef signed short    Sint16;
20 typedef unsigned short  Uint16;
21 typedef signed int      Sint32;
22 typedef unsigned int    Uint32;
23 #if __WORDSIZE == 64
24 typedef signed long int Sint64;
25 typedef unsigned long int       Uint64;
26 #else
27 typedef signed long long int    Sint64;
28 typedef unsigned long long int  Uint64;
29 #endif
30
31 typedef Sint64  Sint;
32 typedef Uint64  Uint;
33 typedef Uint64  tPAddr;
34 typedef Uint64  tVAddr;
35
36 typedef Uint64  size_t;
37
38 typedef volatile int    tSpinlock;
39 #define IS_LOCKED(lockptr)      (!!(*(tSpinlock*)lockptr))
40 #define LOCK(lockptr)   do {int v=1;\
41         while(v)\
42         __asm__ __volatile__("lock xchgl %0, (%2)":"=r"(v):"r"(1),"r"(lockptr));\
43         }while(0)
44 #define RELEASE(lockptr)        __asm__ __volatile__("lock andl $0, (%0)"::"r"(lockptr));
45 #define HALT()  __asm__ __volatile__ ("hlt")
46
47 // Systemcall Registers
48 // TODO: Fix this structure
49 typedef struct sSyscallRegs
50 {
51         union {
52                 Uint    Num;
53                 Uint    Return;
54         };      // RAX
55         Uint    Arg4;   // RCX
56         Uint    Arg3;   // RDX
57         Uint    Error;  // RBX
58         Uint    Resvd1[2];      // Kernel RSP, RBP
59         Uint    Arg2;   // RSI
60         Uint    Arg1;   // RDI
61         Uint    Arg5;   // R8
62         Uint    Arg6;   // R9
63         Uint    Resvd2[6];      // R10 - R15
64         Uint    Resvd3[5];      // IntNum, ErrCode, RIP, CS, RFLAGS
65         
66         Uint    Resvd4[5];      // Int, Err, rip, CS, ...
67         Uint    StackPointer;   // RSP
68         Uint    Resvd5[1];      // SS   
69 }       tSyscallRegs;
70
71 #endif
72

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