/* * This file is part of DZComm. * Version : 0.6 * Minor changes by Dim Zegebart (zager@post.comstar.ru) to run with Palantir */ /* ______ ___ ___ * /\ _ \ /\_ \ /\_ \ * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ * /\____/ * \_/__/ * By Shawn Hargreaves, * 1 Salisbury Road, * Market Drayton, * Shropshire, * England, TF9 1AJ. * * Hardware interrupt wrapper functions. Unlike the _go32_dpmi_* * functions, these can deal with reentrant interrupts. * * See readme.txt for copyright information. */ #ifndef DJGPP #error This file should only be used by the djgpp version of Allegro #endif #include #include #include #include #include "allegro.h" #include "internal.h" #include "asmdefs.inc" #define MAX_IRQS 16 #define STACK_SIZE 8*1024 /* 8k stack should be plenty */ static int irq_virgin = TRUE; _IRQ_HANDLER _irq_handler[MAX_IRQS]; unsigned char *_irq_stack[IRQ_STACKS]; extern void _irq_wrapper_0(), _irq_wrapper_1(), _irq_wrapper_2(), _irq_wrapper_3(), _irq_wrapper_4(), _irq_wrapper_5(), _irq_wrapper_6(), _irq_wrapper_7(), _irq_wrapper_8(), _irq_wrapper_9(), _irq_wrapper_10(), _irq_wrapper_11(), _irq_wrapper_12(), _irq_wrapper_13(), _irq_wrapper_14(), _irq_wrapper_15(), _irq_wrapper_0_end(); /* _install_irq: * Installs a hardware interrupt handler for the specified irq, allocating * an asm wrapper function which will save registers and handle the stack * switching. The C function should return zero to exit the interrupt with * an iret instruction, and non-zero to chain to the old handler. */ int _install_irq(int num, int (*handler)()) { int c; __dpmi_paddr addr; if (irq_virgin) { /* first time we've been called? */ LOCK_VARIABLE(_irq_handler); LOCK_VARIABLE(_irq_stack); LOCK_FUNCTION(_irq_wrapper_0); for (c=0; c