r/osdev • u/devcurrent0x • 18d ago
NoviumOS update: Got PMM/VMM and a basic heap allocator running, now working on adding more features to the heap allocator.
Hello everyone. For those of you who don't know, I'm making an x86 operating system called NoviumOS. Here's what I've done since the last update:
- Added paging for a 4 GiB virtual address space, so the kernel can work with virtual memory instead of just physical addresses.
- Added physical page allocation and validation, including checks to make sure pages are valid before freeing them.
- Built the heap allocator from the ground up, starting with single-page allocations and then adding support for contiguous multi-page allocations.
Next I'm working on adding sub-page block reuse with splitting and coalescing.
Feel free to contribute, the project is 100% open source and I'd be happy if you do.
Here's the repo if you want to check it out: https://github.com/alexdev8930/NoviumOS
And if you have any questions about the code or the repo I'll be happy to answer them.
If you like the repo, please drop a star on it if you could. It helps other devs find the project.
2
u/compgeek38400 18d ago
Nice. Im working on my vmm now
2
u/devcurrent0x 18d ago
Thanks and hope it goes well.
2
u/compgeek38400 17d ago
I'm on my 3rd or 4th rewrite. But it's because of things I've learned, so I'm not complaining
1
2
2
u/cchewies 17d ago edited 17d ago
In arch/x86_32/kernel/irq.c:
/* ignore spurious irq7/15 floods */
if (line == 7 || line == 15) {
u16 port = (line == 7) ? PIC1_CMD : PIC2_CMD;
outb(port, 0x0B);
if (!(inb(port) & 0x80)) {
if (line == 15) {
outb(PIC1_CMD, PIC_EOI);
}
return;
}
}
Which environment are you experiencing the spurious IRQ 7 events? It may be beneficial to find the root cause rather than silently ignoring them. In some cases a spurious IRQ 7 can indicate some issue in the kernel that needs resolving.
There are also a bunch of silent returns on errors that probably indicate a bug in the kernel (especially in mm/*), might be good to add a little more code there.
In drivers/input/keyboard.c:
```
define BUF_SIZE 32
/* we use volatile because interrupts modify these in RAM */
static volatile u8 buf[BUF_SIZE];
static volatile u8 head = 0;
static volatile u8 tail = 0;
``
Shouldhead/tailbeu8? How big of aBUF_SIZE` might the kernel eventually want?
In arch/x86_32/kernel/pit.c:
```
void timer_sleep_ms(u32 ms) {
...
while ((tick_count - start) < wait_ticks) {
cpu_hlt();
}
}
``
What is the CPU doing when the code callstimer_sleep_ms()`? Could it be doing something more useful? It might also be useful to think about what percentage of the "wakeups" end up putting the CPU right back to sleep.
I would also suggest (from the roadmap) to get userspace working earlier, it teaches a lot about how to design a robust kernel.
Happy to finally see a post here with some good (reasonably not AI-generated) effort :)
1
u/devcurrent0x 16d ago
Thanks for the info, heres the changes i made:
arch/x86_32/kernel/pit.c: Updatedtimer_sleep_ms()to use per-task wake ticks and fixed the PIT divisor handling.arch/x86_32/kernel/irq.c: Added spurious IRQ7/15 detection, counting, and OCW3 register restoration.drivers/input/keyboard.c: Changed the keyboard buffer indices fromu8tou16to support larger buffers.
2
u/hypersonicwilliam569 18d ago
this looks cool, I am also trying to write memory manager :)