Initial commit

This commit is contained in:
Mark 2020-09-20 18:10:21 +03:00
commit f201545a9e
3 changed files with 71 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
Cargo.lock

9
Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "yboot2-proto"
version = "0.1.0"
authors = ["Mark <alnyan@airmail.cc>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

60
src/lib.rs Normal file
View File

@ -0,0 +1,60 @@
const CMDLINE_SIZE: usize = 256;
pub trait LoadProtocol: Sized {
const KERNEL_MAGIC: [u8; 8];
fn set_loader_magic(&mut self);
fn set_mmap(&mut self, map: &MemoryMap);
fn set_initrd(&mut self, base: usize, size: usize);
fn set_acpi_rsdp(&mut self, rsdp: usize);
fn set_video_info(&mut self, info: &VideoInfo);
fn get_video_request(&self) -> VideoRequest;
}
pub struct VideoRequest {
pub width: u32,
pub height: u32,
pub format: PixelFormat
}
pub struct VideoInfo {
pub width: u32,
pub height: u32,
pub format: PixelFormat,
pub framebuffer: usize,
pub pitch: usize
}
#[repr(C)]
pub struct Header {
kernel_magic: [u8; 8],
loader_magic: [u8; 8]
}
#[repr(C)]
pub struct ProtoV1 {
hdr: Header,
memory_map_data: u64,
memory_map_size: u32,
memory_map_entsize: u32,
video_width: u32,
video_height: u32,
video_format: u32,
_pad0: u32,
video_framebuffer: u64,
video_pitch: u64,
elf_symtab_hdr: u64,
elf_symtab_data: u64,
elf_strtab_hdr: u64,
elf_strtab_data: u64,
initrd_base: u64,
initrd_size: u64,
rsdp: u64,
cmdline: [u8; CMDLINE_SIZE]
}