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