il*****@iol.it (ilcario) wrote in message news:<3e**************************@posting.google. com>...
I would like access to direct addess port via Giveio.sys device driver
(with windows xp e 2k).
i don't understand why this source for pilot a uart controller tra an
exception in _asm cli instruction.
How can I do run un assembler instruction with pricilege mode ??
//************** source code
void Serial_Write (unsigned char ch) {
while (!((unsigned char)Read_UART(port_in_use, REG_LSR) &
0x20)){}
//clear interrupts
_asm cli
Write_UART(port_in_use, REG_THR, (int)ch);
//set interrupts
_asm sti
}
//********************
While GiveIO will let you hit selected I/O ports from an application,
it will not let you disable interrupts. In short, you can't disable
interrupts from an application. Even in a device driver, where you
can execute privileged instructions, it's rather more complicated than
that. While you can get away with disabling interrupts for a short
period, in most cases that does *not* solve the problems you're trying
to solve on multi-processor systems. In a DD you'll generally want to
use a lock of some sort, or manage your IRQL.
Second, direct access to the UART isn't a great idea for a Win32
program. Not only are you assuming a particular type of hardware (eg.
an 8250 compatible serial port - which is a dead wrong assumption on
most current laptops, among other systems), you're probably assuming
it's at a fixed I/O location, and you're probably not managing
interacting with other users of the serial port. At the very least
you should disable the normal Windows support for the serial port in
question.
If you're running 16 bit (DOS) code, access to the UART will be
simulated by the OS with a virtual device driver. You'll also be able
to disable interrupts within the virtual DOS machine, but certainly
not the real ones.