fix from trunk for assert(ptproc == newptproc) without vm_stop on shutdown.
[minix.git] / kernel / proto.h
blob265d3a055570740215849439354b0ef9361ff3a4
1 /* Function prototypes. */
3 #ifndef PROTO_H
4 #define PROTO_H
6 #include <minix/safecopies.h>
7 #include <machine/archtypes.h>
8 #include <sys/sigcontext.h>
9 #include <a.out.h>
11 /* Struct declarations. */
12 struct proc;
13 struct timer;
15 /* clock.c */
16 _PROTOTYPE( clock_t get_uptime, (void) );
17 _PROTOTYPE( void set_timer, (struct timer *tp, clock_t t, tmr_func_t f) );
18 _PROTOTYPE( void reset_timer, (struct timer *tp) );
19 _PROTOTYPE( void ser_dump_proc, (void) );
21 _PROTOTYPE( void cycles_accounting_init, (void) );
23 * This functions start and stop accounting for process, kernel or idle cycles.
24 * It inherently have to account for some kernel cycles for process too,
25 * therefore it should be called asap after trapping to kernel and as late as
26 * possible before returning to userspace. These function is architecture
27 * dependent
29 _PROTOTYPE( void context_stop, (struct proc * p) );
30 /* this is a wrapper to make calling it from assembly easier */
31 _PROTOTYPE( void context_stop_idle, (void) );
32 _PROTOTYPE( void restore_fpu, (struct proc *) );
33 _PROTOTYPE( void save_fpu, (struct proc *) );
34 _PROTOTYPE( void fpu_sigcontext, (struct proc *, struct sigframe *fr, struct sigcontext *sc) );
36 /* main.c */
37 _PROTOTYPE( void main, (void) );
38 _PROTOTYPE( void prepare_shutdown, (int how) );
39 _PROTOTYPE( void minix_shutdown, (struct timer *tp) );
41 /* proc.c */
43 _PROTOTYPE( int do_ipc, (reg_t r1, reg_t r2, reg_t r3) );
44 _PROTOTYPE( int mini_notify, (const struct proc *src, endpoint_t dst) );
45 _PROTOTYPE( void enqueue, (struct proc *rp) );
46 _PROTOTYPE( void dequeue, (const struct proc *rp) );
47 _PROTOTYPE( void switch_to_user, (void) );
48 _PROTOTYPE( struct proc * arch_finish_switch_to_user, (void) );
49 _PROTOTYPE( struct proc *endpoint_lookup, (endpoint_t ep) );
50 #if DEBUG_ENABLE_IPC_WARNINGS
51 _PROTOTYPE( int isokendpt_f, (const char *file, int line, endpoint_t e, int *p, int f));
52 #define isokendpt_d(e, p, f) isokendpt_f(__FILE__, __LINE__, (e), (p), (f))
53 #else
54 _PROTOTYPE( int isokendpt_f, (endpoint_t e, int *p, int f) );
55 #define isokendpt_d(e, p, f) isokendpt_f((e), (p), (f))
56 #endif
57 _PROTOTYPE( void proc_no_time, (struct proc *p));
59 /* start.c */
60 _PROTOTYPE( void cstart, (u16_t cs, u16_t ds, u16_t mds,
61 u16_t parmoff, u16_t parmsize) );
62 _PROTOTYPE( char *env_get, (const char *key));
64 /* system.c */
65 _PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) );
66 _PROTOTYPE( void set_sendto_bit, (const struct proc *rc, int id) );
67 _PROTOTYPE( void unset_sendto_bit, (const struct proc *rc, int id) );
68 _PROTOTYPE( void send_sig, (endpoint_t proc_nr, int sig_nr) );
69 _PROTOTYPE( void cause_sig, (proc_nr_t proc_nr, int sig_nr) );
70 _PROTOTYPE( void sig_delay_done, (struct proc *rp) );
71 _PROTOTYPE( void kernel_call, (message *m_user, struct proc * caller) );
72 _PROTOTYPE( void system_init, (void) );
73 #define numap_local(proc_nr, vir_addr, bytes) \
74 umap_local(proc_addr(proc_nr), D, (vir_addr), (bytes))
75 _PROTOTYPE( phys_bytes umap_grant, (struct proc *, cp_grant_id_t, vir_bytes));
76 _PROTOTYPE( void clear_endpoint, (struct proc *rc) );
77 _PROTOTYPE( void clear_ipc_refs, (struct proc *rc, int caller_ret) );
78 _PROTOTYPE( phys_bytes umap_bios, (vir_bytes vir_addr, vir_bytes bytes));
79 _PROTOTYPE( void kernel_call_resume, (struct proc *p));
81 /* system/do_newmap.c */
82 _PROTOTYPE( int newmap, (struct proc * caller, struct proc *rp,
83 struct mem_map *map_ptr));
85 /* system/do_vtimer.c */
86 _PROTOTYPE( void vtimer_check, (struct proc *rp) );
88 /* interrupt.c */
89 _PROTOTYPE( void put_irq_handler, (irq_hook_t *hook, int irq,
90 irq_handler_t handler) );
91 _PROTOTYPE( void rm_irq_handler, (const irq_hook_t *hook) );
92 _PROTOTYPE( void enable_irq, (const irq_hook_t *hook) );
93 _PROTOTYPE( int disable_irq, (const irq_hook_t *hook) );
95 /* debug.c */
96 _PROTOTYPE( int runqueues_ok, (void) );
97 _PROTOTYPE( char *rtsflagstr, (int flags) );
98 _PROTOTYPE( char *miscflagstr, (int flags) );
99 _PROTOTYPE( char *schedulerstr, (struct proc *scheduler) );
100 /* prints process information */
101 _PROTOTYPE( void print_proc, (struct proc *pp));
102 /* prints the given process and recursively all processes it depends on */
103 _PROTOTYPE( void print_proc_recursive, (struct proc *pp));
105 /* system/do_safemap.c */
106 _PROTOTYPE( int map_invoke_vm, (struct proc * caller, int req_type,
107 endpoint_t end_d, int seg_d, vir_bytes off_d,
108 endpoint_t end_s, int seg_s, vir_bytes off_s,
109 size_t size, int flag));
111 /* system/do_safecopy.c */
112 _PROTOTYPE( int verify_grant, (endpoint_t, endpoint_t,
113 cp_grant_id_t, vir_bytes, int,
114 vir_bytes, vir_bytes *, endpoint_t *));
116 /* system/do_sysctl.c */
117 _PROTOTYPE( int do_sysctl, (struct proc * caller, message *m));
119 #if SPROFILE
120 /* profile.c */
121 _PROTOTYPE( void init_profile_clock, (u32_t) );
122 _PROTOTYPE( void stop_profile_clock, (void) );
123 #endif
125 /* functions defined in architecture-dependent files. */
126 _PROTOTYPE( void prot_init, (void) );
127 _PROTOTYPE( phys_bytes phys_copy, (phys_bytes source, phys_bytes dest,
128 phys_bytes count) );
129 _PROTOTYPE( void phys_copy_fault, (void));
130 _PROTOTYPE( void phys_copy_fault_in_kernel, (void));
131 #define virtual_copy(src, dst, bytes) \
132 virtual_copy_f(NULL, src, dst, bytes, 0)
133 #define virtual_copy_vmcheck(caller, src, dst, bytes) \
134 virtual_copy_f(caller, src, dst, bytes, 1)
135 _PROTOTYPE( int virtual_copy_f, (struct proc * caller,
136 struct vir_addr *src, struct vir_addr *dst,
137 vir_bytes bytes, int vmcheck) );
138 _PROTOTYPE( int data_copy, (endpoint_t from, vir_bytes from_addr,
139 endpoint_t to, vir_bytes to_addr, size_t bytes));
140 _PROTOTYPE( int data_copy_vmcheck, (struct proc *,
141 endpoint_t from, vir_bytes from_addr,
142 endpoint_t to, vir_bytes to_addr, size_t bytes));
143 _PROTOTYPE( void alloc_segments, (struct proc *rp) );
144 _PROTOTYPE( void vm_init, (struct proc *first) );
145 _PROTOTYPE( void vm_stop, (void) );
146 _PROTOTYPE( phys_bytes umap_local, (register struct proc *rp, int seg,
147 vir_bytes vir_addr, vir_bytes bytes));
148 _PROTOTYPE( phys_bytes umap_remote, (const struct proc* rp, int seg,
149 vir_bytes vir_addr, vir_bytes bytes) );
150 _PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp,
151 int seg, vir_bytes vir_addr, vir_bytes bytes) );
152 _PROTOTYPE( phys_bytes seg2phys, (u16_t) );
153 _PROTOTYPE( int vm_phys_memset, (phys_bytes source, u8_t pattern,
154 phys_bytes count) );
155 _PROTOTYPE( vir_bytes alloc_remote_segment, (u32_t *, segframe_t *,
156 int, phys_bytes, vir_bytes, int));
157 _PROTOTYPE( int intr_init, (int, int) );
158 _PROTOTYPE( void halt_cpu, (void) );
159 _PROTOTYPE( void arch_init, (void) );
160 _PROTOTYPE( void ser_putc, (char) );
161 _PROTOTYPE( void arch_shutdown, (int) );
162 _PROTOTYPE( void arch_monitor, (void) );
163 _PROTOTYPE( void arch_get_aout_headers, (int i, struct exec *h) );
164 _PROTOTYPE( void restore_user_context, (struct proc * p) );
165 _PROTOTYPE( void read_tsc, (unsigned long *high, unsigned long *low) );
166 _PROTOTYPE( int arch_init_profile_clock, (u32_t freq) );
167 _PROTOTYPE( void arch_stop_profile_clock, (void) );
168 _PROTOTYPE( void arch_ack_profile_clock, (void) );
169 _PROTOTYPE( void do_ser_debug, (void) );
170 _PROTOTYPE( int arch_get_params, (char *parm, int max));
171 _PROTOTYPE( int arch_set_params, (char *parm, int max));
172 _PROTOTYPE( void arch_pre_exec, (struct proc *pr, u32_t, u32_t));
173 _PROTOTYPE( int arch_umap, (const struct proc *pr, vir_bytes, vir_bytes,
174 int, phys_bytes *));
175 _PROTOTYPE( int arch_do_vmctl, (message *m_ptr, struct proc *p));
176 _PROTOTYPE( int vm_contiguous, (const struct proc *targetproc, vir_bytes vir_buf, size_t count));
177 _PROTOTYPE( void proc_stacktrace, (struct proc *proc) );
178 _PROTOTYPE( int vm_lookup, (const struct proc *proc, vir_bytes virtual, vir_bytes *result, u32_t *ptent));
179 _PROTOTYPE( int delivermsg, (struct proc *target));
180 _PROTOTYPE( void arch_do_syscall, (struct proc *proc) );
181 _PROTOTYPE( int arch_phys_map, (int index, phys_bytes *addr,
182 phys_bytes *len, int *flags));
183 _PROTOTYPE( int arch_phys_map_reply, (int index, vir_bytes addr));
184 _PROTOTYPE( int arch_enable_paging, (struct proc * caller, const message * m_ptr));
186 _PROTOTYPE( int copy_msg_from_user, (struct proc * p, message * user_mbuf,
187 message * dst));
188 _PROTOTYPE( int copy_msg_to_user, (struct proc * p, message * src,
189 message * user_mbuf));
190 _PROTOTYPE(void switch_address_space, (struct proc * p));
191 _PROTOTYPE(void release_address_space, (struct proc *pr));
193 /* utility.c */
194 _PROTOTYPE( void cpu_print_freq, (unsigned cpu));
195 #endif /* PROTO_H */