Subversion Repositories Kolibri OS

Rev

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

Rev 2288 Rev 2384
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2009. 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: 2288 $
8
$Revision: 2384 $
9
 
-
 
10
 
9
 
11
struc MEM_BLOCK
10
 
12
{
11
struct  MEM_BLOCK
13
   .list        LHEAD
12
        list            LHEAD
14
   .next_block  dd ? ;+8
13
        next_block      dd ? ;+8
15
   .prev_block  dd ? ;+4
14
        prev_block      dd ? ;+4
16
   .base        dd ? ;+16
15
        base            dd ? ;+16
17
   .size        dd ? ;+20
-
 
18
   .flags       dd ? ;+24
16
        size            dd ? ;+20
Line 19... Line 17...
19
   .handle      dd ? ;+28
17
        flags           dd ? ;+24
20
   .sizeof:
18
        handle          dd ? ;+28
21
}
19
ends
Line 22... Line -...
22
 
-
 
23
FREE_BLOCK      equ  4
-
 
24
USED_BLOCK      equ  8
-
 
25
DONT_FREE_BLOCK equ  10h
-
 
Line 26... Line 20...
26
 
20
 
27
virtual at 0
21
FREE_BLOCK      equ  4
28
  MEM_BLOCK MEM_BLOCK
22
USED_BLOCK      equ  8
29
end virtual
23
DONT_FREE_BLOCK equ  10h
Line 144... Line 138...
144
        add     edx, 0x1000
138
        add     edx, 0x1000
145
        dec     ecx
139
        dec     ecx
146
        jnz     .l1
140
        jnz     .l1
Line 147... Line 141...
147
 
141
 
148
        mov     edi, HEAP_BASE                     ;descriptors
142
        mov     edi, HEAP_BASE                     ;descriptors
149
        mov     ebx, HEAP_BASE+MEM_BLOCK.sizeof      ;free space
143
        mov     ebx, HEAP_BASE+sizeof.MEM_BLOCK      ;free space
Line 150... Line 144...
150
        mov     ecx, HEAP_BASE+MEM_BLOCK.sizeof*2    ;terminator
144
        mov     ecx, HEAP_BASE+sizeof.MEM_BLOCK*2    ;terminator
151
 
145
 
152
        xor     eax, eax
146
        xor     eax, eax
153
        mov     [edi+block_next], ebx
147
        mov     [edi+block_next], ebx
154
        mov     [edi+block_prev], eax
148
        mov     [edi+block_prev], eax
155
        mov     [edi+list_fd], eax
149
        mov     [edi+list_fd], eax
156
        mov     [edi+list_bk], eax
150
        mov     [edi+list_bk], eax
157
        mov     [edi+block_base], HEAP_BASE
151
        mov     [edi+block_base], HEAP_BASE
Line 158... Line 152...
158
        mov     [edi+block_size], 4096*MEM_BLOCK.sizeof
152
        mov     [edi+block_size], 4096*sizeof.MEM_BLOCK
159
        mov     [edi+block_flags], USED_BLOCK
153
        mov     [edi+block_flags], USED_BLOCK
160
 
154
 
Line 166... Line 160...
166
        mov     [edi+block_size], eax
160
        mov     [edi+block_size], eax
167
        mov     [edi+block_flags], USED_BLOCK
161
        mov     [edi+block_flags], USED_BLOCK
Line 168... Line 162...
168
 
162
 
169
        mov     [ebx+block_next], ecx
163
        mov     [ebx+block_next], ecx
170
        mov     [ebx+block_prev], edi
164
        mov     [ebx+block_prev], edi
Line 171... Line 165...
171
        mov     [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK.sizeof
165
        mov     [ebx+block_base], HEAP_BASE+4096*sizeof.MEM_BLOCK
172
 
166
 
173
        mov     ecx, [pg_data.kernel_pages]
167
        mov     ecx, [pg_data.kernel_pages]
174
        shl     ecx, 12
168
        shl     ecx, 12
175
        sub     ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK.sizeof
169
        sub     ecx, HEAP_BASE-OS_BASE+4096*sizeof.MEM_BLOCK
176
        mov     [heap_size], ecx
170
        mov     [heap_size], ecx
177
        mov     [heap_free], ecx
171
        mov     [heap_free], ecx
Line 183... Line 177...
183
 
177
 
184
        mov     ecx, mem_block_list+63*8
178
        mov     ecx, mem_block_list+63*8
Line 185... Line 179...
185
            list_add ebx, ecx
179
            list_add ebx, ecx
186
 
180
 
Line 187... Line 181...
187
        mov     ecx, 4096-3-1
181
        mov     ecx, 4096-3-1
188
        mov     eax, HEAP_BASE+MEM_BLOCK.sizeof*4
182
        mov     eax, HEAP_BASE+sizeof.MEM_BLOCK*4
189
 
183
 
190
        mov     [next_memblock], HEAP_BASE+MEM_BLOCK.sizeof*3
184
        mov     [next_memblock], HEAP_BASE+sizeof.MEM_BLOCK *3
191
@@:
185
@@:
Line 192... Line 186...
192
        mov     [eax-MEM_BLOCK.sizeof], eax
186
        mov     [eax-sizeof.MEM_BLOCK], eax
Line 193... Line 187...
193
        add     eax, MEM_BLOCK.sizeof
187
        add     eax, sizeof.MEM_BLOCK
194
        loop    @B
188
        loop    @B
195
 
189
 
196
        mov     [eax-MEM_BLOCK.sizeof], dword 0
190
        mov     [eax-sizeof.MEM_BLOCK], dword 0
Line 1290... Line 1284...
1290
 
1284
 
1291
        add     ecx, 4095
1285
        add     ecx, 4095
1292
        and     ecx, -4096
1286
        and     ecx, -4096
Line 1293... Line 1287...
1293
        mov     [size], ecx
1287
        mov     [size], ecx
1294
 
1288
 
1295
        mov     eax, SMEM.sizeof
1289
        mov     eax, sizeof.SMEM
1296
        call    malloc
1290
        call    malloc
1297
        test    eax, eax
1291
        test    eax, eax
1298
        mov     esi, eax
1292
        mov     esi, eax
Line 1352... Line 1346...
1352
        ja      .fail
1346
        ja      .fail
Line 1353... Line 1347...
1353
 
1347
 
1354
        mov     ebx, [CURRENT_TASK]
1348
        mov     ebx, [CURRENT_TASK]
1355
        shl     ebx, 5
1349
        shl     ebx, 5
1356
        mov     ebx, [CURRENT_TASK+ebx+4]
1350
        mov     ebx, [CURRENT_TASK+ebx+4]
Line 1357... Line 1351...
1357
        mov     eax, SMAP.sizeof
1351
        mov     eax, sizeof.SMAP
1358
 
1352
 
1359
        call    create_kernel_object
1353
        call    create_kernel_object
1360
        test    eax, eax
1354
        test    eax, eax