2
0
Fork 0
genodepkgs/apps/modules.as.dhall

111 lines
3.5 KiB
Plaintext
Raw Normal View History

2020-01-17 01:24:34 +01:00
let Genode = env:DHALL_GENODE
let Prelude = Genode.Prelude
let BootModules = Genode.BootModules
let RomEntry = Prelude.Map.Entry Text BootModules.ROM.Type
2020-01-27 01:54:43 +01:00
let compile =
λ(addressType : Text)
→ λ(rom : Prelude.Map.Type Text BootModules.ROM.Type)
→ let NaturalIndex = { index : Natural, value : Text }
2020-01-27 01:54:43 +01:00
let TextIndex = { index : Text, value : Text }
let moduleKeys = Prelude.Map.keys Text BootModules.ROM.Type rom
2020-01-27 01:54:43 +01:00
let moduleValues =
let f =
λ(e : RomEntry)
→ merge
{ RomText = λ(text : Text) → ".ascii ${Text/show text}"
, RomPath = λ(path : Text) → ".incbin ${Text/show path}"
}
e.mapValue
2020-01-27 01:54:43 +01:00
in Prelude.List.map RomEntry Text f rom
2020-01-27 01:54:43 +01:00
let map =
λ(list : List Text)
→ λ(f : TextIndex → Text)
→ let indexedNatural = Prelude.List.indexed Text list
2020-01-27 01:54:43 +01:00
let indexed =
Prelude.List.map
NaturalIndex
TextIndex
( λ(x : NaturalIndex)
→ { index = Prelude.Natural.show x.index
, value = x.value
}
)
indexedNatural
2020-01-27 01:54:43 +01:00
let texts = Prelude.List.map TextIndex Text f indexed
2020-01-27 01:54:43 +01:00
in Prelude.Text.concatSep "\n" texts
2020-01-27 01:54:43 +01:00
let mapNames = map moduleKeys
2020-01-27 01:54:43 +01:00
let mapValues = map moduleValues
2020-01-27 01:54:43 +01:00
in ''
.set MIN_PAGE_SIZE_LOG2, 12
.set DATA_ACCESS_ALIGNM_LOG2, 3
2020-01-27 01:54:43 +01:00
.section .data
2020-01-27 01:54:43 +01:00
.p2align DATA_ACCESS_ALIGNM_LOG2
.global _boot_modules_headers_begin
_boot_modules_headers_begin:
2020-01-27 01:54:43 +01:00
''
++ mapNames
( λ(m : TextIndex)
2020-01-27 01:54:43 +01:00
→ ''
${addressType} _boot_module_${m.index}_name
${addressType} _boot_module_${m.index}_begin
${addressType} _boot_module_${m.index}_end - _boot_module_${m.index}_begin
''
)
++ ''
.global _boot_modules_headers_end
_boot_modules_headers_end:
2020-01-27 01:54:43 +01:00
''
++ mapNames
( λ(m : TextIndex)
→ ''
.p2align DATA_ACCESS_ALIGNM_LOG2
_boot_module_${m.index}_name:
.string "${m.value}"
.byte 0
2020-01-27 01:54:43 +01:00
''
)
++ ''
.section .data.boot_modules_binaries
2020-01-27 01:54:43 +01:00
.global _boot_modules_binaries_begin
_boot_modules_binaries_begin:
2020-01-27 01:54:43 +01:00
''
++ mapValues
( λ(m : TextIndex)
→ ''
.p2align MIN_PAGE_SIZE_LOG2
_boot_module_${m.index}_begin:
${m.value}
_boot_module_${m.index}_end:
''
)
++ ''
.p2align MIN_PAGE_SIZE_LOG2
.global _boot_modules_binaries_end
_boot_modules_binaries_end:
''
in { to32bitImage = compile ".long", to64bitImage = compile ".quad" }