parent
049b0d3053
commit
8cdc415417
@ -0,0 +1,125 @@
|
||||
-- SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
let Genode = env:DHALL_GENODE
|
||||
|
||||
let Prelude = Genode.Prelude
|
||||
|
||||
let BootModules = Genode.BootModules
|
||||
|
||||
let RomEntry = Prelude.Map.Entry Text BootModules.ROM.Type
|
||||
|
||||
let compile =
|
||||
λ(addressType : Text)
|
||||
→ λ(boot : Genode.Boot.Type)
|
||||
→ λ(out : Text)
|
||||
→ let NaturalIndex = { index : Natural, value : Text }
|
||||
|
||||
let TextIndex = { index : Text, value : Text }
|
||||
|
||||
let moduleKeys =
|
||||
Prelude.Map.keys Text BootModules.ROM.Type boot.rom # [ "config" ]
|
||||
|
||||
let moduleValues =
|
||||
let f =
|
||||
λ(e : RomEntry)
|
||||
→ merge
|
||||
{ RomText = λ(text : Text) → ".ascii ${Text/show text}"
|
||||
, RomPath = λ(path : Text) → ".incbin ${Text/show path}"
|
||||
}
|
||||
e.mapValue
|
||||
|
||||
in Prelude.List.map RomEntry Text f boot.rom
|
||||
# [ ".incbin \"${out}/config\"" ]
|
||||
|
||||
let map =
|
||||
λ(list : List Text)
|
||||
→ λ(f : TextIndex → Text)
|
||||
→ let indexedNatural = Prelude.List.indexed Text list
|
||||
|
||||
let indexed =
|
||||
Prelude.List.map
|
||||
NaturalIndex
|
||||
TextIndex
|
||||
( λ(x : NaturalIndex)
|
||||
→ { index = Prelude.Natural.show x.index
|
||||
, value = x.value
|
||||
}
|
||||
)
|
||||
indexedNatural
|
||||
|
||||
let texts = Prelude.List.map TextIndex Text f indexed
|
||||
|
||||
in Prelude.Text.concatSep "\n" texts
|
||||
|
||||
let mapNames = map moduleKeys
|
||||
|
||||
let mapValues = map moduleValues
|
||||
|
||||
let asm =
|
||||
''
|
||||
.set MIN_PAGE_SIZE_LOG2, 12
|
||||
.set DATA_ACCESS_ALIGNM_LOG2, 3
|
||||
|
||||
.section .data
|
||||
|
||||
.p2align DATA_ACCESS_ALIGNM_LOG2
|
||||
.global _boot_modules_headers_begin
|
||||
_boot_modules_headers_begin:
|
||||
|
||||
''
|
||||
++ mapNames
|
||||
( λ(m : TextIndex)
|
||||
→ ''
|
||||
${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:
|
||||
|
||||
''
|
||||
++ mapNames
|
||||
( λ(m : TextIndex)
|
||||
→ ''
|
||||
.p2align DATA_ACCESS_ALIGNM_LOG2
|
||||
_boot_module_${m.index}_name:
|
||||
.string "${m.value}"
|
||||
.byte 0
|
||||
|
||||
''
|
||||
)
|
||||
++ ''
|
||||
.section .data.boot_modules_binaries
|
||||
|
||||
.global _boot_modules_binaries_begin
|
||||
_boot_modules_binaries_begin:
|
||||
|
||||
''
|
||||
++ 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 { config = Genode.Init.render boot.config
|
||||
, modules_asm = asm
|
||||
, stats =
|
||||
let sum = Genode.Init.resources boot.config
|
||||
|
||||
in "RAM=${Prelude.Natural.show sum.ram}"
|
||||
}
|
||||
|
||||
let funcs = { to32bitImage = compile ".long", to64bitImage = compile ".quad" }
|
||||
|
||||
in funcs.to64bitImage
|
@ -0,0 +1,42 @@
|
||||
-- SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
let Genode = env:DHALL_GENODE
|
||||
|
||||
let Prelude = Genode.Prelude
|
||||
|
||||
let Args = { config : Genode.Init.Type, rom : Genode.BootModules.Type } : Type
|
||||
|
||||
let RomEntry = Prelude.Map.Entry Text Genode.BootModules.ROM.Type
|
||||
|
||||
let addLine =
|
||||
λ(e : RomEntry)
|
||||
→ λ(script : Text)
|
||||
→ merge
|
||||
{ RomText =
|
||||
λ(rom : Text)
|
||||
→ ''
|
||||
${script}
|
||||
echo ${Text/show rom} > ${Text/show e.mapKey}
|
||||
''
|
||||
, RomPath =
|
||||
λ(rom : Text)
|
||||
→ ''
|
||||
${script}
|
||||
ln -s ${Text/show rom} ${Text/show e.mapKey}
|
||||
''
|
||||
}
|
||||
e.mapValue
|
||||
|
||||
in λ(args : Args) -> \(out : Text)
|
||||
→
|
||||
{ config = Genode.Init.render args.config
|
||||
, script = Prelude.List.fold
|
||||
RomEntry
|
||||
args.rom
|
||||
Text
|
||||
addLine
|
||||
''
|
||||
#!/bin/sh
|
||||
ln -s ${out}/config config
|
||||
''
|
||||
}
|
@ -1,75 +1,5 @@
|
||||
#!/usr/bin/env expect
|
||||
|
||||
##
|
||||
# Generate assembly code aggregating boot-module data from specified files.
|
||||
#
|
||||
proc generate_boot_modules_asm {modules} {
|
||||
|
||||
# architecture dependent definitions
|
||||
set address_type ".quad"
|
||||
|
||||
# header
|
||||
set asm_src {}
|
||||
append asm_src ".set MIN_PAGE_SIZE_LOG2, 12\n"
|
||||
append asm_src ".set DATA_ACCESS_ALIGNM_LOG2, 3\n"
|
||||
append asm_src "\n"
|
||||
append asm_src ".section .data\n"
|
||||
append asm_src "\n"
|
||||
append asm_src ".p2align DATA_ACCESS_ALIGNM_LOG2\n"
|
||||
append asm_src ".global _boot_modules_headers_begin\n"
|
||||
append asm_src "_boot_modules_headers_begin:\n"
|
||||
append asm_src "\n"
|
||||
|
||||
# module list
|
||||
set i 0
|
||||
foreach module $modules {
|
||||
incr i
|
||||
append asm_src "${address_type} _boot_module_${i}_name\n"
|
||||
append asm_src "${address_type} _boot_module_${i}_begin\n"
|
||||
append asm_src "${address_type} _boot_module_${i}_end -"
|
||||
append asm_src " _boot_module_${i}_begin\n"
|
||||
append asm_src "\n"
|
||||
}
|
||||
append asm_src ".global _boot_modules_headers_end\n"
|
||||
append asm_src "_boot_modules_headers_end:\n"
|
||||
append asm_src "\n"
|
||||
|
||||
# module names
|
||||
set i 0
|
||||
foreach module $modules {
|
||||
incr i
|
||||
append asm_src ".p2align DATA_ACCESS_ALIGNM_LOG2\n"
|
||||
append asm_src "_boot_module_${i}_name:\n"
|
||||
append asm_src ".string \"${module}\"\n"
|
||||
append asm_src ".byte 0\n"
|
||||
append asm_src "\n"
|
||||
}
|
||||
|
||||
# header end
|
||||
append asm_src ".section .data.boot_modules_binaries\n"
|
||||
append asm_src "\n"
|
||||
append asm_src ".global _boot_modules_binaries_begin\n"
|
||||
append asm_src "_boot_modules_binaries_begin:\n"
|
||||
append asm_src "\n"
|
||||
|
||||
# module data
|
||||
set i 0
|
||||
foreach module $modules {
|
||||
incr i
|
||||
append asm_src ".p2align MIN_PAGE_SIZE_LOG2\n"
|
||||
append asm_src "_boot_module_${i}_begin:\n"
|
||||
append asm_src ".incbin \"${module}\"\n"
|
||||
append asm_src "_boot_module_${i}_end:\n"
|
||||
append asm_src "\n"
|
||||
}
|
||||
|
||||
append asm_src ".p2align MIN_PAGE_SIZE_LOG2\n"
|
||||
append asm_src ".global _boot_modules_binaries_end\n"
|
||||
append asm_src "_boot_modules_binaries_end:\n"
|
||||
|
||||
return $asm_src
|
||||
}
|
||||
|
||||
eval $env(baseSetup)
|
||||
|
||||
eval $env(testScript)
|
||||
|
Loading…
Reference in new issue