Update BOOT_DATA structure and use it instead of all the BOOT_* vars.

git-svn-id: svn://kolibrios.org@7132 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2017-12-17 02:12:53 +00:00
parent b00728a5d1
commit 368d42ffae
18 changed files with 192 additions and 204 deletions

View File

@ -282,18 +282,18 @@ else
jnz @f jnz @f
mov word [cs:cfgmanager.loader_block], si mov word [cs:cfgmanager.loader_block], si
mov word [cs:cfgmanager.loader_block+2], ds mov word [cs:cfgmanager.loader_block+2], ds
mov word [es:BOOT_KERNEL_RESTART], kernel_restart_bootblock mov word [es:BOOT_LO.kernel_restart], kernel_restart_bootblock
@@: @@:
; \end{diamond}[02.12.2005] ; \end{diamond}[02.12.2005]
; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source disk ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source disk
; (see comment to BOOT_BX_FROM_LOAD and loader_doc.txt) ; (see comment to BOOT_LO.bx_from_load and loader_doc.txt)
mov word [es:BOOT_BX_FROM_LOAD], 'r1' ; default value: /rd/1 mov word [es:BOOT_LO.bx_from_load], 'r1' ; default value: /rd/1
cmp cx, 'HA' cmp cx, 'HA'
jnz no_hd_load jnz no_hd_load
cmp dx, 'RD' cmp dx, 'RD'
jnz no_hd_load jnz no_hd_load
mov [es:BOOT_BX_FROM_LOAD], bx mov [es:BOOT_LO.bx_from_load], bx
no_hd_load: no_hd_load:
; set up stack ; set up stack
@ -441,15 +441,15 @@ sayerr:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sti sti
; --------------- APM --------------------- ; --------------- APM ---------------------
and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) and word [es:BOOT_LO.apm_version], 0 ; ver = 0.0 (APM not found)
mov ax, 0x5300 mov ax, 0x5300
xor bx, bx xor bx, bx
int 0x15 int 0x15
jc apm_end ; APM not found jc apm_end ; APM not found
test cx, 2 test cx, 2
jz apm_end ; APM 32-bit protected-mode interface not supported jz apm_end ; APM 32-bit protected-mode interface not supported
mov [es:BOOT_APM_VERSION], ax ; Save APM Version mov [es:BOOT_LO.apm_version], ax ; Save APM Version
mov [es:BOOT_APM_FLAGS], cx ; Save APM flags mov [es:BOOT_LO.apm_flags], cx ; Save APM flags
; Write APM ver ---- ; Write APM ver ----
and ax, 0xf0f and ax, 0xf0f
@ -468,10 +468,10 @@ sayerr:
xor bx, bx xor bx, bx
int 0x15 int 0x15
mov [es:BOOT_APM_ENTRY], ebx mov [es:BOOT_LO.apm_entry], ebx
mov [es:BOOT_APM_CODE_32], ax mov [es:BOOT_LO.apm_code_32], ax
mov [es:BOOT_APM_CODE_16], cx mov [es:BOOT_LO.apm_code_16], cx
mov [es:BOOT_APM_DATA_16], dx mov [es:BOOT_LO.apm_data_16], dx
apm_end: apm_end:
_setcursor d80x25_top_num, 0 _setcursor d80x25_top_num, 0
@ -951,33 +951,33 @@ end if
; GRAPHICS ACCELERATION ; GRAPHICS ACCELERATION
; force yes ; force yes
mov [es:BOOT_MTRR], byte 1 mov [es:BOOT_LO.mtrr], byte 1
; DMA ACCESS TO HD ; DMA ACCESS TO HD
mov al, [preboot_dma] mov al, [preboot_dma]
mov [es:BOOT_DMA], al mov [es:BOOT_LO.dma], al
; Set kernel DEBUG mode - if nonzero, duplicates debug output to the screen. ; Set kernel DEBUG mode - if nonzero, duplicates debug output to the screen.
mov al, [preboot_debug] mov al, [preboot_debug]
mov [es:BOOT_DEBUG_PRINT], al ;// 0x901E mov [es:BOOT_LO.debug_print], al ;// 0x901E
; Start the first app (right now it's LAUNCHER) after kernel is loaded? ; Start the first app (right now it's LAUNCHER) after kernel is loaded?
mov al, [preboot_launcher] mov al, [preboot_launcher]
mov [es:BOOT_LAUNCHER_START], al ;// 0x901D mov [es:BOOT_LO.launcher_start], al ;// 0x901D
; BOOT DEVICE ; BOOT DEVICE
mov al, [preboot_device] mov al, [preboot_device]
dec al dec al
mov [es:BOOT_DEV], al mov [es:BOOT_LO.dev], al
; GET MEMORY MAP ; GET MEMORY MAP
include '../detect/biosmem.inc' include '../detect/biosmem.inc'
; READ DISKETTE TO MEMORY ; READ DISKETTE TO MEMORY
cmp byte [es:BOOT_DEV], 0 cmp byte [es:BOOT_LO.dev], 0
jne no_sys_on_floppy jne no_sys_on_floppy
mov si, diskload mov si, diskload
call print call print
@ -1304,7 +1304,7 @@ no_sys_on_floppy:
out dx, al out dx, al
if defined extended_primary_loader if defined extended_primary_loader
cmp [es:BOOT_DEV], 1 cmp [es:BOOT_LO.dev], 1
jne no_sys_from_primary jne no_sys_from_primary
; load kolibri.img using callback from primary loader ; load kolibri.img using callback from primary loader
and word [movedesc + 24 + 2], 0 and word [movedesc + 24 + 2], 0
@ -1343,7 +1343,7 @@ end if
xor ax, ax xor ax, ax
mov es, ax mov es, ax
mov ax, [es:BOOT_VESA_MODE] ; vga & 320x200 mov ax, [es:BOOT_LO.vesa_mode] ; vga & 320x200
mov bx, ax mov bx, ax
cmp ax, 0x13 cmp ax, 0x13
je setgr je setgr

