Mercurial > hg > CbC > CbC_xv6
annotate src/proc.h @ 357:e194c940c664
fix Getopt
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 15 Jun 2020 18:41:01 +0900 |
parents | 654f2dadd744 |
children | 650fac123133 |
rev | line source |
---|---|
26 | 1 #include "typedefData.h" |
0 | 2 #ifndef PROC_INCLUDE_ |
3 #define PROC_INCLUDE_ | |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
80
diff
changeset
|
4 #include "context.h" |
0 | 5 |
149 | 6 |
0 | 7 // Per-CPU state, now we only support one CPU |
8 struct cpu { | |
9 uchar id; // index into cpus[] below | |
10 struct context* scheduler; // swtch() here to enter scheduler | |
11 volatile uint started; // Has the CPU started? | |
12 | |
13 int ncli; // Depth of pushcli nesting. | |
14 int intena; // Were interrupts enabled before pushcli? | |
15 | |
16 // Cpu-local storage variables; see below | |
17 struct cpu* cpu; | |
18 struct proc* proc; // The currently-running process. | |
19 }; | |
20 | |
21 extern struct cpu cpus[NCPU]; | |
22 extern int ncpu; | |
23 | |
24 extern struct cpu* cpu; | |
25 extern struct proc* proc; | |
26 | |
27 //PAGEBREAK: 17 | |
28 // Saved registers for kernel context switches. The context switcher | |
29 // needs to save the callee save register, as usually. For ARM, it is | |
30 // also necessary to save the banked sp (r13) and lr (r14) registers. | |
31 // There is, however, no need to save the user space pc (r15) because | |
32 // pc has been saved on the stack somewhere. We only include it here | |
33 // for debugging purpose. It will not be restored for the next process. | |
34 // According to ARM calling convension, r0-r3 is caller saved. We do | |
35 // not need to save sp_svc, as it will be saved in the pcb, neither | |
36 // pc_svc, as it will be always be the same value. | |
37 // | |
38 // Keep it in sync with swtch.S | |
39 // | |
40 struct context { | |
41 // svc mode registers | |
42 uint r4; | |
43 uint r5; | |
44 uint r6; | |
45 uint r7; | |
46 uint r8; | |
47 uint r9; | |
48 uint r10; | |
49 uint r11; | |
50 uint r12; | |
51 uint lr; | |
52 }; | |
53 | |
54 | |
55 enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; | |
56 | |
57 // Per-process state | |
58 struct proc { | |
59 uint sz; // Size of process memory (bytes) | |
60 pde_t* pgdir; // Page table | |
61 char* kstack; // Bottom of kernel stack for this process | |
62 enum procstate state; // Process state | |
63 volatile int pid; // Process ID | |
64 struct proc* parent; // Parent process | |
65 struct trapframe* tf; // Trap frame for current syscall | |
66 struct context* context; // swtch() here to run process | |
67 void* chan; // If non-zero, sleeping on chan | |
68 int killed; // If non-zero, have been killed | |
69 struct file* ofile[NOFILE]; // Open files | |
70 struct inode* cwd; // Current directory | |
71 char name[16]; // Process name (debugging) | |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
80
diff
changeset
|
72 struct Context cbc_context; |
25 | 73 union cbc_arg { |
74 struct cbc_console_arg { | |
37 | 75 int n; |
32 | 76 int target; |
77 char* dst; | |
78 struct inode *ip; | |
79 struct file *f; | |
80 int num; | |
37 | 81 struct pipe *p; |
82 char *addr; | |
83 int i; | |
32 | 84 __code (*next)(int ret); |
26 | 85 } cbc_console_arg; |
25 | 86 } cbc_arg; |
87 __code (*cbc_next)(); | |
27 | 88 struct spinlock *lk; |
0 | 89 }; |
90 | |
80 | 91 // typedef struct context_interface<Type,Imple>{ |
92 // // union Data* stack; | |
93 // // union Data* data; | |
94 // | |
95 // // __code push(Impl* stack,Type* data, __code next(...)); | |
96 // // __code next(...); | |
97 // | |
98 // union Data* stack; | |
99 // union Data* data; | |
100 // union Data* data1; | |
101 // enum Code whenEmpty; | |
102 // enum Code clear; | |
103 // enum Code push; | |
104 // enum Code pop; | |
105 // enum Code pop2; | |
106 // enum Code isEmpty; | |
107 // enum Code get; | |
108 // enum Code get2; | |
109 // enum Code next; | |
110 // }context_interface; | |
111 | |
112 | |
0 | 113 // Process memory is laid out contiguously, low addresses first: |
114 // text | |
115 // original data and bss | |
116 // fixed-size stack | |
117 // expandable heap | |
118 #endif |