Commit graph vbos/mem/buddy.c
Author SHA1 Message Date
2076f1dae1
lock: merge spinlock and mtx locks into one
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
2026-08-13 14:19:10 -04:00
b8560b4577 buddy: fix bug in buddy_zone_free
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
2026-07-19 17:40:11 -04:00
4eb1841158 buddy: add fancy memmap printing to serial output
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
2026-07-17 03:57:39 -04:00
4096f03d32 buddy: fix page fault
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
2026-07-14 23:34:31 -04:00
6c2613ab96 buddy: add bounds check
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
2026-07-11 23:56:04 -04:00
2b0fed03d6 buddy: add free 2026-05-12 03:26:50 -04:00
a252a3f8e9 kv2: initialize memory manager, early pci devices
Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
2026-05-12 03:00:45 -04:00
Michael Shaw
d6873d6c7a kv2: add paging
this also fixes up a bunch of formatting, adding the type vaddr_t

Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
2026-04-13 00:04:26 -04:00
Michael Shaw
d2ef885e8d v2 initial commit 2026-04-11 11:35:31 -04:00
Michael Shaw
fdb319e96b paging: move paging from buddy.c into new file 2023-11-15 15:41:48 -05:00
Michael Shaw
4dc4f07dc6 mem: improve device memory mapping
MMIO ports will no longer directly map to HHDM addresses and will need
to be searched for in the memory mapping tree
2023-10-24 22:16:33 -04:00
Michael Shaw
cf035645e8 mem: flush tlb on kmap 2023-06-10 21:27:49 -04:00
Michael Shaw
30bf724282 kunmap: add error checking 2023-05-28 00:00:52 -04:00
Michael Shaw
8ee80d22c9 mem: add kunmap and begin tracking mapped pages 2023-05-27 23:24:39 -04:00
Michael Shaw
13437a219e page: do not invalidate kernel TLB entries
set the PAGE_GLOBAL attr for kernel pages
2023-05-23 23:23:10 -04:00
Michael Shaw
29a0435cf6 slab: replace struct slab with slab_t
This type should never be modified by the user, and only passed into the
functions in slab.c. Using a typedef to notifies the user semantically
of this fact
2023-05-19 16:49:34 -04:00
Michael Shaw
0395b65ad8 stdio: add vsnprintf and change printf to kprintf 2023-05-14 01:23:21 -04:00
Michael Shaw
d3e9b728dc slab: no longer automatically allocate slab cache sizes 2023-05-10 13:18:37 -04:00
Michael Shaw
29dd9b54e7 buddy: adjust memory mappings for early init
this massively speeds up boot on larger memory systems, as before this
was only tested on a 2GB system. Only identity mapping the first 4GB of
still allows MMIO to work, but without the massive space and time taken
by the previous method
2023-05-10 01:10:36 -04:00
Michael Shaw
d6828e5698 buddy: fix printf format size error 2023-05-10 00:47:57 -04:00
Michael Shaw
8544efe1ab slab: upgrade kmalloc to allow DMA regions
these DMA regions are only meant to comply with certain AHCI
requirements, and are not yet general purpose
2023-05-08 01:14:11 -04:00
Michael Shaw
c623f4a9fb mem: rename function 2023-05-07 15:28:52 -04:00
Michael Shaw
69ee1fd79c ahci: complete read/write sectors function 2023-05-07 15:21:04 -04:00
Michael Shaw
7db20603f6 ahci: add ahci_read_sectors function 2023-05-06 23:50:14 -04:00
Michael Shaw
adfa24dd1e ahci: complete hbafis_t struct 2023-05-06 17:27:52 -04:00
Michael Shaw
39c778d2f0 add some asserts 2023-05-04 02:02:17 -04:00
Michael Shaw
e1108b3493 mem: improve slabbing to include flags 2023-04-29 16:54:12 -04:00
Michael Shaw
aaeabe7b49 mem: switch kmap to slab allocation
allocating individual pages en-masse for kmap with the buddy allocator
is way too slow, especially with the new method of buddy allocation that
is noticeably slower to start, but scales more efficiently.

the slab allocator is extremely fast and is perfect for this purpose
2023-04-29 14:51:57 -04:00
Michael Shaw
9222a373fc buddy: replace free-lists with binary tree
before this patch, the buddy allocator used a hybrid bitmap-freelist
approach where free would use the bitmap to determine size, but all
other operations we O(n) traversals of the free-list.

now, both alloc and free use the bitmap exclusively for allocation.
2023-04-29 00:15:50 -04:00
Michael Shaw
9cf4b71559 revert apic change
this is now on its own branch and will be worked on separately from the
main focus of this project, which is to get a VFS and into userspace as
soon as possible
2023-04-22 14:47:46 -04:00
Michael Shaw
c78085373c mem: clean up mem_early_init
Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
2023-04-22 14:15:18 -04:00
Michael Shaw
2e59620395 mem: fix bug with kmap
the `next_level` function was calling `alloc_page_early` directly
instead of using the pointer `alloc_page`, causing the mapping to work
inconsistently.
2023-04-22 13:58:39 -04:00
Michael Shaw
22762339f9 irq: begin moving away from 8259
8259 PIC was used for interrupts for bootstrap development while the memory manager was being constructed. now that this is complete, a transition to the apic will begin

this patch fixes memory mapping issues with the reserved regions that caused page faults before.
2023-04-22 13:01:46 -04:00
Michael Shaw
addf96aae7 mem: fix bug with slab_create
before this would overwrite into the next region, which would cause an
error at `buddy_alloc_helper` as the region overridden was the `len`
field of a `struct buddy_free_list`
2023-04-20 21:43:43 -04:00
Michael Shaw
4239ca1b7e mem: replace mem_initialized bool with function pointer 2023-04-20 15:41:19 -04:00
Michael Shaw
7303bcc3e2 mem.c: cleanup 2023-04-19 17:37:18 -04:00
Michael Shaw
5b79d54440 mem: fix next_level function
add the OR hhdm_start to the return address since this returns a
(uint64_t *) and not a paddr_t
2023-04-19 17:35:21 -04:00
Michael Shaw
fc08269219 mem: clarify comments on buddy allocator 2023-04-18 14:12:21 -04:00
Michael Shaw
a08a7dd1a4 mem: set buddy_alloc_helper minimum size to 0x1000 bytes 2023-04-14 12:56:11 -04:00
Michael Shaw
a1329f092b mem: add comment explaining buddy allocator concept 2023-04-14 12:50:56 -04:00
Michael Shaw
4595f35e4f mem: rename mem_region_header to buddy_region_header 2023-04-14 12:47:30 -04:00
Michael Shaw
98c99b1780 mem: reorganize buddy.c 2023-04-14 09:03:01 -04:00
Michael Shaw
b8fa30c8ed mem: change buddy allocator api
the buddy allocator now returns HHDM addresses as void* rather than
zero-based adddresses as paddr_t. it also automatically searches regions
now, rather than requiring a (struct mem_region_header *) for each
alloc/free
2023-04-13 17:36:04 -04:00
Michael Shaw
a506cc481e mem: removed unncessary messages and allocation 2023-04-13 13:12:21 -04:00
Michael Shaw
a089d09322 add todo lol 2023-04-12 19:10:39 -04:00
Renamed from mem/early.c (Browse further)