Subversion Repositories Kolibri OS

Rev

Rev 96 | Rev 115 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
94 mario79 1
 
87 mario79 2
cd_current_pointer_of_input    dd  0
3
cd_current_pointer_of_input_2  dd  0
4
cd_mem_location                dd  0
5
cd_counter_block               dd  0
6
IDE_Channel_1                  db  0
95 mario79 7
IDE_Channel_2                  db  0
8
endg
87 mario79 9
10
 
11
12
 
13
14
 
15
    cmp   [cd_status],0
16
    je    reserve_ok2
17
18
 
19
    call  change_task
20
    jmp   reserve_cd
95 mario79 21
87 mario79 22
 
23
24
 
25
    mov   eax,[0x3000]
26
    shl   eax,5
27
    mov   eax,[eax+0x3000+4]
28
    mov   [cd_status],eax
29
    pop   eax
30
    sti
31
    ret
32
95 mario79 33
 
34
    cmp   [ChannelNumber],1
35
    jne   .IDE_Channel_2
36
.IDE_Channel_1:
37
    cli
38
    cmp   [IDE_Channel_1],0
39
    je    .reserve_ok_1
40
    sti
41
    call  change_task
42
    jmp   .IDE_Channel_1
43
.IDE_Channel_2:
44
    cli
45
    cmp   [IDE_Channel_2],0
46
    je    .reserve_ok_2
47
    sti
48
    call  change_task
49
    jmp   .IDE_Channel_1
50
.reserve_ok_1:
51
    mov [IDE_Channel_1],1
52
    ret
53
.reserve_ok_2:
54
    mov [IDE_Channel_2],1
55
    ret
56
57
 
58
    cmp   [ChannelNumber],1
59
    jne   .IDE_Channel_2
60
.IDE_Channel_1:
61
    mov [IDE_Channel_1],0
62
    ret
63
.IDE_Channel_2:
64
    mov [IDE_Channel_2],0
65
    ret
66
87 mario79 67
 
68
69
 
70
;
71
;  fs_CdRead - LFN variant for reading CD disk
72
;
73
;  esi  points to filename /dir1/dir2/.../dirn/file,0
74
;  ebx  pointer to 64-bit number = first wanted byte, 0+
75
;       may be ebx=0 - start from first byte
76
;  ecx  number of bytes to read, 0+
77
;  edx  mem location to return data
78
;
79
;  ret ebx = bytes read or 0xffffffff file not found
80
;      eax = 0 ok read or other = errormsg
81
;
82
;--------------------------------------------------------------
83
fs_CdRead:
84
    push    edi
85
    cmp    byte [esi], 0
86
    jnz    @f
87
.noaccess:
88
    pop    edi
89
.noaccess_2:
90
    or    ebx, -1
91
    mov    eax, ERROR_ACCESS_DENIED
92
    ret
93
94
 
95
    pop     eax edx ecx edi
96
    jmp  .noaccess_2
97
98
 
99
    call    cd_find_lfn
100
    jnc    .found
101
    pop    edi
102
    cmp   [DevErrorCode],0
103
    jne   .noaccess_2
104
    or    ebx, -1
105
    mov    eax, ERROR_FILE_NOT_FOUND
106
    ret
107
108
 
109
    mov    edi,[cd_current_pointer_of_input]
110
    test   byte [edi+25],10b    ; do not allow read directories
111
    jnz    .noaccess
112
    test    ebx, ebx
113
    jz    .l1
114
    cmp    dword [ebx+4], 0
115
    jz    @f
116
        xor     ebx, ebx
117
.reteof:
118
    mov    eax, 6 ; end of file
119
    pop    edi
120
    ret
121
@@:
122
    mov    ebx, [ebx]
123
.l1:
124
        push    ecx edx
125
        push    0
126
        mov     eax, [edi+10] ; реальный размер файловой секции
127
        sub     eax, ebx
128
        jb      .eof
129
        cmp     eax, ecx
130
        jae     @f
131
        mov     ecx, eax
132
        mov     byte [esp], 6
133
@@:
134
     mov    eax,[edi+2]
135
     mov    [CDSectorAddress],eax
136
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
137
.new_sector:
138
    test    ecx, ecx
139
    jz    .done
140
    sub    ebx, 2048
141
    jae    .new_sector
142
    add    ebx, 2048
143
    jnz    .incomplete_sector
144
    cmp    ecx, 2048
145
    jb    .incomplete_sector
146
; we may read and memmove complete sector
147
    mov  [CDDataBuf_pointer],edx
