coverity appeasement
[minix.git] / kernel / arch / i386 / include / arch_proto.h
blob3693ac46043482aae09b47b7a24b0174528c6707
2 #ifndef _I386_PROTO_H
3 #define _I386_PROTO_H
5 #include <machine/vm.h>
7 #define K_STACK_SIZE I386_PAGE_SIZE
9 #ifndef __ASSEMBLY__
11 /* Hardware interrupt handlers. */
12 void hwint00(void);
13 void hwint01(void);
14 void hwint02(void);
15 void hwint03(void);
16 void hwint04(void);
17 void hwint05(void);
18 void hwint06(void);
19 void hwint07(void);
20 void hwint08(void);
21 void hwint09(void);
22 void hwint10(void);
23 void hwint11(void);
24 void hwint12(void);
25 void hwint13(void);
26 void hwint14(void);
27 void hwint15(void);
29 /* Exception handlers (real or protected mode), in numerical order. */
30 void int00(void), divide_error (void);
31 void int01(void), single_step_exception (void);
32 void int02(void), nmi (void);
33 void int03(void), breakpoint_exception (void);
34 void int04(void), overflow (void);
35 void int05(void), bounds_check (void);
36 void int06(void), inval_opcode (void);
37 void int07(void), copr_not_available (void);
38 void double_fault(void);
39 void copr_seg_overrun(void);
40 void inval_tss(void);
41 void segment_not_present(void);
42 void stack_exception(void);
43 void general_protection(void);
44 void page_fault(void);
45 void copr_error(void);
46 void alignment_check(void);
47 void machine_check(void);
48 void simd_exception(void);
50 /* Software interrupt handlers, in numerical order. */
51 void trp(void);
52 void ipc_entry(void);
53 void kernel_call_entry(void);
54 void level0_call(void);
56 /* exception.c */
57 struct exception_frame {
58 reg_t vector; /* which interrupt vector was triggered */
59 reg_t errcode; /* zero if no exception does not push err code */
60 reg_t eip;
61 reg_t cs;
62 reg_t eflags;
63 reg_t esp; /* undefined if trap is nested */
64 reg_t ss; /* undefined if trap is nested */
67 void exception(struct exception_frame * frame);
69 /* klib386.s */
70 __dead void monitor(void);
71 __dead void reset(void);
72 __dead void x86_triplefault(void);
73 reg_t read_cr0(void);
74 reg_t read_cr2(void);
75 void write_cr0(unsigned long value);
76 unsigned long read_cr4(void);
77 void write_cr4(unsigned long value);
78 void write_cr3(unsigned long value);
79 unsigned long read_cpu_flags(void);
80 phys_bytes vir2phys(void *);
81 void phys_insb(u16_t port, phys_bytes buf, size_t count);
82 void phys_insw(u16_t port, phys_bytes buf, size_t count);
83 void phys_outsb(u16_t port, phys_bytes buf, size_t count);
84 void phys_outsw(u16_t port, phys_bytes buf, size_t count);
85 u32_t read_cr3(void);
86 void reload_cr3(void);
87 void i386_invlpg(phys_bytes linaddr);
88 vir_bytes phys_memset(phys_bytes ph, u32_t c, phys_bytes bytes);
89 void reload_ds(void);
90 void ia32_msr_read(u32_t reg, u32_t * hi, u32_t * lo);
91 void ia32_msr_write(u32_t reg, u32_t hi, u32_t lo);
92 void fninit(void);
93 void clts(void);
94 void fxsave(void *);
95 void fnsave(void *);
96 int fxrstor(void *);
97 int __fxrstor_end(void *);
98 int frstor(void *);
99 int __frstor_end(void *);
100 int __frstor_failure(void *);
101 unsigned short fnstsw(void);
102 void fnstcw(unsigned short* cw);
103 void x86_lgdt(void *);
104 void x86_lldt(u32_t);
105 void x86_ltr(u32_t);
106 void x86_lidt(void *);
107 void x86_load_kerncs(void);
108 void x86_load_ds(u32_t);
109 void x86_load_ss(u32_t);
110 void x86_load_es(u32_t);
111 void x86_load_fs(u32_t);
112 void x86_load_gs(u32_t);
115 void switch_k_stack(void * esp, void (* continuation)(void));
117 void __switch_address_space(struct proc * p, struct proc ** __ptproc);
118 #define switch_address_space(proc) \
119 __switch_address_space(proc, get_cpulocal_var_ptr(ptproc))
121 void refresh_tlb(void);
123 /* multiboot.c */
124 void multiboot_init(void);
126 /* protect.c */
127 struct tss_s {
128 reg_t backlink;
129 reg_t sp0; /* stack pointer to use during interrupt */
130 reg_t ss0; /* " segment " " " " */
131 reg_t sp1;
132 reg_t ss1;
133 reg_t sp2;
134 reg_t ss2;
135 reg_t cr3;
136 reg_t ip;
137 reg_t flags;
138 reg_t ax;
139 reg_t cx;
140 reg_t dx;
141 reg_t bx;
142 reg_t sp;
143 reg_t bp;
144 reg_t si;
145 reg_t di;
146 reg_t es;
147 reg_t cs;
148 reg_t ss;
149 reg_t ds;
150 reg_t fs;
151 reg_t gs;
152 reg_t ldt;
153 u16_t trap;
154 u16_t iobase;
155 /* u8_t iomap[0]; */
156 } __attribute__((packed));
158 void enable_iop(struct proc *pp);
159 u32_t read_cs(void);
160 u32_t read_ds(void);
161 u32_t read_ss(void);
163 void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len);
164 phys_bytes alloc_lowest(kinfo_t *cbi, phys_bytes len);
165 void vm_enable_paging(void);
166 void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end);
167 phys_bytes pg_roundup(phys_bytes b);
168 void pg_info(reg_t *, u32_t **);
169 void pg_clear(void);
170 void pg_identity(kinfo_t *);
171 phys_bytes pg_load(void);
172 void pg_map(phys_bytes phys, vir_bytes vaddr, vir_bytes vaddr_end, kinfo_t *cbi);
173 int pg_mapkernel(void);
174 void pg_mapproc(struct proc *p, struct boot_image *ip, kinfo_t *cbi);
176 /* prototype of an interrupt vector table entry */
177 struct gate_table_s {
178 void(*gate) (void);
179 unsigned char vec_nr;
180 unsigned char privilege;
183 /* copies an array of vectors to the IDT. The last vector must be zero filled */
184 void idt_copy_vectors(struct gate_table_s * first);
185 void idt_copy_vectors_pic(void);
186 void idt_reload(void);
188 EXTERN void * k_stacks_start;
189 extern void * k_stacks;
191 #define get_k_stack_top(cpu) ((void *)(((char*)(k_stacks)) \
192 + 2 * ((cpu) + 1) * K_STACK_SIZE))
194 void mfence(void);
195 #define barrier() do { mfence(); } while(0)
198 #ifndef __GNUC__
199 /* call a function to read the stack fram pointer (%ebp) */
200 reg_t read_ebp(void);
201 #define get_stack_frame(__X) ((reg_t)read_ebp())
202 #else
203 /* read %ebp directly */
204 #define get_stack_frame(__X) ((reg_t)__builtin_frame_address(0))
205 #endif
208 * sets up TSS for a cpu and assigns kernel stack and cpu id
210 int tss_init(unsigned cpu, void * kernel_stack);
212 void int_gate_idt(unsigned vec_nr, vir_bytes offset, unsigned dpl_type);
214 void __copy_msg_from_user_end(void);
215 void __copy_msg_to_user_end(void);
216 void __user_copy_msg_pointer_failure(void);
218 int platform_tbl_checksum_ok(void *ptr, unsigned int length);
219 int platform_tbl_ptr(phys_bytes start, phys_bytes end, unsigned
220 increment, void * buff, unsigned size, phys_bytes * phys_addr, int ((*
221 cmp_f)(void *)));
223 /* breakpoints.c */
224 int breakpoint_set(phys_bytes linaddr, int bp, const int flags);
225 #define BREAKPOINT_COUNT 4
226 #define BREAKPOINT_FLAG_RW_MASK (3 << 0)
227 #define BREAKPOINT_FLAG_RW_EXEC (0 << 0)
228 #define BREAKPOINT_FLAG_RW_WRITE (1 << 0)
229 #define BREAKPOINT_FLAG_RW_RW (2 << 0)
230 #define BREAKPOINT_FLAG_LEN_MASK (3 << 2)
231 #define BREAKPOINT_FLAG_LEN_1 (0 << 2)
232 #define BREAKPOINT_FLAG_LEN_2 (1 << 2)
233 #define BREAKPOINT_FLAG_LEN_4 (2 << 2)
234 #define BREAKPOINT_FLAG_MODE_MASK (3 << 4)
235 #define BREAKPOINT_FLAG_MODE_OFF (0 << 4)
236 #define BREAKPOINT_FLAG_MODE_LOCAL (1 << 4)
237 #define BREAKPOINT_FLAG_MODE_GLOBAL (2 << 4)
239 /* functions defined in architecture-independent kernel source. */
240 #include "kernel/proto.h"
242 #endif /* __ASSEMBLY__ */
244 #endif