]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/commitdiff
Add TCGETA, TCSETA
authorLeo C <erbl259-lmu@yahoo.de>
Fri, 6 Nov 2015 18:13:42 +0000 (19:13 +0100)
committerLeo C <erbl259-lmu@yahoo.de>
Mon, 13 Jun 2016 16:21:20 +0000 (18:21 +0200)
cbios/Makefile
cbios/ascii.180
cbios/bioskrnl.180
cbios/chario.180
cbios/config.inc
cbios/ioctl.inc
cbios/mm.180
cbios/utils.180

index fafba284a5464d8573e0233b375713a7c806f16c..6d01deca8736433149ccbd48e7b0e518530aba15 100644 (file)
@@ -7,7 +7,7 @@ SRC += sdio.180 cfio.180
 SRC += scb.180
 ALLSRC := $(SRC) ldrbios.180
 
-INC := config.inc z180reg.inc z180.lib
+INC := config.inc z180reg.inc z180.lib ioctl.inc
 
 
 OBJ := $(SRC:.180=.rel)
index cb485508ce2fe7b3fa17c83028bafde189414db9..2581bf539b714103d89b1fd961b6e88412aa9a5b 100644 (file)
@@ -4,19 +4,22 @@
 \r
        global  as0_dev,as1_dev\r
 \r
-       extrn   as_init\r
+       extrn   @ctbl,f_cpu\r
        extrn   ff_empty,ff_get,ff_full,ff_put\r
        extrn   ff_puth,ff_cnt,ff_gech\r
        extrn   bufinit\r
-       extrn   isv_sw,ijphl,add_hla\r
+       extrn   isv_sw,ijphl,add_hla,div32_r\r
+       extrn   b_st_a,b_ld_a\r
 \r
 \r
 \r
-       include config.inc\r
-       include ioctl.inc\r
-       include z180reg.inc\r
+       maclib z180reg.inc\r
+       maclib config.inc\r
+       maclib ioctl.inc\r
+       maclib modebaud.inc\r
 \r
 \r
+       m2b     mbxon_bit,mb$xon$xoff\r
 \r
 ;-----------------------------------------------------\r
 \r
        dw      asci0_ista\r
        dw      asci_ioctl\r
 as0_dev:\r
-       db      0\r
-       db      0\r
-       db      0\r
-       db      0\r
-       db      0\r
+       db      0                       ;absolute device #\r
+       db      0                       ;relative device\r
+       db      0                       ;iflags\r
+       db      0                       ;fflags\r
+       db      M_CS8                   ;cflags\r
 o.absdev       equ     0\r
 o.reldev       equ     1\r
-o.cflags       equ     2\r
-o.iflags       equ     3\r
-o.fflags       equ     4\r
+o.iflags       equ     2\r
+o.fflags       equ     3\r
+o.cflags       equ     4\r
+\r
+       db      0\r
+       db      0\r
+oint.iflags    equ     as0_dev+o.iflags-s0.inbuf\r
+oint.fflags    equ     as0_dev+o.fflags-s0.inbuf\r
+       mkbuf   s0.rx_id, s0.inbuf, s0.rx_len\r
+       mkbuf   s0.tx_id, s0.outbuf,s0.tx_len\r
+\r
 \r
        dw      asci1_out\r
        dw      asci1_osta\r
@@ -45,20 +56,14 @@ o.fflags    equ     4
        dw      asci1_ista\r
        dw      asci_ioctl\r
 as1_dev:\r
-       db      0\r
-       db      1\r
-       db      0\r
-       db      0\r
-       db      0\r
+       db      0                       ;absolute device #\r
+       db      1                       ;relative device\r
+       db      0                       ;iflags\r
+       db      0                       ;fflags\r
+       db      M_CS8                   ;cflags\r
 \r
-\r
-\r
-o.in_flags     equ     $-s0.inbuf\r
        db      0\r
-o.in_flow      equ     $-s0.inbuf\r
        db      0\r
