Subversion Repositories Kolibri OS

Rev

Rev 150 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 150 Rev 154
1
uglobal
1
uglobal
2
cd_current_pointer_of_input    dd  0
2
cd_current_pointer_of_input    dd  0
3
cd_current_pointer_of_input_2  dd  0
3
cd_current_pointer_of_input_2  dd  0
4
cd_mem_location                dd  0
4
cd_mem_location                dd  0
5
cd_counter_block               dd  0
5
cd_counter_block               dd  0
6
IDE_Channel_1                  db  0
6
IDE_Channel_1                  db  0
7
IDE_Channel_2                  db  0
7
IDE_Channel_2                  db  0
8
endg
8
endg
9
 
9
 
10
CDDataBuf equ 0x7000
10
CDDataBuf equ 0x7000
11
 
11
 
12
reserve_cd:
12
reserve_cd:
13
 
13
 
14
    cli
14
    cli
15
    cmp   [cd_status],0
15
    cmp   [cd_status],0
16
    je    reserve_ok2
16
    je    reserve_ok2
17
 
17
 
18
    sti
18
    sti
19
    call  change_task
19
    call  change_task
20
    jmp   reserve_cd
20
    jmp   reserve_cd
21
 
21
 
22
  reserve_ok2:
22
  reserve_ok2:
23
 
23
 
24
    push  eax
24
    push  eax
25
    mov   eax,[0x3000]
25
    mov   eax,[0x3000]
26
    shl   eax,5
26
    shl   eax,5
27
    mov   eax,[eax+0x3000+TASKDATA.pid]
27
    mov   eax,[eax+0x3000+TASKDATA.pid]
28
    mov   [cd_status],eax
28
    mov   [cd_status],eax
29
    pop   eax
29
    pop   eax
30
    sti
30
    sti
31
    ret
31
    ret
32
 
32
 
33
reserve_cd_channel:
33
reserve_cd_channel:
34
    cmp   [ChannelNumber],1
34
    cmp   [ChannelNumber],1
35
    jne   .IDE_Channel_2
35
    jne   .IDE_Channel_2
36
.IDE_Channel_1:
36
.IDE_Channel_1:
37
    cli
37
    cli
38
    cmp   [IDE_Channel_1],0
38
    cmp   [IDE_Channel_1],0
39
    je    .reserve_ok_1
39
    je    .reserve_ok_1
40
    sti
40
    sti
41
    call  change_task
41
    call  change_task
42
    jmp   .IDE_Channel_1
42
    jmp   .IDE_Channel_1
43
.IDE_Channel_2:
43
.IDE_Channel_2:
44
    cli
44
    cli
45
    cmp   [IDE_Channel_2],0
45
    cmp   [IDE_Channel_2],0
46
    je    .reserve_ok_2
46
    je    .reserve_ok_2
47
    sti
47
    sti
48
    call  change_task
48
    call  change_task
49
    jmp   .IDE_Channel_1
49
    jmp   .IDE_Channel_1
50
.reserve_ok_1:
50
.reserve_ok_1:
51
    mov [IDE_Channel_1],1
51
    mov [IDE_Channel_1],1
52
    ret
52
    ret
53
.reserve_ok_2:
53
.reserve_ok_2:
54
    mov [IDE_Channel_2],1
54
    mov [IDE_Channel_2],1
55
    ret
55
    ret
56
 
56
 
57
free_cd_channel:
57
free_cd_channel:
58
    cmp   [ChannelNumber],1
58
    cmp   [ChannelNumber],1
59
    jne   .IDE_Channel_2
59
    jne   .IDE_Channel_2
60
.IDE_Channel_1:
60
.IDE_Channel_1:
61
    mov [IDE_Channel_1],0  
61
    mov [IDE_Channel_1],0  
62
    ret
62
    ret
63
.IDE_Channel_2:
63
.IDE_Channel_2:
64
    mov [IDE_Channel_2],0
64
    mov [IDE_Channel_2],0
65
    ret
65
    ret
66
    
66
    
67
cd_status dd 0
67
cd_status dd 0
68
 
68
 
69
;----------------------------------------------------------------
69
;----------------------------------------------------------------
70
;
70
;
71
;  fs_CdRead - LFN variant for reading CD disk
71
;  fs_CdRead - LFN variant for reading CD disk
72
;
72
;
73
;  esi  points to filename /dir1/dir2/.../dirn/file,0
73
;  esi  points to filename /dir1/dir2/.../dirn/file,0
74
;  ebx  pointer to 64-bit number = first wanted byte, 0+
74
;  ebx  pointer to 64-bit number = first wanted byte, 0+
75
;       may be ebx=0 - start from first byte
75
;       may be ebx=0 - start from first byte
76
;  ecx  number of bytes to read, 0+
76
;  ecx  number of bytes to read, 0+
77
;  edx  mem location to return data
77
;  edx  mem location to return data
78
;
78
;
79
;  ret ebx = bytes read or 0xffffffff file not found
79
;  ret ebx = bytes read or 0xffffffff file not found
80
;      eax = 0 ok read or other = errormsg
80
;      eax = 0 ok read or other = errormsg
81
;
81
;
82
;--------------------------------------------------------------
82
;--------------------------------------------------------------
83
fs_CdRead:
83
fs_CdRead:
84
    push    edi
