Going realmode in kernel drivers?
Peter B
pb at ludd.luth.se
Mon Nov 24 07:18:48 PST 2003
i386/FreeBSD-4.x/lkm.
How does one get into 'realmode' inside a kernel driver?
The reason for the need is a tight timeing loop that measures the lenght of
pulses. And disableing interrupts is just not enough.
Target cpu's are AMD K5 + AMD XP.
Asfair when reading cycles per opcode. The number of cycles required increase
about three times when useing protected mode or similar.
Code excerpt:
u_int32_t register cnt1;
u_int32_t register cnt_max=0xFF;
u_int32_t register *store_ptr;
u_int32_t register *store_end;
u_int8_t register last_val=0;
store_ptr = ..;
store_end = ..+ SIZ;
disable_intr();
for(;;)
{
for(cnt1=0; cnt1<cnt_max && ((inb(0x379)&0x20) != last_val); cnt1++)
;
*(store_ptr++) = cnt1;
if( store_ptr>=store_end )
break;
last_val ^= 0x20;
}
enable_intr();
(Will start on a new count every signal flank).
/P
More information about the freebsd-hackers
mailing list