mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Mark _start as extern; fix wrong entry point name
This commit is contained in:
@@ -210,7 +210,7 @@ pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle] // don't mangle the name of this function
|
#[no_mangle] // don't mangle the name of this function
|
||||||
pub fn _start() -> ! {
|
pub extern fn _start() -> ! {
|
||||||
// this function is the entry point, since the linker looks for a function
|
// this function is the entry point, since the linker looks for a function
|
||||||
// named `_start` by default
|
// named `_start` by default
|
||||||
loop {}
|
loop {}
|
||||||
@@ -277,7 +277,7 @@ The implementation looks like this:
|
|||||||
static HELLO: &[u8] = b"Hello World!";
|
static HELLO: &[u8] = b"Hello World!";
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn _start() -> ! {
|
pub extern fn _start() -> ! {
|
||||||
let vga_buffer = 0xb8000 as *const u8 as *mut u8;
|
let vga_buffer = 0xb8000 as *const u8 as *mut u8;
|
||||||
|
|
||||||
for (i, &byte) in HELLO.iter().enumerate() {
|
for (i, &byte) in HELLO.iter().enumerate() {
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ Now we can delete the `print_something` function and print directly from our `_s
|
|||||||
```rust
|
```rust
|
||||||
// in src/main.rs
|
// in src/main.rs
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn _start() -> ! {
|
pub extern fn _start() -> ! {
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
vga_buffer::WRITER.lock().write_str("Hello again").unwrap();
|
vga_buffer::WRITER.lock().write_str("Hello again").unwrap();
|
||||||
write!(vga_buffer::WRITER.lock(), ", some numbers: {} {}", 42, 1.337).unwrap();
|
write!(vga_buffer::WRITER.lock(), ", some numbers: {} {}", 42, 1.337).unwrap();
|
||||||
@@ -586,7 +586,7 @@ To use `println` in `main.rs`, we need to import the macros of the VGA buffer mo
|
|||||||
mod vga_buffer;
|
mod vga_buffer;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn rust_main() {
|
pub extern fn _start() {
|
||||||
println!("Hello World{}", "!");
|
println!("Hello World{}", "!");
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ mod vga_buffer;
|
|||||||
/// This function is the entry point, since the linker looks for a function
|
/// This function is the entry point, since the linker looks for a function
|
||||||
/// named `_start_` by default.
|
/// named `_start_` by default.
|
||||||
#[no_mangle] // don't mangle the name of this function
|
#[no_mangle] // don't mangle the name of this function
|
||||||
pub fn _start() -> ! {
|
pub extern fn _start() -> ! {
|
||||||
println!("Hello World{}", "!");
|
println!("Hello World{}", "!");
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
|
|||||||
Reference in New Issue
Block a user