Subversion Repositories Kolibri OS

Rev

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

Rev 1213 Rev 1289
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2009. 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: 1213 $
8
$Revision: 1289 $
9
 
9
 
10
 
10
 
Line 752... Line 752...
752
           pop edi
752
           pop edi
753
           pop esi
753
           pop esi
754
           pop ebx
754
           pop ebx
755
           ret
755
           ret
756
endp
756
endp
-
 
757
 
-
 
758
align 4
-
 
759
proc user_alloc_at stdcall, address:dword, alloc_size:dword
-
 
760
 
-
 
761
           push ebx
-
 
762
           push esi
-
 
763
           push edi
-
 
764
 
-
 
765
           mov ebx, [current_slot]
-
 
766
           mov edx, [address]
-
 
767
           and edx, not 0xFFF
-
 
768
           mov [address], edx
-
 
769
           sub edx, 0x1000
-
 
770
           jb  .error
-
 
771
           mov esi, [ebx+APPDATA.heap_base]
-
 
772
           mov edi, [ebx+APPDATA.heap_top]
-
 
773
           cmp edx, esi
-
 
774
           jb  .error
-
 
775
.scan:
-
 
776
           cmp esi, edi
-
 
777
           jae .error
-
 
778
           mov ebx, esi
-
 
779
           shr ebx, 12
-
 
780
           mov eax, [page_tabs+ebx*4]
-
 
781
           mov ecx, eax
-
 
782
           and ecx, 0xFFFFF000
-
 
783
           add ecx, esi
-
 
784
           cmp edx, ecx
-
 
785
           jb  .found
-
 
786
           mov esi, ecx
-
 
787
           jmp .scan
-
 
788
.error:
-
 
789
           xor eax, eax
-
 
790
           pop edi
-
 
791
           pop esi
-
 
792
           pop ebx
-
 
793
           ret
-
 
794
.found:
-
 
795
           test al, FREE_BLOCK
-
 
796
           jz  .error
-
 
797
           mov eax, ecx
-
 
798
           sub eax, edx
-
 
799
           sub eax, 0x1000
-
 
800
           cmp eax, [alloc_size]
-
 
801
           jb  .error
-
 
802
 
-
 
803
; Here we have 1 big free block which includes requested area.
-
 
804
; In general, 3 other blocks must be created instead:
-
 
805
; free at [esi, edx);
-
 
806
; busy at [edx, edx+0x1000+ALIGN_UP(alloc_size,0x1000));
-
 
807
; free at [edx+0x1000+ALIGN_UP(alloc_size,0x1000), ecx)
-
 
808
; First or third block (or both) may be absent.
-
 
809
           mov eax, edx
-
 
810
           sub eax, esi
-
 
811
           jz  .nofirst
-
 
812
           or  al, FREE_BLOCK
-
 
813
           mov [page_tabs+ebx*4], eax
-
 
814
.nofirst:
-
 
815
           mov eax, [alloc_size]
-
 
816
           add eax, 0x1FFF
-
 
817
           and eax, not 0xFFF
-
 
818
           mov ebx, edx
-
 
819
           add edx, eax
-
 
820
           shr ebx, 12
-
 
821
           or  al, USED_BLOCK
-
 
822
           mov [page_tabs+ebx*4], eax
-
 
823
           shr eax, 12
-
 
824
           dec eax
-
 
825
           jz  .second_nofill
-
 
826
           inc ebx
-
 
827
.fill:
-
 
828
           mov dword [page_tabs+ebx*4], 2
-
 
829
           inc ebx
-
 
830
           dec eax
-
 
831
           jnz .fill
-
 
832
.second_nofill:
-
 
833
           sub ecx, edx
-
 
834
           jz  .nothird
-
 
835
           or  cl, FREE_BLOCK
-
 
836
           mov [page_tabs+ebx*4], ecx
-
 
837
.nothird:
-
 
838
 
-
 
839
           mov     edx, [current_slot]
-
 
840
           mov     ebx, [alloc_size]
-
 
841
           add     ebx, 0xFFF
-
 
842
           and     ebx, not 0xFFF
-
 
843
           add     ebx, [edx+APPDATA.mem_size]
-
 
844
           call    update_mem_size
-
 
845
 
-
 
846
           mov eax, [address]
-
 
847
 
-
 
848
           pop edi
-
 
849
           pop esi
-
 
850
           pop ebx
-
 
851
           ret
-
 
852
endp
Line 757... Line 853...
757
 
853
 
758
align 4
854
align 4
Line 759... Line 855...
759
proc user_free stdcall, base:dword
855
proc user_free stdcall, base:dword