]> cloudbase.mooo.com Git - avrcpm.git/commitdiff
* avr/z80.asm:
authorLeo <erbl259-lmu@yahoo.de>
Fri, 6 Aug 2010 10:08:56 +0000 (10:08 +0000)
committerLeo <erbl259-lmu@yahoo.de>
Fri, 6 Aug 2010 10:08:56 +0000 (10:08 +0000)
  - Added a RAM disk

git-svn-id: svn://cu.loc/avr-cpm/trunk@70 57430480-672e-4586-8877-bcf8adbbf3b7

avrcpm/avr/z80.asm

index 4b0e5072f73dc7e28523076766cbb8f7956c2053..2c54babf0017fa4dc0cbf1d14fa4f85783ae5bfa 100644 (file)
@@ -45,6 +45,8 @@
  
 #define PARTID 0x52            /* Partition table id */
                                /* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */
+#define RAMDISKNR 'I'-'A'      /* Driveletter for first RAM disk */
+#define RAMDISKCNT 1           /* Number of RAM disks */
 
 #define UBRR_VAL  ((F_CPU+BAUD*8)/(BAUD*16)-1)  /* clever rounding */
 
 
 
 
+; -------------------- DRAM ---------------
+
+; DRAM_SETADDR val, low_and_mask, low_or_mask, high_and_mask, high_or_mask
+.macro DRAM_SETADDR
+       mov temp,@0
+.if low(@1) != 0xff
+       andi temp,@1
+.endif
+.if  low(@2) != 0
+       ori temp, @2
+.endif
+       out P_AL,temp
+       
+       mov temp,@0
+.if low(@3) != 0xff
+       andi temp,@3
+.endif
+       ori temp, @4 | (1<<mmc_cs)
+       out P_AH,temp
+.endm
+
 ;----------------------------------------
 ; add wait states
 ;      dram_wait  number_of_cycles
@@ -909,8 +932,13 @@ dskDiskCheck:
        lds     temp,seekdsk
        lds     temp2,ndisks    ;check if selected disk # is less then # of disks
        cp      temp,temp2
-       ldi     temp,0
-       brlt    PC+2
+       brlt    dsk_dchend
+       
+       cpi     temp,RAMDISKNR
+       brlt    dsk_dcher
+       cpi     temp,RAMDISKNR+RAMDISKCNT
+       brlt    dsk_dchend
+dsk_dcher:
        ldi     temp,0xff               ;error return
        ret
        
@@ -1028,9 +1056,9 @@ dsk_read:
        sbi     flags,readop            ;read operation
        ;RAM disk?
        lds     temp2,seekdsk
-;      cpi     temp2,RAMDISKNR
-;      brlt    PC+2
-;       rjmp   rdskDoIt
+       cpi     temp2,RAMDISKNR
+       brlt    PC+2
+        rjmp   rdskDoIt
 
        sts     unacnt,_0
        sbi     flags,rsflag            ;must read data
@@ -1046,9 +1074,9 @@ dsk_write:
 
        ;RAM disk?
        lds     temp2,seekdsk
-;      cpi     temp2,RAMDISKNR
-;      brlt    PC+2
-;       rjmp   rdskDoIt
+       cpi     temp2,RAMDISKNR
+       brlt    PC+2
+        rjmp   rdskDoIt
        andi    temp,WRTMSK
        sts     wrtype,temp             ;save write type
 
@@ -1408,6 +1436,144 @@ dsk_rd1:
        ret
 
 
