Add extended_primary_loader to autobuild.

* Build fat1x, fat32, cdfs, after_win loaders.
* Set use_lba=1 by default in fat32 loader.
* Build kolibri.raw: flash / hdd image.
* Add example config.ini file.
* Add an option (config file and screen) to not load ramdisk image.
* Add an option (config file only) to set /sys path.

Now you can boot without a ramdisk from a storage that is supported
by the kernel itself, i.e. without loadable drivers. Thus you can not
load the system without a ramdisk from SATA/AHCI and USB drives.

git-svn-id: svn://kolibrios.org@8091 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2020-10-04 16:53:59 +00:00
parent 02edd3949b
commit f5e0f96e84
22 changed files with 171 additions and 43 deletions

View File

@ -790,7 +790,6 @@ end
-- generate tup rule for kolibri.img
tup.definerule{inputs = input_deps, command = make_img_command, outputs = output_deps}
tup.definerule{inputs = {"../kernel/trunk/boot/uefi4kos.asm", "kolibri.img", "../kernel/trunk/kernel.bin"}, command = "fasm ../kernel/trunk/boot/uefi4kos.asm %o", outputs = {"kolibri.efi"}}
-- generate command and dependencies for mkisofs
input_deps = {"kolibri.img"}
@ -822,3 +821,40 @@ for i,v in ipairs(distr_extra_files) do
else tup.definerule{inputs = {v.group or v[2]}, command = cmd, outputs = {"distribution_kit/" .. v[1]}}
end
end
-- generate tup rule for kolibri.efi
tup.definerule{inputs = {"../kernel/trunk/boot/uefi4kos.asm", "kolibri.img", "../kernel/trunk/kernel.bin.ext_loader"},
command = "fasm -dUEFI=1 -dextended_primary_loader=1 ../kernel/trunk/boot/uefi4kos.asm %o",
outputs = {"kolibri.efi"}}
input_deps = {"kolibri.img", "../kernel/trunk/bootloader/extended_primary_loader/fat32/kordldr.f32.bin", "../kernel/trunk/bootloader/extended_primary_loader/fat32/bootsect.bin", "../kernel/trunk/kernel.mnt.ext_loader"}
make_raw_command = '^ MKIMG kolibri.raw^ ' -- for tup: don't write full command to logs
make_raw_command = make_raw_command .. "dd if=/dev/zero of=kolibri.raw bs=1048576 count=64 2>&1"
make_raw_command = make_raw_command .. " && parted --script kolibri.raw mktable msdos"
make_raw_command = make_raw_command .. " && parted --script kolibri.raw unit MiB mkpart primary fat32 1 100%%"
make_raw_command = make_raw_command .. " && parted --script kolibri.raw set 1 boot on"
bootsector = "../kernel/trunk/bootloader/extended_primary_loader/fat32/bootsect.bin"
make_raw_command = make_raw_command .. " && mformat -i kolibri.raw@@1M -v KOLIBRIOS -T 129024 -h 16 -s 32 -H 2048 -c 1 -F -B " .. bootsector .. " ::"
make_raw_command = make_raw_command .. " && mcopy -moi kolibri.raw@@1M ../kernel/trunk/kernel.mnt.ext_loader ::KERNEL.MNT"
make_raw_command = make_raw_command .. " && mcopy -moi kolibri.raw@@1M kolibri.img ::KOLIBRI.IMG"
make_raw_command = make_raw_command .. " && mcopy -moi kolibri.raw@@1M ../kernel/trunk/bootloader/extended_primary_loader/fat32/kordldr.f32.bin ::KORDLDR.F32"
make_raw_command = make_raw_command .. " && mcopy -moi kolibri.raw@@1M ../kernel/trunk/bootloader/extended_primary_loader/config.ini ::CONFIG.INI"
make_raw_command = make_raw_command .. ' && mmd -i kolibri.raw@@1M ::KOLIBRIOS'
-- make folders
table.sort(img_dirs)
for i,v in ipairs(img_dirs) do
if v ~= img_dirs[i-1] then
make_raw_command = make_raw_command .. ' && mmd -i kolibri.raw@@1M "::KOLIBRIOS/' .. v .. '"'
end
end
for i,v in ipairs(img_files) do
local_file = v[2]
make_raw_command = make_raw_command .. ' && mcopy -moi kolibri.raw@@1M "' .. local_file .. '" "::KOLIBRIOS/' .. v[1] .. '"'
end
-- generate tup rule for kolibri.raw
tup.definerule{inputs = input_deps, command = make_raw_command, outputs = {"kolibri.raw"}}

View File

