vm: merge i386 and arm pagetable code
[minix.git] / kernel / proto.h
blobc0065dd8946b2379d12410d1dd60859da0a1724d
1 /* Function prototypes. */
3 /* FIXME this is a hack how to avoid inclusion conflicts */
4 #ifdef __kernel__
6 #ifndef PROTO_H
7 #define PROTO_H
9 #include <minix/safecopies.h>
10 #include <machine/archtypes.h>
11 #include <a.out.h>
13 /* Struct declarations. */
14 struct proc;
15 struct timer;
17 /* clock.c */
18 clock_t get_uptime(void);
19 void set_timer(struct timer *tp, clock_t t, tmr_func_t f);
20 void reset_timer(struct timer *tp);
21 void ser_dump_proc(void);
23 void cycles_accounting_init(void);
25 * This functions start and stop accounting for process, kernel or idle cycles.
26 * It inherently have to account for some kernel cycles for process too,
27 * therefore it should be called asap after trapping to kernel and as late as
28 * possible before returning to userspace. These function is architecture
29 * dependent
31 void context_stop(struct proc * p);
32 /* this is a wrapper to make calling it from assembly easier */
33 void context_stop_idle(void);
34 int restore_fpu(struct proc *);
35 void save_fpu(struct proc *);
36 void save_local_fpu(struct proc *, int retain);
37 void fpu_sigcontext(struct proc *, struct sigframe *fr, struct
38 sigcontext *sc);
40 /* main.c */
41 #ifndef UNPAGED
42 #define kmain __k_unpaged_kmain
43 #endif
44 void kmain(kinfo_t *cbi);
45 void prepare_shutdown(int how);
46 __dead void minix_shutdown(struct timer *tp);
47 void bsp_finish_booting(void);
49 /* proc.c */
51 int do_ipc(reg_t r1, reg_t r2, reg_t r3);
52 void proc_init(void);
53 int cancel_async(struct proc *src, struct proc *dst);
54 int has_pending_notify(struct proc * caller, int src_p);
55 int has_pending_asend(struct proc * caller, int src_p);
56 void unset_notify_pending(struct proc * caller, int src_p);
57 int mini_notify(const struct proc *src, endpoint_t dst);
58 void enqueue(struct proc *rp);
59 void dequeue(struct proc *rp);
60 void switch_to_user(void);
61 void arch_proc_reset(struct proc *rp);
62 void arch_proc_setcontext(struct proc *rp, struct stackframe_s *state, int user);
63 struct proc * arch_finish_switch_to_user(void);
64 struct proc *endpoint_lookup(endpoint_t ep);
65 #if DEBUG_ENABLE_IPC_WARNINGS
66 int isokendpt_f(const char *file, int line, endpoint_t e, int *p, int
67 f);
68 #define isokendpt_d(e, p, f) isokendpt_f(__FILE__, __LINE__, (e), (p), (f))
69 #else
70 int isokendpt_f(endpoint_t e, int *p, int f);
71 #define isokendpt_d(e, p, f) isokendpt_f((e), (p), (f))
72 #endif
73 void proc_no_time(struct proc *p);
74 void reset_proc_accounting(struct proc *p);
75 void flag_account(struct proc *p, int flag);
76 int try_deliver_senda(struct proc *caller_ptr, asynmsg_t *table, size_t
77 size);
79 /* start.c */
80 void cstart();
81 char *env_get(const char *key);
83 /* system.c */
84 int get_priv(register struct proc *rc, int proc_type);
85 void set_sendto_bit(const struct proc *rc, int id);
86 void unset_sendto_bit(const struct proc *rc, int id);
87 void fill_sendto_mask(const struct proc *rc, sys_map_t *map);
88 int send_sig(endpoint_t proc_nr, int sig_nr);
89 void cause_sig(proc_nr_t proc_nr, int sig_nr);
90 void sig_delay_done(struct proc *rp);
91 void kernel_call(message *m_user, struct proc * caller);
92 void system_init(void);
93 void clear_endpoint(struct proc *rc);
94 void clear_ipc_refs(struct proc *rc, int caller_ret);
95 void kernel_call_resume(struct proc *p);
96 int sched_proc(struct proc *rp, int priority, int quantum, int cpu);
98 /* system/do_vtimer.c */
99 void vtimer_check(struct proc *rp);
101 /* interrupt.c */
102 void put_irq_handler(irq_hook_t *hook, int irq, irq_handler_t handler);
103 void rm_irq_handler(const irq_hook_t *hook);
104 void enable_irq(const irq_hook_t *hook);
105 int disable_irq(const irq_hook_t *hook);
107 void interrupts_enable(void);
108 void interrupts_disable(void);
110 /* debug.c */
111 int runqueues_ok(void);
112 #ifndef CONFIG_SMP
113 #define runqueues_ok_local runqueues_ok
114 #else
115 #define runqueues_ok_local() runqueues_ok_cpu(cpuid)
116 int runqueues_ok_cpu(unsigned cpu);
117 #endif
118 char *rtsflagstr(u32_t flags);
119 char *miscflagstr(u32_t flags);
120 char *schedulerstr(struct proc *scheduler);
121 /* prints process information */
122 void print_proc(struct proc *pp);
123 /* prints the given process and recursively all processes it depends on */
124 void print_proc_recursive(struct proc *pp);
125 #if DEBUG_IPC_HOOK
126 void hook_ipc_msgrecv(message *msg, struct proc *src, struct proc *dst);
127 void hook_ipc_msgsend(message *msg, struct proc *src, struct proc *dst);
128 void hook_ipc_msgkcall(message *msg, struct proc *proc);
129 void hook_ipc_msgkresult(message *msg, struct proc *proc);
130 void hook_ipc_clear(struct proc *proc);
131 #endif
133 /* system/do_safecopy.c */
134 int verify_grant(endpoint_t, endpoint_t, cp_grant_id_t, vir_bytes, int,
135 vir_bytes, vir_bytes *, endpoint_t *);
137 /* system/do_sysctl.c */
138 int do_sysctl(struct proc * caller, message *m);
140 #if SPROFILE
141 /* profile.c */
142 void init_profile_clock(u32_t);
143 void stop_profile_clock(void);
144 #endif
146 /* functions defined in architecture-dependent files. */
147 void prot_init();
148 void arch_post_init();
149 void arch_set_secondary_ipc_return(struct proc *, u32_t val);
150 phys_bytes phys_copy(phys_bytes source, phys_bytes dest, phys_bytes
151 count);
152 void phys_copy_fault(void);
153 void phys_copy_fault_in_kernel(void);
154 void memset_fault(void);
155 void memset_fault_in_kernel(void);
156 #define virtual_copy(src, dst, bytes) \
157 virtual_copy_f(NULL, src, dst, bytes, 0)
158 #define virtual_copy_vmcheck(caller, src, dst, bytes) \
159 virtual_copy_f(caller, src, dst, bytes, 1)
160 int virtual_copy_f(struct proc * caller, struct vir_addr *src, struct
161 vir_addr *dst, vir_bytes bytes, int vmcheck);
162 int data_copy(endpoint_t from, vir_bytes from_addr, endpoint_t to,
163 vir_bytes to_addr, size_t bytes);
164 int data_copy_vmcheck(struct proc *, endpoint_t from, vir_bytes
165 from_addr, endpoint_t to, vir_bytes to_addr, size_t bytes);
166 phys_bytes umap_virtual(struct proc* rp, int seg, vir_bytes vir_addr,
167 vir_bytes bytes);
168 phys_bytes seg2phys(u16_t);
169 int vm_memset(struct proc *caller, endpoint_t who, phys_bytes dst,
170 int pattern, phys_bytes count);
171 int intr_init(int);
172 void halt_cpu(void);
173 void arch_init(void);
174 void arch_boot_proc(struct boot_image *b, struct proc *p);
175 void cpu_identify(void);
176 /* arch dependent FPU initialization per CPU */
177 void fpu_init(void);
178 /* returns true if pfu is present and initialized */
179 int is_fpu(void);
180 void ser_putc(char);
181 __dead void arch_shutdown(int);
182 void restore_user_context(struct proc * p);
183 void read_tsc(u32_t *high, u32_t *low);
184 int arch_init_profile_clock(u32_t freq);
185 void arch_stop_profile_clock(void);
186 void arch_ack_profile_clock(void);
187 void do_ser_debug(void);
188 int arch_get_params(char *parm, int max);
189 void memory_init(void);
190 void mem_clear_mapcache(void);
191 void arch_proc_init(struct proc *pr, u32_t, u32_t, char *);
192 int arch_do_vmctl(message *m_ptr, struct proc *p);
193 int vm_contiguous(const struct proc *targetproc, vir_bytes vir_buf,
194 size_t count);
195 void proc_stacktrace(struct proc *proc);
196 int vm_lookup(const struct proc *proc, vir_bytes virtual, phys_bytes
197 *result, u32_t *ptent);
198 size_t vm_lookup_range(const struct proc *proc,
199 vir_bytes vir_addr, phys_bytes *phys_addr, size_t bytes);
200 void delivermsg(struct proc *target);
201 void arch_do_syscall(struct proc *proc);
202 int arch_phys_map(int index, phys_bytes *addr, phys_bytes *len, int
203 *flags);
204 int arch_phys_map_reply(int index, vir_bytes addr);
205 reg_t arch_get_sp(struct proc *p);
206 int arch_enable_paging(struct proc * caller);
207 int vm_check_range(struct proc *caller,
208 struct proc *target, vir_bytes vir_addr, size_t bytes);
210 int copy_msg_from_user(message * user_mbuf, message * dst);
211 int copy_msg_to_user(message * src, message * user_mbuf);
212 void switch_address_space(struct proc * p);
213 void release_address_space(struct proc *pr);
215 void enable_fpu_exception(void);
216 void disable_fpu_exception(void);
217 void release_fpu(struct proc * p);
218 void arch_pause(void);
219 short cpu_load(void);
220 void busy_delay_ms(int ms);
222 /* utility.c */
223 void cpu_print_freq(unsigned cpu);
224 #endif /* __kernel__ */
226 #endif /* PROTO_H */