summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-17 14:49:33 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-17 14:49:45 -0400
commit2f6d195ba384fd9e683ba3cb5aaf58797a85e9e3 (patch)
tree71fdba68b2fc707c46cb62fdab58eb7a44c88c4d
parentgcc14stdenv instead of clang (diff)
downloadcomus-2f6d195ba384fd9e683ba3cb5aaf58797a85e9e3.tar.gz
comus-2f6d195ba384fd9e683ba3cb5aaf58797a85e9e3.tar.bz2
comus-2f6d195ba384fd9e683ba3cb5aaf58797a85e9e3.zip
fix compile warnings
-rw-r--r--Makefile1
-rw-r--r--kernel/lib/kprintf.c1
-rw-r--r--kernel/memory/paging.c31
-rw-r--r--user/lib/printf.c1
4 files changed, 14 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index eed133b..0faeee0 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ CFLAGS += -D DEBUG -g
CFLAGS += $(CPPFLAGS)
LDFLAGS += -nmagic -nostdlib
+LDFLAGS += -z noexecstack
SRC=kernel
BIN=bin
diff --git a/kernel/lib/kprintf.c b/kernel/lib/kprintf.c
index 452e45c..3494b38 100644
--- a/kernel/lib/kprintf.c
+++ b/kernel/lib/kprintf.c
@@ -438,6 +438,7 @@ static void do_printf(context_t *ctx, va_list args)
opts.radix = 16;
opts.hash = true;
opts.zero = true;
+ /* fallthrough */
case 'd':
case 'i':
case 'u':
diff --git a/kernel/memory/paging.c b/kernel/memory/paging.c
index 2671cc2..5177928 100644
--- a/kernel/memory/paging.c
+++ b/kernel/memory/paging.c
@@ -1,3 +1,4 @@
+#include "lib/kio.h"
#include <lib.h>
#include <comus/memory.h>
@@ -521,8 +522,6 @@ static inline void *page_align(void *addr)
void *mem_mapaddr(mem_ctx_t ctx, void *phys, void *virt, size_t len,
unsigned int flags)
{
- TRACE("PHYS %16p VIRT %16p LEN %zu FLAGS %08x \n", phys, virt, len, flags);
-
long pages;
ptrdiff_t error;
void *aligned_phys;
@@ -550,8 +549,6 @@ void *mem_mapaddr(mem_ctx_t ctx, void *phys, void *virt, size_t len,
void mem_unmapaddr(mem_ctx_t ctx, void *virt)
{
- TRACE("VIRT %16p\n", virt);
-
long pages = virtaddr_free(ctx->virtctx, virt);
if (pages < 1)
return;
@@ -560,25 +557,23 @@ void mem_unmapaddr(mem_ctx_t ctx, void *virt)
void *mem_alloc_page(mem_ctx_t ctx)
{
- return mem_alloc_pages(ctx, 1);
+ void *virt = virtaddr_alloc(ctx->virtctx, 1);
+ if (virt == NULL)
+ return NULL;
+ if (map_page((volatile struct pml4e *)ctx->pml4, virt, NULL, F_WRITEABLE)) {
+ virtaddr_free(ctx->virtctx, virt);
+ return NULL;
+ }
+ return virt;
}
void *mem_alloc_pages(mem_ctx_t ctx, size_t count)
{
- TRACE("COUNT %zu\n", count);
-
void *virt = virtaddr_alloc(ctx->virtctx, count);
if (virt == NULL)
return NULL;
- //void *phys = alloc_phys_pages(count);
- //if (phys == NULL) {
- // virtaddr_free(virt);
- // return NULL;
- //}
- if (map_pages((volatile struct pml4e *)ctx->pml4, virt,
- //phys,
- //F_WRITEABLE,
- NULL, F_WRITEABLE, count)) {
+ if (map_pages((volatile struct pml4e *)ctx->pml4, virt, NULL, F_WRITEABLE,
+ count)) {
virtaddr_free(ctx->virtctx, virt);
return NULL;
}
@@ -587,8 +582,6 @@ void *mem_alloc_pages(mem_ctx_t ctx, size_t count)
void mem_free_pages(mem_ctx_t ctx, void *virt)
{
- TRACE("VIRT %16p\n", virt);
-
long pages = virtaddr_free(ctx->virtctx, virt);
if (pages == 1)
unmap_page((volatile struct pml4e *)ctx->pml4, virt);
@@ -598,8 +591,6 @@ void mem_free_pages(mem_ctx_t ctx, void *virt)
int mem_load_page(mem_ctx_t ctx, void *virt_addr)
{
- TRACE("VIRT %16p\n", virt_addr);
-
volatile struct pte *page =
get_page((volatile struct pml4e *)ctx->pml4, virt_addr);
if (page == NULL)
diff --git a/user/lib/printf.c b/user/lib/printf.c
index 4d20263..65d7f0f 100644
--- a/user/lib/printf.c
+++ b/user/lib/printf.c
@@ -444,6 +444,7 @@ static void do_printf(context_t *ctx, va_list args)
opts.radix = 16;
opts.hash = true;
opts.zero = true;
+ /* fallthrough */
case 'd':
case 'i':
case 'u':