-       mkbuf   s0.rx_id, s0.inbuf, s0.rx_len\r
-       mkbuf   s0.tx_id, s0.outbuf,s0.tx_len\r
        mkbuf   s1.rx_id, s1.inbuf, s1.rx_len\r
        mkbuf   s1.tx_id, s1.outbuf,s1.tx_len\r
 \r
@@ -68,10 +73,30 @@ o.in_flow   equ     $-s0.inbuf
 \r
 \r
 ioctl_ftab:\r
-       dw      cinit\r
+       dw      func_tcinit             ;(00h) CP/M 3 DEVINI function\r
+       dw      func_tcgeta             ;(01h) Get the current serial port settings.\r
+       dw      func_tcseta             ;(02h) Set the current serial port settings.\r
+       dw      func_tcsetaw            ;(03h) Allow the output buffer to drain\r
+       dw      func_tcsetaf            ;(04h) Allow the output buffer to drain, discard pending input\r
+       dw      func_tcsbrk             ;(05h) Sending a break (250ms .. 500ms)\r
+       dw      func_tcsbrkp            ;(06h) arg is timeinterval in 0.1sec\r
+       dw      func_tiocsbrk           ;(07h) Turn break on\r
+       dw      func_tioccbrk           ;(08h) Turn break off\r
+       dw      func_tcxonc             ;(09h) Software flow control (TCOOFF, TCOON, TCIOFF, TCION)\r
+       dw      func_tcflsh             ;(0Ah) Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)\r
+       dw      func_fionread           ;(0Bh) Get the number of bytes in the input buffer.\r
+       dw      func_tiocoutq           ;(0Ch) Get the number of bytes in the output buffer.\r
+       dw      func_tiocmget           ;(0Dh) get the status of modem bits.\r
+       dw      func_tiocmbis           ;(0Eh) set the indicated modem bits.\r
+       dw      func_tiocmbic           ;(0Fh) clear the indicated modem bits.\r
+       dw      func_tiocmset           ;(10h) set the status of modem bits.\r
+       dw      func_tiocgsoftcar       ;(11h) Get the status of the CLOCAL flag in the c_cflag field\r
+       dw      func_tiocssoftcar       ;(12h) Set the CLOCAL flag when  *argp  is nonzero, and clear it otherwise.\r
+\r
 IOCTL_MAX equ  ($-ioctl_ftab)/2\r
        dw      nofunc\r
 \r
+\r
 ;--------------------------------------------------------------\r
 ;\r
 ; b:  device number\r
@@ -98,45 +123,358 @@ asci_ioctl:
        call    ijphl\r
        pop     ix\r
 nofunc:\r
+       or      a\r
        ret\r
 \r
-\r
 ;--------------------------------------------------------------\r
+; CP/M 3 DEVINI function\r
 ; Init Serial I/O for input and output (ASCI 0/1)\r
 \r
-cinit:\r
-       ld      a,stat0\r
-       add     a,(ix+o.reldev)\r
-       ld      c,a\r
-       ld      b,0\r
-       push    bc\r
-       xor     a                       ;\r
-       out     (c),a                   ;Disable rx/tx interrupts\r
+func_tcinit:\r
+       call    asci_stop\r
+\r
+init_st:\r
+       ld      c,asext0                ;Enable baud rate generator\r
+       ld      a,M_BRGMOD+M_DCD0DIS    ; +M_CTS0DIS +M_BREAKEN\r
+       bit     CCTS_OFLOW,(ix+o.fflags)\r
+       jr      nz,$+4\r
+        or     M_CTS0DIS\r
+       call    out_asci_reg\r
 \r
-       ld      c,(ix+o.reldev)\r
        ld      b,(ix+o.absdev)\r
