home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 550b.lha / newser_v2.10 / ioexp.i next >
Text File  |  1991-09-08  |  13KB  |  486 lines

  1. *****************************************************************************
  2. * Program:  newser.i - ©1990 by The Puzzle Factory
  3. * Function: The One & Only master include file for the I/O Expansion board.
  4. *
  5. * Author:   Jeff Lavin
  6. * History:  08/23/90 JL V0.50 Created
  7. *           11/25/90 JL V0.51 Started to add parallel stuff
  8. *           12/10/90 JL V0.51 Added some more parallel stuff
  9. *
  10. * [To all: Please don't forget to bump the revision numbers if you do *any*
  11. *          modifications at all.  -Jeff]
  12. *
  13. *****************************************************************************
  14. *
  15. * Some of the following is:
  16. *
  17. *****************************************************************************
  18. *
  19. * Copyright (C) 1985, Commodore Amiga Inc.  All rights reserved.
  20. * Permission granted for non-commercial use
  21. *
  22. * asmsupp.i -- random low level assembly support routines
  23. *              used by the Commodore sample Library & Device
  24. *
  25. *****************************************************************************
  26.  
  27. ;Set Tabs           |       |                 |       |
  28.  
  29.     ifeq    __M68
  30.     fail    "Using the wrong assembler!"
  31.     endc
  32.  
  33. INFO_LEVEL    equ    0    ;Assembly-time options
  34.  
  35. ;Put a message to the serial port at 9600 baud.  Used as so:
  36. ;
  37. ;    PUTDEBUG   30,<'%s/Init: called'>
  38. ;
  39. ;Parameters can be printed out by pushing them on the stack and
  40. ;adding the appropriate C printf-style % formatting commands.
  41.  
  42. PUTDEBUG     macro        ;[level,msg]
  43.     ifge    INFO_LEVEL-\1
  44.     pea    (subSysName,pc)
  45.     movem.l a0/a1/d0/d1,-(sp)
  46.     lea    (msg\@,pc),a0    ;Point to static format string
  47.     lea    (4*4,sp),a1    ;Point to args
  48.     bsr    KPutFmt
  49.     movem.l (sp)+,d0/d1/a0/a1
  50.     addq.l    #4,sp
  51.     bra.b    end\@
  52.  
  53. msg\@    cstr    \2,10
  54.     even
  55. end\@
  56.     endc
  57.     endm
  58.  
  59. *****************************************************************************
  60. *
  61. * Here are the includes for the serial portion of the I/O Expansion Board.
  62. * Everything from here to the end of the file is:
  63. *
  64. *      Copyright (C) 1990 by Jeff Lavin  --  All rights reserved.
  65. *      Permission granted for non-commercial use.
  66. *
  67. *****************************************************************************
  68.  
  69. *** MACROS ***
  70.  
  71.     ifnd    SYS
  72. SYS    macro
  73.     jsr    (_LVO\1,a6)
  74.     endm
  75.     endc
  76.  
  77. EXEC    macro
  78.     move.l    a1,-(sp)
  79.     move.l    a6,-(sp)
  80.     movea.l    (SysBase).w,a6
  81.     jsr    (_LVO\1,a6)
  82.     movea.l    (sp)+,a6
  83.     movea.l    (sp)+,a1
  84.     endm
  85.  
  86. Disable    macro
  87.     ifc    '\1',''
  88.     move.w    #INTF_INTEN,(_intena).l
  89.     move.l    a6,-(sp)
  90.     movea.l    (SysBase).w,a6
  91.     addq.b    #1,(IDNestCnt,a6)
  92.     movea.l    (sp)+,a6
  93.     endc
  94.     ifnc    '\1',''
  95.     movea.l    (SysBase).w,\1
  96.     move.w    #INTF_INTEN,(_intena).l
  97.     addq.b    #1,(IDNestCnt,\1)
  98.     endc
  99.     endm
  100.  
  101. Enable    macro
  102.     ifc    '\1',''
  103.     move.l    a6,-(sp)
  104.     movea.l    (SysBase).w,a6
  105.     subq.b    #1,(IDNestCnt,a6)
  106.     movea.l    (sp)+,a6
  107.     bge.s    .Enable\#
  108.     move.w    #INTF_SETCLR!INTF_INTEN,(_intena).l
  109. .Enable\#
  110.     endc
  111.     ifnc    '\1',''
  112.     movea.l    (SysBase).w,\1
  113.     subq.b    #1,(IDNestCnt,\1)
  114.     bge.s    .Enable\#
  115.     move.w    #INTF_SETCLR!INTF_INTEN,(_intena).l
  116. .Enable\#
  117.     endc
  118.     endm
  119.  
  120. Forbid    macro
  121.     move.l    a6,-(sp)
  122.     movea.l    (SysBase).w,a6
  123.     addq.b    #1,(TDNestCnt,a6)
  124.     movea.l    (sp)+,a6
  125.     endm
  126.  
  127. Permit    macro
  128.     movem.l    d0/d1/a0/a1/a6,-(sp)
  129.     movea.l    (SysBase).w,a6
  130.     SYS    Permit
  131.     movem.l    (sp)+,d0/d1/a0/a1/a6
  132.     endm
  133.  
  134. PREFFILE    macro
  135.     cstr    'S:Serial-Preferences'
  136.     even
  137.     endm
  138.  
  139. MYDEVNAME    macro
  140.     cstr    'newser.device'
  141.     even
  142.     endm
  143.  
  144.  
  145. MYIDENT    macro
  146.     cstr    'newser alpha test version 1.0 (17 Aug 1990)',13,10
  147.     even
  148.     endm
  149.  
  150. MYUNITNAME1         macro
  151.     cstr    'SER1:'
  152.     even
  153.     endm
  154.  
  155. MYUNITNAME2         macro
  156.     cstr    'SER2:'
  157.     even
  158.     endm
  159.  
  160. MYUNITNAME3         macro
  161.     cstr    'SER3:'
  162.     even
  163.     endm
  164.  
  165. MYUNITNAME4         macro
  166.     cstr    'SER4:'
  167.     even
  168.     endm
  169.  
  170. PARDEVNAME    macro
  171.     cstr    'eightbit.device'
  172.     even
  173.     endm
  174.  
  175.  
  176. PARIDENT    macro
  177.     cstr    'eightbit alpha test version 1.0 (10 Dec 1990)',13,10
  178.     even
  179.     endm
  180.  
  181. PARUNITNAME1    macro
  182.     cstr    'PAR1:'
  183.     even
  184.     endm
  185.  
  186. PARUNITNAME2    macro
  187.     cstr    'PAR2:'
  188.     even
  189.     endm
  190.  
  191. PARUNITNAME3    macro
  192.     cstr    'PAR3:'
  193.     even
  194.     endm
  195.  
  196. PARUNITNAME4    macro
  197.     cstr    'PAR4:'
  198.     even
  199.     endm
  200.  
  201. *** EQUATES ***
  202.  
  203.     ifnd    SysBase
  204. SysBase    equ    4
  205.     endc
  206.  
  207. MYPROCSTACKSIZE    equ    $900    ;Stack size for the task we will create
  208.  
  209. MYPRI    equ    0    ;Used for configuring the roms
  210.  
  211. VERSION    equ    1    ;A major version number.
  212.  
  213. REVISION    equ    0    ;A particular revision
  214.  
  215. MYDEV_END    equ    CMD_NONSTD+2    ;Number of device comands 
  216.  
  217. MD_NUMUNITS    equ    4    ;Maximum number of units in this device
  218.  
  219. *** New SerialPrefs Structure ***
  220.  
  221. UnitPrefs    clrso
  222. up_BufSize    so.w    1    ;0 to 7
  223. up_BaudRate    so.w    1    ;0 to 15
  224. up_WordLen    so.b    1    ;0=5, 1=6, 2=7, 3=8
  225. up_StopBits    so.b    1    ;0=1, 1=2
  226. up_Parity    so.b    1    ;0=Odd, 1=Even, 2=Mark, 3=Space, 4=None
  227. up_Shake    so.b    1    ;0=RTS/CTS, 1=xON/xOFF
  228. up_Sizeof    soval
  229.  
  230. SerialPrefs    clrso
  231. sp_Unit01    so.b    up_Sizeof    ;For ACIA 0, Unit 1
  232. sp_Unit02    so.b    up_Sizeof    ;For ACIA 0, Unit 2
  233. sp_Unit11    so.b    up_Sizeof    ;For ACIA 1, Unit 1
  234. sp_Unit12    so.b    up_Sizeof    ;For ACIA 1, Unit 2
  235. ;;;sp_Sizeof    soval
  236.  
  237. serprefs    clrso
  238. prefs_CTLCHAR    so.l    1    ;Control char's (order = xON,xOFF,rsvd,rsvd)
  239. prefs_RBUFLEN    so.l    1    ;Length in bytes of serial port's read buffer
  240. prefs_EXTFLAGS    so.l    1    ;Additional serial flags
  241. prefs_BAUD    so.l    1    ;Baud rate requested (true baud)
  242. prefs_BRKTIME    so.l    1    ;Duration of break signal in MICROseconds
  243. prefs_TERMARRAY    so.b    TERMARRAY_SIZE    ;Termination character array
  244. prefs_READLEN    so.b    1    ;Bits per read char (bit count)
  245. prefs_WRITELEN    so.b    1    ;Bits per write char (bit count)
  246. prefs_STOPBITS    so.b    1    ;Stopbits for read (count)
  247. prefs_SERFLAGS    so.b    1    ;See SERFLAGS bit definitions
  248. serprefs_sizeof    soval
  249.  
  250. MyDev    setso    LIB_SIZE
  251. md_Flags    so.b    1
  252. md_Pad1    so.b    1
  253. md_SysLib    so.l    1
  254. md_SegList    so.l    1
  255. md_Units    so.b    MD_NUMUNITS*4
  256. prefs_unit0    so.b    serprefs_sizeof    ;The reason why prefs are in this
  257. prefs_unit1    so.b    serprefs_sizeof    ;structure instead of the unit structure
  258. prefs_unit2    so.b    serprefs_sizeof    ;is that the pref settings should be saved
  259. prefs_unit3    so.b    serprefs_sizeof    ;across CloseDevice calls (which usually
  260. MyDev_Sizeof    soval        ;causes the unit to be dumped).
  261.  
  262. MyDevUnit    setso    UNIT_SIZE    ;Odd # longwords
  263. mdu_wport    so.b    MP_SIZE    ;MsgPort for write task
  264. MDU_FLAGS    so.b    1
  265. IERstate    so.b    1    ;Current state of IER used as a mask
  266. mdu_UnitNum    so.b    1
  267. frstate    so.b    1    ;This var mirrors a write-only register
  268. mdu_SysLib    so.l    1    ;Copy of location 4
  269. mdu_Device    so.l    1    ;Ptr to main device struct
  270. mdu_rstack    so.b    MYPROCSTACKSIZE    ;For read task
  271. mdu_wstack    so.b    MYPROCSTACKSIZE    ;For write task
  272. mdu_rtcb    so.b    TC_SIZE    ;Task Control Block (TCB) for read task
  273. mdu_wtcb    so.b    TC_SIZE    ;Task Control Block (TCB) for write task
  274. mdu_is    so.b    IS_SIZE    ;Interrupt structure
  275. timerport    so.b    MP_SIZE
  276. timeriorequest    so.b    IOTV_SIZE
  277. AltBuf    so.b    64    ;64-byte alternate buffer
  278. readsig    so.l    1    ;Read task signals
  279. readabortsig    so.l    1
  280. tdresig    so.l    1    ;Transmit buffer empty - put another byte
  281. dsrsig    so.l    1    ;Transition on DSR - used for handshaking (if enabled)
  282. writeabortsig    so.l    1
  283. xonsig    so.l    1    ;Comes from read task, and indicates xon received
  284. breaksig    so.l    1    ;This is an Exec exception signal
  285. head    so.l    1    ;Ptr to start of circular buffer (logical)
  286. tail    so.l    1    ;Ptr to end of circular buffer (logical)
  287. startbuf    so.l    1    ;Ptr to physical start of input buffer
  288. endbuf    so.l    1    ;Ptr to physical end of input buffer
  289. ReadRequestPtr    so.l    1
  290. WriteRequestPtr    so.l    1
  291. breakiorequest    so.l    1
  292. xstate    so.b    1    ;Zero if 'x-off' received, else $FF
  293. ISRcopy    so.b    1    ;Used for read error diagnosis
  294. CSRcopy    so.b    1    ;Used for read error diagnosis
  295. Exclusive    so.b    1    ;True if someone has exclusive access to this unit
  296. daciabase    so.l    1
  297. mdu_prefs    so.l    1    ;Ptr to prefs for this unit (in MyDev)
  298. MyDevUnit_Sizeof    soval
  299.  
  300. ;Note that we have a single unit structure used by both the read and write
  301. ;tasks (and the interrupt routine).
  302.  
  303. * UNIT_FLAG definitions:
  304.  
  305.     BITDEF    UNIT,INREADTASK,0    
  306.     BITDEF    UNIT,INWRITETASK,1
  307.     BITDEF    UNIT,READACTIVE,2
  308.     BITDEF    UNIT,WRITEACTIVE,3
  309.     BITDEF    UNIT,BREAKACTIVE,4
  310.     BITDEF    UNIT,INBREAK,5
  311.  
  312. ;INBREAK is used by the queued break routine to protect against immediate breaks
  313. ;(a rather unlikely scenereo, but it might happen; who knows?)
  314.  
  315. * Bit definitions for MDU_FLAGS
  316.  
  317.     BITDEF    MDU,STOPPED,2    ;State bit for unit stopped
  318.     BITDEF    MDU,V,3    ;Buffer overflow flag - set in int routine if an overflow occurs
  319.  
  320. * Bit definitions for ioflags
  321.  
  322.     BITDEF    ioflags,Active,4    ;IO request in progress
  323.     BITDEF    ioflags,Ignore,5    ;Ignore this IO request
  324.  
  325. * Equates & bit defs for IERstate
  326.  
  327. READINT    equ    $87
  328. READINTMASK    equ    $7
  329.  
  330. HANDINT    equ    $88
  331. HANDINTMASK    equ    $8
  332.  
  333. WRITEINT    equ    $C0
  334. WRITEINTMASK    equ    $40
  335.  
  336. WRITEOFF    equ    $40
  337. WRITEOFFMASK    equ    $BF
  338.  
  339. *** The Hardware ***
  340.  
  341. ;_custom    equ    $DFF000
  342. ;_intena    equ    _custom+intena
  343.  
  344. ;The ACIAs are located at $400 byte boundaries beginning at ACIA_Base:
  345. ;
  346. ; Unit1    equ    $BF9000    ;65C52 DACIA chip 1, unit 1
  347. ; Unit2    equ    $BF9400    ;65C52 DACIA chip 1, unit 2
  348. ; Unit3    equ    $BF9800    ;65C52 DACIA chip 2, unit 1
  349. ; Unit4    equ    $BF9C00    ;65C52 DACIA chip 2, unit 2
  350.  
  351. ACIA_Base    equ    $BF9000    ;Base address of all units
  352. ACIA0    equ    $0000    ;Offset of 1st chip
  353. ACIA1    equ    $0800    ;Offset of 2nd chip
  354. UNIT2    equ    $0400    ;Offset of 2nd unit
  355.  
  356. IER    equ    $0000    ;Interrupt Enable Register
  357. ISR    equ    $0000    ;Interrupt Status Register
  358. CTR    equ    $0100    ;Control Register
  359. FMR    equ    $0100    ;Format Register
  360. CSR    equ    $0100    ;Control Status Register
  361. CDR    equ    $0200    ;Compare Data Register
  362. ACR    equ    $0200    ;Auxilliary Control Register
  363. TDR    equ    $0300    ;Transmit Data Register
  364. RDR    equ    $0300    ;Receive Data Register
  365.  
  366. * Interrupt Status Registers (ISR1=0, ISR2=4) Read only
  367.  
  368.     BITDEF    ISR,SETCLR,7    ;Any bit set
  369.     BITDEF    ISR,TDRE,6    ;Transmit Data Register Empty
  370.     BITDEF    ISR,CTST,5    ;Transition on *CTS Line
  371.     BITDEF    ISR,DCDT,4    ;Transition on *DCD Line
  372.     BITDEF    ISR,DSRT,3    ;Transition on *DSR Line
  373.     BITDEF    ISR,PAR,2    ;Parity status
  374.     BITDEF    ISR,FEOB,1    ;Frame error, Overrun, Break
  375.     BITDEF    ISR,RDRF,0    ;Receive Data Register Full
  376.  
  377. * Interrupt Enable Registers (IER1=0, IER2=4) Write only
  378.  
  379.     BITDEF    IER,SETCLR,7    ;Same as above
  380.     BITDEF    IER,TDRE,6
  381.     BITDEF    IER,CTST,5
  382.     BITDEF    IER,DCDT,4
  383.     BITDEF    IER,DSRT,3
  384.     BITDEF    IER,PAR,2
  385.     BITDEF    IER,FEOB,1
  386.     BITDEF    IER,RDRF,0
  387.  
  388. * Control Status Registers (CSR1=1, CSR2=5) Read only
  389.  
  390.     BITDEF    CSR,FE,7    ;Framing Error
  391.     BITDEF    CSR,TUR,6    ;Transmitter Underrun
  392.     BITDEF    CSR,CTSL,5    ;*CTS Level
  393.     BITDEF    CSR,DCDL,4    ;*DCD Level
  394.     BITDEF    CSR,DSRL,3    ;*DSR Level
  395.     BITDEF    CSR,RBRK,2    ;Receive Break
  396.     BITDEF    CSR,DTRL,1    ;*DTR Level
  397.     BITDEF    CSR,RTSL,0    ;*RTS Level
  398.  
  399. * Control Registers (CR1=1, CR2=5) Write only
  400.  
  401.     BITDEF    CR,CTRL,7    ;1=Access FMR,  0=Access CTR
  402.     BITDEF    CR,AUX,6    ;1=Access ACR,  0=Access CDR
  403.     BITDEF    CR,STOP2,5    ;1=2 stop bits, 0=1 stop bit
  404.     BITDEF    CR,ECHO,4    ;1=Echo mode,   0=Echo mode disabled
  405.  
  406.  comment |
  407. Baud_50    equ    %00000000    ;Bits 3-0
  408. Baud_110    equ    %00000001
  409. Baud_134    equ    %00000010
  410. Baud_150    equ    %00000011
  411. Baud_300    equ    %00000100
  412. Baud_600    equ    %00000101
  413. Baud_1200    equ    %00000110
  414. Baud_1800    equ    %00000111
  415. Baud_2400    equ    %00001000
  416. Baud_3600    equ    %00001001
  417. Baud_4800    equ    %00001010
  418. Baud_7200    equ    %00001011
  419. Baud_9600    equ    %00001100
  420. Baud_19200    equ    %00001101
  421. Baud_38400    equ    %00001110
  422. Baud_EXT    equ    %00001111
  423. |
  424.  
  425. * Format Registers (FR1=1, FR2=5) Write only
  426.  
  427.     BITDEF    FR,FRMT,7    ;1=Access FR, 0=Access CR
  428.  
  429. WORDLEN_5    equ    %00000000    ;Bits 5-6
  430. WORDLEN_6    equ    %00100000
  431. WORDLEN_7    equ    %01000000
  432. WORDLEN_8    equ    %01100000
  433.  
  434. PAR_ODD    equ    %00000000    ;Bits 3-4
  435. PAR_EVEN    equ    %00001000
  436. PAR_MARK    equ    %00010000
  437. PAR_SPACE    equ    %00011000
  438.  
  439.     BITDEF    FR,PAR,2    ;1=Parity as specified in bits 3-4
  440.     BITDEF    FR,DTR,1    ;1=Set DTR hi, 0=Set DTR lo
  441.     BITDEF    FR,RTS,0    ;1=Set RTS hi, 0=Set RTS lo
  442.  
  443. * Compare Data Register  (CDR1=2, CDR2=6) Write only
  444.  
  445. ;Bit 6 of Control Register must be 0.  By writing a value into this
  446. ;register, the DACIA is put into the compare mode.  In this mode the Receive
  447. ;Data Register Full bit is inhibited until a character is received that
  448. ;matches the value in this register.  The next character is then received
  449. ;normally.
  450.  
  451. * Auxiliary Control Registers (ACR1=2, ACR2=6) Write only
  452.  
  453. ;Bit 6 of Control Register must be 1.
  454.  
  455.     BITDEF    ACR,BRK,1    ;Transmit break
  456.     BITDEF    ACR,ARM,0    ;Address recognition mode
  457.  
  458. *****************************************************************************
  459. *
  460. * Here are the includes for the parallel portion of the I/O Expansion Board.
  461. *
  462. *****************************************************************************
  463.  
  464. VIA_Base    equ    $BF1000    ;Base address of all units
  465. VIA0    equ    $0000    ;VIA #0 Base offset
  466. VIA1    equ    $4000    ;VIA #1 Base offset
  467.  
  468. ORB    equ    $0000    ;I/O Register B
  469. ORA    equ    $0100    ;I/O Register A
  470. DDRB    equ    $0200    ;Data Direction Register B
  471. DDRA    equ    $0300    ;Data Direction Register A
  472. T1CL    equ    $0400    ;Timer #1 Counter (lower 8 bits)
  473. T1CH    equ    $0500    ;Timer #1 Counter (upper 8 bits)
  474. T1LL    equ    $0600    ;Timer #1 Latch (lower 8 bits)
  475. T1LH    equ    $0700    ;Timer #1 Latch (upper 8 bits)
  476. T2CL    equ    $0800    ;Timer #2 Counter (lower 8 bits)
  477. T2CH    equ    $0900    ;Timer #2 Counter (upper 8 bits)
  478. SHFTR    equ    $0A00    ;Shift Register
  479. AUXCR    equ    $0B00    ;Auxiliary Control Register
  480. PERCR    equ    $0C00    ;Peripheral Control Register
  481. INTFR    equ    $0D00    ;Interrupt Flag Register
  482. INTER    equ    $0E00    ;Interrupt Enable Register
  483. ORAF    equ    $0F00    ;I/O Register A (no handshake)
  484.  
  485. ;End of File
  486.