1SubDir HAIKU_TOP src system boot platform u-boot ; 2 3SubDirHdrs $(HAIKU_TOP) headers private kernel boot platform $(TARGET_BOOT_PLATFORM) ; 4 5SubDirHdrs $(HAIKU_TOP) src system boot arch $(TARGET_ARCH) ; 6 7UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; 8UsePrivateHeaders [ FDirName graphics common ] ; 9UsePrivateHeaders [ FDirName graphics vesa ] ; 10UsePrivateHeaders [ FDirName storage ] ; 11UsePrivateHeaders [ FDirName kernel arch generic ] ; 12 13# TODO: move this to arch/arm ! 14 15UsePrivateHeaders [ FDirName kernel arch $(TARGET_ARCH) board $(TARGET_BOOT_BOARD) ] ; 16 17{ 18 local defines = _BOOT_MODE ; 19 20 defines = [ FDefines $(defines) ] ; 21 SubDirCcFlags $(defines) -g3 ; 22 SubDirC++Flags $(defines) -fno-rtti -g3 ; 23} 24 25# we fake NetBSD since we don't have an OS ID yet for uimage, 26# and we also fake a netbsd loader anyway. 27local uImageFakeOS = "netbsd" ; 28 29SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ; 30 31# First build the non arch dependent parts 32KernelMergeObject boot_platform_u-boot_common.o : 33 start.cpp 34 debug.cpp 35 console.cpp 36 serial.cpp 37 devices.cpp 38 keyboard.cpp 39 menu.cpp 40 cpu.cpp 41 uimage.cpp 42 video.cpp 43 mmu.cpp 44 $(genericPlatformSources) 45 46 47 : -fno-pic 48 : boot_platform_generic.a 49; 50 51KernelMergeObject boot_platform_u-boot.o : 52 : : 53 # must come first to have _start_* at correct locations 54 boot_platform_u-boot_$(TARGET_ARCH).o 55 boot_platform_u-boot_common.o 56; 57 58# bootable flash image 59rule BuildUBootFlashImage image : haikuLoader : uboot_image 60{ 61 Depends $(image) : $(haikuLoader) ; 62 #Depends $(image) : $(archive) ; 63 Depends $(image) : $(uboot_image) ; 64 LocalClean clean : $(image) ; 65 FLASH_IMAGE_BLOCK_SIZE on $(image) = 128k ; 66 FLASH_IMAGE_BLOCK_COUNT on $(image) = 256 ; 67 #FLASH_IMAGE_UBOOT_OFFSET on $(image) = 0 ; 68 FLASH_IMAGE_LOADER_OFFSET on $(image) = 248 ; 69 BuildUBootFlashImage1 $(image) : $(haikuLoader) $(uboot_image) ; 70} 71 72 73actions BuildUBootFlashImage1 74{ 75 $(RM) $(<) 76 77 # make an empty image 78 dd of=$(<) \ 79 if=/dev/zero \ 80 bs=$(FLASH_IMAGE_BLOCK_SIZE) \ 81 count=$(FLASH_IMAGE_BLOCK_COUNT) 82 83 # add u-boot 84 dd of=$(<) \ 85 if=$(>[2]) \ 86 bs=$(FLASH_IMAGE_BLOCK_SIZE) \ 87 conv=notrunc 88 89 # add root fs 90# dd of=$(<) \ 91# if=$(>[3]) \ 92# bs=$(FLASH_IMAGE_BLOCK_SIZE) \ 93# conv=notrunc \ 94# seek=$(FLASH_IMAGE_ROOTFS_OFFSET) 95 96 # add haiku_loader (raw, elf or uimage) 97 dd of=$(<) \ 98 if=$(>[1]) \ 99 bs=$(FLASH_IMAGE_BLOCK_SIZE) \ 100 conv=notrunc seek=$(FLASH_IMAGE_LOADER_OFFSET) 101} 102 103# uImage 104rule BuildUImage image : data : args 105{ 106 Depends $(image) : $(data) ; 107 LocalClean clean : $(image) ; 108 MKIMAGE_ARGS on $(image) = $(args) ; 109 colon on $(image) = ":" ; 110 local files = $(data:G=) ; 111 BuildUImage1 $(image) : $(data) ; 112} 113 114actions BuildUImage1 115{ 116 mkimage $(MKIMAGE_ARGS) -d $(>:J=$(colon)) $(<) 117} 118 119rule BuildUImageScript script : content 120{ 121 LocalClean clean : $(script) ; 122 SCRIPTCONTENT on $(script) = $(content) ; 123 SCRIPTNAME on $(script) = $(script) ; 124 FAKEOS on $(script) = $(uImageFakeOS) ; 125 BuildUImageScript1 $(script) : $(content) ; 126} 127 128actions BuildUImageScript1 129{ 130 rm -f $(<) $(<).txt 131 echo '$(SCRIPTCONTENT)' > $(<).txt 132 mkimage -A $(TARGET_ARCH) -O $(FAKEOS) -T script -C none -n $(SCRIPTNAME) \ 133 -d $(<).txt $(<) 134 rm -f $(<).txt 135} 136 137# SD/mmc image rule 138# requires sfdisk and mtools packages on linux 139rule BuildUBootSDImage image : files 140{ 141 Depends $(image) : $(files) ; 142 SDIMAGE_BLOCK_SIZE on $(image) = 1M ; 143 SDIMAGE_SIZE on $(image) = $(HAIKU_BOARD_SDIMAGE_SIZE) ; 144 SDIMAGE_FDISK on $(image) = $(HOST_SFDISK) ; 145 SDIMAGE_FDISK_SCRIPT on $(image) = 146 "0,$(HAIKU_BOARD_SDIMAGE_FAT_SIZE),0c,-\\\n,,eb\\\n\\\n" ; 147 SDIMAGE_FDISK_H on $(image) = 255 ; 148 SDIMAGE_FDISK_S on $(image) = 63 ; 149 SDIMAGE_FDISK_C on $(image) = ; 150 SDIMAGE_FDISK_UNIT on $(image) = M ; 151 BuildUBootSDImage1 $(image) : $(files) ; 152} 153 154actions BuildUBootSDImage1 155{ 156 $(RM) $(<) 157 $(RM) $(<).mtools 158 159 # make an empty image 160 dd of=$(<) \ 161 if=/dev/zero \ 162 bs=$(SDIMAGE_BLOCK_SIZE) \ 163 count=$(SDIMAGE_SIZE) 164 # partition it 165 printf '$(SDIMAGE_FDISK_SCRIPT)' | $(SDIMAGE_FDISK) -f -D \ 166 -H $(SDIMAGE_FDISK_H) -S $(SDIMAGE_FDISK_S) \ 167 -u$(SDIMAGE_FDISK_UNIT) $(<) 168 #-H $(SDIMAGE_FDISK_H) -S $(SDIMAGE_FDISK_S) -C \\\$(( $(SDIMAGE_SIZE) * 1024 * 1024 / $(SDIMAGE_FDISK_H) / $(SDIMAGE_FDISK_S))) \ 169 # generate mtools config 170 echo 'drive i: file="$(<)" partition=1' > $(<).mtools 171 # format the image 172 MTOOLSRC=$(<).mtools mformat -v "Haiku" i: 173 # populate 174 MTOOLSRC=$(<).mtools mcopy $(>) i: 175 # list content 176 #MTOOLSRC=$(<).mtools mdir i: 177 # cleanup 178 $(RM) $(<).mtools 179} 180 181# uimage targets 182BuildUImage haiku_loader.ub : haiku_loader : 183 -A $(TARGET_ARCH) -O $(uImageFakeOS) -T kernel -C none 184 -a $(HAIKU_BOARD_LOADER_BASE) -e $(HAIKU_BOARD_LOADER_ENTRY_RAW) 185 -n 'haiku_loader $(TARGET_BOOT_BOARD)' ; 186 187local tgzArchive = haiku-floppyboot.tgz ; 188 189BuildUImage haiku_loader_linux.ub : haiku_loader : 190 -A $(TARGET_ARCH) -O linux -T kernel -C none 191 -a $(HAIKU_BOARD_LOADER_BASE) -e $(HAIKU_BOARD_LOADER_ENTRY_LINUX) 192 -n 'haiku_loader $(TARGET_BOOT_BOARD)' ; 193 194BuildUImage haiku_loader_nbsd.ub : haiku_loader $(tgzArchive) : 195 -A $(TARGET_ARCH) -O $(uImageFakeOS) -T multi -C none 196 -a $(HAIKU_BOARD_LOADER_BASE) -e $(HAIKU_BOARD_LOADER_ENTRY_NBSD) 197 -n 'haiku_loader $(TARGET_BOOT_BOARD)' ; 198 199if $(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME) { 200 BuildUImageScript $(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME) : 201 $(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT) ; 202} 203 204if $(HAIKU_BOARD_MLO_IMAGE) && $(HAIKU_BOARD_MLO_IMAGE_URL) { 205 DownloadFile $(HAIKU_BOARD_MLO_IMAGE) $(HAIKU_BOARD_MLO_IMAGE_URL) ; 206} 207 208if $(HAIKU_BOARD_UBOOT_IMAGE) && $(HAIKU_BOARD_UBOOT_IMAGE_URL) { 209 # Download the u-boot binary file. 210 ubootFile = [ DownloadFile $(HAIKU_BOARD_UBOOT_IMAGE) 211 : $(HAIKU_BOARD_UBOOT_IMAGE_URL) ] ; 212} 213 214# flash image targets 215BuildUBootFlashImage haiku-$(HAIKU_BOOT_BOARD)_flash_image_raw.img : haiku_loader : 216 $(ubootFile) ; 217NotFile haiku-flash-image ; 218Depends haiku-flash-image : haiku-$(HAIKU_BOOT_BOARD)_flash_image_raw.img ; 219 220#BuildUBootFlashImage haiku-$(HAIKU_BOOT_BOARD)_flash_image_elf.img : boot_loader_u-boot : 221# $(ubootFile) ; 222#NotFile haiku-flash-elf-image ; 223#Depends haiku-flash-elf-image : haiku-$(HAIKU_BOOT_BOARD)_flash_image_elf.img ; 224 225BuildUBootFlashImage haiku-$(HAIKU_BOOT_BOARD)_flash_image_uimage.img : haiku_loader.ub : 226 $(ubootFile) ; 227NotFile haiku-flash-uimage ; 228Depends haiku-flash-uimage : haiku-$(HAIKU_BOOT_BOARD)_flash_image_uimage.img ; 229 230# SD/mmc image targets 231BuildUBootSDImage haiku-$(HAIKU_BOOT_BOARD).mmc : $(HAIKU_BOARD_SDIMAGE_FILES) ; 232NotFile haiku-mmc-image ; 233Depends haiku-mmc-image : haiku-$(HAIKU_BOOT_BOARD).mmc ; 234 235SEARCH on [ FGristFiles $(genericPlatformSources) ] 236 = [ FDirName $(HAIKU_TOP) src system boot platform generic ] ; 237 238# Tell the build system to where stage1.bin can be found, so it can be used 239# elsewhere. 240SEARCH on stage1.bin = $(SUBDIR) ; 241 242SubInclude HAIKU_TOP src system boot platform u-boot arch ; 243