summaryrefslogtreecommitdiff
path: root/src/kernel/mem
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/mem')
-rw-r--r--src/kernel/mem/_dlmalloc.c8
-rw-r--r--src/kernel/mem/_dlmalloc.h5
-rw-r--r--src/kernel/mem/gdt.c2
-rw-r--r--src/kernel/mem/mem.h1
-rw-r--r--src/kernel/mem/paging.c5
5 files changed, 17 insertions, 4 deletions
diff --git a/src/kernel/mem/_dlmalloc.c b/src/kernel/mem/_dlmalloc.c
index 18dabab..30c6622 100644
--- a/src/kernel/mem/_dlmalloc.c
+++ b/src/kernel/mem/_dlmalloc.c
@@ -912,6 +912,14 @@ static FORCEINLINE int win32munmap(void* ptr, size_t size) {
/* #define TRY_LOCK(lk) ... */
/* static MLOCK_T malloc_global_mutex = ... */
+#define MLOCK_T uint32_t
+#define INITIAL_LOCK(l) (*l = MUTEX_UNLOCKED)
+#define DESTROY_LOCK(l) (0)
+#define ACQUIRE_LOCK(l) (mutex_lock (l))
+#define RELEASE_LOCK(l) (mutex_unlock (l))
+#define TRY_LOCK(l) (mutex_lockE(l))
+static MLOCK_T malloc_global_mutex = MUTEX_UNLOCKED;
+
#elif USE_SPIN_LOCKS
/* First, define CAS_LOCK and CLEAR_LOCK on ints */
diff --git a/src/kernel/mem/_dlmalloc.h b/src/kernel/mem/_dlmalloc.h
index a030da2..7b2e2cc 100644
--- a/src/kernel/mem/_dlmalloc.h
+++ b/src/kernel/mem/_dlmalloc.h
@@ -2,14 +2,19 @@
#define DEF_DLMALLOC_H
#include "lib/std.h"
+#include <stdlib_common.h>
+#include <string.h>
#define NO_MALLOC_STATS 1
#define LACKS_TIME_H
#define LACKS_UNISTD_H
#define LACKS_SYS_PARAM_H
+#define LACKS_STDLIB_H
#define USE_DL_PREFIX
+#define USE_LOCKS 2
+
/* Version identifier to allow people to support multiple versions */
#ifndef DLMALLOC_VERSION
diff --git a/src/kernel/mem/gdt.c b/src/kernel/mem/gdt.c
index 8ee403a..494aaf2 100644
--- a/src/kernel/mem/gdt.c
+++ b/src/kernel/mem/gdt.c
@@ -1,5 +1,5 @@
#include "gdt.h"
-#include <stdlib.h>
+#include <stdlib_common.h>
#include <core/monitor.h>
extern void gdt_flush(uint32_t); //ASM (imported from idt_.asm)
diff --git a/src/kernel/mem/mem.h b/src/kernel/mem/mem.h
index b6e9622..cb9c396 100644
--- a/src/kernel/mem/mem.h
+++ b/src/kernel/mem/mem.h
@@ -5,6 +5,7 @@
kmalloc_page and kfree_page are used mostly for paging. */
#include <types.h>
+#include "_dlmalloc.h"
void* kmalloc_page(size_t *phys);
void kfree_page(void* page);
diff --git a/src/kernel/mem/paging.c b/src/kernel/mem/paging.c
index 5953fc6..0527f06 100644
--- a/src/kernel/mem/paging.c
+++ b/src/kernel/mem/paging.c
@@ -1,6 +1,6 @@
#include "paging.h"
#include <bitset.h>
-#include <stdlib.h>
+#include <stdlib_common.h>
#include <core/monitor.h>
#include "mem.h"
#include "seg.h"
@@ -17,7 +17,7 @@ struct page_directory *kernel_pagedir, *current_pagedir;
uint32_t frame_alloc() {
uint32_t free = bitset_firstFree(&frames);
if (free == (uint32_t) -1) {
- PANIC("Out of memory!");
+ PANIC("No more frames to allocate, system is out of memory!");
}
bitset_set(&frames, free);
return free;
@@ -166,7 +166,6 @@ struct page *pagedir_getPage(struct page_directory *pd, uint32_t address, int ma
pd->tablesPhysical[table_idx] |= 0x07;
if (table_idx >= FIRST_KERNEL_PAGETABLE) {
- monitor_write("UKPI ");
tasking_updateKernelPagetable(table_idx, pd->tables[table_idx], pd->tablesPhysical[table_idx]);
}