[coreboot] Dynamic detection of Parallel Port

Joseph Smith joe at settoplinux.org
Sat Dec 6 19:07:06 CET 2008




On Sat, 6 Dec 2008 09:49:32 -0800, "ron minnich" <rminnich at gmail.com>
wrote:
> 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}'
> 0070-0071
> 
> 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).
> 
Awsome, that is exacly what I was looking for, thanks Ron.

-- 
Thanks,
Joseph Smith
Set-Top-Linux
www.settoplinux.org





More information about the coreboot mailing list