Subversion Repositories Kolibri OS

Rev

Rev 32 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32 Rev 39
Line 26... Line 26...
26
  MEM_heap_block    rd .heap_block_info*max_heaps/4
26
  MEM_heap_block    rd .heap_block_info*max_heaps/4
27
  MEM_heap_count    rd 1
27
  MEM_heap_count    rd 1
28
  MEM_cli_count     rd 1
28
  MEM_cli_count     rd 1
29
  MEM_cli_prev      rd 1
29
  MEM_cli_prev      rd 1
30
  MEM_FreeSpace     rd 1
30
  MEM_FreeSpace     rd 1
31
  MEM_AllSpace      rd 1
31
;  MEM_AllSpace      rd 1
32
endg
32
endg
33
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34
;;MEM_Init
34
;;MEM_Init
35
;;Initialize memory manager structures.
35
;;Initialize memory manager structures.
36
;;Must be called first.
36
;;Must be called first.
Line 103... Line 103...
103
    push  edi   
103
    push  edi   
104
    mov   edi,edx
104
    mov   edi,edx
105
    shr   edi,12
105
    shr   edi,12
106
    sub   edi,ebx                ;edi=-free space
106
    sub   edi,ebx                ;edi=-free space
107
    sub   [MEM_FreeSpace],edi
107
    sub   [MEM_FreeSpace],edi
108
    sub   [MEM_AllSpace],edi
108
;    sub   [MEM_AllSpace],edi
Line 109... Line 109...
109
 
109
 
110
    mov   [eax],eax
110
    mov   [eax],eax
111
    add   [eax],edx              ;first 4 bytes - pointer to first free page
111
    add   [eax],edx              ;first 4 bytes - pointer to first free page
112
;clean page info area    
112
;clean page info area    
Line 289... Line 289...
289
;;  eax - physical address of page
289
;;  eax - physical address of page
290
;;Result:
290
;;Result:
291
;;  eax - 1 success
291
;;  eax - 1 success
292
;;  eax - 0 failed
292
;;  eax - 0 failed
293
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
293
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
294
if used MEM_Free_Page
294
if (used MEM_Free_Page) | (used MEM_Free_Page_Linear)
295
MEM_Free_Page:
295
MEM_Free_Page:
296
    test  eax,eax
296
    test  eax,eax
297
    jz    MEM_Free_Page_Zero
297
    jz    MEM_Free_Page_Zero
298
    test  eax,0xFFF
298
    test  eax,0xFFF
299
    jnz   MEM_Free_Page_Not_Aligned
299
    jnz   MEM_Free_Page_Not_Aligned
Line 363... Line 363...
363
;;  eax - 0 failed
363
;;  eax - 0 failed
364
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
364
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
365
if used MEM_Free_Page_Linear
365
if used MEM_Free_Page_Linear
366
MEM_Free_Page_Linear:
366
MEM_Free_Page_Linear:
367
    test  eax,eax
367
    test  eax,eax
368
    jz    MEM_Free_Page_Linear_Zero
368
    jz    MEM_Free_Page_Zero
369
    test  eax,0xFFF
369
    test  eax,0xFFF
370
    jnz   MEM_Free_Page_Linear_Not_Aligned
370
    jnz   MEM_Free_Page_Not_Aligned
371
    push  ebx
371
    push  ebx
372
    push  ecx
372
    push  ecx
373
    push  edx
373
    push  edx
374
    call  MEM_Heap_Lock
374
    call  MEM_Heap_Lock
375
    mov   ecx,[MEM_heap_count]
375
    mov   ecx,[MEM_heap_count]
Line 378... Line 378...
378
    
378
    
379
MEM_Free_Page_Linear_Heap_loop:
379
MEM_Free_Page_Linear_Heap_loop:
380
    sub   eax,[MEM_heap_block+ecx+.heap_linear_address]
380
    sub   eax,[MEM_heap_block+ecx+.heap_linear_address]
381
    js    MEM_Free_Page_Linear_Heap_loopnext
381
    js    MEM_Free_Page_Linear_Heap_loopnext
382
    cmp   eax,[MEM_heap_block+ecx+.heap_block_size]
382
    cmp   eax,[MEM_heap_block+ecx+.heap_block_size]
383
    jl    MEM_Free_Page_Linear_Heap_loopend
383
    jl    MEM_Free_Page_Heap_loopend
384
MEM_Free_Page_Linear_Heap_loopnext:
384
MEM_Free_Page_Linear_Heap_loopnext:
385
    add   eax,[MEM_heap_block+ecx+.heap_linear_address]
385
    add   eax,[MEM_heap_block+ecx+.heap_linear_address]
386
    sub   ecx,16
386
    sub   ecx,16
387
    jns   MEM_Free_Page_Linear_Heap_loop
387
    jns   MEM_Free_Page_Linear_Heap_loop
388
    xor   eax,eax
388
    xor   eax,eax
389
    inc   eax
389
    inc   eax
390
    jmp   MEM_Free_Page_Linear_ret
-
 
391
    
-
 
392
MEM_Free_Page_Linear_Heap_loopend:
-
 
393
    mov   ecx,[MEM_heap_block+ecx+.heap_linear_address]
-
 
394
    mov   ebx,eax
-
 
395
    add   eax,ecx   
-
 
396
    shr   ebx,10
-
 
397
    mov   edx,[ecx+.range_info+ebx]
-
 
398
    test  edx,0x80000000
-
 
399
    jnz   MEM_Free_Page_Linear_Bucket
-
 
400
    test  dx,dx
-
 
401
    jz    MEM_Free_Page_Linear_Error
-
 
402
    dec   word [ecx+.range_info+ebx]
-
 
403
    jnz   MEM_Free_Page_Linear_OK
-
 
404
MEM_Free_Page_Linear_Bucket:
-
 
405
    mov   edx,[ecx]
-
 
406
    mov   [eax],edx
-
 
407
    mov   dword [eax+4],0
-
 
408
    mov   [ecx],eax
-
 
409
    test  edx,edx
-
 
410
    jz    MEM_Free_Page_No_Next
-
 
411
    mov   [edx+4],eax
-
 
412
MEM_Free_Page_No_Next:
-
 
413
    mov   dword [ecx+.range_info+ebx],0
-
 
414
    inc   [MEM_FreeSpace]
-
 
415
MEM_Free_Page_Linear_OK:
-
 
416
    xor   eax, eax
-
 
417
    inc   eax
-
 
418
MEM_Free_Page_Linear_ret:    
-
 
419
    call  MEM_Heap_UnLock
-
 
420
    pop   edx
-
 
421
    pop   ecx
-
 
422
    pop   ebx
-
 
423
    ret
-
 
424
    
-
 
425
MEM_Free_Page_Linear_Error:
-
 
426
    xor   eax,eax
-
 
427
    jmp   MEM_Free_Page_Linear_ret
-
 
428
    
-
 
429
MEM_Free_Page_Linear_Zero:
-
 
430
    inc   eax
-
 
431
    ret
-
 
432
    
-
 
433
MEM_Free_Page_Linear_Not_Aligned:
-
 
434
    xor   eax,eax
-
 
435
    ret
390
    jmp   MEM_Free_Page_ret
436
end if
391
end if
437
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
392
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
438
;;MEM_Alloc_Pages
393
;;MEM_Alloc_Pages
439
;;Allocates set of pages.
394
;;Allocates set of pages.