Rust has many useful abstractions and utils that require heap allocations. String
, Vec
and Box
are some of them. To be able to use them, we need to allocate memory at runtime, which requires a custom allocator.
If you want to find out more about it, please refer to the alloc::GlobalAllocator or alloc::Allocator and the Rust book for globalallocator or allocatorapi.
Add the following to your code to define new global allocator:
```rust use kernel_alloc::KernelAlloc;
static GLOBAL: KernelAlloc = KernelAlloc; ```
Add the following to your code to define new physical allocator:
rust
use kernel_alloc::PhysicalAllocator;