axplat
This crate provides a unified abstraction layer for diverse hardware platforms. It allows kernel developers to bootstrap custom kernels across various platforms and interact with essential peripherals using hardware-agnostic APIs.
Interfaces can be divided into the following categories:
| Category | Trait | Description |
|---|---|---|
| init | InitIf |
Platform initialization |
| console | ConsoleIf |
Console input and output |
| power | PowerIf |
Power management |
| mem | MemIf |
Physical memory information |
| time | TimeIf |
Time-related operations |
| irq | IrqIf |
Interrupt request handling |
Each category of interfaces provides a trait (e.g., ConsoleIf) for a platform package to implement. You can use the corresponding platform-related functions in your project directly from the axplat crate without importing the specific platform package.
How to use in your kernel project
// Link you kernel with the specific platform package in some crate.
// extern crate your_platform_crate;
// Write your kernel code (can be in another crate).
!
More APIs can be found in the documentation. More example kernels can be found in the examples directory.
How to write a platform package
1. Implement each interface trait
use impl_plat_interface;
/// Implementation of Platform initialization.
;
/// Implementation of Console input and output.
;
// Implementation of other traits...
2. Implement platform bootstrapping code and call the entry function of axplat
unsafe extern "C" !
We also provide a cargo plugin called cargo-axplat for creating a new platform package and adding it into your project.
Some examples of platform packages for various platforms are listed in the platforms directory.