-       call    as_init\r
+       ld      c,8                     ;\r
+       mlt     bc                      ;\r
+       ld      hl,@ctbl+7              ;\r
+       add     hl,bc                   ;\r
+       ld      a,(hl)                  ;get baudrate index\r
+       call    as_br_div\r
+       ld      c,astc0l\r
+       ld      a,l\r
+       call    out_asci_reg\r
+       inc     c\r
+       ld      a,h\r
+       call    out_asci_reg\r
+\r
+\r
+       ld      c,cntlb0\r
+       ld      a,M_MPBT                ;No MP Mode, X16\r
+       bit     PARODD,(ix+o.iflags)\r
+       jr      z,$+4\r
+        or     M_PEO\r
+       call    out_asci_reg\r
+\r
+       ld      c,cntla0\r
+       ld      a,(ix+o.cflags)\r
+       srlan   CS8\r
+       ld      hl,mod_tab\r
+       call    add_hla\r
+       ld      a,(hl)\r
+       or      a,M_RE+M_TE+M_RTS0+M_EFR ;Rx/Tx enable\r
+       call    out_asci_reg\r
+\r
+       push    ix\r
        bit     0,(ix+o.reldev)\r
        jr      nz,init_1\r
        ld      hl,rtxisvjmp0           ;rx/tx int vector\r
        ld      (ivtab + IV$ASCI0),hl   ;\r
-       ld      ix,s0.inbuf\r
-       call    bufinit\r
        ld      ix,s0.outbuf\r
+       call    bufinit\r
+       ld      ix,s0.inbuf\r
        jr      init_2\r
 init_1:\r
        ld      hl,rtxisvjmp1           ;rx/tx int vector\r
        ld      (ivtab + IV$ASCI1),hl   ;\r
-       ld      ix,s1.inbuf\r
-       call    bufinit\r
        ld      ix,s1.outbuf\r
+       call    bufinit\r
+       ld      ix,s1.inbuf\r
 init_2:\r
        call    bufinit\r
