Subversion Repositories Kolibri OS

Rev

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

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