Subversion Repositories Kolibri OS

Rev

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

Rev 2212 Rev 2382
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: 2212 $
8
$Revision: 2382 $
9
 
9
 
Line 169... Line 169...
169
proc map_io_mem stdcall, base:dword, size:dword, flags:dword
169
proc map_io_mem stdcall, base:dword, size:dword, flags:dword
Line 170... Line 170...
170
 
170
 
171
           push ebx
171
        push    ebx
172
           push edi
172
        push    edi
-
 
173
        mov     eax, [size]
173
           mov eax, [size]
174
        add     eax, [base]
174
           add eax, 4095
175
        add     eax, 4095
-
 
176
        and     eax, -4096
-
 
177
        mov     ecx, [base]
-
 
178
        and     ecx, -4096
175
           and eax, -4096
179
        sub     eax, ecx
-
 
180
        mov     [size], eax
176
           mov [size], eax
181
 
177
           stdcall alloc_kernel_space, eax
182
        stdcall alloc_kernel_space, eax
178
           test eax, eax
183
        test    eax, eax
179
           jz .fail
184
        jz      .fail
Line 187... Line 192...
187
           shr ecx, 12
192
        shr     ecx, 12
188
           and edx, -4096
193
        and     edx, -4096
189
           or edx, [flags]
194
        or      edx, [flags]
190
@@:
195
@@:
191
           mov [page_tabs+eax*4], edx
196
        mov     [page_tabs+eax*4], edx
192
          ; push eax
-
 
193
           invlpg [ebx]
197
        invlpg  [ebx]
194
          ; pop eax
-
 
195
           inc eax
198
        inc     eax
196
           add ebx, edi
199
        add     ebx, edi
197
           add edx, edi
200
        add     edx, edi
198
           loop @B
201
        loop    @B
Line 212... Line 215...
212
;  ebx= linear address
215
;  ebx= linear address
213
;  ecx= count
216
;  ecx= count
Line 214... Line 217...
214
 
217
 
215
align 4
218
align 4
216
commit_pages:
-
 
217
           push edi
219
commit_pages:
218
           test ecx, ecx
220
        test    ecx, ecx
Line -... Line 221...
-
 
221
        jz      .fail
-
 
222
 
219
           jz .fail
223
        push    edi
220
 
224
        push    eax
221
           mov edi, ebx
225
        push    ecx
-
 
226
        mov     ecx, pg_data.mutex
-
 
227
        call    mutex_lock
Line 222... Line 228...
222
           mov ebx, pg_data.pg_mutex
228
        pop     ecx
223
           call wait_mutex      ;ebx
229
        pop     eax
224
 
230
 
225
           mov edx, 0x1000
231
        mov     edi, ebx
226
           mov ebx, edi
-
 
227
           shr ebx, 12
232
        shr     edi, 12
228
@@:
233
        lea     edi, [page_tabs+edi*4]
229
           mov [page_tabs+ebx*4], eax
-
 
230
          ; push eax
234
@@:
231
           invlpg [edi]
235
        stosd
232
          ; pop eax
-
 
233
           add edi, edx
-
 
234
           add eax, edx
236
        invlpg  [ebx]
235
           inc ebx
-
 
236
           dec ecx
237
        add     eax, 0x1000
237
           jnz @B
238
        add     ebx, 0x1000
-
 
239
        loop    @B
-
 
240
 
-
 
241
        pop     edi
-
 
242
 
238
           mov [pg_data.pg_mutex],ecx
243
        mov     ecx, pg_data.mutex
Line 239... Line 244...
239
.fail:
244
        call    mutex_unlock
240
           pop edi
245
.fail:
241
           ret
246
        ret
Line 242... Line 247...
242
 
247
 
243
 
248
 
Line -... Line 249...
-
 
249
; param
244
; param
250
;  eax= base
245
;  eax= base
251
;  ecx= count
246
;  ecx= count
252
 
Line 247... Line 253...
247
 
253
align 4
248
align 4
254
release_pages:
Line 249... Line 255...
249
release_pages:
255
 
250
 
256
        push    ebp
-
 
257
        push    esi
-
 
258
        push    edi
-
 
259
        push    ebx
-
 
260
 
-
 
261
        mov     esi, eax
Line 251... Line 262...
251
           pushad
262
        mov     edi, eax
252
           mov ebx, pg_data.pg_mutex
263
 
253
           call wait_mutex      ;ebx
264
        shr     esi, 12
254
 
265
        lea     esi, [page_tabs+esi*4]
255
           mov esi, eax
266
 
256
           mov edi, eax
267
        push    ecx
257
 
-
 
258
           shr esi, 10
268
        mov     ecx, pg_data.mutex
259
           add esi, page_tabs
-
 
Line 260... Line 269...
260
 
269
        call    mutex_lock
261
           mov ebp, [pg_data.pages_free]
270
        pop     ecx
Line 262... Line 271...
262
           mov ebx, [page_start]
271
 
Line 283... Line 292...
283
 
292
 
284
           mov ebx, eax
293
        mov     ebx, eax
285
.next:
294
.next:
286
           add edi, 0x1000
