Skip to content
Open
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
3 changes: 2 additions & 1 deletion build_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ class ConfigInfo:
kernel_options={
"KernelDebugBuild": True,
"KernelPrinting": True,
"KernelVerificationBuild": False
"KernelVerificationBuild": False,
"HardwareDebugAPI": True
}
),
ConfigInfo(
Expand Down
7 changes: 5 additions & 2 deletions libmicrokit/include/microkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ typedef unsigned int microkit_channel;
typedef unsigned int microkit_child;
typedef seL4_MessageInfo_t microkit_msginfo;

#define VSPACE_CAP 3
#define MONITOR_EP 5
/* Only valid in the 'benchmark' configuration */
#define TCB_CAP 6
Expand All @@ -24,8 +25,10 @@ typedef seL4_MessageInfo_t microkit_msginfo;
#define BASE_ENDPOINT_CAP 74
#define BASE_IRQ_CAP 138
#define BASE_TCB_CAP 202
#define BASE_VM_TCB_CAP 266
#define BASE_VCPU_CAP 330
#define BASE_VSPACE_CAP 266
#define BASE_VM_TCB_CAP 330
#define BASE_VCPU_CAP 394
#define BASE_FRAME_CAP 458

#define MICROKIT_MAX_CHANNELS 62
#define MICROKIT_MAX_CHANNEL_ID (MICROKIT_MAX_CHANNELS - 1)
Expand Down
21 changes: 21 additions & 0 deletions tool/microkit/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tool/microkit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ path = "src/main.rs"
roxmltree = "0.19.0"
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.117"
zerocopy = {version="0.8.25",features=["derive"]}

[profile.release]
strip = true
49 changes: 49 additions & 0 deletions tool/microkit/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use crate::util::bytes_to_struct;
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use zerocopy::{Immutable, IntoBytes};
use crate::sel4::PageSize;

#[repr(C, packed)]
struct ElfHeader32 {
Expand Down Expand Up @@ -97,13 +99,21 @@ struct ElfHeader64 {
const ELF_MAGIC: &[u8; 4] = b"\x7FELF";

pub struct ElfSegment {
pub name: Option<String>,
pub data: Vec<u8>,
pub phys_addr: u64,
pub virt_addr: u64,
pub loadable: bool,
attrs: u32,
}

#[derive(IntoBytes, Immutable)]
#[repr(C)]
pub struct TableMetadata {
pub base_addr: u64,
pub pgd: [u64; 64],
}

impl ElfSegment {
pub fn mem_size(&self) -> u64 {
self.data.len() as u64
Expand Down Expand Up @@ -211,6 +221,7 @@ impl ElfFile {
.copy_from_slice(&bytes[segment_start..segment_end]);

let segment = ElfSegment {
name: None,
data: segment_data,
phys_addr: phent.paddr,
virt_addr: phent.vaddr,
Expand Down Expand Up @@ -363,4 +374,42 @@ impl ElfFile {
pub fn loadable_segments(&self) -> Vec<&ElfSegment> {
self.segments.iter().filter(|s| s.loadable).collect()
}

pub fn create_segment(&mut self, segment_name: &str, size: u64) -> ElfSegment {
let mut last_addr = 0;
for segment in self.segments.iter() {
if segment.virt_addr > last_addr {
last_addr = segment.virt_addr + segment.data.len() as u64;
}
}

// Align the last address we found to a page boundary
last_addr = last_addr + (PageSize::Small as u64 - (last_addr % PageSize::Small as u64));

ElfSegment {
name: Some(segment_name.to_string()),
data: vec![0; size as usize],
phys_addr: last_addr,
virt_addr: last_addr,
loadable: true,
attrs: ElfSegmentAttributes::Read as u32,
}
}

pub fn get_segment(&mut self, segment_name: &str) -> Option<&mut ElfSegment> {
for segment in self.segments.iter_mut() {
if let Some(name) = &segment.name {
if name == segment_name {
return Some(segment);
}
}
}
None
}

pub fn populate_segment(&mut self, segment_name: &str, data: &[u8]) {
let mut segment = self.get_segment(segment_name).unwrap();
assert!(data.len() <= segment.data.len());
segment.data = data.to_vec();
}
}
Loading