Subversion Repositories Kolibri OS

Rev

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

Rev 9831 Rev 9900
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2022. 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: 9831 $
8
$Revision: 9900 $
9
 
9
 
Line 171... Line 171...
171
 
171
 
172
        push    ebx
172
        push    ebx
173
        push    edi
173
        push    edi
174
        mov     eax, [size]
174
        mov     eax, [size]
175
        add     eax, [base]
175
        add     eax, [base]
176
        add     eax, 4095
176
        add     eax, PAGE_SIZE-1
177
        and     eax, -4096
177
        and     eax, -PAGE_SIZE
178
        mov     ecx, [base]
178
        mov     ecx, [base]
179
        and     ecx, -4096
179
        and     ecx, -PAGE_SIZE
180
        sub     eax, ecx
180
        sub     eax, ecx
Line 181... Line 181...
181
        mov     [size], eax
181
        mov     [size], eax
182
 
182
 
183
        stdcall alloc_kernel_space, eax
183
        stdcall alloc_kernel_space, eax
184
        test    eax, eax
184
        test    eax, eax
Line 185... Line 185...
185
        jz      .fail
185
        jz      .fail
186
        push    eax
186
        push    eax
187
 
187
 
188
        mov     edi, 0x1000
188
        mov     edi, PAGE_SIZE
189
        mov     ebx, eax
189
        mov     ebx, eax
190
        mov     ecx, [size]
190
        mov     ecx, [size]
Line 201... Line 201...
201
        add     edx, edi
201
        add     edx, edi
202
        loop    @B
202
        loop    @B
Line 203... Line 203...
203
 
203
 
204
        pop     eax
204
        pop     eax
205
        mov     edx, [base]
205
        mov     edx, [base]
206
        and     edx, 4095
206
        and     edx, PAGE_SIZE-1
207
        add     eax, edx
207
        add     eax, edx
208
.fail:
208
.fail:
209
        pop     edi
209
        pop     edi
210
        pop     ebx
210
        pop     ebx
Line 234... Line 234...
234
        shr     edi, 12
234
        shr     edi, 12
235
        lea     edi, [page_tabs + edi*4]
235
        lea     edi, [page_tabs + edi*4]
236
@@:
236
@@:
237
        stosd
237
        stosd
238
        invlpg  [ebx]
238
        invlpg  [ebx]
239
        add     eax, 0x1000
239
        add     eax, PAGE_SIZE
240
        add     ebx, 0x1000
240
        add     ebx, PAGE_SIZE
241
        loop    @B
241
        loop    @B
Line 242... Line 242...
242
 
242
 
Line 243... Line 243...
243
        pop     edi
243
        pop     edi
Line 292... Line 292...
292
        cmp     eax, ebx
292
        cmp     eax, ebx
293
        jae     .next
293
        jae     .next
Line 294... Line 294...
294
 
294
 
295
        mov     ebx, eax
295
        mov     ebx, eax
296
.next:
296
.next:
297
        add     edi, 0x1000
297
        add     edi, PAGE_SIZE
298
        add     esi, 4
298
        add     esi, 4
Line 299... Line 299...
299
        loop    @B
299
        loop    @B
300
 
300
 
Line 325... Line 325...
325
 
325
 
326
        xor     eax, eax
326
        xor     eax, eax
327
@@:
327
@@:
328
        stosd
328
        stosd
329
        invlpg  [edx]
329
        invlpg  [edx]
330
        add     edx, 0x1000
330
        add     edx, PAGE_SIZE
Line 331... Line 331...
331
        loop    @b
331
        loop    @b
332
 
332
 
Line 338... Line 338...
338
proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
338
proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
339
        push    ebx
339
        push    ebx
340
        mov     ebx, [lin_addr]
340
        mov     ebx, [lin_addr]
341
        shr     ebx, 22
341
        shr     ebx, 22
342
        mov     eax, [phis_addr]
342
        mov     eax, [phis_addr]
343
        and     eax, not 0xFFF
343
        and     eax, -PAGE_SIZE
344
        or      eax, PG_UWR
344
        or      eax, PG_UWR
345
        mov     dword [master_tab + ebx*4], eax
345
        mov     dword [master_tab + ebx*4], eax
346
        mov     eax, [lin_addr]
346
        mov     eax, [lin_addr]
347
        shr     eax, 10
