diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index 5f78987d14..4778afc991 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -226,9 +226,10 @@ resendQ equ OS_BASE+0x0770000 ;skin_data equ OS_BASE+0x0778000 draw_data equ OS_BASE+0x0800000 -sysint_stack_data equ OS_BASE+0x0803000 -tss_data equ OS_BASE+0x0920000 +tss_data equ 0x0803000 ;OS_BASE+0x0920000 + +HEAP_BASE equ 0xA0B000 ;x00C00000 pages_tab equ 0x60000000 master_tab equ 0x60180000 @@ -238,11 +239,7 @@ sys_pgdir equ OS_BASE+0x00050000 sys_master_tab equ OS_BASE+0x00051000 sys_pgmap equ OS_BASE+0x00052000 -;lfb_start equ 0x00800000 -;new_app_pdir equ OS_BASE+0x01000000 -;new_app_master_table equ OS_BASE+0x01001000 -;new_app_ptable equ OS_BASE+0x01002000 new_app_base equ 0x60400000 diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index caf81eaf6f..4b77d87022 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -512,13 +512,13 @@ proc load_file stdcall, file_name:dword .exit: push eax lea edi, [eax+ebx] ;cleanup remain space - mov ecx, ebx ;from file end - add ecx, 4095 - and ecx, not 4095 + mov ecx, 4096 ;from file end + and ebx, 4095 sub ecx, ebx xor eax, eax cld rep stosb + mov ebx, [file_size] pop eax ret .cleanup: diff --git a/kernel/trunk/core/fpu.inc b/kernel/trunk/core/fpu.inc index 13b028cac1..c7748eeb86 100644 --- a/kernel/trunk/core/fpu.inc +++ b/kernel/trunk/core/fpu.inc @@ -6,9 +6,6 @@ init_fpu: bt [cpu_caps], CAPS_SSE jnc .no_SSE - stdcall kernel_alloc, 512*256 - mov [fpu_data], eax - mov ebx, cr4 mov ecx, cr0 or ebx, CR4_OSFXSR+CR4_OSXMMEXPT @@ -29,16 +26,14 @@ init_fpu: xorps xmm5, xmm5 xorps xmm6, xmm6 xorps xmm7, xmm7 - fxsave [eax] + fxsave [fpu_data] ;[eax] ret .no_SSE: - stdcall kernel_alloc, 112*256 - mov [fpu_data], eax mov ecx, cr0 and ecx, not CR0_EM or ecx, CR0_MP+CR0_NE mov cr0, ecx - fnsave [eax] + fnsave [fpu_data] ret align 4 @@ -118,8 +113,6 @@ iglobal fpu_owner dd 1 endg - - reg_eip equ ebp+4 reg_cs equ ebp+8 reg_eflags equ ebp+12 diff --git a/kernel/trunk/core/heap.inc b/kernel/trunk/core/heap.inc index dd9cfe807b..aa823056d4 100644 --- a/kernel/trunk/core/heap.inc +++ b/kernel/trunk/core/heap.inc @@ -1,18 +1,16 @@ -HEAP_BASE equ 0x00C00000 -;HEAP_SIZE equ 0x01000000 - struc MEM_BLOCK { .next_block dd ? .prev_block dd ? ;+4 - .list_next dd ? ;+8 - .list_prev dd ? ;+12 + .list_fd dd ? ;+8 + .list_bk dd ? ;+12 .base dd ? ;+16 .size dd ? ;+20 .flags dd ? ;+24 .handle dd ? ;+28 } +MEM_LIST_OFFSET equ 8 FREE_BLOCK equ 4 USED_BLOCK equ 8 @@ -24,8 +22,8 @@ MEM_BLOCK_SIZE equ 8*4 block_next equ MEM_BLOCK.next_block block_prev equ MEM_BLOCK.prev_block -list_next equ MEM_BLOCK.list_next -list_prev equ MEM_BLOCK.list_prev +list_fd equ MEM_BLOCK.list_fd +list_bk equ MEM_BLOCK.list_bk block_base equ MEM_BLOCK.base block_size equ MEM_BLOCK.size block_flags equ MEM_BLOCK.flags @@ -40,18 +38,18 @@ macro calc_index op } macro remove_from_list op -{ mov edx, [op+list_next] - mov ecx, [op+list_prev] +{ mov edx, [op+list_fd] + mov ecx, [op+list_bk] test edx, edx jz @f - mov [edx+list_prev], ecx + mov [edx+list_bk], ecx @@: test ecx, ecx jz @f - mov [ecx+list_next], edx + mov [ecx+list_fd], edx @@: - mov [op+list_next],0 - mov [op+list_prev],0 + mov [op+list_fd],0 + mov [op+list_bk],0 } macro remove_from_free op @@ -72,11 +70,12 @@ macro remove_from_free op macro remove_from_used op { - remove_from_list op - cmp [mem_used_list], op - jne @f - mov [mem_used_list], edx -@@: + mov edx, [op+list_fd] + mov ecx, [op+list_bk] + mov [edx+list_bk], ecx + mov [ecx+list_fd], edx + mov [op+list_fd], 0 + mov [op+list_bk], 0 } align 4 @@ -97,6 +96,10 @@ proc init_kernel_heap mov [mem_block_end], mem_block_map+512 mov [mem_block_arr], HEAP_BASE + mov eax, mem_used.fd-MEM_LIST_OFFSET + mov [mem_used.fd], eax + mov [mem_used.bk], eax + stdcall alloc_pages, dword 32 mov ecx, 32 mov edx, eax @@ -109,20 +112,20 @@ proc init_kernel_heap jnz .l1 mov edi, HEAP_BASE - mov ebx, edi - add ebx, MEM_BLOCK_SIZE + mov ebx, HEAP_BASE+MEM_BLOCK_SIZE xor eax, eax mov [edi+block_next], ebx mov [edi+block_prev], eax - mov [edi+list_next], eax - mov [edi+list_prev], eax + mov [edi+list_fd], eax + mov [edi+list_bk], eax mov [edi+block_base], HEAP_BASE mov [edi+block_size], 4096*MEM_BLOCK_SIZE mov [edi+block_flags], USED_BLOCK mov [ebx+block_next], eax mov [ebx+block_prev], eax - mov [ebx+list_next], eax + mov [ebx+list_fd], eax + mov [ebx+list_bk], eax mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK_SIZE mov ecx, [MEM_AMOUNT] @@ -135,7 +138,6 @@ proc init_kernel_heap mov [mem_block_mask], eax mov [mem_block_mask+4],0x80000000 - mov [mem_used_list], eax mov [mem_block_list+63*4], ebx mov byte [mem_block_map], 0xFC and [heap_mutex], 0 @@ -220,6 +222,15 @@ found: endp proc free_mem_block + mov dword [eax], 0 + mov dword [eax+4], 0 + mov dword [eax+8], 0 + mov dword [eax+12], 0 + mov dword [eax+16], 0 +; mov dword [eax+20], 0 + mov dword [eax+24], 0 + mov dword [eax+28], 0 + sub eax, [mem_block_arr] shr eax, 5 @@ -285,8 +296,8 @@ proc alloc_kernel_space stdcall, size:dword mov eax, [edi+block_prev] mov [esi+block_prev], eax mov [edi+block_prev], esi - mov [esi+list_next], 0 - mov [esi+list_prev], 0 + mov [esi+list_fd], 0 + mov [esi+list_bk], 0 and eax, eax jz @f mov [eax+block_next], esi @@ -318,22 +329,22 @@ proc alloc_kernel_space stdcall, size:dword btr [mem_block_mask], ecx @@: mov edx, [mem_block_list+eax*4] - mov [edi+list_next], edx + mov [edi+list_fd], edx test edx, edx jz @f - mov [edx+list_prev], edi + mov [edx+list_bk], edi @@: mov [mem_block_list+eax*4], edi bts [mem_block_mask], eax .m_eq_ind: - mov ebx, [mem_used_list] - mov [esi+list_next], ebx - test ebx, ebx - jz @f - mov [ebx+list_prev], esi -@@: + mov ecx, mem_used.fd-MEM_LIST_OFFSET + mov edx, [ecx+list_fd] + mov [esi+list_fd], edx + mov [esi+list_bk], ecx + mov [ecx+list_fd], esi + mov [edx+list_bk], esi + mov [esi+block_flags], USED_BLOCK - mov [mem_used_list], esi mov eax, [esi+block_base] mov ebx, [size] sub [heap_free], ebx @@ -346,13 +357,13 @@ proc alloc_kernel_space stdcall, size:dword jnz @f btr [mem_block_mask], ebx @@: - mov ecx, [mem_used_list] - mov [edi+list_next], ecx - test ecx, ecx - jnz @f - mov [ecx+list_prev], edi -@@: - mov [mem_used_list], edi + mov ecx, mem_used.fd-MEM_LIST_OFFSET + mov edx, [ecx+list_fd] + mov [edi+list_fd], edx + mov [edi+list_bk], ecx + mov [ecx+list_fd], edi + mov [edx+list_bk], edi + mov [edi+block_flags], USED_BLOCK mov eax, [edi+block_base] mov ebx, [size] @@ -372,14 +383,14 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword call wait_mutex ;ebx mov eax, [base] - mov esi, [mem_used_list] + mov esi, [mem_used.fd] @@: - test esi, esi - jz .fail + cmp esi, mem_used.fd-MEM_LIST_OFFSET + je .fail cmp [esi+block_base], eax je .found - mov esi, [esi+list_next] + mov esi, [esi+list_fd] jmp @b .found: cmp [esi+block_flags], USED_BLOCK @@ -452,10 +463,10 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword @@: mov esi, [mem_block_list+eax*4] mov [mem_block_list+eax*4], edi - mov [edi+list_next], esi + mov [edi+list_fd], esi test esi, esi jz @f - mov [esi+list_prev], edi + mov [esi+list_bk], edi @@: bts [mem_block_mask], eax .m_eq: @@ -471,10 +482,10 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword mov edi, [mem_block_list+eax*4] mov [mem_block_list+eax*4], esi - mov [esi+list_next], edi + mov [esi+list_fd], edi test edi, edi jz @f - mov [edi+list_prev], esi + mov [edi+list_bk], esi @@: bts [mem_block_mask], eax mov [esi+block_flags],FREE_BLOCK @@ -500,14 +511,14 @@ proc kernel_alloc stdcall, size:dword and eax, not 4095; mov [size], eax and eax, eax - jz .error + jz .err mov ebx, eax shr ebx, 12 mov [pages_count], ebx stdcall alloc_kernel_space, eax - and eax, eax - jz .error + test eax, eax + jz .err mov [lin_addr], eax mov ecx, [pages_count] @@ -522,7 +533,7 @@ proc kernel_alloc stdcall, size:dword stdcall alloc_pages, ebx pop ecx ; yes ecx!!! and eax, eax - jz .error + jz .err mov edi, eax mov edx, [lin_addr] @@ -536,12 +547,12 @@ proc kernel_alloc stdcall, size:dword mov ecx, [pages_count] and ecx, 7 jz .end - -@@: push ecx +@@: + push ecx call alloc_page pop ecx test eax, eax - jz .error + jz .err stdcall map_page,edx,eax,dword PG_SW add edx, 0x1000 @@ -550,7 +561,7 @@ proc kernel_alloc stdcall, size:dword .end: mov eax, [lin_addr] ret -.error: +.err: xor eax, eax ret endp @@ -563,14 +574,14 @@ proc kernel_free stdcall, base:dword call wait_mutex ;ebx mov eax, [base] - mov esi, [mem_used_list] + mov esi, [mem_used.fd] @@: - test esi, esi - jz .fail + cmp esi, mem_used.fd-MEM_LIST_OFFSET + je .fail cmp [esi+block_base], eax je .found - mov esi, [esi+list_next] + mov esi, [esi+list_fd] jmp @b .found: cmp [esi+block_flags], USED_BLOCK diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index e070f4977d..2470fa293c 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -1,5 +1,5 @@ -tmp_page_tab equ 0x00C00000 +tmp_page_tab equ HEAP_BASE align 4 proc mem_test @@ -18,6 +18,7 @@ proc mem_test cmp dword [edi], 'TEST' xchg ebx, dword [edi] je @b + mov [MEM_AMOUNT], edi and eax, not (CR0_CD+CR0_NW) ;enable caching mov cr0, eax @@ -27,12 +28,35 @@ proc mem_test endp align 4 -proc init_memEx +proc init_mem + + mov eax, [MEM_AMOUNT] + + mov [pg_data.mem_amount], eax + mov [pg_data.kernel_max], eax + + shr eax, 12 + mov edx, eax + mov [pg_data.pages_count], eax + mov [pg_data.kernel_pages], eax + + shr eax, 3 + mov [pg_data.pagemap_size], eax + + shr edx, 10 + cmp edx, 3 + ja @f + inc edx ;at least 4Mb for kernel heap +@@: + mov [pg_data.kernel_tables], edx + xor eax, eax mov edi, sys_pgdir mov ecx, 2048 + cld rep stosd + mov edx, sys_pgdir bt [cpu_caps], CAPS_PSE jnc .no_PSE @@ -45,89 +69,68 @@ proc init_memEx or ebx, CR4_PGE @@: mov cr4, ebx + sub [pg_data.kernel_tables], 2 - mov dword [sys_pgdir], eax + mov [edx], eax add eax, 0x00400000 - mov dword [sys_pgdir+4], eax - add eax, 0x00400000 - mov dword [sys_pgdir+8], eax + mov [edx+4], eax + add edx, 8 - mov dword [sys_pgdir+0x600], sys_pgdir+PG_SW - - mov ecx, [pg_data.kernel_tables] - sub ecx, 3 ;4 - mov eax, tmp_page_tab+PG_SW - mov edi, sys_pgdir+12 ;16 - - jmp .map_kernel_tabs + mov eax, 0x800000+PG_SW + mov ecx, (HEAP_BASE-0x800000)/4096 + jmp .map_low .no_PSE: mov eax, PG_SW - mov esi, tmp_page_tab - mov ecx, 3072/4; 4096/4 ;0x0 - 0x00FFFFFF + mov ecx, HEAP_BASE/4096 .map_low: - mov [esi], eax + mov edi, tmp_page_tab +@@: ; + stosd add eax, 0x1000 - mov [esi+4], eax - add eax, 0x1000 - mov [esi+8], eax - add eax, 0x1000 - mov [esi+12], eax - add eax, 0x1000 - add esi, 16 dec ecx - jnz .map_low ;ядро + jnz @B + + mov ecx, [pg_data.kernel_tables] + shl ecx, 10 + xor eax, eax + rep stosd mov ecx, [pg_data.kernel_tables] mov eax, tmp_page_tab+PG_SW - mov edi, sys_pgdir + mov edi, edx .map_kernel_tabs: - mov [edi], eax + stosd add eax, 0x1000 - add edi, 4 dec ecx jnz .map_kernel_tabs - mov edi, tmp_page_tab - bt [cpu_caps], CAPS_PSE - jc @F - add edi, 3072*4 ;4096*4 ;skip low kernel memory -@@: - mov ecx, [pg_data.kernel_tables] - sub ecx, 3 - shl ecx, 10 - xor eax, eax - cld - rep stosd - mov dword [sys_pgdir+0x600], sys_pgdir+PG_SW - ret endp align 4 proc init_page_map + mov edi, sys_pgmap - mov ecx, 384/4 + mov ecx, (HEAP_BASE/4096)/32 ;384/4 + mov ebx, ecx xor eax,eax cld rep stosd not eax mov ecx, [pg_data.pagemap_size] - sub ecx, 384 + sub ecx, ebx shr ecx, 2 rep stosd - mov edi, sys_pgmap+384 + lea edi, [sys_pgmap+ebx*4] ;+384 mov edx, [pg_data.pages_count] mov ecx, [pg_data.kernel_tables] - bt [cpu_caps], CAPS_PSE - jnc @f - sub ecx, 3 -@@: - sub edx, 3072 + add ecx, (HEAP_BASE/4096) and 31 + sub edx, HEAP_BASE/4096 sub edx, ecx mov [pg_data.pages_free], edx @@ -140,9 +143,9 @@ proc init_page_map mov ecx, ebx and ecx, 31 shl eax, cl + mov [page_start], edi; sys_pgmap+384 stosd - mov [page_start], sys_pgmap+384 mov ebx, sys_pgmap add ebx, [pg_data.pagemap_size] mov [page_end], ebx @@ -1348,7 +1351,6 @@ uglobal align 16 irq_tab rd 16 - MEM_FreeSpace rd 1 ipc_tmp rd 1 @@ -1363,7 +1365,6 @@ align 16 tmp_task_ptab rd 1 tmp_task_data rd 1 - fpu_data rd 1 fdd_buff rd 1 LFBSize rd 1 @@ -1395,6 +1396,8 @@ endg uglobal align 16 + fpu_data: + rb 512 mst MEM_STATE @@ -1406,7 +1409,9 @@ align 16 srv.fd rd 1 srv.bk rd 1 - mem_used_list rd 1 + mem_used.fd rd 1 + mem_used.bk rd 1 + mem_block_arr rd 1 mem_block_start rd 1 mem_block_end rd 1 @@ -1424,6 +1429,7 @@ align 16 event_end rd 1 event_uid rd 1 sys_page_map rd 1 + os_stack rd 1 endg if 0 diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index f55d4a1e29..bd16f38a19 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -31,7 +31,6 @@ build_process_gdt_tss_pointer: ret - build_interrupt_table: mov edi, idts+8 @@ -623,10 +622,9 @@ term9: mov eax,[PROC_BASE+eax+APPDATA.dir_table] stdcall destroy_app_space, eax -;; mov esi, [.slot] - pop esi ;restore stack + mov esi, [.slot] cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 - jne fpu_ok_1 + jne @F mov [fpu_owner],1 mov eax, [256+PROC_BASE+APPDATA.fpu_state] @@ -634,11 +632,11 @@ term9: clts jnc .no_SSE fxrstor [eax] - jmp fpu_ok_1 + jmp @F .no_SSE: fnclex frstor [eax] -fpu_ok_1: +@@: mov [0xf400],byte 0 ; empty keyboard buffer mov [0xf500],byte 0 ; empty button buffer @@ -747,24 +745,22 @@ fpu_ok_1: .nodebug: popad - pusha ; at 0x80000+ - mov edi,esi - shl edi,8 - add edi,0x80000 - mov ecx,256/4 - xor eax, eax - rep stosd - popa + mov ebx, [.slot] + shl ebx, 8 + mov ebx,[PROC_BASE+ebx+APPDATA.pl0_stack] - pusha ; name to spaces - mov edi,esi - shl edi,8 - add edi,0x80000+APPDATA.app_name - mov ecx,11 - mov eax,' ' - rep stosb - popa + stdcall kernel_free, ebx + mov edi, [.slot] + shl edi,8 + add edi,0x80000 + mov eax, 0x20202020 + stosd + stosd + stosd + mov ecx,244/4 + xor eax, eax + rep stosd ; activate window movzx eax, word [0xC000 + esi*2] @@ -824,7 +820,6 @@ fpu_ok_1: loop newirqfree popa - pusha ; remove all port reservations mov edx,esi shl edx, 5 @@ -910,6 +905,7 @@ fpu_ok_1: mov [application_table_status],0 mov esi,process_terminated call sys_msg_board_str + add esp, 4 ret restore .slot diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index fbf10f8e2c..74b556a4b7 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -1,4 +1,4 @@ - GREEDY_KERNEL equ 0 +GREEDY_KERNEL equ 0 struc APP_HEADER_00 @@ -168,7 +168,8 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword mov eax,[app_mem] mov [ebx+APPDATA.mem_size],eax -if not GREEDY_KERNEL +if GREEDY_KERNEL +else mov ecx, [app_mem] mov edi, [file_size] add edi, 4095 @@ -301,7 +302,6 @@ proc get_new_process_place ret endp - align 4 proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword locals @@ -449,7 +449,7 @@ end if .fail: dec [pg_data.pg_mutex] cmp [dir_addr], 0 - jz @f + je @f stdcall destroy_app_space, [dir_addr] @@: xor eax, eax @@ -968,38 +968,30 @@ align 4 proc set_app_params stdcall,slot:dword, params:dword,\ cmd_line:dword, app_path:dword, flags:dword - mov edi, [slot] - mov esi, [fpu_data] - bt [cpu_caps], CAPS_SSE - jnc .no_SSE + locals + pl0_stack dd ? + endl + + stdcall kernel_alloc, 0x2000 + mov [pl0_stack], eax + + lea edi, [eax+0x2000-512] + + mov eax, [slot] + mov ebx, eax - shl edi, 8 - mov eax, edi - lea edi, [esi+edi*2] - mov [eax+PROC_BASE+APPDATA.fpu_state], edi - mov [eax+PROC_BASE+APPDATA.fpu_handler], 0 - mov [eax+PROC_BASE+APPDATA.sse_handler], 0 - mov ecx, 512/4 - jmp @F -.no_SSE: - mov eax, edi shl eax, 8 - mov ebx, edi - shl edi, 7 - shl ebx, 4 - sub edi, ebx ;edi*=112 - add edi, esi mov [eax+PROC_BASE+APPDATA.fpu_state], edi mov [eax+PROC_BASE+APPDATA.fpu_handler], 0 mov [eax+PROC_BASE+APPDATA.sse_handler], 0 - mov ecx, 112/4 -@@: + + mov esi, fpu_data + mov ecx, 512/4 rep movsd - mov ebx,[slot] - cmp ebx,[TASK_COUNT] - jle .noinc - inc dword [TASK_COUNT] ;update number of processes + cmp ebx,[TASK_COUNT] + jle .noinc + inc dword [TASK_COUNT] ;update number of processes .noinc: shl ebx,8 lea edx, [ebx+PROC_BASE+APP_EV_OFFSET] @@ -1012,6 +1004,8 @@ proc set_app_params stdcall,slot:dword, params:dword,\ mov ecx, [def_cursor] mov [PROC_BASE+APPDATA.cursor+ebx],ecx + mov eax, [pl0_stack] + mov [PROC_BASE+APPDATA.pl0_stack+ebx],eax shr ebx,3 mov eax, new_app_base @@ -1105,9 +1099,8 @@ proc set_app_params stdcall,slot:dword, params:dword,\ mov [edi+TSS._gs],graph_data ;selector of graphic segment mov [edi+TSS._io],word 128 mov [edi+TSS._ss0], os_data - mov ebx,[slot] - shl ebx,12 - add ebx,sysint_stack_data+4096 + mov ebx, [pl0_stack] + add ebx, 0x2000-512 mov [edi+TSS._esp0],ebx mov ecx, edi ;ecx - address of application TSS diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 698bd733a6..345bde119d 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -356,32 +356,6 @@ B32: mov [0xe024],dword Vesa20_getpixel32 no_mode_0x12: -; MEMORY MODEL - - call mem_test - - mov [MEM_AMOUNT], eax - - mov [pg_data.mem_amount], eax - mov [pg_data.kernel_max], eax - - shr eax, 12 - mov edx, eax - mov [pg_data.pages_count], eax - mov [pg_data.kernel_pages], eax - - shr eax, 3 - mov [pg_data.pagemap_size], eax - - shr edx, 10 - cmp edx, 3 - ja @f - inc edx ;at least 4Mb for kernel heap -@@: - mov [pg_data.kernel_tables], edx - -; ENABLE PAGING - call test_cpu ; btr [cpu_caps], CAPS_SSE ;test: dont't use sse code ; btr [cpu_caps], CAPS_SSE2 ;test: don't use sse2 @@ -393,9 +367,12 @@ B32: ; btr [cpu_caps], CAPS_MTRR ;test: don't use MTRR bts [cpu_caps], CAPS_TSC ;force use rdtsc - call init_memEx +; MEMORY MODEL + call mem_test + call init_mem call init_page_map +; ENABLE PAGING mov eax, sys_pgdir mov cr3, eax @@ -404,6 +381,8 @@ B32: mov cr0,eax call init_kernel_heap + stdcall kernel_alloc, 0x2000 + mov [os_stack], eax call init_LFB call init_mtrr call init_fpu @@ -580,41 +559,35 @@ include 'vmodeld.inc' mov esi,boot_setostask call boot_log - mov eax, [fpu_data] + mov eax, fpu_data mov dword [0x80000+APPDATA.fpu_state], eax mov dword [0x80000+APPDATA.fpu_handler], 0 mov dword [0x80000+APPDATA.sse_handler], 0 ; name for OS/IDLE process - mov dword [0x80000+256+APPDATA.app_name], dword 'OS/I' - mov dword [0x80000+256+APPDATA.app_name+4], dword 'DLE ' + mov dword [0x80000+256+APPDATA.app_name], dword 'OS/I' + mov dword [0x80000+256+APPDATA.app_name+4], dword 'DLE ' + mov edi, [os_stack] + mov dword [0x80000+256+APPDATA.pl0_stack], edi + add edi, 0x2000-512 + mov dword [0x80000+256+APPDATA.fpu_state], edi + + mov esi, fpu_data + mov ecx, 512/4 + cld + rep movsd + + mov dword [0x80000+256+APPDATA.fpu_handler], 0 + mov dword [0x80000+256+APPDATA.sse_handler], 0 + mov ebx, [def_cursor] mov dword [0x80000+256+APPDATA.cursor], ebx - mov dword [0x80000+256+APPDATA.fpu_handler], 0 - mov dword [0x80000+256+APPDATA.sse_handler], 0 mov ebx, PROC_BASE+256+APP_OBJ_OFFSET mov dword [0x80000+256+APPDATA.fd_obj], ebx mov dword [0x80000+256+APPDATA.bk_obj], ebx - -;set fpu save area - mov esi, eax - bt [cpu_caps], CAPS_SSE - jnc .no_sse - - lea edi, [eax+512] - mov dword [PROC_BASE+256+APPDATA.fpu_state], edi - mov ecx, 512/4 - jmp @F -.no_sse: - lea edi, [eax+112] - mov dword [PROC_BASE+256+APPDATA.fpu_state], edi - mov ecx, 112/4 -@@: - rep movsd - ; task list mov [0x3020+TASKDATA.wnd_number], 1 ; on screen number mov [0x3020+TASKDATA.pid], 1 ; process id number @@ -632,7 +605,9 @@ include 'vmodeld.inc' mov [edi+TSS._cr3],eax mov [edi+TSS._eip],osloop mov [edi+TSS._eflags],dword 0x11202 ; sti and resume - mov [edi+TSS._esp],sysint_stack_data + 4096*2 ; uses slot 1 stack + mov eax, [os_stack] + add eax, 0x2000-512 + mov [edi+TSS._esp], eax mov [edi+TSS._cs],os_code mov [edi+TSS._ss],os_data mov [edi+TSS._ds],os_data diff --git a/kernel/trunk/kernel32.inc b/kernel/trunk/kernel32.inc index 2361c40327..3303245224 100644 --- a/kernel/trunk/kernel32.inc +++ b/kernel/trunk/kernel32.inc @@ -176,7 +176,7 @@ struc APPDATA .ev_count dd ? ;+20 .fpu_handler dd ? ;+24 .sse_handler dd ? ;+28 - dd ? ;unused ;+32 + .pl0_stack dd ? ;unused ;+32 .heap_base dd ? ;+36 .heap_top dd ? ;+40 .cursor dd ? ;+44 diff --git a/kernel/trunk/memmap.inc b/kernel/trunk/memmap.inc index f96db77a7b..d403e18fed 100644 --- a/kernel/trunk/memmap.inc +++ b/kernel/trunk/memmap.inc @@ -209,19 +209,11 @@ ; 08 dword draw limit - x end ; 0C dword draw limit - y end ; -; 802000 -> 802fff free (4 Kb) ; -; 803000 -> 902fff sysint_stack_data -; - ring0 stacks for ring3 processes -; - used for interrupt handling -; - 256 entries * 4096 step -; -; 903000 -> 91ffff free (116 Kb) -; -; 920000 -> B28000 TSS and IO map for (8192*8)=65536 ports +; 803000 -> 0xA0AFFF TSS and IO map for (8192*8)=65536 ports ; (128+8192)*256 = 2129920 = 0x208000 ; -; C00000 -> kernel heap +; 0xA0B000 -> kernel heap