diff --git a/.gitignore b/.gitignore index 538a99b..f90af77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ +# SPDX-FileCopyrightText: 2022 Andrius Štikonas # SPDX-License-Identifier: MIT *~ -*/build/ +build/ *.d *.lib *.efi diff --git a/.gitmodules b/.gitmodules index db3572e..7ebbad9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2022 Andrius Štikonas +# SPDX-License-Identifier: MIT + [submodule "bootstrap-seeds"] path = bootstrap-seeds url = https://github.com/oriansj/bootstrap-seeds/ diff --git a/Development/efi/boot_table.h b/Development/efi/boot_table.h index c70a248..4dbf765 100644 --- a/Development/efi/boot_table.h +++ b/Development/efi/boot_table.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_BOOT_TABLE_H__ diff --git a/Development/efi/device_path_protocol.h b/Development/efi/device_path_protocol.h index 36f8768..2e41a0b 100644 --- a/Development/efi/device_path_protocol.h +++ b/Development/efi/device_path_protocol.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_DEVICE_PATH_PROTOCOL_H__ diff --git a/Development/efi/efi.h b/Development/efi/efi.h index bab88c5..a7a5d93 100644 --- a/Development/efi/efi.h +++ b/Development/efi/efi.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_H__ diff --git a/Development/efi/file_protocol.h b/Development/efi/file_protocol.h index 93d1478..6dbde51 100644 --- a/Development/efi/file_protocol.h +++ b/Development/efi/file_protocol.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_FILE_PROTOCOL_H__ diff --git a/Development/efi/loaded_image_protocol.h b/Development/efi/loaded_image_protocol.h index 4d04315..c4c6431 100644 --- a/Development/efi/loaded_image_protocol.h +++ b/Development/efi/loaded_image_protocol.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_LOADED_IMAGE_PROTOCOL_H__ diff --git a/Development/efi/simple_file_system_protocol.h b/Development/efi/simple_file_system_protocol.h index dd77072..31b2f85 100644 --- a/Development/efi/simple_file_system_protocol.h +++ b/Development/efi/simple_file_system_protocol.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_H__ diff --git a/Development/efi/simple_text_output_protocol.h b/Development/efi/simple_text_output_protocol.h index 0169147..8ec3e18 100644 --- a/Development/efi/simple_text_output_protocol.h +++ b/Development/efi/simple_text_output_protocol.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_H__ diff --git a/Development/efi/system_table.h b/Development/efi/system_table.h index cd1d948..2cb1ec8 100644 --- a/Development/efi/system_table.h +++ b/Development/efi/system_table.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_SYSTEM_TABLE_H__ diff --git a/Development/efi/types.h b/Development/efi/types.h index b2c9176..f39fece 100644 --- a/Development/efi/types.h +++ b/Development/efi/types.h @@ -1,3 +1,4 @@ +/* SPDX-FileCopyrightText: Mike Krinkin */ /* SPDX-License-Identifier: Unlicense */ #ifndef __EFI_TYPES_H__ diff --git a/Development/rootfs/kaem.amd64 b/Development/rootfs/kaem.amd64 index 7d7ff06..8fe0a35 100644 --- a/Development/rootfs/kaem.amd64 +++ b/Development/rootfs/kaem.amd64 @@ -1,4 +1,6 @@ -# kaem +# SPDX-FileCopyrightText: 2022 Andrius Štikonas +# +# SPDX-License-Identifier: GPL-3.0-or-later # Rebuild hex0 EFI\BOOT\hex0.efi hex0_amd64.hex0 hex0.efi diff --git a/Development/rootfs/startup.nsh b/Development/rootfs/startup.nsh deleted file mode 100644 index 04b0d68..0000000 --- a/Development/rootfs/startup.nsh +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: Unlicense - -BOOTX64 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..65fc360 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +# SPDX-FileCopyrightText: 2022 Andrius Štikonas +# +# SPDX-License-Identifier: GPL-3.0-or-later + +targets = kaem-minimal hex0 +ESP_SIZE_MIB = 50 +QEMU = qemu-system-x86_64 +QEMU_KVM = -enable-kvm + +ifneq ($(wildcard /usr/share/OVMF/OVMF_CODE.fd),) + OVMF_IMG = /usr/share/OVMF/OVMF_CODE.fd +else + OVMF_IMG = /usr/share/edk2-ovmf/OVMF_CODE.fd +endif + +ESP_SIZE_SECTORS = $$(($(ESP_SIZE_MIB) * 2048)) +DISK_SIZE_SECTORS = $$(($(ESP_SIZE_SECTORS) + 2048 + 33)) + +build_dir = build +rootfs_dir = $(build_dir)/rootfs +boot_dir = $(rootfs_dir)/EFI/BOOT + +.PHONY : clean rootfs qemu + +qemu: $(build_dir)/disk.img $(OVMF_IMG) + $(QEMU) -cpu qemu64 -net none \ + $(QEMU_KVM) \ + -drive if=pflash,format=raw,unit=0,file=$(OVMF_IMG),readonly=on \ + -drive if=ide,format=raw,file=$< + +$(build_dir)/disk.img: $(build_dir)/esp.img + dd if=/dev/zero of=$@ bs=512 count=$(DISK_SIZE_SECTORS) + parted $@ -s -a minimal mklabel gpt + parted $@ -s -a minimal mkpart EFI FAT32 2048s $(ESP_SIZE_SECTORS)s + parted $@ -s -a minimal toggle 1 boot + dd if=$< of=$@ bs=512 seek=2048 conv=notrunc + +$(build_dir)/esp.img: rootfs + dd if=/dev/zero of=$@ bs=512 count=$(ESP_SIZE_SECTORS) + mformat -i $@ -h 32 -t 32 -n 64 -c 1 + mcopy -s -i $@ $(rootfs_dir)/* :: + +rootfs: + rm -rf $(rootfs_dir) + mkdir -p $(boot_dir) + rsync -av . $(rootfs_dir) --exclude $(build_dir) --exclude ".*" --exclude "Development/" --exclude "*/Development/" --exclude "bootstrap-seeds/" + + mkdir -p $(rootfs_dir)/bootstrap-seeds/UEFI/ + rsync -av bootstrap-seeds/UEFI/ $(rootfs_dir)/bootstrap-seeds/UEFI/ + mv $(rootfs_dir)/bootstrap-seeds/UEFI/amd64/kaem-optional-seed.efi $(boot_dir)/BOOTX64.efi + +clean: + rm -rf $(build_dir) diff --git a/amd64/Development/kaem-optional.M1 b/amd64/Development/kaem-minimal.M1 similarity index 100% rename from amd64/Development/kaem-optional.M1 rename to amd64/Development/kaem-minimal.M1 diff --git a/amd64/Development/kaem-optional.S b/amd64/Development/kaem-minimal.S similarity index 100% rename from amd64/Development/kaem-optional.S rename to amd64/Development/kaem-minimal.S diff --git a/amd64/Development/kaem-optional.hex2 b/amd64/Development/kaem-minimal.hex2 similarity index 100% rename from amd64/Development/kaem-optional.hex2 rename to amd64/Development/kaem-minimal.hex2 diff --git a/amd64/PE32-amd64.hex2 b/amd64/PE32-amd64.hex2 index 46f8f6b..8270401 100644 --- a/amd64/PE32-amd64.hex2 +++ b/amd64/PE32-amd64.hex2 @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2022 Jeremiah Orians +# +# SPDX-License-Identifier: GPL-3.0-or-later + # DOS MZ header 4D 5A # Signature 00 00 # Number of bytes in the last page. diff --git a/amd64/artifact/README b/amd64/artifact/README new file mode 100644 index 0000000..abbc25a --- /dev/null +++ b/amd64/artifact/README @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2022 Andrius Štikonas +# SPDX-License-Identifier: MIT + +This is a placeholder directory that will contain AMD64 bootstrap artifacts. diff --git a/amd64/kaem-optional.hex0 b/amd64/kaem-minimal.hex0 similarity index 100% rename from amd64/kaem-optional.hex0 rename to amd64/kaem-minimal.hex0 diff --git a/amd64/mescc-tools-mini-kaem.kaem b/amd64/mescc-tools-mini-kaem.kaem new file mode 100644 index 0000000..85c0587 --- /dev/null +++ b/amd64/mescc-tools-mini-kaem.kaem @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: 2022 Andrius Štikonas +# +# SPDX-License-Identifier: GPL-3.0-or-later + +################################# +# Phase-1 Build hex1 from hex0 # +################################# diff --git a/amd64/mescc-tools-seed-kaem.kaem b/amd64/mescc-tools-seed-kaem.kaem new file mode 100644 index 0000000..38219a9 --- /dev/null +++ b/amd64/mescc-tools-seed-kaem.kaem @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2022 Andrius Štikonas +# +# SPDX-License-Identifier: GPL-3.0-or-later + +############################################### +# Phase-0 Build hex0 from bootstrapped binary # +############################################### +bootstrap-seeds\UEFI\amd64\hex0-seed.efi amd64\hex0.hex0 amd64\artifact\hex0.efi +# hex0 should have the exact same checksum as hex0-seed as they are both supposed +# to be built from hex0_amd64.hex0 and by definition must be identical + +######################################### +# Phase-0b Build minimal kaem from hex0 # +######################################### +amd64\artifact\hex0.efi amd64\kaem-minimal.hex0 amd64\artifact\kaem-0.efi +# for checksum validation reasons diff --git a/bootstrap-seeds b/bootstrap-seeds index c720706..c422e3c 160000 --- a/bootstrap-seeds +++ b/bootstrap-seeds @@ -1 +1 @@ -Subproject commit c72070654660727b28334026cbb365dcd02e8f6b +Subproject commit c422e3cf55485b8ecd21cb7afeeccf0cc6616d36 diff --git a/kaem.amd64 b/kaem.amd64 new file mode 100644 index 0000000..09a7a2e --- /dev/null +++ b/kaem.amd64 @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2022 Andrius Štikonas +# +# SPDX-License-Identifier: GPL-3.0-or-later + +################################################## +# Phase 0-11 Build hex0 from bootstrapped binary # +################################################## + +EFI\BOOT\BOOTX64.efi amd64\mescc-tools-seed-kaem.kaem +amd64\artifact\kaem-0.efi amd64\mescc-tools-mini-kaem.kaem