Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
580 mario79 1
;**************************************************************************
2
;
3
;   [cache_ide[X]_pointer]
4
;   or [cache_ide[X]_data_pointer]  first entry in cache list
5
;
6
;            +0   - lba sector
7
;            +4   - state of cache sector
8
;                   0 = empty
9
;                   1 = used for read  ( same as in hd )
10
;                   2 = used for write ( differs from hd )
11
;
12
;  [cache_ide[X]_system_data]
13
;  or [cache_ide[x]_appl_data] - cache entries
14
;
15
;**************************************************************************
16
align 4
17
write_cache:
18
;-----------------------------------------------------------
19
; write all changed sectors to disk
20
;-----------------------------------------------------------
21
    push  eax ecx edx esi edi
22
 
23
    ; write difference ( 2 ) from cache to hd
24
    call  calculate_cache
25
    add   esi,8
26
    mov   edi,1
585 mario79 27
write_cache_more:
28
    cmp   dword [esi+4],2	; if cache slot is not different
580 mario79 29
    jne   .write_chain
585 mario79 30
    mov   dword [esi+4],1	; same as in hd
31
    mov   eax,[esi]		; eax = sector to write
580 mario79 32
    cmp   eax,[PARTITION_START]
585 mario79 33
    jb	  danger
580 mario79 34
    cmp   eax,[PARTITION_END]
585 mario79 35
    ja	  danger
580 mario79 36
; DMA write is permitted only if [allow_dma_access]=1
585 mario79 37
	cmp	[allow_dma_access], 2
38
	jae	.nodma
39
	cmp	[dma_hdd], 1
40
	jnz	.nodma
580 mario79 41
; Объединяем запись цепочки последовательных секторов в одно обращение к диску
585 mario79 42
	cmp	ecx, 1
43
	jz	.nonext
44
	cmp	dword [esi+8+4], 2
45
	jnz	.nonext
46
	push	eax
47
	inc	eax
48
	cmp	eax, [esi+8]
49
	pop	eax
50
	jnz	.nonext
51
	cmp	[cache_chain_started], 1
52
	jz	@f
53
	mov	[cache_chain_started], 1
54
	mov	[cache_chain_size], 0
55
	mov	[cache_chain_pos], edi
56
	mov	[cache_chain_ptr], esi
580 mario79 57
@@:
585 mario79 58
	inc	[cache_chain_size]
59
	cmp	[cache_chain_size], 64
60
	jnz	.continue
61
	jmp	.write_chain
580 mario79 62
.nonext:
585 mario79 63
	call	flush_cache_chain
64
	mov	[cache_chain_size], 1
65
	mov	[cache_chain_ptr], esi
66
	call	write_cache_sector
67
	jmp	.continue
580 mario79 68
.nodma:
585 mario79 69
	call	cache_write_pio
580 mario79 70
.write_chain:
585 mario79 71
	call	flush_cache_chain
580 mario79 72
.continue:
585 mario79 73
danger:
580 mario79 74
    add   esi,8
75
    inc   edi
76
    dec   ecx
77
    jnz   write_cache_more
585 mario79 78
	call	flush_cache_chain
580 mario79 79
 return_02:
80
    pop   edi esi edx ecx eax
81
    ret
82
 
83
flush_cache_chain:
585 mario79 84
	cmp	[cache_chain_started], 0
85
	jz	@f
86
	call	write_cache_chain
87
	mov	[cache_chain_started], 0
580 mario79 88
@@:
585 mario79 89
	ret
90
;--------------------------------------------------------------------
580 mario79 91
align 4
92
find_empty_slot:
93
;-----------------------------------------------------------
94
; find empty or read slot, flush cache if next 10% is used by write
95
; output : edi = cache slot
96
;-----------------------------------------------------------
97
;    push  ecx esi
98
 
585 mario79 99
search_again:
580 mario79 100
    call  calculate_cache_3
585 mario79 101
    shr   ecx,3
102
search_for_empty:
580 mario79 103
    inc   edi
104
    call  calculate_cache_4
105
    jbe   inside_cache
106
    mov   edi,1
