0
|
1 //
|
|
2 // a definition of data structure/methods
|
|
3 //
|
|
4 #ifndef INCLUDE_DEFS_H
|
|
5 #define INCLUDE_DEFS_H
|
|
6
|
|
7 #define UMAX(a, b) ((uint)(a) > (uint)(b) ? (uint)(a):(uint)(b))
|
|
8 #define UMIN(a, b) ((uint)(a) > (uint)(b) ? (uint)(b):(uint)(a))
|
|
9
|
|
10 // number of elements in fixed-size array
|
|
11 #define NELEM(x) (sizeof(x)/sizeof((x)[0]))
|
|
12
|
|
13 struct buf;
|
|
14 struct context;
|
|
15 struct file;
|
|
16 struct inode;
|
|
17 struct pipe;
|
|
18 struct proc;
|
|
19 struct spinlock;
|
|
20 struct stat;
|
|
21 struct superblock;
|
|
22 struct trapframe;
|
|
23
|
|
24 typedef uint32 pte_t;
|
|
25 typedef uint32 pde_t;
|
|
26 extern uint32 _kernel_pgtbl;
|
|
27 typedef void (*ISR) (struct trapframe *tf, int n);
|
|
28
|
|
29 // arm.c
|
|
30 void set_stk(uint mode, uint addr);
|
|
31 void cli (void);
|
|
32 void sti (void);
|
|
33 uint spsr_usr();
|
|
34 int int_enabled();
|
|
35 void pushcli(void);
|
|
36 void popcli(void);
|
|
37 void getcallerpcs(void *, uint*);
|
|
38 void* get_fp (void);
|
|
39 void show_callstk (char *);
|
|
40
|
|
41
|
|
42 // bio.c
|
|
43 void binit(void);
|
|
44 struct buf* bread(uint, uint);
|
|
45 void brelse(struct buf*);
|
|
46 void bwrite(struct buf*);
|
|
47
|
|
48 // buddy.c
|
|
49 void kmem_init (void);
|
|
50 void kmem_init2(void *vstart, void *vend);
|
|
51 void* kmalloc (int order);
|
|
52 void kfree (void *mem, int order);
|
|
53 void free_page(void *v);
|
|
54 void* alloc_page (void);
|
|
55 void kmem_test_b (void);
|
|
56 int get_order (uint32 v);
|
|
57
|
|
58 // console.c
|
|
59 void consoleinit(void);
|
|
60 void cprintf(char*, ...);
|
|
61 void consoleintr(int(*)(void));
|
30
|
62 __code cbc_panic(char*) __attribute__((noreturn));
|
0
|
63 void panic(char*) __attribute__((noreturn));
|
|
64
|
|
65 // exec.c
|
|
66 int exec(char*, char**);
|
|
67
|
|
68 // file.c
|
|
69 struct file* filealloc(void);
|
|
70 void fileclose(struct file*);
|
|
71 struct file* filedup(struct file*);
|
|
72 void fileinit(void);
|
30
|
73 __code cbc_fileread (struct file*, char*, int, __code (*)(int));
|
0
|
74 int fileread(struct file*, char*, int n);
|
|
75 int filestat(struct file*, struct stat*);
|
|
76 int filewrite(struct file*, char*, int n);
|
|
77
|
|
78 // fs.c
|
|
79 void readsb(int dev, struct superblock *sb);
|
|
80 int dirlink(struct inode*, char*, uint);
|
|
81 struct inode* dirlookup(struct inode*, char*, uint*);
|
|
82 struct inode* ialloc(uint, short);
|
|
83 struct inode* idup(struct inode*);
|
|
84 void iinit(void);
|
|
85 void ilock(struct inode*);
|
|
86 void iput(struct inode*);
|
|
87 void iunlock(struct inode*);
|
|
88 void iunlockput(struct inode*);
|
|
89 void iupdate(struct inode*);
|
|
90 int namecmp(const char*, const char*);
|
|
91 struct inode* namei(char*);
|
|
92 struct inode* nameiparent(char*, char*);
|
33
|
93 __code cbc_readi (struct inode*, char*, uint, uint, __code (*)(int));
|
0
|
94 int readi(struct inode*, char*, uint, uint);
|
|
95 void stati(struct inode*, struct stat*);
|
|
96 int writei(struct inode*, char*, uint, uint);
|
|
97
|
|
98 // ide.c
|
|
99 void ideinit(void);
|
|
100 void iderw(struct buf*);
|
|
101
|
|
102 // kalloc.c
|
|
103 /*char* kalloc(void);
|
|
104 void kfree(char*);
|
|
105 void kinit1(void*, void*);
|
|
106 void kinit2(void*, void*);
|
|
107 void kmem_init (void);*/
|
|
108
|
|
109 // log.c
|
|
110 void initlog(void);
|
|
111 void log_write(struct buf*);
|
|
112 void begin_trans();
|
|
113 void commit_trans();
|
|
114
|
|
115 // picirq.c
|
|
116 void pic_enable(int, ISR);
|
|
117 void pic_init(void*);
|
|
118 void pic_dispatch (struct trapframe *tp);
|
|
119
|
|
120 // pipe.c
|
|
121 int pipealloc(struct file**, struct file**);
|
|
122 void pipeclose(struct pipe*, int);
|
|
123 int piperead(struct pipe*, char*, int);
|
37
|
124 __code cbc_piperead(struct pipe*, char*, int, __code (*)(int));
|
0
|
125 int pipewrite(struct pipe*, char*, int);
|
|
126
|
|
127 //PAGEBREAK: 16
|
|
128 // proc.c
|
|
129 struct proc* copyproc(struct proc*);
|
|
130 void exit(void);
|
|
131 int fork(void);
|
|
132 int growproc(int);
|
|
133 int kill(int);
|
|
134 void pinit(void);
|
|
135 void procdump(void);
|
|
136 void scheduler(void) __attribute__((noreturn));
|
|
137 void sched(void);
|
27
|
138 __code cbc_sleep(void*, struct spinlock*, __code(*next1)());
|
0
|
139 void sleep(void*, struct spinlock*);
|
|
140 void userinit(void);
|
|
141 int wait(void);
|
37
|
142 __code cbc_wakeup(void*, __code(*next1)());
|
0
|
143 void wakeup(void*);
|
|
144 void yield(void);
|
|
145
|
|
146 // swtch.S
|
|
147 void swtch(struct context**, struct context*);
|
|
148
|
|
149 // spinlock.c
|
|
150 void acquire(struct spinlock*);
|
|
151 int holding(struct spinlock*);
|
|
152 void initlock(struct spinlock*, char*);
|
|
153 void release(struct spinlock*);
|
|
154
|
|
155 // string.c
|
|
156 int memcmp(const void*, const void*, uint);
|
|
157 void* memmove(void*, const void*, uint);
|
|
158 void* memset(void*, int, uint);
|
|
159 char* safestrcpy(char*, const char*, int);
|
|
160 int strlen(const char*);
|
|
161 int strncmp(const char*, const char*, uint);
|
|
162 char* strncpy(char*, const char*, int);
|
|
163
|
|
164 // syscall.c
|
|
165 int argint(int, int*);
|
|
166 int argptr(int, char**, int);
|
|
167 int argstr(int, char**);
|
|
168 int fetchint(uint, int*);
|
|
169 int fetchstr(uint, char**);
|
31
|
170 __code cbc_ret(int);
|
0
|
171 void syscall(void);
|
|
172
|
|
173 // timer.c
|
|
174 void timer_init(int hz);
|
|
175 extern struct spinlock tickslock;
|
|
176
|
|
177 // trap.c
|
|
178 extern uint ticks;
|
|
179 void trap_init(void);
|
|
180 void dump_trapframe (struct trapframe *tf);
|
|
181
|
|
182 // trap_asm.S
|
|
183 void trap_reset(void);
|
|
184 void trap_und(void);
|
|
185 void trap_swi(void);
|
|
186 void trap_iabort(void);
|
|
187 void trap_dabort(void);
|
|
188 void trap_na(void);
|
|
189 void trap_irq(void);
|
|
190 void trap_fiq(void);
|
|
191
|
|
192 // uart.c
|
|
193 void uart_init(void*);
|
|
194 void uartputc(int);
|
|
195 int uartgetc(void);
|
|
196 void micro_delay(int us);
|
|
197 void uart_enable_rx();
|
|
198
|
|
199 // vm.c
|
|
200 int allocuvm(pde_t*, uint, uint);
|
|
201 int deallocuvm(pde_t*, uint, uint);
|
|
202 void freevm(pde_t*);
|
|
203 void inituvm(pde_t*, char*, uint);
|
|
204 int loaduvm(pde_t*, char*, struct inode*, uint, uint);
|
|
205 pde_t* copyuvm(pde_t*, uint);
|
|
206 void switchuvm(struct proc*);
|
|
207 int copyout(pde_t*, uint, void*, uint);
|
|
208 void clearpteu(pde_t *pgdir, char *uva);
|
|
209 void* kpt_alloc(void);
|
|
210 void init_vmm (void);
|
|
211 void kpt_freerange (uint32 low, uint32 hi);
|
|
212 void paging_init (uint phy_low, uint phy_hi);
|
|
213 #endif
|