148
    call ReadCDWRetr      ; читаем сектор файла
149
    cmp   [DevErrorCode],0
150
    jne   .noaccess_3
151
    inc  dword [CDSectorAddress]
152
    add    edx, 2048
153
    sub    ecx, 2048
154
    jmp    .new_sector
155
.incomplete_sector:
156
; we must read and memmove incomplete sector
157
    mov  [CDDataBuf_pointer],CDDataBuf
158
    call ReadCDWRetr      ; читаем сектор файла
159
    cmp   [DevErrorCode],0
160
    jne   .noaccess_3
161
    inc  dword [CDSectorAddress]
162
    mov    eax,CDDataBuf
163
    add    eax, ebx
164
    push    ecx
165
    add    ecx, ebx
166
    cmp    ecx, 2048
167
    jbe    @f
168
    mov    ecx, 2048
169
@@:
170
    sub    ecx, ebx
171
     push edi esi ecx
172
     mov edi,edx
173
     mov esi,eax ;0x7000   ; CD data buffer
174
     cld
175
     rep movsb
176
     pop ecx esi edi
177
    add    edx, ecx
178
    sub    [esp], ecx
179
    pop    ecx
180
    xor    ebx, ebx
181
    jmp    .new_sector
182
183
 
184
        mov     ebx, edx
185
        pop     eax edx ecx edi
186
        sub     ebx, edx
187
        ret
188
.eof:
189
        mov     ebx, edx
190
        pop     eax edx ecx
191
        sub     ebx, edx
192
        jmp     .reteof
193
194
 
195
;
196
;  fs_CdReadFolder - LFN variant for reading CD disk folder
197
;
198
;  esi  points to filename  /dir1/dir2/.../dirn/file,0
199
;  ebx  pointer to structure 32-bit number = first wanted block, 0+
200
;                          & flags (bitfields)
201
; flags: bit 0: 0=ANSI names, 1=UNICODE names
202
;  ecx  number of blocks to read, 0+
203
;  edx  mem location to return data
204
;
205
;  ret ebx = blocks read or 0xffffffff folder not found
206
;      eax = 0 ok read or other = errormsg
207
;
208
;--------------------------------------------------------------
209
fs_CdReadFolder:
210
        push    edi
211
        call    cd_find_lfn
212
        jnc     .found
213
        pop     edi
214
        cmp   [DevErrorCode],0
215
        jne     .noaccess_1
216
        or      ebx, -1
217
        mov     eax, ERROR_FILE_NOT_FOUND
218
        ret
219
.found:
220
        mov    edi,[cd_current_pointer_of_input]
221
        test   byte [edi+25],10b    ; do not allow read directories
222
        jnz     .found_dir
223
        pop     edi
224
.noaccess_1:
225
        or      ebx, -1
226
        mov     eax, ERROR_ACCESS_DENIED
227
        ret
228
.found_dir:
229
        mov    eax,[edi+2]    ; eax=cluster
230
        mov    [CDSectorAddress],eax
231
        mov    eax,[edi+10] ; размер директрории
232
.doit:
233
; init header
234
        push    eax ecx
235
        mov     edi, edx
236
        mov     ecx, 32/4
237
        xor     eax, eax
238
        rep     stosd
239
        pop     ecx eax
240
        mov     byte [edx], 1   ; version
241
        mov     [cd_mem_location],edx
242
        add     [cd_mem_location],32
243
; начинаем переброску БДВК в УСВК
244
;.mainloop:
245
        mov  [cd_counter_block],dword 0
246
        dec  dword [CDSectorAddress]
247
        push ecx
248
.read_to_buffer:
249
        inc  dword [CDSectorAddress]
250
        mov  [CDDataBuf_pointer],CDDataBuf
251
        call ReadCDWRetr         ; читаем сектор директории
252
        cmp   [DevErrorCode],0
253
        jne   .noaccess_1
254
        call .get_names_from_buffer
255
        sub  eax,2048
256
; директория закончилась?
257
        cmp  eax,0
258
        ja   .read_to_buffer
99 mario79 259
        mov   edi,[cd_counter_block]
87 mario79 260
        mov   [edx+8],edi
261
        mov   edi,[ebx]
262
        sub   [edx+4],edi
263
        pop     ecx edi
264
        mov     ebx, [edx+4]
89 diamond 265
        mov     eax,ERROR_SUCCESS
87 mario79 266
        ret
267
268
 
269
    mov     [cd_current_pointer_of_input_2],CDDataBuf