|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 2876 (0xb3c)
Types: TextFile
Notes: UNIX file
Names: »clkk.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦2d53db1df⟧ UNIX Filesystem
└─⟦this⟧ »frankh/src/junk/clkk.c«
/*
* Centronics parallel printer interface driver for Commodore Z8000M
* (uses the Z8036 chip).
*
*
*
*
*/
#include <coherent.h>
#include <con.h>
#include <errno.h>
#include <io.h>
#include <proc.h>
#include <uproc.h>
#include <stat.h>
int ckload();
int ckuload();
int ckwrite();
int ckopen();
int ckclose();
int ckintr();
int nulldev();
int nonedev();
CON ckcon = {
DFCHR, /* Flags */
12, /* Major index */
ckopen, /* Open */
ckclose, /* Close */
nulldev, /* Block */
nonedev, /* Read */
ckwrite, /* Write */
nonedev, /* Ioctl */
nulldev, /* Powerfail */
nulldev, /* Timeout */
ckload, /* Load */
ckuload /* Unload */
};
/*
* Various ports and masks. All initialization of the Z8036
* is done in the mach since there are other devices that
* use the chip. If you want to change LPIRQ you must also
* modify its definition in the mach.
*/
#define LPPORT 0x1D /* Printer port */
#define BUSYPORT 0x1F /* BUSY port */
#define ACKPORT 0x9D /* Acknowledge port */
#define STROBEPORT 0x9F /* Strobe port */
#define SETSTROBE 0x70 /* Sets strobe line */
#define CLEARSTROBE 0x78 /* Clears strobe line */
#define ACKMASK 0x02 /* Mask for acknowledge bit */
#define BUSYMASK 0x01 /* Mask for busy bit */
#define PBCS 0x93 /* Z8036 #2 port B cmd & stat reg */
#define PCDD 0x0D
#define PCDATA 0x1F
#define PBDATA 0x1B
#define CLRIPIUS 0x20 /* Mask to clear IP and IUS */
#define LPIRQ 0x70 /* Printer interrupt */
#define MAXBUF 256 /* # of bytes in buffer */
#define LOLIM 30 /* Low buffer limit for wakeup */
/* lpflag bits */
#define LPOPEN 0x01 /* Printer is open */
#define LPSLEEP 0x02 /* Sleeping on buffer event */
#define LPRAW 0x04 /* Raw mode */
#define LPWFI 0x08 /* Waiting for Interrupt */
/*
*
*
*
* The data lines are initialised, as follows in md.s:
* 8036 #1, port b, non-inverting: output data lines
* 8036 #1, port c, bit 0, non-inverting: input busy line
* 8036 #2, port b, bit 1, inverting: inpupt acknowledge
* 8036 #2, port c, bit 3, non-inverting: output strobe
*
*/
main()
{
unsigned int tmp;
printf("Begin . . .\n");
outb( PCDD, 0x05); /* set up STOP line */
outb( PCDATA, inb(PCDATA) | 0x50);
outb( PBDATA, 0);
printf("ckload: start\n");
outb( PCDATA, inb(PCDATA) & ~0x01); /* set select = 0 */
outb( PBDATA, inb(PBDATA) | 0x80); /* set stop = 1 */
outb( PBDATA, inb(PBDATA) & 0xF0); /* set d0-d3 = 0 */
outb( PBDATA, inb(PBDATA) | 0x40); /* set adw = 1 */
tmp = 0; /* delay */
outb( PBDATA, inb(PBDATA) & ~0x40); /* set adw = 0 */
outb( PBDATA, inb(PBDATA) | 0x10); /* set rd = 1 */
tmp = 5 * 5; /* delay */
tmp = inb(PBDATA) & 0x0F; /* read and mask */
printf("ckload: tmp = %u\n", tmp);
outb( PBDATA, inb(PBDATA) & ~0x80); /* set stop = 0 */
outb( PBDATA, inb(PBDATA) | 0x01); /* set select = 1 */
}