@ -1,5 +1,7 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("echo lang fix " .. ((tup.getconfig("LANG") == "") and "en" or tup.getconfig("LANG")) .. " > %o", {"lang.inc"})
tup.rule({"bootbios.asm", extra_inputs = {"lang.inc"}}, "fasm %f %o ", "bootbios.bin")
tup.rule({"bootbios.asm", extra_inputs = {"lang.inc"}}, "fasm %f %o -dextended_primary_loader=1", "bootbios.bin.ext_loader")
tup.rule({"kernel.asm", extra_inputs = {"bootbios.bin", "lang.inc"}}, "fasm -m 65536 %f %o " .. tup.getconfig("KERPACK_CMD"), "kernel.mnt")
tup.rule({"kernel.asm", extra_inputs = {"lang.inc"}}, "fasm -m 65536 %f %o -dUEFI=1", "kernel.bin")
tup.rule({"kernel.asm", extra_inputs = {"bootbios.bin.ext_loader", "lang.inc"}}, "fasm -m 65536 %f %o -dextended_primary_loader=1" .. tup.getconfig("KERPACK_CMD"), "kernel.mnt.ext_loader")
tup.rule({"kernel.asm", extra_inputs = {"lang.inc"}}, "fasm -m 65536 %f %o -dUEFI=1 -dextended_primary_loader=1", "kernel.bin.ext_loader")

View File

@ -667,7 +667,7 @@ end if
jnz .show_remarks
; e) preboot_device = from where to boot?
if defined extended_primary_loader
_ask_question bdev,'12',preboot_device ; range accepted for answer: 1-2
_ask_question bdev,'13',preboot_device ; range accepted for answer: 1-3
else
_ask_question bdev,'14',preboot_device ; range accepted for answer: 1-4
end if
@ -970,9 +970,25 @@ end if
; BOOT DEVICE
mov al, [preboot_device]
dec al
if defined extended_primary_loader
cmp al, RD_LOAD_FROM_MEMORY
jnz @f
mov al, RD_LOAD_FROM_NONE
@@:
end if
mov [es:BOOT_LO.rd_load_from], al
; /sys path
mov eax, dword[preboot_syspath+0]
mov dword[es:BOOT_LO.syspath+0], eax
mov eax, dword[preboot_syspath+4]
mov dword[es:BOOT_LO.syspath+4], eax
mov eax, dword[preboot_syspath+8]
mov dword[es:BOOT_LO.syspath+8], eax
mov eax, dword[preboot_syspath+12]
mov dword[es:BOOT_LO.syspath+12], eax
; GET MEMORY MAP
include '../detect/biosmem.inc'

View File

@ -27,10 +27,10 @@ s_vesa db "Version of VESA: "
gr_mode db "Select a videomode: ",13,10,0
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
if defined extended_primary_loader
bdev db "Load ramdisk from [1-floppy; 2-kolibri.img]: ",0
bdev db "Load ramdisk from [1-floppy; 2-kolibri.img; 3-don't load]: ",0
else
bdev db "Load ramdisk from [1-floppy; 2-C:\kolibri.img (FAT32);"
db 13,10,186," "
@ -75,9 +75,10 @@ ask_launcher db "Start first application (LAUNCHER) after kernel is loaded? [1
preboot_device_msg db " [e] Floppy image: ",0
if defined extended_primary_loader
preboot_device_msgs dw 0,pdm1,pdm2,0
preboot_device_msgs dw 0,pdm1,pdm2,pdm3,0
pdm1 db "real floppy",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "do not use floppy image",13,10,0
else
preboot_device_msgs dw 0,pdm1,pdm2,pdm3,pdm4,0
pdm1 db "real floppy",13,10,0

View File

@ -30,7 +30,8 @@ gr_mode cp866 "Выберите видеорежим: ",13,10,0
ask_bd cp866 "Добавить диски, видимые через BIOS в режиме V86? [1-да, 2-нет]: ",0
if defined extended_primary_loader
bdev cp866 "Загрузить образ из [1-дискета; 2-kolibri.img из папки загрузки]: ",0
bdev cp866 "Загрузить образ из [1-дискета; 2-kolibri.img из папки загрузки;",13,10
cp866 "║ 3-не загружать]: ",0
else
bdev cp866 "Загрузить образ из [1-дискета; 2-C:\kolibri.img (FAT32);",13,10
cp866 "║ 3-использовать уже загруженный образ;",13,10
@ -73,9 +74,10 @@ ask_launcher cp866 "Запустить первую программу (LAUNC
preboot_device_msg cp866 " [e] Образ дискеты: ",0
if defined extended_primary_loader
preboot_device_msgs dw 0,pdm1,pdm2,0
preboot_device_msgs dw 0,pdm1,pdm2,pdm3,0
pdm1 cp866 "настоящая дискета",13,10,0
pdm2 cp866 "kolibri.img из папки загрузки",13,10,0
pdm3 cp866 "не загружать образ рамдиска",13,10,0
else
preboot_device_msgs dw 0,pdm1,pdm2,pdm3,pdm4,0
pdm1 cp866 "настоящая дискета",13,10,0

