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