aboutsummaryrefslogtreecommitdiff
path: root/kernel/mm/physical_mm/allocation.c
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-01-09 12:28:43 -0500
committerRaghuram Subramani <raghus2247@gmail.com>2025-01-09 12:28:43 -0500
commit36b9c0960d8cf7900e4b7cec16b2d6a2fd801e67 (patch)
tree62e59b8fdbc9309815790c2cc68312865d0e61ab /kernel/mm/physical_mm/allocation.c
parentc39920c3a3ef0544feef6c325673506c0e3fac88 (diff)
Revert "kernel: mm: physical: Refactor into separate files"
This reverts commit c39920c3a3ef0544feef6c325673506c0e3fac88.
Diffstat (limited to 'kernel/mm/physical_mm/allocation.c')
-rw-r--r--kernel/mm/physical_mm/allocation.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/kernel/mm/physical_mm/allocation.c b/kernel/mm/physical_mm/allocation.c
deleted file mode 100644
index 85d945f..0000000
--- a/kernel/mm/physical_mm/allocation.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <stdbool.h>
-#include <stdint.h>
-
-#include <libk/stdio.h>
-
-#include <mm/physical_mm.h>
-
-#include <kernel/halt.h>
-
-uint32_t
-physical_mm_find_first_free_block(uint32_t *memory_map)
-{
- /* TODO: Why doesn't using block_count instead of MAX_BLOCKS work? */
- for (uint32_t i = 0; i < MAX_BLOCKS / BITMAP_ENTRY_SIZE; i++)
- /* At least one block in the entry isn't in use */
- if (memory_map[i] != 0xffffffff)
- /* Test each bit to see if it's zero */
- for (uint32_t j = 0; j < BITMAP_ENTRY_SIZE; j++)
- if (!physical_mm_test_bit(i * BITMAP_ENTRY_SIZE + j, memory_map))
- return i * BITMAP_ENTRY_SIZE + j;
-
- /* Shouldn't be reached, since we're keeping track of the number of free
- * blocks */
- ASSERT_NOT_REACHED();
- return -1;
-}
-
-void *
-physical_mm_allocate_block(uint32_t *total_free_blocks, uint32_t *memory_map)
-{
- if (total_free_blocks == 0) {
- printk("physical_mm", "No more free blocks!");
- return NULL;
- }
-
- uint32_t block = physical_mm_find_first_free_block(memory_map);
-
- physical_mm_set_used(block, total_free_blocks, memory_map);
-
- uint32_t physical_address = block * BLOCK_SIZE;
- return (void *) physical_address;
-}
-
-void
-physical_mm_free_block(void *physical_address,
- uint32_t *total_free_blocks,
- uint32_t *memory_map)
-{
- uint32_t block = ((uint32_t) physical_address) / BLOCK_SIZE;
- physical_mm_set_usable(block, total_free_blocks, memory_map);
-}