View File

@ -74,12 +74,25 @@ parse_imgfrom:
jc .nothing
cmp al, 1
jb .nothing
cmp al, 2
cmp al, 3
ja .nothing
mov [es:preboot_device], al
.nothing:
ret
parse_syspath:
; everything except spaces
mov bx, preboot_syspath
.next_char:
call parse_char
jc .done
mov [es:bx], al
inc bx
jmp .next_char
.done:
mov byte[es:bx], 0 ; terminator
ret
parse_char:
; skip spaces and return the next character or CF if EOF.
cmp si, dx

View File

@ -27,9 +27,12 @@ preboot_debug db 0 ; load kernel in debug mode? (1-yes, 2-no)
preboot_launcher db 0 ; start launcher after kernel is loaded? (1-yes, 2-no)
preboot_dma db 0 ; use DMA for access to HDD (1-always, 2-only for read, 3-never)
preboot_device db 0 ; device to load ramdisk from
; 0-floppy 1-harddisk 2-kernel restart
; 3-format ram disk 4-don't use ramdisk
; 1-floppy 2-harddisk 3-kernel restart
; 4-format ram disk 5-don't use ramdisk
; !!!! 0 - autodetect !!!!
preboot_biosdisk db 0 ; use V86 to access disks through BIOS (1-yes, 2-no)
preboot_syspath db '/RD/1',0 ; path to /sys dir
rb 20-($-preboot_syspath)
if defined extended_primary_loader
; timeout in 1/18th of second for config settings screen
preboot_timeout dw PREBOOT_TIMEOUT*18

View File

@ -75,13 +75,6 @@ read_ramdisk:
call register_ramdisk
jmp yes_sys_on_hd
;-----------------------------------------------------------------------------
; Register ramdisk file system
register_ramdisk:
mov esi, boot_initramdisk
call boot_log
call ramdisk_init
ret
;-----------------------------------------------------------------------------
iglobal
align 4
read_image_fsinfo:

View File

@ -204,14 +204,14 @@ main:
cli
mov rsi, kernel_bin_data_begin
mov rsi, kernel_data_begin
mov rdi, KERNEL_BASE
mov rcx, (kernel_bin_data_end - kernel_bin_data_begin + 7) / 8
mov rcx, (kernel_data_end - kernel_data_begin + 7) / 8
rep movsq
mov rsi, kolibri_img_data_begin
mov rsi, ramdisk_data_begin
mov rdi, RAMDISK_BASE
mov rcx, (kolibri_img_data_end - kolibri_img_data_begin + 7 ) / 8
mov rcx, (ramdisk_data_end - ramdisk_data_begin + 7 ) / 8
rep movsq
xor esi, esi
@ -232,8 +232,10 @@ main:
mov word[esi + BOOT_LO.apm_code_16], 0
mov word[esi + BOOT_LO.apm_data_16], 0
mov byte[esi + BOOT_LO.bios_hd_cnt], 0
mov word[esi + BOOT_LO.sys_disk], 'r1' ; boot from /rd/1
mov rsi, syspath
mov rdi, BOOT_LO.syspath
mov ecx, 32
rep movsb
lgdt [cs:GDTR]
@ -428,17 +430,19 @@ msg_success du 'Success!',13,10,0
msg_error du 'Error!',13,10,0
msg du 79 dup ' ',13,10,0
syspath db '/RD/1',0
memory_map rb MEMORY_MAP_SIZE
gop_buffer rb GOP_BUFFER_SIZE
kernel_bin_data_begin:
file '../kernel.bin'
kernel_bin_data_end:
kernel_data_begin:
file '../kernel.bin.ext_loader'
kernel_data_end:
kolibri_img_data_begin:
ramdisk_data_begin:
file '../../../data/kolibri.img'
kolibri_img_data_end:
ramdisk_data_end:
align 16
data fixups

View File

@ -0,0 +1,2 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("kordldr.win.asm", "fasm %f %o", "kordldr.win.bin")

View File

@ -0,0 +1,2 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("bootsect.asm", "fasm %f %o ", "bootsect.bin")

View File

@ -50,7 +50,8 @@ real_start:
; get file system information
; scan for Primary Volume Descriptor
db 66h
movi eax, 10h-1
push 10h-1
pop eax
pvd_scan_loop:
mov cx, 1
inc eax

View File

@ -0,0 +1,15 @@
; boot time parameters for KolibriOS
; timeout in seconds for config settings screen
timeout=5
; width*height
resolution=1024*768
; where to load ramdisk from
; 2 - /hd0/1/kolibri.img
; 3 - don't load ramdisk
;imgfrom=3
; which directory to use as /sys
;syspath=/HD0/1/KOLIBRIOS

