Page 1 of 1
Linux->Nasm->Flush ports
Posted: Fri Jul 09, 2010 3:09 pm
by yousafsajjad
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.
Re: Linux->Nasm->Flush ports
Posted: Fri Jul 09, 2010 3:17 pm
by gravaera
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
Re: Linux->Nasm->Flush ports
Posted: Fri Jul 09, 2010 6:55 pm
by Brynet-Inc
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.
Re: Linux->Nasm->Flush ports
Posted: Fri Jul 09, 2010 10:24 pm
by yousafsajjad
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
Posted: Fri Jul 09, 2010 11:00 pm
by ucosty
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.
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.
Re: Linux->Nasm->Flush ports
Posted: Sat Jul 10, 2010 12:20 am
by pcmattman
I believe the OP is looking for something like "iodelay()", often implemented like so:
Code: Select all
inline void iodelay(){
outl(0x80, inl(0x80));
}
Port 0x80 is often used in this way as a delay+flush operation.
Re: Linux->Nasm->Flush ports
Posted: Mon Jul 12, 2010 8:39 am
by yousafsajjad
Yeah you are right its DMA register and I have done what I intended to do. Thanks guys