00ca8b4cf2
Maybe it will be needed on real hw later.
197 lines
5.2 KiB
Plaintext
197 lines
5.2 KiB
Plaintext
# Set anyboot file name and directory defaults.
|
|
HAIKU_MMC_NAME ?= $(HAIKU_DEFAULT_MMC_NAME) ;
|
|
HAIKU_MMC_DIR ?= $(HAIKU_DEFAULT_MMC_DIR) ;
|
|
HAIKU_MMC = $(HAIKU_MMC_NAME) ;
|
|
HAIKU_MMC_LABEL ?= $(HAIKU_DEFAULT_MMC_LABEL) ;
|
|
|
|
# SD/mmc image rule
|
|
# Files must be in this order:
|
|
# out : mbrtool fatshell os_image loader floppyboot everything_else
|
|
rule BuildSDImage image : files
|
|
{
|
|
local mbrtool = <build>mbrtool ;
|
|
local fatshell = <build>fat_shell ;
|
|
|
|
Depends $(image) : $(files) $(TARGET_DEVICE_TREES) ;
|
|
Depends $(image) : $(HAIKU_IMAGE_NAME) ;
|
|
Depends $(image) : $(mbrtool) ;
|
|
Depends $(image) : $(fatshell) ;
|
|
|
|
SDIMAGE_OS_SIZE on $(image) = $(HAIKU_IMAGE_SIZE) ;
|
|
SDIMAGE_BEGIN on $(image) = $(HAIKU_BOOT_SDIMAGE_BEGIN:E=63) ;
|
|
|
|
if $(TARGET_BOOT_PLATFORM) = efi {
|
|
switch $(TARGET_ARCH) {
|
|
case x86_64 :
|
|
EFINAME on $(image) = "BOOTX64.EFI" ;
|
|
case arm :
|
|
EFINAME on $(image) = "BOOTARM.EFI" ;
|
|
case arm64 :
|
|
EFINAME on $(image) = "BOOTAA64.EFI" ;
|
|
case riscv32 :
|
|
EFINAME on $(image) = "BOOTRISCV32.EFI" ;
|
|
case riscv64 :
|
|
EFINAME on $(image) = "BOOTRISCV64.EFI" ;
|
|
case * :
|
|
Exit "Error: Unknown EFI architecture!" ;
|
|
}
|
|
BuildEfiSDImage1 $(image) : $(mbrtool) $(fatshell) $(files) ;
|
|
} else if $(TARGET_BOOT_PLATFORM) = u-boot {
|
|
BuildUBootSDImage1 $(image) : $(mbrtool) $(fatshell) $(files) ;
|
|
} else {
|
|
# TODO: For now we do nothing. Maybe we want a "AddSDImage" to
|
|
# append additional loaders like the raw riscv one?
|
|
echo "Asked for $(TARGET_BOOT_PLATFORM) target boot platform" ;
|
|
echo "Unknown path to handle adding to image" ;
|
|
}
|
|
}
|
|
|
|
# Usage:
|
|
# out : mbrtool fatshell os_image loader floppyboot everything_else
|
|
actions BuildUBootSDImage1
|
|
{
|
|
$(RM) $(1)
|
|
|
|
export $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
|
|
|
# in KiB
|
|
EFI_SIZE=32768
|
|
BOOT_SIZE=`expr ${EFI_SIZE} + $(SDIMAGE_BEGIN)`
|
|
MMC_SIZE=`expr $(SDIMAGE_OS_SIZE) \* 1024 + ${BOOT_SIZE}`
|
|
|
|
# Build "boot" disk
|
|
dd if=/dev/zero of=$(1) bs=1K count=${BOOT_SIZE}
|
|
|
|
# generate u-boot environment variables
|
|
echo 'os=haiku' > uEnv.txt
|
|
echo 'platform=u-boot' >> uEnv.txt
|
|
echo "loader=haiku_loader.ub" >> uEnv.txt
|
|
|
|
# Lay down partition map
|
|
OS_LENGTH=`expr ${MMC_SIZE} - ${BOOT_SIZE}`
|
|
|
|
# EFI System Partition
|
|
$(2[1]) $(1) 0 0xef $(SDIMAGE_BEGIN) ${EFI_SIZE}
|
|
# OS Partition
|
|
$(2[1]) $(1) 1 0xeb ${BOOT_SIZE} ${OS_LENGTH}
|
|
|
|
FATFS="$(2[2]) --start-offset `expr $(SDIMAGE_BEGIN) \* 1024`"
|
|
|
|
# format the image
|
|
${FATFS} --end-offset `expr ${BOOT_SIZE} \* 1024` \
|
|
--initialize "$(1)" 'Haiku Boot'
|
|
|
|
# populate
|
|
for i in $(2[4-]) ; do
|
|
echo "cp :${i} myfs/" | ${FATFS} $(1)
|
|
done
|
|
|
|
echo "cp :uEnv.txt myfs/" | ${FATFS} $(1)
|
|
|
|
# lay down FDT's
|
|
echo "mkdir myfs/fdt" | ${FATFS} $(1)
|
|
for i in $(TARGET_DEVICE_TREES[1-]) ; do
|
|
echo "cp :${i} myfs/fdt/" | ${FATFS} $(1)
|
|
done
|
|
|
|
# list content
|
|
echo "ls myfs" | ${FATFS} $(1)
|
|
|
|
# cleanup
|
|
$(RM) uEnv.txt
|
|
$(RM) boot.scr
|
|
|
|
# Add haiku partition to MMC image
|
|
cat $(2[3-3]) >> $(1)
|
|
}
|
|
|
|
|
|
# Usage:
|
|
# out : mbrtool fatshell os_image loader floppyboot everything_else
|
|
actions BuildEfiSDImage1
|
|
{
|
|
$(RM) $(1)
|
|
|
|
export $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
|
|
|
# in KiB
|
|
EFI_SIZE=32768
|
|
BOOT_SIZE=`expr ${EFI_SIZE} + $(SDIMAGE_BEGIN)`
|
|
MMC_SIZE=`expr $(SDIMAGE_OS_SIZE) \* 1024 + ${BOOT_SIZE}`
|
|
|
|
# Build "boot" disk
|
|
dd if=/dev/zero of=$(1) bs=1K count=${BOOT_SIZE}
|
|
|
|
# generate u-boot environment variables
|
|
echo 'os=haiku' > uEnv.txt
|
|
echo 'platform=efi' >> uEnv.txt
|
|
echo "loader=EFI/BOOT/$(EFINAME)" >> uEnv.txt
|
|
|
|
# Lay down partition map
|
|
OS_LENGTH=`expr ${MMC_SIZE} - ${BOOT_SIZE}`
|
|
|
|
# EFI System Partition
|
|
$(2[1]) $(1) 0 0xef $(SDIMAGE_BEGIN) ${EFI_SIZE}
|
|
# OS Partition
|
|
$(2[1]) $(1) 1 0xeb ${BOOT_SIZE} ${OS_LENGTH}
|
|
|
|
FATFS="$(2[2]) --start-offset `expr $(SDIMAGE_BEGIN) \* 1024`"
|
|
|
|
# format the image
|
|
${FATFS} --end-offset `expr ${BOOT_SIZE} \* 1024` \
|
|
--initialize "$(1)" 'Haiku Boot'
|
|
|
|
# populate
|
|
echo "mkdir -p myfs/EFI/BOOT" | ${FATFS} $(1)
|
|
echo "cp :$(2[4-4]) myfs/EFI/BOOT/$(EFINAME)" | ${FATFS} $(1)
|
|
|
|
# copy misc files
|
|
for i in $(2[5-]) ; do
|
|
echo "cp :${i} myfs/" | ${FATFS} $(1)
|
|
done
|
|
echo "cp :uEnv.txt myfs/" | ${FATFS} $(1)
|
|
|
|
# lay down FDT's
|
|
echo "mkdir myfs/fdt" | ${FATFS} $(1)
|
|
for i in $(TARGET_DEVICE_TREES[1-]) ; do
|
|
echo "cp :${i} myfs/fdt/" | ${FATFS} $(1)
|
|
done
|
|
|
|
# list content
|
|
echo "ls myfs" | ${FATFS} $(1)
|
|
|
|
# cleanup
|
|
$(RM) uEnv.txt
|
|
$(RM) boot.scr
|
|
|
|
# Add haiku partition to MMC image
|
|
cat $(2[3-3]) >> $(1)
|
|
}
|
|
|
|
for platform in [ MultiBootSubDirSetup ] {
|
|
on $(platform) {
|
|
# SD/mmc image targets
|
|
if $(TARGET_BOOT_PLATFORM) = efi {
|
|
if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = riscv64 {
|
|
# These EFI platforms need u-boot to get them going
|
|
BuildSDImage $(HAIKU_MMC_NAME) : $(HAIKU_IMAGE)
|
|
haiku_loader.$(TARGET_BOOT_PLATFORM)
|
|
boot.scr ;
|
|
} else {
|
|
BuildSDImage $(HAIKU_MMC_NAME) : $(HAIKU_IMAGE)
|
|
haiku_loader.$(TARGET_BOOT_PLATFORM) ;
|
|
}
|
|
} else if $(TARGET_BOOT_PLATFORM) = u-boot {
|
|
BuildSDImage $(HAIKU_MMC_NAME) :
|
|
$(HAIKU_IMAGE) haiku_loader.$(TARGET_BOOT_PLATFORM) haiku-floppyboot.tgz.$(TARGET_BOOT_PLATFORM) boot.scr ;
|
|
} else {
|
|
BuildSDImage $(HAIKU_MMC_NAME) :
|
|
$(HAIKU_IMAGE) haiku_loader.$(TARGET_BOOT_PLATFORM) boot.scr ;
|
|
}
|
|
}
|
|
}
|
|
|
|
#BlessSDImage haiku-$(TARGET_KERNEL_ARCH).mmc ;
|
|
NotFile haiku-mmc-image ;
|
|
Depends haiku-mmc-image : $(HAIKU_MMC_NAME) ;
|