Subversion Repositories Kolibri OS

Rev

Rev 3798 | Rev 4424 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3798 Rev 4391
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2012. 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 3798 $
8
$Revision: 4391 $
9
 
9
 
10
 
10
 
Line 282... Line 282...
282
        mov     [size], eax
282
        mov     [size], eax
Line 283... Line 283...
283
 
283
 
284
        cmp     eax, [heap_free]
284
        cmp     eax, [heap_free]
Line 285... Line 285...
285
        ja      .error
285
        ja      .error
286
 
-
 
Line 287... Line 286...
287
        mov     ecx, heap_mutex
286
 
Line 288... Line 287...
288
        call    mutex_lock
287
        spin_lock_irqsave heap_mutex
289
 
288
 
Line 343... Line 342...
343
           list_add edi, edx
342
        list_add edi, edx
344
.add_used:
343
.add_used:
Line 345... Line 344...
345
 
344
 
Line 346... Line 345...
346
        call    md.add_to_used
345
        call    md.add_to_used
347
 
-
 
348
        mov     ecx, heap_mutex
346
 
349
        call    mutex_unlock
347
        spin_unlock_irqrestore heap_mutex
350
        mov     eax, [esi+block_base]
348
        mov     eax, [esi+block_base]
351
        pop     edi
349
        pop     edi
352
        pop     esi
350
        pop     esi
Line 362... Line 360...
362
@@:
360
@@:
363
        mov     esi, edi
361
        mov     esi, edi
364
        jmp     .add_used
362
        jmp     .add_used
Line 365... Line 363...
365
 
363
 
366
.error_unlock:
364
.error_unlock:
367
        mov     ecx, heap_mutex
-
 
368
        call    mutex_unlock
365
        spin_unlock_irqrestore heap_mutex
369
.error:
366
.error:
370
        xor     eax, eax
367
        xor     eax, eax
371
        pop     edi
368
        pop     edi
372
        pop     esi
369
        pop     esi
Line 375... Line 372...
375
endp
372
endp
Line 376... Line 373...
376
 
373
 
377
align 4
374
align 4
Line 378... Line 375...
378
proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
375
proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
379
 
-
 
Line 380... Line 376...
380
        mov     ecx, heap_mutex
376
 
Line 381... Line 377...
381
        call    mutex_lock
377
        spin_lock_irqsave heap_mutex
382
 
378
 
Line 444... Line 440...
444
.add_block:
440
.add_block:
445
        bts     [mem_block_mask], eax
441
        bts     [mem_block_mask], eax
446
        lea     edx, [mem_block_list+eax*8]
442
        lea     edx, [mem_block_list+eax*8]
447
        list_add edi, edx
443
        list_add edi, edx
448
.m_eq:
444
.m_eq:
449
        mov     ecx, heap_mutex
445
        spin_unlock_irqrestore heap_mutex
450
        call    mutex_unlock
-
 
451
        xor     eax, eax
446
        xor     eax, eax
452
        not     eax
447
        not     eax
453
        ret
448
        ret
454
.insert:
449
.insert:
455
        mov     [esi+block_flags], FREE_BLOCK
450
        mov     [esi+block_flags], FREE_BLOCK
Line 457... Line 452...
457
        calc_index eax
452
        calc_index eax
458
        mov     edi, esi
453
        mov     edi, esi
459
        jmp     .add_block
454
        jmp     .add_block
Line 460... Line 455...
460
 
455
 
461
.fail:
456
.fail:
462
        mov     ecx, heap_mutex
-
 
463
        call    mutex_unlock
457
        spin_unlock_irqrestore heap_mutex
464
        xor     eax, eax
458
        xor     eax, eax
465
        ret
459
        ret
Line 466... Line 460...
466
endp
460
endp
Line 542... Line 536...
542
align 4
536
align 4
543
proc kernel_free stdcall, base:dword
537
proc kernel_free stdcall, base:dword
Line 544... Line 538...
544
 
538
 
Line 545... Line 539...
545
        push    ebx esi
539
        push    ebx esi
546
 
-
 
Line 547... Line 540...
547
        mov     ecx, heap_mutex
540
 
548
        call    mutex_lock
541
        spin_lock_irqsave heap_mutex
Line 549... Line -...
549
 
-
 
550
        mov     eax, [base]
542
 
551
        call    md.find_used
543
        mov     eax, [base]
Line 552... Line 544...
552
 
544
        call    md.find_used
Line 553... Line 545...
553
        mov     ecx, heap_mutex
545
 
554
        cmp     [esi+block_flags], USED_BLOCK
546
        cmp     [esi+block_flags], USED_BLOCK
555
        jne     .fail
547
        jne     .fail
556
 
548
 
557
        call    mutex_unlock
549
        spin_unlock_irqrestore heap_mutex
558
 
550
 
559
        mov     eax, [esi+block_base]
551
        mov     eax, [esi+block_base]
560
        mov     ecx, [esi+block_size]
552
        mov     ecx, [esi+block_size]
561
        shr     ecx, 12
553
        shr     ecx, 12
562
        call    release_pages   ;eax, ecx
554
        call    release_pages   ;eax, ecx
563
        stdcall free_kernel_space, [base]
555
        stdcall free_kernel_space, [base]
564
        pop     esi ebx
556
        pop     esi ebx
565
        ret
557
        ret