示例#1
0
void install_keyboard_handler() 
{
    struct x86_gate *idt = (struct x86_gate *) sidt();
    
    fill_gate(idt[KEY_IDT_ENTRY].filler, (unsigned int) asm_keyboard_wrapper, KERNEL_CS_SEGSEL, ACC_TRAP_GATE);
    init_kb_buffer();
}
示例#2
0
void install_timer_handler() 
{
    struct x86_gate *idt = (struct x86_gate *) sidt();

    fill_gate(idt[TIMER_IDT_ENTRY].filler, (unsigned int) asm_timer_wrapper, KERNEL_CS_SEGSEL, ACC_TRAP_GATE); 

    outb(TIMER_MODE_IO_PORT, TIMER_SQUARE_WAVE);
    outb(TIMER_PERIOD_IO_PORT, ((TIMER_RATE / 100) & 0xff));
    iodelay(); 
    outb(TIMER_PERIOD_IO_PORT, (((TIMER_RATE / 100) >> 8) & 0xff));
}
示例#3
0
/*
 * Init the VM code. 
 */
void
oskit_uvm_redzone_init(void)
{
	oskit_addr_t	addr;

	/*
	 * We use a task gate to catch page faults, since a stack overflow
	 * will try and dump more stuff on the stack. This is the easiest
	 * way to deal with it.
	 */
	if ((addr = (oskit_addr_t)
	            lmm_alloc_aligned(&malloc_lmm, STACKSIZE, 0, 12, 0)) == 0)
		panic(__FUNCTION__": Could not allocate stack\n");

	task_tss.ss0   = KERNEL_DS;
	task_tss.esp0  = addr + STACKSIZE - sizeof(double);
	task_tss.esp   = task_tss.esp0;
	task_tss.ss    = KERNEL_DS;
	task_tss.ds    = KERNEL_DS;
	task_tss.es    = KERNEL_DS;
	task_tss.fs    = KERNEL_DS;
	task_tss.gs    = KERNEL_DS;
	task_tss.cs    = KERNEL_CS;
	task_tss.io_bit_map_offset = sizeof(task_tss);
	task_tss.eip    = (int) double_fault_handler;

	/* Make sure the task is started with interrupts disabled */
	osenv_intr_disable();
	task_tss.eflags = (int) get_eflags();
	osenv_intr_enable();
	
	/* Both TSSs has to know about the page tables */
	task_tss.cr3    = get_cr3();
	base_tss.cr3	= get_cr3();

	/* Initialize the base TSS descriptor.  */
	fill_descriptor(&base_gdt[KERNEL_TRAP_TSS / 8],
			kvtolin(&task_tss), sizeof(task_tss) - 1,
			ACC_PL_K|ACC_TSS|ACC_P, 0);

	/*
	 * NOTE: The task switch will include an extra word on the stack,
	 * pushed by the CPU. The handler will need to be in assembly code
	 * if we care about that value. As it is, the handler routine
	 * stack is going to be slightly messed up, but since the handler
	 * calls panic, it is not a problem right now. 
	 */
	fill_gate(&base_idt[T_DOUBLE_FAULT],
		  0, KERNEL_TRAP_TSS, ACC_TASK_GATE|ACC_P|ACC_PL_K, 0);

	base_idt_load();
	base_gdt_load();
}
示例#4
0
文件: main.c 项目: OnelungBL/CSC-159
void SetIDTEntry(int entry_num, func_ptr_t entry_addr){
    struct i386_gate *gateptr = &idt_table[entry_num];
    fill_gate(gateptr, (int)entry_addr, get_cs(), ACC_INTR_GATE,0);
}
示例#5
0
文件: main.c 项目: suond/csc159
void SetEntry(int entry_num, func_ptr_t func_ptr) {
	struct i386_gate *gateptr = &IDT_ptr[entry_num];
	fill_gate(gateptr, (int) func_ptr, get_cs(), ACC_INTR_GATE,0);

}