347
        shr     eax, 10
348
        add     eax, page_tabs
348
        add     eax, page_tabs
Line 387... Line 387...
387
; but we don't need it outside of this function,
387
; but we don't need it outside of this function,
388
; so we're returning physical address.
388
; so we're returning physical address.
389
; Therefore, allocate memory with kernel_alloc,
389
; Therefore, allocate memory with kernel_alloc,
390
; this will allocate physical page and a linear address somewhere,
390
; this will allocate physical page and a linear address somewhere,
391
; and deallocate only linear address with free_kernel_space.
391
; and deallocate only linear address with free_kernel_space.
392
        stdcall kernel_alloc, 0x1000
392
        stdcall kernel_alloc, PAGE_SIZE
393
        mov     edi, eax
393
        mov     edi, eax
394
        mov     esi, master_tab
394
        mov     esi, master_tab
395
        mov     ecx, 1024
395
        mov     ecx, 1024
396
        rep movsd
396
        rep movsd
397
        mov     ecx, [master_tab + (OS_BASE shr 20)]
397
        mov     ecx, [master_tab + (OS_BASE shr 20)]
Line 416... Line 416...
416
 
416
 
417
        cmp     [ebx + PROC.heap_base], 0
417
        cmp     [ebx + PROC.heap_base], 0
Line 418... Line 418...
418
        jne     .exit
418
        jne     .exit
419
 
419
 
420
        mov     edi, [new_size]
420
        mov     edi, [new_size]
421
        add     edi, 4095
421
        add     edi, PAGE_SIZE-1
Line 422... Line 422...
422
        and     edi, not 4095
422
        and     edi, not 4095
423
        mov     [new_size], edi
423
        mov     [new_size], edi
424
 
424
 
Line 425... Line 425...
425
        mov     esi, [ebx + PROC.mem_used]
425
        mov     esi, [ebx + PROC.mem_used]
426
        add     esi, 4095
426
        add     esi, PAGE_SIZE-1
427
        and     esi, not 4095
427
        and     esi, not 4095
Line 445... Line 445...
445
        invlpg  [ebx]
445
        invlpg  [ebx]
446
        call    free_page
446
        call    free_page
Line 447... Line 447...
447
 
447
 
448
.next:
448
.next:
449
        inc     edi
449
        inc     edi
450
        add     ebx, 0x1000
450
        add     ebx, PAGE_SIZE
451
        cmp     edi, esi
451
        cmp     edi, esi
Line 452... Line 452...
452
        jb      @B
452
        jb      @B
453
 
453
 
Line 546... Line 546...
546
        cmp     eax, 0x400000
546
        cmp     eax, 0x400000
547
        jb      @f
547
        jb      @f
548
        shr     eax, 12
548
        shr     eax, 12
549
        mov     eax, [page_tabs + (eax+(OS_BASE shr 12))*4]
549
        mov     eax, [page_tabs + (eax+(OS_BASE shr 12))*4]
550
@@:
550
@@:
551
        and     eax, 0xFFFFF000
551
        and     eax, -PAGE_SIZE
552
        ret
552
        ret
Line 553... Line 553...
553
 
553
 
554
 
554
 
Line 604... Line 604...
604
        jz      .fail
604
        jz      .fail
Line 605... Line 605...
605
 
605
 
Line 606... Line 606...
606
        stdcall map_page, [.err_addr], eax, PG_UWR
606
        stdcall map_page, [.err_addr], eax, PG_UWR
607
 
607
 
608
        mov     edi, [.err_addr]
608
        mov     edi, [.err_addr]
609
        and     edi, 0xFFFFF000
609
        and     edi, -PAGE_SIZE
610
        mov     ecx, 1024
610
        mov     ecx, 1024
611
        xor     eax, eax
611
        xor     eax, eax
612
       ;cld     ;caller is duty for this
612
       ;cld     ;caller is duty for this
Line 617... Line 617...
617
        iretd
617
        iretd
Line 618... Line 618...
618
 
618
 
619
.err_access:
619
.err_access:
620
; access denied? this may be a result of copy-on-write protection for DLL
620
; access denied? this may be a result of copy-on-write protection for DLL
621
; check list of HDLLs
621
; check list of HDLLs
622
        and     ebx, not 0xFFF
622
        and     ebx, -PAGE_SIZE
623
        mov     eax, [current_process]
