Skip to content

Commit ece5150

Browse files
author
Dan Cross
committed
global: prototype transfer vectors
Add a prototype transfer vector into `global`. Signed-off-by: Dan Cross <[email protected]>
1 parent be4a166 commit ece5150

File tree

7 files changed

+54
-10
lines changed

7 files changed

+54
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

global/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ edition = "2021"
1515
[dependencies]
1616
arch = { package = "x86_64", path = "../x86_64" }
1717
hypatia = { path = "../hypatia" }
18+
uart = { path = "../uart" }

global/src/link.ld

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 The Hypatia Authors
2+
* Copyright 2023 The Hypatia Authors
33
* All rights reserved
44
*
55
* Use of this source code is governed by an MIT-style
@@ -9,9 +9,17 @@
99

1010
ENTRY(init)
1111

12+
EXTERN(xferv);
13+
1214
SECTIONS {
1315
. = 0xFFFFFC0000000000;
1416

17+
.xferv . :
18+
{
19+
KEEP(*(.xferv*))
20+
}
21+
. = ALIGN(4096);
22+
1523
.text . :
1624
{
1725
*(.text*)

global/src/main.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
// Copyright 2021 The Hypatia Authors
1+
// Copyright 2023 The Hypatia Authors
22
// All rights reserved
33
//
44
// Use of this source code is governed by an MIT-style
55
// license that can be found in the LICENSE file or at
66
// https://opensource.org/licenses/MIT.
77

8+
#![feature(naked_functions)]
89
#![feature(strict_provenance)]
910
#![cfg_attr(not(test), no_main)]
1011
#![cfg_attr(not(test), no_std)]
1112
#![forbid(absolute_paths_not_starting_with_crate)]
1213
#![forbid(elided_lifetimes_in_paths)]
1314
#![forbid(unsafe_op_in_unsafe_fn)]
1415

15-
use arch::Page4K;
16-
17-
/// Returns a static reference to the global zero page.
18-
pub fn zero_page() -> &'static Page4K {
19-
const ZERO_PAGE: Page4K = Page4K::new();
20-
&ZERO_PAGE
21-
}
16+
mod x86_64;
2217

2318
/// Initialize the system.
2419
#[no_mangle]
2520
pub extern "C" fn init() {
26-
zero_page();
21+
uart::panic_println!("Hello from global");
2722
}
2823

2924
hypatia::runtime!();

global/src/x86_64/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright 2023 The Hypatia Authors
2+
// All rights reserved
3+
//
4+
// Use of this source code is governed by an MIT-style
5+
// license that can be found in the LICENSE file or at
6+
// https://opensource.org/licenses/MIT.
7+
8+
mod xferv;

global/src/x86_64/swtch.rs

Whitespace-only changes.

global/src/x86_64/xferv.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2023 The Hypatia Authors
2+
// All rights reserved
3+
//
4+
// Use of this source code is governed by an MIT-style
5+
// license that can be found in the LICENSE file or at
6+
// https://opensource.org/licenses/MIT.
7+
8+
use core::arch::asm;
9+
10+
#[export_name = "xferv"]
11+
#[link_section = ".xferv"]
12+
#[naked]
13+
unsafe extern "C" fn xferv() {
14+
unsafe {
15+
asm!(r#"
16+
.balign 8; jmp {hi};
17+
.balign 8; jmp {bye};
18+
"#,
19+
hi = sym hi,
20+
bye = sym bye,
21+
options(att_syntax, noreturn));
22+
}
23+
}
24+
25+
extern "C" fn hi() {
26+
uart::panic_println!("Hi!");
27+
}
28+
29+
extern "C" fn bye() {
30+
uart::panic_println!("Bye!");
31+
}

0 commit comments

Comments
 (0)