Fix error returned from set_mmap

This commit is contained in:
Mark 2020-09-21 13:59:23 +03:00
parent a3642f482a
commit 7be4052928
2 changed files with 4 additions and 4 deletions

View File

@ -23,6 +23,7 @@ pub const FLAG_UPPER: u32 = 1 << 2;
pub enum Error {
BufferTooSmall,
BadPointer,
Error
}

View File

@ -30,13 +30,13 @@ impl LoadProtocol for ProtoV1 {
if self.memory_map.size == 0 || self.memory_map.address == 0 {
// Memory map pointer is stored
if ptr >= 0x100000000 as *const _ {
panic!("Memory map pointer crosses 4GiB");
return Err(Error::BadPointer);
}
self.memory_map.address = map.address;
} else {
if map.size > self.memory_map.size {
panic!("Can't fit memory map");
return Err(Error::BufferTooSmall);
}
unsafe {
extern "C" {
@ -48,8 +48,7 @@ impl LoadProtocol for ProtoV1 {
self.memory_map.size = map.size;
self.memory_map.entsize = map.entsize;
Err(Error::BufferTooSmall)
Ok(())
}
fn set_initrd(&mut self, base: usize, size: usize) {
if self.initrd_base + self.initrd_size >= 0x100000000 {