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

More Nix improvements #157

Merged
merged 8 commits into from
Jun 26, 2024
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
4 changes: 2 additions & 2 deletions crates/examples/microkit/http-server/http-server.system
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@

<protection_domain name="pl031_driver" pp="true" priority="251">
<program_image path="microkit-http-server-example-pl031-driver.elf" />
<map mr="pl031_mmio" vaddr="0x5_000_000_000" perms="rw" cached="false" setvar_vaddr="pl031_mmio_vaddr" />
<map mr="pl031_mmio" vaddr="0x5_000_000_000" perms="rw" cached="false" setvar_vaddr="pl031_mmio_vaddr" />
<irq irq="34" id="0" />
</protection_domain>

<protection_domain name="sp804_driver" pp="true" priority="254">
<program_image path="microkit-http-server-example-sp804-driver.elf" />
<map mr="sp804_mmio" vaddr="0x5_000_000_000" perms="rw" cached="false" setvar_vaddr="sp804_mmio_vaddr" />
<map mr="sp804_mmio" vaddr="0x5_000_000_000" perms="rw" cached="false" setvar_vaddr="sp804_mmio_vaddr" />
<irq irq="43" id="0" />
</protection_domain>

Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-microkit/base/src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ pub(crate) fn nb_send_recv(action: PreparedDeferredAction) -> Event {
pub(crate) fn forfeit_sc() -> PreparedDeferredAction {
PreparedDeferredAction::new(
MONITOR_EP_CAP.cast(),
sel4::MessageInfoBuilder::default().length(1).build(),
sel4::MessageInfoBuilder::default().build(),
)
}
2 changes: 1 addition & 1 deletion crates/sel4-microkit/base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod ipc;

pub use channel::{Channel, IrqAckError, ProtectionDomain};
pub use defer::{DeferredAction, DeferredActionInterface, DeferredActionSlot};
pub use handler::{Handler, Infallible, NullHandler};
pub use handler::{Handler, Infallible, Never, NullHandler};
pub use message::{
get_mr, set_mr, with_msg_bytes, with_msg_bytes_mut, with_msg_regs, with_msg_regs_mut,
MessageInfo, MessageLabel, MessageRegisterValue,
Expand Down
6 changes: 4 additions & 2 deletions crates/sel4-shared-ring-buffer/smoltcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ impl<A: AbstractBounceBufferAllocator> Device for DeviceImpl<A> {
}

fn receive(&mut self, _timestamp: Instant) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
let r = self.inner().borrow_mut().receive();
r.map(|(rx_ix, tx_ix)| (self.new_rx_token(rx_ix), self.new_tx_token(tx_ix)))
self.inner()
.borrow_mut()
.receive()
.map(|(rx_ix, tx_ix)| (self.new_rx_token(rx_ix), self.new_tx_token(tx_ix)))
}

fn transmit(&mut self, _timestamp: Instant) -> Option<Self::TxToken<'_>> {
Expand Down
16 changes: 15 additions & 1 deletion hacking/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,21 @@ let
inherit lib pkgs;
} // import ./top-level self);

this = makeOverridableWith lib.id mkThis baseArgs;
this = lib.fix (self: makeOverridableWith lib.id mkThis baseArgs // rec {
overrideNixpkgsArgs = f: self.override (superArgs: selfBase:
let
concreteSuperArgs = superArgs selfBase;
in
concreteSuperArgs // {
nixpkgsArgsFor = crossSystem: f (concreteSuperArgs.nixpkgsArgsFor crossSystem);
}
);
withOverlays = overlays: self.overrideNixpkgsArgs (superNixpkgsArgs:
superNixpkgsArgs // {
overlays = superNixpkgsArgs.overlays ++ overlays;
}
);
});

in
this
12 changes: 5 additions & 7 deletions hacking/nix/scope/crates.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let

globalPatchSection = workspaceManifest.patch;

overrides = {
overridesForMkCrate = {
sel4-sys = {
extraPaths = [
"build"
Expand Down Expand Up @@ -59,13 +59,11 @@ let
};

unAugmentedCrates = lib.listToAttrs (lib.forEach workspaceMemberPaths (cratePath: rec {
name = (crateUtils.crateManifest cratePath).package.name; # TODO redundant
value = crateUtils.mkCrate cratePath (overrides.${name} or {});
name = (crateUtils.crateManifest cratePath).package.name;
value = crateUtils.mkCrate cratePath (overridesForMkCrate.${name} or {});
}));

augmentedCrates = crateUtils.augmentCrates unAugmentedCrates;

crates = augmentedCrates;
crates = crateUtils.augmentCrates unAugmentedCrates;

isPrivate = crateName: builtins.match "^sel4-.*" crateName == null;

Expand All @@ -75,5 +73,5 @@ let
(lib.concatMapStrings (crateName: "${crateName}\n") (lib.attrNames publicCrates));

in {
inherit crates globalPatchSection publicCrates publicCratesTxt;
inherit crates overridesForMkCrate globalPatchSection publicCrates publicCratesTxt;
}
3 changes: 2 additions & 1 deletion hacking/nix/scope/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ superCallPackage ../rust-utils {} self //
{ name = fname; path = builtins.toFile fname (builtins.readFile "${dir}/${fname}"); }
];

inherit (callPackage ./crates.nix {}) crates globalPatchSection publicCrates publicCratesTxt;
inherit (callPackage ./crates.nix {})
crates overridesForMkCrate globalPatchSection publicCrates publicCratesTxt;

distribution = callPackage ./distribution.nix {};

Expand Down
2 changes: 1 addition & 1 deletion hacking/nix/scope/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ in rec {

microkit = fetchGit {
url = "https://github.com/coliasgroup/microkit.git";
rev = "44e618ec5188f4079b894bf482c5e596370785db"; # branch "rust-nix"
rev = "fdcccc7d4af51c35ca2992ba6839955e4b44a039"; # branch "rust-nix"
local = localRoot + "/microkit";
};

Expand Down
2 changes: 1 addition & 1 deletion hacking/nix/scope/world/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ self: with self;
$OBJCOPY -O elf32-i386 ${kernelBinary} $out
'';

libsel4 = assert !worldConfig.isMicrokit; "${seL4ForUserspace}/libsel4";
libsel4 = if worldConfig.isMicrokit then microkitDir else "${seL4ForUserspace}/libsel4";

seL4Config =
let
Expand Down
Loading