multiboot kernel

git-svn-id: svn://kolibrios.org@847 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-08-07 15:34:13 +00:00
parent 94030d053e
commit ebacfa0899
6 changed files with 515 additions and 365 deletions

View File

@ -0,0 +1,151 @@
DWORD equ dword
WORD equ word
BYTE equ byte
PTR equ
_init:
push esi
push ebx
sub esp, 4
mov eax, DWORD PTR [_boot_mbi]
test BYTE PTR [eax], 2
je .L2
push ecx
push ecx
push DWORD PTR [eax+12]
push .LC0
call _printf
add esp, 16
.L2:
mov eax, DWORD PTR [_boot_mbi]
test BYTE PTR [eax], 4
je L4
push edx
push edx
push DWORD PTR [eax+16]
push .LC1
call _printf
add esp, 16
.L4:
mov eax, DWORD PTR [_boot_mbi]
test BYTE PTR [eax], 8
je .L6
push esi
xor esi, esi
push DWORD PTR [eax+24]
push DWORD PTR [eax+20]
push .LC2
call _printf
mov eax, DWORD PTR [_boot_mbi]
mov ebx, DWORD PTR [eax+24]
jmp .L22
.L9:
mov eax, DWORD PTR [ebx-12]
inc esi
push DWORD PTR [ebx-8]
mov DWORD PTR [_pg_balloc], eax
push eax
push DWORD PTR [ebx-16]
push .LC3
call _printf
.L22:
mov eax, DWORD PTR [_boot_mbi]
add esp, 16
mov edx, ebx
add ebx, 16
cmp esi, DWORD PTR [eax+20]
jb .L9
mov edx, DWORD PTR [edx-16]
push ebx
push ebx
sub edx, 536870912
lea eax, [edx+512]
mov DWORD PTR [_rd_fat], eax
lea eax, [edx+4790]
push edx
push .LC4
mov DWORD PTR [_rd_fat_end], eax
lea eax, [edx+9728]
mov DWORD PTR [_rd_root], eax
lea eax, [edx+16896]
mov DWORD PTR [_rd_base], edx
mov DWORD PTR [_rd_root_end], eax
call _printf
add esp, 16
.L6:
mov eax, DWORD PTR [_boot_mbi]
xor esi, esi
test BYTE PTR [eax], 64
je .L13
push ecx
push DWORD PTR [eax+44]
push DWORD PTR [eax+48]
push .LC5
call _printf
mov eax, DWORD PTR [_boot_mbi]
add esp, 16
mov ebx, DWORD PTR [eax+48]
jmp .L14
.L15:
push edx
push DWORD PTR [ebx+20]
push DWORD PTR [ebx+12]
push DWORD PTR [ebx+16]
push DWORD PTR [ebx+4]
push DWORD PTR [ebx+8]
push DWORD PTR [ebx]
push .LC6
call _printf
add esp, 32
cmp DWORD PTR [ebx+20], 1
jne .L16
mov eax, DWORD PTR [ebx+4]
add eax, DWORD PTR [ebx+12]
and eax, -4096
cmp esi, eax
jae .L16
mov esi, eax
.L16:
mov eax, DWORD PTR [ebx]
add eax, 4
lea ebx, [eax+ebx]
.L14:
mov edx, DWORD PTR [_boot_mbi]
mov eax, DWORD PTR [edx+48]
add eax, DWORD PTR [edx+44]
cmp ebx, eax
jb .L15
cmp esi, 268435456
jbe .L13
mov esi, 268435456
.L13:
mov DWORD PTR [_mem_amount], esi
pop eax
pop ebx
pop esi
ret
.LC0:
db "boot_device = 0x%x",10,0
.LC1:
db "cmdline = %s",10,0
.LC2:
db "mods_count = %d, mods_addr = 0x%x",10,0
.LC3:
db " mod_start = 0x%x, mod_end = 0x%x, string = %s",10,0
.LC4:
db " rd_base = %x",10,0
.LC5:
db "mmap_addr = 0x%x, mmap_length = 0x%x",10,0
.LC6:
db " size = 0x%x, base_addr = 0x%x%x, length = 0x%x%x, type = 0x%x",10,0
restore DWORD
restore WORD
restore BYTE
restore PTR

