mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Transition the code to Rust 2018
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
authors = ["Philipp Oppermann <dev@phil-opp.com>"]
|
||||
name = "blog_os"
|
||||
version = "0.2.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bootloader = "0.3.4"
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
#![cfg_attr(not(test), no_main)] // disable all Rust-level entry points
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
|
||||
|
||||
// add the library as dependency (same crate name as executable)
|
||||
#[macro_use]
|
||||
extern crate blog_os;
|
||||
|
||||
use blog_os::exit_qemu;
|
||||
use blog_os::{exit_qemu, serial_println};
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
/// This function is the entry point, since the linker looks for a function
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
#![cfg_attr(not(test), no_main)]
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate blog_os;
|
||||
extern crate x86_64;
|
||||
extern crate lazy_static;
|
||||
|
||||
use blog_os::exit_qemu;
|
||||
use blog_os::{exit_qemu, serial_println};
|
||||
use core::panic::PanicInfo;
|
||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
#![cfg_attr(not(test), no_main)]
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate blog_os;
|
||||
extern crate x86_64;
|
||||
extern crate lazy_static;
|
||||
|
||||
use blog_os::exit_qemu;
|
||||
use blog_os::{exit_qemu, serial_println};
|
||||
use core::panic::PanicInfo;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
#![cfg_attr(not(test), no_main)]
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate blog_os;
|
||||
|
||||
use blog_os::exit_qemu;
|
||||
use blog_os::{exit_qemu, serial_println};
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[cfg(not(test))]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// problem we skip compilation of this module on Windows.
|
||||
#![cfg(not(windows))]
|
||||
|
||||
use gdt;
|
||||
use crate::gdt;
|
||||
use pic8259_simple::ChainedPics;
|
||||
use spin;
|
||||
use x86_64::structures::idt::{ExceptionStackFrame, InterruptDescriptorTable};
|
||||
@@ -48,7 +48,7 @@ extern "x86-interrupt" fn double_fault_handler(
|
||||
stack_frame: &mut ExceptionStackFrame,
|
||||
_error_code: u64,
|
||||
) {
|
||||
use hlt_loop;
|
||||
use crate::hlt_loop;
|
||||
|
||||
println!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
||||
hlt_loop();
|
||||
|
||||
16
src/lib.rs
16
src/lib.rs
@@ -1,20 +1,6 @@
|
||||
#![no_std] // don't link the Rust standard library
|
||||
#![cfg_attr(not(test), no_std)] // don't link the Rust standard library
|
||||
#![feature(abi_x86_interrupt)]
|
||||
|
||||
extern crate bootloader;
|
||||
extern crate spin;
|
||||
extern crate volatile;
|
||||
extern crate lazy_static;
|
||||
extern crate pic8259_simple;
|
||||
extern crate uart_16550;
|
||||
extern crate x86_64;
|
||||
extern crate pc_keyboard;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate array_init;
|
||||
#[cfg(test)]
|
||||
extern crate std;
|
||||
|
||||
#[macro_use]
|
||||
pub mod vga_buffer;
|
||||
pub mod gdt;
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
#![cfg_attr(not(test), no_main)] // disable all Rust-level entry points
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate blog_os;
|
||||
extern crate x86_64;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
use blog_os::println;
|
||||
|
||||
/// This function is the entry point, since the linker looks for a function
|
||||
/// named `_start` by default.
|
||||
#[cfg(not(test))]
|
||||
|
||||
@@ -33,7 +33,7 @@ macro_rules! serial_print {
|
||||
/// Prints to the host through the serial interface, appending a newline.
|
||||
#[macro_export]
|
||||
macro_rules! serial_println {
|
||||
() => (serial_print!("\n"));
|
||||
($fmt:expr) => (serial_print!(concat!($fmt, "\n")));
|
||||
($fmt:expr, $($arg:tt)*) => (serial_print!(concat!($fmt, "\n"), $($arg)*));
|
||||
() => ($crate::serial_print!("\n"));
|
||||
($fmt:expr) => ($crate::serial_print!(concat!($fmt, "\n")));
|
||||
($fmt:expr, $($arg:tt)*) => ($crate::serial_print!(concat!($fmt, "\n"), $($arg)*));
|
||||
}
|
||||
|
||||
@@ -157,9 +157,9 @@ macro_rules! print {
|
||||
/// Like the `print!` macro in the standard library, but prints to the VGA text buffer.
|
||||
#[macro_export]
|
||||
macro_rules! println {
|
||||
() => (print!("\n"));
|
||||
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
||||
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
||||
() => ($crate::print!("\n"));
|
||||
($fmt:expr) => ($crate::print!(concat!($fmt, "\n")));
|
||||
($fmt:expr, $($arg:tt)*) => ($crate::print!(concat!($fmt, "\n"), $($arg)*));
|
||||
}
|
||||
|
||||
/// Prints the given formatted string to the VGA text buffer through the global `WRITER` instance.
|
||||
|
||||
Reference in New Issue
Block a user