-       pop     bc\r
+       pop     ix\r
+       call    asci_start\r
+       ret\r
+\r
+;--------------------------------------------------------------\r
+\r
+mod_tab:\r
+       db      000B                    ; 7N1\r
+       db      100B                    ; 8N1\r
+       db      001B                    ; 7N2\r
+       db      101B                    ; 8N2\r
+       db      010B                    ; 7P1\r
+       db      110B                    ; 8P1\r
+       db      011B                    ; 7P2\r
+       db      111B                    ; 8P2\r
+\r
+\r
+;--------------------------------------------------------------\r
+; Get the current serial port settings.\r
+\r
+func_tcgeta:\r
+       ld      a,d\r
+       or      e\r
+       ld      a,0ffh\r
+       jr      z,fgeta_e\r
+\r
+       ld      a,(ix+o.iflags)\r
+       call    b_st_a\r
+       inc     de\r
+       ld      a,(ix+o.fflags)\r
+       call    b_st_a\r
+       inc     de\r
+\r
+       ld      b,(ix+o.absdev)\r
+       ld      c,8                     ;\r
+       mlt     bc                      ;\r
+       ld      hl,@ctbl+7              ;\r
+       add     hl,bc                   ;\r
+       ld      a,(hl)                  ;get baudrate index\r
+       and     M_CBAUD\r
+       ld      b,a\r
+       ld      a,(ix+o.cflags)\r
+       and     ~M_CBAUD\r
+       or      b\r
+       call    b_st_a\r
+       dec     de\r
+       dec     de\r
+       xor     a\r
+fgeta_e:\r
+       ret\r
+\r
+\r
+;--------------------------------------------------------------\r
+; Set the current serial port settings.\r
+\r
+func_tcseta:\r
+       ld      a,d\r
+       or      e\r
+       ld      a,0ffh\r
+       jr      z,fseta_e\r
+\r
+       call    asci_stop\r
+\r
+       call    b_ld_a\r
+       ld      (ix+o.iflags),a\r
+       inc     de\r
+       call    b_ld_a\r
+       ld      (ix+o.fflags),a\r
+       inc     de\r
+\r
+       ld      b,(ix+o.absdev)\r
+       ld      c,8                     ;\r
+       mlt     bc                      ;\r
+       ld      hl,@ctbl+7              ;\r
+       add     hl,bc                   ;\r
+       call    b_ld_a\r
+       ld      (ix+o.cflags),a\r
+       and     M_CBAUD\r
+       ld      (hl),a                  ;set baudrate index\r
+       dec     de\r
+       dec     de\r
+       push    de\r
+       call    init_st\r
+       pop     de\r
+       xor     a\r
+fseta_e:\r
+       ret\r
+\r
+\r
+;--------------------------------------------------------------\r
+; Allow the output buffer to drain\r
+\r
+func_tcsetaw:\r
+\r
+;--------------------------------------------------------------\r
+; Allow the output buffer to drain, discard pending input\r
+\r
+func_tcsetaf:\r
+\r
+;--------------------------------------------------------------\r
+; Sending a break (250ms .. 500ms)\r
+\r
+func_tcsbrk:\r
+\r
+;--------------------------------------------------------------\r
+; arg is timeinterval in 0.1sec\r
+\r
+func_tcsbrkp:\r
+\r
+;--------------------------------------------------------------\r
+; Turn break on\r
+\r
+func_tiocsbrk:\r
+\r
+;--------------------------------------------------------------\r
+; Turn break off\r
+\r
+func_tioccbrk:\r
+\r
+;--------------------------------------------------------------\r
+; Software flow control (TCOOFF, TCOON, TCIOFF, TCION)\r
+\r
+func_tcxonc:\r
+\r
+;--------------------------------------------------------------\r
+; Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)\r
+\r
+func_tcflsh:\r
+\r
+;--------------------------------------------------------------\r
+; Get the number of bytes in the input buffer.\r
+\r
+func_fionread:\r
+\r
+;--------------------------------------------------------------\r
+; Get the number of bytes in the output buffer.\r
+\r
+func_tiocoutq:\r
+\r
+;--------------------------------------------------------------\r
+; get the status of modem bits.\r
+\r
+func_tiocmget:\r
+\r
+;--------------------------------------------------------------\r
+; set the indicated modem bits.\r
+\r
+func_tiocmbis:\r
+\r
+;--------------------------------------------------------------\r
+; clear the indicated modem bits.\r
+\r
+func_tiocmbic:\r
+\r
+;--------------------------------------------------------------\r
+; set the status of modem bits.\r
+\r
+func_tiocmset:\r
+\r
+;--------------------------------------------------------------\r
+; Get the status of the CLOCAL flag in the c_cflag field\r
+\r
+func_tiocgsoftcar:\r
+\r
+;--------------------------------------------------------------\r
+; Set the CLOCAL flag when  *argp  is nonzero, and clear it otherwise.\r
+\r
+func_tiocssoftcar:\r
+\r
+       or      0ffh\r
+       ret\r
+\r
+;--------------------------------------------------------------\r
+\r
+asci_stop:\r
+       ld      c,stat0                 ;Disable rx/tx interrupts\r
+       xor     a                       ;\r
+       call    out_asci_reg\r
+\r
+       ld      c,cntla0                ;Disable receiver and transmitter\r
+       ld      a,M_RTS0+M_EFR          ;RTS/CKA1\r
+       jr      out_asci_reg\r
+\r
+;--------------------------------------------------------------\r
+\r
+asci_start:\r
+       ld      c,stat0                 ;\r
        ld      a,M_RIE\r
-       out     (c),a                   ;Enable rx interrupts\r
+       jr      out_asci_reg\r
+\r
+;--------------------------------------------------------------\r
+; output to asci0/1 register\r
+;\r
+; c:  register address\r
+; a:  value\r
+;\r
+\r
+out_asci_reg:\r
+       push    bc\r
+       ld      b,a\r
+       ld      a,c\r
+       cp      astc0l                  ;astc0/1 are 16 bit\r
+       jr      c,$+5\r
+        add    a,(ix+o.reldev)\r
+       add     a,(ix+o.reldev)\r
+       ld      c,a\r
+       ld      a,b\r
+       ld      b,0\r
+       out     (c),a\r
+       pop     bc\r
        ret\r
 \r
