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

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