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