View File

@ -731,9 +731,9 @@ set_vmode:
mov bx, word [es:si+2] ; resolution Y mov bx, word [es:si+2] ; resolution Y
mov word [es:BOOT_X_RES], ax ; resolution X mov word [es:BOOT_LO.x_res], ax ; resolution X
mov word [es:BOOT_Y_RES], bx ; resolution Y mov word [es:BOOT_LO.y_res], bx ; resolution Y
mov word [es:BOOT_VESA_MODE], cx ; number of mode mov word [es:BOOT_LO.vesa_mode], cx ; number of mode
cmp cx, 0x12 cmp cx, 0x12
je .mode0x12_0x13 je .mode0x12_0x13
@ -752,11 +752,11 @@ set_vmode:
int 0x10 int 0x10
; LFB ; LFB
mov eax, [es:mi.PhysBasePtr];di+0x28] mov eax, [es:mi.PhysBasePtr];di+0x28]
mov [es:BOOT_LFB], eax mov [es:BOOT_LO.lfb], eax
; ---- vbe voodoo ; ---- vbe voodoo
BytesPerLine equ 0x10 BytesPerLine equ 0x10
mov ax, [es:di+BytesPerLine] mov ax, [es:di+BytesPerLine]
mov [es:BOOT_PITCH], ax mov [es:BOOT_LO.pitch], ax
; BPP ; BPP
cmp [es:mi.BitsPerPixel], 16 cmp [es:mi.BitsPerPixel], 16
jne .l0 jne .l0
@ -765,12 +765,12 @@ set_vmode:
mov [es:mi.BitsPerPixel], 15 mov [es:mi.BitsPerPixel], 15
.l0: .l0:
mov al, byte [es:di+0x19] mov al, byte [es:di+0x19]
mov [es:BOOT_BPP], al mov [es:BOOT_LO.bpp], al
jmp .exit jmp .exit
.mode0x12_0x13: .mode0x12_0x13:
mov byte [es:BOOT_BPP], 32 mov byte [es:BOOT_LO.bpp], 32
or dword [es:BOOT_LFB], 0xFFFFFFFF; 0x800000 or dword [es:BOOT_LO.lfb], 0xFFFFFFFF; 0x800000
; VESA 1.2 PM BANK SWITCH ADDRESS ; VESA 1.2 PM BANK SWITCH ADDRESS
@ -789,7 +789,7 @@ set_vmode:
; add eax, ebx ; add eax, ebx
; push 0x0000 ; push 0x0000
; pop es ; pop es
; mov [es:BOOT_BANK_SW], eax ; mov [es:BOOT_LO.bank_sw], eax
.exit: .exit:
ret ret

View File

@ -11,7 +11,7 @@ $Revision$
read_ramdisk: read_ramdisk:
; READ RAMDISK IMAGE FROM HD (only for IDE0, IDE1, IDE2, IDE3) ; READ RAMDISK IMAGE FROM HD (only for IDE0, IDE1, IDE2, IDE3)
cmp byte [BOOT_DEV+OS_BASE+0x10000], 1 cmp byte [BOOT.dev+0x10000], 1
jne no_sys_on_hd.1 jne no_sys_on_hd.1
xor ebp, ebp xor ebp, ebp
@ -112,7 +112,7 @@ no_sys_on_hd:
DEBUGF 1, "K : RD not found\n" DEBUGF 1, "K : RD not found\n"
.1: .1:
; test_to_format_ram_disk (need if not using ram disk) ; test_to_format_ram_disk (need if not using ram disk)
cmp byte [BOOT_DEV+OS_BASE+0x10000], 3 cmp byte [BOOT.dev+0x10000], 3
jne not_format_ram_disk jne not_format_ram_disk
; format_ram_disk ; format_ram_disk
mov edi, RAMDISK mov edi, RAMDISK

View File