295
        add     edi, 0x1000
287
           add esi, 4
-
 
288
           dec ecx
296
        add     esi, 4
-
 
297
        loop    @B
289
           jnz @B
298
 
290
           mov [pg_data.pages_free], ebp
299
        mov     [pg_data.pages_free], ebp
-
 
300
        mov     ecx, pg_data.mutex
-
 
301
        call    mutex_unlock
-
 
302
 
-
 
303
        pop     ebx
-
 
304
        pop     edi
291
           and [pg_data.pg_mutex],0
305
        pop     esi
292
           popad
306
        pop     ebp
Line 293... Line 307...
293
           ret
307
        ret
294
 
308
 
295
; param
309
; param
Line 421... Line 435...
421
endp
435
endp
Line 422... Line 436...
422
 
436
 
423
align 4
437
align 4
Line 424... Line 438...
424
proc new_mem_resize stdcall, new_size:dword
438
proc new_mem_resize stdcall, new_size:dword
425
 
439
 
Line 426... Line 440...
426
           mov ebx, pg_data.pg_mutex
440
        mov     ecx, pg_data.mutex
427
           call wait_mutex    ;ebx
441
        call    mutex_lock
428
 
442
 
429
           mov edi, [new_size]
443
        mov     edi, [new_size]
Line 454... Line 468...
454
           push eax
468
        push    eax
455
           invlpg [ebx]
469
        invlpg  [ebx]
456
           pop eax
470
        pop     eax
457
           call free_page
471
        call    free_page
Line -... Line 472...
-
 
472
 
458
 
473
.next:
459
.next:     add edi, 1
474
        add     edi, 1
460
           cmp edi, esi
475
        cmp     edi, esi
Line 461... Line 476...
461
           jb @B
476
        jb      @B
462
 
477
 
463
.update_size:
478
.update_size:
Line -... Line 479...
-
 
479
        mov     ebx, [new_size]
-
 
480
        call    update_mem_size
-
 
481
 
464
           mov     ebx, [new_size]
482
        mov     ecx, pg_data.mutex
465
           call    update_mem_size
-
 
466
 
483
        call    mutex_unlock
467
           xor eax, eax
484
 
Line 468... Line 485...
468
           dec [pg_data.pg_mutex]
485
        xor     eax, eax
469
           ret
486
        ret
Line 537... Line 554...
537
.out_of_memory:
554
.out_of_memory:
538
;//-
555
;//-
539
           pop edi
556
        pop     edi
540
           pop esi
557
        pop     esi
541
.exit:
558
.exit:
-
 
559
        mov     ecx, pg_data.mutex
-
 
560
        call    mutex_unlock
-
 
561
 
542
           xor eax, eax
562
        xor     eax, eax
543
           inc eax
563
        inc     eax
544
           dec [pg_data.pg_mutex]
-
 
545
           ret
564
        ret
546
endp
565
endp
Line 547... Line 566...
547
 
566
 
548
update_mem_size:
567
update_mem_size:
Line 777... Line 796...
777
;           test eax, eax
796
;           test eax, eax
778
;           jz @f
797
;           jz @f
779
;          and eax, 0xFFFFF000
798
;          and eax, 0xFFFFF000
780
;           stdcall map_page, edi, eax
799
;           stdcall map_page, edi, eax
Line -... Line 800...
-
 
800
 
781
 
801
@@:
782
@@:        mov edi, [lin_addr]
802
        mov     edi, [lin_addr]
783
           and edi, 0xFFFFF000
803
        and     edi, 0xFFFFF000
784
           mov ecx, [buf_size]
804
        mov     ecx, [buf_size]
785
           add ecx, 4095
805
        add     ecx, 4095
786
           shr ecx, 12
806
        shr     ecx, 12
Line 837... Line 857...
837
           and eax, 0xFFFFF000
857
        and     eax, 0xFFFFF000
838
           test eax, eax
858
        test    eax, eax
839
           jz .exit
859
        jz      .exit
840
           stdcall map_page,edi,eax,PG_UW
860
        stdcall map_page, edi, eax, PG_UW
Line -... Line 861...
-
 
861
 
841
 
862
@@:
842
@@:        mov edi, [lin_addr]
863
        mov     edi, [lin_addr]
843
           and edi, 0xFFFFF000
864
        and     edi, 0xFFFFF000
844
           mov ecx, [buf_size]
865
        mov     ecx, [buf_size]
845
           add ecx, 4095
866
        add     ecx, 4095
846
           shr ecx, 12
867
        shr     ecx, 12
Line 968... Line 989...
968
 
989
 
969
        add edx, ecx
990
        add     edx, ecx
970
        add edx, 4095
991
        add     edx, 4095
Line -... Line 992...
-
 
992
        and     edx, not 4095
971
        and edx, not 4095
993
 
972
 
994
.touch:
973
.touch: mov eax, [ecx]
995
        mov     eax, [ecx]
974
        add ecx, 0x1000
996
        add     ecx, 0x1000
Line 975... Line 997...
975
        cmp ecx, edx
997
        cmp     ecx, edx