build.ck 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. PandaBoard UEFI Firmware
  5. Abstract:
  6. This module implements UEFI firmware for the TI PandaBoard.
  7. Author:
  8. Evan Green 19-Dec-2014
  9. Environment:
  10. Firmware
  11. --*/
  12. function build() {
  13. plat = "panda";
  14. text_address = "0x82000000";
  15. sources = [
  16. "armv7/entry.S",
  17. "armv7/smpa.S",
  18. "debug.c",
  19. "fwvol.c",
  20. "//uefi/plat/panda/init:id.o",
  21. "intr.c",
  22. "main.c",
  23. "memmap.c",
  24. "omap4usb.c",
  25. ":" + plat + "fwv.o",
  26. "ramdenum.c",
  27. "sd.c",
  28. "serial.c",
  29. "smbios.c",
  30. "smp.c",
  31. "timer.c",
  32. "video.c"
  33. ];
  34. includes = [
  35. "$//uefi/include"
  36. ];
  37. sources_config = {
  38. "CFLAGS": ["-fshort-wchar"]
  39. };
  40. link_ldflags = [
  41. "-nostdlib",
  42. "-Wl,--no-wchar-size-warning",
  43. "-static"
  44. ];
  45. link_config = {
  46. "LDFLAGS": link_ldflags
  47. };
  48. platfw = plat + "fw";
  49. platfw_usb = platfw + "_usb";
  50. libfw = "lib" + platfw;
  51. libfw_target = ":" + libfw;
  52. common_libs = [
  53. "//uefi/core:ueficore",
  54. "//kernel/kd:kdboot",
  55. "//uefi/core:ueficore",
  56. "//uefi/archlib:uefiarch",
  57. "//lib/fatlib:fat",
  58. "//lib/basevid:basevid",
  59. "//lib/rtl/kmode:krtl",
  60. "//lib/rtl/base:basertlb",
  61. "//kernel/kd/kdusb:kdnousb",
  62. "//kernel:archboot",
  63. ];
  64. libs = [
  65. libfw_target,
  66. "//uefi/dev/gic:gic",
  67. "//uefi/dev/sd/core:sd",
  68. "//uefi/dev/omap4:omap4",
  69. "//uefi/dev/omapuart:omapuart",
  70. ];
  71. libs += common_libs + [libfw_target];
  72. fw_lib = {
  73. "label": libfw,
  74. "inputs": sources,
  75. "sources_config": sources_config
  76. };
  77. entries = static_library(fw_lib);
  78. elf = {
  79. "label": platfw + ".elf",
  80. "inputs": libs + ["//uefi/core:emptyrd"],
  81. "sources_config": sources_config,
  82. "includes": includes,
  83. "config": link_config
  84. };
  85. entries += executable(elf);
  86. usb_elf = {
  87. "label": platfw_usb + ".elf",
  88. "inputs": [":ramdisk.o"] + libs,
  89. "sources_config": sources_config,
  90. "includes": includes,
  91. "config": link_config
  92. };
  93. entries += executable(usb_elf);
  94. //
  95. // Build the firmware volume.
  96. //
  97. ffs = [
  98. "//uefi/core/runtime:rtbase.ffs",
  99. "//uefi/plat/" + plat + "/runtime:" + plat + "rt.ffs",
  100. "//uefi/plat/" + plat + "/acpi:acpi.ffs"
  101. ];
  102. fw_volume = uefi_fwvol_o(plat, ffs);
  103. entries += fw_volume;
  104. //
  105. // Flatten the firmware image and convert to u-boot.
  106. //
  107. flattened = {
  108. "label": platfw + ".bin",
  109. "inputs": [":" + platfw + ".elf"]
  110. };
  111. flattened = flattened_binary(flattened);
  112. entries += flattened;
  113. flattened_usb = {
  114. "label": platfw_usb + ".bin",
  115. "inputs": [":" + platfw_usb + ".elf"]
  116. };
  117. flattened_usb = flattened_binary(flattened_usb);
  118. entries += flattened_usb;
  119. uboot_config = {
  120. "TEXT_ADDRESS": text_address,
  121. "MKUBOOT_FLAGS": "-c -a arm -f legacy"
  122. };
  123. uboot = {
  124. "label": platfw,
  125. "inputs": [":" + platfw + ".bin"],
  126. "orderonly": ["//uefi/tools/mkuboot:mkuboot"],
  127. "tool": "mkuboot",
  128. "config": uboot_config,
  129. "nostrip": TRUE
  130. };
  131. entries += binplace(uboot);
  132. uboot_usb = {
  133. "label": "pandausb.img",
  134. "inputs": [":" + platfw_usb + ".bin"],
  135. "orderonly": ["//uefi/tools/mkuboot:mkuboot"],
  136. "tool": "mkuboot",
  137. "config": uboot_config,
  138. "nostrip": TRUE
  139. };
  140. entries += binplace(uboot_usb);
  141. //
  142. // Create the RAM disk image. Debugging is always enabled in these RAM disk
  143. // images since they're only used for development.
  144. //
  145. msetup_flags = [
  146. "-q",
  147. "-G30M",
  148. "-lpanda-usb",
  149. "-i$" + binroot + "/install.img",
  150. "-D"
  151. ];
  152. entry = {
  153. "type": "target",
  154. "tool": "msetup_image",
  155. "label": "ramdisk",
  156. "output": "ramdisk",
  157. "inputs": ["//images:install.img"],
  158. "config": {"MSETUP_FLAGS": msetup_flags}
  159. };
  160. entries += [entry];
  161. //
  162. // Create the RAM disk for the USB version. The manual override of
  163. // OBJCOPY_FLAGS back to their default is needed because make applies
  164. // variable overrides to all prerequisites of a target. So some
  165. // OBJCOPY_FLAGS on an upper prerequisite would apply here.
  166. //
  167. ramdisk_o = {
  168. "type": "target",
  169. "label": "ramdisk.o",
  170. "inputs": [":ramdisk"],
  171. "tool": "objcopy",
  172. "config": {"OBJCOPY_FLAGS": global_config["OBJCOPY_FLAGS"]}
  173. };
  174. entries += [ramdisk_o];
  175. return entries;
  176. }
  177. return build();