[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-tech
Subject:    Re: Writing printer port based driver...
From:       Alexander Yurchenko <grange () rt ! mipt ! ru>
Date:       2004-12-22 14:55:28
Message-ID: 20041222145528.GA11347 () disorder ! rt ! mipt ! ru
[Download RAW message or body]

On Wed, Dec 22, 2004 at 10:32:20PM +0000, Josh wrote:
> 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

device lcd
file dev/ic/lcd.c lcd & lcd_isa 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

attach lcd at isa with lcd_isa
file dev/isa/lcd_isa.c lcd_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?

Clone lpt_isa.c into the lcd_isa.c like you did with lpt.c.

> 
> Thanks

-- 
   Alexander Yurchenko (aka grange)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic