aboutsummaryrefslogtreecommitdiff
path: root/src/kernel.rs
blob: 9377eb5808595209f63ebdd247d1e55ef3b10473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Kernel Code

#![allow(non_snake_case)]
#![allow(clippy::upper_case_acronyms,dead_code)]
#![feature(format_args_nl)]
#![feature(panic_info_message)]
#![feature(trait_alias)]
#![feature(exclusive_range_pattern)]
#![no_main]
#![no_std]

mod alloc;
mod console;
mod cpu;
mod panic_wait;
mod print;
mod sync;
mod uart;
use crate::console::console;
use crate::alloc::CHAR_ALLOCATOR;

/// Initialization Code
unsafe fn kernel_init() -> ! {
	console().init().unwrap();
	CHAR_ALLOCATOR.init();
	kernel_main()
}

/// Post init
fn kernel_main() -> ! {
	for idx in 0..30 {
		if let Some(cell) = CHAR_ALLOCATOR.alloc() {
			cell.data = ('0' as u8 + idx as u8) as char;
			println!("SUCCESS: Allocated a char! {:?} {:?}", cell, CHAR_ALLOCATOR);
			CHAR_ALLOCATOR.free(cell);
		} else {
			println!("ERROR: No more chars remaining! {:?}", CHAR_ALLOCATOR);
		}
	}
	println!("I should be able to print {} here!", 5);
	loop { }
}