+;--------------------------------------------------------------\r
+; baud rate divider\r
+;\r
+;   a: index\r
+; return\r
+;   hl: divider\r
+\r
+as_br_div:\r
+       push    de\r
+       push    bc\r
+       and     0fh\r
+       add     a,a                     ;get factor\r
+       ld      hl,bd150_tab\r
+       call    add_hla\r
+       ld      c,(hl)\r
+       inc     hl\r
+       ld      b,(hl)\r
+       ld      hl,(f_cpu)\r
+       ld      de,(f_cpu+2)\r
+       call    div32_r\r
+       ld      bc,32*150\r
+       call    div32_r\r
+       ld      de,2\r
+       or      a\r
+       sbc     hl,de\r
+       pop     bc\r
+       pop     de\r
+       ret     nc\r
+       ld      hl,0\r
+       ret\r
+\r
+bd150_tab:\r
+;              factor          index   baudrate        orig. cp/m\r
+       dw      19200/150       ; 0     19200           -\r
+       dw      28800/150       ; 1     28800           50\r
+       dw      38400/150       ; 2     38400           75\r
+       dw      57600/150       ; 3     57600           110\r
+       dw      11520/15        ; 4     115200          134.5\r
+       dw      150/150         ; 5     150\r
+       dw      300/150         ; 6     300\r
+       dw      600/150         ; 7     600\r
+       dw      1200/150        ; 8     1200\r
+       dw      1800/150        ; 9     1800\r
+       dw      2400/150        ;10     2400\r
+       dw      3600/150        ;11     3600\r
+       dw      4800/150        ;12     4800\r
+       dw      7200/150        ;13     7200\r
+       dw      9600/150        ;14     9600\r
+       dw      19200/150       ;15     19200\r
+\r
+\r
+;--------------------------------------------------------------\r
+\r
+   if 0\r
+\r
+initab0:\r
+       db      1,stat0,0               ;Disable rx/tx interrupts\r
+                                       ;Enable baud rate generator\r
+       db      1,asext0,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS\r
+       db      2,astc0l\r
+init_br_off equ $ - initab0\r
+       dw      28\r
+       db      1,cntlb0,M_MPBT         ;No MP Mode, X16\r
+       db      1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
+       db      0\r
+\r
+initab1:\r
+       db      1,stat1,0               ;Disable rx/tx ints, disable CTS1\r
+       db      1,asext1,M_BRGMOD       ;Enable baud rate generator\r
+       db      2,astc1l,low 3, high 3\r
+       db      1,cntlb1,M_MPBT         ;No MP Mode, X16\r
+       db      1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
+       db      0\r
+   endif\r
 \r
 ;--------------------------------------------------------------\r
 \r
@@ -288,7 +626,7 @@ rxtxi0_lp1:
                                        ;todo: parity, framing overrun error\r
 \r
 \r
-       ld      e,(ix+o.in_flow)\r
+       ld      e,(ix+oint.fflags)\r
        bit     IXON,e\r
        jr      z,rxtxi0_2\r
 \r
index 2a6349429c4294b6e0efb3a1b868091ce851671a..0bb3ecc499b494712790f5781ca45934a090a4b4 100644 (file)
@@ -44,6 +44,7 @@ ccp   equ     0100h           ; Console Command Processor gets loaded
 \r
        extrn ?ci,?co,?cist,?cost       ; each take device in <B>\r
        extrn ?cinit                    ; (re)initialize device in <C>\r
+       extrn ioctl\r
        extrn @ctbl                     ; physical character device table\r
 \r
     ; disk communication data items\r
@@ -63,7 +64,9 @@ ccp   equ     0100h           ; Console Command Processor gets loaded
 \r
        extrn ?time                     ; signal time operation\r
 \r
-       include modebaud.inc            ; define mode bits\r
+       extrn ijphl                     ; vectored call\r
+\r
+       maclib modebaud.inc             ; define mode bits\r
 \r
 \r
     ; External names for BIOS entry points\r
