README.generic-board 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # SPDX-License-Identifier: GPL-2.0+
  2. #
  3. # (C) Copyright 2014 Google, Inc
  4. # Simon Glass <sjg@chromium.org>
  5. Background
  6. ----------
  7. U-Boot traditionally had a board.c file for each architecture. This introduced
  8. quite a lot of duplication, with each architecture tending to do
  9. initialisation slightly differently. To address this, a new 'generic board
  10. init' feature was introduced in March 2013 (further motivation is
  11. provided in the cover letter below).
  12. All boards and architectures have moved to this as of mid 2016.
  13. What has changed?
  14. -----------------
  15. The main change is that the arch/<arch>/lib/board.c file is removed in
  16. favour of common/board_f.c (for pre-relocation init) and common/board_r.c
  17. (for post-relocation init).
  18. Related to this, the global_data and bd_info structures now have a core set of
  19. fields which are common to all architectures. Architecture-specific fields
  20. have been moved to separate structures.
  21. Further Background
  22. ------------------
  23. The full text of the original generic board series is reproduced below.
  24. --8<-------------
  25. This series creates a generic board.c implementation which contains
  26. the essential functions of the major arch/xxx/lib/board.c files.
  27. What is the motivation for this change?
  28. 1. There is a lot of repeated code in the board.c files. Any change to
  29. things like setting up the baud rate requires a change in 10 separate
  30. places.
  31. 2. Since there are 10 separate files, adding a new feature which requires
  32. initialisation is painful since it must be independently added in 10
  33. places.
  34. 3. As time goes by the architectures naturally diverge since there is limited
  35. pressure to compare features or even CONFIG options against similar things
  36. in other board.c files.
  37. 4. New architectures must implement all the features all over again, and
  38. sometimes in subtle different ways. This places an unfair burden on getting
  39. a new architecture fully functional and running with U-Boot.
  40. 5. While it is a bit of a tricky change, I believe it is worthwhile and
  41. achievable. There is no requirement that all code be common, only that
  42. the code that is common should be located in common/board.c rather than
  43. arch/xxx/lib/board.c.
  44. All the functions of board_init_f() and board_init_r() are broken into
  45. separate function calls so that they can easily be included or excluded
  46. for a particular architecture. It also makes it easier to adopt Graeme's
  47. initcall proposal when it is ready.
  48. http://lists.denx.de/pipermail/u-boot/2012-January/114499.html
  49. This series removes the dependency on generic relocation. So relocation
  50. happens as one big chunk and is still completely arch-specific. See the
  51. relocation series for a proposed solution to this for ARM:
  52. http://lists.denx.de/pipermail/u-boot/2011-December/112928.html
  53. or Graeme's recent x86 series v2:
  54. http://lists.denx.de/pipermail/u-boot/2012-January/114467.html
  55. Instead of moving over a whole architecture, this series takes the approach
  56. of simply enabling generic board support for an architecture. It is then up
  57. to each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board
  58. config file. If this is not done, then the code will be generated as
  59. before. This allows both sets of code to co-exist until we are comfortable
  60. with the generic approach, and enough boards run.
  61. ARM is a relatively large board.c file and one which I can test, therefore
  62. I think it is a good target for this series. On the other hand, x86 is
  63. relatively small and simple, but different enough that it introduces a
  64. few issues to be solved. So I have chosen both ARM and x86 for this series.
  65. After a suggestion from Wolfgang I have added PPC also. This is the
  66. largest and most feature-full board, so hopefully we have all bases
  67. covered in this RFC.
  68. A generic global_data structure is also required. This might upset a few
  69. people. Here is my basic reasoning: most fields are the same, all
  70. architectures include and need it, most global_data.h files already have
  71. #ifdefs to select fields for a particular SOC, so it is hard to
  72. see why architecures are different in this area. We can perhaps add a
  73. way to put architecture-specific fields into a separate header file, but
  74. for now I have judged that to be counter-productive.
  75. Similarly we need a generic bd_info structure, since generic code will
  76. be accessing it. I have done this in the same way as global_data and the
  77. same comments apply.
  78. There was dicussion on the list about passing gd_t around as a parameter
  79. to pre-relocation init functions. I think this makes sense, but it can
  80. be done as a separate change, and this series does not require it.
  81. While this series needs to stand on its own (as with the link script
  82. cleanup series and the generic relocation series) the goal is the
  83. unification of the board init code. So I hope we can address issues with
  84. this in mind, rather than focusing too narrowly on particular ARM, x86 or
  85. PPC issues.
  86. I have run-tested ARM on Tegra Seaboard only. To try it out, define
  87. CONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on
  88. x86 and PPC at least it will hang, but if you are lucky it will print
  89. something first :-)
  90. I have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all
  91. ARM, PPC and x86 boards. There are a few failures due to errors in
  92. the board config, which I have sent patches for. The main issue is
  93. just the difference between __bss_end and __bss_end__.
  94. Note: the first group of commits are required for this series to build,
  95. but could be separated out if required. I have included them here for
  96. convenience.
  97. ------------->8--
  98. Simon Glass, sjg@chromium.org
  99. March 2014
  100. Updated after final removal, May 2016