All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 0/19] Create generic board init and move ARM and x86 to it
Date: Tue, 27 Dec 2011 22:35:41 -0800	[thread overview]
Message-ID: <1325054160-24894-1-git-send-email-sjg@chromium.org> (raw)

This series creates a generic board.c implementation which contains
the essential functions of the various 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 later if desired.

Generic relocation is used (see previous series) but now rather than
calling relocate_code() to do everything, we call the individual
relocation steps one by one. Again this makes it easier to leave things
out, particularly for SPL.

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.

The next target should probably be PowerPC, since it is large and has
some additional features. I suspect we may want to leave some of these
very architecture-specific functions in arch/powerpc/lib/board.c, taking
out only the generic code. I haven't felt a strong need to do this for
ARM/x86, but we could even go as far as putting the initcall list into
the architecture-specific board file if the architecture adds a lot of
unusual calls.

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.

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 or x86
issues.

Comments welcome. Note that the x86 side of this still needs a fair bit
of work, sorry.


Simon Glass (19):
  Introduce generic global_data
  Make relocation functions global
  Add basic initcall implementation
  define CONFIG_SYS_LEGACY_BOARD everywhere
  Add generic post-relocation board_r.c
  Add generic pre-relocation board_f.c
  Add spl load feature
  switch ARM over to generic board
  arm: Remove unused code in board.c, global_data.h
  Add CONFIG_SYS_SYM_OFFSETS to support offset symbols
  x86: Remove compiler warning in sc520_timer.c
  x86: Remove dead code in eNET
  x86: Add processor library and relocation functions
  Tidy up asm/generic sections.h to include x86 symbols
  Add fields required by x86 to global_data
  x86: Change stub example to use asm-generic/sections.h
  x86: Add initial memory barrier macros
  Bring in x86 to unified board architecture
  x86: Remove unused board/global_data code

 README                             |    5 +
 arch/arm/include/asm/global_data.h |   77 +-----
 arch/arm/include/asm/u-boot-arm.h  |    4 -
 arch/arm/lib/board.c               |  622 +-----------------------------------
 arch/avr32/config.mk               |    3 +
 arch/blackfin/config.mk            |    3 +
 arch/m68k/config.mk                |    3 +
 arch/microblaze/config.mk          |    3 +
 arch/mips/config.mk                |    3 +
 arch/nds32/config.mk               |    3 +
 arch/nios2/config.mk               |    3 +
 arch/powerpc/config.mk             |    3 +
 arch/sandbox/config.mk             |    3 +
 arch/sh/config.mk                  |    3 +
 arch/sparc/config.mk               |    3 +
 arch/x86/config.mk                 |    3 -
 arch/x86/cpu/sc520/sc520_timer.c   |    2 +-
 arch/x86/include/asm/global_data.h |   57 +----
 arch/x86/include/asm/io.h          |    8 +
 arch/x86/include/asm/reloc.h       |   32 ++
 arch/x86/include/asm/u-boot-x86.h  |    8 -
 arch/x86/lib/Makefile              |    1 +
 arch/x86/lib/board.c               |  452 +--------------------------
 arch/x86/lib/proc.S                |   67 ++++
 board/eNET/eNET.c                  |    5 -
 board/freescale/p2020come/Makefile |    6 +
 common/Makefile                    |    7 +-
 common/board_f.c                   |  461 ++++++++++++++++++++++++++
 common/board_r.c                   |  385 ++++++++++++++++++++++
 common/reloc.c                     |   46 +++-
 config.mk                          |    4 +
 examples/standalone/stubs.c        |    7 +-
 include/asm-generic/global_data.h  |  129 ++++++++
 include/asm-generic/sections.h     |   29 ++
 include/initcall.h                 |   25 ++
 include/reloc.h                    |   16 +
 lib/Makefile                       |    1 +
 lib/initcall.c                     |   41 +++
 38 files changed, 1308 insertions(+), 1225 deletions(-)
 create mode 100644 arch/x86/include/asm/reloc.h
 create mode 100644 arch/x86/lib/proc.S
 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/initcall.h
 create mode 100644 lib/initcall.c

-- 
1.7.3.1

             reply	other threads:[~2011-12-28  6:35 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-28  6:35 Simon Glass [this message]
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 01/19] Introduce generic global_data Simon Glass
2011-12-29  7:47   ` Andreas Bießmann
2012-01-07 22:33     ` Simon Glass
2012-01-08 10:48       ` Graeme Russ
2012-01-08 18:13         ` Simon Glass
2012-01-09 11:21           ` Andreas Bießmann
2012-01-09 18:17             ` Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 02/19] Make relocation functions global Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 03/19] Add basic initcall implementation Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 04/19] define CONFIG_SYS_LEGACY_BOARD everywhere Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 05/19] Add generic post-relocation board_r.c Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 06/19] Add generic pre-relocation board_f.c Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 07/19] Add spl load feature Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 08/19] switch ARM over to generic board Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 09/19] arm: Remove unused code in board.c, global_data.h Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 10/19] Add CONFIG_SYS_SYM_OFFSETS to support offset symbols Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 11/19] x86: Remove compiler warning in sc520_timer.c Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 12/19] x86: Remove dead code in eNET Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 13/19] x86: Add processor library and relocation functions Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 14/19] Tidy up asm/generic sections.h to include x86 symbols Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 15/19] Add fields required by x86 to global_data Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 16/19] x86: Change stub example to use asm-generic/sections.h Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 17/19] x86: Add initial memory barrier macros Simon Glass
2011-12-28  6:35 ` [U-Boot] [RFC PATCH 18/19] Bring in x86 to unified board architecture Simon Glass
2011-12-28  6:36 ` [U-Boot] [RFC PATCH 19/19] x86: Remove unused board/global_data code Simon Glass
2011-12-28 17:30 ` [U-Boot] [RFC PATCH 0/19] Create generic board init and move ARM and x86 to it Wolfgang Denk
2011-12-28 18:13   ` Simon Glass
2011-12-30 15:49 ` Graeme Russ
2011-12-31  0:03   ` Wolfgang Denk
2011-12-31  2:02   ` Simon Glass
2011-12-31 11:52     ` Graeme Russ
2012-01-01 23:48       ` Simon Glass
2012-01-02 11:26         ` Graeme Russ
2012-01-02 14:46           ` Wolfgang Denk
2012-01-03  5:33             ` Simon Glass
2012-01-03  8:12               ` Wolfgang Denk
2012-01-03  9:15                 ` Graeme Russ
2012-01-03 15:55                 ` Simon Glass
2012-01-03 22:35                   ` Wolfgang Denk
2012-01-03 22:52                     ` Simon Glass
2012-01-03  5:28           ` Simon Glass
2012-01-01  1:54     ` Wolfgang Denk
2012-01-01 23:47       ` Simon Glass
2012-01-02  6:50         ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325054160-24894-1-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.