From 09684c0db94e8bd44a8beb03862d81e4787e29ac Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Wed, 29 Nov 2017 22:03:58 +0000 Subject: [PATCH] Synchronize memmap.inc and const.inc, replace hardcoded numbers with macros. git-svn-id: svn://kolibrios.org@7122 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/boot/bootvesa.inc | 2 +- kernel/trunk/bus/pci/pci16.inc | 10 +++++----- kernel/trunk/bus/pci/pci32.inc | 18 ++++++++--------- kernel/trunk/const.inc | 33 ++++++++++++++++++++------------ kernel/trunk/core/dll.inc | 4 ++-- kernel/trunk/core/memory.inc | 2 +- kernel/trunk/detect/biosdisk.inc | 6 +++--- kernel/trunk/detect/biosmem.inc | 18 ++++++++--------- kernel/trunk/detect/vortex86.inc | 4 ++-- kernel/trunk/init.inc | 28 +++++++++++++-------------- kernel/trunk/kernel.asm | 6 +++--- kernel/trunk/memmap.inc | 15 ++++++++------- 12 files changed, 78 insertions(+), 68 deletions(-) diff --git a/kernel/trunk/boot/bootvesa.inc b/kernel/trunk/boot/bootvesa.inc index 72e4fbbee6..1c8d3a8c82 100644 --- a/kernel/trunk/boot/bootvesa.inc +++ b/kernel/trunk/boot/bootvesa.inc @@ -789,7 +789,7 @@ set_vmode: ; add eax, ebx ; push 0x0000 ; pop es -; mov [es:0x9014], eax +; mov [es:BOOT_BANK_SW], eax .exit: ret diff --git a/kernel/trunk/bus/pci/pci16.inc b/kernel/trunk/bus/pci/pci16.inc index fe6deed14d..e03ecf9266 100644 --- a/kernel/trunk/bus/pci/pci16.inc +++ b/kernel/trunk/bus/pci/pci16.inc @@ -24,15 +24,15 @@ init_pci_16: xor ax, ax mov es, ax - mov byte [es:0x9020], 1;default mechanism:1 + mov byte [es:BOOT_PCI_DATA], 1;default mechanism:1 mov ax, 0xb101 int 0x1a or ah, ah jnz pci16skip - mov [es:0x9021], cl;last PCI bus in system - mov [es:0x9022], bx - mov [es:0x9024], edi + mov [es:BOOT_PCI_DATA+1], cl;last PCI bus in system + mov [es:BOOT_PCI_DATA+2], bx + mov [es:BOOT_PCI_DATA+4], edi ; we have a PCI BIOS, so check which configuration mechanism(s) ; it supports @@ -41,7 +41,7 @@ init_pci_16: jnz pci16skip test al, 2 jz pci16skip - mov byte [es:0x9020], 2; if (al&3)==2 => mechanism 2 + mov byte [es:BOOT_PCI_DATA], 2; if (al&3)==2 => mechanism 2 pci16skip: diff --git a/kernel/trunk/bus/pci/pci32.inc b/kernel/trunk/bus/pci/pci32.inc index 7bd80c0858..5730d22b8c 100644 --- a/kernel/trunk/bus/pci/pci32.inc +++ b/kernel/trunk/bus/pci/pci32.inc @@ -101,17 +101,17 @@ pci_api_drv: pci_fn_0: ; PCI function 0: get pci version (AH.AL) - movzx eax, word [BOOT_VARS+0x9022] + movzx eax, word [BOOT_VARS+BOOT_PCI_DATA+2] ret pci_fn_1: ; PCI function 1: get last bus in AL - mov al, [BOOT_VARS+0x9021] + mov al, [BOOT_VARS+BOOT_PCI_DATA+1] ret pci_fn_2: ; PCI function 2: get pci access mechanism - mov al, [BOOT_VARS+0x9020] + mov al, [BOOT_VARS+BOOT_PCI_DATA] ret pci_service_not_supported: @@ -156,7 +156,7 @@ align 4 pci_read_reg: push ebx esi - cmp byte [BOOT_VARS+0x9020], 2;what mechanism will we use? + cmp byte [BOOT_VARS+BOOT_PCI_DATA], 2;what mechanism will we use? je pci_read_reg_2 ; mechanism 1 @@ -260,7 +260,7 @@ align 4 pci_write_reg: push esi ebx - cmp byte [BOOT_VARS+0x9020], 2;what mechanism will we use? + cmp byte [BOOT_VARS+BOOT_PCI_DATA], 2;what mechanism will we use? je pci_write_reg_2 ; mechanism 1 @@ -519,9 +519,9 @@ sys_pcibios: cmp ebp, 1 ; PCI_FUNCTION_ID jnz .not_PCI_BIOS_PRESENT mov edx, 'PCI ' - mov al, [BOOT_VARS + 0x9020] - mov bx, [BOOT_VARS + 0x9022] - mov cl, [BOOT_VARS + 0x9021] + mov al, [BOOT_VARS + BOOT_PCI_DATA] + mov bx, [BOOT_VARS + BOOT_PCI_DATA + 2] + mov cl, [BOOT_VARS + BOOT_PCI_DATA + 1] xor ah, ah jmp .return_abcd @@ -665,7 +665,7 @@ end virtual .next_func: inc dword [.devfn] mov ah, [.bus] - cmp ah, [BOOT_VARS+0x9021] + cmp ah, [BOOT_VARS+BOOT_PCI_DATA+1] jbe .loop .nomemory: leave diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index ca85a77097..765f122bf6 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -313,28 +313,25 @@ 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_LOG equ 0x901D ;byte not used anymore (0 or 1 : enable system log display) -BOOT_LAUNCHER_START equ 0x901D ;byte (0 or 1) start the first app (right now it's LAUNCHER) after kernel is loaded? -;BOOT_DIRECT_LFB equ 0x901E ;byte 0 or 1 : enable direct lfb write, paging disabled +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 ; +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_IDE_BASE_ADDR equ 0x9031 ;word IDEContrRegsBaseAddr ; now free and is not used BOOT_MEM_AMOUNT equ 0x9034 ;dword memory amount BOOT_APM_ENTRY equ 0x9040 BOOT_APM_VERSION equ 0x9044 -BOOT_APM_FLAGS equ 0x9046 ;unused +BOOT_APM_FLAGS equ 0x9046 BOOT_APM_CODE_32 equ 0x9050 BOOT_APM_CODE_16 equ 0x9052 BOOT_APM_DATA_16 equ 0x9054 -;BOOT_IDE_BAR0_16 equ 0x9056 ; now free and is not used -;BOOT_IDE_BAR1_16 equ 0x9058 ; now free and is not used -;BOOT_IDE_BAR2_16 equ 0x905A ; now free and is not used -;BOOT_IDE_BAR3_16 equ 0x905C ; now free and is not used -;BOOT_IDE_PI_16 equ 0x905E ; now free and is not used -;BOOT_IDE_INTERR_16 equ 0x9060 ; now free and is not used + +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 TMP_FILE_NAME equ 0 TMP_CMD_LINE equ 1024 @@ -936,3 +933,15 @@ struct IRQH data dd ? ;user-specific data num_ints dd ? ;how many times handled ends + +struct DQ + lo dd ? + hi dd ? +ends + +struct e820entry + addr DQ ? + size DQ ? + type dd ? +ends + diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 076af84b03..e737cb6b04 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -476,7 +476,7 @@ proc load_file stdcall, file_name:dword jne .cleanup mov eax, [file] - cmp dword [eax], 0x4B43504B + cmp dword [eax], 'KPCK' jne .exit mov ebx, [eax+4] mov [file_size], ebx @@ -583,7 +583,7 @@ proc load_file_umode stdcall, file_name:dword jne .err_2 mov eax, [km_file] - cmp dword [eax], 0x4B43504B ; check kpack signature + cmp dword [eax], 'KPCK' ; check kpack signature jne .raw_file mov ebx, [eax+4] ;get real size of file diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index f2d87cc7e4..a3a2632623 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -1336,7 +1336,7 @@ endp align 4 proc print_mem - mov edi, BOOT_VAR + 0x9104 + mov edi, BOOT_VAR + BOOT_MEMMAP_BLOCKS mov ecx, [edi-4] test ecx, ecx jz .done diff --git a/kernel/trunk/detect/biosdisk.inc b/kernel/trunk/detect/biosdisk.inc index 8005f698bb..201d354dc6 100644 --- a/kernel/trunk/detect/biosdisk.inc +++ b/kernel/trunk/detect/biosdisk.inc @@ -15,7 +15,7 @@ $Revision$ xor cx, cx mov es, cx - mov di, 0x9080 + mov di, BOOT_BIOS_HD mov byte [es:di-1], cl cmp [preboot_biosdisk], 1 jnz bdde @@ -62,7 +62,7 @@ bdds: jb .noide cmp word [es:si+1Ah], 0xFFFF jz .noide - inc byte [es:0x907F] + inc byte [es:BOOT_BIOS_HD_CNT] mov al, dl stosb push ds @@ -95,7 +95,7 @@ bdds: cmp byte [es:si+2Ah], 'B' jz bddc2 .nousb: - inc byte [es:0x907F] + inc byte [es:BOOT_BIOS_HD_CNT] mov al, dl stosb xor ax, ax diff --git a/kernel/trunk/detect/biosmem.inc b/kernel/trunk/detect/biosmem.inc index d214efe9b9..598b5ab797 100644 --- a/kernel/trunk/detect/biosmem.inc +++ b/kernel/trunk/detect/biosmem.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2009-2015. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2009-2017. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -17,25 +17,25 @@ $Revision$ xor ebx, ebx mov es, bx mov ds, bx - mov di, 0x9104 - mov [di-4], ebx ; no blocks yet + mov di, BOOT_MEMMAP_BLOCKS + mov [BOOT_MEMMAP_BLOCK_CNT], ebx ; no blocks yet mov ecx, 20 - mov edx, 0x534D4150 + mov edx, 'PAMS' ; 'SMAP' int 15h jc no_E820 - cmp eax, 0x534D4150 + cmp eax, 'PAMS' jnz no_E820 e820_mem_loop: ; cmp byte [di+16], 1 ; ignore non-free areas ; jnz e820_mem_next - inc byte [0x9100] - add di, 20 + inc byte [BOOT_MEMMAP_BLOCK_CNT] + add di, sizeof.e820entry e820_mem_next: ; consequent calls to fn E820 test ebx, ebx jz e820_test_done - cmp byte [0x9100], 32 - jae e820_test_done + cmp byte [BOOT_MEMMAP_BLOCK_CNT], MAX_MEMMAP_BLOCKS + jz e820_test_done mov eax, 0xE820 int 15h jc e820_test_done diff --git a/kernel/trunk/detect/vortex86.inc b/kernel/trunk/detect/vortex86.inc index 9c89db45b2..5dd751c008 100644 --- a/kernel/trunk/detect/vortex86.inc +++ b/kernel/trunk/detect/vortex86.inc @@ -12,7 +12,7 @@ $Revision$ VORTEX86DEBUG = 0 ; For testing in emulators and in non-Vortex86 CPU computers, set this to 1 -VORTEX86DEBUGVALUE = 0x35504d44 ; FAKE port output = used for testing +VORTEX86DEBUGVALUE = 'DMP5' ; FAKE port output = used for testing NORTH_BRIDGE = 0x80000000 ; Base address of Vortex86 PCI North Bridge SOUTH_BRIDGE = 0x80003800 ; Base address of Vortex86 PCI South Bridge @@ -155,4 +155,4 @@ end if .nullPCIoutput: ; Emulators and non-Vortex86 CPU computers will usually return \0 in this register DEBUGF 1, "0 (NULL)\n" -.Vortex86end: \ No newline at end of file +.Vortex86end: diff --git a/kernel/trunk/init.inc b/kernel/trunk/init.inc index 7ac92dfcc7..b3f70904d9 100644 --- a/kernel/trunk/init.inc +++ b/kernel/trunk/init.inc @@ -15,7 +15,7 @@ MEM_UC equ 0 ;uncached memory align 4 proc mem_test ; if we have BIOS with fn E820, skip the test - cmp dword [BOOT_VARS-OS_BASE + 0x9100], 0 + cmp dword [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCK_CNT], 0 jnz .ret mov eax, cr0 @@ -35,14 +35,14 @@ proc mem_test and eax, not (CR0_CD+CR0_NW) ;enable caching mov cr0, eax - inc dword [BOOT_VARS-OS_BASE + 0x9100] + inc dword [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCK_CNT] xor eax, eax - mov [BOOT_VARS-OS_BASE + 0x9104], eax - mov [BOOT_VARS-OS_BASE + 0x9108], eax - mov [BOOT_VARS-OS_BASE + 0x910C], edi - mov [BOOT_VARS-OS_BASE + 0x9110], eax + mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.addr.lo], eax + mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.addr.hi], eax + mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.size.lo], edi + mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.size.hi], eax inc eax - mov [BOOT_VARS-OS_BASE + 0x9114], eax + mov [BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS + e820entry.type], eax .ret: ret endp @@ -50,7 +50,7 @@ endp align 4 proc init_mem ; calculate maximum allocatable address and number of allocatable pages - mov edi, BOOT_VARS-OS_BASE + 0x9104 + mov edi, BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS mov ecx, [edi-4] xor esi, esi; esi will hold total amount of memory xor edx, edx; edx will hold maximum allocatable address @@ -197,7 +197,7 @@ proc init_page_map rep stosd ; scan through memory map and mark free areas as available - mov ebx, BOOT_VARS-OS_BASE + 0x9104 + mov ebx, BOOT_VARS-OS_BASE + BOOT_MEMMAP_BLOCKS mov edx, [ebx-4] .scanmap: cmp [ebx+16], byte 1 @@ -448,9 +448,9 @@ ACPI_HI_RSDP_WINDOW_START equ 0x000E0000 ACPI_HI_RSDP_WINDOW_END equ 0x00100000 ACPI_RSDP_CHECKSUM_LENGTH equ 20 -ACPI_HPET_SIGN equ 0x54455048 -ACPI_MADT_SIGN equ 0x43495041 -ACPI_FADT_SIGN equ 0x50434146 +ACPI_HPET_SIGN equ 'HPET' +ACPI_MADT_SIGN equ 'APIC' +ACPI_FADT_SIGN equ 'FACP' acpi_locate: @@ -477,9 +477,9 @@ acpi_locate: ret .check: - cmp [ebx], dword 0x20445352 + cmp [ebx], dword 'RSD ' jne .next - cmp [ebx+4], dword 0x20525450 + cmp [ebx+4], dword 'PTR ' jne .next mov edx, ebx diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 034c9c72e2..e1bb9edeba 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -447,7 +447,7 @@ high_code: mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? mov [launcher_start], al - mov esi, BOOT_VARS+0x9080 + mov esi, BOOT_VARS+BOOT_BIOS_HD movzx ecx, byte [esi-1] mov [NumBiosDisks], ecx mov edi, BiosDisksData @@ -2188,9 +2188,9 @@ sys_system: ret ;------------------------------------------------------------------------------ sysfn_shutdown: ; 18.9 = system shutdown - cmp ecx, 1 + cmp ecx, SYSTEM_SHUTDOWN jl exit_for_anyone - cmp ecx, 4 + cmp ecx, SYSTEM_RESTART jg exit_for_anyone mov [BOOT_VARS+BOOT_SHUTDOWN_TYPE], cl diff --git a/kernel/trunk/memmap.inc b/kernel/trunk/memmap.inc index 72a10365fa..bae6a23499 100644 --- a/kernel/trunk/memmap.inc +++ b/kernel/trunk/memmap.inc @@ -14,19 +14,20 @@ ; 0:9008 word vesa video mode ; 0:900A word X res ; 0:900C word Y res -; 0:9010 byte mouse port - not used ; 0:9014 dword Vesa 1.2 pm bank switch ; 0:9018 dword Vesa 2.0 LFB address ; 0:901C byte 0 or 1 : enable MTRR graphics acceleration -; 0:901D byte not used anymore (0 or 1 : enable system log display) -; 0:901E byte 0 or 1 : enable direct lfb write, paging disabled +; 0:901D byte (0 or 1) start the first app (right now it's LAUNCHER) after kernel is loaded? +; 0:901E byte If nonzero, duplicates debug output to the screen. ; 0:901F byte DMA write : 1=yes, 2=no ; 0:9020 8bytes pci data ; 0:9030 byte shutdown type (see sysfn 18.9) -; 0:9031 word IDEContrRegsBaseAddr -; 0x9040 - dword - entry point of APM BIOS -; 0x9044 - word - version (BCD) -; 0x9046 - word - flags +; 0:9040 dword entry point of APM BIOS +; 0:9044 word version (BCD) +; 0:9046 word flags +; 0:9050 word APM_CODE_32 +; 0:9052 word APM_CODE_16 +; 0:9054 word APM_DATA_16 ; 0:907F byte number of BIOS hard disks ; 0:9080 Nbytes BIOS hard disks ; 0:9100 word available physical memory map: number of blocks