585 mario79 107
inside_cache:
580 mario79 108
    push   esi
109
    call  calculate_cache_1
110
    cmp   dword [edi*8+esi+4],2
111
    pop   esi
585 mario79 112
    jb	  found_slot			; it's empty or read
580 mario79 113
    dec   ecx
114
    jnz   search_for_empty
585 mario79 115
    call  write_cache			; no empty slots found, write all
580 mario79 116
    cmp   [hd_error],0
117
    jne   found_slot_access_denied
585 mario79 118
    jmp   search_again			; and start again
119
found_slot:
580 mario79 120
    call  calculate_cache_5
585 mario79 121
found_slot_access_denied:
580 mario79 122
    ret
585 mario79 123
;--------------------------------------------------------------------
580 mario79 124
align 4
125
clear_hd_cache:
126
    mov   [fat_in_cache],-1
127
    mov   [fat_change],0
128
    ret
129
;--------------------------------------------------------------------
130
align 4
131
calculate_cache:
132
;    mov   ecx,cache_max         ; entries in cache
133
;    mov   esi,HD_CACHE+8
134
 
135
; 1 - IDE0 ... 4 - IDE3
136
.ide0:
137
    cmp    [hdpos],1
138
    jne    .ide1
139
    cmp    [hdd_appl_data],0
140
    jne    .ide0_appl_data
141
    mov    ecx,[cache_ide0_system_sad_size]
142
    mov    esi,[cache_ide0_pointer]
143
    ret
144
.ide0_appl_data:
145
    mov    ecx,[cache_ide0_appl_sad_size]
146
    mov    esi,[cache_ide0_data_pointer]
147
    ret
148
.ide1:
149
    cmp    [hdpos],2
150
    jne    .ide2
151
    cmp    [hdd_appl_data],0
152
    jne    .ide1_appl_data
153
    mov    ecx,[cache_ide1_system_sad_size]
154
    mov    esi,[cache_ide1_pointer]
155
    ret
156
.ide1_appl_data:
157
    mov    ecx,[cache_ide1_appl_sad_size]
158
    mov    esi,[cache_ide1_data_pointer]
159
    ret
160
.ide2:
161
    cmp    [hdpos],3
162
    jne    .ide3
163
    cmp    [hdd_appl_data],0
164
    jne    .ide2_appl_data
165
    mov    ecx,[cache_ide2_system_sad_size]
585 mario79 166
    mov    esi,[cache_ide2_pointer]
580 mario79 167
    ret
168
.ide2_appl_data:
169
    mov    ecx,[cache_ide2_appl_sad_size]
170
    mov    esi,[cache_ide2_data_pointer]
171
    ret
172
.ide3:
173
    cmp    [hdd_appl_data],0
174
    jne    .ide3_appl_data
175
    mov    ecx,[cache_ide3_system_sad_size]
585 mario79 176
    mov    esi,[cache_ide3_pointer]
580 mario79 177
    ret
178
.ide3_appl_data:
179
    mov    ecx,[cache_ide3_appl_sad_size]
180
    mov    esi,[cache_ide3_data_pointer]
181
    ret
182
;--------------------------------------------------------------------
183
align 4
184
calculate_cache_1:
185
;    lea   esi,[edi*8+HD_CACHE]
186
; 1 - IDE0 ... 4 - IDE3
187
.ide0:
188
    cmp    [hdpos],1
189
    jne    .ide1
190
    cmp    [hdd_appl_data],0
191
    jne    .ide0_appl_data
192
    mov    esi,[cache_ide0_pointer]
193
    ret
194
.ide0_appl_data:
195
    mov    esi,[cache_ide0_data_pointer]
196
    ret
197
.ide1:
198
    cmp    [hdpos],2
199
    jne    .ide2
200
    cmp    [hdd_appl_data],0
201
    jne    .ide1_appl_data
202
    mov    esi,[cache_ide1_pointer]
203
    ret
204
.ide1_appl_data:
205
    mov    esi,[cache_ide1_data_pointer]
206
    ret
207
.ide2:
208
    cmp    [hdpos],3
209
    jne    .ide3
210
    cmp    [hdd_appl_data],0