@@ -119,9 +122,10 @@ ccp        equ     0100h           ; Console Command Processor gets loaded
 ?stbnk:        jp      setbnk          ; select different bank for disk I/O DMA operations\r
 ?xmov: jp      ?xmove          ; set source and destination banks for one operation\r
 \r
+       jp      0               ; reserved for system implementor\r
        jp      0               ; reserved for future expansion\r
        jp      0               ; reserved for future expansion\r
-       jp      0               ; reserved for future expansion\r
+?ioctl jp      ioctl           ;\r
 \r
 \r
        ; BOOT\r
@@ -167,7 +171,7 @@ d$init$loop:
        ld      (@ADRV),bc      ; save absolute and relative drive code\r
        ld      l,(ix-4)\r
        ld      h,(ix-3)        ; get init pointer\r
-       call    ipchl           ; call init routine\r
+       call    ijphl           ; call init routine\r
        pop     hl              ; recover @drv pointer\r
 d$init$next:\r
        pop     bc              ; recover counter and drive #\r
@@ -423,12 +427,6 @@ ci$rdy:
 ;-------------------------------------------------------------------------------\r
 ; Utility Subroutines\r
 \r
-\r
-ipchl:         ; vectored CALL point\r
-       jp      (hl)\r
-\r
-\r
-\r
        ; BNKSEL\r
        ;       Bank Select.  Select CPU bank for further execution.\r
 \r
@@ -480,8 +478,7 @@ seldsk:
        inc     hl\r
        ld      h,(hl)\r
        ld      l,a\r
-       call    ipchl           ; call LOGIN\r
-notfirst:\r
+       call    ijphl           ; call LOGIN\r
        ld      hl,(@xdph)      ; recover DPH pointer\r
        ret\r
 \r
index 3451262a9036018601c33d61851e5885a6e6f8bc..c29271d6e9f68fb293b21f1e70bab506050d8664 100644 (file)
@@ -4,15 +4,15 @@
 \r
 \r
 \r
-       public ?cinit,?ci,?co,?cist,?cost\r
+       public ?cinit,ioctl,?ci,?co,?cist,?cost\r
        public @ctbl\r
 \r
        extrn   ff_dev\r
        extrn   as0_dev,as1_dev\r
        extrn   _b0call\r
 \r
-       include config.inc\r
-       include z180reg.inc\r
+       maclib  z180reg.inc\r
+       maclib  config.inc\r
 \r
        include modebaud.inc    ; define mode bits and baud equates\r
 \r
@@ -42,7 +42,7 @@ O_COF equ     -10
 O_COSTF        equ     -8\r
 O_CIF  equ     -6\r
 O_CISTF        equ     -4\r
-O_INITF        equ     -2\r
+O_IOCTLF equ   -2\r
 \r
        dseg\r
 xctbl:\r
@@ -71,14 +71,15 @@ null_dev:
 \r
        cseg\r
 ?cinit:                                ; init devices\r
-       b0call  _cinit\r
+       ld      b,c\r
+       ld      c,0             ;\r
+ioctl:\r
+       b0call  _ioctl\r
        ret\r
 \r
        dseg\r
-_cinit:\r
-       ld      b,c\r
-       ld      hl,O_INITF\r
-       ld      c,0             ;\r
+_ioctl:\r
+       ld      hl,O_IOCTLF\r
        jr      vector_io\r
 \r
 ;--------------------------------------------------------------\r
index fe31e57de1a2fafd789d0ccc8da2580b5bd413e5..9034624cebf2fbd3dae45c041e1f2467c9adee49 100644 (file)
@@ -218,3 +218,49 @@ b0call     macro   address
        call    _b0call\r
        dw      address\r
        endm\r
