Kernel - Fix compilation on x86_64 and armv7 (for MM changes)
[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 char    BOOL;
47
48 #define __ASM__ __asm__ __volatile__
49
50 // === MACROS ===
51 /**
52  * \brief Halt the CPU
53  */
54 #define HALT()  __asm__ __volatile__ ("sti;\n\thlt")
55 /**
56  * \brief Fire a magic breakpoint (bochs)
57  */
58 #define MAGIC_BREAK()   __asm__ __volatile__ ("xchg %bx, %bx")
59
60 // Systemcall Registers
61 // TODO: Fix this structure
62 typedef struct sSyscallRegs
63 {
64         union {
65                 Uint    Num;
66                 Uint    Return;
67         };      // RAX
68         Uint    Error;  // RBX
69         Uint    Arg1;   // RDI
70         Uint    Arg2;   // RSI
71         Uint    Arg3;   // RDX
72         Uint    Arg4;   // RCX
73         Uint    Arg5;   // R8
74         Uint    Arg6;   // R9
75         Uint    _Flags;
76         Uint    _IP;
77         Uint    StackPointer;   // RSP
78         
79 }       tSyscallRegs;
80
81 /**
82  * \brief Short Spinlock structure
83  */
84 struct sShortSpinlock {
85         #if STACKED_LOCKS == 2
86         volatile void   *Lock;  //!< Lock value
87         #else
88         volatile int    Lock;   //!< Lock value
89         #endif
90         
91         #if LOCK_DISABLE_INTS
92          int    IF;     //!< Interrupt state on call to SHORTLOCK
93         #endif
94         #if STACKED_LOCKS
95          int    Depth;
96         #endif
97 };
98
99 // === FUNCTIONS ===
100 extern int      IS_LOCKED(struct sShortSpinlock *Lock);
101 extern int      CPU_HAS_LOCK(struct sShortSpinlock *Lock);
102 extern void     SHORTLOCK(struct sShortSpinlock *Lock);
103 extern void     SHORTREL(struct sShortSpinlock *Lock);
104
105 extern void     Debug_PutCharDebug(char ch);
106 extern void     Debug_PutStringDebug(const char *Str);
107
108 #endif
109

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