Remove building with NOCRYPTO option
[minix.git] / minix / kernel / proto.h
blobf8b8dbed1364c1b661fe90a9b18bd4f79e9dc907
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 <machine/signal.h>
12 #include <machine/frame.h>
14 /* Struct declarations. */
15 struct proc;
16 struct ipc_filter_s;
18 /* clock.c */
19 void init_clock(void);
20 clock_t get_realtime(void);
21 void set_realtime(clock_t);
22 void set_adjtime_delta(int32_t);
23 clock_t get_monotonic(void);
24 void set_boottime(time_t);
25 time_t get_boottime(void);
26 void set_kernel_timer(minix_timer_t *tp, clock_t t, tmr_func_t f, int arg);
27 void reset_kernel_timer(minix_timer_t *tp);
28 void ser_dump_proc(void);
30 void cycles_accounting_init(void);
32 * This functions start and stop accounting for process, kernel or idle cycles.
33 * It inherently have to account for some kernel cycles for process too,
34 * therefore it should be called asap after trapping to kernel and as late as
35 * possible before returning to userspace. These function is architecture
36 * dependent
38 void context_stop(struct proc * p);
39 /* this is a wrapper to make calling it from assembly easier */
40 void context_stop_idle(void);
41 void get_cpu_ticks(unsigned int cpu, uint64_t ticks[MINIX_CPUSTATES]);
42 int restore_fpu(struct proc *);
43 void save_fpu(struct proc *);
44 void save_local_fpu(struct proc *, int retain);
45 void fpu_sigcontext(struct proc *, struct sigframe_sigcontext *fr, struct
46 sigcontext *sc);
48 /* main.c */
49 #ifndef UNPAGED
50 #define kmain __k_unpaged_kmain
51 #endif
52 void kmain(kinfo_t *cbi);
53 void prepare_shutdown(int how);
54 __dead void minix_shutdown(int how);
55 void bsp_finish_booting(void);
57 /* proc.c */
59 int do_ipc(reg_t r1, reg_t r2, reg_t r3);
60 void proc_init(void);
61 int cancel_async(struct proc *src, struct proc *dst);
62 int has_pending_notify(struct proc * caller, int src_p);
63 int has_pending_asend(struct proc * caller, int src_p);
64 void unset_notify_pending(struct proc * caller, int src_p);
65 int mini_notify(const struct proc *src, endpoint_t dst);
66 void vm_suspend(struct proc *caller, const struct proc *target,
67 const vir_bytes linaddr, const vir_bytes len, const int type,
68 const int writeflag);
69 void enqueue(struct proc *rp);
70 void dequeue(struct proc *rp);
71 void switch_to_user(void);
72 void arch_proc_reset(struct proc *rp);
73 void arch_proc_setcontext(struct proc *rp, struct stackframe_s *state,
74 int user, int restorestyle);
75 struct proc * arch_finish_switch_to_user(void);
76 struct proc *endpoint_lookup(endpoint_t ep);
77 #if DEBUG_ENABLE_IPC_WARNINGS
78 int isokendpt_f(const char *file, int line, endpoint_t e, int *p, int
79 f);
80 #define isokendpt_d(e, p, f) isokendpt_f(__FILE__, __LINE__, (e), (p), (f))
81 #else
82 int isokendpt_f(endpoint_t e, int *p, int f);
83 #define isokendpt_d(e, p, f) isokendpt_f((e), (p), (f))
84 #endif
85 void proc_no_time(struct proc *p);
86 void reset_proc_accounting(struct proc *p);
87 void flag_account(struct proc *p, int flag);
88 int try_deliver_senda(struct proc *caller_ptr, asynmsg_t *table, size_t
89 size);
91 /* start.c */
92 void cstart(void);
93 char *env_get(const char *key);
95 /* system.c */
96 int get_priv(register struct proc *rc, int proc_type);
97 void set_sendto_bit(const struct proc *rc, int id);
98 void unset_sendto_bit(const struct proc *rc, int id);
99 void fill_sendto_mask(const struct proc *rc, sys_map_t *map);
100 int send_sig(endpoint_t proc_nr, int sig_nr);
101 void cause_sig(proc_nr_t proc_nr, int sig_nr);
102 void sig_delay_done(struct proc *rp);
103 void send_diag_sig(void);
104 void kernel_call(message *m_user, struct proc * caller);
105 void system_init(void);
106 void clear_endpoint(struct proc *rc);
107 void clear_ipc_refs(struct proc *rc, int caller_ret);
108 void kernel_call_resume(struct proc *p);
109 int sched_proc(struct proc *rp, int priority, int quantum, int cpu, int niced);
110 int add_ipc_filter(struct proc *rp, int type,
111 vir_bytes address, size_t length);
112 void clear_ipc_filters(struct proc *rp);
113 int check_ipc_filter(struct ipc_filter_s *ipcf, int fill_flags);
114 int allow_ipc_filtered_msg(struct proc *rp, endpoint_t src_e,
115 vir_bytes m_src_v, message *m_src_p);
116 int allow_ipc_filtered_memreq(struct proc *src_rp, struct proc *dst_rp);
117 int priv_add_irq(struct proc *rp, int irq);
118 int priv_add_io(struct proc *rp, struct io_range *ior);
119 int priv_add_mem(struct proc *rp, struct minix_mem_range *memr);
121 /* system/do_vtimer.c */
122 void vtimer_check(struct proc *rp);
124 /* interrupt.c */
125 void put_irq_handler(irq_hook_t *hook, int irq, irq_handler_t handler);
126 void rm_irq_handler(const irq_hook_t *hook);
127 void enable_irq(const irq_hook_t *hook);
128 int disable_irq(const irq_hook_t *hook);
130 void interrupts_enable(void);
131 void interrupts_disable(void);
133 /* debug.c */
134 int runqueues_ok(void);
135 #ifndef CONFIG_SMP
136 #define runqueues_ok_local runqueues_ok
137 #else
138 #define runqueues_ok_local() runqueues_ok_cpu(cpuid)
139 int runqueues_ok_cpu(unsigned cpu);
140 #endif
141 char *rtsflagstr(u32_t flags);
142 char *miscflagstr(u32_t flags);
143 char *schedulerstr(struct proc *scheduler);
144 /* prints process information */
145 void print_proc(struct proc *pp);
146 /* prints the given process and recursively all processes it depends on */
147 void print_proc_recursive(struct proc *pp);
148 void printmsg(message *msg, struct proc *src, struct proc *dst,
149 char operation, int printparams);
150 #if DEBUG_IPC_HOOK
151 void hook_ipc_msgrecv(message *msg, struct proc *src, struct proc *dst);
152 void hook_ipc_msgsend(message *msg, struct proc *src, struct proc *dst);
153 void hook_ipc_msgkcall(message *msg, struct proc *proc);
154 void hook_ipc_msgkresult(message *msg, struct proc *proc);
155 void hook_ipc_clear(struct proc *proc);
156 #endif
158 /* system/do_safecopy.c */
159 struct cp_sfinfo; /* external callers may only provide NULL */
160 int verify_grant(endpoint_t, endpoint_t, cp_grant_id_t, vir_bytes, int,
161 vir_bytes, vir_bytes *, endpoint_t *, struct cp_sfinfo *);
163 /* system/do_diagctl.c */
164 int do_diagctl(struct proc * caller, message *m);
166 #if SPROFILE
167 /* profile.c */
168 void init_profile_clock(u32_t);
169 void stop_profile_clock(void);
170 #endif
172 /* functions defined in architecture-dependent files. */
173 void prot_init(void);
174 void arch_post_init(void);
175 void arch_set_secondary_ipc_return(struct proc *, u32_t val);
176 phys_bytes phys_copy(phys_bytes source, phys_bytes dest, phys_bytes
177 count);
178 void phys_copy_fault(void);
179 void phys_copy_fault_in_kernel(void);
180 void memset_fault(void);
181 void memset_fault_in_kernel(void);
182 #define virtual_copy(src, dst, bytes) \
183 virtual_copy_f(NULL, src, dst, bytes, 0)
184 #define virtual_copy_vmcheck(caller, src, dst, bytes) \
185 virtual_copy_f(caller, src, dst, bytes, 1)
186 int virtual_copy_f(struct proc * caller, struct vir_addr *src, struct
187 vir_addr *dst, vir_bytes bytes, int vmcheck);
188 int data_copy(endpoint_t from, vir_bytes from_addr, endpoint_t to,
189 vir_bytes to_addr, size_t bytes);
190 int data_copy_vmcheck(struct proc *, endpoint_t from, vir_bytes
191 from_addr, endpoint_t to, vir_bytes to_addr, size_t bytes);
192 phys_bytes umap_virtual(struct proc* rp, int seg, vir_bytes vir_addr,
193 vir_bytes bytes);
194 phys_bytes seg2phys(u16_t);
195 int vm_memset(struct proc *caller, endpoint_t who, phys_bytes dst,
196 int pattern, phys_bytes count);
197 int intr_init(int);
198 void halt_cpu(void);
199 void arch_init(void);
200 void arch_boot_proc(struct boot_image *b, struct proc *p);
201 void cpu_identify(void);
202 /* arch dependent FPU initialization per CPU */
203 void fpu_init(void);
204 /* returns true if pfu is present and initialized */
205 int is_fpu(void);
206 void ser_putc(char);
207 __dead void arch_shutdown(int);
208 void restore_user_context(struct proc * p);
209 void read_tsc(u32_t *high, u32_t *low);
210 int arch_init_profile_clock(u32_t freq);
211 void arch_stop_profile_clock(void);
212 void arch_ack_profile_clock(void);
213 void do_ser_debug(void);
214 int arch_get_params(char *parm, int max);
215 void memory_init(void);
216 void mem_clear_mapcache(void);
217 void arch_proc_init(struct proc *pr, u32_t, u32_t, u32_t, char *);
218 int arch_do_vmctl(message *m_ptr, struct proc *p);
219 int vm_contiguous(const struct proc *targetproc, vir_bytes vir_buf,
220 size_t count);
221 void proc_stacktrace(struct proc *proc);
222 int vm_lookup(const struct proc *proc, vir_bytes virtual, phys_bytes
223 *result, u32_t *ptent);
224 size_t vm_lookup_range(const struct proc *proc,
225 vir_bytes vir_addr, phys_bytes *phys_addr, size_t bytes);
226 void arch_do_syscall(struct proc *proc);
227 int arch_phys_map(int index, phys_bytes *addr, phys_bytes *len, int
228 *flags);
229 int arch_phys_map_reply(int index, vir_bytes addr);
230 reg_t arch_get_sp(struct proc *p);
231 int arch_enable_paging(struct proc * caller);
232 int vm_check_range(struct proc *caller,
233 struct proc *target, vir_bytes vir_addr, size_t bytes, int writable);
235 int copy_msg_from_user(message * user_mbuf, message * dst);
236 int copy_msg_to_user(message * src, message * user_mbuf);
237 void switch_address_space(struct proc * p);
238 void release_address_space(struct proc *pr);
240 void enable_fpu_exception(void);
241 void disable_fpu_exception(void);
242 void release_fpu(struct proc * p);
243 void arch_pause(void);
244 short cpu_load(void);
245 void busy_delay_ms(int ms);
247 /* utility.c */
248 void cpu_print_freq(unsigned cpu);
249 #endif /* __kernel__ */
251 #endif /* PROTO_H */