[U-Boot] [PATCH v4 0/27] Create generic board init for ARM, x86, PPC
Simon Glass
sjg at chromium.org
Thu Mar 15 03:15:57 CET 2012
This series creates a generic board.c implementation which contains
the essential functions of the major arch/xxx/lib/board.c files.
What is the motivation for this change?
1. There is a lot of repeated code in the board.c files. Any change to
things like setting up the baud rate requires a change in 10 separate
places.
2. Since there are 10 separate files, adding a new feature which requires
initialisation is painful since it must be independently added in 10
places.
3. As time goes by the architectures naturely diverge since there is limited
pressure to compare features or even CONFIG options against simiilar things
in other board.c files.
4. New architectures must implement all the features all over again, and
sometimes in subtley different ways. This places an unfair burden on getting
a new architecture fully functional and running with U-Boot.
5. While it is a bit of a tricky change, I believe it is worthwhile and
achievable. There is no requirement that all code be common, only that
the code that is common should be located in common/board.c rather than
arch/xxx/lib/board.c.
All the functions of board_init_f() and board_init_r() are broken into
separate function calls so that they can easily be included or excluded
for a particular architecture. It also makes it easier to adopt Graeme's
initcall proposal when it is ready.
http://lists.denx.de/pipermail/u-boot/2012-January/114499.html
This series removes the dependency on generic relocation. So relocation
happens as one big chunk and is still completely arch-specific. See the
relocation series for a proposed solution to this for ARM:
http://lists.denx.de/pipermail/u-boot/2011-December/112928.html
or Graeme's recent x86 series v2:
http://lists.denx.de/pipermail/u-boot/2012-January/114467.html
Instead of moving over a whole architecture, this series takes the approach
of simply enabling generic board support for an architecture. It is then up
to each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board
config file. If this is not done, then the code will be generated as
before. This allows both sets of code to co-exist until we are comfortable
with the generic approach, and enough boards run.
ARM is a relatively large board.c file and one which I can test, therefore
I think it is a good target for this series. On the other hand, x86 is
relatively small and simple, but different enough that it introduces a
few issues to be solved. So I have chosen both ARM and x86 for this series.
After a suggestion from Wolfgang I have added PPC also. This is the
largest and most feature-full board, so hopefully we have all bases
covered in this RFC.
A generic global_data structure is also required. This might upset a few
people. Here is my basic reasoning: most fields are the same, all
architectures include and need it, most global_data.h files already have
#ifdefs to select fields for a particular SOC, so it is hard to
see why architecures are different in this area. We can perhaps add a
way to put architecture-specific fields into a separate header file, but
for now I have judged that to be counter-productive.
Similarly we need a generic bd_info structure, since generic code will
be accessing it. I have done this in the same way as global_data and the
same comments apply.
There was dicussion on the list about passing gd_t around as a parameter
to pre-relocation init functions. I think this makes sense, but it can
be done as a separate change, and this series does not require it.
While this series needs to stand on its own (as with the link script
cleanup series and the generic relocation series) the goal is the
unification of the board init code. So I hope we can address issues with
this in mind, rather than focusing too narrowly on particular ARM, x86 or
PPC issues.
I have run-tested ARM on Tegra Seaboard only. To try it out, define
CONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on
x86 and PPC at least it will hang, but if you are lucky it will print
something first :-)
I have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all
ARM, PPC and x86 boards. There are a few failures due to errors in
the board config, which I have sent patches for. The main issue is
just the difference between __bss_end and __bss_end__.
Note: the first group of commits are required for this series to build,
but could be separated out if required. I have included them here for
convenience.
Comments welcome.
Changes in v2:
- Add CONFIG_SYS_GENERIC_BOARD to allow board to select generic board
- Add PowerPC support
- Change generic board to an opt-in system on a per-board basic
- Rebase to master
Changes in v3:
- Add header to new x86 relocate.c and init_helpers.c
- Cast away the volatile on gd for memcpy()
- Rebase on top of x86/master (which has not yet been pulled to master)
- Rebase to master
Changes in v4:
- Add asm/sections.h for each architecture
- Add three more fields required for ARM
- Drop sc520_timer.c patch (warning already fixed by previous patch)
- Rebase to master
- Updates to sit on top of earlier patches
- Use asm/sections.h instead of asm-generic/sections.h
Simon Glass (27):
arm: Change board baud_rate to ulong
x86: Change board baud_rate to ulong
arm: Only display frame buffer info if there is LCD/video support
x86: Remove dead code in eNET
x86: Add initial memory barrier macros
ppc: Add initial memory barrier macros
Introduce generic global_data
Introduce generic u-boot.h file
Introduce generic link section.h symbol files
arm: Use sections header to obtain link symbols
x86: Change stub example to use asm-generic/sections.h
Introduce a basic initcall implementation
Define CONFIG_SYS_LEGACY_BOARD everywhere
Introduce generic pre-relocation board_f.c
Introduce generic post-relocation board_r.c
Add spl load feature
arm: Enable generic board support
Add CONFIG_SYS_SYM_OFFSETS to support offset symbols
x86: Use sections header to obtain link symbols
Add x86 fields to generic global_data
x86: Enable generic board support
Add ppc fields to generic global data
Adjust board_f for ppc
Adjust board_r.c for PowerPC
ppc: Enable generic board board
tegra: Mark board init files for ARMv4t
tegra: Enable generic board for Seaboard.
README | 17 +
arch/arm/cpu/armv7/tegra2/config.mk | 2 +
arch/arm/include/asm/global_data.h | 7 +
arch/arm/include/asm/sections.h | 27 +
arch/arm/include/asm/u-boot-arm.h | 4 -
arch/arm/include/asm/u-boot.h | 11 +-
arch/arm/lib/Makefile | 4 +-
arch/arm/lib/board.c | 1 +
arch/avr32/config.mk | 3 +
arch/avr32/cpu/start.S | 2 +-
arch/avr32/cpu/u-boot.lds | 2 +-
arch/avr32/include/asm/sections.h | 6 +-
arch/avr32/lib/board.c | 2 +-
arch/blackfin/config.mk | 3 +
arch/blackfin/include/asm/sections.h | 27 +
arch/m68k/config.mk | 3 +
arch/m68k/include/asm/sections.h | 27 +
arch/microblaze/config.mk | 3 +
arch/microblaze/include/asm/sections.h | 27 +
arch/mips/config.mk | 3 +
arch/mips/include/asm/sections.h | 27 +
arch/nds32/config.mk | 3 +
arch/nds32/include/asm/sections.h | 27 +
arch/nios2/config.mk | 3 +
arch/nios2/include/asm/sections.h | 27 +
arch/openrisc/include/asm/sections.h | 27 +
arch/powerpc/include/asm/global_data.h | 7 +
arch/powerpc/include/asm/io.h | 8 +
arch/powerpc/include/asm/sections.h | 27 +
arch/powerpc/include/asm/u-boot.h | 7 +
arch/powerpc/lib/Makefile | 4 +-
arch/sandbox/config.mk | 3 +
arch/sandbox/include/asm/sections.h | 27 +
arch/sh/config.mk | 3 +
arch/sh/include/asm/sections.h | 27 +
arch/sparc/config.mk | 3 +
arch/sparc/include/asm/sections.h | 27 +
arch/x86/include/asm/global_data.h | 7 +
arch/x86/include/asm/io.h | 8 +
arch/x86/include/asm/sections.h | 27 +
arch/x86/include/asm/u-boot-x86.h | 8 -
arch/x86/include/asm/u-boot.h | 13 +-
arch/x86/lib/Makefile | 4 +-
arch/x86/lib/board.c | 1 +
arch/x86/lib/init_helpers.c | 1 +
arch/x86/lib/relocate.c | 1 +
board/cm4008/flash.c | 1 +
board/cm41xx/flash.c | 1 +
board/eNET/eNET.c | 5 -
common/Makefile | 4 +
common/board_f.c | 888 ++++++++++++++++++++++++++++++++
common/board_r.c | 862 +++++++++++++++++++++++++++++++
common/cmd_bdinfo.c | 6 +-
config.mk | 8 +
examples/standalone/stubs.c | 7 +-
include/asm-generic/global_data.h | 241 +++++++++
include/asm-generic/sections.h | 124 +++++
include/asm-generic/u-boot.h | 160 ++++++
include/common.h | 16 +
include/configs/seaboard.h | 2 +
include/initcall.h | 25 +
lib/Makefile | 1 +
lib/initcall.c | 41 ++
63 files changed, 2866 insertions(+), 34 deletions(-)
create mode 100644 arch/arm/include/asm/sections.h
create mode 100644 arch/blackfin/include/asm/sections.h
create mode 100644 arch/m68k/include/asm/sections.h
create mode 100644 arch/microblaze/include/asm/sections.h
create mode 100644 arch/mips/include/asm/sections.h
create mode 100644 arch/nds32/include/asm/sections.h
create mode 100644 arch/nios2/include/asm/sections.h
create mode 100644 arch/openrisc/include/asm/sections.h
create mode 100644 arch/powerpc/include/asm/sections.h
create mode 100644 arch/sandbox/include/asm/sections.h
create mode 100644 arch/sh/include/asm/sections.h
create mode 100644 arch/sparc/include/asm/sections.h
create mode 100644 arch/x86/include/asm/sections.h
create mode 100644 common/board_f.c
create mode 100644 common/board_r.c
create mode 100644 include/asm-generic/global_data.h
create mode 100644 include/asm-generic/sections.h
create mode 100644 include/asm-generic/u-boot.h
create mode 100644 include/initcall.h
create mode 100644 lib/initcall.c
--
1.7.7.3
More information about the U-Boot
mailing list