+\r
+;-----------------------------------------------------\r
+; shift accu right logical n bits\r
+\r
+srlan  macro   n\r
+       if n > 7 or n < 0\r
+        xor a\r
+        exitm\r
+       endif\r
+\r
+       if n > 4\r
+        rept 8-n\r
+         rlca\r
+        endm\r
+        and (1 << (8-n)) - 1\r
+        exitm\r
+       endif\r
+\r
+       if n > 2\r
+        rept n\r
+         rrca\r
+        endm\r
+        and (1 << (8-n)) - 1\r
+        exitm\r
+       endif\r
+\r
+       rept n\r
+        srl a\r
+       endm\r
+       endm\r
+\r
+;-----------------------------------------------------\r
+; convert bit mask to bit number\r
+\r
+m2b    macro   name,mask\r
+       local   n\r
+       n defl  mask\r
+       name defl 0\r
+       rept 8\r
+         n defl n/2\r
+         if n = 0\r
+           exitm\r
+         endif\r
+         name defl name+1\r
+       endm\r
+       endm\r
index d3a7b7b7b814cef6529f98860f5210f5927ee011..8d1f303b9db477770013caa9c87538a9227f1452 100644 (file)
@@ -26,7 +26,7 @@ TIOCGSOFTCAR  equ     11h             ;Get the status of the CLOCAL flag in the c_cflag field
 TIOCSSOFTCAR   equ     12h             ;Set the CLOCAL flag when  *argp  is nonzero, and clear it otherwise.\r
 \r
 \r
-; iflag bits (0)\r
+; iflags bits (0)\r
        b2m     IGNBRK, 0               ;Ignore BREAK condition on input.\r
        b2m     BRKINT, 1\r
        b2m     INPCK,  2               ;Enable input parity checking.\r
@@ -34,7 +34,7 @@ TIOCSSOFTCAR  equ     12h             ;Set the CLOCAL flag when  *argp  is nonzero, and clear it
        b2m     PARMRK, 4               ;Prefix a character with a parity error or framing error with  FFH  00H.\r
        b2m     ISTRIP, 5               ;Strip off eighth bit.\r
        b2m     PARODD, 6               ;If set, then parity for input and output is odd.\r
-; fflag bits (1)\r
+; fflags bits (1)\r
        b2m     IXON,   0               ;Enable XON/XOFF flow control on output.\r
        b2m     IXANY,  1               ;Typing any character will restart stopped output.\r
        b2m     IXOFF,  2               ;Enable XON/XOFF flow control on input.\r
@@ -44,7 +44,7 @@ TIOCSSOFTCAR  equ     12h             ;Set the CLOCAL flag when  *argp  is nonzero, and clear it
        b2m     CREAD,  6               ;Enable receiver.\r
 \r
 \r
-;      control mode flags (2)\r
+; cflags (2)\r
 M_CBAUD                equ     01Fh            ;Baud speed mask\r
  B0            equ     000h            ;hang up\r
  B50           equ     011h\r
@@ -70,8 +70,9 @@ M_CBAUD               equ     01Fh            ;Baud speed mask
  B192000       equ     016h\r
  B288000       equ     017h\r
 M_CSIZE                equ     020h            ;Character size mask.\r
- CS7           equ     000h            ;\r
- CS8           equ     020h            ;\r
+ M_CS7         equ     000h            ;\r
+ M_CS8         equ     020h            ;\r
+ CS8           equ     5               ;\r
        b2m     CSTOPB, 6               ;Set two stop bits, rather than one.\r
        b2m     PARENB, 7               ;Enable parity generation on output and parity checking for input.\r
 \r
index 9f90e0385f94593e49cd2db44132d8fcd0622cab..9df0471a4d6e8404d55dd5b6a694adcf23ccb6d5 100644 (file)
@@ -5,9 +5,15 @@
        public mmuinit
        public bnk2log,bnk2phy,hwl2phy,phy2log
        public isv_sw
+       public b_ld_a,b_ld_hl,b_st_a,b_st_hl
 
-       include config.inc
-       include z180reg.inc
+
+       extrn @cbnk
+       extrn ijphl
+
+
+       maclib z180reg.inc
+       maclib config.inc
 
 
 ;----------------------------------------------------------------------
