Move spinlock to separate folder
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
#include <stddef.h>
|
||||
#include <limine.h>
|
||||
#include "pmm.h"
|
||||
#include "spinlock.h"
|
||||
#include "kprintf.h"
|
||||
#include "bitmap/bitmap.h"
|
||||
#include "bootinfo/bootinfo.h"
|
||||
#include "spinlock/spinlock.h"
|
||||
|
||||
#define _DIV_ROUNDUP(num, div) ((num + div - 1) / div)
|
||||
|
||||
PhysMem PHYS_MEM;
|
||||
|
||||
void pmm_init(void) {
|
||||
PHYS_MEM.spinlock = SPINLOCK_INIT();
|
||||
spinlock_init(&PHYS_MEM.spinlock);
|
||||
|
||||
BitMap *bm = &PHYS_MEM.self;
|
||||
bm->init = false;
|
||||
@ -53,9 +53,9 @@ void pmm_init(void) {
|
||||
}
|
||||
|
||||
void *pmm_alloc(size_t pages) {
|
||||
SPINLOCK_ACQUIRE(&PHYS_MEM.spinlock);
|
||||
spinlock_acquire(&PHYS_MEM.spinlock);
|
||||
uintptr_t phys = (uintptr_t)bitmap_alloc(&PHYS_MEM.self, pages);
|
||||
SPINLOCK_RELEASE(&PHYS_MEM.spinlock);
|
||||
spinlock_release(&PHYS_MEM.spinlock);
|
||||
|
||||
if (!phys) {
|
||||
ERR("hal/pmm", "phys memory ran out\n");
|
||||
@ -65,7 +65,7 @@ void *pmm_alloc(size_t pages) {
|
||||
}
|
||||
|
||||
void pmm_free(uintptr_t ptr, size_t pages) {
|
||||
SPINLOCK_ACQUIRE(&PHYS_MEM.spinlock);
|
||||
spinlock_acquire(&PHYS_MEM.spinlock);
|
||||
bitmap_markregion(&PHYS_MEM.self, (void *)ptr, pages * BITMAP_BLOCK_SIZE, 0);
|
||||
SPINLOCK_RELEASE(&PHYS_MEM.spinlock);
|
||||
spinlock_release(&PHYS_MEM.spinlock);
|
||||
}
|
||||
|
Reference in New Issue
Block a user