macro_rules! kernel {
(
name: $kernel_name:ident,
instance: $kernel_instance:ident,
main_arguments: ( $($main_arg_name:ident : $main_arg_type:ty),* $(,)? ),
devices: { $($dev_name:ident : $dev_type:ty => ($($dev_create_arg:tt)*) / ($($dev_init_arg:tt)*)),+ $(,)? },
stdout: None,
scheduler: $scheduler_type:ty => ($($scheduler_create_args:tt)*) / ($($scheduler_init_args:tt)*),
applications: { $($app_name:ident : $app_type:ty => ($($app_create_arg:tt)*)),+ $(,)? }
) => { ... };
(
name: $kernel_name:ident,
instance: $kernel_instance:ident,
main_arguments: ( $($main_arg_name:ident : $main_arg_type:ty),* $(,)? ),
devices: { $($dev_name:ident : $dev_type:ty => ($($dev_create_arg:tt)*) / ($($dev_init_arg:tt)*)),+ $(,)? },
stdout: $stdout_name:expr,
scheduler: $scheduler_type:ty => ($($scheduler_create_args:tt)*) / ($($scheduler_init_args:tt)*),
applications: { $($app_name:ident : $app_type:ty => ($($app_create_arg:tt)*)),* $(,)? }
) => { ... };
}Expand description
A kernel is defined with the mango_rt::kernel! macro. This defines:
- the name of the initialisation function (
name) - the name of the static instance (
instance). It is recommended that this is set toKERNEL_INSTANCE. - the arguments from the bootloader given to the main function (
main_arguments). - the list of devices defined by the kernel (
devices). - the device used for stdout (
stdout). - the scheduler used (
scheduler). - the list of applications (
applications).
Example of use:
mango_rt::kernel!(
name: hello_world_kernel,
instance: KERNEL_INSTANCE,
main_arguments: (boot_info: &'static bootloader::BootInfo),
devices: {
system: mango_hal::systems::x86_64::System => () / (boot_info),
vga_output: mango_hal::io::VgaTextBuffer => () / (),
},
stdout: Some(&KERNEL_INSTANCE.vga_output),
scheduler: mango_rt::schedulers::NoScheduler => (),
applications: {
hello_world: HelloWorld => ()
}
);