@@ -353,7 +359,7 @@ isv_sw:                                     ;
        ld      d,(hl)                  ;
        ex      de,hl                   ;
        push    bc                      ;
-       call    jphl                    ;
+       call    ijphl                   ;
 
        pop     bc                      ;
        pop     hl                      ;
@@ -365,15 +371,122 @@ isv_sw:                                  ;
        pop     hl                      ;
        ei                              ;
        ret                             ;
-jphl:
-       jp      (hl)                    ;
 
 
        ds      24
 istack:
 
+       dseg
+
+;--------------------------------------------------------------------
+; Load byte/word from user ram
+;
+;   de:  src address in users bank
+; return
+;    a:  value (byte)
+;   hl:  value (word)
+
+b_ld_a:
+       push    hl
+       or      a               ; clear carry == byte store
+       jr      $+3
+b_ld_hl:
+       scf                     ; set carry == word store
+       push    af              ; save flag
+       push    hl              ; make space on stack
+
+       ld      a,(@cbnk)
+       ld      b,a             ; b = src bank
+
+       ld      hl,0
+       ld      a,l
+       ld      c,l             ; c = dst bank (0)
+       add     hl,sp           ; hl = dst
+       adc     a,1             ; a = count
+       ex      de,hl
+       call    dma_move
+       ex      de,hl
+       pop     hl
+       pop     af
+       ret     c
+       ld      a,l
+       pop     hl
+       ret
+
+;--------------------------------------------------------------------
+; Store byte/word to user ram
+;
+;   de:  dst address in users bank
+;    a:  value (byte)
+;   hl:  value (word)
+
+b_st_a:
+       push    hl
+       ld      l,a
+       or      a               ; clear carry == byte store
+       jr      $+3
+b_st_hl:
+       scf                     ; set carry == word store
+       push    af              ; save flag
+       push    hl              ; put value on stack
+
+       ld      a,(@cbnk)       ;
+       ld      c,a             ; c = dst bank
+       ld      a,0
+       ld      l,a
+       ld      h,a
+       ld      b,a             ; b = src bank (0)
+       add     hl,sp           ; hl = src
+       adc     a,1             ; a = count
+
+       call    dma_move
+
+       pop     hl              ; restore value
+       pop     af              ; carry
+       ret     c
+       pop     hl
+       ret
+
+;--------------------------------------------------------------------
+;
+;    hl: src
+;    de: dst
+;     b: src bank
+;     c: dst bank
+;     a: count
+
+dma_move:
+       out0    (bcr0l),a       ; setup DMA count
+       xor     a
+       out0    (bcr0h),a
+
+       push    hl
+       ld      a,b
+       call    bnk2phy
+       out0    (sar0l),l       ; setup DMA src address
+       out0    (sar0h),h
+       out0    (sar0b),a
+
+       ld      l,e
+       ld      h,d
+       ld      a,c
+       call    bnk2phy
+       out0    (dar0l),l       ; setup DMA dst address
+       out0    (dar0h),h
+       out0    (dar0b),a
+
+       ld      a,M_MMOD        ; DMA burst mode
+       out0    (dmode),a
+       ld      a,M_DE0+M_NDWE1 ; enable DMA0
+       out0    (dstat),a       ; move ...
+       pop     hl
+       ret
+
+
 ;====================================================================
 
+       cseg
+
   if 0
 
 ;--------------------------------------------------------------------
index a84d2171ec14e4fed661969c729e223226057c01..1fdb6cafa72ab7ee099fb05db6048585245a70e7 100644 (file)
@@ -1,4 +1,3 @@
-==== BASE ====
        title 'general utility routines'
 
        ; i/o port init routines
@@ -85,12 +84,17 @@ io1_nxt:
 
        pop     bc
        ret
+
+       cseg
+
 ;--------------------------------------------------------------------
 ; vectored CALL point
 
 ijphl:
        jp      (hl)
 
+       dseg
+
 ;--------------------------------------------------------------------
 ; add a to hl
 ;