Skip to content

Commit 6cf5d47

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 4fa026c commit 6cf5d47

File tree

7 files changed

+52
-2
lines changed

7 files changed

+52
-2
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 = "2024"
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
@@ -11,6 +11,8 @@
1111
#![forbid(elided_lifetimes_in_paths)]
1212
#![forbid(unsafe_op_in_unsafe_fn)]
1313

14+
mod x86_64;
15+
1416
use arch::Page4K;
1517

1618
/// Returns a static reference to the global zero page.
@@ -23,6 +25,7 @@ pub fn zero_page() -> &'static Page4K {
2325
#[unsafe(no_mangle)]
2426
pub extern "C" fn init() {
2527
zero_page();
28+
uart::panic_println!("Hello from global");
2629
}
2730

2831
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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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::naked_asm;
9+
10+
#[unsafe(export_name = "xferv")]
11+
#[unsafe(link_section = ".xferv")]
12+
#[unsafe(naked)]
13+
unsafe extern "C" fn xferv() {
14+
naked_asm!(r#"
15+
.balign 8; jmp {hi};
16+
.balign 8; jmp {bye};
17+
"#,
18+
hi = sym hi,
19+
bye = sym bye,
20+
options(att_syntax));
21+
}
22+
23+
extern "C" fn hi() {
24+
uart::panic_println!("Hi!");
25+
}
26+
27+
extern "C" fn bye() {
28+
uart::panic_println!("Bye!");
29+
}

0 commit comments

Comments
 (0)