View File

@ -0,0 +1,3 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("bootsect.asm", "fasm %f %o", "bootsect.bin")
tup.rule("kordldr.f1x.asm", "fasm %f %o", "kordldr.f1x.bin")

View File

@ -0,0 +1,3 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("bootsect.asm", "fasm %f %o", "bootsect.bin")
tup.rule("kordldr.f32.asm", "fasm %f %o", "kordldr.f32.bin")

View File

@ -24,7 +24,7 @@
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;*****************************************************************************
use_lba = 0
use_lba = 1
org 0x7C00
jmp start
nop

View File

@ -683,11 +683,11 @@ struct e820entry
type dd ?
ends
RD_LOAD_FROM_FLOPPY = 0
RD_LOAD_FROM_HD = 1
RD_LOAD_FROM_MEMORY = 2
RD_LOAD_FROM_FORMAT = 3
RD_LOAD_FROM_NONE = 4
RD_LOAD_FROM_FLOPPY = 1
RD_LOAD_FROM_HD = 2
RD_LOAD_FROM_MEMORY = 3
RD_LOAD_FROM_FORMAT = 4
RD_LOAD_FROM_NONE = 5
struct boot_data
bpp db ? ; bits per pixel
@ -721,7 +721,7 @@ struct boot_data
kernel_restart dw ?
sys_disk dw ? ; Device to mount on /sys/, see loader_doc.txt for details
acpi_rsdp dd ?
rb 0x1f
syspath 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

View File

@ -77,6 +77,7 @@ config_file_variables:
config_variable 'vbemode', parse_vbemode
config_variable 'biosdisks', parse_biosdisks
config_variable 'imgfrom', parse_imgfrom
config_variable 'syspath', parse_syspath
dw 0
; data for image file loading, look in PrimaryLoader.txt
image_file_struct:

View File

@ -28,6 +28,16 @@ proc Parser_params
locals
buff rb 4 ; for test cd
endl
if defined extended_primary_loader
mov ecx, sysdir_path
mov [ecx-64], dword 'sys'
mov [ecx-2], byte 3
mov esi, BOOT.syspath
mov edi, sysdir_path-1
mov ecx, 20
rep movsb
ret
else
mov ax, [BOOT.sys_disk]
mov ecx, sysdir_path
mov [ecx-64], dword 'sys'
@ -61,6 +71,7 @@ proc Parser_params
jne .next_cd
@@:
ret
end if
.hard_disk:
sub al, '1'

View File

@ -138,7 +138,11 @@ pci_data_sel = pci_data_32-gdts
; places revision number there.
if ~ defined UEFI
bootbios:
file 'bootbios.bin'
if ~ defined extended_primary_loader
file 'bootbios.bin'
else
file 'bootbios.bin.ext_loader'
end if
if __REV__ > 0
cur_pos = 0
cnt = 0
@ -697,8 +701,10 @@ endg
call PIT_init
; Register ramdisk file system
if ~ defined extended_primary_loader
cmp [BOOT.rd_load_from], RD_LOAD_FROM_HD ; will be loaded later
je @f
end if
cmp [BOOT.rd_load_from], RD_LOAD_FROM_NONE
je @f
call register_ramdisk
@ -1099,6 +1105,14 @@ boot_log:
ret
;-----------------------------------------------------------------------------
; Register ramdisk file system
register_ramdisk:
mov esi, boot_initramdisk
call boot_log
call ramdisk_init
ret
; in: edx -> APPDATA for OS/IDLE slot
; in: ebx = stack base
proc setup_os_slot

View File

@ -48,3 +48,8 @@ biosdisks=<включить доступ к дискам через BIOS> - бу
imgfrom=<источник рамдиска>. 1 - грузить дискету, 2 - грузить файл
kolibri.img, находящийся рядом с первичным загрузчиком. Умолчальное
значение 1 при загрузке с дискеты и 2 в противном случае.
syspath=<путь к директории /sys> - строка.
Умолчальное значение /RD/1. Может быть и не корнем раздела, например
/HD0/1/KOLIBRIOS. Ядро должно уметь работать с носителем без подгружаемых
драйверов.

View File

@ -39,7 +39,8 @@
# CONFIG_KERPACK_CMD=&& kerpack %o
# CONFIG_PESTRIP_CMD=&& EXENAME=%o fasm $(ROOT)/data/common/pestrip.asm %o
### BUILD_TYPE, if set, enables building kolibri.img and kolibri.iso.
### BUILD_TYPE, if set, enables building kolibri.img, kolibri.iso and
### kolibri.raw.
### Must match subdirectory name in $(ROOT)/data.
### Requires Linux.
# CONFIG_BUILD_TYPE=eng