Hi,
I am using the following code to flush port:
in al, 081h
out 081h, al
but it is giving me segmentation fault. Does anyone how I can do it.
Linux->Nasm->Flush ports
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: Linux->Nasm->Flush ports
Hi:
Please explain what you mean by "flushing" a port: in that code all you do is read from port I/O and then write the value back. Technically, this is just an unnecessary delay: devices usually have specific read/write sequences which trigger device responses, and interacting with port mapped I/O unnecessarily is just introducing unnecessary latency and probably causing the device to do undesired operation anyway.
Also, I/O reads and writes are usually implemented using some protocol between the processor and bus, and this has overhead, plus the fact that the firmware will then have to, in its own chipset specific manner redirect your I/O signal to the right device, etc etc: all you're doing is causing unnecessary hassle.
If a device requires a "flush", it will tell you so in its datasheet and it will tell you how to do so. But you don't go around "flushing" port mapped regs.
--All the best,
gravaera
Please explain what you mean by "flushing" a port: in that code all you do is read from port I/O and then write the value back. Technically, this is just an unnecessary delay: devices usually have specific read/write sequences which trigger device responses, and interacting with port mapped I/O unnecessarily is just introducing unnecessary latency and probably causing the device to do undesired operation anyway.
Also, I/O reads and writes are usually implemented using some protocol between the processor and bus, and this has overhead, plus the fact that the firmware will then have to, in its own chipset specific manner redirect your I/O signal to the right device, etc etc: all you're doing is causing unnecessary hassle.
If a device requires a "flush", it will tell you so in its datasheet and it will tell you how to do so. But you don't go around "flushing" port mapped regs.
--All the best,
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: Linux->Nasm->Flush ports
I would be very surprised if Linux allowed direct I/O access like that, also, if that's the bulk of your program.. it will not execute.
-
- Posts: 5
- Joined: Thu Jul 08, 2010 6:03 pm
Re: Linux->Nasm->Flush ports
yeah you are right .. i am calling an assembly function from C. So I need to get permission to that port using ioperm() first and than it works.
Re: Linux->Nasm->Flush ports
According to http://www.pcguide.com/ref/mbsys/res/ioSummary-c.html, port 81h is a DMA page register. I doubt very much that your code does what you think or even want.yousafsajjad wrote:yeah you are right .. i am calling an assembly function from C. So I need to get permission to that port using ioperm() first and than it works.
The cake is a lie | rackbits.com
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: Linux->Nasm->Flush ports
I believe the OP is looking for something like "iodelay()", often implemented like so:
Port 0x80 is often used in this way as a delay+flush operation.
Code: Select all
inline void iodelay(){
outl(0x80, inl(0x80));
}
-
- Posts: 5
- Joined: Thu Jul 08, 2010 6:03 pm
Re: Linux->Nasm->Flush ports
Yeah you are right its DMA register and I have done what I intended to do. Thanks guys