 lib environment
 opt nol
 lib dtab
 lib sptab
 lib pprtab
 lib inttab
 lib bfhdr
 lib blktab
 lib chrtab
 lib fio
 lib macdefs
 opt lis,exp
 sttl Device Driver Tables
 pag
 name devtab
 data
 define

*
* System Parameters - adjust accordingly
*

USE_SPR set 0
USE_PPR set 1
USE_IOP set 1 -- set to 1 to have IOP ports

SSIZE equ 1 initial stack size (*PAGSIZ)
MAXJOB equ 10 maximum simult user tasks
NBLKS equ 16 Accessable pages in address space
USRHIP equ NBLKS-1 User's highest addressable page
USRHIP_4 equ USRHIP<<4

* terminal i/o constants

OQHI equ 119 outq upper limit
OQLO equ 15 outq lower limit
CHRLIM equ 255 max characters on q

*
LIGHTS fcb 0

*
* Machine constants
*

DATBOX equ $F800 memory mapper regs
TSR equ $E280 Task Select/Status Register
FUSE equ $FB00 Task Switch "FUSE"
BLKHOL fcb $F3 black hole memory cell
DSKTRM fcb $F3 swap map terminator
WHTHOL fcb $F4 white hole memory cell
CLOCK equ $E210 gimix clock base
HZTIM equ 6250 ???+1??? gimix clock rate
CLKSEL equ CLOCK+1 clock select and status register
CLKLAT equ CLOCK+6 clock timer latch
CLKCON equ %01000001 clock control (gimix)
CLKMSK equ %10000000 clock interrupt mask
*
* Device Register Definitions
*

*
* Memory - Memory DMA Controller (On-board CPU)
*
 base $FC00
DMA_SCR rmb 1 Source Control Register
DMA_SAR rmb 2 Source Address Register
DMA_DCR rmb 1 Destination Control Register
DMA_DAR rmb 2 Destination Address Register
DMA_CNT rmb 2 Byte Count Register

*
*  DMAF2
*
 base $F000
DMFINT rmb 1 dma interrupt register
DMFCCR rmb 1 dma control register
DMFADR rmb 2 dma address register
DMFCOM rmb 1 wd command register
DMFTRK rmb 1 wd track register
DMFSEC rmb 1 wd sector register
DMFDAT rmb 1 wd data register
DMFDRV equ DMFINT drive select register

*
* Xebec SA1410 5" Winchester
*
 base $F100
SASI_CSR rmb 1 control/status register
SASI_ADR rmb 3 DMA address registers
SASI_DATA rmb 1 SASI data port

*
*  Special device addresses
*

BASACI equ $E000
PIA0 equ $E072 gimix parallel port (pia)

 data

*
* ROM Routines
*
Pdata lda ,x+ get next character
 beq 99f exit at null
 bsr Pchar print it
 bra Pdata continue
99 rts
Phex pshs cc
 seti
 jsr [$F802]
 puls cc,pc
Pspace pshs cc
 seti
 jsr [$F804]
 puls cc,pc
Pchar pshs cc
 seti
 jsr [$F806]
 puls cc,pc
Tinit pshs cc
 seti
 jsr [$F808]
 puls cc,pc
Phex2 pshs b
 bsr Phex
 puls a
 bra Phex

contab equ *
 ifc &a,'8'
Uni_DN equ FD_8 8" Floppy Diskette
 info 8" Floppy Diskette Root File System
 else
 ifc &a,'5'
Uni_DN equ FD_5_40+2 5" Floppy Diskette
 info 5" Floppy Diskette Root File System
 else
 ifc &a,'580'
Uni_DN equ FD_5_80+2 5" Floppy
 info 5"/80 Floppy Diskette Root File System
 else
 ifc &a,'5W'
Uni_DN equ WINminor 5" Winchester
 info 5" Winchester Root File System
 else
 err ** Unknown root system '&a' **
Uni_DN equ 4 Default (hard disk)
 endif
 endif
 endif
 endif