+;***************************************************************************
+; ----------------- RAM disk -----------------
+
+       .dseg
+rdskbuf:
+       .byte   128
+       
+       .cseg
+;----------------------------------------------
+
+rdsk_adr:
+       ldi     xl,0
+       lds     xh,seeksec
+       lds     temp2,seektrk
+       
+       lsr     xh
+       ror     xl                      ;Col 0..7
+       
+       mov     temp,temp2
+       andi    temp,0x0f
+       swap    temp
+       or      xh,temp                 ;Row  0..7
+       
+       ldi     zl,low (rdskbuf)
+       ldi     zh,high(rdskbuf)
+       ldi     temp3,128
+       DRAM_SETADDR xh, ~0,(1<<ram_ras), ~0,(1<<ram_a8)|(1<<ram_oe)
+       cbi     P_RAS,ram_ras
+
+.if DISK_DEBUG
+       mov     temp,xh
+       rcall   printhex
+       rcall   printstr
+       .db     " ",0
+       mov     temp,xl
+       rcall   printhex
+       rcall   printstr
+       .db     " ",0
+.endif
+       ret
+
+;----------------------------------------------
+
+rdskDoIt:
+       sts     erflag,_0
+       sbis    flags,readop
+        rjmp   rdsk_wr
+       
+.if DISK_DEBUG
+       rcall   printstr
+       .db     13,"rd-adr: ",0
+.endif
+       rcall   rdsk_adr
+rdsk_rdl:
+       DRAM_SETADDR xl, ~(1<<ram_ras),0, ~((1<<ram_oe)), (1<<ram_a8)
+       cbi     P_CAS,ram_cas
+       cbi     P_A8,ram_a8
+       inc     xl
+       dram_wait DRAM_WAITSTATES       ;
+       in      temp,P_DQ-2             ; PIN
+       sbi     P_CAS,ram_cas
+
+       cbi     P_CAS,ram_cas
+       andi    temp,0x0f
+       swap    temp
+       dram_wait DRAM_WAITSTATES       ;
+       in      temp2,P_DQ-2    ; PIN
+       andi    temp2,0x0f
+       or      temp,temp2
+
+       sbi     P_OE,ram_oe
+       sbi     P_CAS,ram_cas
+       dec     temp3
+       st      z+,temp
+       brne    rdsk_rdl
+
+       sbi     P_RAS,ram_ras
+       ldi     zl,low (rdskbuf)
+       ldi     zh,high(rdskbuf)
+       lds     xl,dmaadr
+       lds     xh,dmaadr+1
+       ldi     temp3,128       
+rdsk_rdstl:
+       ld      temp,z+
+       rcall   dram_write
+       adiw    x,1
+       dec     temp3
+       brne    rdsk_rdstl
+       ret
+       
+
+rdsk_wr:
+.if DISK_DEBUG
+       rcall   printstr
+       .db     13,"wr-adr: ",0
+.endif 
+       lds     xl,dmaadr
+       lds     xh,dmaadr+1
+       ldi     zl,low (rdskbuf)
+       ldi     zh,high(rdskbuf)
+       ldi     temp3,128       
+rdsk_wrldl:
+       rcall   dram_read
+       st      z+,temp
+       adiw    x,1
+       dec     temp3
+       brne    rdsk_wrldl      
+
+       ldi     temp2,RAM_DQ_MASK | (1<<ram_w) | (1<<ram_cas)
+       out     DDRC,temp2
+       rcall   rdsk_adr
+rdsk_wrl:
+       ld      temp,z+
+       mov     temp2,temp
+       andi    temp,RAM_DQ_MASK & ~(1<<ram_w)
+       ori     temp,(1<<ram_cas)
+       out     PORTC,temp
+       DRAM_SETADDR xl, ~(1<<ram_ras),0, ~((1<<ram_a8)),(1<<ram_oe)
+       cbi     PORTC,ram_cas
+       sbi     PORTD,ram_a8
+       sbi     PORTC,ram_cas
+       swap    temp2
+       andi    temp2,RAM_DQ_MASK & ~(1<<ram_w)
+       ori     temp2,(1<<ram_cas)
+       out     PORTC,temp2
+       cbi     PORTC,ram_cas
+       inc     xl
+       sbi     PORTC,ram_cas
+       dec     temp3
+       brne    rdsk_wrl
+
+       sbi     P_RAS,ram_ras
+       ldi     temp,~RAM_DQ_MASK | (1<<ram_w) | (1<<ram_cas)
+       out     DDRC,temp
+       out     PORTC,temp
+       ret
+       
+
 ;***************************************************************************
 
 ; ----------------- MMC/SD routines ------------------
@@ -1705,25 +1871,6 @@ resetwait:
 
 ; ------------------ DRAM routines -------------
 
-; DRAM_SETADDR val, low_and_mask, low_or_mask, high_and_mask, high_or_mask
-.macro DRAM_SETADDR
-       mov temp,@0
-.if low(@1) != 0xff
-       andi temp,@1
-.endif
-.if  low(@2) != 0
-       ori temp, @2
-.endif
-       out P_AL,temp
-       
-       mov temp,@0
-.if low(@3) != 0xff
-       andi temp,@3
-.endif
-       ori temp, @4 | (1<<mmc_cs)
-       out P_AH,temp
-.endm
-
 ;Loads the byte on address xh:xl into temp.
 ;must not alter xh:xl
 
@@ -2379,7 +2526,7 @@ rxfifo:
 txfifo:
        .byte   TXBUFSIZE
 
-ramtop:                
+ramtop:        .byte   0       
        .cseg
 
 ; Save received character in a circular buffer. Do nothing if buffer overflows.