]> cloudbase.mooo.com Git - avrcpm.git/blob - dsk_ram.asm
git-svn-id: svn://cu.loc/avr-cpm/trunk/avrcpm/avr@114 57430480-672e-4586-8877-bcf8adb...
[avrcpm.git] / dsk_ram.asm
1 ; Various functions for the Interaction with the CPM Filesystem
2 ;
3 ; Copyright (C) 2010 Frank Zoll
4 ;
5 ; This file is part of avrcpm.
6 ;
7 ; avrcpm is free software: you can redistribute it and/or modify it
8 ; under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
11 ;
12 ; avrcpm is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
19 ;
20 ; $Id$
21 ;
22
23 #ifndef RAMDSK_SUPPORT
24 #define RAMDSK_SUPPORT 0
25 #endif
26
27 #if RAMDSK_SUPPORT
28
29 ;-------------------------------------- Defines for RAMDISK Structures
30
31 ;----------------------------------------------- Start of Data Segment
32
33 .dseg
34
35 rdskbuf: .byte 128 ; Buffer for RAM-Disk interaktions
36
37 ; ---------------------------------------------- Start of Code Segment
38 .cseg
39
40 ; ====================================================================
41 ; Function: Calculate an sets the adress of Sector within the RAMDISK
42 ; ====================================================================
43 ; Parameters
44 ; --------------------------------------------------------------------
45 ; Registers : none
46 ; Variables : [r] seeksec Sector to read
47 ; [r] seektrk Track to read
48 ; [w] temp3 Number of Bytes per Sector (128)
49 ; --------------------------------------------------------------------
50 ; Description:
51 ; ====================================================================
52
53
54 rdsk_adr:
55 ldi xl,0
56 lds xh,seeksec
57 lds temp2,seektrk
58
59 lsr xh
60 ror xl ;Col 0..7
61
62 mov temp,temp2
63 andi temp,0x0f
64 swap temp
65 or xh,temp ;Row 0..7
66
67 ldiw z,rdskbuf
68 ldi temp3,128
69 DRAM_SETADDR xh, ~0,(1<<ram_ras), ~0,(1<<ram_a8)|(1<<ram_oe)
70 cbi P_RAS,ram_ras
71
72 .if DISK_DEBUG > 1
73 mov temp,xh
74 rcall printhex
75 printstring " "
76 mov temp,xl
77 rcall printhex
78 printstring " "
79 .endif
80 ret
81
82 ; ====================================================================
83 ; Function: Does a read opperation on a RAMDISK
84 ; ====================================================================
85 ; Parameters
86 ; --------------------------------------------------------------------
87 ; Registers : none
88 ; Variables : [r] seeksec Sector to read
89 ; [r] seektrk Track to read
90 ; [r] flags RW operation Flags
91 ; [w] erflag Error Status of the operation
92 ; --------------------------------------------------------------------
93 ; Description:
94 ; ====================================================================
95
96
97 rdsk_read:
98
99 .if DISK_DEBUG > 1
100 printnewline
101 printstring "rd-adr: "
102 .endif
103 rcall rdsk_adr
104
105 rdsk_rdl:
106 DRAM_SETADDR xl, ~(1<<ram_ras),0, ~((1<<ram_oe)), (1<<ram_a8)
107 cbi P_CAS,ram_cas
108 cbi P_A8,ram_a8
109 inc xl
110 dram_wait DRAM_WAITSTATES ;
111 in temp,P_DQ-2 ; PIN
112 sbi P_CAS,ram_cas
113
114 cbi P_CAS,ram_cas
115 andi temp,0x0f
116 swap temp
117 dram_wait DRAM_WAITSTATES ;
118 in temp2,P_DQ-2 ; PIN
119 andi temp2,0x0f
120 or temp,temp2
121
122 sbi P_OE,ram_oe
123 sbi P_CAS,ram_cas
124 dec temp3
125 st z+,temp
126 brne rdsk_rdl
127
128 sbi P_RAS,ram_ras
129 ldiw z,rdskbuf
130 lds xl,dmaadr
131 lds xh,dmaadr+1
132 ldi temp3,128
133 rdsk_rdstl:
134 ld temp,z+
135 mem_write
136 adiw x,1
137 dec temp3
138 brne rdsk_rdstl
139 ret
140
141 ; ====================================================================
142 ; Function: Does a write opperation on a RAMDISK
143 ; ====================================================================
144 ; Parameters
145 ; --------------------------------------------------------------------
146 ; Registers : none
147 ; Variables : [r] seeksec Sector to read
148 ; [r] seektrk Track to read
149 ; [r] flags RW operation Flags
150 ; [w] erflag Error Status of the operation
151 ; --------------------------------------------------------------------
152 ; Description:
153 ; ====================================================================
154
155 rdsk_write:
156 .if DISK_DEBUG > 1
157 printnewline
158 printstring "wr-adr: "
159 .endif
160 lds xl,dmaadr
161 lds xh,dmaadr+1
162 ldiw z,rdskbuf
163 ldi temp3,128
164 rdsk_wrldl:
165 mem_read
166 st z+,temp
167 adiw x,1
168 dec temp3
169 brne rdsk_wrldl
170
171 ldi temp2,RAM_DQ_MASK | (1<<ram_w) | (1<<ram_cas)
172 out DDRC,temp2
173 rcall rdsk_adr
174 rdsk_wrl:
175 ld temp,z+
176 mov temp2,temp
177 andi temp,RAM_DQ_MASK & ~(1<<ram_w)
178 ori temp,(1<<ram_cas)
179 out PORTC,temp
180 DRAM_SETADDR xl, ~(1<<ram_ras),0, ~((1<<ram_a8)),(1<<ram_oe)
181 cbi PORTC,ram_cas
182 sbi PORTD,ram_a8
183 sbi PORTC,ram_cas
184 swap temp2
185 andi temp2,RAM_DQ_MASK & ~(1<<ram_w)
186 ori temp2,(1<<ram_cas)
187 out PORTC,temp2
188 cbi PORTC,ram_cas
189 inc xl
190 sbi PORTC,ram_cas
191 dec temp3
192 brne rdsk_wrl
193
194 sbi P_RAS,ram_ras
195 ldi temp,~RAM_DQ_MASK | (1<<ram_w) | (1<<ram_cas)
196 out DDRC,temp
197 out PORTC,temp
198 ret
199
200
201 rdsk_add_partition:
202 ret
203
204
205 #else
206
207 rdsk_read:
208 ret
209 rdsk_write:
210 ret
211 rdsk_add_partition:
212 ret
213
214 #endif