comparison src/defs.h @ 0:83c23a36980d

Init
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Fri, 26 May 2017 23:11:05 +0900
parents
children 1a64b5645cdd
comparison
equal deleted inserted replaced
-1:000000000000 0:83c23a36980d
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));
62 void panic(char*) __attribute__((noreturn));
63
64 // exec.c
65 int exec(char*, char**);
66
67 // file.c
68 struct file* filealloc(void);
69 void fileclose(struct file*);
70 struct file* filedup(struct file*);
71 void fileinit(void);
72 int fileread(struct file*, char*, int n);
73 int filestat(struct file*, struct stat*);
74 int filewrite(struct file*, char*, int n);
75
76 // fs.c
77 void readsb(int dev, struct superblock *sb);
78 int dirlink(struct inode*, char*, uint);
79 struct inode* dirlookup(struct inode*, char*, uint*);
80 struct inode* ialloc(uint, short);
81 struct inode* idup(struct inode*);
82 void iinit(void);
83 void ilock(struct inode*);
84 void iput(struct inode*);
85 void iunlock(struct inode*);
86 void iunlockput(struct inode*);
87 void iupdate(struct inode*);
88 int namecmp(const char*, const char*);
89 struct inode* namei(char*);
90 struct inode* nameiparent(char*, char*);
91 int readi(struct inode*, char*, uint, uint);
92 void stati(struct inode*, struct stat*);
93 int writei(struct inode*, char*, uint, uint);
94
95 // ide.c
96 void ideinit(void);
97 void iderw(struct buf*);
98
99 // kalloc.c
100 /*char* kalloc(void);
101 void kfree(char*);
102 void kinit1(void*, void*);
103 void kinit2(void*, void*);
104 void kmem_init (void);*/
105
106 // log.c
107 void initlog(void);
108 void log_write(struct buf*);
109 void begin_trans();
110 void commit_trans();
111
112 // picirq.c
113 void pic_enable(int, ISR);
114 void pic_init(void*);
115 void pic_dispatch (struct trapframe *tp);
116
117 // pipe.c
118 int pipealloc(struct file**, struct file**);
119 void pipeclose(struct pipe*, int);
120 int piperead(struct pipe*, char*, int);
121 int pipewrite(struct pipe*, char*, int);
122
123 //PAGEBREAK: 16
124 // proc.c
125 struct proc* copyproc(struct proc*);
126 void exit(void);
127 int fork(void);
128 int growproc(int);
129 int kill(int);
130 void pinit(void);
131 void procdump(void);
132 void scheduler(void) __attribute__((noreturn));
133 void sched(void);
134 void sleep(void*, struct spinlock*);
135 void userinit(void);
136 int wait(void);
137 void wakeup(void*);
138 void yield(void);
139
140 // swtch.S
141 void swtch(struct context**, struct context*);
142
143 // spinlock.c
144 void acquire(struct spinlock*);
145 int holding(struct spinlock*);
146 void initlock(struct spinlock*, char*);
147 void release(struct spinlock*);
148
149 // string.c
150 int memcmp(const void*, const void*, uint);
151 void* memmove(void*, const void*, uint);
152 void* memset(void*, int, uint);
153 char* safestrcpy(char*, const char*, int);
154 int strlen(const char*);
155 int strncmp(const char*, const char*, uint);
156 char* strncpy(char*, const char*, int);
157
158 // syscall.c
159 int argint(int, int*);
160 int argptr(int, char**, int);
161 int argstr(int, char**);
162 int fetchint(uint, int*);
163 int fetchstr(uint, char**);
164 void syscall(void);
165
166 // timer.c
167 void timer_init(int hz);
168 extern struct spinlock tickslock;
169
170 // trap.c
171 extern uint ticks;
172 void trap_init(void);
173 void dump_trapframe (struct trapframe *tf);
174
175 // trap_asm.S
176 void trap_reset(void);
177 void trap_und(void);
178 void trap_swi(void);
179 void trap_iabort(void);
180 void trap_dabort(void);
181 void trap_na(void);
182 void trap_irq(void);
183 void trap_fiq(void);
184
185 // uart.c
186 void uart_init(void*);
187 void uartputc(int);
188 int uartgetc(void);
189 void micro_delay(int us);
190 void uart_enable_rx();
191
192 // vm.c
193 int allocuvm(pde_t*, uint, uint);
194 int deallocuvm(pde_t*, uint, uint);
195 void freevm(pde_t*);
196 void inituvm(pde_t*, char*, uint);
197 int loaduvm(pde_t*, char*, struct inode*, uint, uint);
198 pde_t* copyuvm(pde_t*, uint);
199 void switchuvm(struct proc*);
200 int copyout(pde_t*, uint, void*, uint);
201 void clearpteu(pde_t *pgdir, char *uva);
202 void* kpt_alloc(void);
203 void init_vmm (void);
204 void kpt_freerange (uint32 low, uint32 hi);
205 void paging_init (uint phy_low, uint phy_hi);
206 #endif