Commit Graph

104 Commits

Author SHA1 Message Date
6084aae603 Kernel: Add guard pages to kernel and userspace stacks 2025-07-02 23:12:36 +03:00
17f1ac10e3 Kernel: Don't ignore modules passed with multiboot2 2025-07-02 00:17:42 +03:00
eecdad50a6 Kernel: Fix most of mutex + block race conditions
All block functions now take an optional mutex parameter that is
atomically unlocked instead of having the user unlock it before hand.
This prevents a ton of race conditions everywhere in the code!
2025-06-06 03:59:22 +03:00
60d1c26114 Kernel: Fix race condition in FileBackedRegion creation 2025-06-01 13:48:03 +03:00
d54489bbcb Kernel: Implement MemoryRegion pinning
This allows process to pin a MemoryRegion into users memory space for
syscall duration without allowing user to munmap the region.
2025-04-22 04:30:07 +03:00
76bad31dd5 Kernel: Reorder locking with VirtualRange 2025-04-01 23:09:30 +03:00
e6a2f55a59 Kernel: Closing file backed mmap wont expand the file size 2024-12-03 16:12:26 +02:00
64c52012df Kernel: Fix MemoryRegion overlap comparison
This made some calls to `munmap` unmap extra regions.
2024-11-13 17:26:42 +02:00
f0b18da881 Kernel: Add kmalloc helper APIs 2024-10-14 11:39:04 +03:00
2b43569927 Kernel: Use enums in boot info instead of magic values 2024-10-14 11:36:51 +03:00
55fbd09e45 Kernel: Rewrite physical memory allocation with PageTable::fast_pages 2024-10-14 11:32:54 +03:00
54732edff4 Kernel: Fix bugs in memory regions
MemoryRegion::initialize() required size to be page aligned, this is not
necessary.

MemoryBackedRegion::copy_data_to_region() required user-write
permissions for underlying data. This did not matter as memory backed
regions dont support COW memory, but it could lead to bugs later on.
2024-09-15 23:18:05 +03:00
c77ad5fb34 Kernel: Implement copy-on-write memory for file backed mmaps 2024-09-11 19:33:50 +03:00
de35cec2e1 Kernel: Allow private file mappings past file end
This is just to make memory mapping ELF files easier :D
2024-09-05 14:48:42 +03:00
2f241e1b61 Kernel: Implement FileBackedRegion::clone 2024-09-05 13:59:09 +03:00
1138ec77ca Kernel: Fix MemoryBackedRegion cloning for non page aligned size 2024-09-04 21:14:26 +03:00
a134d16070 Kernel: Fix MemoryRegion test for contains_fully 2024-08-30 15:33:58 +03:00
fb35f06cf5 Kernel: Add better support for bootloaders loading the kernel
Before I assumed that bootloaders loaded the kernel at physical address
0, but this patch kinda allows loading to different addresses. This
still doesn't fully work as kernel bootstrap paging relies on kernel
being loaded at 0
2024-08-22 14:48:21 +03:00
9bc02c81f8 Kernel: Map DMA and PCI MMIO as uncached 2024-07-30 11:10:08 +03:00
96c7e9e29d Kernel: Cleanup VirtualRange code
Virtual range does not need to look into the page table for mapped
physcial pages. It can (and should) just keep track of them itself.
2024-07-21 17:35:07 +03:00
0578d41500 Kernel: Implement WriteCombining memory
This makes framebuffer much faster on real hardware
2024-07-15 22:09:09 +03:00
bd1290706a Kernel: Implement SharedMemoryObject cloning 2024-06-03 03:41:00 +03:00
8bfacb0091 Kernel: Implement deletion of SMO objects 2024-05-31 13:04:23 +03:00
6840a8983c Kernel: Make sure MSB is not set on SMO keys 2024-05-29 20:01:12 +03:00
d4d530e6c8 Kernel: Implement basic shared memory objects
These can allocate memory that can be shared between processes using
a global key. There is currenly no safety checks meaning anyone can
map any shared memory object just by trying to map every possible key.
2024-05-29 15:58:46 +03:00
9c36d7c338 BAN/Kernel: Rework assertion/panic system
BAN/Assert.h does not need any includes meaning it can be included
anywhere without problems.
2024-03-04 11:41:54 +02:00
8141b9977d Kernel: Per processor information is now stored in class Processor
This allows us to allocate processor stacks, and other per processor
structures dynamically in runtime. Giving processor stack to
ap_trampoline feels super hacky, but it works for now.
2024-03-03 22:30:06 +02:00
ec0cb5fd54 Kernel: Remove CriticalScopes from memory handing code 2024-02-29 19:16:41 +02:00
d94f6388b7 Kernel: Fix all broken locks from new mutexes 2024-02-28 22:45:34 +02:00
6d59a2b45d Kernel: Remove VirtualRanges created in kmalloc memory
These were only used as stacks of kernel threads, but they can just
as well be allocated as full pages from Heap
2024-02-28 13:19:18 +02:00
09c24088a2 Kernel: Cleanup kmalloc VirtualRange creation 2024-02-28 13:19:18 +02:00
e26f360d93 Kernel: allow kmalloc of size 0 2024-02-07 22:36:24 +02:00
dfe5a2d665 All: Cleanup all files
Add newline to end of files and remove whitespace from end of lines
2024-01-24 15:53:38 +02:00
9b841cb823 BuildSystem/Kernel: Enable -Wextra and -Werror in kernel
Only needed to fix some unused variable bugs
2023-12-01 01:22:53 +02:00
60e755210c Kernel/LibC: Implement very basic msync 2023-11-22 22:44:06 +02:00
84040e64b8 Kernel: Don't use multiboot2 explicitly. Parse it to common structure
This allows support of multiple different bootloaders
2023-11-17 18:54:59 +02:00
ca34ece8ef BAN: Update ASSERT api
its now much harder to mix < with <= and > with >=
2023-11-02 00:01:12 +02:00
640d27748f Kernel: Temporarily force FileBackedRegion mappings writable
Now that write-protect bit is enabled this is neccessary.
2023-10-30 19:08:33 +02:00
42772611ce Kernel: Add fast page to page table
Add "fast page" to KERNEL_OFFSET. This is always present in page
tables and only requires changing the page table entry to map. This
requires no interrupts since it should only be for very operations
like memcpy.

