build.ck 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*++
  2. Copyright (c) 2012 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. Kernel
  9. Abstract:
  10. This is the core of the operating system.
  11. Author:
  12. Evan Green 26-Jul-2012
  13. Environment:
  14. Kernel
  15. --*/
  16. from menv import kernelLibrary, copy, driver, createVersionHeader, mconfig;
  17. function build() {
  18. var arch = mconfig.arch;
  19. var archSources;
  20. var armSources;
  21. var baseSources;
  22. var binroot = mconfig.binroot;
  23. var bootArchLib;
  24. var bootArchSources;
  25. var entries;
  26. var kernel;
  27. var kernelConfig;
  28. var kernelLibs;
  29. var versionConfig;
  30. var versionFile;
  31. var versionMajor;
  32. var versionMinor;
  33. var versionRevision;
  34. baseSources = [
  35. "init.c"
  36. ];
  37. if ((arch == "armv7") || (arch == "armv6")) {
  38. armSources = [
  39. "armv7/commsup.S",
  40. "armv7/inttable.S",
  41. "armv7/prochw.c",
  42. "armv7/sstep.c",
  43. "armv7/trap.S",
  44. "armv7/vfp.c"
  45. ];
  46. bootArchSources = [":armv7/sstep.o"];
  47. if (arch == "armv7") {
  48. archSources = armSources + [
  49. "armv7/archsup.S",
  50. "armv7/archsupc.c"
  51. ];
  52. } else {
  53. archSources = armSources + [
  54. "armv6/archsup.S",
  55. "armv6/archsupc.c"
  56. ];
  57. }
  58. } else if (arch == "x86") {
  59. archSources = [
  60. "x86/archsup.S",
  61. "x86/archsupc.c",
  62. "x86/prochw.c",
  63. "x86/trap.S"
  64. ];
  65. } else if (arch == "x64") {
  66. archSources = [
  67. "x64/archsup.S",
  68. "x64/archsupc.c",
  69. "x64/prochw.c",
  70. "x64/trap.S"
  71. ];
  72. }
  73. kernelLibs = [
  74. "kernel/acpi:acpi",
  75. "lib/crypto:crypto",
  76. "kernel/ob:ob",
  77. "lib/rtl/base:basertl",
  78. "lib/rtl/kmode:krtl",
  79. "lib/im:imn",
  80. "lib/basevid:basevid",
  81. "lib/termlib:termlib",
  82. "kernel/kd:kd",
  83. "kernel/kd/kdusb:kdusb",
  84. "kernel/ps:ps",
  85. "kernel/ke:ke",
  86. "kernel/io:io",
  87. "kernel/hl:hl",
  88. "kernel/mm:mm",
  89. "kernel/sp:sp"
  90. ];
  91. kernelConfig = {
  92. "LDFLAGS": ["-Wl,--whole-archive"]
  93. };
  94. kernel = {
  95. "label": "kernel",
  96. "inputs": baseSources + archSources + kernelLibs,
  97. "implicit": [":kernel-version"],
  98. "entry": "KepStartSystem",
  99. "config": kernelConfig
  100. };
  101. bootArchLib = {
  102. "label": "archboot",
  103. "inputs": bootArchSources
  104. };
  105. entries = driver(kernel);
  106. if (bootArchSources) {
  107. entries += kernelLibrary(bootArchLib);
  108. }
  109. //
  110. // Copy the config files.
  111. //
  112. entries += copy("config/dev2drv.set",
  113. binroot + "/dev2drv.set",
  114. "dev2drv.set",
  115. null,
  116. null);
  117. entries += copy("config/devmap.set",
  118. binroot + "/devmap.set",
  119. "devmap.set",
  120. null,
  121. null);
  122. entries += copy("config/init.set",
  123. binroot + "/init.set",
  124. "init.set",
  125. null,
  126. null);
  127. entries += copy("config/init.sh",
  128. binroot + "/init.sh",
  129. "init.sh",
  130. null,
  131. null);
  132. //
  133. // Create the version header.
  134. //
  135. versionMajor = "0";
  136. versionMinor = "4";
  137. versionRevision = "1";
  138. entries += createVersionHeader(versionMajor,
  139. versionMinor,
  140. versionRevision);
  141. //
  142. // Also create a version file in the binroot.
  143. //
  144. versionConfig = {
  145. "MAJOR": versionMajor,
  146. "MINOR": versionMinor,
  147. "REVISION": versionRevision,
  148. "FORM": "simple"
  149. };
  150. versionFile = {
  151. "type": "target",
  152. "label": "kernel-version",
  153. "output": binroot + "/kernel-version",
  154. "tool": "gen_version",
  155. "config": versionConfig
  156. };
  157. entries += [versionFile];
  158. return entries;
  159. }