211
    jne    .ide2_appl_data
212
    mov    esi,[cache_ide2_pointer]
213
    ret
214
.ide2_appl_data:
215
    mov    esi,[cache_ide2_data_pointer]
216
    ret
217
.ide3:
218
    cmp    [hdd_appl_data],0
219
    jne    .ide3_appl_data
585 mario79 220
    mov    esi,[cache_ide3_pointer]
580 mario79 221
    ret
222
.ide3_appl_data:
223
    mov    esi,[cache_ide3_data_pointer]
224
    ret
225
;--------------------------------------------------------------------
226
align 4
227
calculate_cache_2:
228
;    add   esi,HD_CACHE+65536
229
; 1 - IDE0 ... 4 - IDE3
230
.ide0:
231
    cmp    [hdpos],1
232
    jne    .ide1
233
    cmp    [hdd_appl_data],0
234
    jne    .ide0_appl_data
585 mario79 235
    mov    eax,[cache_ide0_system_data]
580 mario79 236
    ret
237
.ide0_appl_data:
238
    mov    eax,[cache_ide0_appl_data]
239
    ret
240
.ide1:
241
    cmp    [hdpos],2
242
    jne    .ide2
243
    cmp    [hdd_appl_data],0
244
    jne    .ide1_appl_data
245
    mov    eax,[cache_ide1_system_data]
246
    ret
247
.ide1_appl_data:
248
    mov    eax,[cache_ide1_appl_data]
249
    ret
250
.ide2:
251
    cmp    [hdpos],3
252
    jne    .ide3
253
    cmp    [hdd_appl_data],0
254
    jne    .ide2_appl_data
255
    mov    eax,[cache_ide2_system_data]
256
    ret
257
.ide2_appl_data:
258
    mov    eax,[cache_ide2_appl_data]
259
    ret
260
.ide3:
261
    cmp    [hdd_appl_data],0
262
    jne    .ide3_appl_data
585 mario79 263
    mov    eax,[cache_ide3_system_data]
580 mario79 264
    ret
265
.ide3_appl_data:
266
    mov    eax,[cache_ide3_appl_data]
267
    ret
268
;--------------------------------------------------------------------
269
align 4
270
calculate_cache_3:
271
;    mov   ecx,cache_max*10/100
272
;    mov   edi,[cache_search_start]
273
 
274
; 1 - IDE0 ... 4 - IDE3
275
.ide0:
276
    cmp    [hdpos],1
277
    jne    .ide1
278
    cmp    [hdd_appl_data],0
279
    jne    .ide0_appl_data
280
    mov    ecx,[cache_ide0_system_sad_size]
281
    mov    edi,[cache_ide0_search_start]
282
    ret
283
.ide0_appl_data:
284
    mov    ecx,[cache_ide0_appl_sad_size]
285
    mov    edi,[cache_ide0_appl_search_start]
286
    ret
287
.ide1:
288
    cmp    [hdpos],2
289
    jne    .ide2
290
    cmp    [hdd_appl_data],0
291
    jne    .ide1_appl_data
292
    mov    ecx,[cache_ide1_system_sad_size]
293
    mov    edi,[cache_ide1_search_start]
294
    ret
295
.ide1_appl_data:
296
    mov    ecx,[cache_ide1_appl_sad_size]
297
    mov    edi,[cache_ide1_appl_search_start]
298
    ret
299
.ide2:
300
    cmp    [hdpos],3
301
    jne    .ide3
302
    cmp    [hdd_appl_data],0
303
    jne    .ide2_appl_data
304
    mov    ecx,[cache_ide2_system_sad_size]
585 mario79 305
    mov    edi,[cache_ide2_search_start]
580 mario79 306
    ret
307
.ide2_appl_data:
308
    mov    ecx,[cache_ide2_appl_sad_size]
309
    mov    edi,[cache_ide2_appl_search_start]
310
    ret
311
.ide3:
312
    cmp    [hdd_appl_data],0
313
    jne    .ide3_appl_data
314
    mov    ecx,[cache_ide3_system_sad_size]
585 mario79 315
    mov    edi,[cache_ide3_search_start]
