473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

unhandled exception : Privileged instruction

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

Jul 22 '05 #1
3 5906
ilcario <il*****@iol.it> scribbled the following
on comp.lang.c:
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 (pa*****@cc.helsinki.fi) ------------- 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

Jul 22 '05 #2
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.

Jul 22 '05 #3
> 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
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: juergen perlinger | last post by:
Hello out there. sometimes I need to have proper control of the floating point arithmetic of the C(and C++) runtime system, and using the f.p. exception handling of the C99 standard is quite...
3
by: ilcario | last post by:
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...
20
by: Bonj | last post by:
Hello. Does anybody know if there is a difference between the way C# calls a COM object, and the way C++ calls a COM object? And is there anyway to make the latter emulate the former? I have a...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
5
by: Dave Stewart | last post by:
I recently wrote my first Vb.net application, or at least my first complex app since moving up from vb6. When run from the VS.NET IDE, the program shows no errors and runs fine. When the output exe...
5
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by...
5
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can...
0
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks...
1
by: vighnesh | last post by:
Hi All Can anyone please let me know how to catch an unhandled exception like " An Unhandled exception of type 'system.stackoverflowexception' occured in mscorlib.dll " I am unable to catch...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.