@ -16,9 +16,9 @@ $Revision$
align 4 align 4
system_shutdown: ; shut down the system system_shutdown: ; shut down the system
cmp byte [BOOT_VARS+BOOT_SHUTDOWN_TYPE], SYSTEM_SHUTDOWN cmp byte [BOOT.shutdown_type], SYSTEM_SHUTDOWN
jb @F jb @F
cmp byte [BOOT_VARS+BOOT_SHUTDOWN_TYPE], SYSTEM_RESTART cmp byte [BOOT.shutdown_type], SYSTEM_RESTART
jbe .valid jbe .valid
@@: @@:
ret ret
@ -62,7 +62,7 @@ yes_shutdown_param:
cli cli
call IRQ_mask_all call IRQ_mask_all
mov eax, [OS_BASE + BOOT_SHUTDOWN_TYPE] mov eax, dword[BOOT.shutdown_type]
cmp al, SYSTEM_RESTART cmp al, SYSTEM_RESTART
jne @F jne @F
@ -91,7 +91,7 @@ org $-OS_BASE
mov eax, cr3 mov eax, cr3
mov cr3, eax mov cr3, eax
cmp byte [BOOT_SHUTDOWN_TYPE], SYSTEM_SHUTDOWN cmp byte [BOOT_LO.shutdown_type], SYSTEM_SHUTDOWN
jne no_acpi_power_off jne no_acpi_power_off
; system_power_off ; system_power_off
@ -179,7 +179,7 @@ align 4
restart_code_start: restart_code_start:
org 0x50000 org 0x50000
cmp byte [BOOT_SHUTDOWN_TYPE], SYSTEM_RESTART cmp byte [BOOT_LO.shutdown_type], SYSTEM_RESTART
jne @F jne @F
mov esi, _CLEAN_ZONE-OS_BASE mov esi, _CLEAN_ZONE-OS_BASE
@ -277,7 +277,7 @@ align 4
xor ax, ax xor ax, ax
mov ds, ax mov ds, ax
mov al, [BOOT_SHUTDOWN_TYPE] mov al, [BOOT_LO.shutdown_type]
cmp al, SYSTEM_RESTART cmp al, SYSTEM_RESTART
je .restart je .restart
@ -350,7 +350,7 @@ align 4
pop ds pop ds
push 0 push 0
pop es pop es
mov si, [es:BOOT_KERNEL_RESTART] mov si, [es:BOOT_LO.kernel_restart]
mov ax, 'KL' mov ax, 'KL'
jmp 0x1000:0000 jmp 0x1000:0000

View File