strm fcb 21 number of terminals
stsk fcb 48 number of tasks
siob fcb 32 number of io buffers
schl fcb  8 number of character lists
sfdn fcb 64 number of fdn entries
stxt fcb 20 number of text entries
smnt fcb 5 number of mounts
stim fcb 24 number of timeouts allowed
slok fcb 32 number of lock table entries
srtd fdb Uni_DN root device number
sppd fdb Uni_DN pipe device number
sswd fdb Uni_DN swap device number
stlm fcb 0 time limit in 25.6 X seconds (0 disables)
sfil fdb 500 max file size for reg user
scon fdb BASACI console terminal address (acia)
sconbr fcb 0 Baud Rate value for system console
smxj fcb MAXJOB max user task count
stmz fdb 300 time zone (minutes west of gmt)
sdlt fcb 0 daylight savings here (0 if not)
sphz fcb 0 non-zero if power line is 50HZ
stup fcb 0 auto update time (0 disables) - value*4
smxm fcb NBLKS maximum mem segments per task
FD_SRT fcb 0 Floppy Disk Seek Rate
SWTPCvii fcb 0 non SWTPC vii system
DATsense fcb $00 Pure DAT
ROMmap fdb $FEFF Map registers for $E000-$FFFF
NMIhan fdb Fault Hardware detected fault
SWI2han fdb 0 ** Handled in ROM
MAXMAP fcb 8 Number of maps in system

*
* Macros used to generate IOP tables
*
iop macro
minor set 0
 rpt 3
 iop_minor &1,&2,&3
 endm
*
iop_minor macro
* tty &2+minor
 fcb 2,minor IOP
 fcb %00001110 int mask
 fdb &1 status register
 fdb &3,0 No Baud Rate Generators
 fdb fio_int interrupt routine
 fdb &2+minor device number
minor set minor+1
 endm


*
* Interrupt Handler Table
*    Used to decide which device generated an interrupt
* and how to process it.
*

inttab
 fcb N_intdev number of interrupt devices
 iop BASACI+$00,0,IOP0
 iop BASACI+$10,3,IOP1
 iop BASACI+$20,6,IOP2
 iop BASACI+$30,9,IOP3
 iop BASACI+$40,12,IOP4
 iop BASACI+$50,15,IOP5
 iop BASACI+$60,18,IOP6
 if USE_SPR
* serial printer 1
 fcb 0,0 ACIA
 fcb %10000000 int mask
 fdb SRLPRT0 status register
 fdb 0,0 No Baud Rate Generators
 fdb spntr interrupt routine
 fdb $0500 device number
* serial printer two
 fcb 0,0 ACIA
 fcb %10000000 int mask
 fdb SRLPRT1 status register
 fdb 0,0 No Baud Rate Generators
 fdb spntr interrupt routine
 fdb $0501 device number
 endif
 if USE_PPR
* parallel printer
 fcb 1,0 PIA
 fcb %10000000 int mask
 fdb PIA0+1 status register
 fdb 0,0 No Baud Rate Generators
 fdb ppint interrupt routine
 fdb $0600 device number
 endif
*
N_intdev equ (*-inttab-1)/INTSIZ
*
intend equ *

*
* Special tables used by IOP interface
*
IOP0 rzb IOP_SIZE
IOP1 rzb IOP_SIZE
IOP2 rzb IOP_SIZE
IOP3 rzb IOP_SIZE
IOP4 rzb IOP_SIZE
IOP5 rzb IOP_SIZE
IOP6 rzb IOP_SIZE

*
* fnttab
*
* Interrupt table for firq type interrupts.  It is
* the same as inttab above.
*

fnttab
fntend equ *


 pag

*
* Device tables
*

* Character table

chrtab
* tty device
 fdb iop_open tty open routine
 fdb iop_close tty close routine
 fdb iop_read tty read routine
 fdb iop_write tty write routine
 fdb iop_spcl special routine
* mem device
 fdb nuldev mem open
 fdb nuldev mem close
 fdb mdrd mem read
 fdb mdwr mem write
 fdb nuldev mem special
* null device
 fdb nuldev null dev open
 fdb nuldev null dev close
 fdb nuldrd null device read
 fdb nuldwr null device write
 fdb nuldev null special
* floppy disk (character)
 fdb fchop fd open
 fdb fchcl fd close
 fdb fchrd fd read
 fdb fchwr fd write
 fdb fchsp fd special
* 5" winchester character drivers
 fdb wincop win open
 fdb winccl win close
 fdb wincrd win read
 fdb wincwr win write
 fdb wincsp special
 if USE_SPR
