forked from DragonOS-Community/DragonOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 添加对内核引导协议的抽象 (DragonOS-Community#913)
* 添加multiboot header * head.S传参增加bootloader类型 * feat: 添加引导加载协议的抽象,并为multiboot2实现这个抽象. * 把framebuffer的映射地址改为从early ioremap和mmio pool分配 * riscv64能运行
- Loading branch information
Showing
42 changed files
with
828 additions
and
1,329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ | |
:caption: 目录 | ||
|
||
bootloader | ||
multiboot2 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use system_error::SystemError; | ||
|
||
use super::dragonstub::early_dragonstub_init; | ||
|
||
#[derive(Debug)] | ||
#[repr(u64)] | ||
pub(super) enum BootProtocol { | ||
DragonStub = 1, | ||
} | ||
|
||
pub(super) fn early_boot_init(protocol: BootProtocol) -> Result<(), SystemError> { | ||
match protocol { | ||
BootProtocol::DragonStub => early_dragonstub_init(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use alloc::string::String; | ||
use system_error::SystemError; | ||
|
||
use crate::{ | ||
driver::video::fbdev::base::BootTimeScreenInfo, | ||
init::boot::{register_boot_callbacks, BootCallbacks, BootloaderAcpiArg}, | ||
}; | ||
|
||
pub(super) fn early_dragonstub_init() -> Result<(), SystemError> { | ||
register_boot_callbacks(&DragonStubCallBack); | ||
Ok(()) | ||
} | ||
|
||
struct DragonStubCallBack; | ||
|
||
impl BootCallbacks for DragonStubCallBack { | ||
fn init_bootloader_name(&self) -> Result<Option<String>, SystemError> { | ||
Ok(format!("DragonStub").into()) | ||
} | ||
|
||
fn init_acpi_args(&self) -> Result<BootloaderAcpiArg, SystemError> { | ||
Ok(BootloaderAcpiArg::NotProvided) | ||
} | ||
|
||
fn init_kernel_cmdline(&self) -> Result<(), SystemError> { | ||
// parsed in `early_init_scan_chosen()` | ||
Ok(()) | ||
} | ||
|
||
fn early_init_framebuffer_info( | ||
&self, | ||
_scinfo: &mut BootTimeScreenInfo, | ||
) -> Result<(), SystemError> { | ||
unimplemented!("dragonstub early_init_framebuffer_info") | ||
} | ||
|
||
fn early_init_memory_blocks(&self) -> Result<(), SystemError> { | ||
// parsed in `early_init_scan_memory()` and uefi driver | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
pub fn rand() -> usize { | ||
unimplemented!("RiscV64 rand"); | ||
static mut SEED: u64 = 0xdead_beef_cafe_babe; | ||
let mut buf = [0u8; size_of::<usize>()]; | ||
for x in buf.iter_mut() { | ||
unsafe { | ||
// from musl | ||
SEED = SEED.wrapping_mul(0x5851_f42d_4c95_7f2d); | ||
*x = (SEED >> 33) as u8; | ||
} | ||
} | ||
let x: usize = unsafe { core::mem::transmute(buf) }; | ||
return x; | ||
} |
Oops, something went wrong.