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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "MIT"
authors = ["Stefan Lankes <slankes@eonerc.rwth-aachen.de>"]

[dependencies]
spin = "0.4.9" # Spinlocks.
#spin = "0.4.9" # Spinlocks.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#spin = "0.4.9" # Spinlocks.

cortex-a = "2.3.1"
register = "0.3.2"
r0 = "0.2.2"
Expand Down
2 changes: 1 addition & 1 deletion aarch64-eduos.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"linker": "lld-8",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "+a53,+strict-align,-fp-armv8",
Expand Down
9 changes: 8 additions & 1 deletion src/arch/aarch64/boot.S
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
* DEALINGS IN THE SOFTWARE.
*
*/

.section ".data"
.global boot_stack
.balign 0x10
boot_stack: .skip 0x2000

.section ".text.boot"

.global _start
Expand All @@ -38,7 +44,8 @@ _start:
2: // cpu id == 0

// init 1G stack stack in RAM area (>0x40000000 for qemu virt device)
movz x1, 0x5000, lsl 16
//movz x1, 0x5000, lsl 16
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a friend of leaving unused code in the file, would suggest to remove it. For viewing the diff to the qemu-version, I will create a qemu-branch, so one could simply do git diff.

Suggested change
//movz x1, 0x5000, lsl 16

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removing is the better option

ldr x1, =(boot_stack+0x2000-0x10)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great, if you could explain this line in a comment above

mov sp, x1

// jump to Rust code, should not return
Expand Down
4 changes: 1 addition & 3 deletions src/arch/aarch64/boot.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![no_std]

/// Some space for init stuff before calling `main()`.
#[no_mangle]
pub unsafe extern "C" fn init() -> ! {
Expand All @@ -14,4 +12,4 @@ pub unsafe extern "C" fn init() -> ! {
}

// Disable all cores except core 0, and then jump to init()
global_asm!(include_str!("boot.S"));
global_asm!(include_str!("boot.S"));
7 changes: 3 additions & 4 deletions src/arch/aarch64/serial.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::fmt;
use spin::Mutex;
use aarch64::io::*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using aarch64 crate here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what?

use core::ptr::write_volatile;

/// A COM serial port.
pub struct ComPort {
Expand All @@ -23,11 +22,11 @@ impl fmt::Write for ComPort {
// Output each byte of our string.
for &b in s.as_bytes() {
// Write our byte.
write_byte(self.port_address, b);
unsafe { write_volatile(self.port_address as *mut u8, b); }
}
Ok(())
}
}

/// Our primary serial port.
pub static COM1: Mutex<ComPort> = Mutex::new(ComPort::new(0x09000000));
pub static mut COM1: ComPort = ComPort::new(0x800 /*0x09000000*/);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub static mut COM1: ComPort = ComPort::new(0x800 /*0x09000000*/);
pub static mut COM1: ComPort = ComPort::new(0x800);

3 changes: 1 addition & 2 deletions src/arch/x86_64/serial.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use core::fmt;
use spin::Mutex;
use x86::io::*;

/// A COM serial port.
Expand Down Expand Up @@ -32,4 +31,4 @@ impl fmt::Write for ComPort {
}

/// Our primary serial port.
pub static COM1: Mutex<ComPort> = Mutex::new(ComPort::new(0x3F8));
pub static mut COM1: ComPort = ComPort::new(0x3F8);
5 changes: 1 addition & 4 deletions src/console.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
//! A wrapper around our serial console.

use core::fmt;
use spin::Mutex;
use arch::serial;

pub struct Console;

impl fmt::Write for Console {
/// Output a string to each of our console outputs.
fn write_str(&mut self, s: &str) -> fmt::Result {
serial::COM1.lock().write_str(s)
unsafe { serial::COM1.write_str(s) }
}
}

pub static CONSOLE: Mutex<Console> = Mutex::new(Console);
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(asm, const_fn, lang_items, global_asm)]
#![no_std]

extern crate spin;
//extern crate spin;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//extern crate spin;

#[cfg(target_arch = "x86_64")]
extern crate x86;

Expand Down
3 changes: 2 additions & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
macro_rules! print {
($($arg:tt)*) => ({
use core::fmt::Write;
$crate::console::CONSOLE.lock().write_fmt(format_args!($($arg)*)).unwrap();
let mut console: $crate::console::Console = $crate::console::Console{};
console.write_fmt(format_args!($($arg)*)).unwrap();
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
extern crate eduos_rs;

use core::panic::PanicInfo;
use core::ptr;
// use core::ptr;
// use eduos_rs::arch::processor::shutdown;

/// This is the main function called by `init()` function from boot.rs
Expand Down