Handle IRQs inside the kernel
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m42s

This commit is contained in:
2026-03-13 20:33:27 +01:00
parent 4760818118
commit 217179c9a0
84 changed files with 14517 additions and 1297 deletions

82
kernel/mm/_malloc_port.c Normal file
View File

@@ -0,0 +1,82 @@
#include <libk/align.h>
#include <libk/string.h>
#include <limine/requests.h>
#include <mm/pmm.h>
#include <page_size.h>
#include <stdint.h>
#include <sys/debug.h>
#define LACKS_UNISTD_H 1
#define LACKS_SYS_MMAN_H 1
#define LACKS_SYS_PARAM_H 1
#define LACKS_FCNTL_H 1
#define LACKS_SYS_TYPES_H 1
#define LACKS_SCHED_H 1
#define LACKS_ERRNO_H 1
#define LACKS_STDLIB_H 1
#define LACKS_TIME_H 1
#define LACKS_STRINGS_H 1
#define ABORT \
{ \
(void)0; \
}
#define MALLOC_ALIGNMENT 16
#define HAVE_MORECORE 0
#define NO_MALLOC_STATS 1
#define USE_LOCKS 1
#define MALLOC_FAILURE_ACTION \
do { \
DEBUG ("malloc failure\n"); \
} while (0)
#define EINVAL -1
#define ENOMEM -1
#define DEFAULT_MMAP_THRESHOLD 0
#define open _open_dummy
#define O_RDWR 0
#define PROT_READ 0
#define PROT_WRITE 0
#define MAP_PRIVATE 0
#define fprintf(...)
int _open_dummy (const char* path, uint16_t modes) {
(void)path, (void)modes;
return 0;
}
void* mmap (void* addr, size_t size, int prot, int flags, int fd, size_t off) {
(void)prot, (void)fd, (void)off, (void)flags;
if (size == 0)
return (void*)-1;
size = div_align_up (size, PAGE_SIZE);
physaddr_t p_addr = pmm_alloc (size);
if (p_addr == PMM_ALLOC_ERR)
return (void*)-1;
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
uintptr_t a = (uintptr_t)(p_addr + hhdm->offset);
memset ((void*)a, 0, size * PAGE_SIZE);
return (void*)a;
}
int munmap (void* addr, size_t length) {
if (length == 0)
return 0;
length = div_align_up (length, PAGE_SIZE);
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
physaddr_t p_addr = (uintptr_t)addr - hhdm->offset;
pmm_free (p_addr, length);
return 0;
}