623
        mov     eax, [current_process]
624
        mov     eax, [eax + PROC.dlls_list_ptr]
624
        mov     eax, [eax + PROC.dlls_list_ptr]
625
        test    eax, eax
625
        test    eax, eax
626
        jz      .fail
626
        jz      .fail
Line 678... Line 678...
678
 
678
 
679
        push    eax
679
        push    eax
680
        stdcall map_page, [.err_addr], eax, dword PG_SWR
680
        stdcall map_page, [.err_addr], eax, dword PG_SWR
681
        pop     eax
681
        pop     eax
682
        mov     edi, [.err_addr]
682
        mov     edi, [.err_addr]
683
        and     edi, -4096
683
        and     edi, -PAGE_SIZE
Line 684... Line 684...
684
        lea     esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0
684
        lea     esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0
685
 
685
 
686
        mov     ebx, esi
686
        mov     ebx, esi
687
        shr     ebx, 12
687
        shr     ebx, 12
688
        mov     edx, [current_slot]
688
        mov     edx, [current_slot]
Line 689... Line 689...
689
        or      eax, PG_SWR
689
        or      eax, PG_SWR
690
        mov     [edx + APPDATA.io_map + ebx*4], eax
690
        mov     [edx + APPDATA.io_map + ebx*4], eax
691
 
691
 
692
        add     esi, [default_io_map]
692
        add     esi, [default_io_map]
693
        mov     ecx, 4096/4
693
        mov     ecx, PAGE_SIZE/4
694
       ;cld     ;caller is duty for this
694
       ;cld     ;caller is duty for this
Line 717... Line 717...
717
        mov     [process], eax
717
        mov     [process], eax
718
        mov     ebx, [ofs]
718
        mov     ebx, [ofs]
719
        shr     ebx, 22
719
        shr     ebx, 22
720
        mov     eax, [eax + PROC.pdt_0 + ebx*4]                 ;get page table
720
        mov     eax, [eax + PROC.pdt_0 + ebx*4]                 ;get page table
721
        mov     esi, [ipc_ptab]
721
        mov     esi, [ipc_ptab]
722
        and     eax, 0xFFFFF000
722
        and     eax, -PAGE_SIZE
723
        jz      .exit
723
        jz      .exit
724
        stdcall map_page, esi, eax, PG_SWR
724
        stdcall map_page, esi, eax, PG_SWR
725
@@:
725
@@:
726
        mov     edi, [lin_addr]
726
        mov     edi, [lin_addr]
727
        and     edi, 0xFFFFF000
727
        and     edi, -PAGE_SIZE
728
        mov     ecx, [buf_size]
728
        mov     ecx, [buf_size]
729
        add     ecx, 4095
729
        add     ecx, PAGE_SIZE-1
730
        shr     ecx, 12
730
        shr     ecx, 12
731
        inc     ecx                  ; ???????????
731
        inc     ecx                  ; ???????????
Line 732... Line 732...
732
 
732
 
733
        mov     edx, [ofs]
733
        mov     edx, [ofs]
Line 747... Line 747...
747
        jnz     .map
747
        jnz     .map
Line 748... Line 748...
748
 
748
 
749
        inc     ebx
749
        inc     ebx
750
        mov     eax, [process]
750
        mov     eax, [process]
751
        mov     eax, [eax + PROC.pdt_0 + ebx*4]
751
        mov     eax, [eax + PROC.pdt_0 + ebx*4]
752
        and     eax, 0xFFFFF000
752
        and     eax, -PAGE_SIZE
Line 753... Line 753...
753
        jz      .exit
753
        jz      .exit
754
 
754
 
755
        stdcall map_page, esi, eax, PG_SWR
755
        stdcall map_page, esi, eax, PG_SWR
Line 780... Line 780...
780
        mov     [process], eax
780
        mov     [process], eax
781
        mov     ebx, [ofs]
781
        mov     ebx, [ofs]
782
        shr     ebx, 22
782
        shr     ebx, 22
783
        mov     eax, [eax + PROC.pdt_0 + ebx*4]                 ;get page table
783
        mov     eax, [eax + PROC.pdt_0 + ebx*4]                 ;get page table
784
        mov     esi, [proc_mem_tab]
784
        mov     esi, [proc_mem_tab]
785
        and     eax, 0xFFFFF000
785
        and     eax, -PAGE_SIZE