580 mario79 316
    ret
317
.ide3_appl_data:
318
    mov    ecx,[cache_ide3_appl_sad_size]
319
    mov    edi,[cache_ide3_appl_search_start]
320
    ret
321
;--------------------------------------------------------------------
322
align 4
323
calculate_cache_4:
324
;    cmp   edi,cache_max
325
; 1 - IDE0 ... 4 - IDE3
326
.ide0:
327
    cmp    [hdpos],1
328
    jne    .ide1
329
    cmp    [hdd_appl_data],0
330
    jne    .ide0_appl_data
331
    cmp   edi,[cache_ide0_system_sad_size]
332
    ret
333
.ide0_appl_data:
334
    cmp   edi,[cache_ide0_appl_sad_size]
335
    ret
336
.ide1:
337
    cmp    [hdpos],2
338
    jne    .ide2
339
    cmp    [hdd_appl_data],0
340
    jne    .ide1_appl_data
341
    cmp   edi,[cache_ide1_system_sad_size]
342
    ret
343
.ide1_appl_data:
344
    cmp   edi,[cache_ide1_appl_sad_size]
345
    ret
346
.ide2:
347
    cmp    [hdpos],3
348
    jne    .ide3
349
    cmp    [hdd_appl_data],0
350
    jne    .ide2_appl_data
351
    cmp   edi,[cache_ide2_system_sad_size]
352
    ret
353
.ide2_appl_data:
354
    cmp   edi,[cache_ide2_appl_sad_size]
355
    ret
356
.ide3:
357
    cmp    [hdd_appl_data],0
358
    jne    .ide3_appl_data
359
    cmp   edi,[cache_ide3_system_sad_size]
360
    ret
361
.ide3_appl_data:
362
    cmp   edi,[cache_ide3_appl_sad_size]
363
    ret
364
;--------------------------------------------------------------------
365
align 4
366
calculate_cache_5:
367
;    mov   [cache_search_start],edi
368
; 1 - IDE0 ... 4 - IDE3
369
.ide0:
370
    cmp    [hdpos],1
371
    jne    .ide1
372
    cmp    [hdd_appl_data],0
373
    jne    .ide0_appl_data
585 mario79 374
    mov   [cache_ide0_search_start],edi
580 mario79 375
    ret
376
.ide0_appl_data:
377
    mov   [cache_ide0_appl_search_start],edi
378
    ret
379
.ide1:
380
    cmp    [hdpos],2
381
    jne    .ide2
382
    cmp    [hdd_appl_data],0
383
    jne    .ide1_appl_data
384
    mov   [cache_ide1_search_start],edi
385
    ret
386
.ide1_appl_data:
387
    mov   [cache_ide1_appl_search_start],edi
388
    ret
389
.ide2:
390
    cmp    [hdpos],3
391
    jne    .ide3
392
    cmp    [hdd_appl_data],0
393
    jne    .ide2_appl_data
394
    mov   [cache_ide2_search_start],edi
395
    ret
396
.ide2_appl_data:
397
    mov   [cache_ide2_appl_search_start],edi
398
    ret
399
.ide3:
400
    cmp    [hdd_appl_data],0
401
    jne    .ide3_appl_data
585 mario79 402
    mov   [cache_ide3_search_start],edi
580 mario79 403
    ret
404
.ide3_appl_data:
405
    mov   [cache_ide3_appl_search_start],edi
406
    ret
585 mario79 407
 
580 mario79 408
;--------------------------------------------------------------------
409
align 4
585 mario79 410
find_empty_slot_CD_cache:
411
;-----------------------------------------------------------
412
; find empty or read slot, flush cache if next 10% is used by write
413
; output : edi = cache slot
414
;-----------------------------------------------------------
415
.search_again:
416
    call  cd_calculate_cache_3
417
.search_for_empty:
418
    inc   edi
419
    call  cd_calculate_cache_4
420
    jbe   .inside_cache
421
    mov   edi,1
422
.inside_cache:
423
    call  cd_calculate_cache_5
580 mario79 424
    ret
585 mario79 425
;--------------------------------------------------------------------
426
clear_CD_cache:
427
    pusha