I used to map all temporary mappings to vaddr 0, but this is much
better. C++ standard always says that nullptr access is undefined
and this gets rid of it.

Fixed some bugs I found along the way
2023-10-30 19:02:09 +02:00
6e676ee8c5 Kernel: Remove GeneralAllocator since it was not used 2023-10-30 18:13:17 +02:00
f3d9da9549 Kernel: Rewrite all read/write functions to use BAN::ByteSpan
This allows us to not work with raw pointers and use sized containers
for reading and writing.
2023-10-24 11:56:00 +03:00
69a39b7077 Kernel: Start using multiboot2 instead of multiboot
This allows better compatibility with (U)EFI and gives RSDP location
instead of me having to scan ram to find it.
2023-10-17 01:06:24 +03:00
b3b8376cca Kernel: Fix PhysicalRange mapping size 2023-10-13 03:45:01 +03:00
d4c9f371a6 Kernel: make DMARegion::create static and fix mapping 2023-10-08 18:18:36 +03:00
2aabf43ace Kernel: fix some math in physical ranges
I allocated 1 bitmap page per 8 data pages. Bitmap page can actually
store 8*PAGE_SIZE data pages.

Also properly set last bits in bitmap. I did not care about endianness
but now we set the bits on unsigned long longs instead of bytes.
2023-10-08 13:25:34 +03:00
a6ca9fd453 Kernel: Implement bare boness DMA Region
This does nothing but allocate contiguous physical and virtual memory
and map it as CacheDisable. Also memory is automatically freed RAII style.
2023-10-08 02:57:22 +03:00
799aab02f5 Kernel: Add API for getting contiguous physcial pages
This will be used to create DMA regions.
2023-10-08 02:57:22 +03:00
0fae2c7309 Kernel: Rework physical memory allocation
PhysicalRange is now much simpler bitmap. This makes expanding
PhysicalRange API much easier.
2023-10-08 02:50:23 +03:00
27eb5af6f0 Kernel: Rework interrupt mechanism
All interruptrable classes now inherit from Interruptable which
has methdo handle_irq which is called on a interrupt.
2023-10-05 18:53:45 +03:00
Bananymous
5ee3506474 Kernel: Add physical memory info to /proc/{pid}/meminfo 2023-09-30 22:11:45 +03:00