Verified Commit b1b249cd authored by james's avatar james
Browse files

feat(core): define typed addresses and captured register state

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+4 −0
Changes for .gitignore: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
_build/
*.install
guest/build/
__pycache__/

dune-project

0 → 100644
+8 −0
Changes for dune-project: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
(lang dune 3.10)
(name scope)
(version 0.1.0)
(generate_opam_files true)
(package
 (name scope)
 (synopsis "Inspect and replay Xen guest page tables")
 (depends (ocaml (>= 4.14)) dune))

lib/address.ml

0 → 100644
+33 −0
Changes for lib/address.ml: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
module Virtual = struct
  type t = int64
  let of_int64 x = x
  let to_int64 x = x
end

module Physical = struct
  type t = int64
  let of_int64 x = x
  let to_int64 x = x
end

module Machine = struct
  type t = int64
  let of_int64 x = x
  let to_int64 x = x
end

let compare = Int64.unsigned_compare
let hex x = Printf.sprintf "0x%016Lx" x

let parse s =
  if String.length s = 0 || s.[0] = '-' || s.[0] = '+' then
    invalid_arg ("invalid unsigned address: " ^ s);
  try Int64.of_string (if String.starts_with ~prefix:"0x" s then s else "0u" ^ s)
  with Failure _ -> invalid_arg ("invalid unsigned address: " ^ s)

let bit x n = Int64.logand x (Int64.shift_left 1L n) <> 0L
let mask n = Int64.pred (Int64.shift_left 1L n)
let align x n = Int64.logand x (Int64.lognot (mask n))
let canonical x =
  let high = Int64.shift_right x 47 in
  high = 0L || high = -1L

lib/address.mli

0 → 100644
+25 −0
Changes for lib/address.mli: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
module Virtual : sig
  type t
  val of_int64 : int64 -> t
  val to_int64 : t -> int64
end

module Physical : sig
  type t
  val of_int64 : int64 -> t
  val to_int64 : t -> int64
end

module Machine : sig
  type t
  val of_int64 : int64 -> t
  val to_int64 : t -> int64
end

val compare : int64 -> int64 -> int
val hex : int64 -> string
val parse : string -> int64
val bit : int64 -> int -> bool
val mask : int -> int64
val align : int64 -> int -> int64
val canonical : int64 -> bool

lib/dune

0 → 100644
+4 −0
Changes for lib/dune: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
(library
 (name scope)
 (public_name scope)
 (libraries unix))
Loading