Fiddling with x86_64 and i486 builds
[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 STACKED_LOCKS   0
14 #define LOCK_DISABLE_INTS       1
15
16 //#define INT_MAX       0x7FFFFFFF
17 //#define UINT_MAX      0xFFFFFFFF
18
19 // === Core Types ===
20 typedef signed char     Sint8;
21 typedef unsigned char   Uint8;
22 typedef signed short    Sint16;
23 typedef unsigned short  Uint16;
24 typedef signed int      Sint32;
25 typedef unsigned int    Uint32;
26 #if __WORDSIZE == 64
27 typedef signed long int Sint64;
28 typedef unsigned long int       Uint64;
29 #else
30 typedef signed long long int    Sint64;
31 typedef unsigned long long int  Uint64;
32 #endif
33
34 typedef Sint64  Sint;
35 typedef Uint64  Uint;
36 typedef Uint64  tPAddr;
37 typedef Uint64  tVAddr;
38
39 typedef Uint64  size_t;
40 typedef char    BOOL;
41
42 #define __ASM__ __asm__ __volatile__
43
44 // === MACROS ===
45 /**
46  * \brief Halt the CPU
47  */
48 #define HALT()  __asm__ __volatile__ ("sti;\n\thlt")
49 /**
50  * \brief Fire a magic breakpoint (bochs)
51  */
52 #define MAGIC_BREAK()   __asm__ __volatile__ ("xchg %bx, %bx")
53
54 // Systemcall Registers
55 // TODO: Fix this structure
56 typedef struct sSyscallRegs
57 {
58         union {
59                 Uint    Num;
60                 Uint    Return;
61         };      // RAX
62         Uint    Arg4;   // RCX
63         Uint    Arg3;   // RDX
64         Uint    Error;  // RBX
65         Uint    Resvd1[2];      // Kernel RSP, RBP
66         Uint    Arg2;   // RSI
67         Uint    Arg1;   // RDI
68         Uint    Arg5;   // R8
69         Uint    Arg6;   // R9
70         Uint    Resvd2[6];      // R10 - R15
71         Uint    Resvd3[5];      // IntNum, ErrCode, RIP, CS, RFLAGS
72         
73         Uint    Resvd4[5];      // Int, Err, rip, CS, ...
74         Uint    StackPointer;   // RSP
75         Uint    Resvd5[1];      // SS   
76 }       tSyscallRegs;
77
78 /**
79  * \brief Short Spinlock structure
80  */
81 struct sShortSpinlock {
82         #if STACKED_LOCKS == 2
83         volatile void   *Lock;  //!< Lock value
84         #else
85         volatile int    Lock;   //!< Lock value
86         #endif
87         
88         #if LOCK_DISABLE_INTS
89          int    IF;     //!< Interrupt state on call to SHORTLOCK
90         #endif
91         #if STACKED_LOCKS
92          int    Depth;
93         #endif
94 };
95
96 // === FUNCTIONS ===
97 extern int      IS_LOCKED(struct sShortSpinlock *Lock);
98 extern int      CPU_HAS_LOCK(struct sShortSpinlock *Lock);
99 extern void     SHORTLOCK(struct sShortSpinlock *Lock);
100 extern void     SHORTREL(struct sShortSpinlock *Lock);
101
102 #endif
103

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