[coreboot] Dynamic detection of Parallel Port

ron minnich rminnich at gmail.com
Sat Dec 6 18:49:32 CET 2008

you're making it too hard. :-)

If you do this:
 awk '/rtc/{print $1}'

you get a line like this:
cat /proc/ioports | awk '/rtc/{print $1}'

OK, but you just want the first four digits, right? Well, strtoul will
do this for you, so:
port = strtoul(string, 0, 16);

it will stop at the '-', which is not hex. Problem solved.

But how do I get this into a program?

paraflash `awk '/rtc/{print $1}'`

First arg will be the port addresses.

Instead of 'rtc', use whatever your parallel port name is.

Did you want more than one? Here's another example:
[rminnich at xcpu2 coreboot-v3]$ echo `cat /proc/ioports | awk '/ahci/{print $1}' `
1c20-1c3f 1c40-1c43 1c44-1c47 1c48-1c4f 1c50-1c57
[rminnich at xcpu2 coreboot-v3]$

So your program will see a sequence of arguments, one for each parallel port.

You don't have to do it exactly this way, but this is why we have all
these fiddly little tools, so you can put things together without
having to write lots of code.

If you don't want users to see this commnand, use popen(3).



More information about the coreboot mailing list