View File

@ -556,57 +556,27 @@ _zone_create:
ret ret
_init_mm: _init_mm:
push esi
xor eax, eax
push ebx push ebx
xor esi, esi sub esp, 24
sub esp, 20 mov eax, DWORD PTR [_mem_amount]
mov ebx, DWORD PTR [_mem_counter] mov DWORD PTR [esp], .LC3
test ebx, ebx mov ebx, eax
jle .L93 shr ebx, 12
xor ecx, ecx mov DWORD PTR [esp+8], ebx
xor edx, edx
jmp .L94
.L95:
add ecx, 1
add edx, 20
cmp ecx, ebx
je .L103
.L94:
cmp DWORD PTR [_mem_table+edx+16], 1
jne .L95
mov eax, DWORD PTR [_mem_table+edx]
add eax, DWORD PTR [_mem_table+edx+8]
and eax, -4096
cmp esi, eax
jae .L95
add ecx, 1
add edx, 20
cmp ecx, ebx
mov esi, eax
jne .L94
.L103:
cmp esi, 268435456
mov eax, esi
ja .L104
mov esi, eax
shr esi, 12
.L93:
mov DWORD PTR [_mem_amount], eax
mov [pg_data.mem_amount], eax
mov [pg_data.pages_count], esi
mov DWORD PTR [esp+8], esi
mov DWORD PTR [esp+4], eax mov DWORD PTR [esp+4], eax
mov DWORD PTR [esp], .LC1 call _printf
call _printf mov eax, DWORD PTR [_pg_balloc]
mov DWORD PTR [esp], .LC4
mov DWORD PTR [esp+8], esi mov DWORD PTR [esp+8], eax
lea eax, [ebx+ebx*4]
sal eax, 2
mov DWORD PTR [esp+4], eax
call _printf
mov DWORD PTR [esp+8], ebx
mov DWORD PTR [esp+4], 0 mov DWORD PTR [esp+4], 0
mov DWORD PTR [esp], _z_core mov DWORD PTR [esp], _z_core
call _zone_create call _zone_create
mov DWORD PTR [esp+8], esi mov DWORD PTR [esp+8], ebx
mov DWORD PTR [esp+4], 0 mov DWORD PTR [esp+4], 0
mov DWORD PTR [esp], _z_core mov DWORD PTR [esp], _z_core
call _zone_release call _zone_release
@ -616,17 +586,14 @@ _init_mm:
shr eax, 12 shr eax, 12
mov DWORD PTR [esp+8], eax mov DWORD PTR [esp+8], eax
call _zone_reserve call _zone_reserve
add esp, 20 add esp, 24
pop ebx pop ebx
pop esi ret
ret .LC3:
.L104: db "last page = %x total pages = %x",10,0
mov eax, 268435456 .LC4:
mov esi, eax db "conf_size = %x free mem start =%x",10,0
shr esi, 12
jmp .L93
.LC1:
db 'memory size = %x total pages = %x',10,0
_frame_free: _frame_free:
push ebx push ebx

View File

