-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.ml
74 lines (66 loc) · 2.52 KB
/
config.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(* Copyright (C) 2017, Thomas Leonard <[email protected]>
See the README file for details. *)
(** Configuration for the "mirage" tool. *)
open Mirage
type framebuffer_ty = Framebuffer
let framebuffer = Type Framebuffer
let config_framebuffer =
impl @@ object inherit Mirage.base_configurable
method module_name = "Framebuffer_placeholder_goes_here"
method name = "my framebuffer, hello!"
method ty = framebuffer
method! packages : package list value =
(Key.match_ Key.(value target) @@ begin function
| `Xen -> [package ~min:"0.4.0" "mirage-qubes";
package "mirage-framebuffer-qubes"]
| `Unix | `MacOSX ->
[package "mirage-unix"; package "mirage-framebuffer-tsdl"]
| _ -> []
end)
|> Mirage.Key.map (List.cons (package "mirage-framebuffer"))
method! deps = []
method! connect mirage_info _modname _args =
Key.eval (Info.context mirage_info) @@
Key.match_ Key.(value target) @@ begin function
| `Unix | `MacOSX ->
{| Lwt.return (fun () ->
let b =
let module X = Framebuffer.Make(Framebuffer_tsdl) in
X.init ()
in
Lwt.return ((), b))
|}
| `Xen ->
{| Lwt.return (fun () ->
Qubes.RExec.connect ~domid:0 () >>= fun qrexec ->
Qubes.GUI.connect ~domid:0 () >>= fun gui ->
let b =
let module X = Framebuffer.Make(Framebuffer_qubes) in
X.init gui
in
let agent_listener = Qubes.RExec.listen qrexec Command.handler
in
Lwt.async (Qubes.GUI.listen gui) ;
Lwt.async (fun () ->
OS.Lifecycle.await_shutdown_request ()
>>= fun (`Poweroff | `Reboot) ->
Qubes.RExec.disconnect qrexec
);
Lwt.return ((agent_listener, qrexec, gui),b))
|}
| `Virtio | `Hvt | `Muen | `Genode ->
failwith "Mirage_Framebuffer is not implemented for Virtio | Uvkm | Muen"
| `Qubes ->
failwith "Mirage_framebuffer must be used with -t xen for Qubes"
end
end
let main =
foreign
~deps:[abstract config_framebuffer]
~packages:[
package "cstruct";
package "mirage-logs";
package "mirage-framebuffer-imagelib";
] "Unikernel.Main" (time @-> job)
let () =
register "eye-of-mirage" [ main $ default_time ] ~argv:no_argv