Subversion Repositories Kolibri OS

Rev

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