@ -70,7 +70,7 @@ main:
cmp [rdi + 8], rdx cmp [rdi + 8], rdx
jnz .not_acpi20 jnz .not_acpi20
mov rax, [rdi + 16] mov rax, [rdi + 16]
mov rdx, BOOT_ACPI_RSDP mov rdx, BOOT_LO.acpi_rsdp
mov [rdx], eax mov [rdx], eax
;jmp $ ;jmp $
jmp .all_tables_done jmp .all_tables_done
@ -157,27 +157,27 @@ main:
mov rcx, [gop_info] mov rcx, [gop_info]
mov eax, [rcx + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution] mov eax, [rcx + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
xor rdx, rdx xor rdx, rdx
mov word [rdx + BOOT_X_RES], ax mov word [rdx + BOOT_LO.x_res], ax
mov eax, [rcx + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution] mov eax, [rcx + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
mov word [rdx + BOOT_Y_RES], ax mov word [rdx + BOOT_LO.y_res], ax
mov eax, [rcx + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine] mov eax, [rcx + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine]
shl eax, 2 shl eax, 2
mov word [rdx + BOOT_PITCH], ax mov word [rdx + BOOT_LO.pitch], ax
mov byte [rdx + BOOT_PCI_DATA + 0], 1 mov byte [rdx + BOOT_LO.pci_data + 0], 1
mov byte [rdx + BOOT_PCI_DATA + 1], 0 mov byte [rdx + BOOT_LO.pci_data + 1], 0
mov byte [rdx + BOOT_PCI_DATA + 2], 0x10 mov byte [rdx + BOOT_LO.pci_data + 2], 0x10
mov byte [rdx + BOOT_PCI_DATA + 3], 0x02 mov byte [rdx + BOOT_LO.pci_data + 3], 0x02
mov dword [rdx + BOOT_PCI_DATA + 4], 0xe3 mov dword [rdx + BOOT_LO.pci_data + 4], 0xe3
uefi_call_wrapper BootServices, GetMemoryMap, memory_map_size, memory_map, memory_map_key, descriptor_size, descriptor_ver uefi_call_wrapper BootServices, GetMemoryMap, memory_map_size, memory_map, memory_map_key, descriptor_size, descriptor_ver
cmp eax, EFI_SUCCESS cmp eax, EFI_SUCCESS
jnz .error jnz .error
mov rdi, BOOT_MEMMAP_BLOCK_CNT mov rdi, BOOT_LO.memmap_block_cnt
mov dword[rdi], 0 mov dword[rdi], 0
mov rdi, BOOT_MEMMAP_BLOCKS mov rdi, BOOT_LO.memmap_blocks
mov rax, [memory_map_size] mov rax, [memory_map_size]
xor edx, edx xor edx, edx
mov rcx, [descriptor_size] mov rcx, [descriptor_size]
@ -215,24 +215,24 @@ main:
rep movsq rep movsq
xor esi, esi xor esi, esi
mov byte[esi + BOOT_BPP], 32 mov byte[esi + BOOT_LO.bpp], 32
mov word[esi + BOOT_VESA_MODE], 0 mov word[esi + BOOT_LO.vesa_mode], 0
mov dword[esi + BOOT_BANK_SW], 0 mov dword[esi + BOOT_LO.bank_switch], 0
mov rdi, [fb_base] mov rdi, [fb_base]
mov dword[esi + BOOT_LFB], edi mov dword[esi + BOOT_LO.lfb], edi
mov byte[esi + BOOT_MTRR], 1 mov byte[esi + BOOT_LO.mtrr], 1
mov byte[esi + BOOT_LAUNCHER_START], 1 mov byte[esi + BOOT_LO.launcher_start], 1
mov byte[esi + BOOT_DEBUG_PRINT], 1 mov byte[esi + BOOT_LO.debug_print], 1
mov byte[esi + BOOT_DMA], 0 mov byte[esi + BOOT_LO.dma], 0
; mov qword[esi + BOOT_PCI_DATA], 0 ; mov qword[esi + BOOT_LO.pci_data], 0
mov dword[esi + BOOT_APM_ENTRY], 0 mov dword[esi + BOOT_LO.apm_entry], 0
mov word[esi + BOOT_APM_VERSION], 0 mov word[esi + BOOT_LO.apm_version], 0
mov dword[esi + BOOT_APM_FLAGS], 0 mov dword[esi + BOOT_LO.apm_flags], 0
mov word[esi + BOOT_APM_CODE_32], 0 mov word[esi + BOOT_LO.apm_code_32], 0
mov word[esi + BOOT_APM_CODE_16], 0 mov word[esi + BOOT_LO.apm_code_16], 0
mov word[esi + BOOT_APM_DATA_16], 0 mov word[esi + BOOT_LO.apm_data_16], 0
mov byte[esi + BOOT_BIOS_HD_CNT], 0 mov byte[esi + BOOT_LO.bios_hd_cnt], 0
mov word[esi + BOOT_BX_FROM_LOAD], 'r1' ; boot from /rd/1 mov word[esi + BOOT_LO.bx_from_load], 'r1' ; boot from /rd/1
lgdt [cs:GDTR] lgdt [cs:GDTR]
@ -341,7 +341,7 @@ add_uefi_memmap:
.done: .done:
mov [rdi + e820entry.type], eax mov [rdi + e820entry.type], eax
mov rax, BOOT_MEMMAP_BLOCK_CNT mov rax, BOOT_LO.memmap_block_cnt
inc word[rax] inc word[rax]
pop rdi rsi rdx rcx rbx rax pop rdi rsi rdx rcx rbx rax

View File

@ -24,15 +24,15 @@ init_pci_16:
xor ax, ax xor ax, ax
mov es, ax mov es, ax
mov byte [es:BOOT_PCI_DATA], 1;default mechanism:1 mov byte [es:BOOT_LO.pci_data], 1;default mechanism:1
mov ax, 0xb101 mov ax, 0xb101
int 0x1a int 0x1a
or ah, ah or ah, ah
jnz pci16skip jnz pci16skip
mov [es:BOOT_PCI_DATA+1], cl;last PCI bus in system mov [es:BOOT_LO.pci_data+1], cl;last PCI bus in system
mov [es:BOOT_PCI_DATA+2], bx mov word[es:BOOT_LO.pci_data+2], bx
mov [es:BOOT_PCI_DATA+4], edi mov dword[es:BOOT_LO.pci_data+4], edi
; we have a PCI BIOS, so check which configuration mechanism(s) ; we have a PCI BIOS, so check which configuration mechanism(s)
; it supports ; it supports
@ -41,7 +41,7 @@ init_pci_16:
jnz pci16skip jnz pci16skip
test al, 2 test al, 2
jz pci16skip jz pci16skip
mov byte [es:BOOT_PCI_DATA], 2; if (al&3)==2 => mechanism 2 mov byte [es:BOOT_LO.pci_data], 2; if (al&3)==2 => mechanism 2
pci16skip: pci16skip:

View File

@ -101,17 +101,17 @@ pci_api_drv:
pci_fn_0: pci_fn_0:
; PCI function 0: get pci version (AH.AL) ; PCI function 0: get pci version (AH.AL)
movzx eax, word [BOOT_VARS+BOOT_PCI_DATA+2] movzx eax, word [BOOT.pci_data+2]
ret ret
pci_fn_1: pci_fn_1:
; PCI function 1: get last bus in AL ; PCI function 1: get last bus in AL
mov al, [BOOT_VARS+BOOT_PCI_DATA+1] mov al, [BOOT.pci_data+1]
ret ret
pci_fn_2: pci_fn_2:
; PCI function 2: get pci access mechanism ; PCI function 2: get pci access mechanism
mov al, [BOOT_VARS+BOOT_PCI_DATA] mov al, [BOOT.pci_data]
ret ret
pci_service_not_supported: pci_service_not_supported:
@ -156,7 +156,7 @@ align 4
pci_read_reg: pci_read_reg:
push ebx esi push ebx esi
cmp byte [BOOT_VARS+BOOT_PCI_DATA], 2;what mechanism will we use? cmp byte [BOOT.pci_data], 2;what mechanism will we use?
je pci_read_reg_2 je pci_read_reg_2
; mechanism 1 ; mechanism 1
@ -260,7 +260,7 @@ align 4
pci_write_reg: pci_write_reg:
push esi ebx push esi ebx
cmp byte [BOOT_VARS+BOOT_PCI_DATA], 2;what mechanism will we use? cmp byte [BOOT.pci_data], 2;what mechanism will we use?
je pci_write_reg_2 je pci_write_reg_2
; mechanism 1 ; mechanism 1
@ -519,9 +519,9 @@ sys_pcibios:
cmp ebp, 1 ; PCI_FUNCTION_ID cmp ebp, 1 ; PCI_FUNCTION_ID
jnz .not_PCI_BIOS_PRESENT jnz .not_PCI_BIOS_PRESENT
mov edx, 'PCI ' mov edx, 'PCI '
mov al, [BOOT_VARS + BOOT_PCI_DATA] mov al, [BOOT.pci_data]
mov bx, [BOOT_VARS + BOOT_PCI_DATA + 2] mov bx, word[BOOT.pci_data + 2]
mov cl, [BOOT_VARS + BOOT_PCI_DATA + 1] mov cl, [BOOT.pci_data + 1]
xor ah, ah xor ah, ah
jmp .return_abcd jmp .return_abcd
@ -665,7 +665,7 @@ end virtual
.next_func: .next_func:
inc dword [.devfn] inc dword [.devfn]
mov ah, [.bus] mov ah, [.bus]
cmp ah, [BOOT_VARS+BOOT_PCI_DATA+1] cmp ah, [BOOT.pci_data+1]
jbe .loop jbe .loop
.nomemory: .nomemory:
leave leave

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -229,7 +229,7 @@ CDDataBuf equ (OS_BASE+0x0005000)
;unused 0x6000 - 0x8fff ;unused 0x6000 - 0x8fff
BOOT_VARS equ (OS_BASE) ;0x9000 BOOT_VARS equ 0x9000
idts equ (OS_BASE+0x000B100) idts equ (OS_BASE+0x000B100)
WIN_STACK equ (OS_BASE+0x000C000) WIN_STACK equ (OS_BASE+0x000C000)
@ -334,41 +334,6 @@ PAT_TYPE_UCM equ 7
PAT_VALUE equ 0x00070106; (UC<<24)|(UCM<<16)|(WC<<8)|WB PAT_VALUE equ 0x00070106; (UC<<24)|(UCM<<16)|(WC<<8)|WB
;;;;;;;;;;;boot time variables
BOOT_BPP equ 0x9000 ;byte bits per pixel
BOOT_PITCH equ 0x9001 ;word scanline length
BOOT_VESA_MODE equ 0x9008 ;word vesa video mode
BOOT_X_RES equ 0x900A ;word X res
BOOT_Y_RES equ 0x900C ;word Y res
BOOT_BANK_SW equ 0x9014 ;dword Vesa 1.2 pm bank switch
BOOT_LFB equ 0x9018 ;dword Vesa 2.0 LFB address
BOOT_MTRR equ 0x901C ;byte 0 or 1 : enable MTRR graphics acceleration
BOOT_LAUNCHER_START equ 0x901D ;byte (0 or 1) start the first app (right now it's LAUNCHER) after kernel is loaded?
BOOT_DEBUG_PRINT equ 0x901E ;byte If nonzero, duplicates debug output to the screen.
BOOT_DMA equ 0x901F ;byte DMA write : 1=yes, 2=no
BOOT_PCI_DATA equ 0x9020 ;8bytes pci data
BOOT_SHUTDOWN_TYPE equ 0x9030 ;byte shutdown type (see sysfn 18.9)
BOOT_MEM_AMOUNT equ 0x9034 ;dword memory amount
BOOT_APM_ENTRY equ 0x9040
BOOT_APM_VERSION equ 0x9044
BOOT_APM_FLAGS equ 0x9046
BOOT_APM_CODE_32 equ 0x9050
BOOT_APM_CODE_16 equ 0x9052
BOOT_APM_DATA_16 equ 0x9054
BOOT_DEV equ 0x9056 ; byte
BOOT_KERNEL_RESTART equ 0x9058 ; word
BOOT_BX_FROM_LOAD equ 0x905A ; word
; low byte: a,b,c,d -- hdX, r -- rdX
; high byte: symbol 'X' as in the line above, e.g. '1', not 1
; see loader_doc.txt for details
BOOT_ACPI_RSDP equ 0x905C ; dword
BOOT_BIOS_HD_CNT equ 0x907F ; byte number of BIOS hard disks
BOOT_BIOS_HD equ 0x9080 ; Nbytes BIOS hard disks
BOOT_MEMMAP_BLOCK_CNT equ 0x9100 ; word available physical memory map: number of blocks
BOOT_MEMMAP_BLOCKS equ 0x9104 ; available physical memory map: blocks, i.e. e820entry structs
MAX_MEMMAP_BLOCKS equ 32 MAX_MEMMAP_BLOCKS equ 32
TMP_FILE_NAME equ 0 TMP_FILE_NAME equ 0
@ -705,39 +670,67 @@ struct HDLL
parent dd ? ;DLLDESCR parent dd ? ;DLLDESCR
ends ends
struct DQ
struct BOOT_DATA lo dd ?
bpp dd ? hi dd ?
scanline dd ?
vesa_mode dd ?
x_res dd ?
y_res dd ?
mouse_port dd ?
bank_switch dd ?
lfb dd ?
vesa_mem dd ?
log dd ?
direct_lfb dd ?
pci_data dd ?
dd ?
ide_base dd ?
mem_amount dd ?
pages_count dd ?
pagemap_size dd ?
kernel_max dd ?
kernel_pages dd ?
kernel_tables dd ?
cpu_vendor dd ?
dd ?
dd ?
cpu_sign dd ?
cpu_info dd ?
cpu_caps dd ?
dd ?
dd ?
ends ends
struct e820entry
addr DQ ?
size DQ ?
type dd ?
ends
struct boot_data
bpp db ? ; bits per pixel
pitch dw ? ; scanline length
db ?
dd ?
vesa_mode dw ?
x_res dw ?
y_res dw ?
dw ?
dd ?
bank_switch dd ? ; Vesa 1.2 pm bank switch
lfb dd ? ; Vesa 2.0 LFB address
mtrr db ? ; 0 or 1: enable MTRR graphics acceleration
launcher_start db ? ; 0 or 1: start the first app (right now it's LAUNCHER) after kernel is loaded
debug_print db ? ; if nonzero, duplicates debug output to the screen
dma db ? ; DMA write: 1=yes, 2=no
pci_data rb 8
rb 8
shutdown_type db ? ; see sysfn 18.9
rb 15
apm_entry dd ? ; entry point of APM BIOS
apm_version dw ? ; BCD
apm_flags dw ?
rb 8
apm_code_32 dw ?
apm_code_16 dw ?
apm_data_16 dw ?
dev db ?
db ?
kernel_restart dw ?
bx_from_load dw ?
; low byte: a,b,c,d -- hdX, r -- rdX
; high byte: symbol 'X' as in the line above, e.g. '1', not 1
; see loader_doc.txt for details
acpi_rsdp dd ?
rb 0x1f
bios_hd_cnt db ? ; number of BIOS hard disks
bios_hd rb 0x80 ; BIOS hard disks
memmap_block_cnt dd ? ; available physical memory map: number of blocks
memmap_blocks e820entry
rb sizeof.e820entry * (MAX_MEMMAP_BLOCKS - 1)
ends
virtual at BOOT_VARS
BOOT_LO boot_data
end virtual
virtual at OS_BASE + BOOT_VARS
BOOT boot_data
end virtual
struct display_t struct display_t
x dd ? x dd ?
y dd ? y dd ?
@ -972,14 +965,3 @@ struct IRQH
num_ints dd ? ;how many times handled num_ints dd ? ;how many times handled
ends ends
struct DQ
lo dd ?
hi dd ?
ends
struct e820entry
addr DQ ?
size DQ ?
type dd ?
ends

View File

@ -1336,7 +1336,7 @@ endp
align 4 align 4
proc print_mem proc print_mem
mov edi, BOOT_VAR + BOOT_MEMMAP_BLOCKS mov edi, BOOT.memmap_blocks
mov ecx, [edi-4] mov ecx, [edi-4]
test ecx, ecx test ecx, ecx
jz .done jz .done

View File

@ -10,7 +10,7 @@ $Revision$
; Initializes MTRRs. ; Initializes MTRRs.
proc init_mtrr proc init_mtrr
cmp [BOOT_VARS+BOOT_MTRR], byte 2 cmp [BOOT.mtrr], byte 2
je .exit je .exit
bt [cpu_caps], CAPS_MTRR bt [cpu_caps], CAPS_MTRR

View File

@ -112,13 +112,18 @@ macro movi r,i
include '../kglobals.inc' include '../kglobals.inc'
CAPS_MTRR equ 12 CAPS_MTRR equ 12
MSR_MTRR_DEF_TYPE equ 0x2FF
CAPS_PGE equ 13
CAPS_PAT equ 16
MSR_CR_PAT equ 0x277
PAT_VALUE equ 0x00070106 ; (UC<<24)|(UCM<<16)|(WC<<8)|WB
MEM_WB equ 6 ;write-back memory MEM_WB equ 6 ;write-back memory
MEM_WC equ 1 ;write combined memory MEM_WC equ 1 ;write combined memory
MEM_UC equ 0 ;uncached memory MEM_UC equ 0 ;uncached memory
include 'mtrr.inc' include 'mtrr.inc'
BOOT_VARS = 0 BOOT_VARS = 0
BOOT_MTRR db 1 BOOT.mtrr db 1
align 4 align 4
cpu_caps dd 1 shl CAPS_MTRR cpu_caps dd 1 shl CAPS_MTRR
LFBAddress dd 0xE0000000 LFBAddress dd 0xE0000000

View File

@ -15,7 +15,7 @@ $Revision$
xor cx, cx xor cx, cx
mov es, cx mov es, cx
mov di, BOOT_BIOS_HD mov di, BOOT_LO.bios_hd
mov byte [es:di-1], cl mov byte [es:di-1], cl
cmp [preboot_biosdisk], 1 cmp [preboot_biosdisk], 1
jnz bdde jnz bdde
@ -62,7 +62,7 @@ bdds:
jb .noide jb .noide
cmp word [es:si+1Ah], 0xFFFF cmp word [es:si+1Ah], 0xFFFF
jz .noide jz .noide
inc byte [es:BOOT_BIOS_HD_CNT] inc byte [es:BOOT_LO.bios_hd_cnt]
mov al, dl mov al, dl
stosb stosb
push ds push ds
@ -95,7 +95,7 @@ bdds:
cmp byte [es:si+2Ah], 'B' cmp byte [es:si+2Ah], 'B'
jz bddc2 jz bddc2
.nousb: .nousb:
inc byte [es:BOOT_BIOS_HD_CNT] inc byte [es:BOOT_LO.bios_hd_cnt]
mov al, dl mov al, dl
stosb stosb
xor ax, ax xor ax, ax

View File

@ -17,8 +17,8 @@ $Revision$
xor ebx, ebx xor ebx, ebx
mov es, bx mov es, bx
mov ds, bx mov ds, bx
mov di, BOOT_MEMMAP_BLOCKS mov di, BOOT_LO.memmap_blocks
mov [BOOT_MEMMAP_BLOCK_CNT], ebx ; no blocks yet mov [BOOT_LO.memmap_block_cnt], ebx ; no blocks yet
mov ecx, 20 mov ecx, 20
mov edx, 'PAMS' ; 'SMAP' mov edx, 'PAMS' ; 'SMAP'
int 15h int 15h
@ -28,13 +28,13 @@ $Revision$
e820_mem_loop: e820_mem_loop:
; cmp byte [di+16], 1 ; ignore non-free areas ; cmp byte [di+16], 1 ; ignore non-free areas
; jnz e820_mem_next ; jnz e820_mem_next
inc byte [BOOT_MEMMAP_BLOCK_CNT] inc byte [BOOT_LO.memmap_block_cnt]
add di, sizeof.e820entry add di, sizeof.e820entry
e820_mem_next: e820_mem_next:
; consequent calls to fn E820 ; consequent calls to fn E820
test ebx, ebx test ebx, ebx
jz e820_test_done jz e820_test_done
cmp byte [BOOT_MEMMAP_BLOCK_CNT], MAX_MEMMAP_BLOCKS cmp byte [BOOT_LO.memmap_block_cnt], MAX_MEMMAP_BLOCKS
jz e820_test_done jz e820_test_done
mov eax, 0xE820 mov eax, 0xE820
int 15h int 15h

View File

@ -28,7 +28,7 @@ proc Parser_params
locals locals
buff rb 4 ; for test cd buff rb 4 ; for test cd
endl endl
mov ax, [OS_BASE+BOOT_BX_FROM_LOAD] mov ax, [BOOT.bx_from_load]
mov ecx, sysdir_path mov ecx, sysdir_path
mov [ecx-64], dword 'sys' mov [ecx-64], dword 'sys'
mov [ecx-2], byte 3 mov [ecx-2], byte 3

View File

@ -15,7 +15,7 @@ MEM_UC equ 0 ;uncached memory
align 4 align 4
proc mem_test proc mem_test
; if we have BIOS with fn E820, skip the test ; if we have BIOS with fn E820, skip the test
cmp dword [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCK_CNT], 0 cmp dword [BOOT_LO.memmap_block_cnt], 0
jnz .ret jnz .ret
mov eax, cr0 mov eax, cr0
@ -35,14 +35,14 @@ proc mem_test
and eax, not (CR0_CD+CR0_NW) ;enable caching and eax, not (CR0_CD+CR0_NW) ;enable caching
mov cr0, eax mov cr0, eax
inc dword [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCK_CNT] inc dword [BOOT_LO.memmap_block_cnt]
xor eax, eax xor eax, eax
mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.addr.lo], eax mov [BOOT_LO.memmap_blocks + e820entry.addr.lo], eax
mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.addr.hi], eax mov [BOOT_LO.memmap_blocks + e820entry.addr.hi], eax
mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.size.lo], edi mov [BOOT_LO.memmap_blocks + e820entry.size.lo], edi
mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.size.hi], eax mov [BOOT_LO.memmap_blocks + e820entry.size.hi], eax
inc eax inc eax
mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.type], eax mov [BOOT_LO.memmap_blocks + e820entry.type], eax
.ret: .ret:
ret ret
endp endp
@ -50,7 +50,7 @@ endp
align 4 align 4
proc init_mem proc init_mem
; calculate maximum allocatable address and number of allocatable pages ; calculate maximum allocatable address and number of allocatable pages
mov edi, BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS mov edi, BOOT_LO.memmap_blocks
mov ecx, [edi-4] mov ecx, [edi-4]
xor esi, esi; esi will hold total amount of memory xor esi, esi; esi will hold total amount of memory
xor edx, edx; edx will hold maximum allocatable address xor edx, edx; edx will hold maximum allocatable address
@ -197,7 +197,7 @@ proc init_page_map
rep stosd rep stosd
; scan through memory map and mark free areas as available ; scan through memory map and mark free areas as available
mov ebx, BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS mov ebx, BOOT_LO.memmap_blocks
mov edx, [ebx-4] mov edx, [ebx-4]
.scanmap: .scanmap:
cmp [ebx+16], byte 1 cmp [ebx+16], byte 1
@ -459,7 +459,7 @@ acpi_locate:
if defined UEFI if defined UEFI
; UEFI loader knows where RSDP is ; UEFI loader knows where RSDP is
mov ebx, [BOOT_ACPI_RSDP] mov ebx, [BOOT_LO.acpi_rsdp]
test ebx, ebx test ebx, ebx
jz .done jz .done
call .check call .check