428
.ide0:
429
    xor   eax,eax
430
    cmp    [cdpos],1
431
    jne    .ide1
432
    mov    [cache_ide0_search_start],eax
433
    mov    ecx,[cache_ide0_system_sad_size]
434
    mov    edi,[cache_ide0_pointer]
435
    call   .clear
436
    mov    [cache_ide0_appl_search_start],eax
437
    mov    ecx,[cache_ide0_appl_sad_size]
438
    mov    edi,[cache_ide0_data_pointer]
439
    jmp    .continue
440
.ide1:
441
    cmp    [cdpos],2
442
    jne    .ide2
443
    mov    [cache_ide1_search_start],eax
444
    mov    ecx,[cache_ide1_system_sad_size]
445
    mov    edi,[cache_ide1_pointer]
446
    call   .clear
447
    mov    [cache_ide1_appl_search_start],eax
448
    mov    ecx,[cache_ide1_appl_sad_size]
449
    mov    edi,[cache_ide1_data_pointer]
450
    jmp    .continue
451
.ide2:
452
    cmp    [cdpos],3
453
    jne    .ide3
454
    mov    [cache_ide2_search_start],eax
455
    mov    ecx,[cache_ide2_system_sad_size]
456
    mov    edi,[cache_ide2_pointer]
457
    call   .clear
458
    mov    [cache_ide2_appl_search_start],eax
459
    mov    ecx,[cache_ide2_appl_sad_size]
460
    mov    edi,[cache_ide2_data_pointer]
461
    jmp    .continue
462
.ide3:
463
    mov    [cache_ide3_search_start],eax
464
    mov    ecx,[cache_ide3_system_sad_size]
465
    mov    edi,[cache_ide3_pointer]
466
    call   .clear
467
    mov    [cache_ide3_appl_search_start],eax
468
    mov    ecx,[cache_ide3_appl_sad_size]
469
    mov    edi,[cache_ide3_data_pointer]
470
.continue:
471
    call   .clear
472
    popa
473
    ret
474
.clear:
475
    shl   ecx,1
476
    cld
477
    rep   stosd
478
    ret
479
;--------------------------------------------------------------------
480
align 4
481
cd_calculate_cache:
482
;    mov   ecx,cache_max         ; entries in cache
483
;    mov   esi,HD_CACHE+8
484
 
485
; 1 - IDE0 ... 4 - IDE3
486
.ide0:
487
    cmp    [cdpos],1
488
    jne    .ide1
489
    cmp    [cd_appl_data],0
490
    jne    .ide0_appl_data
491
    mov    ecx,[cache_ide0_system_sad_size]
492
    mov    esi,[cache_ide0_pointer]
493
    ret
494
.ide0_appl_data:
495
    mov    ecx,[cache_ide0_appl_sad_size]
496
    mov    esi,[cache_ide0_data_pointer]
497
    ret
498
.ide1:
499
    cmp    [cdpos],2
500
    jne    .ide2
501
    cmp    [cd_appl_data],0
502
    jne    .ide1_appl_data
503
    mov    ecx,[cache_ide1_system_sad_size]
504
    mov    esi,[cache_ide1_pointer]
505
    ret
506
.ide1_appl_data:
507
    mov    ecx,[cache_ide1_appl_sad_size]
508
    mov    esi,[cache_ide1_data_pointer]
509
    ret
510
.ide2:
511
    cmp    [cdpos],3
512
    jne    .ide3
513
    cmp    [cd_appl_data],0
514
    jne    .ide2_appl_data
515
    mov    ecx,[cache_ide2_system_sad_size]
516
    mov    esi,[cache_ide2_pointer]
517
    ret
518
.ide2_appl_data:
519
    mov    ecx,[cache_ide2_appl_sad_size]
520
    mov    esi,[cache_ide2_data_pointer]
521
    ret
522
.ide3:
523
    cmp    [cd_appl_data],0
524
    jne    .ide3_appl_data
525
    mov    ecx,[cache_ide3_system_sad_size]
526
    mov    esi,[cache_ide3_pointer]
527
    ret
