Mail Archives: djgpp/1999/05/05/00:24:38
Date: | Tue, 04 May 1999 23:19:06 -0500
|
From: | "Miguel A. Ordorica V." <ordorica AT df1 DOT telmex DOT net DOT mx>
|
Subject: | Help with interrupt wrapper, PLEASE (corrected)
|
To: | djgpp AT delorie DOT com
|
Message-id: | <003601be96ae$6b24c3c0$fc8426c8@df1.telmex.net.mx>
|
MIME-version: | 1.0
|
X-Mailer: | Microsoft Outlook Express 5.00.2014.211
|
X-MSMail-Priority: | Normal
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2014.211
|
X-Priority: | 3
|
Reply-To: | djgpp AT delorie DOT com
|
This is a multi-part message in MIME format.
--Boundary_(ID_4CFTEQZABfI8KWexlhzEpg)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: quoted-printable
/*Earlier today, I posted this same message but It somehow came out all =
messed up. I hope it's right this time, sorry.*/
=20
Below is the code for an interrupt wrapper I'm trying to get to =
work, along with it's setup code. It is a modified version of the =
interrupt wrapper code from Allegro. In theory, the wrapper allows for =
two different functions to be called: one with interrupts disabled and =
the other one with interrupts enabled. This is so that very long =
functions can be associated with an irq without having interrupts =
disabled long enough to mess up the program.
That's theory, though. The truth is, this thing is WAY too =
erratic. I tested it with a couple of simple functions that only set a =
flag when they were called. Although the functions were never actually =
called, the wrapper WAS!! That was one out of every five tries or so, =
the rest of the time the program simply died and locked my machine up, =
and it seems that the farthest EIP ever got was the ljump instruction =
below, so I can't tell if the code after that works at all.
Please, somebody help me! I don't know what is wrong and there =
simply aren't any experienced ASM programmers around here! I've checked =
it about a hundred times and cannot find anything wrong. Any help would =
be greatly appreciated.
Miguel Angel.
ordorica AT df1 DOT telmex DOT net DOT mx
sleeptk AT geocities DOT com
P.S. If you think this is not a good approach, please let me know of any =
other I could use.
.text
#define WRAPPER(x) ; \
.globl __wrapper_isr_inside_##x ; \
.align 4 ; \
__wrapper_isr_inside_##x: ; \
pushw %ds /* save registers */ ; \
pushw %es ; \
pushw %fs ; \
pushw %gs ; \
pushal ; \
; \
.byte 0x2e /* cs: override */ ; \
movw ___djgpp_ds_alias, %ax ; \
movw %ax, %ds /* set up selectors */ ; \
movw %ax, %es ; \
movw %ax, %fs ; \
movw %ax, %gs ; \
; \
movl $x, %esi ; \
movl __stacks(,%esi,4), %ebx ; \
; \
movl %esp, %ecx /* old stack in ecx + dx */; \
movw %ss, %dx ; \
; \
movl %ebx, %esp /* set up our stack */ ; \
movw %ax, %ss ; \
; \
pushl %edx /* push old stack onto new*/; \
pushl %ecx ; \
; \
cld * clear the direction flag */ ; \
; \
movl __addresses_isr_inside(,%esi,4), %eax ; \
call *%eax /* call the C handler */ ; \
; \
cli ; \
; \
popl %ecx /* restore the old stack */; \
popl %edx ; \
movw %dx, %ss ; \
movl %ecx, %esp ; \
; \
orl %eax, %eax /* check return value */ ; \
jz get_out_##x ; \
; \
popal /* chain to old handler */ ; \
popw %gs ; \
popw %fs ; \
popw %es ; \
popw %ds ; \
pushl __flags ; \
pushl __code_sel ; \
movl %esi, __temp ; \
movl $x, %esi ; \
pushl __addresses_isr_after(,%esi,4) ; \
movl __temp, %esi ; \
ljmp %cs:__addresses_old_isr+4*x ; \
; \
get_out_##x: ; \
popal /* iret */ ; \
popw %gs ; \
popw %fs ; \
popw %es ; \
popw %ds ; \
pushl __flags ; \
pushl __code_sel ; \
movl %esi, __temp ; \
movl $x, %esi ; \
pushl __addresses_isr_after(,%esi,4) ; \
movl __temp, %esi ; \
sti ; \
iret ; \
; \
.globl __wrapper_isr_after_##x ; \
.align 4 ; \
__wrapper_isr_after_##x: ; \
pushw %ds ; \
pushw %es ; \
pushw %fs ; \
pushw %gs ; \
pushal ; \
movl $x, %esi ; \
movl __addresses_isr_after(,%esi,4), %eax ; \
call *%eax ; \
cli ; \
popal ; \
popw %gs ; \
popw %fs ; \
popw %es ; \
popw %ds ; \
sti ; \
iret
WRAPPER(0);
WRAPPER(1);
WRAPPER(2);
WRAPPER(3);
WRAPPER(4);
WRAPPER(5);
WRAPPER(6);
WRAPPER(7);
.globl __wrapper_isr_inside_0_end
.align 4
__wrapper_isr_inside_0_end:
ret
Somewhere else...
extern void _wrapper_isr_inside_0(), _wrapper_isr_inside_1(), =
_wrapper_isr_inside_2(),
_wrapper_isr_inside_3(), _wrapper_isr_inside_4(), =
_wrapper_isr_inside_5(),
_wrapper_isr_inside_6(), _wrapper_isr_inside_7(),
_wrapper_isr_inside_0_end(),
_wrapper_isr_after_0(), _wrapper_isr_after_1(), =
_wrapper_isr_after_2(),
_wrapper_isr_after_3(), _wrapper_isr_after_4(), =
_wrapper_isr_after_5(),
_wrapper_isr_after_6(), _wrapper_isr_after_7();
dword _flags, _temp, _code_sel;
dword _addresses_isr_inside[NO_OF_WRAPPERS],
_addresses_isr_after[NO_OF_WRAPPERS],
_addresses_old_isr[NO_OF_WRAPPERS];
int _int_numbers[NO_OF_WRAPPERS];
__dpmi_paddr _old_handlers[NO_OF_WRAPPERS];
byte *_stacks[NO_OF_WRAPPERS];
int irq_handling_startup(void)
{
int counter;
for(counter=3D0; counter<NO_OF_WRAPPERS; counter++)
{
_addresses_isr_inside[counter]=3DNULL;
_addresses_isr_after[counter]=3DNULL;
_addresses_old_isr[counter]=3D=3DNULL;
_int_numbers[counter]=3D=3DNULL;
_stacks[counter]=3D((byte *)malloc(STACK_SIZE))+STACK_SIZE-32;
LOCK_ARRAY(_stacks[counter]-STACK_SIZE+32, STACK_SIZE, =
sizeof(byte));
}
_code_sel=3D_my_cs();
__asm__ volatile
(
"pushfl\n\t
popl %%eax\n\t
movl %%eax, __flags\n\t"
: :
: "eax", "memory"
);
LOCK_FUNCTION(_wrapper_isr_inside_0);
LOCK_ARRAY(_addresses_isr_inside, NO_OF_WRAPPERS, sizeof(dword));
LOCK_ARRAY(_addresses_isr_after, NO_OF_WRAPPERS, sizeof(dword));
LOCK_ARRAY(_addresses_old_isr, NO_OF_WRAPPERS, sizeof(dword));
LOCK_ARRAY(_int_numbers, NO_OF_WRAPPERS, sizeof(int));
LOCK_ARRAY(_old_handlers, NO_OF_WRAPPERS, sizeof(__dpmi_paddr));
LOCK_ARRAY(_stacks, NO_OF_WRAPPERS, sizeof(dword));
LOCK_VARIABLE(_temp);
LOCK_VARIABLE(_flags);
LOCK_VARIABLE(_code_sel);
return 0;
}
int take_over_irq(int number, int (*inside)(void), void (*after)(void))
{
int counter;
__dpmi_paddr address;
for(counter=3D0; counter<NO_OF_WRAPPERS; counter++)
{
if(_addresses_isr_inside[counter]=3D=3DNULL)
goto free1;
}
return -1;
free1:
_int_numbers[counter]=3Dnumber;
_old_handlers[counter].selector=3D_my_cs();
_addresses_isr_inside[counter]=3D(dword)inside;
_addresses_isr_after[counter]=3D(dword)after;
switch(counter)
{
default: return -1;
case 0: address.offset32=3D(dword)_wrapper_isr_inside_0; break;
case 1: address.offset32=3D(dword)_wrapper_isr_inside_1; break;
case 2: address.offset32=3D(dword)_wrapper_isr_inside_2; break;
case 3: address.offset32=3D(dword)_wrapper_isr_inside_3; break;
case 4: address.offset32=3D(dword)_wrapper_isr_inside_4; break;
case 5: address.offset32=3D(dword)_wrapper_isr_inside_5; break;
case 6: address.offset32=3D(dword)_wrapper_isr_inside_6; break;
case 7: address.offset32=3D(dword)_wrapper_isr_inside_7; break;
}
address.selector=3D_my_cs();
__dpmi_get_protected_mode_interrupt_vector(number, =
&(_old_handlers[counter]));
_addresses_old_isr[counter]=3D_old_handlers[counter].offset32;
if(__dpmi_set_protected_mode_interrupt_vector(number, &address))
return -1;
return 0;
}
=20
--Boundary_(ID_4CFTEQZABfI8KWexlhzEpg)
Content-type: text/html; charset=iso-8859-1
Content-transfer-encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2014.210" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>
<DIV><STRONG><FONT size=3D2>/*Earlier today, I posted this same message =
but It=20
somehow came out all messed up. I hope it's right this time,=20
sorry.*/</FONT></STRONG></DIV>
<DIV><FONT size=3D2></FONT><STRONG> </STRONG></DIV>
<DIV><FONT size=3D2> Below is =
the code=20
for an interrupt wrapper I'm trying to get to work, along with it's =
setup code.=20
It is a modified </FONT><FONT size=3D2>version of the interrupt =
</FONT><FONT=20
size=3D2>wrapper code from Allegro. In theory, the wrapper allows for =
two=20
different functions to be called: </FONT><FONT size=3D2>one with =
interrupts=20
</FONT><FONT size=3D2>disabled and the other one with interrupts =
enabled. This is=20
so that very long functions can be </FONT><FONT size=3D2>associated with =
</FONT><FONT size=3D2>an irq without having interrupts =
disabled long enough=20
to mess up the program.</FONT></DIV>
<DIV><FONT size=3D2> That's =
theory,=20
though. The truth is, this thing is WAY too erratic. I tested it with a =
couple=20
of simple functions </FONT><FONT size=3D2>that only set a flag when they =
were=20
called. Although the functions were never actually called, =
the wrapper=20
WAS!! </FONT><FONT size=3D2>That was one out of every five tries or so, =
the rest=20
of the time the program simply died and locked my machine </FONT><FONT=20
size=3D2>up, and it seems that the farthest E</FONT><FONT =
size=3D2>IP ever got=20
was the ljump instruction below, so I can't tell if the code =
after=20
that </FONT><FONT size=3D2>works at all.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> Please, =
somebody=20
help me! I don't know what is wrong and there simply aren't any =
experienced=20
</FONT><FONT size=3D2>ASM programmers around here! I've checked it about =
a hundred=20
times and cannot find anything wrong. Any help would </FONT><FONT =
size=3D2>be=20
greatly appreciated.</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> =
=20
Miguel Angel.</FONT></DIV>
<DIV><FONT size=3D2> =
=20
<A=20
href=3D"mailto:ordorica AT df1 DOT telmex DOT net DOT mx">ordorica AT df1 DOT telmex DOT net DOT mx</A>=
</FONT></DIV>
<DIV><FONT size=3D2> =
=20
<A=20
href=3D"mailto:sleeptk AT geocities DOT com">sleeptk AT geocities DOT com</A></FONT></D=
IV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>P.S. If you think this is not a good approach, =
please let me=20
know of any other I could use.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>.text</FONT></DIV>
<DIV> </DIV>
<DIV><BR><FONT face=3D"Courier New" size=3D2>#define=20
WRAPPER(x) &nb=
sp; &nbs=
p;  =
; =
=20
; \<BR>.globl=20
__wrapper_isr_inside_##x &=
nbsp; &n=
bsp; &nb=
sp; =20
; \<BR> .align=20
4 =
&=
nbsp; &n=
bsp; &nb=
sp; =20
;=20
\<BR> __wrapper_isr_inside_##x: &=
nbsp; &n=
bsp; &nb=
sp; =20
; \<BR> pushw=20
%ds &nbs=
p;  =
; =20
/* save registers */ ; =
\<BR> =20
pushw=20
%es &nbs=
p;  =
; =
&=
nbsp; =20
; \<BR> pushw=20
%fs &nbs=
p;  =
; =
&=
nbsp; =20
; \<BR> pushw=20
%gs &nbs=
p;  =
; =
&=
nbsp; =20
; \<BR> =20
pushal &=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p; =20
;=20
\<BR> &n=
bsp; =20
&=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p; =20
; \</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> .byte=20
0x2e &nb=
sp; &nbs=
p; =20
/* cs: override */ ;=20
\<BR> movw ___djgpp_ds_alias,=20
%ax &nbs=
p;  =
; =
=20
; \<BR> movw %ax,=20
%ds &nbs=
p;  =
; =20
/* set up selectors */ ; \<BR> movw =
%ax,=20
%es &nbs=
p;  =
; =
&=
nbsp; =20
; \<BR> movw %ax,=20
%fs &nbs=
p;  =
; =
&=
nbsp; =20
; \<BR> movw %ax,=20
%gs &nbs=
p;  =
; =
&=
nbsp; =20
;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
=20
; \<BR> movl $x,=20
%esi &nb=
sp; &nbs=
p;  =
; =
=20
; \<BR> movl __stacks(,%esi,4),=20
%ebx &nb=
sp; &nbs=
p;  =
; =20
;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
=20
; \<BR> movl %esp,=20
%ecx &nb=
sp; =20
/* old stack in ecx + dx */; \<BR> movw %ss,=20
%dx &nbs=
p;  =
; =
&=
nbsp; =20
;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
=20
; \<BR> movl %ebx,=20
%esp &nb=
sp; =20
/* set up our stack */ ; \<BR> =
movw=20
%ax,=20
%ss &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> pushl=20
%edx &nb=
sp; &nbs=
p; =20
/* push old stack onto new*/; \<BR> pushl=20
%ecx &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =20
=
=20
; \<BR> =20
cld &nbs=
p;  =
; *=20
clear the direction flag */ ;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> movl __addresses_isr_inside(,%esi,4),=20
%eax &nb=
sp; &nbs=
p;;=20
\<BR> call=20
*%eax &n=
bsp; &nb=
sp; =20
/* call the C handler */ ;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> =20
cli &nbs=
p;  =
; =
&=
nbsp; &n=
bsp; ;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> popl=20
%ecx &nb=
sp; &nbs=
p; =20
/* restore the old stack */; \<BR> popl=20
%edx &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> movw %dx,=20
%ss &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> movl %ecx,=20
%esp &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> orl %eax,=20
%eax &nb=
sp; &nbs=
p;=20
/* check return value */ ; \<BR> jz=20
get_out_##x &n=
bsp; &nb=
sp; &nbs=
p;  =
; ;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> =20
popal &n=
bsp; &nb=
sp; =20
/* chain to old handler */ ; \<BR> popw=20
%gs &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%fs &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%es &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%ds &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> pushl=20
__flags =
&=
nbsp; &n=
bsp; &nb=
sp; ;=20
\<BR> pushl=20
__code_sel &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> movl %esi,=20
__temp &=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p; ;=20
\<BR> movl $x,=20
%esi &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> pushl=20
__addresses_isr_after(,%esi,4) &=
nbsp; &n=
bsp; ;=20
\<BR> movl __temp,=20
%esi &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> ljmp=20
%cs:__addresses_old_isr+4*x &nbs=
p;  =
; =
;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR>get_out_##x: &n=
bsp; &nb=
sp; &nbs=
p;  =
; ;=20
\<BR> =20
popal &n=
bsp; &nb=
sp; =20
/* iret=20
*/  =
; ;=20
\<BR> popw=20
%gs &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%fs &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%es &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%ds &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> pushl=20
__flags =
&=
nbsp; &n=
bsp; &nb=
sp; ;=20
\<BR> pushl=20
__code_sel &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> movl %esi,=20
__temp &=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p; ;=20
\<BR> movl $x,=20
%esi &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> pushl=20
__addresses_isr_after(,%esi,4) &=
nbsp; &n=
bsp; ;=20
\<BR> movl __temp,=20
%esi &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> =20
sti &nbs=
p;  =
; =
&=
nbsp; &n=
bsp; ;=20
\<BR> =20
iret &nb=
sp; &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR>.globl=20
__wrapper_isr_after_##x &n=
bsp; &nb=
sp; &nbs=
p; ;=20
\<BR> .align=20
4 =
&=
nbsp; &n=
bsp; &nb=
sp; ;=20
\<BR> =20
__wrapper_isr_after_##x: &=
nbsp; &n=
bsp; &nb=
sp; ;=20
\<BR> pushw=20
%ds &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> pushw=20
%es &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> pushw=20
%fs &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> pushw=20
%gs &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> =20
pushal &=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p;  =
;;=20
\<BR> movl $x,=20
%esi &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> movl __addresses_isr_after(,%esi,4),=20
%eax &nb=
sp; &nbs=
p; ;=20
\<BR> call=20
*%eax &n=
bsp; &nb=
sp; &nbs=
p;  =
; ;=20
\<BR> =20
cli &nbs=
p;  =
; =
&=
nbsp; &n=
bsp; ;=20
\<BR> =20
popal &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
;=20
\<BR> popw=20
%gs &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%fs &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%es &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> popw=20
%ds &nbs=
p;  =
; =
&=
nbsp; ;=20
\<BR> =20
sti &nbs=
p;  =
; =
&=
nbsp; &n=
bsp; ;=20
\<BR> iret</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2>WRAPPER(0);<BR>WRAPPER(1);<BR>WRAPPER(2);<BR>WRAPPER(3);<BR>WRAP=
PER(4);<BR>WRAPPER(5);<BR>WRAPPER(6);<BR>WRAPPER(7);</FONT></DIV>
<DIV> </DIV>
<DIV><BR><FONT face=3D"Courier New" size=3D2>.globl=20
__wrapper_isr_inside_0_end<BR> .align=20
4<BR>__wrapper_isr_inside_0_end:<BR> ret</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>Somewhere else...</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>extern void =
_wrapper_isr_inside_0(),=20
_wrapper_isr_inside_1(),=20
_wrapper_isr_inside_2(),<BR> &nb=
sp; =20
_wrapper_isr_inside_3(), _wrapper_isr_inside_4(),=20
_wrapper_isr_inside_5(),<BR> &nb=
sp; =20
_wrapper_isr_inside_6(),=20
_wrapper_isr_inside_7(),<BR> &nb=
sp; =20
_wrapper_isr_inside_0_end(),<BR>  =
; =20
_wrapper_isr_after_0(), _wrapper_isr_after_1(),=20
_wrapper_isr_after_2(),<BR> &nbs=
p; =20
_wrapper_isr_after_3(), _wrapper_isr_after_4(),=20
_wrapper_isr_after_5(),<BR> &nbs=
p; =20
_wrapper_isr_after_6(), _wrapper_isr_after_7();</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> dword _flags, _temp,=20
_code_sel;<BR> dword=20
_addresses_isr_inside[NO_OF_WRAPPERS],<BR> &=
nbsp;=20
_addresses_isr_after[NO_OF_WRAPPERS],<BR> &n=
bsp;=20
_addresses_old_isr[NO_OF_WRAPPERS];<BR> int =20
_int_numbers[NO_OF_WRAPPERS];<BR> __dpmi_paddr=20
_old_handlers[NO_OF_WRAPPERS];<BR> byte=20
*_stacks[NO_OF_WRAPPERS];</FONT></DIV>
<DIV> </DIV>
<DIV><BR><FONT face=3D"Courier New" size=3D2>int=20
irq_handling_startup(void)<BR>{<BR> int counter;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> for(counter=3D0;=20
counter<NO_OF_WRAPPERS; counter++)<BR> =20
{<BR> =20
_addresses_isr_inside[counter]=3DNULL;<BR> &=
nbsp;=20
_addresses_isr_after[counter]=3DNULL;<BR> &n=
bsp;=20
_addresses_old_isr[counter]=3D=3DNULL;<BR> &=
nbsp;=20
_int_numbers[counter]=3D=3DNULL;<BR> =
_stacks[counter]=3D((byte=20
*)malloc(STACK_SIZE))+STACK_SIZE-32;<BR> &nb=
sp;=20
LOCK_ARRAY(_stacks[counter]-STACK_SIZE+32, STACK_SIZE,=20
sizeof(byte));<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =
_code_sel=3D_my_cs();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> __asm__=20
volatile<BR> (<BR> =20
"pushfl\n\t<BR> popl=20
%%eax\n\t<BR> movl %%eax,=20
__flags\n\t"<BR> :=20
:<BR> : "eax", =
"memory"<BR> =20
);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
LOCK_FUNCTION(_wrapper_isr_inside_0);<BR> =20
LOCK_ARRAY(_addresses_isr_inside, NO_OF_WRAPPERS, =
sizeof(dword));<BR> =20
LOCK_ARRAY(_addresses_isr_after, NO_OF_WRAPPERS, =
sizeof(dword));<BR> =20
LOCK_ARRAY(_addresses_old_isr, NO_OF_WRAPPERS, sizeof(dword));<BR> =
LOCK_ARRAY(_int_numbers, NO_OF_WRAPPERS, sizeof(int));<BR> =20
LOCK_ARRAY(_old_handlers, NO_OF_WRAPPERS, =
sizeof(__dpmi_paddr));<BR> =20
LOCK_ARRAY(_stacks, NO_OF_WRAPPERS, sizeof(dword));<BR> =20
LOCK_VARIABLE(_temp);<BR> LOCK_VARIABLE(_flags);<BR> =20
LOCK_VARIABLE(_code_sel);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> return =
0;<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>int take_over_irq(int number, =
int=20
(*inside)(void), void (*after)(void))<BR>{<BR> int=20
counter;<BR> __dpmi_paddr address;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> for(counter=3D0;=20
counter<NO_OF_WRAPPERS; counter++)<BR> =20
{<BR> =20
if(_addresses_isr_inside[counter]=3D=3DNULL)<BR> &=
nbsp; =20
goto free1;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> return =
-1;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> free1:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
_int_numbers[counter]=3Dnumber;<BR> =20
_old_handlers[counter].selector=3D_my_cs();<BR> =20
_addresses_isr_inside[counter]=3D(dword)inside;<BR> =20
_addresses_isr_after[counter]=3D(dword)after;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
switch(counter)<BR> =20
{<BR> default: return=20
-1;<BR> case 0:=20
address.offset32=3D(dword)_wrapper_isr_inside_0;=20
break;<BR> case 1:=20
address.offset32=3D(dword)_wrapper_isr_inside_1;=20
break;<BR> case 2:=20
address.offset32=3D(dword)_wrapper_isr_inside_2;=20
break;<BR> case 3:=20
address.offset32=3D(dword)_wrapper_isr_inside_3;=20
break;<BR> case 4:=20
address.offset32=3D(dword)_wrapper_isr_inside_4;=20
break;<BR> case 5:=20
address.offset32=3D(dword)_wrapper_isr_inside_5;=20
break;<BR> case 6:=20
address.offset32=3D(dword)_wrapper_isr_inside_6;=20
break;<BR> case 7:=20
address.offset32=3D(dword)_wrapper_isr_inside_7;=20
break;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
address.selector=3D_my_cs();<BR> =20
__dpmi_get_protected_mode_interrupt_vector(number,=20
&(_old_handlers[counter]));<BR> =20
_addresses_old_isr[counter]=3D_old_handlers[counter].offset32;<BR> &=
nbsp;=20
if(__dpmi_set_protected_mode_interrupt_vector(number,=20
&address))<BR> return -1;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> return =
0;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV></FONT></DIV></BODY></HTML>
--Boundary_(ID_4CFTEQZABfI8KWexlhzEpg)--
- Raw text -