void reinstall_c_irq_handler(int irq, _go32_dpmi_seginfo *old_irq) { _go32_dpmi_seginfo new_irq; _go32_dpmi_get_protected_mode_interrupt_vector(IRQ_VECTOR(irq), &new_irq); // importante: reposição do handler original _go32_dpmi_set_protected_mode_interrupt_vector(IRQ_VECTOR(irq), old_irq); // liberta funcao assembly _go32_dpmi_free_iret_wrapper(&new_irq); }
void dump_irq_status (void) { int irq = 0; for ( irq = 0; irq < 16; irq++ ) { if ( irq_enabled ( irq ) ) { printf ( "IRQ%d enabled, ISR at %hx:%hx\n", irq, IRQ_VECTOR(irq)->segment, IRQ_VECTOR(irq)->offset ); } } }
int install_asm_irq_handler(int irq, void (*irq_func)(void), _go32_dpmi_seginfo *old_irq) { // endereço do handler original _go32_dpmi_get_protected_mode_interrupt_vector(IRQ_VECTOR(irq), old_irq); // instalação do handler na IDT _go32_dpmi_seginfo new_irq; new_irq.pm_selector = _go32_my_cs( ); // selector do código new_irq.pm_offset = (unsigned long) irq_func; // endereço do novo handler _go32_dpmi_set_protected_mode_interrupt_vector(IRQ_VECTOR(irq), &new_irq); return 0; }
int install_c_irq_handler(int irq, void (*irq_func)(void), _go32_dpmi_seginfo *old_irq) { // endereço do handler original _go32_dpmi_get_protected_mode_interrupt_vector(IRQ_VECTOR(irq), old_irq); // instalação do handler na IDT _go32_dpmi_seginfo new_irq; new_irq.pm_selector = _go32_my_cs( ); // selector do código new_irq.pm_offset = (unsigned long) irq_func; // endereço do novo handler // prepara funcao assembly para chamar funcao C _go32_dpmi_allocate_iret_wrapper(&new_irq); _go32_dpmi_set_protected_mode_interrupt_vector(IRQ_VECTOR(irq), &new_irq); return 0; }
void task1_main(void) { /* * This is the bootstrap task- start up the scheduler and load the * second task. Our scheduler is driven by the PIT timer IRQ at * 100 Hz. */ Timer_InitPIT(PIT_HZ / 100); Intr_SetMask(0, TRUE); Intr_SetHandler(IRQ_VECTOR(IRQ_TIMER), schedulerIRQ); /* * Create the second task. It can start running at any time now. */ task_init(&task2, task2_main); while (1) { Intr_Disable(); Console_WriteString("Task 1\n"); Console_Flush(); Intr_Enable(); } }
int remove_irq_handler ( irq_t irq, segoff_t *handler, uint8_t *previously_enabled, segoff_t *previous_handler ) { segoff_t *irq_vector = IRQ_VECTOR ( irq ); if ( irq > IRQ_MAX ) { DBG ( "Invalid IRQ number %d\n" ); return 0; } if ( ( irq_vector->segment != handler->segment ) || ( irq_vector->offset != handler->offset ) ) { DBG ( "Cannot remove handler for IRQ %d\n" ); return 0; } DBG ( "Removing handler for IRQ %d\n", irq ); disable_irq ( irq ); irq_vector->segment = previous_handler->segment; irq_vector->offset = previous_handler->offset; if ( *previously_enabled ) enable_irq ( irq ); return 1; }
int install_irq_handler ( irq_t irq, segoff_t *handler, uint8_t *previously_enabled, segoff_t *previous_handler ) { segoff_t *irq_vector = IRQ_VECTOR ( irq ); *previously_enabled = irq_enabled ( irq ); if ( irq > IRQ_MAX ) { DBG ( "Invalid IRQ number %d\n" ); return 0; } previous_handler->segment = irq_vector->segment; previous_handler->offset = irq_vector->offset; if ( *previously_enabled ) disable_irq ( irq ); DBG ( "Installing handler at %hx:%hx for IRQ %d, leaving %s\n", handler->segment, handler->offset, irq, ( *previously_enabled ? "enabled" : "disabled" ) ); DBG ( "...(previous handler at %hx:%hx)\n", previous_handler->segment, previous_handler->offset ); irq_vector->segment = handler->segment; irq_vector->offset = handler->offset; if ( *previously_enabled ) enable_irq ( irq ); return 1; }
void reinstall_asm_irq_handler(int irq, _go32_dpmi_seginfo *old_irq) { // importante: reposição do handler original _go32_dpmi_set_protected_mode_interrupt_vector(IRQ_VECTOR(irq), old_irq); }
int main(void) { uint32 frame = 0; uint32 lastTick = 0; Intr_Init(); Intr_SetFaultHandlers(SVGA_DefaultFaultHandler); Timer_InitPIT(PIT_HZ / FRAME_RATE); Intr_SetMask(PIT_IRQ, TRUE); Intr_SetHandler(IRQ_VECTOR(PIT_IRQ), timerISR); SVGA_Init(); GMR_Init(); Heap_Reset(); SVGA_SetMode(0, 0, 32); Screen_Init(); ScreenDraw_Init(GMRID_SCREEN_DRAW); allocNoise(); /* * Define a screen. */ SVGAScreenObject myScreen = { .structSize = sizeof(SVGAScreenObject), .id = SCREEN_ID, .flags = SVGA_SCREEN_HAS_ROOT | SVGA_SCREEN_IS_PRIMARY, .size = { 800, 600 }, .root = { 0, 0 }, }; Screen_Define(&myScreen); /* * Draw some explanatory text. */ char docString[] = "Annotated Blit Sample:" "\n\n" "You should see two moving rectangles. The left one is animated " "using a fill-annotated blit. The blit itself contains random " "noise, but the annotation is a blue fill. If your host is " "using the annotation, you will see the blue. If not, you'll " "see noise. Either one is correct, but it is often more efficient " "to use the fill." "\n\n" "The right one is a copy-annotated blit. The blit data is again " "random noise, and the copy is a screen-to-screen copy which " "moves the rectangle from its old position to the new position. " "We drew a checkerboard pattern to the screen once, and that " "pattern should be preserved indefinitely if the annotation is " "being executed correctly." "\n\n" "Both rectangles should have a 1-pixel solid white border, and " "in both cases we use a fill-annotated blit to clear the screen " "behind each rectangle. This annotation doesn't lie, its blit data " "matches the advertised fill color."; ScreenDraw_SetScreen(myScreen.id, myScreen.size.width, myScreen.size.height); Console_Clear(); ScreenDraw_WrapText(docString, 770); Console_WriteString(docString); /* * Animate the two rectangles indefinitely, sleeping between frames. */ while (1) { SVGASignedRect oldRect1, oldRect2; SVGASignedRect newRect1, newRect2; /* * Move them around in a circle. */ float theta = frame * 0.01; newRect1.left = 190 + cosf(theta) * 60; newRect1.top = 350 + sinf(theta) * 60; newRect1.right = newRect1.left + 80; newRect1.bottom = newRect1.top + 120; newRect2.left = 530 + sinf(theta) * 60; newRect2.top = 350 + cosf(theta) * 60; newRect2.right = newRect2.left + 80; newRect2.bottom = newRect2.top + 120; /* * Update the position of each. */ updateFillRect(frame ? &oldRect1 : NULL, &newRect1); updateCopyRect(frame ? &oldRect2 : NULL, &newRect2); oldRect1 = newRect1; oldRect2 = newRect2; /* * Wait for the next timer tick. */ while (timerTick == lastTick) { Intr_Halt(); } lastTick = timerTick; frame++; } return 0; }