Genode Packages collection https://git.sr.ht/~ehmry/genodepkgs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compile-boot.dhall 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. let Genode = env:DHALL_GENODE
  2. let Prelude = Genode.Prelude
  3. let BootModules = Genode.BootModules
  4. let RomEntry = Prelude.Map.Entry Text BootModules.ROM.Type
  5. let compile =
  6. λ(addressType : Text)
  7. → λ(boot : Genode.Boot.Type)
  8. → λ(out : Text)
  9. → let NaturalIndex = { index : Natural, value : Text }
  10. let TextIndex = { index : Text, value : Text }
  11. let moduleKeys =
  12. Prelude.Map.keys Text BootModules.ROM.Type boot.rom # [ "config" ]
  13. let moduleValues =
  14. let f =
  15. λ(e : RomEntry)
  16. → merge
  17. { RomText = λ(text : Text) → ".ascii ${Text/show text}"
  18. , RomPath = λ(path : Text) → ".incbin ${Text/show path}"
  19. }
  20. e.mapValue
  21. in Prelude.List.map RomEntry Text f boot.rom
  22. # [ ".incbin \"${out}/config\"" ]
  23. let map =
  24. λ(list : List Text)
  25. → λ(f : TextIndex → Text)
  26. → let indexedNatural = Prelude.List.indexed Text list
  27. let indexed =
  28. Prelude.List.map
  29. NaturalIndex
  30. TextIndex
  31. ( λ(x : NaturalIndex)
  32. → { index = Prelude.Natural.show x.index
  33. , value = x.value
  34. }
  35. )
  36. indexedNatural
  37. let texts = Prelude.List.map TextIndex Text f indexed
  38. in Prelude.Text.concatSep "\n" texts
  39. let mapNames = map moduleKeys
  40. let mapValues = map moduleValues
  41. let asm =
  42. ''
  43. .set MIN_PAGE_SIZE_LOG2, 12
  44. .set DATA_ACCESS_ALIGNM_LOG2, 3
  45. .section .data
  46. .p2align DATA_ACCESS_ALIGNM_LOG2
  47. .global _boot_modules_headers_begin
  48. _boot_modules_headers_begin:
  49. ''
  50. ++ mapNames
  51. ( λ(m : TextIndex)
  52. → ''
  53. ${addressType} _boot_module_${m.index}_name
  54. ${addressType} _boot_module_${m.index}_begin
  55. ${addressType} _boot_module_${m.index}_end - _boot_module_${m.index}_begin
  56. ''
  57. )
  58. ++ ''
  59. .global _boot_modules_headers_end
  60. _boot_modules_headers_end:
  61. ''
  62. ++ mapNames
  63. ( λ(m : TextIndex)
  64. → ''
  65. .p2align DATA_ACCESS_ALIGNM_LOG2
  66. _boot_module_${m.index}_name:
  67. .string "${m.value}"
  68. .byte 0
  69. ''
  70. )
  71. ++ ''
  72. .section .data.boot_modules_binaries
  73. .global _boot_modules_binaries_begin
  74. _boot_modules_binaries_begin:
  75. ''
  76. ++ mapValues
  77. ( λ(m : TextIndex)
  78. → ''
  79. .p2align MIN_PAGE_SIZE_LOG2
  80. _boot_module_${m.index}_begin:
  81. ${m.value}
  82. _boot_module_${m.index}_end:
  83. ''
  84. )
  85. ++ ''
  86. .p2align MIN_PAGE_SIZE_LOG2
  87. .global _boot_modules_binaries_end
  88. _boot_modules_binaries_end:
  89. ''
  90. in { config = Genode.Init.render boot.config
  91. , modules_asm = asm
  92. , stats =
  93. let sum = Genode.Init.resources boot.config
  94. in "RAM=${Prelude.Natural.show sum.ram}"
  95. }
  96. let funcs = { to32bitImage = compile ".long", to64bitImage = compile ".quad" }
  97. in funcs.to64bitImage