Skip to content

Commit

Permalink
Add most of cpu.init() and improve kernel panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratakor committed Oct 12, 2023
1 parent 6f59e40 commit cac581d
Show file tree
Hide file tree
Showing 11 changed files with 358 additions and 101 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Ubik
A kernel
A microkernel

# TODO
- Add a checklist/roadmap
- Move tty and drivers out of kernel space
- Provide compatibility with Linux ABI
- Don't make a monolithic kernel
- Support RISC-V64, aarch64 and x86_64
- Replace limine with a custom bootloader?

Expand Down
7 changes: 3 additions & 4 deletions kernel/apic.zig
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub var io_apics = std.ArrayList(*const IOAPIC).init(root.allocator);
pub var isos = std.ArrayList(*const ISO).init(root.allocator);

pub fn init() void {
// TODO: this is done by all cpu not just bsp, change that >:(
// disable PIC
arch.out(u8, 0xa1, 0xff);
arch.out(u8, 0x21, 0xff);
Expand All @@ -78,8 +79,7 @@ pub fn timerOneShot(us: u64, vector: u8) void {

timerStop();

// TODO
const ticks = us; //* (cpu.this().lapic_freq / 1000000);
const ticks = us * (cpu.this().lapic_freq / 1000000);

writeRegister(.lvt_timer, vector);
writeRegister(.timer_divide, 0);
Expand Down Expand Up @@ -115,8 +115,7 @@ pub fn timerCalibrate() void {
const final_tick = pit.getCurrentCount();

const total_ticks: u64 = initial_tick - final_tick;
_ = total_ticks;
// cpu.this().lapic_freq = (samples / total_ticks) * pit.dividend;
cpu.this().lapic_freq = (samples / total_ticks) * pit.dividend;

timerStop();
}
Expand Down
Loading

0 comments on commit cac581d

Please sign in to comment.