Print this page
bcm2835: we need a loader on this platform as well
As stated before, the Raspberry Pi loader is terrible.  It claims to
supporte ELF file loading, but what it does is crazy.  It loads the ELF file
into memory, gets the start address from the header, converts it into file
offset, adds it to the address where the file was loaded and jumps there.
This is very wrong.  So, instead of booting the loader as an ELF file, we
objcopy it into a plain ol' binary image.  This should be safe because (1)
the loader has no relocations left, (2) whatever benefit we lose from not
having the whole ELF file in memory is only temporary until the loader hands
off control to unix.
Finally, we force the entry point to appear at the beginning of the binary
file by moving _start into its own section (.text.init) and using the
mapfile to put that section before everything else.
   1 #
   2 # This file and its contents are supplied under the terms of the
   3 # Common Development and Distribution License ("CDDL"), version 1.0.
   4 # You may only use this file in accordance with the terms of version
   5 # 1.0 of the CDDL.
   6 #
   7 # A full copy of the text of the CDDL should have accompanied this
   8 # source.  A copy of the CDDL is also available via the Internet at
   9 # http://www.illumos.org/license/CDDL.
  10 #
  11 
  12 #
  13 # Copyright (c) 2013, Joyent, Inc.  All rights reserved.

  14 #
  15 
  16 UTSBASE = ../..
  17 
  18 include $(UTSBASE)/armv6/bcm2835/Makefile.bcm2835
  19 
  20 def             :=      TARGET= def
  21 all             :=      TARGET= all
  22 install         :=      TARGET= install
  23 install_h       :=      TARGET= install_h
  24 clean           :=      TARGET= clean
  25 clobber         :=      TARGET= clobber
  26 lint            :=      TARGET= lint
  27 lintlib         :=      TARGET= lintlib
  28 modlintlib      :=      TARGET= modlintlib
  29 modlist         :=      TARGET= modlist
  30 modlist         :=      NO_STATE= -K $$MODSTATE$$$$
  31 clean.lint      :=      TARGET= clean.lint
  32 check           :=      TARGET= check
  33 
  34 
  35 #
  36 #       Default build targets.
  37 #
  38 .KEEP_STATE:
  39 
  40 def all clean clobber clean.lint: unix .WAIT \
  41                 $(BCM2835_CPU_KMODS) $(BCM2835_KMODS)
  42 
  43 modlist:        unix \

  44                 $(BCM2835_CPU_KMODS) $(BCM2835_KMODS)
  45 
  46 IMPLEMENTED_PLATFORM = Raspberry,Pi
  47 
  48 install: $(ROOT_BCM2835_DIR) $(USR_BCM2835_DIR) \
  49         $(USR_BCM2835_INC_DIR) \
  50         $(USR_BCM2835_SBIN_DIR) \
  51         $(USR_BCM2835_LIB_DIR) \
  52         $(BCM2835_CRYPTO_LINKS) \
  53         unix .WAIT $(BCM2835_CPU_KMODS) \
  54         $(BCM2835_KMODS)
  55 
  56 unix $(BCM2835_KMODS) $(BCM2835_CPU_KMODS): FRC
  57         @cd $@; pwd; $(MAKE) $(NO_STATE) $(TARGET)
  58 
  59 install_h check:        FRC
  60 
  61 #
  62 #       Include common targets.
  63 #
  64 include $(UTSBASE)/armv6/bcm2835/Makefile.targ
  65 
   1 #
   2 # This file and its contents are supplied under the terms of the
   3 # Common Development and Distribution License ("CDDL"), version 1.0.
   4 # You may only use this file in accordance with the terms of version
   5 # 1.0 of the CDDL.
   6 #
   7 # A full copy of the text of the CDDL should have accompanied this
   8 # source.  A copy of the CDDL is also available via the Internet at
   9 # http://www.illumos.org/license/CDDL.
  10 #
  11 
  12 #
  13 # Copyright (c) 2013, Joyent, Inc.  All rights reserved.
  14 # Copyright (c) 2015, Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  15 #
  16 
  17 UTSBASE = ../..
  18 
  19 include $(UTSBASE)/armv6/bcm2835/Makefile.bcm2835
  20 
  21 def             :=      TARGET= def
  22 all             :=      TARGET= all
  23 install         :=      TARGET= install
  24 install_h       :=      TARGET= install_h
  25 clean           :=      TARGET= clean
  26 clobber         :=      TARGET= clobber
  27 lint            :=      TARGET= lint
  28 lintlib         :=      TARGET= lintlib
  29 modlintlib      :=      TARGET= modlintlib
  30 modlist         :=      TARGET= modlist
  31 modlist         :=      NO_STATE= -K $$MODSTATE$$$$
  32 clean.lint      :=      TARGET= clean.lint
  33 check           :=      TARGET= check
  34 
  35 
  36 #
  37 #       Default build targets.
  38 #
  39 .KEEP_STATE:
  40 
  41 def all clean clobber clean.lint: unix loader .WAIT \
  42                 $(BCM2835_CPU_KMODS) $(BCM2835_KMODS)
  43 
  44 modlist:        unix \
  45                 loader \
  46                 $(BCM2835_CPU_KMODS) $(BCM2835_KMODS)
  47 
  48 IMPLEMENTED_PLATFORM = Raspberry,Pi
  49 
  50 install: $(ROOT_BCM2835_DIR) $(USR_BCM2835_DIR) \
  51         $(USR_BCM2835_INC_DIR) \
  52         $(USR_BCM2835_SBIN_DIR) \
  53         $(USR_BCM2835_LIB_DIR) \
  54         $(BCM2835_CRYPTO_LINKS) \
  55         unix .WAIT $(BCM2835_CPU_KMODS) \
  56         $(BCM2835_KMODS) loader
  57 
  58 unix loader $(BCM2835_KMODS) $(BCM2835_CPU_KMODS): FRC
  59         @cd $@; pwd; $(MAKE) $(NO_STATE) $(TARGET)
  60 
  61 install_h check:        FRC
  62 
  63 #
  64 #       Include common targets.
  65 #
  66 include $(UTSBASE)/armv6/bcm2835/Makefile.targ
  67