Rev 2 | Rev 19 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 5 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; RAMDISK functions ;; |
3 | ;; RAMDISK functions ;; |
4 | ;; (C) 2004 Ville Turjanmaa, License: GPL ;; |
4 | ;; (C) 2004 Ville Turjanmaa, License: GPL ;; |
5 | ;; Addings by M.Lisovin ;; |
5 | ;; Addings by M.Lisovin ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line -... | Line 7... | ||
- | 7 | ||
- | 8 | ; calculate fat chain |
|
- | 9 | ||
- | 10 | calculatefatchain: |
|
- | 11 | ||
- | 12 | pushad |
|
- | 13 | ||
- | 14 | mov esi,0x100000+512 |
|
- | 15 | mov edi,0x280000 |
|
- | 16 | ||
- | 17 | fcnew: |
|
- | 18 | mov eax,dword [esi] |
|
- | 19 | mov ebx,dword [esi+4] |
|
- | 20 | mov ecx,dword [esi+8] |
|
- | 21 | mov edx,ecx |
|
- | 22 | shr edx,4 ;8 ok |
|
- | 23 | shr dx,4 ;7 ok |
|
- | 24 | xor ch,ch |
|
- | 25 | shld ecx,ebx,20 ;6 ok |
|
- | 26 | shr cx,4 ;5 ok |
|
- | 27 | shld ebx,eax,12 |
|
- | 28 | and ebx,0x0fffffff ;4 ok |
|
- | 29 | shr bx,4 ;3 ok |
|
- | 30 | shl eax,4 |
|
- | 31 | and eax,0x0fffffff ;2 ok |
|
- | 32 | shr ax,4 ;1 ok |
|
- | 33 | mov dword [edi],eax |
|
- | 34 | add edi,4 |
|
- | 35 | mov dword [edi],ebx |
|
- | 36 | add edi,4 |
|
- | 37 | mov dword [edi],ecx |
|
- | 38 | add edi,4 |
|
- | 39 | mov dword [edi],edx |
|
- | 40 | add edi,4 |
|
- | 41 | add esi,12 |
|
- | 42 | ||
- | 43 | cmp edi,0x280000+2856*2 ;2849 clusters |
|
- | 44 | jnz fcnew |
|
- | 45 | ||
- | 46 | popad |
|
- | 47 | ret |
|
- | 48 | ||
- | 49 | ||
- | 50 | restorefatchain: ; restore fat chain |
|
- | 51 | ||
- | 52 | pushad |
|
- | 53 | ||
- | 54 | mov esi,0x280000 |
|
- | 55 | mov edi,0x100000+512 |
|
- | 56 | ||
- | 57 | fcnew2: |
|
- | 58 | mov eax,dword [esi] |
|
- | 59 | mov ebx,dword [esi+4] |
|
- | 60 | shl ax,4 |
|
- | 61 | shl eax,4 |
|
- | 62 | shl bx,4 |
|
- | 63 | shr ebx,4 |
|
- | 64 | shrd eax,ebx,8 |
|
- | 65 | shr ebx,8 |
|
- | 66 | mov dword [edi],eax |
|
- | 67 | add edi,4 |
|
- | 68 | mov word [edi],bx |
|
- | 69 | add edi,2 |
|
- | 70 | add esi,8 |
|
- | 71 | ||
- | 72 | cmp edi,0x100000+512+4278 ;4274 bytes - all used FAT |
|
- | 73 | jb fcnew2 |
|
- | 74 | ||
- | 75 | mov esi,0x100000+512 ; duplicate fat chain |
|
- | 76 | mov edi,0x100000+512+0x1200 |
|
- | 77 | mov ecx,1069 ;4274/4 |
|
- | 78 | cld |
|
- | 79 | rep movsd |
|
- | 80 | ||
- | 81 | popad |
|
- | 82 | ret |
|
Line 7... | Line 83... | ||
7 | 83 | ||
8 | 84 | ||
9 | ramdisk_free_space: |
85 | ramdisk_free_space: |
10 | ;--------------------------------------------- |
86 | ;--------------------------------------------- |
Line 16... | Line 92... | ||
16 | push eax ebx ecx |
92 | push eax ebx ecx |
Line 17... | Line 93... | ||
17 | 93 | ||
18 | mov edi,0x280000 ;start of FAT |
94 | mov edi,0x280000 ;start of FAT |
19 | xor ax,ax ;Free cluster=0x0000 in FAT |
95 | xor ax,ax ;Free cluster=0x0000 in FAT |
20 | xor ebx,ebx ;counter |
96 | xor ebx,ebx ;counter |
21 | mov ecx,2847 ;2849 ;2849 clusters |
97 | mov ecx,2849 ;2849 clusters |
22 | cld |
98 | cld |
23 | rdfs1: |
99 | rdfs1: |
24 | repne scasw |
100 | repne scasw |
25 | jnz rdfs2 ;if last cluster not 0 |
101 | jnz rdfs2 ;if last cluster not 0 |
Line 120... | Line 196... | ||
120 | mov edi,edx |
196 | mov edi,edx |
121 | dec ebx |
197 | dec ebx |
122 | push edx |
198 | push edx |
123 | mov edx,ecx |
199 | mov edx,ecx |
124 | add edx,ebx |
200 | add edx,ebx |
125 | cmp edx,14 ;ebx+ecx=14 |
201 | cmp edx,15 ;ebx+ecx=14+1 |
126 | pushf |
202 | pushf |
127 | jbe fr_do1 |
203 | jbe fr_do1 |
128 | sub edx,14 |
204 | sub edx,14 |
129 | sub ecx,edx |
205 | sub ecx,edx |
130 | fr_do1: |
206 | fr_do1: |
Line 134... | Line 210... | ||
134 | shl ecx,7 |
210 | shl ecx,7 |
135 | cld |
211 | cld |
136 | rep movsd |
212 | rep movsd |
137 | popf |
213 | popf |
138 | pop edx |
214 | pop edx |
139 | ; jae fr_do2 |
215 | jae fr_do2 |
140 | xor eax,eax ; ok read |
216 | xor eax,eax ; ok read |
141 | xor ebx,ebx |
217 | xor ebx,ebx |
142 | ret |
218 | ret |
143 | fr_do2: ;if last cluster |
219 | fr_do2: ;if last cluster |
144 | mov eax,6 ;end of file |
220 | mov eax,6 ;end of file |