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