Commit 4f533262 authored by Stefan Lankes's avatar Stefan Lankes
Browse files

using AllocError to indicate an allocation failure

parent 1f30129c
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be // http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms. // copied, modified, or distributed except according to those terms.
use core::convert::TryInto; use core::{alloc::AllocError, convert::TryInto};
use crate::arch::aarch64::mm::paging::{BasePageSize, PageSize}; use crate::arch::aarch64::mm::paging::{BasePageSize, PageSize};
use crate::arch::aarch64::mm::{PhysAddr, VirtAddr}; use crate::arch::aarch64::mm::{PhysAddr, VirtAddr};
...@@ -43,7 +43,7 @@ pub fn total_memory_size() -> usize { ...@@ -43,7 +43,7 @@ pub fn total_memory_size() -> usize {
pub fn init_page_tables() {} pub fn init_page_tables() {}
pub fn allocate(size: usize) -> Result<PhysAddr, ()> { pub fn allocate(size: usize) -> Result<PhysAddr, AllocError> {
assert!(size > 0); assert!(size > 0);
assert_eq!( assert_eq!(
size % BasePageSize::SIZE, size % BasePageSize::SIZE,
...@@ -62,7 +62,7 @@ pub fn allocate(size: usize) -> Result<PhysAddr, ()> { ...@@ -62,7 +62,7 @@ pub fn allocate(size: usize) -> Result<PhysAddr, ()> {
)) ))
} }
pub fn allocate_aligned(size: usize, alignment: usize) -> Result<PhysAddr, ()> { pub fn allocate_aligned(size: usize, alignment: usize) -> Result<PhysAddr, AllocError> {
assert!(size > 0); assert!(size > 0);
assert!(alignment > 0); assert!(alignment > 0);
assert_eq!( assert_eq!(
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be // http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms. // copied, modified, or distributed except according to those terms.
use core::convert::TryInto; use core::{alloc::AllocError, convert::TryInto};
use crate::arch::aarch64::mm::paging::{BasePageSize, PageSize}; use crate::arch::aarch64::mm::paging::{BasePageSize, PageSize};
use crate::arch::aarch64::mm::{PhysAddr, VirtAddr}; use crate::arch::aarch64::mm::{PhysAddr, VirtAddr};
...@@ -32,7 +32,7 @@ pub fn init() { ...@@ -32,7 +32,7 @@ pub fn init() {
KERNEL_FREE_LIST.lock().list.push_back(entry); KERNEL_FREE_LIST.lock().list.push_back(entry);
} }
pub fn allocate(size: usize) -> Result<VirtAddr, ()> { pub fn allocate(size: usize) -> Result<VirtAddr, AllocError> {
assert!(size > 0); assert!(size > 0);
assert_eq!( assert_eq!(
size % BasePageSize::SIZE, size % BasePageSize::SIZE,
...@@ -51,7 +51,7 @@ pub fn allocate(size: usize) -> Result<VirtAddr, ()> { ...@@ -51,7 +51,7 @@ pub fn allocate(size: usize) -> Result<VirtAddr, ()> {
)) ))
} }
pub fn allocate_aligned(size: usize, alignment: usize) -> Result<VirtAddr, ()> { pub fn allocate_aligned(size: usize, alignment: usize) -> Result<VirtAddr, AllocError> {
assert!(size > 0); assert!(size > 0);
assert!(alignment > 0); assert!(alignment > 0);
assert_eq!( assert_eq!(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment