Add Makefile for creating images and launching qemu.

main
Andrius Štikonas 2 months ago
parent 129bfcbd16
commit f552c166df
  1. 3
      .gitignore
  2. 3
      .gitmodules
  3. 1
      Development/efi/boot_table.h
  4. 1
      Development/efi/device_path_protocol.h
  5. 1
      Development/efi/efi.h
  6. 1
      Development/efi/file_protocol.h
  7. 1
      Development/efi/loaded_image_protocol.h
  8. 1
      Development/efi/simple_file_system_protocol.h
  9. 1
      Development/efi/simple_text_output_protocol.h
  10. 1
      Development/efi/system_table.h
  11. 1
      Development/efi/types.h
  12. 4
      Development/rootfs/kaem.amd64
  13. 3
      Development/rootfs/startup.nsh
  14. 53
      Makefile
  15. 0
      amd64/Development/kaem-minimal.M1
  16. 0
      amd64/Development/kaem-minimal.S
  17. 0
      amd64/Development/kaem-minimal.hex2
  18. 4
      amd64/PE32-amd64.hex2
  19. 4
      amd64/artifact/README
  20. 0
      amd64/kaem-minimal.hex0
  21. 7
      amd64/mescc-tools-mini-kaem.kaem
  22. 16
      amd64/mescc-tools-seed-kaem.kaem
  23. 2
      bootstrap-seeds
  24. 10
      kaem.amd64

3
.gitignore vendored

@ -1,7 +1,8 @@
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-License-Identifier: MIT
*~
*/build/
build/
*.d
*.lib
*.efi

3
.gitmodules vendored

@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-License-Identifier: MIT
[submodule "bootstrap-seeds"]
path = bootstrap-seeds
url = https://github.com/oriansj/bootstrap-seeds/

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_BOOT_TABLE_H__

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_DEVICE_PATH_PROTOCOL_H__

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_H__

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_FILE_PROTOCOL_H__

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_LOADED_IMAGE_PROTOCOL_H__

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_H__

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_H__

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_SYSTEM_TABLE_H__

@ -1,3 +1,4 @@
/* SPDX-FileCopyrightText: Mike Krinkin */
/* SPDX-License-Identifier: Unlicense */
#ifndef __EFI_TYPES_H__

@ -1,4 +1,6 @@
# kaem
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
#
# SPDX-License-Identifier: GPL-3.0-or-later
# Rebuild hex0
EFI\BOOT\hex0.efi hex0_amd64.hex0 hex0.efi

@ -1,3 +0,0 @@
# SPDX-License-Identifier: Unlicense
BOOTX64

@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
#
# 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)

@ -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.

@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-License-Identifier: MIT
This is a placeholder directory that will contain AMD64 bootstrap artifacts.

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#################################
# Phase-1 Build hex1 from hex0 #
#################################

@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
#
# 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

@ -1 +1 @@
Subproject commit c72070654660727b28334026cbb365dcd02e8f6b
Subproject commit c422e3cf55485b8ecd21cb7afeeccf0cc6616d36

@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
#
# 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
Loading…
Cancel
Save