Skip to content

Commit

Permalink
Compile fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thepowersgang committed Jun 25, 2024
1 parent ff81359 commit 964803a
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"editor.insertSpaces": false
"editor.insertSpaces": false,
"rust-analyzer.check.extraEnv": {
"RUSTFLAGS": "--cfg in_ide"
}
}
1 change: 1 addition & 0 deletions Kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ acpica = [ "kernel/acpica" ]

[dependencies]
kernel = { path = "Core" }

vfs = { path = "Modules/vfs" }
syscalls = { path = "Modules/syscalls" }
network = { path = "Modules/network" }
Expand Down
19 changes: 19 additions & 0 deletions Kernel/Core/arch/imp-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ pub mod memory {
//todo!("AddressSpace::new");
}
}
// HACK: Deref to the architecture-specific version
impl ::core::ops::Deref for AddressSpace {
#[cfg(target_arch="x86_64")]
type Target = crate::arch::amd64::memory::virt::AddressSpace;
fn deref(&self) -> &Self::Target { unreachable!() }
}
impl ::core::ops::DerefMut for AddressSpace {
fn deref_mut(&mut self) -> &mut Self::Target { unreachable!() }
}

pub fn post_init() {
}
Expand Down Expand Up @@ -239,6 +248,16 @@ pub mod threads {
thread_handle: Option<std::thread::JoinHandle<()>>,
inner: Arc<StateInner>,
}
// HACK: Deref to the architecture-specific thread state
// - This allows the IDE to show annotations for at least the current arch
impl ::core::ops::Deref for State {
#[cfg(target_arch="x86_64")]
type Target = crate::arch::amd64::threads::State;
fn deref(&self) -> &Self::Target { unreachable!() }
}
impl ::core::ops::DerefMut for State {
fn deref_mut(&mut self) -> &mut Self::Target { unreachable!() }
}
impl State
{
fn new_priv() -> State {
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Core/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cfg_if::cfg_if!{
pub use self::test as imp;

// TODO: Include all architectures here, with tricks so they compile (for testing/IDE)
//mod amd64;
#[cfg(any(/* in_ide, */target_arch="x86_64" ))] pub mod amd64;
}
else {
// It would be nice to have all architectures built when running
Expand Down
13 changes: 5 additions & 8 deletions Kernel/Core/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,13 @@ pub fn rust_begin_unwind(info: &::core::panic::PanicInfo) -> ! {
begin_panic_fmt(m, file_line)
}
else if let Some(m) = info.payload().downcast_ref::<&str>() {
begin_panic_fmt(&format_args!("{}", m), file_line)
}
else if let Some(m) = info.message() {
begin_panic_fmt(m, file_line)
begin_panic_fmt(&m, file_line)
}
else {
begin_panic_fmt(&format_args!("Unknown"), file_line)
begin_panic_fmt(&info.message(), file_line)
}
}
fn begin_panic_fmt(msg: &::core::fmt::Arguments, (file, line): (&str, u32)) -> !
fn begin_panic_fmt(msg: &impl ::core::fmt::Display, (file,line): (&str, u32)) -> !
{
static NESTED: ::core::sync::atomic::AtomicBool = ::core::sync::atomic::AtomicBool::new(false);
// TODO: Get the arch code to freeze the other CPUs (using an IPI)
Expand All @@ -89,8 +86,8 @@ fn begin_panic_fmt(msg: &::core::fmt::Arguments, (file, line): (&str, u32)) -> !
}
}
crate::arch::print_backtrace();
log_panic!("{}:{}: Panicked \"{:?}\"", file, line, msg);
crate::metadevs::video::set_panic(file, line as usize, msg);
log_panic!("{}:{}: Panicked \"{}\"", file, line, msg);
crate::metadevs::video::set_panic(file, line as usize, &format_args!("{}", msg));
loop{}
}
#[lang="eh_personality"]
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Modules/syscalls/threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl crate::objects::Object for ProtoProcess
let this = unsafe { ::core::ptr::read(self) };
match call
{
#[cfg(not(feature="native"))] // Not used in native mode
#[cfg(not(any(in_ide,feature="native")))] // Not used in native mode
values::CORE_PROTOPROCESS_START => {
let ip: usize = args.get()?;
let sp: usize = args.get()?;
Expand Down
9 changes: 3 additions & 6 deletions Usermode/libstd_rt/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod arch;
mod arch;

#[cfg_attr(test,allow(dead_code))]
fn begin_panic_fmt(msg: &::core::fmt::Arguments, file_line: (&str, u32)) -> ! {
fn begin_panic_fmt(msg: &impl ::core::fmt::Display, file_line: (&str, u32)) -> ! {
// Spit out that log
kernel_log!("PANIC: {}:{}: {}", file_line.0, file_line.1, msg);
// - Backtrace
Expand All @@ -69,13 +69,10 @@ pub fn rust_begin_unwind(info: &::core::panic::PanicInfo) -> ! {
begin_panic_fmt(m, file_line)
}
else if let Some(m) = info.payload().downcast_ref::<&str>() {
begin_panic_fmt(&format_args!("{}", m), file_line)
}
else if let Some(m) = info.message() {
begin_panic_fmt(m, file_line)
begin_panic_fmt(&m, file_line)
}
else {
begin_panic_fmt(&format_args!("Unknown"), file_line)
begin_panic_fmt(&info.message(), file_line)
}
}
#[lang="eh_personality"]
Expand Down
3 changes: 3 additions & 0 deletions rust_os.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"settings": {
"editor.useTabStops": true,
"editor.tabSize": 4,
"rust-analyzer.cargo.cfgs": {
"in_ide": "",
},
"rust-analyzer.server.extraEnv": { "ARCH": "native", "RUSTFLAGS": "--cfg arch=\"native\" --cfg in_ide" }
}
}

0 comments on commit 964803a

Please sign in to comment.