528
.ide3_appl_data:
529
    mov    ecx,[cache_ide3_appl_sad_size]
530
    mov    esi,[cache_ide3_data_pointer]
531
    ret
532
;--------------------------------------------------------------------
533
align 4
534
cd_calculate_cache_1:
535
;    lea   esi,[edi*8+HD_CACHE]
536
; 1 - IDE0 ... 4 - IDE3
537
.ide0:
538
    cmp    [cdpos],1
539
    jne    .ide1
540
    cmp    [cd_appl_data],0
541
    jne    .ide0_appl_data
542
    mov    esi,[cache_ide0_pointer]
543
    ret
544
.ide0_appl_data:
545
    mov    esi,[cache_ide0_data_pointer]
546
    ret
547
.ide1:
548
    cmp    [cdpos],2
549
    jne    .ide2
550
    cmp    [cd_appl_data],0
551
    jne    .ide1_appl_data
552
    mov    esi,[cache_ide1_pointer]
553
    ret
554
.ide1_appl_data:
555
    mov    esi,[cache_ide1_data_pointer]
556
    ret
557
.ide2:
558
    cmp    [cdpos],3
559
    jne    .ide3
560
    cmp    [cd_appl_data],0
561
    jne    .ide2_appl_data
562
    mov    esi,[cache_ide2_pointer]
563
    ret
564
.ide2_appl_data:
565
    mov    esi,[cache_ide2_data_pointer]
566
    ret
567
.ide3:
568
    cmp    [cd_appl_data],0
569
    jne    .ide3_appl_data
570
    mov    esi,[cache_ide3_pointer]
571
    ret
572
.ide3_appl_data:
573
    mov    esi,[cache_ide3_data_pointer]
574
    ret
575
;--------------------------------------------------------------------
576
align 4
577
cd_calculate_cache_2:
578
;    add   esi,HD_CACHE+65536
579
; 1 - IDE0 ... 4 - IDE3
580
.ide0:
581
    cmp    [cdpos],1
582
    jne    .ide1
583
    cmp    [cd_appl_data],0
584
    jne    .ide0_appl_data
585
    mov    eax,[cache_ide0_system_data]
586
    ret
587
.ide0_appl_data:
588
    mov    eax,[cache_ide0_appl_data]
589
    ret
590
.ide1:
591
    cmp    [cdpos],2
592
    jne    .ide2
593
    cmp    [cd_appl_data],0
594
    jne    .ide1_appl_data
595
    mov    eax,[cache_ide1_system_data]
596
    ret
597
.ide1_appl_data:
598
    mov    eax,[cache_ide1_appl_data]
599
    ret
600
.ide2:
601
    cmp    [cdpos],3
602
    jne    .ide3
603
    cmp    [cd_appl_data],0
604
    jne    .ide2_appl_data
605
    mov    eax,[cache_ide2_system_data]
606
    ret
607
.ide2_appl_data:
608
    mov    eax,[cache_ide2_appl_data]
609
    ret
610
.ide3:
611
    cmp    [cd_appl_data],0
612
    jne    .ide3_appl_data
613
    mov    eax,[cache_ide3_system_data]
614
    ret
615
.ide3_appl_data:
616
    mov    eax,[cache_ide3_appl_data]
617
    ret
618
;--------------------------------------------------------------------
619
align 4
620
cd_calculate_cache_3:
621
;    mov   ecx,cache_max*10/100
622
;    mov   edi,[cache_search_start]
623
 
624
; 1 - IDE0 ... 4 - IDE3
625
.ide0:
626
    cmp    [cdpos],1
627
    jne    .ide1
628
    cmp    [cd_appl_data],0
629
    jne    .ide0_appl_data
630
    mov    edi,[cache_ide0_search_start]
631
    ret
632
.ide0_appl_data:
633
    mov    edi,[cache_ide0_appl_search_start]
634
    ret
635
.ide1:
636
    cmp    [cdpos],2
637
    jne    .ide2
638
    cmp    [cd_appl_data],0
639
    jne    .ide1_appl_data
640
    mov    edi,[cache_ide1_search_start]
641
    ret
