-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.h
67 lines (57 loc) · 1.52 KB
/
process.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
#ifndef PROCESS_H_
#define PROCESS_H_
#define TRUE 1
#define FALSE 0
#define PRIVATE static
#define SVC() __asm(" SVC #0")
#define disable() __asm(" cpsid i")
#define enable() __asm(" cpsie i")
#define MSP_RETURN 0xFFFFFFF9 //LR value: exception return using MSP as SP
#define PSP_RETURN 0xFFFFFFFD //LR value: exception return using PSP as SP
void set_LR(volatile unsigned long);
unsigned long get_PSP();
void set_PSP(volatile unsigned long);
unsigned long get_MSP(void);
void set_MSP(volatile unsigned long);
unsigned long get_SP();
void assignR7(volatile unsigned long);
void save_registers();
void restore_registers();
#define STACKSIZE 1024
/* Cortex default stack frame */
struct stack_frame
{
/* Registers saved by s/w (explicit) */
/* There is no actual need to reserve space for R4-R11, other than
* for initialization purposes. Note that r0 is the h/w top-of-stack.
*/
unsigned long r4;
unsigned long r5;
unsigned long r6;
unsigned long r7;
unsigned long r8;
unsigned long r9;
unsigned long r10;
unsigned long r11;
/* Stacked by hardware (implicit)*/
unsigned long r0;
unsigned long r1;
unsigned long r2;
unsigned long r3;
unsigned long r12;
unsigned long lr; /* Address of process-terminate function */
unsigned long pc; /* Address of process entry point */
unsigned long xpsr; /* Initialize to 0x010000000 */
};
/* Process control block */
struct pcb
{
/* Stack pointer - r13 (PSP) */
unsigned long sp;
unsigned id;
/* Links to adjacent PCBs */
struct pcb *next;
struct pcb *prev;
unsigned priority;
};
#endif /*PROCESS_H_*/