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