-
Notifications
You must be signed in to change notification settings - Fork 10
/
gaia.h
101 lines (89 loc) · 1.49 KB
/
gaia.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef __ASSEMBLER__
#include "memlayout.h"
#include "traps.h"
#endif
#define PL_USER 3
#define PL_KERN 0
#define HEADER_SIZE 4
#ifndef __ASSEMBLER__
// Routines to let C code use special GAIA instructions and memory addresses.
static inline void
cli(void)
{
*(int*)INTENABLE = 0;
}
static inline void
sti(void)
{
*(int*)INTENABLE = 1;
}
// read interrupt flag
static inline uchar
is_interruptible(void)
{
return *(int*)INTENABLE;
}
static inline void
setpd(uint val)
{
*(int*)PDADDR = val;
__asm(".space 40\n"); // 10 nops
}
// read trap no
static inline uint
readtrapno()
{
return *(int*)CAUSE;
}
// read trap return address
static inline uint
readtreturn()
{
switch(readtrapno()){
case T_SYSCALL:
return *(int*)EPC; // GAIA stores the correct interrupted address for sysenter exception.
default:
return *(int*)EPC - 4; // GAIA stores interrupted address + 4 for the others.
}
}
// Layout of the trap frame built on the stack by the
// hardware and by trapasm.S, and passed to trap().
struct trapframe {
uint privilege;
// trapno: set in trap.c
uint trapno;
uint retaddr;
// general registers
uint r31;
uint r30;
uint r29;
uint r28;
uint r27;
uint r26;
uint r25;
uint r24;
uint r23;
uint r22;
uint r21;
uint r20;
uint r19;
uint r18;
uint r17;
uint r16;
uint r15;
uint r14;
uint r13;
uint r12;
uint r11;
uint r10;
uint r9;
uint r8;
uint r7;
uint r6;
uint r5;
uint r4;
uint r3;
uint r2;
uint r1;
};
#endif