mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Use new Unique API (#346)
Change Unique to use `new_unchecked`. Fixes #345.
This commit is contained in:
committed by
Philipp Oppermann
parent
e54cfa4378
commit
2ebd4ed954
@@ -247,7 +247,7 @@ pub fn print_something() {
|
||||
let mut writer = Writer {
|
||||
column_position: 0,
|
||||
color_code: ColorCode::new(Color::LightGreen, Color::Black),
|
||||
buffer: unsafe { Unique::new(0xb8000 as *mut _) },
|
||||
buffer: unsafe { Unique::new_unchecked(0xb8000 as *mut _) },
|
||||
};
|
||||
|
||||
writer.write_byte(b'H');
|
||||
@@ -431,7 +431,7 @@ To provide a global writer that can used as an interface from other modules, we
|
||||
pub static WRITER: Writer = Writer {
|
||||
column_position: 0,
|
||||
color_code: ColorCode::new(Color::LightGreen, Color::Black),
|
||||
buffer: unsafe { Unique::new(0xb8000 as *mut _) },
|
||||
buffer: unsafe { Unique::new_unchecked(0xb8000 as *mut _) },
|
||||
};
|
||||
```
|
||||
|
||||
@@ -479,7 +479,7 @@ use spin::Mutex;
|
||||
pub static WRITER: Mutex<Writer> = Mutex::new(Writer {
|
||||
column_position: 0,
|
||||
color_code: ColorCode::new(Color::LightGreen, Color::Black),
|
||||
buffer: unsafe { Unique::new(0xb8000 as *mut _) },
|
||||
buffer: unsafe { Unique::new_unchecked(0xb8000 as *mut _) },
|
||||
});
|
||||
```
|
||||
[Mutex::new] is a const function, too, so it can be used in statics.
|
||||
|
||||
@@ -659,7 +659,7 @@ Because the `ActivePageTable` owns the unique recursive mapped P4 table, there m
|
||||
impl ActivePageTable {
|
||||
pub unsafe fn new() -> ActivePageTable {
|
||||
ActivePageTable {
|
||||
p4: Unique::new(table::P4),
|
||||
p4: Unique::new_unchecked(table::P4),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ pub struct Mapper {
|
||||
|
||||
impl Mapper {
|
||||
pub unsafe fn new() -> Mapper {
|
||||
Mapper { p4: Unique::new(table::P4) }
|
||||
Mapper { p4: Unique::new_unchecked(table::P4) }
|
||||
}
|
||||
|
||||
pub fn p4(&self) -> &Table<Level4> {
|
||||
|
||||
@@ -18,7 +18,7 @@ const BUFFER_WIDTH: usize = 80;
|
||||
pub static WRITER: Mutex<Writer> = Mutex::new(Writer {
|
||||
column_position: 0,
|
||||
color_code: ColorCode::new(Color::LightGreen, Color::Black),
|
||||
buffer: unsafe { Unique::new(0xb8000 as *mut _) },
|
||||
buffer: unsafe { Unique::new_unchecked(0xb8000 as *mut _) },
|
||||
});
|
||||
|
||||
macro_rules! println {
|
||||
|
||||
Reference in New Issue
Block a user