mirror of
https://github.com/iceHtwoO/novaOS.git
synced 2026-04-16 20:22:26 +00:00
Hello World on simulator
This commit is contained in:
5
.cargo/config.toml
Normal file
5
.cargo/config.toml
Normal file
@@ -0,0 +1,5 @@
|
||||
[build]
|
||||
target = "aarch64-unknown-none"
|
||||
|
||||
[target.aarch64-unknown-none]
|
||||
rustflags = ["-C", "link-arg=-Tlink.ld"]
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
25
.vscode/launch.json
vendored
Normal file
25
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to QEMU (AArch64)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/target/aarch64-unknown-none/debug/nova",
|
||||
"miDebuggerServerAddress": "localhost:1234",
|
||||
"miDebuggerPath": "gdb",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": true,
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "Run QEMU"
|
||||
}
|
||||
]
|
||||
}
|
||||
21
.vscode/tasks.json
vendored
Normal file
21
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build",
|
||||
"type": "shell",
|
||||
"command": "cargo build --target aarch64-unknown-none",
|
||||
"args": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Run QEMU",
|
||||
"type": "shell",
|
||||
"command": "qemu-system-aarch64 -M raspi3b -cpu cortex-a72 -display none -kernel ${workspaceFolder}/target/aarch64-unknown-none/debug/nova -s -S",
|
||||
"isBackground": true
|
||||
}
|
||||
]
|
||||
}
|
||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "nova"
|
||||
version = "0.1.0"
|
||||
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "nova"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
19
link.ld
Normal file
19
link.ld
Normal file
@@ -0,0 +1,19 @@
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x80000; /* Kernel load address for AArch64 */
|
||||
.text : { KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) }
|
||||
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r*) }
|
||||
PROVIDE(_data = .);
|
||||
.data : { *(.data .data.* .gnu.linkonce.d*) }
|
||||
.bss (NOLOAD) : {
|
||||
. = ALIGN(16);
|
||||
__bss_start = .;
|
||||
*(.bss .bss.*)
|
||||
*(COMMON)
|
||||
__bss_end = .;
|
||||
}
|
||||
_end = .;
|
||||
|
||||
/DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
|
||||
}
|
||||
__bss_size = (__bss_end - __bss_start)>>3;
|
||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
42
src/main.rs
Normal file
42
src/main.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
#![feature(asm_experimental_arch)]
|
||||
|
||||
use core::{
|
||||
arch::asm,
|
||||
fmt::{self, Write},
|
||||
panic::PanicInfo,
|
||||
};
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_panic: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
const UART0_DR: u32 = 0x3F20_1000;
|
||||
|
||||
struct Uart;
|
||||
|
||||
impl Write for Uart {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
for byte in s.bytes() {
|
||||
unsafe {
|
||||
core::ptr::write_volatile(UART0_DR as *mut u8, byte);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[unsafe(naked)]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
core::arch::naked_asm!("mov sp, #0x80000", "bl main");
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
fn main() {
|
||||
let mut uart = Uart {};
|
||||
writeln!(uart, "Hello World!\n");
|
||||
loop {}
|
||||
}
|
||||
3
tools/start_simulator.sh
Executable file
3
tools/start_simulator.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
qemu-system-aarch64 -M raspi3b -cpu cortex-a53 -serial stdio -display none -kernel ../target/aarch64-unknown-none/debug/nova -s
|
||||
Reference in New Issue
Block a user