main.g 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. # This file is part of asmc, a bootstrapping OS with minimal seed
  2. # Copyright (C) 2018-2019 Giovanni Mascellani <gio@debian.org>
  3. # https://gitlab.com/giomasce/asmc
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. const TEST_ALL 1
  15. const TEST_MAP TEST_ALL
  16. const TEST_INT64 TEST_ALL
  17. const TEST_C TEST_ALL
  18. const RUN_MM0 1
  19. const RUN_ASM 0
  20. const RUN_FASM 0
  21. const RUN_C 0
  22. const RUN_MESCC 0
  23. const RUN_MCPP 0
  24. const RUN_TINYCC 1
  25. const USE_TRIVIAL_MALLOC 0
  26. const USE_SIMPLE_MALLOC 0
  27. const USE_CHECKED_MALLOC 0
  28. const USE_KMALLOC 1
  29. const USE_SIMPLE_MAP 0
  30. const USE_AVL_MAP 0
  31. const USE_RB_MAP 1
  32. fun main 0 {
  33. "Memory break after entering main: " log ;
  34. 0 platform_allocate itoa log ;
  35. "\n" log ;
  36. $compile_mm0
  37. $compile_asm
  38. $compile_int64
  39. $compile_c
  40. $compile_disk
  41. @compile_mm0 0 = ;
  42. @compile_asm 0 = ;
  43. @compile_int64 0 = ;
  44. @compile_c 0 = ;
  45. @compile_disk 0 = ;
  46. if RUN_MM0 {
  47. @compile_mm0 1 = ;
  48. }
  49. if RUN_ASM RUN_FASM || {
  50. @compile_asm 1 = ;
  51. }
  52. if RUN_C RUN_MCPP || RUN_TINYCC || TEST_C || {
  53. @compile_c 1 = ;
  54. }
  55. if TEST_INT64 {
  56. @compile_int64 1 = ;
  57. }
  58. if compile_c {
  59. @compile_int64 1 = ;
  60. @compile_disk 1 = ;
  61. }
  62. if compile_int64 {
  63. @compile_asm 1 = ;
  64. @compile_disk 1 = ;
  65. }
  66. if compile_asm {
  67. @compile_disk 1 = ;
  68. }
  69. "Compiling utils.g... " log ;
  70. "utils.g" platform_g_compile ;
  71. "done!\n" log ;
  72. "Compiling keyboard.g... " log ;
  73. "keyboard.g" platform_g_compile ;
  74. "done!\n" log ;
  75. if USE_TRIVIAL_MALLOC {
  76. "Compiling triv_malloc.g... " log ;
  77. "triv_malloc.g" platform_g_compile ;
  78. "done!\n" log ;
  79. }
  80. if USE_SIMPLE_MALLOC {
  81. "Compiling simple_malloc.g... " log ;
  82. "simple_malloc.g" platform_g_compile ;
  83. "done!\n" log ;
  84. }
  85. if USE_CHECKED_MALLOC {
  86. "Compiling check_malloc.g... " log ;
  87. "check_malloc.g" platform_g_compile ;
  88. "done!\n" log ;
  89. }
  90. if USE_KMALLOC {
  91. "Compiling kmalloc.g... " log ;
  92. "kmalloc.g" platform_g_compile ;
  93. "done!\n" log ;
  94. }
  95. "Compiling malloc_utils.g... " log ;
  96. "malloc_utils.g" platform_g_compile ;
  97. "done!\n" log ;
  98. "Compiling vector.g... " log ;
  99. "vector.g" platform_g_compile ;
  100. "done!\n" log ;
  101. if USE_SIMPLE_MAP {
  102. "Compiling map.g... " log ;
  103. "map.g" platform_g_compile ;
  104. "done!\n" log ;
  105. }
  106. if USE_AVL_MAP {
  107. "Compiling avl_map.g... " log ;
  108. "avl_map.g" platform_g_compile ;
  109. "done!\n" log ;
  110. }
  111. if USE_RB_MAP {
  112. "Compiling rb_map.g... " log ;
  113. "rb_map.g" platform_g_compile ;
  114. "done!\n" log ;
  115. }
  116. if TEST_MAP {
  117. "Compiling map_test.g... " log ;
  118. "map_test.g" platform_g_compile ;
  119. "done!\n" log ;
  120. }
  121. "Compiling utils2.g... " log ;
  122. "utils2.g" platform_g_compile ;
  123. "done!\n" log ;
  124. if compile_disk {
  125. "Compiling atapio.g... " log ;
  126. "atapio.g" platform_g_compile ;
  127. "done!\n" log ;
  128. "Compiling diskfs.g... " log ;
  129. "diskfs.g" platform_g_compile ;
  130. "done!\n" log ;
  131. "Compiling debugfs.g... " log ;
  132. "debugfs.g" platform_g_compile ;
  133. "done!\n" log ;
  134. "Compiling mbr.g... " log ;
  135. "mbr.g" platform_g_compile ;
  136. "done!\n" log ;
  137. }
  138. "Compiling ramfs.g... " log ;
  139. "ramfs.g" platform_g_compile ;
  140. "done!\n" log ;
  141. "Compiling vfs.g... " log ;
  142. "vfs.g" platform_g_compile ;
  143. "done!\n" log ;
  144. "Compiling vfs_utils.g... " log ;
  145. "vfs_utils.g" platform_g_compile ;
  146. "done!\n" log ;
  147. if compile_mm0 {
  148. "Compiling mm0.g... " log ;
  149. "mm0.g" platform_g_compile ;
  150. "done!\n" log ;
  151. }
  152. if compile_asm {
  153. #"Memory break before ASM assembler compilation: " log ;
  154. #0 platform_allocate itoa log ;
  155. #"\n" log ;
  156. "Compiling asm_regs.g... " log ;
  157. "asm_regs.g" platform_g_compile ;
  158. "done!\n" log ;
  159. "Compiling asm_preproc.g... " log ;
  160. "asm_preproc.g" platform_g_compile ;
  161. "done!\n" log ;
  162. "Compiling asm_opcodes.g... " log ;
  163. "asm_opcodes.g" platform_g_compile ;
  164. "done!\n" log ;
  165. "Compiling asm_compile.g... " log ;
  166. "asm_compile.g" platform_g_compile ;
  167. "done!\n" log ;
  168. #"Memory break after ASM assembler compilation: " log ;
  169. #0 platform_allocate itoa log ;
  170. #"\n" log ;
  171. }
  172. if compile_int64 {
  173. "Compiling int64.g... " log ;
  174. "int64.g" platform_g_compile ;
  175. "done!\n" log ;
  176. "Compiling int64_div.g... " log ;
  177. "int64_div.g" platform_g_compile ;
  178. "done!\n" log ;
  179. }
  180. if compile_c {
  181. "Compiling c_utils.g... " log ;
  182. "c_utils.g" platform_g_compile ;
  183. "done!\n" log ;
  184. "Compiling c_ast.g... " log ;
  185. "c_ast.g" platform_g_compile ;
  186. "done!\n" log ;
  187. "Compiling c_preproc.g... " log ;
  188. "c_preproc.g" platform_g_compile ;
  189. "done!\n" log ;
  190. "Compiling c_compile.g... " log ;
  191. "c_compile.g" platform_g_compile ;
  192. "done!\n" log ;
  193. "Compiling c_test.g... " log ;
  194. "c_test.g" platform_g_compile ;
  195. "done!\n" log ;
  196. }
  197. if RUN_MESCC {
  198. "Compiling mescc_hex2.g... " log ;
  199. "mescc_hex2.g" platform_g_compile ;
  200. "done!\n" log ;
  201. "Compiling mescc_m1.g... " log ;
  202. "mescc_m1.g" platform_g_compile ;
  203. "done!\n" log ;
  204. "Compiling mescc_m2.g... " log ;
  205. "mescc_m2.g" platform_g_compile ;
  206. "done!\n" log ;
  207. }
  208. "Memory break after compilers compilation: " log ;
  209. 0 platform_allocate itoa log ;
  210. "\n" log ;
  211. if TEST_MAP {
  212. 0 "map_test" platform_get_symbol \0 ;
  213. }
  214. "Initializing Virtual File System...\n" log ;
  215. compile_disk 0 "vfs_init" platform_get_symbol \1 ;
  216. "Virtual File System initialized!\n" log ;
  217. if compile_int64 {
  218. "Initializing support for int64...\n" log ;
  219. 0 "int64_init" platform_get_symbol \0 ;
  220. "Support for int64 initialized!\n" log ;
  221. }
  222. "Initializing resolve_symbol_ext...\n" log ;
  223. 0 "init_resolve_symbol_ext" platform_get_symbol \0 ;
  224. "done!\n" log ;
  225. if RUN_MM0 {
  226. "/init/set.mm0" 0 "mm0_process" platform_get_symbol \1 ;
  227. }
  228. if RUN_ASM {
  229. "/disk1/test/test.asm" 0 "parse_asm" platform_get_symbol \1 ;
  230. }
  231. if RUN_FASM {
  232. "Compiling fasm.g... " log ;
  233. "fasm.g" platform_g_compile ;
  234. "done!\n" log ;
  235. 0 "compile_fasm" platform_get_symbol \0 ;
  236. }
  237. if RUN_C {
  238. "/disk1/tests/test.c" 0 "parse_c" platform_get_symbol \1 ;
  239. }
  240. if TEST_INT64 {
  241. 0 "int64_test" platform_get_symbol \0 ;
  242. 0 "int64_test_div" platform_get_symbol \0 ;
  243. }
  244. if TEST_C {
  245. 0 "c_run_testcases" platform_get_symbol \0 ;
  246. }
  247. if RUN_MESCC {
  248. 0 "hex2_test" platform_get_symbol \0 ;
  249. 0 "m1_test" platform_get_symbol \0 ;
  250. 0 "m2_test" platform_get_symbol \0 ;
  251. 0 "m2_test_full_compilation" platform_get_symbol \0 ;
  252. }
  253. if RUN_MCPP {
  254. "Compiling mcpp.g... " log ;
  255. "mcpp.g" platform_g_compile ;
  256. "done!\n" log ;
  257. 0 "compile_mcpp" platform_get_symbol \0 ;
  258. }
  259. if RUN_TINYCC {
  260. "Compiling tinycc.g... " log ;
  261. "tinycc.g" platform_g_compile ;
  262. "done!\n" log ;
  263. 0 "compile_tinycc" platform_get_symbol \0 ;
  264. }
  265. if compile_int64 {
  266. "Destroying support for int64... " log ;
  267. 0 "int64_destroy" platform_get_symbol \0 ;
  268. "done!\n" log ;
  269. }
  270. "Destroying resolve_symbol_ext... " log ;
  271. 0 "destroy_resolve_symbol_ext" platform_get_symbol \0 ;
  272. "done!\n" log ;
  273. "Destroying Virtual File System... " log ;
  274. 0 "vfs_destroy" platform_get_symbol \0 ;
  275. "done!\n" log ;
  276. if compile_disk {
  277. "Destroying debugfs... " log ;
  278. 0 "debugfs_deinit" platform_get_symbol \0 ;
  279. "done!\n" log ;
  280. }
  281. "Top of initrd: " log ;
  282. $begin
  283. $end
  284. @begin @end "" platform_walk_initrd ;
  285. end itoa log ;
  286. "\n" log ;
  287. "Memory break before exiting main: " log ;
  288. 0 platform_allocate itoa log ;
  289. "\n" log ;
  290. 0 "malloc_stats" platform_get_symbol \0 ;
  291. }