The changeset implements initial support of relocatable U-Boot code
for SH2/SH3/SH4 architectures and boards, as weel as it restores
a possibility to boot U-Boot on SH boards, which has not been converted
to generic board in time (for more details see commit f41e6088eb1
("sh: Fix build errors for generic board")). Special attention from
maintainers of all touched boards is required, due to inaccessibility
of hardware for me it would be a troublesome task.

Now code/data initialization and relocation in general resemble the
procedure on ARM with minor peculiarities (same one relocation from a
storage device if calculated reloc_off == 0, otherwise two relocations),
however please note that the change does *not* add PIE support (only PIC),
so it may end up that there are persistent pointers to some non-relocated
data, this point requires better investion.

There is a runtime dependency on one generic change in common/board_f.c,
see patch https://patchwork.ozlabs.org/patch/656371/ , also only r2dplus
board is actually converted to support new arcitectural changes,
application of patch 12/12 depends on SH7751 PCI fixes found at
https://patchwork.ozlabs.org/patch/656373/ :

  -#define CONFIG_SYS_TEXT_BASE           0x8FFC0000
  +#define CONFIG_SYS_TEXT_BASE           0x8FE00000

This r2dplus board change allows immediately check the correctness of
the series on a r2dplus qemu target, note that the second copy is
not avoided in this case, also for simplicity SDRAM area up to text base
is large enough to store malloc pool and two copies of loaded code/data.

Board maintainers may pay attention to CONFIG_SYS_MALLOC_CLEAR_ON_INIT,
CONFIG_NEEDS_MANUAL_RELOC, CONFIG_SYS_GENERIC_GLOBAL_DATA etc. options.
To let know about the change and to continue with the completion of
the final step of board conversions to generic board I include all
SH2/SH3/SH4 board maintainers into Cc list, please update your board
configs appropriately.

The change was tested on one custom SH4 (SH7551R) board, r2dplus qemu
target (see also SH7751 PCI change under review), the rest of the boards
are compile tested only.

Multiple kudos to Simon for great patience and a decision to not remove
the code.

Any further improvements are welcome, especially it's worth to mention
the anticipated convertion to PIE.

