Rev 887 | Rev 928 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 887 | Rev 897 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2007-2008. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2007-2008. 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: 887 $ |
8 | $Revision: 897 $ |
9 | 9 | ||
Line 10... | Line 10... | ||
10 | ; Virtual-8086 mode manager |
10 | ; Virtual-8086 mode manager |
Line 47... | Line 47... | ||
47 | ; First is main page directory for V86 mode. |
47 | ; First is main page directory for V86 mode. |
48 | ; Second page: |
48 | ; Second page: |
49 | ; first half (0x800 bytes) is page table for addresses 0 - 0x100000, |
49 | ; first half (0x800 bytes) is page table for addresses 0 - 0x100000, |
50 | ; second half is for V86-to-linear translation. |
50 | ; second half is for V86-to-linear translation. |
51 | ; Third and fourth are for I/O permission map. |
51 | ; Third and fourth are for I/O permission map. |
- | 52 | ||
52 | mov ecx, 2 |
53 | mov ecx, 0x4000 |
- | 54 | mov edx, PG_SW |
|
53 | call @core_alloc@4 |
55 | call @mem_alloc@8 |
54 | test eax, eax |
56 | test eax, eax |
55 | jz .fail2 |
57 | jz .fail2 |
56 | add eax, OS_BASE |
- | |
57 | mov [ebx+V86_machine.pagedir], eax |
58 | mov [ebx+V86_machine.pagedir], eax |
58 | push edi eax |
59 | push edi eax |
59 | mov edi, eax |
60 | mov edi, eax |
60 | add eax, 1800h |
61 | add eax, 1800h |
61 | mov [ebx+V86_machine.pages], eax |
62 | mov [ebx+V86_machine.pages], eax |
Line 70... | Line 71... | ||
70 | pop eax |
71 | pop eax |
71 | ; page directory: first entry is page table... |
72 | ; page directory: first entry is page table... |
72 | mov edi, eax |
73 | mov edi, eax |
73 | add eax, 1000h |
74 | add eax, 1000h |
74 | push eax |
75 | push eax |
75 | sub eax, OS_BASE |
76 | call get_pg_addr |
76 | or al, PG_UW |
77 | or al, PG_UW |
77 | stosd |
78 | stosd |
78 | ; ...and also copy system page tables |
79 | ; ...and also copy system page tables |
79 | ; thx to Serge, system is located at high addresses |
80 | ; thx to Serge, system is located at high addresses |
80 | add edi, (OS_BASE shr 20) - 4 |
81 | add edi, (HEAP_BASE shr 20) - 4 |
81 | push esi |
82 | push esi |
82 | mov esi, (OS_BASE shr 20) + _sys_pdbr |
83 | mov esi, (HEAP_BASE shr 20) + _sys_pdbr |
83 | mov ecx, 0x80000000 shr 22 |
84 | mov ecx, 0x80000000 shr 22 |
84 | rep movsd |
85 | rep movsd |
Line 85... | Line 86... | ||
85 | 86 | ||
86 | mov eax, [ebx+V86_machine.pagedir] ;root dir also is |
87 | mov eax, [ebx+V86_machine.pagedir] ;root dir also is |
Line 108... | Line 109... | ||
108 | @@: |
109 | @@: |
109 | lea eax, [edx + OS_BASE] |
110 | lea eax, [edx + OS_BASE] |
110 | mov [edi+800h], eax |
111 | mov [edi+800h], eax |
111 | lea eax, [edx + 111b] |
112 | lea eax, [edx + 111b] |
112 | stosd |
113 | stosd |
- | 114 | add edx, 0x1000 |
|
113 | loop @b |
115 | loop @b |
114 | pop eax |
116 | pop eax |
115 | pop edi |
117 | pop edi |
116 | ; addresses 0xC0000 - 0xFFFFF - BIOS code (shared between all machines!) |
118 | ; addresses 0xC0000 - 0xFFFFF - BIOS code (shared between all machines!) |
117 | ; physical address = 0xC0000 |
119 | ; physical address = 0xC0000 |
Line 143... | Line 145... | ||
143 | ; destroys: eax, ebx, ecx, edx (due to free) |
145 | ; destroys: eax, ebx, ecx, edx (due to free) |
144 | v86_destroy: |
146 | v86_destroy: |
145 | push eax |
147 | push eax |
Line 146... | Line 148... | ||
146 | 148 | ||
147 | mov ecx, [eax+V86_machine.pagedir] |
- | |
148 | sub ecx, OS_BASE |
149 | mov ecx, [eax+V86_machine.pagedir] |
Line 149... | Line 150... | ||
149 | call @core_free@4 |
150 | call @mem_free@4 |
150 | 151 | ||
Line 151... | Line 152... | ||
151 | pop eax |
152 | pop eax |
Line 298... | Line 299... | ||
298 | call get_pg_addr |
299 | call get_pg_addr |
299 | inc eax |
300 | inc eax |
300 | push dword [ecx+APPDATA.io_map] |
301 | push dword [ecx+APPDATA.io_map] |
301 | push dword [ecx+APPDATA.io_map+4] |
302 | push dword [ecx+APPDATA.io_map+4] |
302 | mov dword [ecx+APPDATA.io_map], eax |
303 | mov dword [ecx+APPDATA.io_map], eax |
303 | mov dword [page_tabs + (tss._io_map_0 shr 10)], eax |
304 | ; mov dword [page_tabs + (tss._io_map_0 shr 10)], eax |
304 | add eax, 0x1000 |
305 | add eax, 0x1000 |
305 | mov dword [ecx+APPDATA.io_map+4], eax |
306 | mov dword [ecx+APPDATA.io_map+4], eax |
306 | mov dword [page_tabs + (tss._io_map_1 shr 10)], eax |
307 | ; mov dword [page_tabs + (tss._io_map_1 shr 10)], eax |
Line 307... | Line 308... | ||
307 | 308 | ||
308 | push [ecx+APPDATA.dir_table] |
309 | push [ecx+APPDATA.dir_table] |
309 | push [ecx+APPDATA.saved_esp0] |
310 | push [ecx+APPDATA.saved_esp0] |
310 | mov [ecx+APPDATA.saved_esp0], esp |
311 | mov [ecx+APPDATA.saved_esp0], esp |
Line 818... | Line 819... | ||
818 | mov [tss._esp0], eax |
819 | mov [tss._esp0], eax |
819 | pop eax |
820 | pop eax |
820 | mov [SLOT_BASE+ecx+APPDATA.dir_table], eax |
821 | mov [SLOT_BASE+ecx+APPDATA.dir_table], eax |
821 | pop ebx |
822 | pop ebx |
822 | mov dword [SLOT_BASE+ecx+APPDATA.io_map+4], ebx |
823 | mov dword [SLOT_BASE+ecx+APPDATA.io_map+4], ebx |
823 | mov dword [page_tabs + (tss._io_map_1 shr 10)], ebx |
824 | ; mov dword [page_tabs + (tss._io_map_1 shr 10)], ebx |
824 | pop ebx |
825 | pop ebx |
825 | mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx |
826 | mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx |
826 | mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx |
827 | ; mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx |
827 | mov cr3, eax |
828 | mov cr3, eax |
828 | ; mov [irq_tab+5*4], 0 |
829 | ; mov [irq_tab+5*4], 0 |
829 | sti |
830 | sti |
Line 830... | Line 831... | ||
830 | 831 |