2 * This file is part of DZComm.
4 * Minor changes by Dim Zegebart (zager@post.comstar.ru) to run with Palantir
9 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
10 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
11 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
12 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
13 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
16 * By Shawn Hargreaves,
22 * The hardware interrupt wrappers used by the stuff in irq.c.
24 * Thanks to Marcel de Kogel for identifying the problems Allegro was
25 * having with reentrant interrupts, and for suggesting this solution.
27 * See readme.txt for copyright information.
32 #error This file should only be used by the djgpp version of Allegro
35 #include "asmdefs.inc"
41 #define WRAPPER(x) ; \
42 .globl __irq_wrapper_##x ; \
44 __irq_wrapper_##x: ; \
45 pushw %ds /* save registers */ ; \
51 .byte 0x2e /* cs: override */ ; \
52 movw ___djgpp_ds_alias, %ax ; \
53 movw %ax, %ds /* set up selectors */ ; \
58 movl $IRQ_STACKS-1, %ecx /* look for a free stack */ ; \
60 stack_search_loop_##x: ; \
61 leal __irq_stack(, %ecx, 4), %ebx ; \
63 jnz found_stack_##x /* found one! */ ; \
66 jge stack_search_loop_##x ; \
68 jmp get_out_##x /* oh shit.. */ ; \
71 movl %esp, %ecx /* old stack in ecx + dx */ ; \
74 movl (%ebx), %esp /* set up our stack */ ; \
77 movl $0, (%ebx) /* flag the stack is in use */ ; \
79 pushl %edx /* push old stack onto new */ ; \
83 cld /* clear the direction flag */ ; \
85 movl __irq_handler + IRQ_HANDLER + IRQ_SIZE*x, %eax ; \
86 call *%eax /* call the C handler */ ; \
88 popl %ebx /* restore the old stack */ ; \
95 orl %eax, %eax /* check return value */ ; \
98 popal /* chain to old handler */ ; \
103 ljmp %cs:__irq_handler + IRQ_OLDVEC + IRQ_SIZE*x ; \
134 .globl __irq_wrapper_0_end