multiboot

Crates.iomultiboot
lib.rsmultiboot
version0.8.0
sourcesrc
created_at2015-03-18 20:35:22.149827
updated_at2022-04-25 02:58:45.621277
descriptionLibrary to access multiboot structures.
homepagehttps://github.com/gz/rust-multiboot
repositoryhttps://github.com/gz/rust-multiboot
max_upload_size
id1605
size101,792
Gerd Zellweger (gz)

documentation

https://docs.rs/multiboot/

README

Multiboot Crates.io Build

This is a multiboot (v1) library written entirely in rust. The code depends only on libcore.

How-to use

extern crate core;

use multiboot::information::{MemoryManagement, Multiboot, PAddr};
use core::{slice, mem};

struct Mem;

impl MemoryManagement for Mem {
    unsafe fn paddr_to_slice(&self, addr: PAddr, size: usize) -> Option<&'static [u8]> {
        let ptr = mem::transmute(addr);
        Some(slice::from_raw_parts(ptr, size))
    }
    
    // If you only want to read fields, you can simply return `None`.
    unsafe fn allocate(&mut self, _length: usize) -> Option<(PAddr, &mut [u8])> {
        None
    }
    
    unsafe fn deallocate(&mut self, addr: PAddr) {
        if addr != 0 {
            unimplemented!()
        }
    }
}

static mut MEM: Mem = Mem;

/// mboot_ptr is the initial pointer to the multiboot structure
/// provided in %ebx on start-up.
pub fn use_multiboot(mboot_ptr: PAddr) -> Option<Multiboot<'static, 'static>> {
    unsafe {
        Multiboot::from_ptr(mboot_ptr, &mut MEM)
    }
}

Functionality is still not complete and patches are welcome!

Documentation

Commit count: 119

cargo fmt