]> cloudbase.mooo.com Git - avrcpm.git/blame - avrcpm/avr/dsk_ram.asm
* Initial changes for FAT16 support.
[avrcpm.git] / avrcpm / avr / dsk_ram.asm
CommitLineData
64219415
FZ
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;\r
22\r
23#ifndef RAMDSK_SUPPORT\r
24 #define RAMDSK_SUPPORT 0 \r
25#endif\r
26\r
27#if RAMDSK_SUPPORT\r
28\r
29;-------------------------------------- Defines for RAMDISK Structures
30\r
31;----------------------------------------------- Start of Data Segment
32
33 .dseg\r
34\r
35rdskbuf: .byte 128 ; Buffer for RAM-Disk interaktions\r
36\r
37; ---------------------------------------------- Start of Code Segment
38 .cseg\r
39
40; ====================================================================\r
41; Function: Calculate an sets the adress of Sector within the RAMDISK
42; ====================================================================\r
43; Parameters\r
44; --------------------------------------------------------------------\r
45; Registers : none\r
46; Variables : [r] seeksec Sector to read\r
47; [r] seektrk Track to read\r
48; [w] temp3 Number of Bytes per Sector (128) \r
49; --------------------------------------------------------------------\r
50; Description:\r
51; ====================================================================\r
52
53
54rdsk_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; ====================================================================\r
83; Function: Does a read opperation on a RAMDISK
84; ====================================================================\r
85; Parameters\r
86; --------------------------------------------------------------------\r
87; Registers : none\r
88; Variables : [r] seeksec Sector to read\r
89; [r] seektrk Track to read\r
90; [r] flags RW operation Flags\r
91; [w] erflag Error Status of the operation\r
92; --------------------------------------------------------------------\r
93; Description:\r
94; ====================================================================\r
95
96
97rdsk_read:
98\r
99.if DISK_DEBUG > 1
100 printnewline
101 printstring "rd-adr: "
102.endif
103 rcall rdsk_adr
104\r
105rdsk_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
133rdsk_rdstl:
134 ld temp,z+
135 mem_write
136 adiw x,1
137 dec temp3
138 brne rdsk_rdstl
139 ret
140
141; ====================================================================\r
142; Function: Does a write opperation on a RAMDISK
143; ====================================================================\r
144; Parameters\r
145; --------------------------------------------------------------------\r
146; Registers : none\r
147; Variables : [r] seeksec Sector to read\r
148; [r] seektrk Track to read\r
149; [r] flags RW operation Flags\r
150; [w] erflag Error Status of the operation\r
151; --------------------------------------------------------------------\r
152; Description:\r
153; ====================================================================\r
154
155rdsk_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
164rdsk_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
174rdsk_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\r
199\r
200\r
201rdsk_add_partition:\r
202 ret\r
203\r
204
205#else\r
206\r
207rdsk_read:\r
208 ret\r
209rdsk_write:\r
210 ret\r
211rdsk_add_partition:\r
212 ret\r
213\r
214#endif\r