[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Writing printer port based driver...
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: Writing printer port based driver...
- From: Josh <pkplex_(_at_)_orcon_(_dot_)_net_(_dot_)_nz>
- Date: Wed, 22 Dec 2004 22:32:20 +0000
Hello.
I have a device which plugs into the printer port, and I want to write a driver for it. I wrote one for the same device on netbsd a long time ago, so all the actual protocol sort of stuff is sorted... but I am very rusty.
Looking at the workings of lpt.c, it looks fairly straight forward, like the netbsd one. However, actually getting the driver compiled in and happy with the kernel config system seems to be tricky.
What I am thinking might be a good idea is to use the already existing lpt_isa part of the lpt driver 'glue' stuff, eg lpt_isa.c. I want to call my driver lcd, and i am writing it for i386, So in the relevant places, like /usr/src/sys/arch/i386/conf/files.i386 I copy the lpt entrys and change them to lcd. Likewise in conf.c.
In /usr/src/sys/conf/files I copy the lpt entry so it looks like this:
device lcd
file dev/ic/lcd.c lcd & (lpt_isa | lpt_localbus | lpt_gsc | lpt_puc | lpt_apio | lpt_ebus) needs-flag
In /usr/src/dev/ic/ I copy lpt.c to lcd.c, and replace lpt and LPT with lcd and LCD respectively. I will change specific stuff ( like the headers ) once I get it compiling.
Then in /usr/src/sys/dev/isa/files.isa I copy the lpt entry in there, except renaming the lpt ( not lpt_isa ) to lcd, so I have:
attach lcd at isa with lpt_isa
file dev/isa/lpt_isa.c lpt_isa needs-flag
I also copy the entry in the kernel config file, so its like this:
lcd0 at isa? port 0x378 irq 7
However when I run config MYKERNEL it comes up with this:
../../../../dev/isa/files.isa:379: redefinition of `lpt_isa'
../../../../dev/isa/files.isa:380: duplicate file dev/isa/lpt_isa.c
../../../../dev/isa/files.isa:376: here is the original definition
*** Stop.
Line 379 and 380 are the lcd attach and file entrys.
I read files.conf manpage, but I dont quite understand it yet, or how to re-use 'glue' routines.
So my question is, how do I re-use the lpt_isa.c (or other) 'glue' routines? Is it possible? Is it proper? Any suggestions?
Thanks
Visit your host, monkey.org