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 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); 47 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(minix_timer_t *tp); 55 void bsp_finish_booting(void); 56 57 /* proc.c */ 58 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); 90 91 /* start.c */ 92 void cstart(); 93 char *env_get(const char *key); 94 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); 120 121 /* system/do_vtimer.c */ 122 void vtimer_check(struct proc *rp); 123 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); 129 130 void interrupts_enable(void); 131 void interrupts_disable(void); 132 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 157 158 /* system/do_safecopy.c */ 159 int verify_grant(endpoint_t, endpoint_t, cp_grant_id_t, vir_bytes, int, 160 vir_bytes, vir_bytes *, endpoint_t *, u32_t *); 161 162 /* system/do_diagctl.c */ 163 int do_diagctl(struct proc * caller, message *m); 164 165 #if SPROFILE 166 /* profile.c */ 167 void init_profile_clock(u32_t); 168 void stop_profile_clock(void); 169 #endif 170 171 /* functions defined in architecture-dependent files. */ 172 void prot_init(); 173 void arch_post_init(); 174 void arch_set_secondary_ipc_return(struct proc *, u32_t val); 175 phys_bytes phys_copy(phys_bytes source, phys_bytes dest, phys_bytes 176 count); 177 void phys_copy_fault(void); 178 void phys_copy_fault_in_kernel(void); 179 void memset_fault(void); 180 void memset_fault_in_kernel(void); 181 #define virtual_copy(src, dst, bytes) \ 182 virtual_copy_f(NULL, src, dst, bytes, 0) 183 #define virtual_copy_vmcheck(caller, src, dst, bytes) \ 184 virtual_copy_f(caller, src, dst, bytes, 1) 185 int virtual_copy_f(struct proc * caller, struct vir_addr *src, struct 186 vir_addr *dst, vir_bytes bytes, int vmcheck); 187 int data_copy(endpoint_t from, vir_bytes from_addr, endpoint_t to, 188 vir_bytes to_addr, size_t bytes); 189 int data_copy_vmcheck(struct proc *, endpoint_t from, vir_bytes 190 from_addr, endpoint_t to, vir_bytes to_addr, size_t bytes); 191 phys_bytes umap_virtual(struct proc* rp, int seg, vir_bytes vir_addr, 192 vir_bytes bytes); 193 phys_bytes seg2phys(u16_t); 194 int vm_memset(struct proc *caller, endpoint_t who, phys_bytes dst, 195 int pattern, phys_bytes count); 196 int intr_init(int); 197 void halt_cpu(void); 198 void arch_init(void); 199 void arch_boot_proc(struct boot_image *b, struct proc *p); 200 void cpu_identify(void); 201 /* arch dependent FPU initialization per CPU */ 202 void fpu_init(void); 203 /* returns true if pfu is present and initialized */ 204 int is_fpu(void); 205 void ser_putc(char); 206 __dead void arch_shutdown(int); 207 void restore_user_context(struct proc * p); 208 void read_tsc(u32_t *high, u32_t *low); 209 int arch_init_profile_clock(u32_t freq); 210 void arch_stop_profile_clock(void); 211 void arch_ack_profile_clock(void); 212 void do_ser_debug(void); 213 int arch_get_params(char *parm, int max); 214 void memory_init(void); 215 void mem_clear_mapcache(void); 216 void arch_proc_init(struct proc *pr, u32_t, u32_t, u32_t, char *); 217 int arch_do_vmctl(message *m_ptr, struct proc *p); 218 int vm_contiguous(const struct proc *targetproc, vir_bytes vir_buf, 219 size_t count); 220 void proc_stacktrace(struct proc *proc); 221 int vm_lookup(const struct proc *proc, vir_bytes virtual, phys_bytes 222 *result, u32_t *ptent); 223 size_t vm_lookup_range(const struct proc *proc, 224 vir_bytes vir_addr, phys_bytes *phys_addr, size_t bytes); 225 void arch_do_syscall(struct proc *proc); 226 int arch_phys_map(int index, phys_bytes *addr, phys_bytes *len, int 227 *flags); 228 int arch_phys_map_reply(int index, vir_bytes addr); 229 reg_t arch_get_sp(struct proc *p); 230 int arch_enable_paging(struct proc * caller); 231 int vm_check_range(struct proc *caller, 232 struct proc *target, vir_bytes vir_addr, size_t bytes, int writable); 233 234 int copy_msg_from_user(message * user_mbuf, message * dst); 235 int copy_msg_to_user(message * src, message * user_mbuf); 236 void switch_address_space(struct proc * p); 237 void release_address_space(struct proc *pr); 238 239 void enable_fpu_exception(void); 240 void disable_fpu_exception(void); 241 void release_fpu(struct proc * p); 242 void arch_pause(void); 243 short cpu_load(void); 244 void busy_delay_ms(int ms); 245 246 /* utility.c */ 247 void cpu_print_freq(unsigned cpu); 248 #endif /* __kernel__ */ 249 250 #endif /* PROTO_H */ 251