Vladimir Zapolskiy (12):
  sh4: use single u-boot linker script for all boards
  sh: place board lowlevel_init code in the beginning of .text
  sh: define entry point and reloc_dst inside a linker script
  sh: add MEMORY command to a shared linker script
  sh: remove undefined DEBUG preprocessor token from board config files
  sh: define CONFIG_DISPLAY_BOARDINFO to print board information
  sh: add common dram_init() function for all boards
  sh: add shared relocate_code() function and call board_init_r()
  sh4: fix start.S by calling board_init_f() after first code relocation
  sh: share the correct version of start.S among all cpus
  sh: generate position independent code for all platforms
  r2dplus: fixup CONFIG_SYS_TEXT_BASE to account arch/sh changes

 arch/sh/Makefile                           |  2 +-
 arch/sh/config.mk                          |  2 +-
 arch/sh/cpu/sh2/Makefile                   |  1 -
 arch/sh/cpu/sh2/cpu.c                      |  6 ---
 arch/sh/cpu/sh3/Makefile                   |  1 -
 arch/sh/cpu/sh3/cpu.c                      |  6 ---
 arch/sh/cpu/sh3/start.S                    | 65 -----------------------
 arch/sh/cpu/sh4/Makefile                   |  1 -
 arch/sh/cpu/sh4/cpu.c                      |  6 ---
 arch/sh/cpu/sh4/start.S                    | 62 ----------------------
 arch/sh/cpu/u-boot.lds                     | 44 ++++++++--------
 arch/sh/lib/Makefile                       |  2 +
 arch/sh/lib/board.c                        | 35 +++++++++++++
 arch/sh/{cpu/sh2 => lib}/start.S           | 33 ++++++------
 board/alphaproject/ap_sh4a_4a/Makefile     |  2 +-
 board/alphaproject/ap_sh4a_4a/ap_sh4a_4a.c | 11 ----
 board/espt/Makefile                        |  2 +-
 board/espt/espt.c                          | 10 ----
 board/mpr2/Makefile                        |  2 +-
 board/mpr2/mpr2.c                          | 10 ----
 board/ms7720se/Makefile                    |  2 +-
 board/ms7720se/ms7720se.c                  | 10 ----
 board/ms7722se/Makefile                    |  2 +-
 board/ms7722se/ms7722se.c                  | 10 ----
 board/ms7750se/Makefile                    |  2 +-
 board/ms7750se/ms7750se.c                  | 10 ----
 board/renesas/MigoR/Makefile               |  2 +-
 board/renesas/MigoR/migo_r.c               | 10 ----
 board/renesas/ap325rxa/Makefile            |  2 +-
 board/renesas/ap325rxa/ap325rxa.c          | 10 ----
 board/renesas/ecovec/Makefile              |  2 +-
 board/renesas/ecovec/ecovec.c              | 10 ----
 board/renesas/r0p7734/Makefile             |  2 +-
 board/renesas/r0p7734/r0p7734.c            | 11 ----
 board/renesas/r2dplus/Makefile             |  2 +-
 board/renesas/r2dplus/r2dplus.c            | 10 ----
 board/renesas/r7780mp/Makefile             |  2 +-
 board/renesas/r7780mp/r7780mp.c            | 10 ----
 board/renesas/rsk7203/Makefile             |  2 +-
 board/renesas/rsk7203/rsk7203.c            | 10 ----
 board/renesas/rsk7264/Makefile             |  2 +-
 board/renesas/rsk7264/rsk7264.c            | 10 ----
 board/renesas/rsk7269/Makefile             |  2 +-
 board/renesas/rsk7269/rsk7269.c            | 10 ----
 board/renesas/sh7752evb/Makefile           |  2 +-
 board/renesas/sh7752evb/sh7752evb.c        | 11 ----
 board/renesas/sh7752evb/u-boot.lds         | 82 -----------------------------
 board/renesas/sh7753evb/Makefile           |  2 +-
 board/renesas/sh7753evb/sh7753evb.c        | 11 ----
 board/renesas/sh7753evb/u-boot.lds         | 82 -----------------------------
 board/renesas/sh7757lcr/Makefile           |  2 +-
 board/renesas/sh7757lcr/sh7757lcr.c        | 25 ---------
 board/renesas/sh7757lcr/u-boot.lds         | 83 ------------------------------
 board/renesas/sh7763rdp/Makefile           |  2 +-
 board/renesas/sh7763rdp/sh7763rdp.c        | 10 ----
 board/renesas/sh7785lcr/Makefile           |  2 +-
 board/renesas/sh7785lcr/sh7785lcr.c        | 10 ----
 board/shmin/Makefile                       |  2 +-
 board/shmin/shmin.c                        | 10 ----
 include/configs/MigoR.h                    |  2 +-
 include/configs/ap325rxa.h                 |  2 +-
 include/configs/ap_sh4a_4a.h               |  2 +-
 include/configs/ecovec.h                   |  2 +-
 include/configs/espt.h                     |  1 +
 include/configs/mpr2.h                     |  2 +
 include/configs/ms7720se.h                 |  1 +
 include/configs/ms7722se.h                 |  1 +
 include/configs/ms7750se.h                 |  2 +
 include/configs/r0p7734.h                  |  2 +-
 include/configs/r2dplus.h                  |  6 +--
 include/configs/r7780mp.h                  |  3 +-
 include/configs/rsk7203.h                  |  2 +-
 include/configs/rsk7264.h                  |  3 +-
 include/configs/rsk7269.h                  |  3 +-
 include/configs/sh7752evb.h                |  3 +-
 include/configs/sh7753evb.h                |  3 +-
 include/configs/sh7757lcr.h                |  3 +-
 include/configs/sh7763rdp.h                |  1 +
 include/configs/sh7785lcr.h                |  2 +-
 include/configs/shmin.h                    |  1 +
 80 files changed, 127 insertions(+), 704 deletions(-)
 delete mode 100644 arch/sh/cpu/sh3/start.S
 delete mode 100644 arch/sh/cpu/sh4/start.S
 create mode 100644 arch/sh/lib/board.c
 rename arch/sh/{cpu/sh2 => lib}/start.S (56%)
 delete mode 100644 board/renesas/sh7752evb/u-boot.lds
 delete mode 100644 board/renesas/sh7753evb/u-boot.lds
 delete mode 100644 board/renesas/sh7757lcr/u-boot.lds

-- 
2.8.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to