Return to BSD News archive
Path: sserve!manuel!munnari.oz.au!spool.mu.edu!uunet!darwin.sura.net!Sirius.dfn.de!fauern!btr0x1!mb3.tu-chemnitz.de!hrz.tu-chemnitz.de!wutcd From: wutcd@hrz.tu-chemnitz.de (Wunsch) Newsgroups: comp.unix.bsd Subject: 386BSD line printer driver Summary: simple line printer driver for 386BSD Keywords: 386BSD,lp() Message-ID: <wutcd.708090976@hrz.tu-chemnitz.de> Date: 9 Jun 92 11:56:16 GMT Article-I.D.: hrz.wutcd.708090976 Sender: bin@hrz.tu-chemnitz.de (Owner of all binaries) Organization: tu-chemnitz Lines: 273 Hi, 386bsd-world, here's my lp driver in its first (surely preliminary) version. This is my first driver for a BSD, so I'm sure there are still bugs in it. Any fixes and remarks are welcome. The driver has been developed and tested on a slow SX machine with 16 MHz clock together with an Epson LQ-550 printer. Maybe the delay algorithm is weak enough to fail on fast machines (the Centronics interface needs some distinct delays between the pulse edges, but short enough not to tsleep() the process). But if you experience this: first try increasing the system variable cpuspeed. (This variable is normally set to 1 [or to 0 in the distribution version of locore.s!]) So the DELAY macros will compute to more time. The boot time messages aren't quiet correct, the ioctl's propably don't return their values... but the driver sends characters to the printer, and the interrupt/context switch code seems to be okay. So test it yourself. Mail any suggestions and bug reports to joerg_wunsch%bonnie@hadrian.hrz.tu-chemnitz.de ------------------------------------------------------------------------ To install the driver you need to do the following: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Extract the files lpreg.h and lp.c from the text below and put them into /sys/i386/isa; lp.c is compressed and uu-encoded, so you must save the appropriate part of text into tempfile, then ``uudecode tempfile'' and ``uncompress lp.c'' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + edit /sys/i386/i386/conf.c according to the following diff script 151a152,162 > #include "lp.h" > #if NLP > 0 > int lpopen(),lpclose(),lpread(),lpwrite(), lpioctl(); > #else > #define lpopen enxio > #define lpclose enxio > #define lpread enxio > #define lpwrite enxio > #define lpioctl enxio > #endif > 197a209,211 > { lpopen, lpclose, lpread, lpwrite, /*D*/ > lpioctl, enodev, nullop, NULL, > seltrue, enodev, NULL }, (NOTE: if you've already assigned a driver to character device major number 13 [``D''], choose a new one. The only place you need this in- formation is when creating the device special file[s].) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + go to /sys/i386/conf and edit the following files append the line i386/isa/lp.c optional lp device-driver to ``files.i386'', and insert the device definition device lp0 at isa? port "IO_LPT1" bio irq 7 vector lpintr into the configuration file (normally the file SMALL) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + ``config SMALL'' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + go to /sys/compile/SMALL, ``make depend'' then ``make'' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + install the system [ ``mv /386bsd /386bsd.alt; cp 386bsd /'' ] and reboot ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + create the required device special files mknod /dev/lp0 c 13 0; ln /dev/lp0 /dev/lp; chmod 222 /dev/lp0 The link for /dev/lp is optional, of course. It should be assigned to the default printer, I guess. In addition, you may link also ln -s ../i386/isa/lpreg.h /usr/include/sys/lpreg.h so user programs can refers to the definitons by including <sys/lpreg.h> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + try ``ls -l > /dev/lp'' That's all for today :-) J"org --------------------------File lpreg.h-------------------------------- /* * Copyright (c) 1992 Joerg Wunsch, Dresden * * This software is part of 386BSD (Copyright by W. F. Jolitz), and * is provided with the same Copyright regulations as 386BSD except * the actual copyright holder. * See the file COPYRIGHT in root directory. * * Mail suggestions and bug reports to: * joerg_wunsch%bonnie@hadrian.hrz.tu-chemnitz.de * */ /* * $Header: /usr/joerg/lp.drv/RCS/lpreg.h,v 1.1 1992/06/07 21:45:38 j Exp $ * * definitions for (parallel) line printer driver */ #define LPPRI PZERO /* any better solution??? PZERO is still interruptible */ #define LPBUFFSIZE 64 /* It isn't very useful to allocate a large buffer: * most printers have buffer space enough to keep * a small file, and large amounts of data will * defer the caller anyway... The only sense to buffer * data is to reduce the user -> kernel space transfer */ #define LPTIMEOUT (hz / 2) /* time to sleep for an interrupt till we declare * the interrupt beeing lost and check status agn. */ #define LP_RESET_TMO 1000 /* # of cycles to check for printer is ready * (ideally, this should be microsec's) */ /* * ioctl's for lp */ #define LP_IOCTL ('L' << 8) #define LPI_RESET (LP_IOCTL + 1) /* hdwr reset printer */ #define LPI_STATUS (LP_IOCTL + 2) /* fetch status port */ /* * define lp (parallel) registers */ /* * register names */ #define LP_DATA 0 /* outb() send to lp; inb() fetch last byte sent */ #define LP_CTRL 2 /* lp controls, as follows: */ #define LPC_STRB 001 /* strobe; set when sending byte */ #define LPC_ALF 002 /* auto-LF; when set lp LF's after CR */ #define LPC_INIT 004 /* /init; when clear reset lp */ #define LPC_SLCTIN 010 /* select in; set to select lp */ #define LPC_IRQEN 020 /* irq enable; enables hdwr int on ack */ /* all bits to be set when LP_CTRL is beeing enabled */ #define LPC_ENABLED (LPC_INIT + LPC_SLCTIN + LPC_IRQEN) #define LP_STAT 1 /* lp status, read/only */ #define LPS_ERR 010 /* clear: lp signals error */ #define LPS_SLCT 020 /* set: lp is selected */ #define LPS_PE 040 /* set: lp out of paper */ #define LPS_ACK 0100 /* cleared during acknowledgment */ #define LPS_BUSY 0200 /* clear: lp is busy (or error) */ #define LPS_MASK (LPS_ERR + LPS_SLCT + LPS_PE + LPS_ACK + LPS_BUSY) --------------------------File lp.c.Z.uuencoded------------------------ begin 644 lp.c.Z M'YV0"EZH4`!"!8@A;^#DD9/F#!HZ(%",20$B1HX<,D`H>5-&SAD05^JXF3,& M#0L01.24F4.FC!N"`PN"H((FS1P0<]Z8H7,GC$H0-D'`\0E1)X@9.&P(F4(D M(D*%#!U"%),'I`L01JYN9).&CIX4)\.X(0,3Z$TX<M[82=.2#(@[7=&`H(.F M#,XP;>P^7=CP(0B59^JP"4,GS9N1(,+<1*J4*8@R>,:4@4.G+%V[8<;0J1.&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