1)fixed memory size in fn 18.16 & 18.17

2)added fn 18.20 - get extended memory info

git-svn-id: svn://kolibrios.org@170 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2006-10-08 07:48:38 +00:00
parent 6c854695d0
commit 9395f92693
8 changed files with 88 additions and 174 deletions

View File

@ -315,7 +315,6 @@ struc SYS_VARS
dd ? dd ?
} }
struc BOOT_DATA struc BOOT_DATA
{ .bpp dd ? { .bpp dd ?
.scanline dd ? .scanline dd ?

View File

@ -127,7 +127,9 @@ proc init_kernel_heap
mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK_SIZE mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK_SIZE
mov ecx, [MEM_AMOUNT] mov ecx, [MEM_AMOUNT]
sub ecx, 0x00C00000 + 4096*MEM_BLOCK_SIZE sub ecx, 0x01000000 + 4096*MEM_BLOCK_SIZE
mov [heap_size], ecx
mov [heap_free], ecx
mov [ebx+block_size], ecx mov [ebx+block_size], ecx
mov [ebx+block_flags], FREE_BLOCK mov [ebx+block_flags], FREE_BLOCK
@ -137,6 +139,8 @@ proc init_kernel_heap
mov [mem_used_list], eax mov [mem_used_list], eax
mov [mem_block_list+63*4], ebx mov [mem_block_list+63*4], ebx
mov byte [mem_block_map], 0xFC mov byte [mem_block_map], 0xFC
mov [heap_blocks], 4095
mov [free_blocks], 4095
ret ret
endp endp
@ -190,7 +194,6 @@ proc get_block stdcall, index:dword
ret ret
endp endp
align 4 align 4
proc alloc_mem_block proc alloc_mem_block
@ -216,6 +219,7 @@ found:
add eax,ebx add eax,ebx
shl eax, 5 shl eax, 5
add eax, [mem_block_arr] add eax, [mem_block_arr]
dec [free_blocks]
popfd popfd
ret ret
endp endp
@ -228,6 +232,7 @@ proc free_mem_block
mov ebx, mem_block_map mov ebx, mem_block_map
bts [ebx], eax bts [ebx], eax
inc [free_blocks]
shr eax, 3 shr eax, 3
and eax, not 3 and eax, not 3
add eax, ebx add eax, ebx
@ -256,6 +261,8 @@ proc alloc_kernel_space stdcall, size:dword
add eax, 0xFFF add eax, 0xFFF
and eax, 0xFFFFF000; and eax, 0xFFFFF000;
mov [size], eax mov [size], eax
cmp eax, [heap_free]
ja .error
shr eax, 12 shr eax, 12
sub eax, 1 sub eax, 1
@ -341,6 +348,8 @@ proc alloc_kernel_space stdcall, size:dword
mov [esi+block_flags], USED_BLOCK mov [esi+block_flags], USED_BLOCK
mov [mem_used_list], esi mov [mem_used_list], esi
mov eax, [esi+block_base] mov eax, [esi+block_base]
mov ebx, [size]
sub [heap_free], ebx
popfd popfd
ret ret
@ -361,6 +370,8 @@ proc alloc_kernel_space stdcall, size:dword
mov [mem_used_list], edi mov [mem_used_list], edi
mov [edi+block_flags], USED_BLOCK mov [edi+block_flags], USED_BLOCK
mov eax, [edi+block_base] mov eax, [edi+block_base]
mov ebx, [size]
sub [heap_free], ebx
popfd popfd
ret ret
.error: .error:
@ -386,6 +397,9 @@ proc free_kernel_space stdcall, base:dword
cmp [esi+block_flags], USED_BLOCK cmp [esi+block_flags], USED_BLOCK
jne .fail jne .fail
mov eax, [esi+block_size]
add [heap_free], eax
mov edi, [esi+block_next] mov edi, [esi+block_next]
test edi, edi test edi, edi
jz .prev jz .prev

View File

@ -111,75 +111,6 @@ proc init_memEx
ret ret
endp endp
;align 4
;proc init_mem
;
; xor eax, eax
; mov edi, sys_pgdir
; mov ecx, 2048
; rep stosd
;
; bt [cpu_caps], CAPS_PSE
; jc .use_PSE
;
; mov eax, PG_SW
; mov esi, tmp_page_tab
; mov ecx, 4096/4 ;0x0 - 0x00FFFFFF
;
;.map_low:
; mov [esi], eax
; 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 ;ÿäðî
; mov eax, tmp_page_tab+PG_SW
; mov ecx, 4
; xor ebx, ebx
;.map_page_tables:
; mov [sys_pgdir+ebx], eax
; mov [sys_master_tab+ebx], eax
; add eax, 0x1000
; add ebx, 4
; dec ecx
; jnz .map_page_tables
; mov dword [sys_pgdir+0x600], sys_master_tab+PG_SW
; mov dword [sys_master_tab+0x600], sys_master_tab+PG_SW
; ret
;.use_PSE:
; mov ebx, cr4
; or ebx, CR4_PSE
; mov eax, PG_LARGE+PG_SW
; bt [cpu_caps], CAPS_PGE
; jnc @F
; or eax, PG_GLOBAL
; or ebx, CR4_PGE
;@@:
; mov dword [sys_pgdir], eax
; add eax, 0x00400000
; mov dword [sys_pgdir+4], eax
; add eax, 0x00400000
; mov dword [sys_pgdir+8], eax
; add eax, 0x00400000
; mov dword [sys_pgdir+12], eax
;
; mov dword [sys_pgdir+0x600], sys_master_tab+PG_SW
; mov dword [sys_master_tab+0x600], sys_master_tab+PG_SW
; mov cr4, ebx
; ret
;endp
align 4 align 4
proc init_page_map proc init_page_map
mov edi, sys_pgmap mov edi, sys_pgmap
@ -226,63 +157,6 @@ proc init_page_map
ret ret
endp endp
;align 4
;proc init_pg_mem
;
; mov edi, sys_pgmap
; mov ecx, 512/4
; xor eax,eax
; cld
; rep stosd
;
; not eax
; mov ecx, [pg_data.pagemap_size]
; sub ecx, 512
; shr ecx, 2
; rep stosd
;
; shl eax, PAGES_USED
; mov [sys_pgmap+512], eax
;
; mov [page_start], sys_pgmap+512
; mov ebx, sys_pgmap
; add ebx, [pg_data.pagemap_size]
; mov [page_end], ebx
; mov eax, [pg_data.pages_count]
; sub eax, 4096+PAGES_USED
; mov [pg_data.pages_free], eax
;
; mov [pg_data.pages_faults], 0
;
; mov edi, OS_BASE+0x01000000
; mov esi, [pg_data.kernel_tables]
; sub esi, 4
; ja @f
; mov esi, 1
;@@:
; call alloc_page
; stdcall map_page_table, sys_pgdir, edi, eax
; add edi, 0x00400000
; dec esi
; jnz @B
;
; mov ecx, [pg_data.kernel_tables]
; sub ecx, 4
; shl ecx, 10
; mov edi, OS_BASE+0x01000000
; shr edi, 10
; add edi, pages_tab
; xor eax, eax
; cld
; rep stosd
;
; mov eax, cr3
; mov cr3, eax
;
; mov [pg_data.pg_mutex], 0
; ret
;endp
align 4 align 4
proc alloc_page proc alloc_page
@ -1025,19 +899,25 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
endp endp
align 4 align 4
proc get_mem_info stdcall, val:dword sysfn_meminfo:
mov esi, [val]
add ebx, new_app_base
mov eax, [pg_data.pages_count] mov eax, [pg_data.pages_count]
mov [esi], eax mov [ebx], eax
mov ebx, [pg_data.pages_free] mov ecx, [pg_data.pages_free]
mov [esi+4], ebx mov [ebx+4], ecx
mov ecx, [pg_data.pages_faults] mov edx, [pg_data.pages_faults]
mov [esi+8], ecx mov [ebx+8], edx
mov esi, [heap_size]
mov [ebx+12], esi
mov edi, [heap_free]
mov [ebx+16], edi
mov eax, [heap_blocks]
mov [ebx+20], eax
mov ecx, [free_blocks]
mov [ebx+24], ecx
ret ret
endp
align 4 align 4
new_services: new_services:
@ -1045,17 +925,17 @@ new_services:
cmp eax,4 cmp eax,4
jle sys_sheduler jle sys_sheduler
cmp eax, 10 cmp eax, 11
jb .fail jb .fail
ja @f ja @f
add ebx, new_app_base ; add ebx, new_app_base
stdcall get_mem_info, ebx ; stdcall get_mem_info, ebx
mov [esp+36], eax ; mov [esp+36], eax
ret ; ret
@@: ;@@:
cmp eax, 11 ; cmp eax, 11
ja @f ; ja @f
stdcall init_heap, ebx stdcall init_heap, ebx
mov [esp+36], eax mov [esp+36], eax
@ -1355,7 +1235,6 @@ proc set_mtrr stdcall, reg:dword,base:dword,size:dword,mem_type:dword
ret ret
endp endp
iglobal iglobal
align 4 align 4
intel_str db "GenuineIntel",0 intel_str db "GenuineIntel",0
@ -1408,11 +1287,15 @@ align 16
mem_block_start rd 1 mem_block_start rd 1
mem_block_end rd 1 mem_block_end rd 1
mem_block_mask rd 2 mem_block_mask rd 2
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
free_blocks rd 1
page_start rd 1 page_start rd 1
page_end rd 1 page_end rd 1
sys_page_map rd 1 sys_page_map rd 1
app_load rd 1 ; app_load rd 1
endg endg
@ -1421,7 +1304,6 @@ endg
; mov edx, 0x400 ;bocsh ; mov edx, 0x400 ;bocsh
; mov al,0xff ;bocsh ; mov al,0xff ;bocsh
; out dx, al ;bocsh ; out dx, al ;bocsh
; nop ;bocsh fix
; pop edx ; pop edx
; pop eax ; pop eax

View File

@ -298,25 +298,28 @@ e7:
fxrstor [eax] fxrstor [eax]
restore_ring3_context restore_ring3_context
iret iret
.init:
fninit ;­ ¬ ­¥ ­ã¦­ë ­¥¬ áª¨à®¢ ­­ë¥ ¨áª«î祭¨ï
mov dword [ebx+PROC_BASE+APPDATA.fpu_init], 1
.exit:
restore_ring3_context
iret
.no_SSE: .no_SSE:
fnsave [eax] fnsave [eax]
mov ebx, [CURRENT_TASK] mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx mov [fpu_owner], ebx
shl ebx, 8 shl ebx, 8
cmp dword [ebx+PROC_BASE+APPDATA.fpu_init], 0 cmp dword [ebx+PROC_BASE+APPDATA.fpu_init], 0
je .init je .ready
mov eax, [ebx+PROC_BASE+APPDATA.fpu_state] mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
frstor [eax] frstor [eax]
restore_ring3_context restore_ring3_context
iret iret
.init:
fninit ;­ ¬ ­¥ ­ã¦­ë ­¥¬ áª¨à®¢ ­­ë¥ ¨áª«î祭¨ï
.ready:
mov dword [ebx+PROC_BASE+APPDATA.fpu_init], 1
.exit:
restore_ring3_context
iret
iglobal iglobal
fpu_owner dd 1 fpu_owner dd 1
endg endg

View File

@ -1,3 +1,5 @@
GREEDY_KERNEL equ 0; 1
struc APP_HEADER_00 struc APP_HEADER_00
{ .banner dq ? { .banner dq ?
@ -134,18 +136,27 @@ proc create_app_space stdcall, app_size:dword,img_size:dword
mov ebx, eax mov ebx, eax
shr eax, 12 shr eax, 12
mov [app_pages], eax mov [app_pages], eax
add ebx, 0x3FFFFF add ebx, 0x3FFFFF
and ebx, NOT(0x3FFFFF) and ebx, NOT(0x3FFFFF)
shr ebx, 22 shr ebx, 22
mov [app_tabs], ebx mov [app_tabs], ebx
mov eax, [img_size] mov ecx, [img_size]
add eax, 4095 add ecx, 4095
and eax, NOT(4095) and ecx, NOT(4095)
mov [img_size], eax mov [img_size], ecx
shr eax, 12 shr ecx, 12
mov [img_pages], eax mov [img_pages], ecx
if GREEDY_KERNEL
lea eax, [ecx+ebx+2] ;only image size
else
lea eax, [eax+ebx+2] ;all requested memory
end if
cmp eax, [pg_data.pages_free]
ja .fail
call alloc_page call alloc_page
test eax, eax test eax, eax
@ -539,10 +550,12 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword,\
rep stosb rep stosb
; read header ; read header
lea eax, [file_size] lea eax, [file_size]
mov ebx, [eax]
mov [img_size], ebx
mov edi, TMP_BUFF mov edi, TMP_BUFF
call [fn_read] call [fn_read]
test eax, eax test eax, eax
jnz .err jnz .err
@ -561,7 +574,11 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword,\
mov eax, cr3 mov eax, cr3
mov [save_cr3], eax mov [save_cr3], eax
stdcall create_app_space,[app_mem], [app_mem];[file_size] if GREEDY_KERNEL
stdcall create_app_space,[app_mem],[img_size]
else
stdcall create_app_space,[app_mem],[app_mem]
end if
test eax, eax test eax, eax
jz .failed jz .failed

View File

@ -113,7 +113,7 @@ endp
align 4 align 4
proc update_stream proc update_stream
locals locals
stream_index dd 0 stream_index dd ?
endl endl
mov [stream_index], 0 mov [stream_index], 0

View File

@ -672,7 +672,6 @@ include 'vmodeld.inc'
mov ax,tss0 mov ax,tss0
ltr ax ltr ax
; READ TSC / SECOND ; READ TSC / SECOND
mov esi,boot_tsc mov esi,boot_tsc
@ -1912,6 +1911,7 @@ sys_end:
jmp waitterm jmp waitterm
iglobal iglobal
align 4
sys_system_table: sys_system_table:
dd sysfn_shutdown ; 1 = system shutdown dd sysfn_shutdown ; 1 = system shutdown
dd sysfn_terminate ; 2 = terminate thread dd sysfn_terminate ; 2 = terminate thread
@ -1933,6 +1933,7 @@ sys_system_table:
dd sysfn_terminate2 ; 18 = terminate thread using PID dd sysfn_terminate2 ; 18 = terminate thread using PID
; instead of slot ; instead of slot
dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration
dd sysfn_meminfo ; 20 = get extended memory info
sysfn_num = ($ - sys_system_table)/4 sysfn_num = ($ - sys_system_table)/4
endg endg
@ -2164,16 +2165,14 @@ sysfn_mouse_acceleration: ; 18.19 = set/get mouse features
ret ret
sysfn_getfreemem: sysfn_getfreemem:
mov eax,[MEM_FreeSpace] mov eax, [pg_data.pages_free]
shl eax,2 shl eax, 2
mov [esp+36],eax mov [esp+36],eax
ret ret
sysfn_getallmem: sysfn_getallmem:
mov eax,[0xFE8C] mov eax,[MEM_AMOUNT]
shr eax,10 shr eax, 10
; mov eax,[MEM_AllSpace]
; shl eax,2
mov [esp+36],eax mov [esp+36],eax
ret ret