Kernel - Added PMM stats method (stubbed) to x86_64 and template
[tpg/acess2.git] / KernelLand / 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 USER_MAX        0x00007FFF##FFFFF000
10 #define KERNEL_BASE     0xFFFFFFFF##80000000
11 #define BITS    64
12 #define PAGE_SIZE       0x1000
13
14 #ifndef MAX_CPUS
15 # define MAX_CPUS       8
16 #endif
17
18 #define STACKED_LOCKS   2       // 0: No, 1: Per-CPU, 2: Per-Thread
19 #define LOCK_DISABLE_INTS       0
20
21 #define INVLPTR ((void*)0x0FFFFFFFFFFFFFFFULL)
22
23 //#define INT_MAX       0x7FFFFFFF
24 //#define UINT_MAX      0xFFFFFFFF
25
26 // === Core Types ===
27 typedef signed char     Sint8;
28 typedef unsigned char   Uint8;
29 typedef signed short    Sint16;
30 typedef unsigned short  Uint16;
31 typedef signed int      Sint32;
32 typedef unsigned int    Uint32;
33 #if __WORDSIZE == 64
34 typedef signed long int Sint64;
35 typedef unsigned long int       Uint64;
36 #else
37 typedef signed long long int    Sint64;
38 typedef unsigned long long int  Uint64;
39 #endif
40
41 typedef Sint64  Sint;
42 typedef Uint64  Uint;
43 typedef Uint64  tPAddr;
44 typedef Uint64  tVAddr;
45
46 typedef Uint64  size_t;
47 typedef char    BOOL;
48
49 #define __ASM__ __asm__ __volatile__
50
51 // === MACROS ===
52 /**
53  * \brief Halt the CPU
54  */
55 #define HALT()  __asm__ __volatile__ ("sti;\n\thlt")
56 /**
57  * \brief Fire a magic breakpoint (bochs)
58  */
59 #define MAGIC_BREAK()   __asm__ __volatile__ ("xchg %bx, %bx")
60
61 // Systemcall Registers
62 // TODO: Fix this structure
63 typedef struct sSyscallRegs
64 {
65         union {
66                 Uint    Num;
67                 Uint    Return;
68         };      // RAX
69         Uint    Error;  // RBX
70         Uint    Arg1;   // RDI
71         Uint    Arg2;   // RSI
72         Uint    Arg3;   // RDX
73         Uint    Arg4;   // RCX
74         Uint    Arg5;   // R8
75         Uint    Arg6;   // R9
76         Uint    _Flags;
77         Uint    _IP;
78         Uint    StackPointer;   // RSP
79         
80 }       tSyscallRegs;
81
82 /**
83  * \brief Short Spinlock structure
84  */
85 struct sShortSpinlock {
86         #if STACKED_LOCKS == 2
87         volatile void   *Lock;  //!< Lock value
88         #else
89         volatile int    Lock;   //!< Lock value
90         #endif
91         
92         #if LOCK_DISABLE_INTS
93          int    IF;     //!< Interrupt state on call to SHORTLOCK
94         #endif
95         #if STACKED_LOCKS
96          int    Depth;
97         #endif
98 };
99
100 // === FUNCTIONS ===
101 extern int      IS_LOCKED(struct sShortSpinlock *Lock);
102 extern int      CPU_HAS_LOCK(struct sShortSpinlock *Lock);
103 extern void     SHORTLOCK(struct sShortSpinlock *Lock);
104 extern void     SHORTREL(struct sShortSpinlock *Lock);
105
106 extern void     Debug_PutCharDebug(char ch);
107 extern void     Debug_PutStringDebug(const char *Str);
108
109 // TODO: Move this to acess.h
110 extern tPAddr   MM_AllocateZero(tVAddr VAddr);
111
112 #endif
113

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