84
    push    edi
85
    cmp    byte [esi], 0
85
    cmp    byte [esi], 0
86
    jnz    @f
86
    jnz    @f
87
.noaccess:
87
.noaccess:
88
    pop    edi
88
    pop    edi
89
.noaccess_2:
89
.noaccess_2:
90
    or    ebx, -1
90
    or    ebx, -1
91
    mov    eax, ERROR_ACCESS_DENIED
91
    mov    eax, ERROR_ACCESS_DENIED
92
    ret
92
    ret
93
 
93
 
94
.noaccess_3:
94
.noaccess_3:
95
    pop     eax edx ecx edi
95
    pop     eax edx ecx edi
96
    jmp  .noaccess_2
96
    jmp  .noaccess_2
97
 
97
 
98
@@:
98
@@:
99
    call    cd_find_lfn
99
    call    cd_find_lfn
100
    jnc    .found
100
    jnc    .found
101
    pop    edi
101
    pop    edi
102
    cmp   [DevErrorCode],0
102
    cmp   [DevErrorCode],0
103
    jne   .noaccess_2
103
    jne   .noaccess_2
104
    or    ebx, -1
104
    or    ebx, -1
105
    mov    eax, ERROR_FILE_NOT_FOUND
105
    mov    eax, ERROR_FILE_NOT_FOUND
106
    ret
106
    ret
107
 
107
 
108
.found:
108
.found:
109
    mov    edi,[cd_current_pointer_of_input]
109
    mov    edi,[cd_current_pointer_of_input]
110
    test   byte [edi+25],10b    ; do not allow read directories
110
    test   byte [edi+25],10b    ; do not allow read directories
111
    jnz    .noaccess
111
    jnz    .noaccess
112
    test    ebx, ebx
112
    test    ebx, ebx
113
    jz    .l1
113
    jz    .l1
114
    cmp    dword [ebx+4], 0
114
    cmp    dword [ebx+4], 0
115
    jz    @f
115
    jz    @f
116
        xor     ebx, ebx
116
        xor     ebx, ebx
117
.reteof:
117
.reteof:
118
    mov    eax, 6 ; end of file
118
    mov    eax, 6 ; end of file
119
    pop    edi
119
    pop    edi
120
    ret
120
    ret
121
@@:
121
@@:
122
    mov    ebx, [ebx]
122
    mov    ebx, [ebx]
123
.l1:
123
.l1:
124
        push    ecx edx
124
        push    ecx edx
125
        push    0
125
        push    0
126
        mov     eax, [edi+10] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè
126
        mov     eax, [edi+10] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè
127
        sub     eax, ebx
127
        sub     eax, ebx
128
        jb      .eof
128
        jb      .eof
129
        cmp     eax, ecx
129
        cmp     eax, ecx
130
        jae     @f
130
        jae     @f
131
        mov     ecx, eax
131
        mov     ecx, eax
132
        mov     byte [esp], 6
132
        mov     byte [esp], 6
133
@@:
133
@@:
134
     mov    eax,[edi+2]
134
     mov    eax,[edi+2]
135
     mov    [CDSectorAddress],eax
135
     mov    [CDSectorAddress],eax
136
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
136
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
137
.new_sector:
137
.new_sector:
138
    test    ecx, ecx
138
    test    ecx, ecx
139
    jz    .done
139
    jz    .done
140
    sub    ebx, 2048
140
    sub    ebx, 2048
141
    jae    .new_sector
141
    jae    .next
142
    add    ebx, 2048
142
    add    ebx, 2048
143
    jnz    .incomplete_sector
143
    jnz    .incomplete_sector
144
    cmp    ecx, 2048
144
    cmp    ecx, 2048
145
    jb    .incomplete_sector
145
    jb    .incomplete_sector
146
; we may read and memmove complete sector
146
; we may read and memmove complete sector
147
    mov  [CDDataBuf_pointer],edx
147
    mov  [CDDataBuf_pointer],edx
148
    call ReadCDWRetr      ; ÷èòàåì ñåêòîð ôàéëà
148
    call ReadCDWRetr      ; ÷èòàåì ñåêòîð ôàéëà
149
    cmp   [DevErrorCode],0
