3.1.7 branch.
[minix.git] / kernel / arch / i386 / proto.h
blob3acb7c42c91fa50b4c06b02aa40729539cede17b
2 #ifndef _I386_PROTO_H
3 #define _I386_PROTO_H
5 /* Hardware interrupt handlers. */
6 _PROTOTYPE( void hwint00, (void) );
7 _PROTOTYPE( void hwint01, (void) );
8 _PROTOTYPE( void hwint02, (void) );
9 _PROTOTYPE( void hwint03, (void) );
10 _PROTOTYPE( void hwint04, (void) );
11 _PROTOTYPE( void hwint05, (void) );
12 _PROTOTYPE( void hwint06, (void) );
13 _PROTOTYPE( void hwint07, (void) );
14 _PROTOTYPE( void hwint08, (void) );
15 _PROTOTYPE( void hwint09, (void) );
16 _PROTOTYPE( void hwint10, (void) );
17 _PROTOTYPE( void hwint11, (void) );
18 _PROTOTYPE( void hwint12, (void) );
19 _PROTOTYPE( void hwint13, (void) );
20 _PROTOTYPE( void hwint14, (void) );
21 _PROTOTYPE( void hwint15, (void) );
23 /* Exception handlers (real or protected mode), in numerical order. */
24 void _PROTOTYPE( int00, (void) ), _PROTOTYPE( divide_error, (void) );
25 void _PROTOTYPE( int01, (void) ), _PROTOTYPE( single_step_exception, (void) );
26 void _PROTOTYPE( int02, (void) ), _PROTOTYPE( nmi, (void) );
27 void _PROTOTYPE( int03, (void) ), _PROTOTYPE( breakpoint_exception, (void) );
28 void _PROTOTYPE( int04, (void) ), _PROTOTYPE( overflow, (void) );
29 void _PROTOTYPE( int05, (void) ), _PROTOTYPE( bounds_check, (void) );
30 void _PROTOTYPE( int06, (void) ), _PROTOTYPE( inval_opcode, (void) );
31 void _PROTOTYPE( int07, (void) ), _PROTOTYPE( copr_not_available, (void) );
32 void _PROTOTYPE( double_fault, (void) );
33 void _PROTOTYPE( copr_seg_overrun, (void) );
34 void _PROTOTYPE( inval_tss, (void) );
35 void _PROTOTYPE( segment_not_present, (void) );
36 void _PROTOTYPE( stack_exception, (void) );
37 void _PROTOTYPE( general_protection, (void) );
38 void _PROTOTYPE( page_fault, (void) );
39 void _PROTOTYPE( copr_error, (void) );
40 void _PROTOTYPE( alignment_check, (void) );
41 void _PROTOTYPE( machine_check, (void) );
42 void _PROTOTYPE( simd_exception, (void) );
44 /* Software interrupt handlers, in numerical order. */
45 _PROTOTYPE( void trp, (void) );
46 _PROTOTYPE( void ipc_entry, (void) );
47 _PROTOTYPE( void kernel_call_entry, (void) );
48 _PROTOTYPE( void level0_call, (void) );
50 /* memory.c */
51 _PROTOTYPE( void i386_freepde, (int pde));
52 _PROTOTYPE( void getcr3val, (void));
55 /* exception.c */
56 struct exception_frame {
57 reg_t vector; /* which interrupt vector was triggered */
58 reg_t errcode; /* zero if no exception does not push err code */
59 reg_t eip;
60 reg_t cs;
61 reg_t eflags;
62 reg_t esp; /* undefined if trap is nested */
63 reg_t ss; /* undefined if trap is nested */
66 _PROTOTYPE( void exception, (struct exception_frame * frame));
68 /* klib386.s */
69 _PROTOTYPE( void monitor, (void) );
70 _PROTOTYPE( void reset, (void) );
71 _PROTOTYPE( void int86, (void) );
72 _PROTOTYPE( reg_t read_cr0, (void) );
73 _PROTOTYPE( reg_t read_cr2, (void) );
74 _PROTOTYPE( void write_cr0, (unsigned long value) );
75 _PROTOTYPE( unsigned long read_cr4, (void) );
76 _PROTOTYPE( void write_cr4, (unsigned long value) );
77 _PROTOTYPE( unsigned long read_cpu_flags, (void) );
78 _PROTOTYPE( void phys_insb, (u16_t port, phys_bytes buf, size_t count) );
79 _PROTOTYPE( void phys_insw, (u16_t port, phys_bytes buf, size_t count) );
80 _PROTOTYPE( void phys_outsb, (u16_t port, phys_bytes buf, size_t count) );
81 _PROTOTYPE( void phys_outsw, (u16_t port, phys_bytes buf, size_t count) );
82 _PROTOTYPE( u32_t read_cr3, (void) );
83 _PROTOTYPE( void reload_cr3, (void) );
84 _PROTOTYPE( void phys_memset, (phys_bytes ph, u32_t c, phys_bytes bytes));
85 _PROTOTYPE( void reload_ds, (void) );
86 _PROTOTYPE( void ia32_msr_read, (u32_t reg, u32_t * hi, u32_t * lo) );
87 _PROTOTYPE( void ia32_msr_write, (u32_t reg, u32_t hi, u32_t lo) );
88 _PROTOTYPE( void fninit, (void));
89 _PROTOTYPE( void clts, (void));
90 _PROTOTYPE( void fxsave, (void *));
91 _PROTOTYPE( void fnsave, (void *));
92 _PROTOTYPE( void fxrstor, (void *));
93 _PROTOTYPE( void frstor, (void *));
94 _PROTOTYPE( unsigned short fnstsw, (void));
95 _PROTOTYPE( void fnstcw, (unsigned short* cw));
97 /* protect.c */
98 struct tss_s {
99 reg_t backlink;
100 reg_t sp0; /* stack pointer to use during interrupt */
101 reg_t ss0; /* " segment " " " " */
102 reg_t sp1;
103 reg_t ss1;
104 reg_t sp2;
105 reg_t ss2;
106 reg_t cr3;
107 reg_t ip;
108 reg_t flags;
109 reg_t ax;
110 reg_t cx;
111 reg_t dx;
112 reg_t bx;
113 reg_t sp;
114 reg_t bp;
115 reg_t si;
116 reg_t di;
117 reg_t es;
118 reg_t cs;
119 reg_t ss;
120 reg_t ds;
121 reg_t fs;
122 reg_t gs;
123 reg_t ldt;
124 u16_t trap;
125 u16_t iobase;
126 /* u8_t iomap[0]; */
129 EXTERN struct tss_s tss;
131 _PROTOTYPE( void idt_init, (void) );
132 _PROTOTYPE( void init_dataseg, (struct segdesc_s *segdp, phys_bytes base,
133 vir_bytes size, int privilege) );
134 _PROTOTYPE( void enable_iop, (struct proc *pp) );
135 _PROTOTYPE( int prot_set_kern_seg_limit, (vir_bytes limit) );
136 _PROTOTYPE( void printseg, (char *banner, int iscs, struct proc *pr, u32_t selector) );
137 _PROTOTYPE( u32_t read_cs, (void));
138 _PROTOTYPE( u32_t read_ds, (void));
139 _PROTOTYPE( u32_t read_ss, (void));
141 /* prototype of an interrupt vector table entry */
142 struct gate_table_s {
143 _PROTOTYPE( void (*gate), (void) );
144 unsigned char vec_nr;
145 unsigned char privilege;
148 EXTERN struct gate_table_s gate_table_pic[];
150 /* copies an array of vectors to the IDT. The last vector must be zero filled */
151 _PROTOTYPE(void idt_copy_vectors, (struct gate_table_s * first));
152 _PROTOTYPE(void idt_reload,(void));
154 EXTERN void * k_boot_stktop;
156 _PROTOTYPE( void int_gate, (unsigned vec_nr, vir_bytes offset,
157 unsigned dpl_type) );
159 _PROTOTYPE(void __copy_msg_from_user_end, (void));
160 _PROTOTYPE(void __copy_msg_to_user_end, (void));
161 _PROTOTYPE(void __user_copy_msg_pointer_failure, (void));
163 /* breakpoints.c */
164 #define BREAKPOINT_COUNT 4
165 #define BREAKPOINT_FLAG_RW_MASK (3 << 0)
166 #define BREAKPOINT_FLAG_RW_EXEC (0 << 0)
167 #define BREAKPOINT_FLAG_RW_WRITE (1 << 0)
168 #define BREAKPOINT_FLAG_RW_RW (2 << 0)
169 #define BREAKPOINT_FLAG_LEN_MASK (3 << 2)
170 #define BREAKPOINT_FLAG_LEN_1 (0 << 2)
171 #define BREAKPOINT_FLAG_LEN_2 (1 << 2)
172 #define BREAKPOINT_FLAG_LEN_4 (2 << 2)
173 #define BREAKPOINT_FLAG_MODE_MASK (3 << 4)
174 #define BREAKPOINT_FLAG_MODE_OFF (0 << 4)
175 #define BREAKPOINT_FLAG_MODE_LOCAL (1 << 4)
176 #define BREAKPOINT_FLAG_MODE_GLOBAL (2 << 4)
178 /* functions defined in architecture-independent kernel source. */
179 #include "kernel/proto.h"
181 #endif