Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to ocaml-solo5-elftool 0.4.0 #207

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ocaml-version: ["4.14.2", "4.13.1"]
ocaml-version: ["4.14.2", "5.2.1"]
operating-system: [macos-latest, ubuntu-latest]

runs-on: ${{ matrix.operating-system }}
Expand Down
3 changes: 2 additions & 1 deletion albatross.opam
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ depends: [
"ohex" {>= "0.2.0"}
"http-lwt-client" {>= "0.3.0"}
"happy-eyeballs-lwt"
"solo5-elftool" {>= "0.3"}
"solo5-elftool" {>= "0.4.0"}
hannesm marked this conversation as resolved.
Show resolved Hide resolved
"cachet" {>= "0.0.2"}
"fpath" {>= "0.7.3"}
"logs-syslog" {>= "0.4.1"}
"digestif" {>= "1.2.0"}
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(wrapped false)
(modules vmm_unix vmm_lwt vmm_vmmd)
(libraries albatross ipaddr.unix bos solo5-elftool lwt lwt.unix ptime.clock.os
digestif)
digestif cachet)
(foreign_stubs
(language c)
(names vmm_stubs)
Expand Down
23 changes: 15 additions & 8 deletions src/vmm_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,24 @@ let destroy_tap tap =
in
Bos.OS.Cmd.run cmd

let owee_buf_of_str b =
let buf = Bigarray.Array1.create Bigarray.Int8_unsigned Bigarray.c_layout (String.length b) in
for i = 0 to String.length b - 1 do
buf.{i} <- String.get_uint8 b i
done;
buf
let cachet_of_str b =
let map () ~pos len =
if pos >= String.length b || len <= 0 then
(Cachet.Bstr.empty :> Cachet.bigstring)
else
let len = min len (max 0 (String.length b - pos)) in
let pg : Cachet.bigstring = Bigarray.Array1.create Bigarray.char Bigarray.c_layout len in
for i = 0 to len - 1 do
pg.{i} <- b.[pos+i]
done;
pg
in
Cachet.make ~cachesize:8 ~map ()

type solo5_target = Spt | Hvt

let solo5_image_target image =
let* abi = Solo5_elftool.query_abi (owee_buf_of_str image) in
let* abi = Solo5_elftool.query_abi (cachet_of_str image) in
match abi.target with
| Solo5_elftool.Hvt -> Ok (Hvt, Int32.to_int abi.version)
| Solo5_elftool.Spt -> Ok (Spt, Int32.to_int abi.version)
Expand Down Expand Up @@ -281,7 +288,7 @@ let devices_match ~bridges ~block_devices mft =
Fmt.(list ~sep:(any ", ") pp_entry) mft.entries)

let manifest_devices_match ~bridges ~block_devices image =
let* mft = Solo5_elftool.query_manifest (owee_buf_of_str image) in
let* mft = Solo5_elftool.query_manifest (cachet_of_str image) in
let bridges = List.map (fun (b, _, _) -> b) bridges
and block_devices = List.map (fun (b, _, _) -> b) block_devices
in
Expand Down
Loading