* serial printer drivers
 fdb spopn serial open
 fdb spcls serial close
 fdb nodev serial read
 fdb spwrt serial write
 fdb spspc special
 else
 fdb nodev serial open
 fdb nodev serial close
 fdb nodev serial read
 fdb nodev serial write
 fdb nodev special
 endif
 if USE_PPR
* parallel printer driver
 fdb ppopn parallel open
 fdb ppcls parallel close
 fdb nodev parallel read
 fdb ppwrt parallel write
 fdb nuldev special
 else
 fdb nodev parallel open
 fdb nodev parallel close
 fdb nodev parallel read
 fdb nodev parallel write
 fdb nodev special
 endif
*
CHRDEV equ (*-chrtab)/DEVSIZ

* Block device table

blktab
 fdb BDopen,BD0open open routine
 fdb BDclose,BD0close close routine
 fdb BDio,BD0io main io routine
 fdb dmfdt device table pointer
 fcb BD0max
*
BLKDEV equ (*-blktab)/BLKSIZ

* Block Device 0 Open table
BD0open
DMF2minor equ (*-BD0open)/2 Minor Device for DMF2 Floppies
DMF2major equ 0
FD_8 equ DMF2minor
 fdb dmfopn fd0 8"
 fdb dmfopn fd1 8"
 fdb dmfopn fd2 8"
 fdb dmfopn fd3 8"
FD_5_40 equ (*-BD0open)/2
 fdb dmfopn fd0 5"/40 tracks
 fdb dmfopn fd1 5"/40 tracks
 fdb dmfopn fd2 5"/40 tracks
 fdb dmfopn fd3 5"/40 tracks
FD_5_80 equ (*-BD0open)/2
 fdb dmfopn fd0 5"/80 tracks
 fdb dmfopn fd1 5"/80 tracks
 fdb dmfopn fd2 5"/80 tracks
 fdb dmfopn fd3 5"/80 tracks
WINminor equ (*-BD0open)/2
WINmajor equ 0
 fdb winopen hd0
 fdb winopen hd1
BD0max equ (*-BD0open)/2

* Block Device 0 Close Table
BD0close
 fdb dmfcls fd0
 fdb dmfcls fd1
 fdb dmfcls fd2
 fdb dmfcls fd3
 fdb dmfcls fd0
 fdb dmfcls fd1
 fdb dmfcls fd2
 fdb dmfcls fd3
 fdb dmfcls fd0
 fdb dmfcls fd1
 fdb dmfcls fd2
 fdb dmfcls fd3
 fdb winclose hd0
 fdb winclose hd1

* Block Device 0 I/O Table
BD0io
 fdb dmfio fd0
 fdb dmfio fd1
 fdb dmfio fd2
 fdb dmfio fd3
 fdb dmfio fd0
 fdb dmfio fd1
 fdb dmfio fd2
 fdb dmfio fd3
 fdb dmfio fd0
 fdb dmfio fd1
 fdb dmfio fd2
 fdb dmfio fd3
 fdb winsto hd0
 fdb winsto hd1

*
* Device Tables
*
dmfdt rzb DVTSIZ device table
windt equ dmfdt

*
* Floppy disk time-out stuff
*
FD5time equ 50 5.0 seconds
FD5cnt fcb 0

* buffer header for character device

fchbuf rzb HDRSIZ buffer header

 if USE_SPR
*
* Tables for serial printers
*

SPBFSZ equ 100 buffer size

* tables and buffers

sptabl fdb spbf0 buffer 0
 fdb SRLPRT0 acia 0
 fdb spbf1 buffer 1
 fdb SRLPRT1 acia 1
SPMAX equ (*-sptabl)/4-1

spbf0 rzb SPBFSZ buffer 0
spbf1 rzb SPBFSZ buffer 1

* structure storage

spstrc rzb (SPMAX+1)*SPSZ
 endif

 if USE_PPR
*
* Tables for Parallel Printers
*

PPstr
 fdb PIA0 PIA address
 fcb 0 Character count
 fcb 0 Busy flag
 fdb 0,0 Queue pointers
 rzb PPBUFSIZ actual buffer
*
PPMAX equ (*-PPstr)/PPSIZ-1
 endif
