Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
|
|
|
|
#ifndef _I386_PROTO_H
|
|
|
|
#define _I386_PROTO_H
|
|
|
|
|
2010-09-15 16:09:52 +02:00
|
|
|
#include <machine/vm.h>
|
|
|
|
|
|
|
|
#define K_STACK_SIZE I386_PAGE_SIZE
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
/* Hardware interrupt handlers. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void hwint00(void);
|
|
|
|
void hwint01(void);
|
|
|
|
void hwint02(void);
|
|
|
|
void hwint03(void);
|
|
|
|
void hwint04(void);
|
|
|
|
void hwint05(void);
|
|
|
|
void hwint06(void);
|
|
|
|
void hwint07(void);
|
|
|
|
void hwint08(void);
|
|
|
|
void hwint09(void);
|
|
|
|
void hwint10(void);
|
|
|
|
void hwint11(void);
|
|
|
|
void hwint12(void);
|
|
|
|
void hwint13(void);
|
|
|
|
void hwint14(void);
|
|
|
|
void hwint15(void);
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
|
|
|
|
/* Exception handlers (real or protected mode), in numerical order. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void int00(void), divide_error (void);
|
|
|
|
void int01(void), single_step_exception (void);
|
|
|
|
void int02(void), nmi (void);
|
|
|
|
void int03(void), breakpoint_exception (void);
|
|
|
|
void int04(void), overflow (void);
|
|
|
|
void int05(void), bounds_check (void);
|
|
|
|
void int06(void), inval_opcode (void);
|
|
|
|
void int07(void), copr_not_available (void);
|
|
|
|
void double_fault(void);
|
|
|
|
void copr_seg_overrun(void);
|
|
|
|
void inval_tss(void);
|
|
|
|
void segment_not_present(void);
|
|
|
|
void stack_exception(void);
|
|
|
|
void general_protection(void);
|
|
|
|
void page_fault(void);
|
|
|
|
void copr_error(void);
|
|
|
|
void alignment_check(void);
|
|
|
|
void machine_check(void);
|
|
|
|
void simd_exception(void);
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
|
|
|
|
/* Software interrupt handlers, in numerical order. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void trp(void);
|
|
|
|
void ipc_entry(void);
|
|
|
|
void kernel_call_entry(void);
|
|
|
|
void level0_call(void);
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
/* memory.c */
|
2012-03-24 16:16:34 +01:00
|
|
|
void segmentation2paging(struct proc * current);
|
|
|
|
void i386_freepde(int pde);
|
|
|
|
void getcr3val(void);
|
2008-11-19 13:26:10 +01:00
|
|
|
|
|
|
|
|
2007-04-23 15:19:25 +02:00
|
|
|
/* exception.c */
|
2009-11-06 10:08:26 +01:00
|
|
|
struct exception_frame {
|
|
|
|
reg_t vector; /* which interrupt vector was triggered */
|
|
|
|
reg_t errcode; /* zero if no exception does not push err code */
|
|
|
|
reg_t eip;
|
|
|
|
reg_t cs;
|
|
|
|
reg_t eflags;
|
|
|
|
reg_t esp; /* undefined if trap is nested */
|
|
|
|
reg_t ss; /* undefined if trap is nested */
|
|
|
|
};
|
|
|
|
|
2012-03-24 16:16:34 +01:00
|
|
|
void exception(struct exception_frame * frame);
|
2007-04-23 15:19:25 +02:00
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
/* klib386.s */
|
2012-03-24 16:16:34 +01:00
|
|
|
__dead void monitor(void);
|
|
|
|
__dead void reset(void);
|
|
|
|
__dead void x86_triplefault(void);
|
|
|
|
reg_t read_cr0(void);
|
|
|
|
reg_t read_cr2(void);
|
|
|
|
void write_cr0(unsigned long value);
|
|
|
|
unsigned long read_cr4(void);
|
|
|
|
void write_cr4(unsigned long value);
|
|
|
|
void write_cr3(unsigned long value);
|
|
|
|
unsigned long read_cpu_flags(void);
|
|
|
|
void phys_insb(u16_t port, phys_bytes buf, size_t count);
|
|
|
|
void phys_insw(u16_t port, phys_bytes buf, size_t count);
|
|
|
|
void phys_outsb(u16_t port, phys_bytes buf, size_t count);
|
|
|
|
void phys_outsw(u16_t port, phys_bytes buf, size_t count);
|
|
|
|
u32_t read_cr3(void);
|
|
|
|
void reload_cr3(void);
|
|
|
|
void i386_invlpg(phys_bytes linaddr);
|
2012-06-06 19:05:28 +02:00
|
|
|
vir_bytes phys_memset(phys_bytes ph, u32_t c, phys_bytes bytes);
|
2012-03-24 16:16:34 +01:00
|
|
|
void reload_ds(void);
|
|
|
|
void ia32_msr_read(u32_t reg, u32_t * hi, u32_t * lo);
|
|
|
|
void ia32_msr_write(u32_t reg, u32_t hi, u32_t lo);
|
|
|
|
void fninit(void);
|
|
|
|
void clts(void);
|
|
|
|
void fxsave(void *);
|
|
|
|
void fnsave(void *);
|
|
|
|
int fxrstor(void *);
|
|
|
|
int __fxrstor_end(void *);
|
|
|
|
int frstor(void *);
|
|
|
|
int __frstor_end(void *);
|
|
|
|
int __frstor_failure(void *);
|
|
|
|
unsigned short fnstsw(void);
|
|
|
|
void fnstcw(unsigned short* cw);
|
|
|
|
|
|
|
|
void switch_k_stack(void * esp, void (* continuation)(void));
|
|
|
|
|
|
|
|
void __switch_address_space(struct proc * p, struct proc ** __ptproc);
|
2010-09-15 16:09:46 +02:00
|
|
|
#define switch_address_space(proc) \
|
|
|
|
__switch_address_space(proc, get_cpulocal_var_ptr(ptproc))
|
|
|
|
|
2012-03-24 16:16:34 +01:00
|
|
|
void refresh_tlb(void);
|
2010-09-15 16:11:17 +02:00
|
|
|
|
2011-05-04 18:51:43 +02:00
|
|
|
/* multiboot.c */
|
2012-03-24 16:16:34 +01:00
|
|
|
void multiboot_init(void);
|
2011-05-04 18:51:43 +02:00
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
/* protect.c */
|
2009-11-06 10:08:26 +01:00
|
|
|
struct tss_s {
|
|
|
|
reg_t backlink;
|
|
|
|
reg_t sp0; /* stack pointer to use during interrupt */
|
|
|
|
reg_t ss0; /* " segment " " " " */
|
|
|
|
reg_t sp1;
|
|
|
|
reg_t ss1;
|
|
|
|
reg_t sp2;
|
|
|
|
reg_t ss2;
|
|
|
|
reg_t cr3;
|
|
|
|
reg_t ip;
|
|
|
|
reg_t flags;
|
|
|
|
reg_t ax;
|
|
|
|
reg_t cx;
|
|
|
|
reg_t dx;
|
|
|
|
reg_t bx;
|
|
|
|
reg_t sp;
|
|
|
|
reg_t bp;
|
|
|
|
reg_t si;
|
|
|
|
reg_t di;
|
|
|
|
reg_t es;
|
|
|
|
reg_t cs;
|
|
|
|
reg_t ss;
|
|
|
|
reg_t ds;
|
|
|
|
reg_t fs;
|
|
|
|
reg_t gs;
|
|
|
|
reg_t ldt;
|
|
|
|
u16_t trap;
|
|
|
|
u16_t iobase;
|
|
|
|
/* u8_t iomap[0]; */
|
|
|
|
};
|
|
|
|
|
2012-03-24 16:16:34 +01:00
|
|
|
void prot_init(void);
|
|
|
|
void idt_init(void);
|
|
|
|
void init_dataseg(struct segdesc_s *segdp, phys_bytes base, vir_bytes
|
|
|
|
size, int privilege);
|
|
|
|
void enable_iop(struct proc *pp);
|
|
|
|
int prot_set_kern_seg_limit(vir_bytes limit);
|
|
|
|
void printseg(char *banner, int iscs, struct proc *pr, u32_t selector);
|
|
|
|
u32_t read_cs(void);
|
|
|
|
u32_t read_ds(void);
|
|
|
|
u32_t read_ss(void);
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
|
2009-08-28 17:55:30 +02:00
|
|
|
/* prototype of an interrupt vector table entry */
|
|
|
|
struct gate_table_s {
|
2012-03-24 16:16:34 +01:00
|
|
|
void(*gate) (void);
|
2009-08-28 17:55:30 +02:00
|
|
|
unsigned char vec_nr;
|
|
|
|
unsigned char privilege;
|
|
|
|
};
|
|
|
|
|
2010-09-15 16:09:52 +02:00
|
|
|
extern struct gate_table_s gate_table_pic[];
|
2009-08-28 17:55:30 +02:00
|
|
|
|
|
|
|
/* copies an array of vectors to the IDT. The last vector must be zero filled */
|
2012-03-24 16:16:34 +01:00
|
|
|
void idt_copy_vectors(struct gate_table_s * first);
|
|
|
|
void idt_reload(void);
|
2009-08-28 17:55:30 +02:00
|
|
|
|
2009-11-06 10:08:26 +01:00
|
|
|
EXTERN void * k_boot_stktop;
|
2010-09-15 16:09:52 +02:00
|
|
|
EXTERN void * k_stacks_start;
|
|
|
|
extern void * k_stacks;
|
|
|
|
|
|
|
|
#define get_k_stack_top(cpu) ((void *)(((char*)(k_stacks)) \
|
|
|
|
+ 2 * ((cpu) + 1) * K_STACK_SIZE))
|
|
|
|
|
2012-03-24 16:16:34 +01:00
|
|
|
void mfence(void);
|
2010-09-15 16:10:12 +02:00
|
|
|
#define barrier() do { mfence(); } while(0)
|
|
|
|
|
|
|
|
|
2010-09-15 16:09:52 +02:00
|
|
|
#ifndef __GNUC__
|
|
|
|
/* call a function to read the stack fram pointer (%ebp) */
|
2012-03-24 16:16:34 +01:00
|
|
|
reg_t read_ebp(void);
|
2010-09-15 16:09:52 +02:00
|
|
|
#define get_stack_frame(__X) ((reg_t)read_ebp())
|
|
|
|
#else
|
|
|
|
/* read %ebp directly */
|
|
|
|
#define get_stack_frame(__X) ((reg_t)__builtin_frame_address(0))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sets up TSS for a cpu and assigns kernel stack and cpu id
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
void tss_init(unsigned cpu, void * kernel_stack);
|
|
|
|
|
|
|
|
void int_gate(unsigned vec_nr, vir_bytes offset, unsigned dpl_type);
|
|
|
|
|
|
|
|
void __copy_msg_from_user_end(void);
|
|
|
|
void __copy_msg_to_user_end(void);
|
|
|
|
void __user_copy_msg_pointer_failure(void);
|
|
|
|
|
|
|
|
int platform_tbl_checksum_ok(void *ptr, unsigned int length);
|
|
|
|
int platform_tbl_ptr(phys_bytes start, phys_bytes end, unsigned
|
|
|
|
increment, void * buff, unsigned size, phys_bytes * phys_addr, int ((*
|
|
|
|
cmp_f)(void *)));
|
2010-09-02 17:43:51 +02:00
|
|
|
|
this patch adds access to the debug breakpoints to
the kernel. They are not used atm, but having them in trunk allows them
to be easily used when needed. To set a breakpoint that triggers when
the variable foo is written to (the most common use case), one calls:
breakpoint_set(vir2phys((vir_bytes) &foo), 0,
BREAKPOINT_FLAG_MODE_GLOBAL |
BREAKPOINT_FLAG_RW_WRITE |
BREAKPOINT_FLAG_LEN_4);
It can later be disabled using:
breakpoint_set(vir2phys((vir_bytes) &foo), 0,
BREAKPOINT_FLAG_MODE_OFF);
There are some limitations:
- There are at most four breakpoints (hardware limit); the index of the
breakpoint (0-3) is specified as the second parameter of
breakpoint_set.
- The breakpoint exception in the kernel is not handled and causes a
panic; it would be reasonably easy to change this by inspecing DR6,
printing a message, disabling the breakpoint and continuing. However,
in my experience even just a panic can be very useful.
- Breakpoints can be set only in the part of the address space that is
in every page table. It is useful for the kernel, but to use this for
user processes would require saving and restoring the debug registers
as part of the context switch. Although the CPU provides support for
local breakpoints (I implemened this as BREAKPOINT_FLAG_LOCAL) they
only work if task switching is used.
2010-03-19 20:15:20 +01:00
|
|
|
/* breakpoints.c */
|
|
|
|
#define BREAKPOINT_COUNT 4
|
|
|
|
#define BREAKPOINT_FLAG_RW_MASK (3 << 0)
|
|
|
|
#define BREAKPOINT_FLAG_RW_EXEC (0 << 0)
|
|
|
|
#define BREAKPOINT_FLAG_RW_WRITE (1 << 0)
|
|
|
|
#define BREAKPOINT_FLAG_RW_RW (2 << 0)
|
|
|
|
#define BREAKPOINT_FLAG_LEN_MASK (3 << 2)
|
|
|
|
#define BREAKPOINT_FLAG_LEN_1 (0 << 2)
|
|
|
|
#define BREAKPOINT_FLAG_LEN_2 (1 << 2)
|
|
|
|
#define BREAKPOINT_FLAG_LEN_4 (2 << 2)
|
|
|
|
#define BREAKPOINT_FLAG_MODE_MASK (3 << 4)
|
|
|
|
#define BREAKPOINT_FLAG_MODE_OFF (0 << 4)
|
|
|
|
#define BREAKPOINT_FLAG_MODE_LOCAL (1 << 4)
|
|
|
|
#define BREAKPOINT_FLAG_MODE_GLOBAL (2 << 4)
|
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
/* functions defined in architecture-independent kernel source. */
|
2010-04-02 00:22:33 +02:00
|
|
|
#include "kernel/proto.h"
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
|
2010-09-15 16:09:52 +02:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
#endif
|