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