786
        jz      .exit
786
        jz      .exit
787
        stdcall map_page, esi, eax, PG_SWR
787
        stdcall map_page, esi, eax, PG_SWR
788
@@:
788
@@:
789
        mov     edi, [lin_addr]
789
        mov     edi, [lin_addr]
790
        and     edi, 0xFFFFF000
790
        and     edi, -PAGE_SIZE
791
        mov     ecx, [buf_size]
791
        mov     ecx, [buf_size]
792
        add     ecx, 4095
792
        add     ecx, PAGE_SIZE-1
793
        shr     ecx, 12
793
        shr     ecx, 12
794
        inc     ecx                  ; ???????????
794
        inc     ecx                  ; ???????????
Line 795... Line 795...
795
 
795
 
796
        mov     edx, [ofs]
796
        mov     edx, [ofs]
Line 810... Line 810...
810
        jnz     .map
810
        jnz     .map
Line 811... Line 811...
811
 
811
 
812
        inc     ebx
812
        inc     ebx
813
        mov     eax, [process]
813
        mov     eax, [process]
814
        mov     eax, [eax + PROC.pdt_0 + ebx*4]
814
        mov     eax, [eax + PROC.pdt_0 + ebx*4]
815
        and     eax, 0xFFFFF000
815
        and     eax, -PAGE_SIZE
Line 816... Line 816...
816
        jz      .exit
816
        jz      .exit
817
 
817
 
818
        stdcall map_page, esi, eax, PG_SWR
818
        stdcall map_page, esi, eax, PG_SWR
Line 872... Line 872...
872
        mov     ecx, [eax + HDLL.fd]
872
        mov     ecx, [eax + HDLL.fd]
873
.scan_hdll:
873
.scan_hdll:
874
        cmp     ecx, eax
874
        cmp     ecx, eax
875
        jz      .no_hdll
875
        jz      .no_hdll
876
        mov     ebx, [ofs]
876
        mov     ebx, [ofs]
877
        and     ebx, not 0xFFF
877
        and     ebx, -PAGE_SIZE
878
        sub     ebx, [ecx + HDLL.base]
878
        sub     ebx, [ecx + HDLL.base]
879
        cmp     ebx, [ecx + HDLL.size]
879
        cmp     ebx, [ecx + HDLL.size]
880
        jb      .hdll_found
880
        jb      .hdll_found
881
        mov     ecx, [ecx + HDLL.fd]
881
        mov     ecx, [ecx + HDLL.fd]
882
        jmp     .scan_hdll
882
        jmp     .scan_hdll
Line 895... Line 895...
895
        or      al, PG_UWR
895
        or      al, PG_UWR
896
        mov     [esi + edx*4], eax
896
        mov     [esi + edx*4], eax
897
        stdcall map_page, edi, eax, [req_access]
897
        stdcall map_page, edi, eax, [req_access]
898
        push    esi edi
898
        push    esi edi
899
        mov     esi, ebx
899
        mov     esi, ebx
900
        mov     ecx, 4096/4
900
        mov     ecx, PAGE_SIZE/4
901
        rep movsd
901
        rep movsd
902
        pop     edi esi
902
        pop     edi esi
903
        pop     ecx ebx
903
        pop     ecx ebx
904
        popf
904
        popf
905
        stc
905
        stc
Line 924... Line 924...
924
        cli
924
        cli
925
        mov     [eax + APPDATA.ipc_start], ecx    ;set fields in extended information area
925
        mov     [eax + APPDATA.ipc_start], ecx    ;set fields in extended information area
926
        mov     [eax + APPDATA.ipc_size], edx
926
        mov     [eax + APPDATA.ipc_size], edx
Line 927... Line 927...
927
 
927
 
928
        add     edx, ecx
928
        add     edx, ecx
929
        add     edx, 4095
929
        add     edx, PAGE_SIZE-1
Line 930... Line 930...
930
        and     edx, not 4095
930
        and     edx, -PAGE_SIZE
931
 
931
 
932
.touch:
932
.touch:
933
        mov     eax, [ecx]
933
        mov     eax, [ecx]
934
        add     ecx, 0x1000
934
        add     ecx, PAGE_SIZE
Line 935... Line 935...
935
        cmp     ecx, edx
935
        cmp     ecx, edx
936
        jb      .touch
936
        jb      .touch