unhandled exception : Privileged instruction

I

ilcario

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
}
//********************


thanks a lot
ilcario
 
J

Joona I Palaste

ilcario <[email protected]> scribbled the following
I would like access to direct addess port via Giveio.sys device driver
(with windows xp e 2k).

This is a question about the Windows platform, not about the C or C++
languages. The only group on your list where your question would be
even remotely topical is comp.lang.asm.x86. I suggest you also try
comp.os.ms-windows.programmer.win32.

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"As a boy, I often dreamed of being a baseball, but now we must go forward, not
backward, upward, not forward, and always whirling, whirling towards freedom!"
- Kang
 
R

Robert Wessel

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.
 
I

Ivan Korotkov

I would like access to direct addess port via Giveio.sys device driver
(with windows xp e 2k).

AFAIK, giveio.sys just enables you access to ports by setting appropriate
bits in TSS's port map. To execute CLI, you need CPL <= IOPL. CPL is 3.
Thus, you have to make IOPL=3. Remedies:

1) set IOPL to 3 from a driver (this is VERY unsafe and IMO will not work
since OS may change IOPL)
2) set your task's IOPL to 3 from a user-mode service (this is much safer
because (i) OS itself supports it and (ii) only your app will work at
IOPL=3);

ZwSetInformationProcess(hProcess, 16, 0, 0); // SeTcbPrivilege required

Then, you don't need giveio at all.

Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,460
Latest member
eibafima

Latest Threads

Top