View File

@ -333,13 +333,13 @@ high_code:
; --------------- APM --------------------- ; --------------- APM ---------------------
; init selectors ; init selectors
mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point mov ebx, [BOOT.apm_entry] ; offset of APM entry point
movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of movzx eax, word [BOOT.apm_code_32] ; real-mode segment base address of
; protected-mode 32-bit code segment ; protected-mode 32-bit code segment
movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of movzx ecx, word [BOOT.apm_code_16] ; real-mode segment base address of
; protected-mode 16-bit code segment ; protected-mode 16-bit code segment
movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of movzx edx, word [BOOT.apm_data_16] ; real-mode segment base address of
; protected-mode 16-bit data segment ; protected-mode 16-bit data segment
shl eax, 4 shl eax, 4
mov [dword apm_code_32 + 2], ax mov [dword apm_code_32 + 2], ax
@ -359,19 +359,19 @@ high_code:
mov dword[apm_entry], ebx mov dword[apm_entry], ebx
mov word [apm_entry + 4], apm_code_32 - gdts mov word [apm_entry + 4], apm_code_32 - gdts
mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags mov eax, dword[BOOT.apm_version] ; version & flags
mov [apm_vf], eax mov [apm_vf], eax
; ----------------------------------------- ; -----------------------------------------
mov al, [BOOT_VARS+BOOT_DMA] ; DMA access mov al, [BOOT.dma] ; DMA access
mov [allow_dma_access], al mov [allow_dma_access], al
mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen mov al, [BOOT.debug_print] ; If nonzero, duplicates debug output to the screen
mov [debug_direct_print], al mov [debug_direct_print], al
mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? mov al, [BOOT.launcher_start] ; Start the first app (LAUNCHER) after kernel is loaded?
mov [launcher_start], al mov [launcher_start], al
mov esi, BOOT_VARS+BOOT_BIOS_HD mov esi, BOOT.bios_hd
movzx ecx, byte [esi-1] movzx ecx, byte [esi-1]
mov [NumBiosDisks], ecx mov [NumBiosDisks], ecx
mov edi, BiosDisksData mov edi, BiosDisksData
@ -694,7 +694,7 @@ endg
call PIT_init call PIT_init
; Register ramdisk file system ; Register ramdisk file system
cmp byte [BOOT_DEV+OS_BASE+0x10000], 1 cmp byte [BOOT.dev+0x10000], 1
je @f je @f
call register_ramdisk call register_ramdisk
@ -785,7 +785,7 @@ include 'detect/dev_fd.inc'
include 'detect/init_ata.inc' include 'detect/init_ata.inc'
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
if 0 if 0
mov ax, [OS_BASE+BOOT_BX_FROM_LOAD] mov ax, [BOOT.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
@ -1294,10 +1294,10 @@ set_variables:
loop .fl60 loop .fl60
push eax push eax
mov ax, [BOOT_VARS+BOOT_Y_RES] mov ax, [BOOT.y_res]
shr ax, 1 shr ax, 1
shl eax, 16 shl eax, 16
mov ax, [BOOT_VARS+BOOT_X_RES] mov ax, [BOOT.x_res]
shr ax, 1 shr ax, 1
mov [MOUSE_X], eax mov [MOUSE_X], eax
call wakeup_osloop call wakeup_osloop
@ -2117,7 +2117,7 @@ sysfn_shutdown: ; 18.9 = system shutdown
jl exit_for_anyone jl exit_for_anyone
cmp ecx, SYSTEM_RESTART cmp ecx, SYSTEM_RESTART
jg exit_for_anyone jg exit_for_anyone
mov [BOOT_VARS+BOOT_SHUTDOWN_TYPE], cl mov [BOOT.shutdown_type], cl
mov eax, [TASK_COUNT] mov eax, [TASK_COUNT]
mov [SYS_SHUTDOWN], al mov [SYS_SHUTDOWN], al

View File

@ -9,6 +9,7 @@
; ;
; Boot: ; Boot:
; ;
; BOOT_LO / boot_data structure
; 0:9000 byte bits per pixel ; 0:9000 byte bits per pixel
; 0:9001 word scanline length ; 0:9001 word scanline length
; 0:9008 word vesa video mode ; 0:9008 word vesa video mode

View File

@ -40,37 +40,37 @@ align 4
init_video: init_video:
mov ebp, bios_fb mov ebp, bios_fb
movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp movzx eax, byte [BOOT.bpp] ; bpp
mov [_display.bits_per_pixel], eax mov [_display.bits_per_pixel], eax
mov [_display.vrefresh], 60 mov [_display.vrefresh], 60
movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max movzx eax, word [BOOT.x_res]; X max
mov [_display.width], eax mov [_display.width], eax
mov [ebp+FRB.width], eax mov [ebp+FRB.width], eax
mov [display_width_standard], eax mov [display_width_standard], eax
dec eax dec eax
mov [screen_workarea.right], eax mov [screen_workarea.right], eax
movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max movzx eax, word [BOOT.y_res]; Y max
mov [_display.height], eax mov [_display.height], eax
mov [ebp+FRB.height], eax mov [ebp+FRB.height], eax
mov [display_height_standard], eax mov [display_height_standard], eax
dec eax dec eax
mov [screen_workarea.bottom], eax mov [screen_workarea.bottom], eax
movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode movzx eax, word [BOOT.vesa_mode] ; screen mode
mov dword [SCR_MODE], eax mov dword [SCR_MODE], eax
mov eax, 640 *4 ; Bytes PerScanLine mov eax, 640 *4 ; Bytes PerScanLine
cmp [SCR_MODE], word 0x13 ; 320x200 cmp [SCR_MODE], word 0x13 ; 320x200
je @f je @f
cmp [SCR_MODE], word 0x12 ; VGA 640x480 cmp [SCR_MODE], word 0x12 ; VGA 640x480
je @f je @f
movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes movzx eax, word[BOOT.pitch] ; for other modes
@@: @@:
mov [_display.lfb_pitch], eax mov [_display.lfb_pitch], eax
mov [ebp+FRB.pitch], eax mov [ebp+FRB.pitch], eax
mov eax, [BOOT_VARS+BOOT_LFB] mov eax, [BOOT.lfb]
mov [LFBAddress], eax mov [LFBAddress], eax
mov eax, [_display.width] mov eax, [_display.width]
@ -179,7 +179,7 @@ init_video:
jmp .ok jmp .ok
.fake: .fake:
mov [BOOT_VARS+BOOT_MTRR], byte 2 mov [BOOT.mtrr], byte 2
stdcall alloc_kernel_space, 0x1000 stdcall alloc_kernel_space, 0x1000
push eax ;store in stack for subsequent push eax ;store in stack for subsequent