[coreboot] Dynamic detection of Parallel Port

Joseph Smith joe at settoplinux.org
Sun Dec 7 06:52:06 CET 2008




On Sat, 06 Dec 2008 23:32:26 +0100, Stefan Reinauer <stepan at coresystems.de>
wrote:
> Joseph Smith wrote:
>> Hello,
>> For the Paraflasher project I would like to setup a function to
>> automatically detect the presence of the PC's parallel ports and their
> base
>> addresses. This way it doesn't need to be hard-coded into the program. I
>> was thinking of using /proc/ioports to do this but I am not really sure
> how
>> to do this in C. Here is what I am thinking:
>>
>> 1. First use grep -c paraport /proc/ioports to check if we have multiple
>> parallel ports and maybe setup loop for it.
>> 2. Then grep paraport /proc/ioports again to get the base address of
> each
>> parallel port detected. This is where I am stuck. I just need to turn
> the
>> first 4 characters (base address) into a variable. Can anyone help???
>>   
Hmm after some research it looks like for every parallel port Linux (kernel
2.4 and up) detects it creates /proc/sys/dev/parport/parport* (0,1,2,3, and
so on) directory. Within this directory there is a base-addr file.

cat /proc/sys/dev/parport/parport0/base-addr 
888 1912
Then turn the first number into hex (888 => 0x378) 

Wala, we have our base address :-)

So, For multi ports I think I just need a shell command that will count how
many parport* directories found in /proc/sys/dev/parport/, any ideas?

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





More information about the coreboot mailing list