mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-10 13:25:25 +01:00
Complete the kernel bootstrap by adding kexec of Linux from Fiwix.
A tiny bootloader bootstrap has been added to compile the builder-hex0 kernel from hex0 source. The boot compiler is builder-hex0-x86-stage1.hex0 and builder-hex0-x86-stage1.bin. The builder-hex0 kernel is now named builder-hex0-x86-stage2.hex0. The inclusion of a binary seed resolves the problem with the previous strategy which used an architecture-specific hex0 compiler. If sysb detects a full disk (i.e. DISK=sda) it now partitions the disk unconditionally because previously fdisk was reporting existing but empty partitions which resulted in no parititions being created. e2fsprogs is now built with --disable-tls because musl was built on Fiwix without full threading support and mkfs.ext4 was crashing without disabling thread local storage. kexec-linux writes the linux kernel and initramfs to a RAM drive on Fiwix which ensure a pre-allocated contiguous memory block. The following is written to the ram drive: a 32-bit number which is the size of the kernel in bytes, a 32-bit number which is the size of the initramfs in bytes, followed by the Linux kernel image, followed by the initramfs. kexec-fiwix invokes a sync syscall to ensure all writes are flushed to the ram drive and then initiates the kexec by shutting down Fiwix with a reboot syscall. Fiwix knows whether and how to perform the kexec based on kernel parameters passed to it.
This commit is contained in:
parent
e86db47b6e
commit
a2fcf1ced9
23 changed files with 633 additions and 277 deletions
22
sysa.py
22
sysa.py
|
|
@ -193,12 +193,24 @@ class SysA(SysGeneral):
|
|||
|
||||
def create_builder_hex0_disk_image(self, image_file_name):
|
||||
"""Create builder-hex0 disk image"""
|
||||
run(os.path.join('sysa', 'stage0-posix', 'src',
|
||||
'bootstrap-seeds', 'POSIX', 'x86', 'hex0-seed'),
|
||||
os.path.join('kernel-bootstrap', 'builder-hex0-x86.hex0'),
|
||||
image_file_name)
|
||||
shutil.copyfile(os.path.join('kernel-bootstrap', 'builder-hex0-x86-stage1.bin'), image_file_name)
|
||||
|
||||
with open(image_file_name, 'ab') as image_file:
|
||||
current_size = os.stat(image_file_name).st_size
|
||||
while current_size != 510:
|
||||
image_file.write(b'\0')
|
||||
current_size += 1
|
||||
image_file.write(b'\x55')
|
||||
image_file.write(b'\xAA')
|
||||
|
||||
# Append stage2 hex0 source
|
||||
with open(os.path.join('kernel-bootstrap', 'builder-hex0-x86-stage2.hex0')) as infile:
|
||||
image_file.write(infile.read().encode())
|
||||
# Pad to next sector
|
||||
current_size = os.stat(image_file_name).st_size
|
||||
while current_size % 512 != 0:
|
||||
image_file.write(b'\0')
|
||||
current_size += 1
|
||||
self.append_srcfs(image_file)
|
||||
|
||||
current_size = os.stat(image_file_name).st_size
|
||||
|
|
@ -213,6 +225,6 @@ class SysA(SysGeneral):
|
|||
|
||||
# fill file with zeros up to desired size, one megabyte at a time
|
||||
with open(image_file_name, 'ab') as image_file:
|
||||
while current_size < 1008 * megabyte:
|
||||
while current_size < 16384 * megabyte:
|
||||
image_file.write(b'\0' * megabyte)
|
||||
current_size += megabyte
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue