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

implement a new context switch #240

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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: 1 addition & 2 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ pre-release-replacements = [
{ file = "Changelog.md", search = "# Unreleased", replace = "# Unreleased\n\n# {{version}} – {{date}}", exactly = 1 },
]
pre-release-commit-message = "Release version {{version}}"

[patch.crates-io]
x86_64 = { git = "https://github.com/Freax13/x86_64", rev = "1335841" }
9 changes: 5 additions & 4 deletions api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ fn main() {
(31, 9),
(40, 9),
(49, 9),
(58, 10),
(68, 10),
(78, 1),
(79, 9),
(58, 9),
(67, 10),
(77, 10),
(87, 1),
(88, 9),
(97, 9),
(106, 9),
(115, 9),
];

let mut code = String::new();
Expand Down
24 changes: 16 additions & 8 deletions api/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl BootloaderConfig {
0x3D,
];
#[doc(hidden)]
pub const SERIALIZED_LEN: usize = 115;
pub const SERIALIZED_LEN: usize = 124;

/// Creates a new default configuration with the following values:
///
Expand Down Expand Up @@ -72,6 +72,7 @@ impl BootloaderConfig {
kernel_stack,
boot_info,
framebuffer,
gdt,
physical_memory,
page_table_recursive,
aslr,
Expand All @@ -94,45 +95,46 @@ impl BootloaderConfig {
let buf = concat_31_9(buf, kernel_stack.serialize());
let buf = concat_40_9(buf, boot_info.serialize());
let buf = concat_49_9(buf, framebuffer.serialize());
let buf = concat_58_9(buf, gdt.serialize());

let buf = concat_58_10(
let buf = concat_67_10(
buf,
match physical_memory {
Option::None => [0; 10],
Option::Some(m) => concat_1_9([1], m.serialize()),
},
);
let buf = concat_68_10(
let buf = concat_77_10(
buf,
match page_table_recursive {
Option::None => [0; 10],
Option::Some(m) => concat_1_9([1], m.serialize()),
},
);
let buf = concat_78_1(buf, [(*aslr) as u8]);
let buf = concat_79_9(
let buf = concat_87_1(buf, [(*aslr) as u8]);
let buf = concat_88_9(
buf,
match dynamic_range_start {
Option::None => [0; 9],
Option::Some(addr) => concat_1_8([1], addr.to_le_bytes()),
},
);
let buf = concat_88_9(
let buf = concat_97_9(
buf,
match dynamic_range_end {
Option::None => [0; 9],
Option::Some(addr) => concat_1_8([1], addr.to_le_bytes()),
},
);

let buf = concat_97_9(
let buf = concat_106_9(
buf,
match minimum_framebuffer_height {
Option::None => [0; 9],
Option::Some(addr) => concat_1_8([1], addr.to_le_bytes()),
},
);
let buf = concat_106_9(
let buf = concat_115_9(
buf,
match minimum_framebuffer_width {
Option::None => [0; 9],
Expand Down Expand Up @@ -189,6 +191,7 @@ impl BootloaderConfig {
let (&kernel_stack, s) = split_array_ref(s);
let (&boot_info, s) = split_array_ref(s);
let (&framebuffer, s) = split_array_ref(s);
let (&gdt, s) = split_array_ref(s);
let (&physical_memory_some, s) = split_array_ref(s);
let (&physical_memory, s) = split_array_ref(s);
let (&page_table_recursive_some, s) = split_array_ref(s);
Expand All @@ -203,6 +206,7 @@ impl BootloaderConfig {
kernel_stack: Mapping::deserialize(&kernel_stack)?,
boot_info: Mapping::deserialize(&boot_info)?,
framebuffer: Mapping::deserialize(&framebuffer)?,
gdt: Mapping::deserialize(&gdt)?,
physical_memory: match physical_memory_some {
[0] if physical_memory == [0; 9] => Option::None,
[1] => Option::Some(Mapping::deserialize(&physical_memory)?),
Expand Down Expand Up @@ -351,6 +355,8 @@ pub struct Mappings {
pub boot_info: Mapping,
/// Specifies the mapping of the frame buffer memory region.
pub framebuffer: Mapping,
/// Specifies the mapping of the GDT.
pub gdt: Mapping,
/// The bootloader supports to map the whole physical memory into the virtual address
/// space at some offset. This is useful for accessing and modifying the page tables set
/// up by the bootloader.
Expand Down Expand Up @@ -388,6 +394,7 @@ impl Mappings {
kernel_stack: Mapping::new_default(),
boot_info: Mapping::new_default(),
framebuffer: Mapping::new_default(),
gdt: Mapping::new_default(),
physical_memory: Option::None,
page_table_recursive: Option::None,
aslr: false,
Expand All @@ -404,6 +411,7 @@ impl Mappings {
kernel_stack: Mapping::random(),
boot_info: Mapping::random(),
framebuffer: Mapping::random(),
gdt: Mapping::random(),
physical_memory: if phys {
Option::Some(Mapping::random())
} else {
Expand Down
Loading