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