void mouse_init(void) /*Note that we are doing NO device initialization. We are assuming that this was done suitably when the system was booted and the standard mouse driver was installed. THis is very poor programming practice! CW */ { /* _go32_dpmi_lock_data(mousequeue,200); I'm not using these in this simple demo so they are commented out. CW _go32_dpmi_lock_data(&mousequeue,sizeof(mousequeue));*/ _go32_dpmi_lock_code(NewInt74,(unsigned long)(LOCKint74-NewInt74)); // This ensures that the handler is not placed into paged memory. _go32_dpmi_get_protected_mode_interrupt_vector(0x74,&old_handler); /* Reads the selector and offset of the old handler into a structure, so that it can be restored later. */ /*Obtains the far pointer for the mouse ISR */ new_mousehandler.pm_selector=_go32_my_cs(); /* Note that _go32_my_cs() returns the selector for the program's code.*/ new_mousehandler.pm_offset=(unsigned long)NewInt74; _go32_dpmi_allocate_iret_wrapper(&new_mousehandler); /* The wrapper saves the machine state using a series of PUSH instructions. */ _go32_dpmi_set_protected_mode_interrupt_vector(0x74,&new_mousehandler); /* Places the ISR far pointer into a protected mode interrupt table. */ }
static void kbd_init_common(void) { _go32_dpmi_get_protected_mode_interrupt_vector(9, &std_kbd_handler_seginfo); atexit(kbd_exit); _go32_dpmi_lock_code(my_kbd_interrupt_handler, (unsigned long)my_kbd_interrupt_handler_end - (unsigned long)my_kbd_interrupt_handler); _go32_dpmi_lock_code(queue_command, (unsigned long)queue_command_end - (unsigned long)queue_command); _go32_dpmi_lock_data(keyconvmaps, sizeof(keyconvmaps)); _go32_dpmi_lock_data(keyarr, sizeof(keyarr)); _go32_dpmi_lock_data(rev_keyarr, sizeof(rev_keyarr)); _go32_dpmi_lock_data(&modifiers, sizeof(modifiers)); _go32_dpmi_lock_data(&num_queued_commands, sizeof(num_queued_commands)); _go32_dpmi_lock_data(&command_queue, sizeof(command_queue)); num_queued_commands = 0; kbd_install(); }
/** * key_init * This function initiates the interrupt for the keyboard. This was given * as part of the VBETEST.C example. **/ void key_init(void){ //Finds location of old handler _go32_dpmi_lock_code(NewInt9, (unsigned long)(LOCKint9 - NewInt9)); _go32_dpmi_get_protected_mode_interrupt_vector(9, &old_handler); //Set new handler new_handler.pm_offset = (unsigned long)NewInt9; new_handler.pm_selector = _go32_my_cs(); //Set in protected mode _go32_dpmi_allocate_iret_wrapper(&new_handler); _go32_dpmi_set_protected_mode_interrupt_vector(9, &new_handler); }
int mouse_init(void(*isr)(void), _go32_dpmi_seginfo *prev_isr) { disable_irq(KBD_IRQ); disable_irq(MOUSE_IRQ); int sucesso = kbc_init(1); _go32_dpmi_lock_code(mouse_isr, (end_mouse_isr - mouse_isr)); _go32_dpmi_lock_data((void*) &b3, sizeof(b3)); set_isr(MOUSE_IRQ, mouse_isr, prev_isr); enable_irq(KBD_IRQ); enable_irq(MOUSE_IRQ); return sucesso; }
void keyboard_int_install() { // retrieve the current (old) keyboard handler _go32_dpmi_get_protected_mode_interrupt_vector(9, &OldHandler); // lock code and data from being paged _go32_dpmi_lock_code(myKeyInt, (long)myKeyInt_Size); _go32_dpmi_lock_data(&keyVal, (long)sizeof(keyVal)); // establish new seginfo struct NewHandler.pm_offset = (long)myKeyInt; NewHandler.pm_selector = _go32_my_cs(); // allocate the IRET wrapper _go32_dpmi_allocate_iret_wrapper(&NewHandler); // install the new keyboard ISR _go32_dpmi_set_protected_mode_interrupt_vector(9, &NewHandler); printf("new keyboard ISR installed\n"); }
void lock_queueFull() { _go32_dpmi_lock_code(lock_queueFull, (unsigned long)(lock_queueFull - queueFullPreHandler)); }
void lock_queuePut() { _go32_dpmi_lock_code(lock_queuePut, (unsigned long)(lock_queuePut - queuePutPreHandler)); }
void lock_putGQueue() { _go32_dpmi_lock_code(putGQueue, (unsigned long)(lock_putGQueue - putGQueuePreHandler)); }