642
.ide1_appl_data:
643
    mov    edi,[cache_ide1_appl_search_start]
644
    ret
645
.ide2:
646
    cmp    [cdpos],3
647
    jne    .ide3
648
    cmp    [cd_appl_data],0
649
    jne    .ide2_appl_data
650
    mov    edi,[cache_ide2_search_start]
651
    ret
652
.ide2_appl_data:
653
    mov    edi,[cache_ide2_appl_search_start]
654
    ret
655
.ide3:
656
    cmp    [cd_appl_data],0
657
    jne    .ide3_appl_data
658
    mov    edi,[cache_ide3_search_start]
659
    ret
660
.ide3_appl_data:
661
    mov    edi,[cache_ide3_appl_search_start]
662
    ret
663
;--------------------------------------------------------------------
664
align 4
665
cd_calculate_cache_4:
666
;    cmp   edi,cache_max
667
; 1 - IDE0 ... 4 - IDE3
668
.ide0:
669
    cmp    [cdpos],1
670
    jne    .ide1
671
    cmp    [cd_appl_data],0
672
    jne    .ide0_appl_data
673
    cmp   edi,[cache_ide0_system_sad_size]
674
    ret
675
.ide0_appl_data:
676
    cmp   edi,[cache_ide0_appl_sad_size]
677
    ret
678
.ide1:
679
    cmp    [cdpos],2
680
    jne    .ide2
681
    cmp    [cd_appl_data],0
682
    jne    .ide1_appl_data
683
    cmp   edi,[cache_ide1_system_sad_size]
684
    ret
685
.ide1_appl_data:
686
    cmp   edi,[cache_ide1_appl_sad_size]
687
    ret
688
.ide2:
689
    cmp    [cdpos],3
690
    jne    .ide3
691
    cmp    [cd_appl_data],0
692
    jne    .ide2_appl_data
693
    cmp   edi,[cache_ide2_system_sad_size]
694
    ret
695
.ide2_appl_data:
696
    cmp   edi,[cache_ide2_appl_sad_size]
697
    ret
698
.ide3:
699
    cmp    [cd_appl_data],0
700
    jne    .ide3_appl_data
701
    cmp   edi,[cache_ide3_system_sad_size]
702
    ret
703
.ide3_appl_data:
704
    cmp   edi,[cache_ide3_appl_sad_size]
705
    ret
706
;--------------------------------------------------------------------
707
align 4
708
cd_calculate_cache_5:
709
;    mov   [cache_search_start],edi
710
; 1 - IDE0 ... 4 - IDE3
711
.ide0:
712
    cmp    [cdpos],1
713
    jne    .ide1
714
    cmp    [cd_appl_data],0
715
    jne    .ide0_appl_data
716
    mov   [cache_ide0_search_start],edi
717
    ret
718
.ide0_appl_data:
719
    mov   [cache_ide0_appl_search_start],edi
720
    ret
721
.ide1:
722
    cmp    [cdpos],2
723
    jne    .ide2
724
    cmp    [cd_appl_data],0
725
    jne    .ide1_appl_data
726
    mov   [cache_ide1_search_start],edi
727
    ret
728
.ide1_appl_data:
729
    mov   [cache_ide1_appl_search_start],edi
730
    ret
731
.ide2:
732
    cmp    [cdpos],3
733
    jne    .ide3
734
    cmp    [cd_appl_data],0
735
    jne    .ide2_appl_data
736
    mov   [cache_ide2_search_start],edi
737
    ret
738
.ide2_appl_data:
739
    mov   [cache_ide2_appl_search_start],edi
740
    ret
741
.ide3:
742
    cmp    [cd_appl_data],0
743
    jne    .ide3_appl_data
744
    mov   [cache_ide3_search_start],edi
745
    ret
746
.ide3_appl_data:
747
    mov   [cache_ide3_appl_search_start],edi
748
    ret
749
;--------------------------------------------------------------------
750
;align 4
751
;calculate_linear_to_real:
752
;    shr eax, 12
753
;    mov eax, [page_tabs+eax*4]
754
;    and eax, 0xFFFFF000
755
;    ret