149
    cmp   [DevErrorCode],0
150
    jne   .noaccess_3
150
    jne   .noaccess_3
151
    inc  dword [CDSectorAddress]
151
    add    edx, 2048
152
    add    edx, 2048
-
 
153
    sub    ecx, 2048
152
    sub    ecx, 2048
154
    jmp    .new_sector
153
.next:
-
 
154
    inc  dword [CDSectorAddress]
-
 
155
    jmp    .new_sector
155
.incomplete_sector:
156
.incomplete_sector:
156
; we must read and memmove incomplete sector
157
; we must read and memmove incomplete sector
157
    mov  [CDDataBuf_pointer],CDDataBuf
158
    mov  [CDDataBuf_pointer],CDDataBuf
158
    call ReadCDWRetr      ; ÷èòàåì ñåêòîð ôàéëà
159
    call ReadCDWRetr      ; ÷èòàåì ñåêòîð ôàéëà
159
    cmp   [DevErrorCode],0
160
    cmp   [DevErrorCode],0
160
    jne   .noaccess_3 
161
    jne   .noaccess_3 
161
    inc  dword [CDSectorAddress]
162
    push    ecx
162
    mov    eax,CDDataBuf
-
 
163
    add    eax, ebx
-
 
164
    push    ecx
-
 
165
    add    ecx, ebx
163
    add    ecx, ebx
166
    cmp    ecx, 2048
164
    cmp    ecx, 2048
167
    jbe    @f
165
    jbe    @f
168
    mov    ecx, 2048
166
    mov    ecx, 2048
169
@@:
167
@@:
170
    sub    ecx, ebx
168
    sub    ecx, ebx
171
     push edi esi ecx
169
     push edi esi ecx
172
     mov edi,edx
170
     mov edi,edx
173
     mov esi,eax ;0x7000   ; CD data buffer
171
        lea     esi, [CDDataBuf + ebx]
174
     cld
172
     cld
175
     rep movsb
173
     rep movsb
176
     pop ecx esi edi
174
     pop ecx esi edi
177
    add    edx, ecx
175
    add    edx, ecx
178
    sub    [esp], ecx
176
    sub    [esp], ecx
179
    pop    ecx
177
    pop    ecx
180
    xor    ebx, ebx
178
    xor    ebx, ebx
181
    jmp    .new_sector
179
    jmp    .next
182
     
180
     
183
.done:
181
.done:
184
        mov     ebx, edx
182
        mov     ebx, edx
185
        pop     eax edx ecx edi
183
        pop     eax edx ecx edi
186
        sub     ebx, edx
184
        sub     ebx, edx
187
        ret
185
        ret
188
.eof:
186
.eof:
189
        mov     ebx, edx
187
        mov     ebx, edx
190
        pop     eax edx ecx
188
        pop     eax edx ecx
191
        sub     ebx, edx
189
        sub     ebx, edx
192
        jmp     .reteof
190
        jmp     .reteof
193
 
191
 
194
;----------------------------------------------------------------
192
;----------------------------------------------------------------
195
;
193
;
196
;  fs_CdReadFolder - LFN variant for reading CD disk folder
194
;  fs_CdReadFolder - LFN variant for reading CD disk folder
197
;
195
;
198
;  esi  points to filename  /dir1/dir2/.../dirn/file,0
196
;  esi  points to filename  /dir1/dir2/.../dirn/file,0
199
;  ebx  pointer to structure 32-bit number = first wanted block, 0+
197
;  ebx  pointer to structure 32-bit number = first wanted block, 0+
200
;                          & flags (bitfields)
198
;                          & flags (bitfields)
201
; flags: bit 0: 0=ANSI names, 1=UNICODE names
199
; flags: bit 0: 0=ANSI names, 1=UNICODE names
202
;  ecx  number of blocks to read, 0+
200
;  ecx  number of blocks to read, 0+
203
;  edx  mem location to return data
201
;  edx  mem location to return data
204
;
202
;
205
;  ret ebx = blocks read or 0xffffffff folder not found
203
;  ret ebx = blocks read or 0xffffffff folder not found
206
;      eax = 0 ok read or other = errormsg
204
;      eax = 0 ok read or other = errormsg
207
;
205
;
208
;--------------------------------------------------------------
206
;--------------------------------------------------------------
209
fs_CdReadFolder:
207
fs_CdReadFolder:
210
        push    edi
208
        push    edi
211
        call    cd_find_lfn
209
        call    cd_find_lfn
212
        jnc     .found
210
        jnc     .found
213
        pop     edi
211
        pop     edi
214
        cmp   [DevErrorCode],0
212
        cmp   [DevErrorCode],0
215
        jne     .noaccess_1
213
        jne     .noaccess_1