From b4814c70842541870452b9b727db73dd37529a12 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Tue, 6 Jan 2015 14:53:54 +0000 Subject: [PATCH] kernel: update PTE bits git-svn-id: svn://kolibrios.org@5356 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/const.inc | 19 +++++++++++------ kernel/trunk/core/apic.inc | 4 ++-- kernel/trunk/core/dll.inc | 6 +++--- kernel/trunk/core/heap.inc | 8 +++---- kernel/trunk/core/memory.inc | 38 ++++++++++++++++----------------- kernel/trunk/core/mtrr.inc | 2 +- kernel/trunk/core/sys32.inc | 14 ++++++------ kernel/trunk/core/taskman.inc | 12 +++++------ kernel/trunk/core/v86.inc | 6 +++--- kernel/trunk/data32.inc | 2 ++ kernel/trunk/init.inc | 8 +++---- kernel/trunk/kernel.asm | 34 ++++++++++++++--------------- kernel/trunk/network/socket.inc | 4 ++-- 13 files changed, 82 insertions(+), 75 deletions(-) diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index 0e50123683..78403f394d 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -271,17 +271,22 @@ REG_RET equ (RING0_STACK_SIZE-56) ;irq0.return PAGE_SIZE equ 4096 PG_UNMAP equ 0x000 -PG_MAP equ 0x001 +PG_READ equ 0x001 PG_WRITE equ 0x002 -PG_SW equ 0x003 -PG_USER equ 0x005 -PG_UW equ 0x007 -PG_NOCACHE equ 0x018 -PG_LARGE equ 0x080 -PG_GLOBAL equ 0x100 +PG_USER equ 0x004 +PG_PCD equ 0x008 +PG_PWT equ 0x010 +PG_GLOBAL equ 0x100 PG_SHARED equ 0x200 +PG_SWR equ 0x003 ; (PG_WRITE+PG_READ) +PG_UR equ 0x005 ; (PG_USER+PG_READ) +PG_UWR equ 0x007 ; (PG_USER+PG_WRITE+PG_READ) +PG_NOCACHE equ 0x018 ; (PG_PCD+PG_PWT) + +PDE_LARGE equ 0x080 + ;;;;;;;;;;;boot time variables BOOT_BPP equ 0x9000 ;byte bits per pixel diff --git a/kernel/trunk/core/apic.inc b/kernel/trunk/core/apic.inc index edceecc593..41f9eb8364 100644 --- a/kernel/trunk/core/apic.inc +++ b/kernel/trunk/core/apic.inc @@ -63,7 +63,7 @@ APIC_init: call IRQ_mask_all ; IOAPIC init - stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW+PG_NOCACHE + stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SWR+PG_NOCACHE mov [IOAPIC_base], eax mov eax, IOAPIC_VER @@ -127,7 +127,7 @@ LAPIC_init: cmp [LAPIC_BASE], 0 jne .done - stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE + stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SWR+PG_NOCACHE mov [LAPIC_BASE], eax mov esi, eax diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 255aeeb151..edb5836836 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -603,7 +603,7 @@ proc load_file_umode stdcall, file_name:dword test eax, eax jz .err_3 - or eax, PG_UW + or eax, PG_UWR stosd dec edx jnz @B @@ -665,7 +665,7 @@ proc load_file_umode stdcall, file_name:dword @@: lodsd and eax, 0xFFFFF000 - or eax, PG_UW + or eax, PG_UWR stosd loop @B @@ -1230,7 +1230,7 @@ proc load_library stdcall, file_name:dword .map_pages_loop: mov eax, [page_tabs+ecx*4] and eax, not 0xFFF - or al, PG_USER + or al, PG_UR xchg eax, [page_tabs+edx*4] test al, 1 jz @f diff --git a/kernel/trunk/core/heap.inc b/kernel/trunk/core/heap.inc index 6696a0f5d8..45b8333b1b 100644 --- a/kernel/trunk/core/heap.inc +++ b/kernel/trunk/core/heap.inc @@ -130,7 +130,7 @@ proc init_kernel_heap stdcall alloc_pages, dword 32 - or eax, PG_SW + or eax, PG_SWR mov ebx, HEAP_BASE mov ecx, 32 call commit_pages @@ -492,7 +492,7 @@ proc kernel_alloc stdcall, size:dword jz .err mov ecx, ebx - or eax, PG_SW + or eax, PG_SWR mov ebx, [lin_addr] call commit_pages @@ -506,7 +506,7 @@ proc kernel_alloc stdcall, size:dword test eax, eax jz .err - stdcall map_page, edx, eax, dword PG_SW + stdcall map_page, edx, eax, dword PG_SWR add edx, 0x1000 dec ebx jnz @B @@ -1451,7 +1451,7 @@ align 4 mov edx, [access] or edx, [owner_access] shl edx, 1 - or edx, PG_USER+PG_SHARED + or edx, PG_SHARED+PG_UR @@: lodsd and eax, 0xFFFFF000 diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 000b5defeb..dce244c396 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -340,7 +340,7 @@ proc map_page_table stdcall, lin_addr:dword, phis_addr:dword shr ebx, 22 mov eax, [phis_addr] and eax, not 0xFFF - or eax, PG_UW ;+PG_NOCACHE + or eax, PG_READ mov dword [master_tab+ebx*4], eax mov eax, [lin_addr] shr eax, 10 @@ -420,7 +420,7 @@ proc init_LFB call alloc_page stdcall map_page_table, LFB_BASE, eax pop eax - or eax, PG_UW + or eax, PG_UWR mov ebx, LFB_BASE ; max VGA=640*480*4=1228800 bytes ; + 32*640*4=81920 bytes for mouse pointer @@ -447,7 +447,7 @@ proc init_LFB bt [cpu_caps], CAPS_PSE jnc .map_page_tables - or esi, PG_LARGE+PG_UW + or esi, PDE_LARGE+PG_UWR mov edx, sys_proc+PROC.pdt_0+(LFB_BASE shr 20) @@: mov [edx], esi @@ -476,7 +476,7 @@ proc init_LFB mov eax, [LFBAddress] mov edi, page_tabs + (LFB_BASE shr 10) - or eax, PG_UW + or eax, PG_UWR mov ecx, [pg_count] cld @@: @@ -679,7 +679,7 @@ end if ret .user_space: - test eax, PG_MAP + test eax, PG_READ jnz .err_access ;Страница присутствует ;Ошибка доступа ? @@ -687,7 +687,7 @@ end if mov ecx, ebx shr ecx, 10 mov edx, [master_tab+ecx*4] - test edx, PG_MAP + test edx, PG_READ jz .fail ;таблица страниц не создана ;неверный адрес в программе @@ -700,7 +700,7 @@ end if test eax, eax jz .fail - stdcall map_page, [.err_addr], eax, PG_UW + stdcall map_page, [.err_addr], eax, PG_UWR mov edi, [.err_addr] and edi, 0xFFFFF000 @@ -737,7 +737,7 @@ end if call alloc_page test eax, eax jz .fail - stdcall map_page, ebx, eax, PG_UW + stdcall map_page, ebx, eax, PG_UWR mov edi, ebx mov ecx, 1024 sub ebx, [esi+HDLL.base] @@ -748,7 +748,7 @@ end if jmp .exit .kernel_space: - test eax, PG_MAP + test eax, PG_READ jz .fail ;страница не присутствует test eax, 12 ;U/S (+below) @@ -774,7 +774,7 @@ end if jz .fail push eax - stdcall map_page, [.err_addr], eax, dword PG_SW + stdcall map_page, [.err_addr], eax, dword PG_SWR pop eax mov edi, [.err_addr] and edi, -4096 @@ -783,7 +783,7 @@ end if mov ebx, esi shr ebx, 12 mov edx, [current_slot] - or eax, PG_SW + or eax, PG_SWR mov [edx+APPDATA.io_map+ebx*4], eax add esi, [default_io_map] @@ -818,7 +818,7 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\ mov esi, [ipc_ptab] and eax, 0xFFFFF000 jz .exit - stdcall map_page, esi, eax, PG_SW + stdcall map_page, esi, eax, PG_SWR @@: mov edi, [lin_addr] and edi, 0xFFFFF000 @@ -849,7 +849,7 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\ and eax, 0xFFFFF000 jz .exit - stdcall map_page, esi, eax, PG_SW + stdcall map_page, esi, eax, PG_SWR xor edx, edx jmp .map .exit: @@ -881,7 +881,7 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\ mov esi, [proc_mem_tab] and eax, 0xFFFFF000 jz .exit - stdcall map_page, esi, eax, PG_SW + stdcall map_page, esi, eax, PG_SWR @@: mov edi, [lin_addr] and edi, 0xFFFFF000 @@ -912,7 +912,7 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\ and eax, 0xFFFFF000 jz .exit - stdcall map_page, esi, eax, PG_SW + stdcall map_page, esi, eax, PG_SWR xor edx, edx jmp .map .exit: @@ -927,7 +927,7 @@ endp ; destroys: only eax proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword mov eax, [esi+edx*4] - test al, PG_MAP + test al, PG_READ jz .not_present test al, PG_WRITE jz .resolve_readonly @@ -947,7 +947,7 @@ proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword pop ecx test eax, eax jz .fail - or al, PG_UW + or al, PG_UWR mov [esi+edx*4], eax jmp .map .resolve_readonly: @@ -989,7 +989,7 @@ proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword call alloc_page test eax, eax jz .no_hdll - or al, PG_UW + or al, PG_UWR mov [esi+edx*4], eax stdcall map_page, edi, eax, [req_access] push esi edi @@ -1090,7 +1090,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword @@: mov [used_buf], ecx stdcall map_mem_ipc, ecx, [dst_slot], \ - edi, esi, PG_SW + edi, esi, PG_SWR mov edi, [dst_offset] add edi, [used_buf] diff --git a/kernel/trunk/core/mtrr.inc b/kernel/trunk/core/mtrr.inc index 1c81b7bb8a..8d7c2bdf6e 100644 --- a/kernel/trunk/core/mtrr.inc +++ b/kernel/trunk/core/mtrr.inc @@ -848,7 +848,7 @@ proc mtrr_validate ; LFB is mapped to virtual address LFB_BASE, ; it uses global pages if supported by CPU. mov ebx, [sys_proc+PROC.pdt_0+(LFB_BASE shr 20)] - test ebx, PG_LARGE + test ebx, PDE_LARGE jnz @f mov ebx, [page_tabs+(LFB_BASE shr 10)] @@: diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index ae8ca3a843..04827cbeda 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -263,7 +263,7 @@ show_error_parameters: call .check_ESP test eax, eax jnz .error_ESP - DEBUGF 1, " [ESP+08]: %x\n",[ebx] + DEBUGF 1, " [ESP+08]: %x\n",[ebx] add ebx, 4 call .check_ESP test eax, eax @@ -293,7 +293,7 @@ show_error_parameters: call .check_ESP test eax, eax jnz .error_ESP - DEBUGF 1, " [ESP+32]: %x\n",[ebx] + DEBUGF 1, " [ESP+32]: %x\n",[ebx] pop edx ecx ebx eax ret .error_ESP: @@ -308,18 +308,18 @@ show_error_parameters: mov ecx, ebx shr ecx, 10 mov edx, [master_tab+ecx*4] - test edx, PG_MAP + test edx, PG_READ jz .fail ;page table is not created ;incorrect address in the program mov eax, [page_tabs+ebx*4] test eax, 2 jz .fail ;address not reserved for use. error - - pop ebx + + pop ebx xor eax, eax - ret - + ret + .fail: pop ebx xor eax, eax diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index b2d1c71176..1d42cf3066 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -503,7 +503,7 @@ proc create_process stdcall, app_size:dword,img_base:dword,img_size:dword rep movsd mov eax, [edi-8192+PROC.pdt_0_phys] - or eax, PG_SW + or eax, PG_SWR mov [edi-4096+(page_tabs shr 20)], eax lea eax, [edi-8192] @@ -529,7 +529,7 @@ proc create_process stdcall, app_size:dword,img_base:dword,img_size:dword rep stosd mov ecx, [img_pages] - mov ebx, PG_UW + mov ebx, PG_UWR xor edx, edx mov esi, [img_base] shr esi, 10 @@ -554,7 +554,7 @@ proc create_process stdcall, app_size:dword,img_base:dword,img_size:dword test eax, eax jz .fail - stdcall map_page, edx, eax, dword PG_UW + stdcall map_page, edx, eax, dword PG_UWR add edx, 0x1000 dec [app_pages] jnz .alloc @@ -643,7 +643,7 @@ align 4 test eax, 1 jz .next and eax, not 0xFFF - stdcall map_page, [tmp_task_ptab], eax, PG_SW + stdcall map_page, [tmp_task_ptab], eax, PG_SWR stdcall destroy_page_table, [tmp_task_ptab] mov eax, [esi] call free_page @@ -788,7 +788,7 @@ proc read_process_memory push ecx stdcall map_memEx, [proc_mem_map], \ - [slot], ebx, ecx, PG_MAP + [slot], ebx, ecx, PG_READ pop ecx mov esi, [offset] @@ -859,7 +859,7 @@ proc write_process_memory ; add ebx, new_app_base push ecx stdcall map_memEx, [proc_mem_map], \ - [slot], ebx, ecx, PG_SW + [slot], ebx, ecx, PG_SWR pop ecx mov edi, [offset] diff --git a/kernel/trunk/core/v86.inc b/kernel/trunk/core/v86.inc index 1813df3f64..30d43f8924 100644 --- a/kernel/trunk/core/v86.inc +++ b/kernel/trunk/core/v86.inc @@ -78,7 +78,7 @@ v86_create: ; (I have seen one computer with EBDA segment = 0x9D80, ; all other computers use less memory) - mov eax, PG_UW + mov eax, PG_UWR mov [page_tabs], eax invlpg [eax] @@ -89,7 +89,7 @@ v86_create: mov byte [0x504], 0x10 mov byte [0x505], 0xF4 - mov eax, 0x99000+PG_UW + mov eax, 0x99000+PG_UWR mov edi, page_tabs+0x99*4 mov edx, 0x1000 mov ecx, 7 @@ -101,7 +101,7 @@ v86_create: ; addresses 0xC0000 - 0xFFFFF - BIOS code (shared between all machines!) ; physical address = 0xC0000 - mov eax, 0xC0000+PG_UW + mov eax, 0xC0000+PG_UWR mov edi, page_tabs+0xC0*4 mov ecx, 64 @@: diff --git a/kernel/trunk/data32.inc b/kernel/trunk/data32.inc index 723a11a120..c76de9acad 100644 --- a/kernel/trunk/data32.inc +++ b/kernel/trunk/data32.inc @@ -219,6 +219,8 @@ dll_cur_addr dd MIN_DEFAULT_DLL_ADDR align 4 +pte_valid_mask dd 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR + keyboard dd 1 syslang dd 1 diff --git a/kernel/trunk/init.inc b/kernel/trunk/init.inc index 11d29d8ccf..8bcd208405 100644 --- a/kernel/trunk/init.inc +++ b/kernel/trunk/init.inc @@ -139,7 +139,7 @@ proc init_mem mov ebx, cr4 or ebx, CR4_PSE - mov eax, PG_LARGE+PG_SW + mov eax, PDE_LARGE+PG_SWR mov cr4, ebx dec [pg_data.kernel_tables-OS_BASE] @@ -149,7 +149,7 @@ proc init_mem mov edi, [tmp_page_tabs] jmp .map_kernel_heap ; new kernel fits to the first 4Mb - nothing to do with ".map_low" .no_PSE: - mov eax, PG_SW + mov eax, PG_SWR mov ecx, [tmp_page_tabs] shr ecx, 12 .map_low: @@ -168,7 +168,7 @@ proc init_mem mov ecx, [pg_data.kernel_tables-OS_BASE] mov eax, [tmp_page_tabs] - or eax, PG_SW + or eax, PG_SWR mov edi, edx .map_kernel_tabs: @@ -177,7 +177,7 @@ proc init_mem dec ecx jnz .map_kernel_tabs - mov dword [sys_proc-OS_BASE+PROC.pdt_0+(page_tabs shr 20)], sys_proc+PROC.pdt_0+PG_SW-OS_BASE + mov dword [sys_proc-OS_BASE+PROC.pdt_0+(page_tabs shr 20)], sys_proc+PROC.pdt_0+PG_SWR-OS_BASE mov edi, (sys_proc+PROC.pdt_0-OS_BASE) lea esi, [edi+(OS_BASE shr 20)] diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 47fd7087dd..03b7518252 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -575,11 +575,11 @@ setvideomode: .noSYSCALL: ; ----------------------------------------- stdcall alloc_page - stdcall map_page, tss-0xF80, eax, PG_SW + stdcall map_page, tss-0xF80, eax, PG_SWR stdcall alloc_page - stdcall map_page, tss+0x80, eax, PG_SW + stdcall map_page, tss+0x80, eax, PG_SWR stdcall alloc_page - stdcall map_page, tss+0x1080, eax, PG_SW + stdcall map_page, tss+0x1080, eax, PG_SWR ; LOAD IDT @@ -754,7 +754,7 @@ endg mov edi, OS_BASE + 8000h mov ecx, (ap_init16_size + 3) / 4 rep movsd - stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE + stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SWR+PG_NOCACHE mov [LAPIC_BASE], eax lea edi, [eax+300h] mov esi, smpt+4 @@ -1059,14 +1059,14 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code ;protect io permission map mov esi, [default_io_map] - stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP + stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ add esi, 0x1000 - stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP + stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ stdcall map_page, tss._io_map_0, \ - [SLOT_BASE+256+APPDATA.io_map], PG_MAP + [SLOT_BASE+256+APPDATA.io_map], PG_READ stdcall map_page, tss._io_map_1, \ - [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP + [SLOT_BASE+256+APPDATA.io_map+4], PG_READ ; SET KEYBOARD PARAMETERS mov al, 0xf6 ; reset keyboard, scan enabled @@ -2802,7 +2802,7 @@ align 4 align 4 @@: mov eax, [page_tabs+esi*4] - or al, PG_UW + or al, PG_UWR mov [page_tabs+ebx*4], eax mov eax, ebx shl eax, 12 @@ -5654,10 +5654,10 @@ end if .rsdp_found: mov esi, [eax+16] ; esi contains physical address of the RSDT mov ebp, [ipc_tmp] - stdcall map_page, ebp, esi, PG_MAP + stdcall map_page, ebp, esi, PG_READ lea eax, [esi+1000h] lea edx, [ebp+1000h] - stdcall map_page, edx, eax, PG_MAP + stdcall map_page, edx, eax, PG_READ and esi, 0xFFF add esi, ebp cmp dword [esi], 'RSDT' @@ -5671,10 +5671,10 @@ end if lodsd mov ebx, eax lea eax, [ebp+2000h] - stdcall map_page, eax, ebx, PG_MAP + stdcall map_page, eax, ebx, PG_READ lea eax, [ebp+3000h] add ebx, 0x1000 - stdcall map_page, eax, ebx, PG_MAP + stdcall map_page, eax, ebx, PG_READ and ebx, 0xFFF lea ebx, [ebx+ebp+2000h] cmp dword [ebx], 'FACP' @@ -5685,10 +5685,10 @@ end if ; ebx is linear address of FADT mov edi, [ebx+40] ; physical address of the DSDT lea eax, [ebp+4000h] - stdcall map_page, eax, edi, PG_MAP + stdcall map_page, eax, edi, PG_READ lea eax, [ebp+5000h] lea esi, [edi+0x1000] - stdcall map_page, eax, esi, PG_MAP + stdcall map_page, eax, esi, PG_READ and esi, 0xFFF sub edi, esi cmp dword [esi+ebp+4000h], 'DSDT' @@ -5736,8 +5736,8 @@ end if add edi, 0x1000 push eax lea eax, [ebp+4000h] - stdcall map_page, eax, edi, PG_MAP - push PG_MAP + stdcall map_page, eax, edi, PG_READ + push PG_READ lea eax, [edi+1000h] push eax lea eax, [ebp+5000h] diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index 6819d42c9e..b857b845d3 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -1481,7 +1481,7 @@ SOCKET_ring_create: mov esi, eax push edx - stdcall create_ring_buffer, SOCKET_MAXDATA, PG_SW + stdcall create_ring_buffer, SOCKET_MAXDATA, PG_SWR pop edx test eax, eax jz .fail @@ -2407,4 +2407,4 @@ SOCKET_cant_send_more: .notconn: mov dword[esp+20], ENOTCONN mov dword[esp+32], -1 - ret \ No newline at end of file + ret