Fix error returned from set_mmap
This commit is contained in:
parent
a3642f482a
commit
7be4052928
@ -23,6 +23,7 @@ pub const FLAG_UPPER: u32 = 1 << 2;
|
|||||||
|
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
BufferTooSmall,
|
BufferTooSmall,
|
||||||
|
BadPointer,
|
||||||
Error
|
Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ impl LoadProtocol for ProtoV1 {
|
|||||||
if self.memory_map.size == 0 || self.memory_map.address == 0 {
|
if self.memory_map.size == 0 || self.memory_map.address == 0 {
|
||||||
// Memory map pointer is stored
|
// Memory map pointer is stored
|
||||||
if ptr >= 0x100000000 as *const _ {
|
if ptr >= 0x100000000 as *const _ {
|
||||||
panic!("Memory map pointer crosses 4GiB");
|
return Err(Error::BadPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.memory_map.address = map.address;
|
self.memory_map.address = map.address;
|
||||||
} else {
|
} else {
|
||||||
if map.size > self.memory_map.size {
|
if map.size > self.memory_map.size {
|
||||||
panic!("Can't fit memory map");
|
return Err(Error::BufferTooSmall);
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -48,8 +48,7 @@ impl LoadProtocol for ProtoV1 {
|
|||||||
|
|
||||||
self.memory_map.size = map.size;
|
self.memory_map.size = map.size;
|
||||||
self.memory_map.entsize = map.entsize;
|
self.memory_map.entsize = map.entsize;
|
||||||
|
Ok(())
|
||||||
Err(Error::BufferTooSmall)
|
|
||||||
}
|
}
|
||||||
fn set_initrd(&mut self, base: usize, size: usize) {
|
fn set_initrd(&mut self, base: usize, size: usize) {
|
||||||
if self.initrd_base + self.initrd_size >= 0x100000000 {
|
if self.initrd_base + self.initrd_size >= 0x100000000 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user