Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

restore Xen support, autodetected via MIRAGE_OS env var.

This oasis is regenerated by my avsm/oasis@f738442 in the add-xen branch (which puts in the special build rules for linking kernel executables)
  • Loading branch information...
commit 4df80112bcba290c6093607b57eb9d2795562608 1 parent 0ebcc8f
@avsm authored
View
3  .gitignore
@@ -3,4 +3,5 @@ src/main.ml
src/_build
.*.swp
*.native
-src/setup.*
+src/setup.data
+src/setup.log
View
19 src/Makefile
@@ -1,18 +1,13 @@
+ifeq ($(MIRAGE_OS),xen)
+FLAGS=--enable-xen
+else
+FLAGS=--enable-unix
+endif
+
all:
- ocaml setup.ml -configure
+ ocaml setup.ml -configure $(FLAGS)
ocaml setup.ml -build
-xen:
- ./cmd config
- mir-crunch -name "static" ../files > filesystem_static.ml
- mir-crunch -name "templates" ../tmpl > filesystem_templates.ml
- echo open Filesystem_static > main.ml
- echo open Filesystem_templates >> main.ml
- echo open Server >> main.ml
- echo "let _ = OS.Main.run (main ())" >> main.ml
- ocamlbuild -classic-display main.xen
-
.PHONY:clean
clean:
- rm -f filesystem_static.ml filesystem_templates.ml main.ml
ocamlbuild -clean
View
16 src/_oasis
@@ -10,8 +10,12 @@ PostDistCleanCommand: $rm main.ml
Flag unix
Description: build UNIX binary
- Default: true
+ Default: false
+Flag xen
+ Description: build Xen kernel
+ Default: false
+
Executable "mirage-www.unix"
Path: .
MainIs: main.ml
@@ -20,3 +24,13 @@ Executable "mirage-www.unix"
CompiledObject: native
Install: false
BuildDepends: cohttp, cohttp.mirage, uri, re, cow, lwt.unix
+
+Executable "mirage-www.xen"
+ Path: .
+ MainIs: main.ml
+ Build$: flag(xen)
+ Custom: true
+ CompiledObject: native
+ Target: xen
+ Install: false
+ BuildDepends: mirage, cohttp, cohttp.mirage, uri, re, dyntype.syntax, cow.syntax, cow
View
25 src/_tags
@@ -1,5 +1,5 @@
# OASIS_START
-# DO NOT EDIT (digest: c1105fbcb8e4f20970fff1e36ed49585)
+# DO NOT EDIT (digest: 3d6d1bed46f0338f6a52029f7f2debe1)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
@@ -14,18 +14,25 @@
"_darcs": -traverse
"_darcs": not_hygienic
# Executable mirage-www.unix
-"main.native": pkg_cohttp
-"main.native": pkg_cohttp.mirage
-"main.native": pkg_uri
-"main.native": pkg_re
-"main.native": pkg_cow
-"main.native": pkg_lwt.unix
+<main.{native,nobj.o}>: pkg_lwt.unix
+<*.ml{,i}>: pkg_lwt.unix
+# Executable mirage-www.xen
+<main.{native,nobj.o}>: pkg_mirage
+<main.{native,nobj.o}>: pkg_cohttp
+<main.{native,nobj.o}>: pkg_cohttp.mirage
+<main.{native,nobj.o}>: pkg_uri
+<main.{native,nobj.o}>: pkg_re
+<main.{native,nobj.o}>: pkg_dyntype.syntax
+<main.{native,nobj.o}>: pkg_cow.syntax
+<main.{native,nobj.o}>: pkg_cow
+<*.ml{,i}>: pkg_mirage
<*.ml{,i}>: pkg_cohttp
<*.ml{,i}>: pkg_cohttp.mirage
<*.ml{,i}>: pkg_uri
<*.ml{,i}>: pkg_re
+<*.ml{,i}>: pkg_dyntype.syntax
+<*.ml{,i}>: pkg_cow.syntax
<*.ml{,i}>: pkg_cow
-<*.ml{,i}>: pkg_lwt.unix
-"main.native": custom
+<main.{native,nobj.o}>: custom
# OASIS_STOP
<*.ml>:syntax_camlp4o, pkg_lwt.syntax, pkg_dyntype.syntax, pkg_cow.syntax
View
123 src/myocamlbuild.ml
@@ -1,7 +1,7 @@
(* OASIS_START *)
-(* DO NOT EDIT (digest: f1d793f1f1c819881a73d7b9a60b2b34) *)
+(* DO NOT EDIT (digest: 38ffac4d0311ee34b832fb15643acc11) *)
module OASISGettext = struct
-# 21 "/Users/avsm/.opam/3.12.1+mirage-unix-direct/build/oasis.0.3.0/src/oasis/OASISGettext.ml"
+# 21 "/home/avsm/src/git/avsm/oasis/src/oasis/OASISGettext.ml"
let ns_ str =
str
@@ -24,7 +24,7 @@ module OASISGettext = struct
end
module OASISExpr = struct
-# 21 "/Users/avsm/.opam/3.12.1+mirage-unix-direct/build/oasis.0.3.0/src/oasis/OASISExpr.ml"
+# 21 "/home/avsm/src/git/avsm/oasis/src/oasis/OASISExpr.ml"
@@ -116,7 +116,7 @@ end
# 117 "myocamlbuild.ml"
module BaseEnvLight = struct
-# 21 "/Users/avsm/.opam/3.12.1+mirage-unix-direct/build/oasis.0.3.0/src/base/BaseEnvLight.ml"
+# 21 "/home/avsm/src/git/avsm/oasis/src/base/BaseEnvLight.ml"
module MapString = Map.Make(String)
@@ -213,8 +213,76 @@ end
# 215 "myocamlbuild.ml"
+module MyOCamlbuildXen = struct
+# 22 "/home/avsm/src/git/avsm/oasis/src/plugins/ocamlbuild/MyOCamlbuildXen.ml"
+
+ open Ocamlbuild_plugin
+
+ module Util = struct
+ let split s ch =
+ let x = ref [] in
+ let rec go s =
+ let pos = String.index s ch in
+ x := (String.before s pos)::!x;
+ go (String.after s (pos + 1))
+ in
+ try
+ go s
+ with Not_found -> !x
+
+ let split_nl s = split s '\n'
+ let run_and_read x = List.hd (split_nl (Ocamlbuild_pack.My_unix.run_and_read x))
+ end
+
+ module Xen = struct
+ (** Link to a standalone Xen microkernel *)
+ let cc_xen_link bc tags arg out env =
+ (* XXX check ocamlfind path here *)
+ let xenlib = Util.run_and_read "ocamlfind query mirage" in
+ let jmp_obj = Px (xenlib / "longjmp.o") in
+ let head_obj = Px (xenlib / "x86_64.o") in
+ let ocamllib = match bc with |true -> "ocamlbc" |false -> "ocaml" in
+ let ld = getenv ~default:"ld" "LD" in
+ let ldlibs = List.map (fun x -> Px (xenlib / ("lib" ^ x ^ ".a")))
+ [ocamllib; "xen"; "xencaml"; "diet"; "m"] in
+ Cmd (S ( A ld :: [ T(tags++"link"++"xen");
+ A"-d"; A"-nostdlib"; A"-m"; A"elf_x86_64"; A"-T";
+ Px (xenlib / "mirage-x86_64.lds"); head_obj; P arg ]
+ @ ldlibs @ [jmp_obj; A"-o"; Px out]))
+
+ let cc_xen_bc_link tags arg out env = cc_xen_link true tags arg out env
+ let cc_xen_nc_link tags arg out env = cc_xen_link false tags arg out env
+
+ (* Rewrite sections for Xen LDS layout *)
+ let xen_objcopy dst src env builder =
+ let dst = env dst in
+ let src = env src in
+ let cmd = ["objcopy";"--rename-section";".bss=.mlbss";"--rename-section";
+ ".data=.mldata";"--rename-section";".rodata=.mlrodata";
+ "--rename-section";".text=.mltext"] in
+ let cmds = List.map (fun x -> A x) cmd in
+ Cmd (S (cmds @ [Px src; Px dst]))
+
+ let rules () =
+ let cc_link_c_implem ?tag fn c o env build =
+ let c = env c and o = env o in
+ fn (tags_of_pathname c++"implem"+++tag) c o env
+ in
+ rule "final link: %.nobj.o -> %.xen" ~prod:"%(file).xen" ~dep:"%(file).nobj.o"
+ (cc_link_c_implem cc_xen_nc_link "%(file).nobj.o" "%(file).xen")
+
+ end
+
+ let dispatch =
+ function
+ | After_rules ->
+ Xen.rules ()
+ | _ ->
+ ()
+end
+
module MyOCamlbuildFindlib = struct
-# 21 "/Users/avsm/.opam/3.12.1+mirage-unix-direct/build/oasis.0.3.0/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml"
+# 21 "/home/avsm/src/git/avsm/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml"
(** OCamlbuild extension, copied from
* http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild
@@ -234,19 +302,21 @@ module MyOCamlbuildFindlib = struct
Ocamlbuild_pack.Lexers.blank_sep_strings
let split s ch =
- let x =
- ref []
- in
- let rec go s =
- let pos =
- String.index s ch
- in
- x := (String.before s pos)::!x;
- go (String.after s (pos + 1))
+ let buf = Buffer.create 13 in
+ let x = ref [] in
+ let flush () =
+ x := (Buffer.contents buf) :: !x;
+ Buffer.clear buf
in
- try
- go s
- with Not_found -> !x
+ String.iter
+ (fun c ->
+ if c = ch then
+ flush ()
+ else
+ Buffer.add_char buf c)
+ s;
+ flush ();
+ List.rev !x
let split_nl s = split s '\n'
@@ -281,6 +351,7 @@ module MyOCamlbuildFindlib = struct
(* When one link an OCaml library/binary/package, one should use -linkpkg *)
flag ["ocaml"; "link"; "program"] & A"-linkpkg";
+ flag ["ocaml"; "link"; "output_obj"] & A"-linkpkg";
(* For each ocamlfind package one inject the -package option when
* compiling, computing dependencies, generating documentation and
@@ -323,7 +394,7 @@ module MyOCamlbuildFindlib = struct
end
module MyOCamlbuildBase = struct
-# 21 "/Users/avsm/.opam/3.12.1+mirage-unix-direct/build/oasis.0.3.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
+# 21 "/home/avsm/src/git/avsm/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
(** Base functions for writing myocamlbuild.ml
@author Sylvain Le Gall
@@ -339,7 +410,7 @@ module MyOCamlbuildBase = struct
type name = string
type tag = string
-# 56 "/Users/avsm/.opam/3.12.1+mirage-unix-direct/build/oasis.0.3.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
+# 56 "/home/avsm/src/git/avsm/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
type t =
{
@@ -452,6 +523,15 @@ module MyOCamlbuildBase = struct
)
t.lib_c;
+ (* Add output_obj rules mapped to .nobj.o *)
+ let native_output_obj x =
+ OC.link_gen "cmx" "cmxa" !Options.ext_lib [!Options.ext_obj; "cmi"]
+ OC.ocamlopt_link_prog
+ (fun tags -> tags++"ocaml"++"link"++"byte"++"output_obj") x
+ in
+ rule "ocaml: cmx* and o* -> .nobj.o" ~prod:"%.nobj.o" ~deps:["%.cmx"; "%.o"]
+ (native_output_obj "%.cmx" "%.nobj.o");
+
(* Add flags *)
List.iter
(fun (tags, cond_specs) ->
@@ -468,12 +548,13 @@ module MyOCamlbuildBase = struct
[
dispatch t;
MyOCamlbuildFindlib.dispatch;
+ MyOCamlbuildXen.dispatch;
]
end
-# 476 "myocamlbuild.ml"
+# 557 "myocamlbuild.ml"
open Ocamlbuild_plugin;;
let package_default =
{MyOCamlbuildBase.lib_ocaml = []; lib_c = []; flags = []; includes = []; }
@@ -481,6 +562,6 @@ let package_default =
let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
-# 485 "myocamlbuild.ml"
+# 566 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;
View
6,006 src/setup.ml
6,006 additions, 0 deletions not shown
Please sign in to comment.
Something went wrong with that request. Please try again.