@ -67,9 +67,9 @@ keymap_alt:
boot_pal_vga db 'Setting VGA 640x480 palette',0 boot_pal_vga db 'Setting VGA 640x480 palette',0
boot_failed db 'Failed to start first app',0 boot_failed db 'Failed to start first app',0
boot_mtrr db 'Setting MTRR',0 boot_mtrr db 'Setting MTRR',0
if preboot_blogesc ;if preboot_blogesc
boot_tasking db 'All set - press ESC to start',0 ; boot_tasking db 'All set - press ESC to start',0
end if ;end if
new_process_loading db 'K : New Process - loading',13,10,0 new_process_loading db 'K : New Process - loading',13,10,0
new_process_running db 'K : New Process - done',13,10,0 new_process_running db 'K : New Process - done',13,10,0
@ -134,6 +134,13 @@ mode_640_480_16:
mode_320_240_8: mode_320_240_8:
dw 320,240,8,60 dw 320,240,8,60
bx_from_load: dw 'r1' ; ñòðóêòóðà äëÿ õðàíåíèÿ ïàðàìåòðîâ- îòêóäà ãàøðóçèëèñü, áåðåòñÿ íèæå èç bx ; {SPraid}[13.03.2007]
; a,b,c,d - âèí÷åñòåðû, r - ðàì äèñê
; # äèñêà... ñèìâîë, à íå áàéò. '1', à íå 1
; mike.dld { ; mike.dld {
db 0 db 0
dd servetable-0x10000 dd servetable-0x10000
@ -256,6 +263,17 @@ endofcode:
gdte: gdte:
align 16 align 16
__edata: ;equ $-OS_BASE
align 4096
_sys_pdbr rb 4096
rb 8192-512
__os_stack rb 512
cur_saved_data rb 4096 cur_saved_data rb 4096
fpu_data: rb 512 fpu_data: rb 512
@ -293,6 +311,9 @@ large_block_list rd 31
mem_block_mask rd 2 mem_block_mask rd 2
large_block_mask rd 1 large_block_mask rd 1
_boot_mbi rd 1
_mem_amount rd 1 _mem_amount rd 1
_rd_base rd 1 _rd_base rd 1
_rd_fat rd 1 ;RAMDISK + 512 _rd_fat rd 1 ;RAMDISK + 512
@ -322,7 +343,6 @@ event_start rd 1
event_end rd 1 event_end rd 1
event_uid rd 1 event_uid rd 1
sys_page_map rd 1 sys_page_map rd 1
os_stack_seg rd 1
srv.fd rd 1 srv.fd rd 1
srv.bk rd 1 srv.bk rd 1

View File

@ -40,7 +40,7 @@ proc Parser_params
locals locals
buff db 4 dup(?) ; for test cd buff db 4 dup(?) ; for test cd
endl endl
mov eax,[OS_BASE+0x10000+bx_from_load] mov eax,[bx_from_load]
mov ecx,sysdir_path mov ecx,sysdir_path
mov [ecx-64],dword 'sys' mov [ecx-64],dword 'sys'
cmp al,'r' ; if ram disk cmp al,'r' ; if ram disk

View File

@ -73,102 +73,4 @@ init_BIOS32:
.end: .end:
ret ret
align 4
proc test_cpu
locals
cpu_type dd ?
cpu_id dd ?
cpu_Intel dd ?
cpu_AMD dd ?
endl
mov [cpu_type], 0
xor eax, eax
mov [cpu_caps-OS_BASE], eax
mov [cpu_caps+4-OS_BASE], eax
pushfd
pop eax
mov ecx, eax
xor eax, 0x40000
push eax
popfd
pushfd
pop eax
xor eax, ecx
mov [cpu_type], CPU_386
jz .end_cpuid
push ecx
popfd
mov [cpu_type], CPU_486
mov eax, ecx
xor eax, 0x200000
push eax
popfd
pushfd
pop eax
xor eax, ecx
je .end_cpuid
mov [cpu_id], 1
xor eax, eax
cpuid
mov [cpu_vendor-OS_BASE], ebx
mov [cpu_vendor+4-OS_BASE], edx
mov [cpu_vendor+8-OS_BASE], ecx
cmp ebx, dword [intel_str-OS_BASE]
jne .check_AMD
cmp edx, dword [intel_str+4-OS_BASE]
jne .check_AMD
cmp ecx, dword [intel_str+8-OS_BASE]
jne .check_AMD
mov [cpu_Intel], 1
cmp eax, 1
jl .end_cpuid
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
shr eax, 8
and eax, 0x0f
ret
.end_cpuid:
mov eax, [cpu_type]
ret
.check_AMD:
cmp ebx, dword [AMD_str-OS_BASE]
jne .unknown
cmp edx, dword [AMD_str+4-OS_BASE]
jne .unknown
cmp ecx, dword [AMD_str+8-OS_BASE]
jne .unknown
mov [cpu_AMD], 1
cmp eax, 1
jl .unknown
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
shr eax, 8
and eax, 0x0f
ret
.unknown:
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
shr eax, 8
and eax, 0x0f
ret
endp

View File

@ -105,145 +105,154 @@ pci_data_sel equ (pci_data_32-gdts)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 16 BIT ENTRY FROM BOOTSECTOR ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
use16
org 0x0
jmp start_of_code
version db 'Kolibri OS version 0.7.1.0 ',13,10,13,10,0
include "boot/bootstr.inc" ; language-independent boot messages
include "boot/preboot.inc"
if lang eq en
include "boot/booteng.inc" ; english system boot messages
else if lang eq ru
include "boot/bootru.inc" ; russian system boot messages
include "boot/ru.inc" ; Russian font
else if lang eq et
include "boot/bootet.inc" ; estonian system boot messages
include "boot/et.inc" ; Estonian font
else
include "boot/bootge.inc" ; german system boot messages
end if
include "boot/bootcode.inc" ; 16 bit system boot code
include "bus/pci/pci16.inc"
include "detect/biosdisk.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SWITCH TO 32 BIT PROTECTED MODE ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CR0 Flags - Protected mode and Paging
mov ecx, CR0_PE
; Enabling 32 bit protected mode
sidt [cs:old_ints_h]
cli ; disable all irqs
cld
mov al,255 ; mask all irqs
out 0xa1,al
out 0x21,al
l.5: in al, 0x64 ; Enable A20
test al, 2
jnz l.5
mov al, 0xD1
out 0x64, al
l.6: in al, 0x64
test al, 2
jnz l.6
mov al, 0xDF
out 0x60, al
l.7: in al, 0x64
test al, 2
jnz l.7
mov al, 0xFF
out 0x64, al
lgdt [cs:tmp_gdt] ; Load GDT
mov eax, cr0 ; protected mode
or eax, ecx
and eax, 10011111b *65536*256 + 0xffffff ; caching enabled
mov cr0, eax
jmp pword os_code:B32 ; jmp to enable 32 bit mode
align 8
tmp_gdt:
dw 23
dd tmp_gdt+0x10000
dw 0
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011010b
db 0x00
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
include "data16.inc"
use32 use32
org $+0x10000 org 0x100000
mboot:
dd 0x1BADB002
dd 0x00010003
dd -(0x1BADB002 + 0x00010003)
dd mboot
dd 0x100000
dd __edata - OS_BASE
dd LAST_PAGE
dd __start
align 16
__start:
cld
mov esp, __os_stack-OS_BASE
push 0
popf
cmp eax, 0x2BADB002
mov ecx, sz_invboot
jne .fault
bt dword [ebx], 3
mov ecx, sz_nomods
jnc .fault
bt dword [ebx], 6
mov ecx, sz_nommap
jnc .fault
mov [_boot_mbi-OS_BASE], ebx
xor eax, eax
cpuid
cmp eax, 0
mov ecx, sz_nopse
jbe .fault
mov eax, 1
cpuid
bt edx, 3
mov ecx, sz_nopse
jnc .fault
; ENABLE PAGING
mov ecx, 32
mov edi, _sys_pdbr+(OS_BASE shr 20)-OS_BASE
mov eax, PG_LARGE+PG_SW
@@:
stosd
add eax, 4*1024*1024
loop @B
mov dword [_sys_pdbr-OS_BASE], PG_LARGE+PG_SW
mov dword [_sys_pdbr-OS_BASE+4], PG_LARGE+PG_SW+4*1024*1024
mov dword [_sys_pdbr-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE
mov ebx, cr4
or ebx, CR4_PSE
and ebx, not CR4_PAE
mov cr4, ebx
mov eax, _sys_pdbr-OS_BASE
mov ebx, cr0
or ebx,CR0_PG+CR0_WP
mov cr3, eax
mov cr0, ebx
mov ebx, [_boot_mbi]
mov edx, [ebx+20]
mov esi, [ebx+24]
mov ecx, LAST_PAGE
test edx, edx
jz .no_mods
.scan_mod:
mov ecx, [esi+4]
add esi, 16
dec edx
jnz .scan_mod
.no_mods:
add ecx, 4095
and ecx, not 4095
lgdt [gdts]
jmp pword os_code:high_code
.fault:
; push ecx
; call _lcls
; call __bprintf
_hlt:
hlt
jmp _hlt
sz_invboot db 'Invalid multiboot loader magic value',0x0A
db 'Halted',0
sz_nomods db 'No modules loaded',0x0A
db 'Halted',0
sz_nommap db 'No memory table', 0x0A
db 'Halted',0
sz_nopse db 'Page size extensions not supported',0x0A
db 'Halted',0
align 4
B32:
mov ax,os_stack ; Selector for os
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov esp,0x3ec00 ; Set stack
; CLEAR 0x280000 - HEAP_BASE ; CLEAR 0x280000 - HEAP_BASE
xor eax,eax ; xor eax,eax
mov edi,0x280000 ; mov edi,0x280000
mov ecx,(0x800000-0x280000) / 4 ; mov ecx,(0x800000-0x280000) / 4
cld ; cld
rep stosd ; rep stosd
mov edi,0x40000 ; mov edi,0x40000
mov ecx,(0x90000-0x40000)/4 ; mov ecx,(0x90000-0x40000)/4
rep stosd ; rep stosd
; CLEAR KERNEL UNDEFINED GLOBALS ; CLEAR KERNEL UNDEFINED GLOBALS
mov edi, endofcode-OS_BASE ; mov edi, endofcode-OS_BASE
mov ecx, (uglobals_size/4)+4 ; mov ecx, (uglobals_size/4)+4
rep stosd ; rep stosd
; SAVE & CLEAR 0-0xffff ; SAVE & CLEAR 0-0xffff
xor esi, esi ; xor esi, esi
mov edi,0x2F0000 ; mov edi,0x2F0000
mov ecx,0x10000 / 4 ; mov ecx,0x10000 / 4
rep movsd ; rep movsd
xor edi, edi ; xor edi, edi
mov ecx,0x10000 / 4 ; mov ecx,0x10000 / 4
rep stosd ; rep stosd
call test_cpu ; call test_cpu
bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc
call init_BIOS32 ; call init_BIOS32
mov dword [sys_pgdir-OS_BASE], PG_LARGE+PG_SW mov dword [sys_pgdir-OS_BASE], PG_LARGE+PG_SW
mov dword [sys_pgdir-OS_BASE+4], PG_LARGE+PG_SW+4*1024*1024 mov dword [sys_pgdir-OS_BASE+4], PG_LARGE+PG_SW+4*1024*1024
@ -261,7 +270,6 @@ B32:
and ebx, not CR4_PAE and ebx, not CR4_PAE
mov cr4, ebx mov cr4, ebx
; ENABLE PAGING
mov eax, sys_pgdir-OS_BASE mov eax, sys_pgdir-OS_BASE
mov ebx, cr0 mov ebx, cr0
@ -277,15 +285,14 @@ align 4
bios32_entry dd ? bios32_entry dd ?
tmp_page_tabs dd ? tmp_page_tabs dd ?
use16 ;use16
org $-0x10000 ;org $-0x10000
include "boot/shutdown.inc" ; shutdown or restart ;include "boot/shutdown.inc" ; shutdown or restart
org $+0x10000 ;org $+0x10000
use32 ;use32
__DEBUG__ fix 1 __DEBUG__ fix 1
__DEBUG_LEVEL__ fix 1 __DEBUG_LEVEL__ fix 1
include 'init.inc'
org OS_BASE+$ org OS_BASE+$
@ -297,62 +304,150 @@ MEM_UC equ 0 ;uncached memory
include 'printf.inc' include 'printf.inc'
include 'core/mm.asm' include 'core/mm.asm'
include 'core/init.asm'
align 4
proc test_cpu
locals
cpu_type dd ?
cpu_id dd ?
cpu_Intel dd ?
cpu_AMD dd ?
endl
mov [cpu_type], 0
xor eax, eax
mov [cpu_caps], eax
mov [cpu_caps+4], eax
pushfd
pop eax
mov ecx, eax
xor eax, 0x40000
push eax
popfd
pushfd
pop eax
xor eax, ecx
mov [cpu_type], CPU_386
jz .end_cpuid
push ecx
popfd
mov [cpu_type], CPU_486
mov eax, ecx
xor eax, 0x200000
push eax
popfd
pushfd
pop eax
xor eax, ecx
je .end_cpuid
mov [cpu_id], 1
xor eax, eax
cpuid
mov [cpu_vendor], ebx
mov [cpu_vendor+4], edx
mov [cpu_vendor+8], ecx
cmp ebx, dword [intel_str]
jne .check_AMD
cmp edx, dword [intel_str+4]
jne .check_AMD
cmp ecx, dword [intel_str+8]
jne .check_AMD
mov [cpu_Intel], 1
cmp eax, 1
jl .end_cpuid
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
.end_cpuid:
mov eax, [cpu_type]
ret
.check_AMD:
cmp ebx, dword [AMD_str]
jne .unknown
cmp edx, dword [AMD_str+4]
jne .unknown
cmp ecx, dword [AMD_str+8]
jne .unknown
mov [cpu_AMD], 1
cmp eax, 1
jl .unknown
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
.unknown:
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
endp
align 4 align 4
high_code: high_code:
mov ax,os_stack mov ax,os_stack
mov bx,app_data mov dx,app_data
mov ss,ax mov ss,ax
add esp, OS_BASE mov esp, __os_stack
mov ds,bx mov ds, dx
mov es,bx mov es, dx
mov fs,bx mov fs, dx
mov gs,bx mov gs, dx
mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE push ecx
push ebx
bt [cpu_caps], CAPS_PGE ; mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE
jnc @F
or dword [sys_pgdir-OS_BASE+(OS_BASE shr 20)], PG_GLOBAL ; bt [cpu_caps], CAPS_PGE
; jnc @F
mov ebx, cr4 ; or dword [sys_pgdir-OS_BASE+(OS_BASE shr 20)], PG_GLOBAL
or ebx, CR4_PGE
mov cr4, ebx ; mov ebx, cr4
; or ebx, CR4_PGE
; mov cr4, ebx
@@: @@:
xor eax, eax ; xor eax, eax
mov dword [sys_pgdir], eax ; mov dword [sys_pgdir], eax
mov dword [sys_pgdir+4], eax ; mov dword [sys_pgdir+4], eax
mov eax, cr3
mov cr3, eax ; flush TLB
; mov eax, cr3
; mov cr3, eax ; flush TLB
mov edx, 0x3fB mov edx, 0x3fB
mov eax, 3 mov eax, 3
out dx, al out dx, al
; MEMORY MODEL call test_cpu
call _init
mov ecx, 1280*1024
fastcall _balloc
mov [_display_data], eax
mov ecx, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \
(unpack.lc+unpack.lp)))*4
fastcall _balloc
mov [unpack.p], eax
mov ecx, (RING0_STACK_SIZE+512)
fastcall _balloc
mov [os_stack_seg], eax
lea esp, [eax+RING0_STACK_SIZE]
mov [tss._ss0], os_stack mov [tss._ss0], os_stack
mov [tss._esp0], esp mov [tss._esp0], __os_stack
mov [tss._esp], esp mov [tss._esp], __os_stack
mov [tss._cs],os_code mov [tss._cs],os_code
mov [tss._ss],os_stack mov [tss._ss],os_stack
mov [tss._ds],app_data mov [tss._ds],app_data
@ -370,11 +465,27 @@ high_code:
mov ax,tss0 mov ax,tss0
ltr ax ltr ax
xchg bx, bx
mov ecx, 1280*1024
fastcall _balloc
mov [_display_data], eax
mov ecx, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \
(unpack.lc+unpack.lp)))*4
fastcall _balloc
mov [unpack.p], eax
; MEMORY MODEL
call init_kernel_heap ; FIXME initialize heap after pager call init_kernel_heap ; FIXME initialize heap after pager
call _init_mm call _init_mm
mov [pg_data.pg_mutex], 0 mov [pg_data.pg_mutex], 0
hlt
; SAVE REAL MODE VARIABLES ; SAVE REAL MODE VARIABLES
mov ax, [BOOT_VAR + 0x9031] mov ax, [BOOT_VAR + 0x9031]
mov [IDEContrRegsBaseAddr], ax mov [IDEContrRegsBaseAddr], ax
@ -629,23 +740,18 @@ include 'detect/disks.inc'
; mov [dma_hdd],1 ; mov [dma_hdd],1
; CALCULATE FAT CHAIN FOR RAMDISK ; CALCULATE FAT CHAIN FOR RAMDISK
mov [_rd_base], OS_BASE+0x100000
mov [_rd_fat], OS_BASE+0x100000 + 512
mov [_rd_fat_end], OS_BASE+0x100000 + 512 + 4278
mov [_rd_root], OS_BASE+0x100000 + 512*19
mov [_rd_root_end], OS_BASE+0x100000 + 512*33
call calculatefatchain call calculatefatchain
mov ax,[OS_BASE+0x10000+bx_from_load] ; mov ax,[OS_BASE+0x10000+bx_from_load]
cmp ax,'r1' ; if using not ram disk, then load librares and parameters {SPraid.simba} ; cmp ax,'r1' ; if using not ram disk, then load librares and parameters {SPraid.simba}
je no_lib_load ; je no_lib_load
; LOADING LIBRARES ; LOADING LIBRARES
stdcall dll.Load,@IMPORT ; loading librares for kernel (.obj files) ; stdcall dll.Load,@IMPORT ; loading librares for kernel (.obj files)
call load_file_parse_table ; prepare file parse table ; call load_file_parse_table ; prepare file parse table
call set_kernel_conf ; configure devices and gui ; call set_kernel_conf ; configure devices and gui
no_lib_load: ;no_lib_load:
; LOAD FONTS I and II ; LOAD FONTS I and II
@ -718,7 +824,7 @@ no_lib_load:
mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I'
mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE '
mov edi, [os_stack_seg] mov edi, __os_stack-8192+512
mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi
add edi, 0x2000-512 add edi, 0x2000-512
mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi
@ -828,11 +934,11 @@ no_lib_load:
stdcall map_page,tss._io_map_1,\ stdcall map_page,tss._io_map_1,\
(tss._io_map_1-OS_BASE), PG_MAP (tss._io_map_1-OS_BASE), PG_MAP
mov ax,[OS_BASE+0x10000+bx_from_load] ; mov ax,[OS_BASE+0x10000+bx_from_load]
cmp ax,'r1' ; if not rused ram disk - load network configuration from files {SPraid.simba} ; cmp ax,'r1' ; if not rused ram disk - load network configuration from files {SPraid.simba}
je no_st_network ; je no_st_network
call set_network_conf ; call set_network_conf
no_st_network: ; no_st_network:
; LOAD FIRST APPLICATION ; LOAD FIRST APPLICATION
cli cli
@ -891,13 +997,13 @@ first_app_found:
; START MULTITASKING ; START MULTITASKING
if preboot_blogesc ;if preboot_blogesc
mov esi, boot_tasking ; mov esi, boot_tasking
call boot_log ; call boot_log
.bll1: in al, 0x60 ; wait for ESC key press ;.bll1: in al, 0x60 ; wait for ESC key press
cmp al, 129 ; cmp al, 129
jne .bll1 ; jne .bll1
end if ;end if
; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled ; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled
@ -5163,16 +5269,16 @@ yes_shutdown_param:
mov edx, OS_BASE+0x70000 mov edx, OS_BASE+0x70000
call fileread call fileread
mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 ; mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0
mov edi,OS_BASE+0x40000 ; mov edi,OS_BASE+0x40000
mov ecx,1000 ; mov ecx,1000
rep movsb ; rep movsb
mov esi,OS_BASE+0x2F0000 ; restore 0x0 - 0xffff mov esi,OS_BASE+0x2F0000 ; restore 0x0 - 0xffff
mov edi, OS_BASE mov edi, OS_BASE
mov ecx,0x10000/4 mov ecx,0x10000/4
cld cld
rep movsd rep movsd
call restorefatchain call restorefatchain
@ -5181,8 +5287,8 @@ yes_shutdown_param:
out 0xA1, al out 0xA1, al
if 1 if 1
mov word [OS_BASE+0x467+0],pr_mode_exit ; mov word [OS_BASE+0x467+0],pr_mode_exit
mov word [OS_BASE+0x467+2],0x1000 ; mov word [OS_BASE+0x467+2],0x1000
mov al,0x0F mov al,0x0F
out 0x70,al out 0x70,al
@ -5316,3 +5422,7 @@ __REV__ = __REV
uglobals_size = $ - endofcode uglobals_size = $ - endofcode
diff16 "end of kernel code",0,$ diff16 "end of kernel code",0,$
align 16
__end: