Rev 133 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 133 | Rev 147 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; System service for filesystem call ;; |
3 | ;; System service for filesystem call ;; |
4 | ;; (C) 2004 Ville Turjanmaa, License: GPL ;; |
4 | ;; (C) 2004 Ville Turjanmaa, License: GPL ;; |
5 | ;; 29.04.2006 Elimination of hangup after the ;; |
5 | ;; 29.04.2006 Elimination of hangup after the ;; |
6 | ;; expiration hd_wait_timeout (for LBA) - Mario79 ;; |
6 | ;; expiration hd_wait_timeout (for LBA) - Mario79 ;; |
7 | ;; xx.04.2006 LFN support - diamond ;; |
7 | ;; xx.04.2006 LFN support - diamond ;; |
8 | ;; 15.01.2005 get file size/attr/date, file_append (only for hd) - ATV ;; |
8 | ;; 15.01.2005 get file size/attr/date, file_append (only for hd) - ATV ;; |
9 | ;; 23.11.2004 test if hd/partition is set - ATV ;; |
9 | ;; 23.11.2004 test if hd/partition is set - ATV ;; |
10 | ;; 18.11.2004 get_disk_info and more error codes - ATV ;; |
10 | ;; 18.11.2004 get_disk_info and more error codes - ATV ;; |
11 | ;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;; |
11 | ;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;; |
12 | ;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;; |
12 | ;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;; |
13 | ;; ;; |
13 | ;; ;; |
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
15 | 15 | ||
16 | iglobal |
16 | iglobal |
17 | dir0: db 'HARDDISK ' |
17 | dir0: db 'HARDDISK ' |
18 | db 'RAMDISK ' |
18 | db 'RAMDISK ' |
19 | db 'FLOPPYDISK ' |
19 | db 'FLOPPYDISK ' |
20 | db 0 |
20 | db 0 |
21 | 21 | ||
22 | dir1: db 'FIRST ' |
22 | dir1: db 'FIRST ' |
23 | db 'SECOND ' |
23 | db 'SECOND ' |
24 | db 'THIRD ' |
24 | db 'THIRD ' |
25 | db 'FOURTH ' |
25 | db 'FOURTH ' |
26 | db 0 |
26 | db 0 |
27 | 27 | ||
28 | not_select_IDE db 0 |
28 | not_select_IDE db 0 |
29 | 29 | ||
30 | hd_address_table: dd 0x1f0,0x00,0x1f0,0x10 |
30 | hd_address_table: dd 0x1f0,0x00,0x1f0,0x10 |
31 | dd 0x170,0x00,0x170,0x10 |
31 | dd 0x170,0x00,0x170,0x10 |
32 | endg |
32 | endg |
33 | 33 | ||
34 | file_system: |
34 | file_system: |
35 | 35 | ||
36 | ; IN: |
36 | ; IN: |
37 | ; |
37 | ; |
38 | ; eax = 0 ; read file /RamDisk/First 6 |
38 | ; eax = 0 ; read file /RamDisk/First 6 |
39 | ; eax = 1 ; write file /RamDisk/First 33 /HardDisk/First 56 |
39 | ; eax = 1 ; write file /RamDisk/First 33 /HardDisk/First 56 |
40 | ; eax = 2 ; delete file /RamDisk/First 32 |
40 | ; eax = 2 ; delete file /RamDisk/First 32 |
41 | ; eax = 4 ; makedir |
41 | ; eax = 4 ; makedir |
42 | ; eax = 5 ; rename file/directory |
42 | ; eax = 5 ; rename file/directory |
43 | ; eax = 8 ; lba read |
43 | ; eax = 8 ; lba read |
44 | ; eax = 15 ; get_disk_info |
44 | ; eax = 15 ; get_disk_info |
45 | ; eax = 16 ; start application |
- | |
46 | ; |
45 | ; |
47 | ; OUT: |
46 | ; OUT: |
48 | ; |
47 | ; |
49 | ; eax = 0 : read ok |
48 | ; eax = 0 : read ok |
50 | ; eax = 1 : no hd base and/or partition defined |
49 | ; eax = 1 : no hd base and/or partition defined |
51 | ; eax = 2 : function is unsupported for this FS |
50 | ; eax = 2 : function is unsupported for this FS |
52 | ; eax = 3 : unknown FS |
51 | ; eax = 3 : unknown FS |
53 | ; eax = 4 : partition not defined at hd |
52 | ; eax = 4 : partition not defined at hd |
54 | ; eax = 5 : file not found |
53 | ; eax = 5 : file not found |
55 | ; eax = 6 : end of file |
54 | ; eax = 6 : end of file |
56 | ; eax = 7 : memory pointer not in application area |
55 | ; eax = 7 : memory pointer not in application area |
57 | ; eax = 8 : disk full |
56 | ; eax = 8 : disk full |
58 | ; eax = 9 : fat table corrupted |
57 | ; eax = 9 : fat table corrupted |
59 | ; eax = 10 : access denied |
58 | ; eax = 10 : access denied |
60 | ; eax = 11 : disk error |
59 | ; eax = 11 : disk error |
61 | ; |
60 | ; |
62 | ; ebx = size |
61 | ; ebx = size |
63 | 62 | ||
64 | ; \begin{diamond}[18.03.2006] |
63 | ; \begin{diamond}[18.03.2006] |
65 | ; for subfunction 16 (start application) error codes must be negative |
64 | ; for subfunction 16 (start application) error codes must be negative |
66 | ; because positive values are valid PIDs |
65 | ; because positive values are valid PIDs |
67 | ; so possible return values are: |
66 | ; so possible return values are: |
68 | ; eax > 0 : process created, eax=PID |
67 | ; eax > 0 : process created, eax=PID |
69 | 68 | ||
70 | ; -0x10 <= eax < 0 : -eax is filesystem error code: |
69 | ; -0x10 <= eax < 0 : -eax is filesystem error code: |
71 | ; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined |
70 | ; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined |
72 | ; eax = -3 = 0xFFFFFFFD : unknown FS |
71 | ; eax = -3 = 0xFFFFFFFD : unknown FS |
73 | ; eax = -5 = 0xFFFFFFFB : file not found |
72 | ; eax = -5 = 0xFFFFFFFB : file not found |
74 | ; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file) |
73 | ; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file) |
75 | ; eax = -9 = 0xFFFFFFF7 : fat table corrupted |
74 | ; eax = -9 = 0xFFFFFFF7 : fat table corrupted |
76 | ; eax = -10 = 0xFFFFFFF6 : access denied |
75 | ; eax = -10 = 0xFFFFFFF6 : access denied |
77 | 76 | ||
78 | ; -0x20 <= eax < -0x10: eax is process creation error code: |
77 | ; -0x20 <= eax < -0x10: eax is process creation error code: |
79 | ; eax = -0x20 = 0xFFFFFFE0 : too many processes |
78 | ; eax = -0x20 = 0xFFFFFFE0 : too many processes |
80 | ; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable |
79 | ; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable |
81 | ; eax = -0x1E = 0xFFFFFFE2 : no memory |
80 | ; eax = -0x1E = 0xFFFFFFE2 : no memory |
82 | 81 | ||
83 | ; ebx is not changed |
82 | ; ebx is not changed |
84 | 83 | ||
85 | ; \end{diamond}[18.03.2006] |
84 | ; \end{diamond}[18.03.2006] |
86 | 85 | ||
87 | ; Extract parameters |
86 | ; Extract parameters |
88 | add eax, std_application_base_address ; abs start of info block |
87 | add eax, std_application_base_address ; abs start of info block |
89 | 88 | ||
90 | cmp dword [eax+0],15 ; GET_DISK_INFO |
89 | cmp dword [eax+0],15 ; GET_DISK_INFO |
91 | je fs_info |
90 | je fs_info |
92 | cmp dword [eax+0],16 ; RUN - dont care about read&write blocks |
- | |
93 | je fs_read |
- | |
94 | cmp dword [eax+0],5 ; RENAME - dont care about read&write blocks |
91 | cmp dword [eax+0],5 ; RENAME - dont care about read&write blocks |
95 | je fs_read |
92 | je fs_read |
96 | cmp dword [eax+0],4 ; MAKEDIR - dont care about read&write blocks |
93 | cmp dword [eax+0],4 ; MAKEDIR - dont care about read&write blocks |
97 | je fs_read |
94 | je fs_read |
98 | cmp dword [eax+0],2 ; DELETE - dont care about read&write blocks |
95 | cmp dword [eax+0],2 ; DELETE - dont care about read&write blocks |
99 | je fs_read |
96 | je fs_read |
100 | 97 | ||
101 | cmp dword [0x3000],1 ; no memory checks for kernel requests |
98 | cmp dword [0x3000],1 ; no memory checks for kernel requests |
102 | jz no_checks_for_kernel |
99 | jz no_checks_for_kernel |
103 | mov edx,eax |
100 | mov edx,eax |
104 | cmp dword [eax+0],1 |
101 | cmp dword [eax+0],1 |
105 | jnz .usual_check |
102 | jnz .usual_check |
106 | mov ebx,[eax+12] |
103 | mov ebx,[eax+12] |
107 | add ebx,std_application_base_address |
104 | add ebx,std_application_base_address |
108 | mov ecx,[eax+8] |
105 | mov ecx,[eax+8] |
109 | call check_region |
106 | call check_region |
110 | test eax,eax |
107 | test eax,eax |
111 | jnz area_in_app_mem |
108 | jnz area_in_app_mem |
112 | 109 | ||
113 | .error_output: |
110 | .error_output: |
114 | mov esi,buffer_failed |
111 | mov esi,buffer_failed |
115 | call sys_msg_board_str |
112 | call sys_msg_board_str |
116 | ; mov eax,7 |
113 | ; mov eax,7 |
117 | mov dword [esp+36],7 |
114 | mov dword [esp+36],7 |
118 | ret |
115 | ret |
119 | iglobal |
116 | iglobal |
120 | buffer_failed db 'K : Buffer check failed',13,10,0 |
117 | buffer_failed db 'K : Buffer check failed',13,10,0 |
121 | endg |
118 | endg |
122 | .usual_check: |
119 | .usual_check: |
123 | cmp dword [eax+0],0 |
120 | cmp dword [eax+0],0 |
124 | mov ecx,512 |
121 | mov ecx,512 |
125 | jnz .small_size |
122 | jnz .small_size |
126 | mov ecx,[eax+8] |
123 | mov ecx,[eax+8] |
127 | shl ecx,9 |
124 | shl ecx,9 |
128 | .small_size: |
125 | .small_size: |
129 | mov ebx,[eax+12] |
126 | mov ebx,[eax+12] |
130 | add ebx,std_application_base_address |
127 | add ebx,std_application_base_address |
131 | call check_region |
128 | call check_region |
132 | test eax,eax |
129 | test eax,eax |
133 | jz .error_output |
130 | jz .error_output |
134 | area_in_app_mem: |
131 | area_in_app_mem: |
135 | mov eax,edx |
132 | mov eax,edx |
136 | no_checks_for_kernel: |
133 | no_checks_for_kernel: |
137 | 134 | ||
138 | fs_read: |
135 | fs_read: |
139 | 136 | ||
140 | mov ebx,[eax+20] ; program wants root directory ? |
137 | mov ebx,[eax+20] ; program wants root directory ? |
141 | test bl,bl |
138 | test bl,bl |
142 | je fs_getroot |
139 | je fs_getroot |
143 | test bh,bh |
140 | test bh,bh |
144 | jne fs_noroot |
141 | jne fs_noroot |
145 | fs_getroot: |
142 | fs_getroot: |
146 | ; \begin{diamond}[18.03.2006] |
143 | ; \begin{diamond}[18.03.2006] |
147 | ; root - only read is allowed |
144 | ; root - only read is allowed |
148 | ; other operations return "access denied", eax=10 |
145 | ; other operations return "access denied", eax=10 |
149 | ; (execute operation returns eax=-10) |
146 | ; (execute operation returns eax=-10) |
150 | cmp dword [eax], 0 |
147 | cmp dword [eax], 0 |
151 | jz .read_root |
148 | jz .read_root |
152 | mov ecx, 10 |
- | |
153 | cmp dword [eax], 16 |
149 | mov dword [esp+36], 10 |
154 | jnz @f |
- | |
155 | neg ecx |
- | |
156 | @@: mov [esp+36], ecx |
- | |
157 | ret |
150 | ret |
158 | .read_root: |
151 | .read_root: |
159 | ; \end{diamond}[18.03.2006] |
152 | ; \end{diamond}[18.03.2006] |
160 | mov esi,dir0 |
153 | mov esi,dir0 |
161 | mov edi,[eax+12] |
154 | mov edi,[eax+12] |
162 | add edi,std_application_base_address |
155 | add edi,std_application_base_address |
163 | mov ecx,11 |
156 | mov ecx,11 |
164 | push ecx |
157 | push ecx |
165 | ; cld ; already is |
158 | ; cld ; already is |
166 | rep movsb |
159 | rep movsb |
167 | mov al,0x10 |
160 | mov al,0x10 |
168 | stosb |
161 | stosb |
169 | add edi,32-11-1 |
162 | add edi,32-11-1 |
170 | pop ecx |
163 | pop ecx |
171 | rep movsb |
164 | rep movsb |
172 | stosb |
165 | stosb |
173 | and dword [esp+36],0 ; ok read |
166 | and dword [esp+36],0 ; ok read |
174 | mov dword [esp+24],32*2 ; size of root |
167 | mov dword [esp+24],32*2 ; size of root |
175 | ret |
168 | ret |
176 | 169 | ||
177 | fs_info: ;start of code - Mihasik |
170 | fs_info: ;start of code - Mihasik |
178 | push eax |
171 | push eax |
179 | cmp [eax+21],byte 'h' |
172 | cmp [eax+21],byte 'h' |
180 | je fs_info_h |
173 | je fs_info_h |
181 | cmp [eax+21],byte 'H' |
174 | cmp [eax+21],byte 'H' |
182 | je fs_info_h |
175 | je fs_info_h |
183 | cmp [eax+21],byte 'r' |
176 | cmp [eax+21],byte 'r' |
184 | je fs_info_r |
177 | je fs_info_r |
185 | cmp [eax+21],byte 'R' |
178 | cmp [eax+21],byte 'R' |
186 | je fs_info_r |
179 | je fs_info_r |
187 | mov eax,3 ;if unknown disk |
180 | mov eax,3 ;if unknown disk |
188 | xor ebx,ebx |
181 | xor ebx,ebx |
189 | xor ecx,ecx |
182 | xor ecx,ecx |
190 | xor edx,edx |
183 | xor edx,edx |
191 | jmp fs_info1 |
184 | jmp fs_info1 |
192 | fs_info_r: |
185 | fs_info_r: |
193 | call ramdisk_free_space ;if ramdisk |
186 | call ramdisk_free_space ;if ramdisk |
194 | mov ecx,edi ;free space in ecx |
187 | mov ecx,edi ;free space in ecx |
195 | shr ecx,9 ;free clusters |
188 | shr ecx,9 ;free clusters |
196 | mov ebx,2847 ;total clusters |
189 | mov ebx,2847 ;total clusters |
197 | mov edx,512 ;cluster size |
190 | mov edx,512 ;cluster size |
198 | xor eax,eax ;always 0 |
191 | xor eax,eax ;always 0 |
199 | jmp fs_info1 |
192 | jmp fs_info1 |
200 | fs_info_h: ;if harddisk |
193 | fs_info_h: ;if harddisk |
201 | call get_hd_info |
194 | call get_hd_info |
202 | fs_info1: |
195 | fs_info1: |
203 | pop edi |
196 | pop edi |
204 | mov [esp+36],eax |
197 | mov [esp+36],eax |
205 | mov [esp+24],ebx ; total clusters on disk |
198 | mov [esp+24],ebx ; total clusters on disk |
206 | mov [esp+32],ecx ; free clusters on disk |
199 | mov [esp+32],ecx ; free clusters on disk |
207 | mov [edi],edx ; cluster size in bytes |
200 | mov [edi],edx ; cluster size in bytes |
208 | ret ;end of code - Mihasik |
201 | ret ;end of code - Mihasik |
209 | 202 | ||
210 | fs_noroot: |
203 | fs_noroot: |
211 | 204 | ||
212 | push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run |
205 | push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run |
213 | push dword [eax+4] ; 512 block number to read |
206 | push dword [eax+4] ; 512 block number to read |
214 | push dword [eax+8] ; bytes to write/append or 512 blocks to read |
207 | push dword [eax+8] ; bytes to write/append or 512 blocks to read |
215 | mov ebx,[eax+12] |
208 | mov ebx,[eax+12] |
216 | add ebx,std_application_base_address |
209 | add ebx,std_application_base_address |
217 | push ebx ; abs start of return/save area |
210 | push ebx ; abs start of return/save area |
218 | 211 | ||
219 | lea esi,[eax+20] ; abs start of dir + filename |
212 | lea esi,[eax+20] ; abs start of dir + filename |
220 | mov edi,[eax+16] |
213 | mov edi,[eax+16] |
221 | add edi,std_application_base_address ; abs start of work area |
214 | add edi,std_application_base_address ; abs start of work area |
222 | 215 | ||
223 | call expand_pathz |
216 | call expand_pathz |
224 | 217 | ||
225 | push edi ; dir start |
218 | push edi ; dir start |
226 | push ebx ; name of file start |
219 | push ebx ; name of file start |
227 | 220 | ||
228 | mov eax,[edi+1] |
221 | mov eax,[edi+1] |
229 | cmp eax,'RD ' |
222 | cmp eax,'RD ' |
230 | je fs_yesramdisk |
223 | je fs_yesramdisk |
231 | cmp eax,'RAMD' |
224 | cmp eax,'RAMD' |
232 | jne fs_noramdisk |
225 | jne fs_noramdisk |
233 | 226 | ||
234 | fs_yesramdisk: |
227 | fs_yesramdisk: |
235 | 228 | ||
236 | cmp byte [edi+1+11],0 |
229 | cmp byte [edi+1+11],0 |
237 | je fs_give_dir1 |
230 | je fs_give_dir1 |
238 | 231 | ||
239 | mov eax,[edi+1+12] |
232 | mov eax,[edi+1+12] |
240 | cmp eax,'1 ' |
233 | cmp eax,'1 ' |
241 | je fs_yesramdisk_first |
234 | je fs_yesramdisk_first |
242 | cmp eax,'FIRS' |
235 | cmp eax,'FIRS' |
243 | jne fs_noramdisk |
236 | jne fs_noramdisk |
244 | 237 | ||
245 | fs_yesramdisk_first: |
238 | fs_yesramdisk_first: |
246 | 239 | ||
247 | cmp dword [esp+20],8 ; LBA read ramdisk |
240 | cmp dword [esp+20],8 ; LBA read ramdisk |
248 | jne fs_no_LBA_read_ramdisk |
241 | jne fs_no_LBA_read_ramdisk |
249 | 242 | ||
250 | mov eax,[esp+16] ; LBA block to read |
243 | mov eax,[esp+16] ; LBA block to read |
251 | mov ecx,[esp+8] ; abs pointer to return area |
244 | mov ecx,[esp+8] ; abs pointer to return area |
252 | 245 | ||
253 | call LBA_read_ramdisk |
246 | call LBA_read_ramdisk |
254 | jmp file_system_return |
247 | jmp file_system_return |
255 | 248 | ||
256 | 249 | ||
257 | fs_no_LBA_read_ramdisk: |
250 | fs_no_LBA_read_ramdisk: |
258 | 251 | ||
259 | cmp dword [esp+20],0 ; READ |
252 | cmp dword [esp+20],0 ; READ |
260 | jne fs_noramdisk_read |
253 | jne fs_noramdisk_read |
261 | 254 | ||
262 | mov eax,[esp+4] ; fname |
255 | mov eax,[esp+4] ; fname |
263 | add eax,2*12+1 |
256 | add eax,2*12+1 |
264 | mov ebx,[esp+16] ; block start |
257 | mov ebx,[esp+16] ; block start |
265 | inc ebx |
258 | inc ebx |
266 | mov ecx,[esp+12] ; block count |
259 | mov ecx,[esp+12] ; block count |
267 | mov edx,[esp+8] ; return |
260 | mov edx,[esp+8] ; return |
268 | mov esi,[esp+0] |
261 | mov esi,[esp+0] |
269 | sub esi,eax |
262 | sub esi,eax |
270 | add esi,12+1 ; file name length |
263 | add esi,12+1 ; file name length |
271 | call fileread |
264 | call fileread |
272 | 265 | ||
273 | jmp file_system_return |
266 | jmp file_system_return |
274 | 267 | ||
275 | 268 | ||
276 | fs_noramdisk_read: |
269 | fs_noramdisk_read: |
277 | 270 | ||
278 | cmp dword [esp+20],1 ; WRITE |
271 | cmp dword [esp+20],1 ; WRITE |
279 | jne fs_noramdisk_write |
272 | jne fs_noramdisk_write |
280 | 273 | ||
281 | mov eax,[esp+4] ; fname |
274 | mov eax,[esp+4] ; fname |
282 | add eax,2*12+1 |
275 | add eax,2*12+1 |
283 | mov ebx,[esp+8] ; buffer |
276 | mov ebx,[esp+8] ; buffer |
284 | mov ecx,[esp+12] ; count to write |
277 | mov ecx,[esp+12] ; count to write |
285 | mov edx,0 ; create new |
278 | mov edx,0 ; create new |
286 | call filesave |
279 | call filesave |
287 | 280 | ||
288 | ; eax=0 ok - eax=1 not enough free space |
281 | ; eax=0 ok - eax=1 not enough free space |
289 | 282 | ||
290 | jmp file_system_return |
283 | jmp file_system_return |
291 | 284 | ||
292 | fs_noramdisk_write: |
285 | fs_noramdisk_write: |
293 | - | ||
294 | cmp dword [esp+20],16 ; START APPLICATION |
- | |
295 | jne fs_noramdisk_start_application |
- | |
296 | - | ||
297 | mov eax,[esp+4] ; fname |
- | |
298 | add eax,2*12+1 |
- | |
299 | - | ||
300 | xor ebx,ebx ; parameters to pass |
- | |
301 | cmp dword [esp+12],ebx;0 |
- | |
302 | je no_fl_start_param |
- | |
303 | mov ebx, [esp+12] |
- | |
304 | add ebx, std_application_base_address |
- | |
305 | no_fl_start_param: |
- | |
306 | mov edx,[esp+16] ; flags |
- | |
307 | - | ||
308 | call start_application_fl |
- | |
309 | - | ||
310 | jmp file_system_startapp_return |
- | |
311 | - | ||
312 | fs_noramdisk_start_application: ;there's new code - Mihasik |
286 | |
313 | cmp dword [esp+20],2 ;DELETE |
287 | cmp dword [esp+20],2 ;DELETE |
314 | jne fs_noramdisk_delete |
288 | jne fs_noramdisk_delete |
315 | mov eax,[esp+4] ; fname |
289 | mov eax,[esp+4] ; fname |
316 | add eax,2*12+1 |
290 | add eax,2*12+1 |
317 | call filedelete |
291 | call filedelete |
318 | jmp file_system_return |
292 | jmp file_system_return |
319 | 293 | ||
320 | fs_noramdisk_delete: |
294 | fs_noramdisk_delete: |
321 | fs_noramdisk: |
295 | fs_noramdisk: |
322 | 296 | ||
323 | ;******************************************************************** |
297 | ;******************************************************************** |
324 | mov eax,[edi+1] |
298 | mov eax,[edi+1] |
325 | cmp eax,'FD ' |
299 | cmp eax,'FD ' |
326 | je fs_yesflpdisk |
300 | je fs_yesflpdisk |
327 | cmp eax,'FLOP' |
301 | cmp eax,'FLOP' |
328 | jne fs_noflpdisk |
302 | jne fs_noflpdisk |
329 | 303 | ||
330 | fs_yesflpdisk: |
304 | fs_yesflpdisk: |
331 | call reserve_flp |
305 | call reserve_flp |
332 | 306 | ||
333 | cmp byte [edi+1+11],0 |
307 | cmp byte [edi+1+11],0 |
334 | je fs_give_dir1 |
308 | je fs_give_dir1 |
335 | 309 | ||
336 | mov eax,[edi+1+12] |
310 | mov eax,[edi+1+12] |
337 | cmp eax,'1 ' |
311 | cmp eax,'1 ' |
338 | je fs_yesflpdisk_first |
312 | je fs_yesflpdisk_first |
339 | cmp eax,'FIRS' |
313 | cmp eax,'FIRS' |
340 | je fs_yesflpdisk_first |
314 | je fs_yesflpdisk_first |
341 | cmp eax,'2 ' |
315 | cmp eax,'2 ' |
342 | je fs_yesflpdisk_second |
316 | je fs_yesflpdisk_second |
343 | cmp eax,'SECO' |
317 | cmp eax,'SECO' |
344 | jne fs_noflpdisk |
318 | jne fs_noflpdisk |
345 | jmp fs_yesflpdisk_second |
319 | jmp fs_yesflpdisk_second |
346 | 320 | ||
347 | fs_yesflpdisk_first: |
321 | fs_yesflpdisk_first: |
348 | mov [flp_number],1 |
322 | mov [flp_number],1 |
349 | jmp fs_yesflpdisk_start |
323 | jmp fs_yesflpdisk_start |
350 | fs_yesflpdisk_second: |
324 | fs_yesflpdisk_second: |
351 | mov [flp_number],2 |
325 | mov [flp_number],2 |
352 | fs_yesflpdisk_start: |
326 | fs_yesflpdisk_start: |
353 | cmp dword [esp+20],0 ; READ |
327 | cmp dword [esp+20],0 ; READ |
354 | jne fs_noflpdisk_read |
328 | jne fs_noflpdisk_read |
355 | 329 | ||
356 | mov eax,[esp+4] ; fname |
330 | mov eax,[esp+4] ; fname |
357 | add eax,2*12+1 |
331 | add eax,2*12+1 |
358 | mov ebx,[esp+16] ; block start |
332 | mov ebx,[esp+16] ; block start |
359 | inc ebx |
333 | inc ebx |
360 | mov ecx,[esp+12] ; block count |
334 | mov ecx,[esp+12] ; block count |
361 | mov edx,[esp+8] ; return |
335 | mov edx,[esp+8] ; return |
362 | mov esi,[esp+0] |
336 | mov esi,[esp+0] |
363 | sub esi,eax |
337 | sub esi,eax |
364 | add esi,12+1 ; file name length |
338 | add esi,12+1 ; file name length |
365 | call floppy_fileread |
339 | call floppy_fileread |
366 | 340 | ||
367 | jmp file_system_return |
341 | jmp file_system_return |
368 | 342 | ||
369 | 343 | ||
370 | fs_noflpdisk_read: |
344 | fs_noflpdisk_read: |
371 | 345 | ||
372 | cmp dword [esp+20],1 ; WRITE |
346 | cmp dword [esp+20],1 ; WRITE |
373 | jne fs_noflpdisk_write |
347 | jne fs_noflpdisk_write |
374 | 348 | ||
375 | mov eax,[esp+4] ; fname |
349 | mov eax,[esp+4] ; fname |
376 | add eax,2*12+1 |
350 | add eax,2*12+1 |
377 | mov ebx,[esp+8] ; buffer |
351 | mov ebx,[esp+8] ; buffer |
378 | mov ecx,[esp+12] ; count to write |
352 | mov ecx,[esp+12] ; count to write |
379 | mov edx,0 ; create new |
353 | mov edx,0 ; create new |
380 | call floppy_filesave |
354 | call floppy_filesave |
381 | 355 | ||
382 | ; eax=0 ok - eax=1 not enough free space |
356 | ; eax=0 ok - eax=1 not enough free space |
383 | 357 | ||
384 | jmp file_system_return |
358 | jmp file_system_return |
385 | 359 | ||
386 | fs_noflpdisk_write: |
360 | fs_noflpdisk_write: |
387 | 361 | ||
388 | cmp dword [esp+20],2 ; DELETE |
362 | cmp dword [esp+20],2 ; DELETE |
389 | jne fs_noflpdisk_delete |
363 | jne fs_noflpdisk_delete |
390 | 364 | ||
391 | mov eax,[esp+4] ; fname |
365 | mov eax,[esp+4] ; fname |
392 | add eax,2*12+1 |
366 | add eax,2*12+1 |
393 | call floppy_filedelete |
367 | call floppy_filedelete |
394 | mov [flp_status],0 |
368 | mov [flp_status],0 |
395 | jmp file_system_return |
369 | jmp file_system_return |
396 | 370 | ||
397 | fs_noflpdisk_delete: |
371 | fs_noflpdisk_delete: |
398 | cmp dword [esp+20],16 ; START APPLICATION |
- | |
399 | jne fs_noflpdisk_start_application |
- | |
400 | - | ||
401 | mov eax,[esp+4] ; fname |
- | |
402 | add eax,2*12+1 |
- | |
403 | - | ||
404 | xor ebx,ebx ; parameters to pass |
- | |
405 | cmp dword [esp+12],ebx;0 |
- | |
406 | je no_flp_start_param |
- | |
407 | mov ebx,[0x3010] |
- | |
408 | mov ebx,[ebx+0x10] |
- | |
409 | add ebx,[esp+12] |
- | |
410 | - | ||
411 | no_flp_start_param: |
- | |
412 | mov edx,[esp+16] ; flags |
- | |
413 | - | ||
414 | call start_application_floppy |
- | |
415 | - | ||
416 | file_system_startapp_return: |
- | |
417 | mov ebx, [esp+24+24] ; do not modify ebx in application |
- | |
418 | jmp file_system_return |
- | |
419 | - | ||
420 | fs_noflpdisk_start_application: |
- | |
421 | 372 | ||
422 | fs_noflpdisk: |
373 | fs_noflpdisk: |
423 | ;***************************************************************** |
374 | ;***************************************************************** |
424 | 375 | ||
425 | mov eax,[edi+1] |
376 | mov eax,[edi+1] |
426 | cmp eax,'HD0 ' |
377 | cmp eax,'HD0 ' |
427 | je fs_yesharddisk_IDE0 |
378 | je fs_yesharddisk_IDE0 |
428 | cmp eax,'HD1 ' |
379 | cmp eax,'HD1 ' |
429 | je fs_yesharddisk_IDE1 |
380 | je fs_yesharddisk_IDE1 |
430 | cmp eax,'HD2 ' |
381 | cmp eax,'HD2 ' |
431 | je fs_yesharddisk_IDE2 |
382 | je fs_yesharddisk_IDE2 |
432 | cmp eax,'HD3 ' |
383 | cmp eax,'HD3 ' |
433 | je fs_yesharddisk_IDE3 |
384 | je fs_yesharddisk_IDE3 |
434 | jmp old_path_harddisk |
385 | jmp old_path_harddisk |
435 | fs_yesharddisk_IDE0: |
386 | fs_yesharddisk_IDE0: |
436 | call reserve_hd1 |
387 | call reserve_hd1 |
437 | mov [hdbase],0x1f0 |
388 | mov [hdbase],0x1f0 |
438 | mov [hdid],0x0 |
389 | mov [hdid],0x0 |
439 | mov [hdpos],1 |
390 | mov [hdpos],1 |
440 | jmp fs_yesharddisk_partition |
391 | jmp fs_yesharddisk_partition |
441 | fs_yesharddisk_IDE1: |
392 | fs_yesharddisk_IDE1: |
442 | call reserve_hd1 |
393 | call reserve_hd1 |
443 | mov [hdbase],0x1f0 |
394 | mov [hdbase],0x1f0 |
444 | mov [hdid],0x10 |
395 | mov [hdid],0x10 |
445 | mov [hdpos],2 |
396 | mov [hdpos],2 |
446 | jmp fs_yesharddisk_partition |
397 | jmp fs_yesharddisk_partition |
447 | fs_yesharddisk_IDE2: |
398 | fs_yesharddisk_IDE2: |
448 | call reserve_hd1 |
399 | call reserve_hd1 |
449 | mov [hdbase],0x170 |
400 | mov [hdbase],0x170 |
450 | mov [hdid],0x0 |
401 | mov [hdid],0x0 |
451 | mov [hdpos],3 |
402 | mov [hdpos],3 |
452 | jmp fs_yesharddisk_partition |
403 | jmp fs_yesharddisk_partition |
453 | fs_yesharddisk_IDE3: |
404 | fs_yesharddisk_IDE3: |
454 | call reserve_hd1 |
405 | call reserve_hd1 |
455 | mov [hdbase],0x170 |
406 | mov [hdbase],0x170 |
456 | mov [hdid],0x10 |
407 | mov [hdid],0x10 |
457 | mov [hdpos],4 |
408 | mov [hdpos],4 |
458 | fs_yesharddisk_partition: |
409 | fs_yesharddisk_partition: |
459 | ; call choice_necessity_partition |
410 | ; call choice_necessity_partition |
460 | ; jmp fs_yesharddisk_all |
411 | ; jmp fs_yesharddisk_all |
461 | jmp fs_for_new_semantic |
412 | jmp fs_for_new_semantic |
462 | 413 | ||
463 | choice_necessity_partition: |
414 | choice_necessity_partition: |
464 | mov eax,[edi+1+12] |
415 | mov eax,[edi+1+12] |
465 | call StringToNumber |
416 | call StringToNumber |
466 | mov [fat32part],eax |
417 | mov [fat32part],eax |
467 | choice_necessity_partition_1: |
418 | choice_necessity_partition_1: |
468 | mov ecx,[hdpos] |
419 | mov ecx,[hdpos] |
469 | xor eax,eax |
420 | xor eax,eax |
470 | mov [0xfe10], eax ; entries in hd cache |
421 | mov [0xfe10], eax ; entries in hd cache |
471 | mov edx,0x40002 |
422 | mov edx,0x40002 |
472 | search_partition_array: |
423 | search_partition_array: |
473 | mov bl,[edx] |
424 | mov bl,[edx] |
474 | movzx ebx,bl |
425 | movzx ebx,bl |
475 | add eax,ebx |
426 | add eax,ebx |
476 | inc edx |
427 | inc edx |
477 | loop search_partition_array |
428 | loop search_partition_array |
478 | sub eax,ebx |
429 | sub eax,ebx |
479 | add eax,[fat32part] |
430 | add eax,[fat32part] |
480 | dec eax |
431 | dec eax |
481 | xor edx,edx |
432 | xor edx,edx |
482 | imul eax,100 |
433 | imul eax,100 |
483 | add eax,0x4000a |
434 | add eax,0x4000a |
484 | mov [transfer_adress],eax |
435 | mov [transfer_adress],eax |
485 | call partition_data_transfer_1 |
436 | call partition_data_transfer_1 |
486 | ret |
437 | ret |
487 | 438 | ||
488 | old_path_harddisk: |
439 | old_path_harddisk: |
489 | mov eax,[edi+1] |
440 | mov eax,[edi+1] |
490 | cmp eax,'HD ' |
441 | cmp eax,'HD ' |
491 | je fs_yesharddisk |
442 | je fs_yesharddisk |
492 | cmp eax,'HARD' |
443 | cmp eax,'HARD' |
493 | jne fs_noharddisk |
444 | jne fs_noharddisk |
494 | 445 | ||
495 | fs_yesharddisk: |
446 | fs_yesharddisk: |
496 | cmp dword [esp+20],8 ; LBA read |
447 | cmp dword [esp+20],8 ; LBA read |
497 | jne fs_no_LBA_read |
448 | jne fs_no_LBA_read |
498 | mov eax,[esp+16] ; LBA block to read |
449 | mov eax,[esp+16] ; LBA block to read |
499 | lea ebx,[edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH |
450 | lea ebx,[edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH |
500 | mov ecx,[esp+8] ; abs pointer to return area |
451 | mov ecx,[esp+8] ; abs pointer to return area |
501 | call LBA_read |
452 | call LBA_read |
502 | jmp file_system_return |
453 | jmp file_system_return |
503 | 454 | ||
504 | fs_no_LBA_read: |
455 | fs_no_LBA_read: |
505 | 456 | ||
506 | cmp byte [edi+1+11],0 ; directory read |
457 | cmp byte [edi+1+11],0 ; directory read |
507 | je fs_give_dir1 |
458 | je fs_give_dir1 |
508 | call reserve_hd1 |
459 | call reserve_hd1 |
509 | fs_for_new_semantic: |
460 | fs_for_new_semantic: |
510 | call choice_necessity_partition |
461 | call choice_necessity_partition |
511 | 462 | ||
512 | fs_yesharddisk_all: |
463 | fs_yesharddisk_all: |
513 | mov eax,1 |
464 | mov eax,1 |
514 | cmp dword [esp+20], 16 |
- | |
515 | jnz @f |
- | |
516 | neg eax |
- | |
517 | @@: mov ebx, [esp+24+24] |
465 | mov ebx, [esp+24+24] |
518 | cmp [hdpos],0 ; is hd base set? |
466 | cmp [hdpos],0 ; is hd base set? |
519 | jz hd_err_return |
467 | jz hd_err_return |
520 | cmp [fat32part],0 ; is partition set? |
468 | cmp [fat32part],0 ; is partition set? |
521 | jnz @f |
469 | jnz @f |
522 | hd_err_return: |
470 | hd_err_return: |
523 | and [hd1_status], 0 |
471 | and [hd1_status], 0 |
524 | jmp file_system_return |
472 | jmp file_system_return |
525 | @@: |
473 | @@: |
526 | 474 | ||
527 | cmp dword [esp+20],0 ; READ |
475 | cmp dword [esp+20],0 ; READ |
528 | jne fs_noharddisk_read |
476 | jne fs_noharddisk_read |
529 | 477 | ||
530 | mov eax,[esp+0] ; /fname |
478 | mov eax,[esp+0] ; /fname |
531 | lea edi,[eax+12] |
479 | lea edi,[eax+12] |
532 | mov byte [eax],0 ; path to asciiz |
480 | mov byte [eax],0 ; path to asciiz |
533 | inc eax ; filename start |
481 | inc eax ; filename start |
534 | 482 | ||
535 | mov ebx,[esp+12] ; count to read |
483 | mov ebx,[esp+12] ; count to read |
536 | mov ecx,[esp+8] ; buffer |
484 | mov ecx,[esp+8] ; buffer |
537 | mov edx,[esp+4] |
485 | mov edx,[esp+4] |
538 | add edx,12*2 ; dir start |
486 | add edx,12*2 ; dir start |
539 | sub edi,edx ; path length |
487 | sub edi,edx ; path length |
540 | mov esi,[esp+16] ; blocks to read |
488 | mov esi,[esp+16] ; blocks to read |
541 | 489 | ||
542 | call file_read |
490 | call file_read |
543 | 491 | ||
544 | mov edi,[esp+0] |
492 | mov edi,[esp+0] |
545 | mov byte [edi],'/' |
493 | mov byte [edi],'/' |
546 | 494 | ||
547 | jmp file_system_return |
495 | jmp file_system_return |
548 | 496 | ||
549 | fs_noharddisk_read: |
497 | fs_noharddisk_read: |
550 | 498 | ||
551 | 499 | ||
552 | cmp dword [esp+20],1 ; WRITE |
500 | cmp dword [esp+20],1 ; WRITE |
553 | jne fs_noharddisk_write |
501 | jne fs_noharddisk_write |
554 | 502 | ||
555 | mov eax,[esp+0] ; /fname |
503 | mov eax,[esp+0] ; /fname |
556 | mov byte [eax],0 ; path to asciiz |
504 | mov byte [eax],0 ; path to asciiz |
557 | inc eax ; filename start |
505 | inc eax ; filename start |
558 | 506 | ||
559 | mov ebx,[esp+12] ; count to write |
507 | mov ebx,[esp+12] ; count to write |
560 | mov ecx,[esp+8] ; buffer |
508 | mov ecx,[esp+8] ; buffer |
561 | mov edx,[esp+4] |
509 | mov edx,[esp+4] |
562 | add edx,12*2 ; path start |
510 | add edx,12*2 ; path start |
563 | 511 | ||
564 | call file_write |
512 | call file_write |
565 | 513 | ||
566 | mov edi,[esp+0] |
514 | mov edi,[esp+0] |
567 | mov byte [edi],'/' |
515 | mov byte [edi],'/' |
568 | 516 | ||
569 | ; eax=0 ok - eax=1 not enough free space |
517 | ; eax=0 ok - eax=1 not enough free space |
570 | 518 | ||
571 | jmp file_system_return |
519 | jmp file_system_return |
572 | 520 | ||
573 | 521 | ||
574 | fs_noharddisk_write: |
522 | fs_noharddisk_write: |
575 | 523 | ||
576 | cmp dword [esp+20],2 ; DELETE |
524 | cmp dword [esp+20],2 ; DELETE |
577 | jne fs_noharddisk_delete |
525 | jne fs_noharddisk_delete |
578 | 526 | ||
579 | mov eax,[esp+0] ; /dirname or /filename |
527 | mov eax,[esp+0] ; /dirname or /filename |
580 | mov byte [eax],0 ; path to asciiz |
528 | mov byte [eax],0 ; path to asciiz |
581 | inc eax ; filename start |
529 | inc eax ; filename start |
582 | mov edx,[esp+4] |
530 | mov edx,[esp+4] |
583 | add edx,12*2 ; path start |
531 | add edx,12*2 ; path start |
584 | 532 | ||
585 | call removedir |
533 | call removedir |
586 | 534 | ||
587 | mov edi,[esp+0] |
535 | mov edi,[esp+0] |
588 | mov byte [edi],'/' |
536 | mov byte [edi],'/' |
589 | 537 | ||
590 | jmp file_system_return |
538 | jmp file_system_return |
591 | 539 | ||
592 | fs_noharddisk_delete: |
540 | fs_noharddisk_delete: |
593 | 541 | ||
594 | cmp dword [esp+20],4 ; MAKEDIR |
542 | cmp dword [esp+20],4 ; MAKEDIR |
595 | jne fs_noharddisk_makedir |
543 | jne fs_noharddisk_makedir |
596 | 544 | ||
597 | mov eax,[esp+0] ; /dirname |
545 | mov eax,[esp+0] ; /dirname |
598 | mov byte [eax],0 ; path to asciiz |
546 | mov byte [eax],0 ; path to asciiz |
599 | inc eax ; filename start |
547 | inc eax ; filename start |
600 | mov edx,[esp+4] |
548 | mov edx,[esp+4] |
601 | add edx,12*2 ; path start |
549 | add edx,12*2 ; path start |
602 | 550 | ||
603 | call makedir |
551 | call makedir |
604 | 552 | ||
605 | mov edi,[esp+0] |
553 | mov edi,[esp+0] |
606 | mov byte [edi],'/' |
554 | mov byte [edi],'/' |
607 | 555 | ||
608 | jmp file_system_return |
556 | jmp file_system_return |
609 | 557 | ||
610 | fs_noharddisk_makedir: |
558 | fs_noharddisk_makedir: |
611 | 559 | ||
612 | cmp dword [esp+20],5 ; RENAME |
560 | cmp dword [esp+20],5 ; RENAME |
613 | jne fs_noharddisk_rename |
561 | jne fs_noharddisk_rename |
614 | 562 | ||
615 | mov edi,[esp+0] ; start of source file name |
563 | mov edi,[esp+0] ; start of source file name |
616 | add edi,12+1 ; continue after name |
564 | add edi,12+1 ; continue after name |
617 | call expand_pathz ; convert destination name |
565 | call expand_pathz ; convert destination name |
618 | 566 | ||
619 | mov eax,[edi+1] |
567 | mov eax,[edi+1] |
620 | cmp eax,'HD ' |
568 | cmp eax,'HD ' |
621 | je fs_rename_test1 |
569 | je fs_rename_test1 |
622 | cmp eax,'HARD' |
570 | cmp eax,'HARD' |
623 | jne fs_rename_error |
571 | jne fs_rename_error |
624 | 572 | ||
625 | fs_rename_test1: |
573 | fs_rename_test1: |
626 | mov eax,[edi+1+12] |
574 | mov eax,[edi+1+12] |
627 | cmp eax,'1 ' |
575 | cmp eax,'1 ' |
628 | je fs_rename_start |
576 | je fs_rename_start |
629 | cmp eax,'FIRS' |
577 | cmp eax,'FIRS' |
630 | jne fs_rename_error |
578 | jne fs_rename_error |
631 | 579 | ||
632 | fs_rename_start: |
580 | fs_rename_start: |
633 | mov byte [ebx],0 ; path to asciiz |
581 | mov byte [ebx],0 ; path to asciiz |
634 | inc ebx ; filename start |
582 | inc ebx ; filename start |
635 | add edi,12*2 ; path start |
583 | add edi,12*2 ; path start |
636 | cmp byte [ebx],0 |
584 | cmp byte [ebx],0 |
637 | je fs_rename_error |
585 | je fs_rename_error |
638 | cmp byte [ebx],32 |
586 | cmp byte [ebx],32 |
639 | je fs_rename_error |
587 | je fs_rename_error |
640 | 588 | ||
641 | mov eax,[esp+0] ; /filename |
589 | mov eax,[esp+0] ; /filename |
642 | mov byte [eax],0 ; path to asciiz |
590 | mov byte [eax],0 ; path to asciiz |
643 | inc eax ; filename start |
591 | inc eax ; filename start |
644 | mov edx,[esp+4] |
592 | mov edx,[esp+4] |
645 | add edx,12*2 ; path start |
593 | add edx,12*2 ; path start |
646 | 594 | ||
647 | call rename |
595 | call rename |
648 | 596 | ||
649 | mov edi,[esp+0] |
597 | mov edi,[esp+0] |
650 | mov byte [edi],'/' |
598 | mov byte [edi],'/' |
651 | 599 | ||
652 | jmp file_system_return |
600 | jmp file_system_return |
653 | 601 | ||
654 | fs_rename_error: |
602 | fs_rename_error: |
655 | mov eax,4 ; partition not defined at hd |
603 | mov eax,4 ; partition not defined at hd |
656 | jmp file_system_return |
604 | jmp file_system_return |
657 | 605 | ||
658 | fs_noharddisk_rename: |
606 | fs_noharddisk_rename: |
659 | - | ||
660 | cmp dword [esp+20],16 ; START APPLICATION |
- | |
661 | jne fs_noharddisk_start_application |
- | |
662 | - | ||
663 | mov eax,[esp+4] ; fname |
- | |
664 | add eax,12*2 |
- | |
665 | - | ||
666 | mov ebx,[esp+0] ; length |
- | |
667 | sub ebx,eax |
- | |
668 | add ebx,12 |
- | |
669 | - | ||
670 | mov ecx,[esp+4] ; work area |
- | |
671 | add ecx,512 |
- | |
672 | - | ||
673 | xor ebp,ebp ; parameters to pass |
- | |
674 | cmp dword [esp+12],ebp;0 |
- | |
675 | je no_hd_start_param |
- | |
676 | mov ebp, [esp+12] |
- | |
677 | add ebp, std_application_base_address |
- | |
678 | no_hd_start_param: |
- | |
679 | mov edx,[esp+16] ; flags |
- | |
680 | - | ||
681 | call start_application_hd |
- | |
682 | - | ||
683 | jmp file_system_startapp_return |
- | |
684 | - | ||
685 | fs_noharddisk_start_application: |
- | |
686 | 607 | ||
687 | fs_noharddisk: |
608 | fs_noharddisk: |
688 | ; \begin{diamond}[18.03.2006] |
609 | ; \begin{diamond}[18.03.2006] |
689 | mov eax, 5 ; file not found |
610 | mov eax, 5 ; file not found |
690 | ; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè? |
611 | ; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè? |
691 | cmp dword [esp+20], 16 |
- | |
692 | jnz @f |
- | |
693 | neg eax |
- | |
694 | @@: mov ebx, [esp+24+24] ; do not change ebx in application |
612 | mov ebx, [esp+24+24] ; do not change ebx in application |
695 | ; \end{diamond}[18.03.2006] |
613 | ; \end{diamond}[18.03.2006] |
696 | 614 | ||
697 | file_system_return: |
615 | file_system_return: |
698 | 616 | ||
699 | add esp,24 |
617 | add esp,24 |
700 | 618 | ||
701 | mov [esp+36],eax |
619 | mov [esp+36],eax |
702 | mov [esp+24],ebx |
620 | mov [esp+24],ebx |
703 | ret |
621 | ret |
704 | 622 | ||
705 | 623 | ||
706 | fs_give_dir1: |
624 | fs_give_dir1: |
707 | 625 | ||
708 | ; \begin{diamond}[18.03.2006] |
626 | ; \begin{diamond}[18.03.2006] |
709 | ; /RD,/FD,/HD - only read is allowed |
627 | ; /RD,/FD,/HD - only read is allowed |
710 | ; other operations return "access denied", eax=10 |
628 | ; other operations return "access denied", eax=10 |
711 | ; (execute operation returns eax=-10) |
629 | ; (execute operation returns eax=-10) |
712 | cmp dword [esp+20], 0 |
630 | cmp dword [esp+20], 0 |
713 | jz .read |
631 | jz .read |
714 | add esp, 20 |
632 | add esp, 20 |
715 | pop ecx |
633 | pop ecx |
716 | mov eax, 10 |
- | |
717 | cmp ecx, 16 |
- | |
718 | jnz @f |
- | |
719 | neg eax |
- | |
720 | @@: mov [esp+36], eax |
634 | mov dword [esp+36], 10 |
721 | ret |
635 | ret |
722 | .read: |
636 | .read: |
723 | ; \end{diamond}[18.03.2006] |
637 | ; \end{diamond}[18.03.2006] |
724 | mov al,0x10 |
638 | mov al,0x10 |
725 | mov ebx,1 |
639 | mov ebx,1 |
726 | mov edi,[esp+8] |
640 | mov edi,[esp+8] |
727 | mov esi,dir1 |
641 | mov esi,dir1 |
728 | fs_d1_new: |
642 | fs_d1_new: |
729 | mov ecx,11 |
643 | mov ecx,11 |
730 | ; cld |
644 | ; cld |
731 | rep movsb |
645 | rep movsb |
732 | stosb |
646 | stosb |
733 | add edi,32-11-1 |
647 | add edi,32-11-1 |
734 | dec ebx |
648 | dec ebx |
735 | jne fs_d1_new |
649 | jne fs_d1_new |
736 | 650 | ||
737 | add esp,24 |
651 | add esp,24 |
738 | 652 | ||
739 | and dword [esp+36],0 ; ok read |
653 | and dword [esp+36],0 ; ok read |
740 | mov dword [esp+24],32*1 ; dir/data size |
654 | mov dword [esp+24],32*1 ; dir/data size |
741 | ret |
655 | ret |
742 | 656 | ||
743 | 657 | ||
744 | 658 | ||
745 | LBA_read_ramdisk: |
659 | LBA_read_ramdisk: |
746 | 660 | ||
747 | cmp [lba_read_enabled],1 |
661 | cmp [lba_read_enabled],1 |
748 | je lbarrl1 |
662 | je lbarrl1 |
749 | 663 | ||
750 | xor ebx,ebx |
664 | xor ebx,ebx |
751 | mov eax,2 |
665 | mov eax,2 |
752 | ret |
666 | ret |
753 | 667 | ||
754 | lbarrl1: |
668 | lbarrl1: |
755 | 669 | ||
756 | cmp eax,18*2*80 |
670 | cmp eax,18*2*80 |
757 | jb lbarrl2 |
671 | jb lbarrl2 |
758 | xor ebx,ebx |
672 | xor ebx,ebx |
759 | mov eax,3 |
673 | mov eax,3 |
760 | ret |
674 | ret |
761 | 675 | ||
762 | lbarrl2: |
676 | lbarrl2: |
763 | 677 | ||
764 | pushad |
678 | pushad |
765 | 679 | ||
766 | call restorefatchain |
680 | call restorefatchain |
767 | 681 | ||
768 | mov edi,ecx |
682 | mov edi,ecx |
769 | mov esi,eax |
683 | mov esi,eax |
770 | 684 | ||
771 | shl esi,9 |
685 | shl esi,9 |
772 | add esi,0x100000 |
686 | add esi,0x100000 |
773 | mov ecx,512/4 |
687 | mov ecx,512/4 |
774 | ; cld |
688 | ; cld |
775 | rep movsd |
689 | rep movsd |
776 | 690 | ||
777 | popad |
691 | popad |
778 | 692 | ||
779 | xor ebx,ebx |
693 | xor ebx,ebx |
780 | xor eax,eax |
694 | xor eax,eax |
781 | ret |
695 | ret |
782 | 696 | ||
783 | LBA_read: |
697 | LBA_read: |
784 | 698 | ||
785 | ; IN: |
699 | ; IN: |
786 | ; |
700 | ; |
787 | ; eax = LBA block to read |
701 | ; eax = LBA block to read |
788 | ; ebx = pointer to FIRST/SECOND/THIRD/FOURTH |
702 | ; ebx = pointer to FIRST/SECOND/THIRD/FOURTH |
789 | ; ecx = abs pointer to return area |
703 | ; ecx = abs pointer to return area |
790 | 704 | ||
791 | cmp [lba_read_enabled],1 |
705 | cmp [lba_read_enabled],1 |
792 | je lbarl1 |
706 | je lbarl1 |
793 | mov eax,2 |
707 | mov eax,2 |
794 | ret |
708 | ret |
795 | 709 | ||
796 | lbarl1: |
710 | lbarl1: |
797 | 711 | ||
798 | call reserve_hd1 |
712 | call reserve_hd1 |
799 | 713 | ||
800 | push eax |
714 | push eax |
801 | push ecx |
715 | push ecx |
802 | 716 | ||
803 | mov edi,hd_address_table |
717 | mov edi,hd_address_table |
804 | mov esi,dir1 |
718 | mov esi,dir1 |
805 | mov eax,[ebx] |
719 | mov eax,[ebx] |
806 | mov edx,'1 ' |
720 | mov edx,'1 ' |
807 | mov ecx,4 |
721 | mov ecx,4 |
808 | blar0: |
722 | blar0: |
809 | cmp eax,[esi] |
723 | cmp eax,[esi] |
810 | je blar2 |
724 | je blar2 |
811 | cmp eax,edx |
725 | cmp eax,edx |
812 | je blar2 |
726 | je blar2 |
813 | inc edx |
727 | inc edx |
814 | add edi,8 |
728 | add edi,8 |
815 | add esi,11 |
729 | add esi,11 |
816 | dec ecx |
730 | dec ecx |
817 | jnz blar0 |
731 | jnz blar0 |
818 | 732 | ||
819 | mov eax,1 |
733 | mov eax,1 |
820 | mov ebx,1 |
734 | mov ebx,1 |
821 | jmp LBA_read_ret |
735 | jmp LBA_read_ret |
822 | 736 | ||
823 | blar2: |
737 | blar2: |
824 | mov eax,[edi+0] |
738 | mov eax,[edi+0] |
825 | mov ebx,[edi+4] |
739 | mov ebx,[edi+4] |
826 | 740 | ||
827 | mov [hdbase],eax |
741 | mov [hdbase],eax |
828 | mov [hdid],ebx |
742 | mov [hdid],ebx |
829 | 743 | ||
830 | call wait_for_hd_idle |
744 | call wait_for_hd_idle |
831 | cmp [hd_error],0 |
745 | cmp [hd_error],0 |
832 | jne hd_lba_error |
746 | jne hd_lba_error |
833 | 747 | ||
834 | ; eax = hd port |
748 | ; eax = hd port |
835 | ; ebx = set for primary (0x00) or slave (0x10) |
749 | ; ebx = set for primary (0x00) or slave (0x10) |
836 | 750 | ||
837 | cli |
751 | cli |
838 | 752 | ||
839 | mov edx,eax |
753 | mov edx,eax |
840 | inc edx |
754 | inc edx |
841 | xor eax,eax |
755 | xor eax,eax |
842 | out dx,al |
756 | out dx,al |
843 | inc edx |
757 | inc edx |
844 | inc eax |
758 | inc eax |
845 | out dx,al |
759 | out dx,al |
846 | inc edx |
760 | inc edx |
847 | mov eax,[esp+4] |
761 | mov eax,[esp+4] |
848 | out dx,al |
762 | out dx,al |
849 | shr eax,8 |
763 | shr eax,8 |
850 | inc edx |
764 | inc edx |
851 | out dx,al |
765 | out dx,al |
852 | shr eax,8 |
766 | shr eax,8 |
853 | inc edx |
767 | inc edx |
854 | out dx,al |
768 | out dx,al |
855 | shr eax,8 |
769 | shr eax,8 |
856 | inc edx |
770 | inc edx |
857 | and al,1+2+4+8 |
771 | and al,1+2+4+8 |
858 | add al,bl |
772 | add al,bl |
859 | add al,128+64+32 |
773 | add al,128+64+32 |
860 | out dx,al |
774 | out dx,al |
861 | 775 | ||
862 | inc edx |
776 | inc edx |
863 | mov al,20h |
777 | mov al,20h |
864 | out dx,al |
778 | out dx,al |
865 | 779 | ||
866 | sti |
780 | sti |
867 | 781 | ||
868 | call wait_for_sector_buffer |
782 | call wait_for_sector_buffer |
869 | cmp [hd_error],0 |
783 | cmp [hd_error],0 |
870 | jne hd_lba_error |
784 | jne hd_lba_error |
871 | 785 | ||
872 | cli |
786 | cli |
873 | 787 | ||
874 | mov edi,[esp+0] |
788 | mov edi,[esp+0] |
875 | mov ecx,256 |
789 | mov ecx,256 |
876 | sub edx,7 |
790 | sub edx,7 |
877 | cld |
791 | cld |
878 | rep insw |
792 | rep insw |
879 | 793 | ||
880 | sti |
794 | sti |
881 | 795 | ||
882 | xor eax,eax |
796 | xor eax,eax |
883 | xor ebx,ebx |
797 | xor ebx,ebx |
884 | 798 | ||
885 | LBA_read_ret: |
799 | LBA_read_ret: |
886 | mov [hd_error],0 |
800 | mov [hd_error],0 |
887 | mov [hd1_status],0 |
801 | mov [hd1_status],0 |
888 | add esp,2*4 |
802 | add esp,2*4 |
889 | 803 | ||
890 | ret |
804 | ret |
891 | 805 | ||
892 | 806 | ||
893 | expand_pathz: |
807 | expand_pathz: |
894 | ; IN: |
808 | ; IN: |
895 | ; esi = asciiz path & file |
809 | ; esi = asciiz path & file |
896 | ; edi = buffer for path & file name |
810 | ; edi = buffer for path & file name |
897 | ; OUT: |
811 | ; OUT: |
898 | ; edi = directory & file : / 11 + / 11 + / 11 - zero terminated |
812 | ; edi = directory & file : / 11 + / 11 + / 11 - zero terminated |
899 | ; ebx = /file name - zero terminated |
813 | ; ebx = /file name - zero terminated |
900 | ; esi = pointer after source |
814 | ; esi = pointer after source |
901 | 815 | ||
902 | push eax |
816 | push eax |
903 | push ecx |
817 | push ecx |
904 | push edi ;[esp+0] |
818 | push edi ;[esp+0] |
905 | 819 | ||
906 | pathz_start: |
820 | pathz_start: |
907 | mov byte [edi],'/' |
821 | mov byte [edi],'/' |
908 | inc edi |
822 | inc edi |
909 | mov al,32 |
823 | mov al,32 |
910 | mov ecx,11 |
824 | mov ecx,11 |
911 | cld |
825 | cld |
912 | rep stosb ; clear filename area |
826 | rep stosb ; clear filename area |
913 | sub edi,11 |
827 | sub edi,11 |
914 | mov ebx,edi ; start of dir/file name |
828 | mov ebx,edi ; start of dir/file name |
915 | 829 | ||
916 | pathz_new_char: |
830 | pathz_new_char: |
917 | mov al,[esi] |
831 | mov al,[esi] |
918 | inc esi |
832 | inc esi |
919 | cmp al,0 |
833 | cmp al,0 |
920 | je pathz_end |
834 | je pathz_end |
921 | 835 | ||
922 | cmp al,'/' |
836 | cmp al,'/' |
923 | jne pathz_not_path |
837 | jne pathz_not_path |
924 | cmp edi,ebx ; skip first '/' |
838 | cmp edi,ebx ; skip first '/' |
925 | jz pathz_new_char |
839 | jz pathz_new_char |
926 | lea edi,[ebx+11] ; start of next directory |
840 | lea edi,[ebx+11] ; start of next directory |
927 | jmp pathz_start |
841 | jmp pathz_start |
928 | 842 | ||
929 | pathz_not_path: |
843 | pathz_not_path: |
930 | cmp al,'.' |
844 | cmp al,'.' |
931 | jne pathz_not_ext |
845 | jne pathz_not_ext |
932 | lea edi,[ebx+8] ; start of extension |
846 | lea edi,[ebx+8] ; start of extension |
933 | jmp pathz_new_char |
847 | jmp pathz_new_char |
934 | 848 | ||
935 | pathz_not_ext: |
849 | pathz_not_ext: |
936 | cmp al,'a' |
850 | cmp al,'a' |
937 | jb pathz_not_low |
851 | jb pathz_not_low |
938 | cmp al,'z' |
852 | cmp al,'z' |
939 | ja pathz_not_low |
853 | ja pathz_not_low |
940 | sub al,0x20 ; char to uppercase |
854 | sub al,0x20 ; char to uppercase |
941 | 855 | ||
942 | pathz_not_low: |
856 | pathz_not_low: |
943 | mov [edi],al |
857 | mov [edi],al |
944 | inc edi |
858 | inc edi |
945 | mov eax,[esp+0] ; start_of_dest_path |
859 | mov eax,[esp+0] ; start_of_dest_path |
946 | add eax,512 ; keep maximum path under 512 bytes |
860 | add eax,512 ; keep maximum path under 512 bytes |
947 | cmp edi,eax |
861 | cmp edi,eax |
948 | jb pathz_new_char |
862 | jb pathz_new_char |
949 | 863 | ||
950 | pathz_end: |
864 | pathz_end: |
951 | cmp ebx,edi ; if path end with '/' |
865 | cmp ebx,edi ; if path end with '/' |
952 | jnz pathz_put_zero ; go back 1 level |
866 | jnz pathz_put_zero ; go back 1 level |
953 | sub ebx,12 |
867 | sub ebx,12 |
954 | 868 | ||
955 | pathz_put_zero: |
869 | pathz_put_zero: |
956 | mov byte [ebx+11],0 |
870 | mov byte [ebx+11],0 |
957 | dec ebx ; include '/' char into file name |
871 | dec ebx ; include '/' char into file name |
958 | pop edi |
872 | pop edi |
959 | pop ecx |
873 | pop ecx |
960 | pop eax |
874 | pop eax |
961 | ret |
875 | ret |
962 | 876 | ||
963 | ;******************************************* |
877 | ;******************************************* |
964 | ;* string to number |
878 | ;* string to number |
965 | ;* input eax - 4 byte string |
879 | ;* input eax - 4 byte string |
966 | ;* output eax - number |
880 | ;* output eax - number |
967 | ;******************************************* |
881 | ;******************************************* |
968 | StringToNumber: |
882 | StringToNumber: |
969 | ; ÏÅÐÅÂÎÄ ÑÒÐÎÊÎÂÎÃÎ ×ÈÑËÀ  ×ÈÑËÎÂÎÉ ÂÈÄ |
883 | ; ÏÅÐÅÂÎÄ ÑÒÐÎÊÎÂÎÃÎ ×ÈÑËÀ  ×ÈÑËÎÂÎÉ ÂÈÄ |
970 | ; Âõîä: |
884 | ; Âõîä: |
971 | ; EDI - àäðåñ ñòðîêè ñ ÷èñëîì. Êîíåö ÷èñëà îòìå÷åí êîäîì 0Dh |
885 | ; EDI - àäðåñ ñòðîêè ñ ÷èñëîì. Êîíåö ÷èñëà îòìå÷åí êîäîì 0Dh |
972 | ; Âûõîä: |
886 | ; Âûõîä: |
973 | ; CF - èíäèêàòîð îøèáîê: |
887 | ; CF - èíäèêàòîð îøèáîê: |
974 | ; 0 - îøèáîê íåò; |
888 | ; 0 - îøèáîê íåò; |
975 | ; 1 - îøèáêà |
889 | ; 1 - îøèáêà |
976 | ; Åñëè CF=0, òî AX - ÷èñëî. |
890 | ; Åñëè CF=0, òî AX - ÷èñëî. |
977 | 891 | ||
978 | push bx |
892 | push bx |
979 | push cx |
893 | push cx |
980 | push dx |
894 | push dx |
981 | push edi |
895 | push edi |
982 | mov [partition_string],eax |
896 | mov [partition_string],eax |
983 | mov edi,partition_string |
897 | mov edi,partition_string |
984 | xor cx,cx |
898 | xor cx,cx |
985 | i1: |
899 | i1: |
986 | mov al,[edi] |
900 | mov al,[edi] |
987 | cmp al,32 ;13 |
901 | cmp al,32 ;13 |
988 | je i_exit |
902 | je i_exit |
989 | ; cmp al,'0' |
903 | ; cmp al,'0' |
990 | ; jb err |
904 | ; jb err |
991 | ; cmp al,'9' |
905 | ; cmp al,'9' |
992 | ; ja err |
906 | ; ja err |
993 | sub al,48 |
907 | sub al,48 |
994 | shl cx,1 |
908 | shl cx,1 |
995 | jc err |
909 | jc err |
996 | mov bx,cx |
910 | mov bx,cx |
997 | shl cx,1 |
911 | shl cx,1 |
998 | jc err |
912 | jc err |
999 | shl cx,1 |
913 | shl cx,1 |
1000 | jc err |
914 | jc err |
1001 | add cx,bx |
915 | add cx,bx |
1002 | jc err |
916 | jc err |
1003 | cbw |
917 | cbw |
1004 | add cx,ax |
918 | add cx,ax |
1005 | jc err |
919 | jc err |
1006 | i3: |
920 | i3: |
1007 | inc edi |
921 | inc edi |
1008 | jmp i1 |
922 | jmp i1 |
1009 | i_exit: |
923 | i_exit: |
1010 | mov ax,cx |
924 | mov ax,cx |
1011 | clc |
925 | clc |
1012 | i4: |
926 | i4: |
1013 | movzx eax,ax |
927 | movzx eax,ax |
1014 | pop edi |
928 | pop edi |
1015 | pop dx |
929 | pop dx |
1016 | pop cx |
930 | pop cx |
1017 | pop bx |
931 | pop bx |
1018 | ret |
932 | ret |
1019 | 933 | ||
1020 | err: |
934 | err: |
1021 | stc |
935 | stc |
1022 | jmp i4 |
936 | jmp i4 |
1023 | 937 | ||
1024 | partition_string: dd 0 |
938 | partition_string: dd 0 |
1025 | db 32>=>>=> |
939 | db 32>=>>=> |