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.

root.dhall 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. let Genode = env:DHALL_GENODE
  2. let Prelude = Genode.Prelude
  3. let XML = Prelude.XML
  4. let Init = Genode.Init
  5. let Child = Init.Child
  6. let Resources = Init.Resources
  7. let ServiceRoute = Init.ServiceRoute
  8. let Policy = Init.Config.Policy
  9. let DefaultPolicy = Init.Config.DefaultPolicy
  10. let LabelSelector = Init.LabelSelector
  11. let label =
  12. λ(label : Text)
  13. → { local = label, route = label } : Child.Attributes.Label
  14. let rootInit =
  15. λ ( params
  16. : { fbDriver : Init.Child.Type
  17. , guests : Init.Children.Type
  18. , inputFilterChargens : List XML.Type
  19. , partitionType : Text
  20. , wm : Init.Type
  21. , graphical-log : Init.Type
  22. , fs-log : Init.Type
  23. , systemLabel : Text
  24. }
  25. )
  26. → Init::{
  27. , children = toMap
  28. { timer =
  29. Child.flat
  30. Child.Attributes::{
  31. , binary = "timer_drv"
  32. , provides = [ "Timer" ]
  33. }
  34. , rtc =
  35. Child.flat
  36. Child.Attributes::{
  37. , binary = "rtc_drv"
  38. , provides = [ "Rtc" ]
  39. , routes =
  40. [ ServiceRoute.parent "IO_PORT"
  41. , ServiceRoute.parent "IO_MEM"
  42. ]
  43. }
  44. , acpi_drv =
  45. Child.flat
  46. Child.Attributes::{
  47. , binary = "acpi_drv"
  48. , priority = 1
  49. , resources = Resources::{
  50. , caps = 350
  51. , ram = Genode.units.MiB 4
  52. }
  53. , romReports = [ label "acpi", label "smbios_table" ]
  54. , routes = [ ServiceRoute.parent "IO_MEM" ]
  55. }
  56. , platform_drv =
  57. Child.flat
  58. Child.Attributes::{
  59. , binary = "platform_drv"
  60. , resources = Resources::{
  61. , caps = 400
  62. , ram = Genode.units.MiB 4
  63. , constrainPhys = True
  64. }
  65. , reportRoms = [ label "acpi" ]
  66. , romReports = [ label "pci" ]
  67. , provides = [ "Acpi", "Platform" ]
  68. , routes =
  69. [ ServiceRoute.parent "IRQ"
  70. , ServiceRoute.parent "IO_MEM"
  71. , ServiceRoute.parent "IO_PORT"
  72. , ServiceRoute.parentLabel
  73. "ROM"
  74. (Some "system")
  75. (Some "system")
  76. ]
  77. , config = Init.Config::{
  78. , attributes = toMap { system = "yes" }
  79. , content =
  80. let PciPolicy/Type =
  81. { labelSuffix : Text, pciClass : Text }
  82. in [ XML.text
  83. ''
  84. <report pci="yes"/>
  85. <policy label_suffix="ps2_drv">
  86. <device name="PS2"/>
  87. </policy>
  88. <policy label_suffix="intel_fb_drv">
  89. <pci class="VGA"/>
  90. <pci bus="0" device="0" function="0"/>
  91. <pci class="ISABRIDGE"/>
  92. </policy>
  93. <policy label_suffix="audio">
  94. <pci class="AUDIO"/>
  95. <pci class="HDAUDIO"/>
  96. </policy>
  97. <policy label="acpica"/>
  98. ''
  99. ]
  100. # Prelude.List.map
  101. PciPolicy/Type
  102. XML.Type
  103. ( λ(policy : PciPolicy/Type)
  104. → XML.element
  105. { name = "policy"
  106. , attributes = toMap
  107. { label_suffix = policy.labelSuffix }
  108. , content =
  109. [ XML.leaf
  110. { name = "pci"
  111. , attributes = toMap
  112. { class = policy.pciClass }
  113. }
  114. ]
  115. }
  116. )
  117. [ { labelSuffix = "ahci_drv"
  118. , pciClass = "AHCI"
  119. }
  120. , { labelSuffix = "nic_drv"
  121. , pciClass = "ETHERNET"
  122. }
  123. , { labelSuffix = "usb_drv", pciClass = "USB" }
  124. , { labelSuffix = "vesa_fb_drv"
  125. , pciClass = "VGA"
  126. }
  127. ]
  128. }
  129. }
  130. , framebuffer = params.fbDriver
  131. , input_filter =
  132. Child.flat
  133. Child.Attributes::{
  134. , binary = "input_filter"
  135. , config =
  136. let key =
  137. λ(name : Text)
  138. → XML.leaf
  139. { name = "key"
  140. , attributes = toMap { name = name }
  141. }
  142. let remap =
  143. λ(name : Text)
  144. → λ(to : Text)
  145. → XML.leaf
  146. { name = "key"
  147. , attributes = toMap { name = name, to = to }
  148. }
  149. in Init.Config::{
  150. , content =
  151. [ XML.leaf
  152. { name = "input"
  153. , attributes = toMap { label = "ps2" }
  154. }
  155. , XML.leaf
  156. { name = "input"
  157. , attributes = toMap { label = "usb" }
  158. }
  159. , XML.element
  160. { name = "output"
  161. , attributes = XML.emptyAttributes
  162. , content =
  163. [ XML.element
  164. { name = "chargen"
  165. , attributes = XML.emptyAttributes
  166. , content =
  167. [ XML.element
  168. { name = "remap"
  169. , attributes =
  170. XML.emptyAttributes
  171. , content =
  172. [ remap
  173. "KEY_LEFTMETA"
  174. "KEY_SCREEN"
  175. , XML.element
  176. { name = "merge"
  177. , attributes =
  178. XML.emptyAttributes
  179. , content =
  180. [ XML.leaf
  181. { name = "input"
  182. , attributes = toMap
  183. { name = "ps2" }
  184. }
  185. , XML.leaf
  186. { name = "input"
  187. , attributes = toMap
  188. { name = "usb" }
  189. }
  190. ]
  191. }
  192. ]
  193. }
  194. , XML.element
  195. { name = "mod1"
  196. , attributes =
  197. XML.emptyAttributes
  198. , content =
  199. [ key "KEY_LEFTSHIFT"
  200. , key "KEY_RIGHTSHIFT"
  201. ]
  202. }
  203. , XML.element
  204. { name = "mod2"
  205. , attributes =
  206. XML.emptyAttributes
  207. , content =
  208. [ key "KEY_LEFTCTRL"
  209. , key "KEY_RIGHTCTRL"
  210. ]
  211. }
  212. , XML.element
  213. { name = "mod3"
  214. , attributes =
  215. XML.emptyAttributes
  216. , content =
  217. [ key "KEY_RIGHTALT" ]
  218. }
  219. ]
  220. # params.inputFilterChargens
  221. }
  222. ]
  223. }
  224. ]
  225. }
  226. , provides = [ "Input" ]
  227. , routes =
  228. [ ServiceRoute.parentLabel
  229. "ROM"
  230. (Some "config")
  231. (Some "config -> input_filter.config")
  232. , ServiceRoute.childLabel
  233. "Input"
  234. "ps2_drv"
  235. (Some "ps2")
  236. (None Text)
  237. , ServiceRoute.childLabel
  238. "Input"
  239. "usb_drv"
  240. (Some "usb")
  241. (None Text)
  242. ]
  243. }
  244. , ps2_drv =
  245. Child.flat
  246. Child.Attributes::{
  247. , binary = "ps2_drv"
  248. , provides = [ "Input" ]
  249. , routes =
  250. [ ServiceRoute.childLabel
  251. "Platform"
  252. "platform_drv"
  253. (None Text)
  254. (Some "ps2_drv")
  255. ]
  256. }
  257. , usb_drv =
  258. Child.flat
  259. Child.Attributes::{
  260. , binary = "usb_drv"
  261. , config = Init.Config::{
  262. , attributes = toMap
  263. { uhci = "yes"
  264. , ohci = "yes"
  265. , ehci = "yes"
  266. , xhci = "yes"
  267. , bios_handoff = "yes"
  268. }
  269. , content =
  270. [ XML.leaf
  271. { name = "hid", attributes = XML.emptyAttributes }
  272. ]
  273. }
  274. , provides = [ "Input" ]
  275. , resources = Init.Resources::{
  276. , caps = 128
  277. , ram = Genode.units.MiB 12
  278. }
  279. , routes =
  280. [ ServiceRoute.childLabel
  281. "Platform"
  282. "platform_drv"
  283. (None Text)
  284. (Some "usb_drv")
  285. ]
  286. }
  287. , wm =
  288. Init.toChild
  289. params.wm
  290. Init.Attributes::{
  291. , provides = [ "Nitpicker", "Report", "ROM" ]
  292. , romReports = [ label "clipboard", label "shape" ]
  293. , routes =
  294. [ ServiceRoute.child "Framebuffer" "framebuffer"
  295. , ServiceRoute.child "Input" "input_filter"
  296. ]
  297. }
  298. , fonts_fs =
  299. Child.flat
  300. Child.Attributes::{
  301. , binary = "vfs"
  302. , config = Init.Config::{
  303. , content =
  304. [ XML.element
  305. { name = "vfs"
  306. , attributes = XML.emptyAttributes
  307. , content =
  308. [ XML.leaf
  309. { name = "rom"
  310. , attributes = toMap
  311. { name = "Inconsolata.ttf" }
  312. }
  313. , XML.element
  314. { name = "dir"
  315. , attributes = toMap { name = "fonts" }
  316. , content =
  317. [ XML.element
  318. { name = "dir"
  319. , attributes = toMap { name = "title" }
  320. , content =
  321. [ XML.leaf
  322. { name = "ttf"
  323. , attributes = toMap
  324. { name = "regular"
  325. , path = "/Inconsolata.ttf"
  326. , size_px = "12"
  327. }
  328. }
  329. ]
  330. }
  331. , XML.element
  332. { name = "dir"
  333. , attributes = toMap { name = "text" }
  334. , content =
  335. [ XML.leaf
  336. { name = "ttf"
  337. , attributes = toMap
  338. { name = "regular"
  339. , path = "/Inconsolata.ttf"
  340. , size_px = "12"
  341. }
  342. }
  343. ]
  344. }
  345. , XML.element
  346. { name = "dir"
  347. , attributes = toMap
  348. { name = "annotation" }
  349. , content =
  350. [ XML.leaf
  351. { name = "ttf"
  352. , attributes = toMap
  353. { name = "regular"
  354. , path = "/Inconsolata.ttf"
  355. , size_px = "12"
  356. }
  357. }
  358. ]
  359. }
  360. , XML.element
  361. { name = "dir"
  362. , attributes = toMap
  363. { name = "monospace" }
  364. , content =
  365. [ XML.leaf
  366. { name = "ttf"
  367. , attributes = toMap
  368. { name = "regular"
  369. , path = "/Inconsolata.ttf"
  370. , size_px = "12"
  371. }
  372. }
  373. ]
  374. }
  375. ]
  376. }
  377. ]
  378. }
  379. ]
  380. , defaultPolicy = Some DefaultPolicy::{
  381. , attributes = toMap { root = "/fonts" }
  382. }
  383. }
  384. , provides = [ "File_system" ]
  385. , resources = Init.Resources::{
  386. , caps = 256
  387. , ram = Genode.units.MiB 12
  388. }
  389. , routes = [ ServiceRoute.child "Block" "block_router" ]
  390. }
  391. , graphical-log =
  392. Init.toChild
  393. params.graphical-log
  394. Init.Attributes::{
  395. , routes =
  396. [ ServiceRoute.child "Nitpicker" "wm"
  397. , ServiceRoute.child "File_system" "fonts_fs"
  398. ]
  399. }
  400. , fs-log =
  401. Init.toChild
  402. params.fs-log
  403. Init.Attributes::{
  404. , routes =
  405. [ ServiceRoute.childLabel
  406. "File_system"
  407. "chroot"
  408. (None Text)
  409. (Some "dump")
  410. ]
  411. }
  412. , rom_to_file =
  413. Child.flat
  414. Child.Attributes::{
  415. , binary = "rom_to_file"
  416. , config = Init.Config::{
  417. , attributes = toMap { rom = "init.config" }
  418. }
  419. , routes =
  420. [ ServiceRoute.childLabel
  421. "File_system"
  422. "chroot"
  423. (None Text)
  424. (Some "dump")
  425. , ServiceRoute.parentLabel
  426. "ROM"
  427. (Some "init.config")
  428. (Some "config")
  429. ]
  430. }
  431. , block =
  432. Child.flat
  433. Child.Attributes::{
  434. , binary = "ahci_drv"
  435. , config = Init.Config::{
  436. , defaultPolicy = Some DefaultPolicy::{
  437. , attributes = toMap { device = "0", writeable = "yes" }
  438. }
  439. }
  440. , provides = [ "Block" ]
  441. , resources = Init.Resources::{
  442. , caps = 256
  443. , ram = Genode.units.MiB 10
  444. }
  445. , routes =
  446. [ ServiceRoute.childLabel
  447. "Platform"
  448. "platform_drv"
  449. (None Text)
  450. (Some "ahci_drv")
  451. ]
  452. }
  453. , block_partitions =
  454. Child.flat
  455. Child.Attributes::{
  456. , binary = "part_block"
  457. , config = Init.Config::{
  458. , content =
  459. Prelude.List.map
  460. Natural
  461. XML.Type
  462. ( λ(i : Natural)
  463. → XML.leaf
  464. { name = "policy"
  465. , attributes =
  466. let partition =
  467. Prelude.Natural.show (i + 1)
  468. in toMap
  469. { label_suffix = " ${partition}"
  470. , partition = partition
  471. , writeable = "yes"
  472. }
  473. }
  474. )
  475. (Prelude.Natural.enumerate 128)
  476. # [ XML.leaf
  477. { name = "report"
  478. , attributes = toMap { partitions = "yes" }
  479. }
  480. ]
  481. }
  482. , resources = Resources::{
  483. , caps = 256
  484. , ram = Genode.units.MiB 8
  485. }
  486. , provides = [ "Block" ]
  487. , routes =
  488. [ ServiceRoute.child "Block" "block"
  489. , ServiceRoute.child "Report" "block_router"
  490. ]
  491. }
  492. , block_router =
  493. Child.flat
  494. Child.Attributes::{
  495. , binary = "block_router"
  496. , config = Init.Config::{
  497. , attributes = toMap { verbose = "yes" }
  498. , content =
  499. [ XML.element
  500. { name = "default-policy"
  501. , attributes = XML.emptyAttributes
  502. , content =
  503. [ XML.leaf
  504. { name = "partition"
  505. , attributes = toMap
  506. { type = params.partitionType
  507. , writeable = "yes"
  508. }
  509. }
  510. ]
  511. }
  512. ]
  513. }
  514. , resources = Resources::{
  515. , caps = 256
  516. , ram = Genode.units.MiB 8
  517. }
  518. , provides = [ "Block", "Report" ]
  519. , routes = [ ServiceRoute.child "Block" "block_partitions" ]
  520. }
  521. , file_system =
  522. Child.flat
  523. Child.Attributes::{
  524. , binary = "vfs"
  525. , config = Init.Config::{
  526. , content =
  527. [ XML.element
  528. { name = "vfs"
  529. , attributes = XML.emptyAttributes
  530. , content =
  531. [ XML.element
  532. { name = "dir"
  533. , attributes = toMap { name = "ext2" }
  534. , content =
  535. [ XML.leaf
  536. { name = "rump"
  537. , attributes = toMap
  538. { fs = "ext2fs"
  539. , writeable = "yes"
  540. , ram = "8M"
  541. }
  542. }
  543. ]
  544. }
  545. ]
  546. }
  547. ]
  548. , policies =
  549. [ Policy::{
  550. , label = LabelSelector.suffix "nix/store"
  551. , attributes = toMap
  552. { root = "/ext2/nix/store", writeable = "no" }
  553. }
  554. , Policy::{
  555. , label = LabelSelector.prefix "chroot"
  556. , attributes = toMap
  557. { root = "/ext2", writeable = "yes", path = "/" }
  558. }
  559. , Policy::{
  560. , label = LabelSelector.prefix "init -> console"
  561. , attributes = toMap { root = "/", writeable = "yes" }
  562. }
  563. ]
  564. }
  565. , provides = [ "File_system" ]
  566. , resources = Init.Resources::{
  567. , caps = 256
  568. , ram = Genode.units.MiB 12
  569. }
  570. , routes = [ ServiceRoute.child "Block" "block_router" ]
  571. }
  572. , chroot =
  573. Child.flat
  574. Child.Attributes::{
  575. , binary = "chroot"
  576. , config = Init.Config::{
  577. , policies =
  578. [ Policy::{
  579. , label = LabelSelector.label "dump"
  580. , attributes = toMap
  581. { path = params.systemLabel, writeable = "yes" }
  582. }
  583. ]
  584. , defaultPolicy = Some DefaultPolicy::{
  585. , attributes = toMap { writeable = "yes" }
  586. }
  587. }
  588. , provides = [ "File_system" ]
  589. , routes = [ ServiceRoute.child "File_system" "file_system" ]
  590. }
  591. , nic_drv =
  592. Child.flat
  593. Child.Attributes::{
  594. , binary = "ipxe_nic_drv"
  595. , provides = [ "Nic" ]
  596. , resources = Init.Resources::{
  597. , caps = 128
  598. , ram = Genode.units.MiB 4
  599. }
  600. , routes =
  601. [ ServiceRoute.childLabel
  602. "Platform"
  603. "platform_drv"
  604. (None Text)
  605. (Some "nic_drv")
  606. ]
  607. }
  608. , nic_router =
  609. Child.flat
  610. Child.Attributes::{
  611. , binary = "nic_router"
  612. , config = Init.Config::{
  613. , content =
  614. [ XML.leaf
  615. { name = "uplink"
  616. , attributes = toMap { domain = "uplink" }
  617. }
  618. , XML.element
  619. { name = "domain"
  620. , attributes = toMap { name = "uplink" }
  621. , content =
  622. [ XML.leaf
  623. { name = "nat"
  624. , attributes = toMap
  625. { domain = "default"
  626. , tcp-ports = "1024"
  627. , udp-ports = "1024"
  628. , icmp-ids = "1024"
  629. }
  630. }
  631. ]
  632. }
  633. , XML.element
  634. { name = "domain"
  635. , attributes = toMap
  636. { name = "default", interface = "10.0.1.1/24" }
  637. , content =
  638. [ XML.leaf
  639. { name = "dhcp-server"
  640. , attributes = toMap
  641. { ip_first = "10.0.1.2"
  642. , ip_last = "10.0.1.200"
  643. , dns_server_from = "uplink"
  644. }
  645. }
  646. ]
  647. # Prelude.List.map
  648. Text
  649. XML.Type
  650. ( λ(proto : Text)
  651. → XML.element
  652. { name = proto
  653. , attributes = toMap
  654. { dst = "0.0.0.0/0"
  655. , domain = "uplink"
  656. }
  657. , content =
  658. [ XML.leaf
  659. { name = "permit-any"
  660. , attributes = toMap
  661. { domain = "uplink" }
  662. }
  663. ]
  664. }
  665. )
  666. [ "tcp", "udp", "icmp" ]
  667. }
  668. ]
  669. , defaultPolicy = Some DefaultPolicy::{
  670. , attributes = toMap { domain = "default" }
  671. }
  672. }
  673. , provides = [ "Nic" ]
  674. , resources = Init.Resources::{ ram = Genode.units.MiB 8 }
  675. , routes = [ ServiceRoute.child "Nic" "nic_drv" ]
  676. }
  677. , init =
  678. Init.toChild
  679. Init::{ children = params.guests }
  680. Init.Attributes::{
  681. , routes =
  682. [ ServiceRoute.parent "VM"
  683. , ServiceRoute.child "Nitpicker" "wm"
  684. , { service =
  685. { name = "File_system"
  686. , label = LabelSelector.last "fonts"
  687. }
  688. , route =
  689. Init.Route.Type.Child
  690. { name = "fonts_fs"
  691. , label = None Text
  692. , diag = None Bool
  693. }
  694. }
  695. , { service =
  696. { name = "File_system"
  697. , label = LabelSelector.suffix "nix/store"
  698. }
  699. , route =
  700. Init.Route.Type.Child
  701. { name = "file_system"
  702. , label = Some "nix/store"
  703. , diag = None Bool
  704. }
  705. }
  706. , { service =
  707. { name = "File_system"
  708. , label = LabelSelector.prefix "console"
  709. }
  710. , route =
  711. Init.Route.Type.Child
  712. { name = "file_system"
  713. , label = None Text
  714. , diag = None Bool
  715. }
  716. }
  717. , ServiceRoute.child "File_system" "chroot"
  718. , ServiceRoute.child "Nic" "nic_router"
  719. , ServiceRoute.child "Rtc" "rtc"
  720. , ServiceRoute.parentLabel
  721. "ROM"
  722. (Some "platform_info")
  723. (Some "platform_info")
  724. , ServiceRoute.child "Report" "_report_rom"
  725. ]
  726. }
  727. }
  728. , routes = [ ServiceRoute.child "Timer" "timer" ]
  729. }
  730. in rootInit