Mail Archives: djgpp/2004/07/16/02:55:35
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
Message-ID: | <003e01c46b01$84546800$0d01a8c0@josepmariaxp>
|
From: | "turomas" <josepmaria AT turomas DOT com>
|
To: | <djgpp AT delorie DOT com>
|
References: | <ZtDJc.129847$wH4 DOT 7032125 AT twister DOT southeast DOT rr DOT com>
|
Subject: | Re: PM hardware interrupts
|
Date: | Fri, 16 Jul 2004 08:52:38 +0200
|
MIME-Version: | 1.0
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Mailer: | Microsoft Outlook Express 6.00.2720.3000
|
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2739.300
|
X-MailScanner-Information: | Please contact the ISP for more information
|
X-MailScanner: | Found to be clean
|
X-MIME-Autoconverted: | from 8bit to quoted-printable by server53.ervers.com id i6G6icf13609
|
X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id i6G6rMBB001436
|
Reply-To: | djgpp AT delorie DOT com
|
Try with this code. It works for me very well for long time ago.
void configurar()
{
int div;
disable();
//configura timers
if(tipus_timer==0){
outportb(B_TIMER+3,0x80|0x36);
outportb(B_TIMER+2,4);
outportb(B_TIMER+2,0);
outportb(B_TIMER+3,0x40|0x36);
outportb(B_TIMER+1,(unsigned char)(div&0xff));
outportb(B_TIMER+1,(unsigned char)((div&0xff00)>>8));
}
if(tipus_timer==1){
outport(B_TIMER,0x8000|(int)div);
if(irqI<8)setvect(irqI+8,ent); //I create setvect function for
compatibility with Borland
if(irqI>=8)setvect(0x70+irqI-8,ent);
habilita_interrupcio();
if(irqI>=8)outportb(0xa0,0x20);
outportb(0x20,0x20);
enable();
}
void habilita_interrupcio()
{
outportb(0x21,0x0);
if(irqI>=8)outportb(0xa1,0x0);
}
void deshabilita_interrupcio()
{
if(irqI<8) outportb(0x21,(0x1<<irqI));
else outportb(0xa1,(0x1<<(irqI&0x7)));
}
unsigned int state87[200];
void ent()
{
asm("fnsave %0\n\t"
"fwait\n\t"
:"=g" (state87)
);
//Codi interrupció
asm("frstor %0\n\t"
"fwait\n\t"
:"=g" (state87)
);
if(irqI>=8)outportb(0xa0,0x20);
outportb(0x20,0x20);
}
int setvect(int intno,void (*interrupt)())
{
_go32_dpmi_get_protected_mode_interrupt_vector(intno, &old_handler);
new_handler.pm_offset = (int)(ent);
new_handler.pm_selector = _go32_my_cs();
if(chain==1)_go32_dpmi_chain_protected_mode_interrupt_vector(intno,
&new_handler);
if(chain==0){
_go32_dpmi_allocate_iret_wrapper(&new_handler);
_go32_dpmi_set_protected_mode_interrupt_vector(intno,&new_handler);
}
intnombre=intno; //I have to store irqnum to restore the old interrupt
}
void desconfigura_interrupcio()
{
if(intnombre>=0){
_go32_dpmi_set_protected_mode_interrupt_vector(intnombre, &old_handler);
if(chain==0)_go32_dpmi_free_iret_wrapper(&new_handler);
}
}
- Raw text -