This commit is contained in:
nt0s 2018-11-20 23:00:45 -05:00
parent 96f3b9f0d5
commit 8e7c1cf6a2
12 changed files with 34 additions and 42 deletions

View File

@ -2,7 +2,7 @@
AS := nasm
CC := clang
LD := lld
DAS := llvm-objdump
DAS := llvm-objdump-6.0
ifneq '$(AS_ENV)' ''
AS := $(AS_ENV)
@ -72,16 +72,9 @@ PREP_FLAGS = -E \
-I$(INC_COMMON) \
$(C_FLAGS_$(MOD))
# generic generate dependency flags used for target
# each submodule can append to this flag
GDEP_FLAGS = $(PREP_FLAGS) \
-MMD \
-MT $@
MKDIR = mkdir -p $(dir $@)
COMP = $(CC) $(C_FLAGS) -o $@ $<
COMPAS = $(AS) $(AS_FLAGS) -o $@ $<
PREP = $(CC) $(PREP_FLAGS) $< > $@
GDEP = $(CC) $(GDEP_FLAGS) -MF $(addsuffix .d, $@) $< > /dev/null
include Rules.top

View File

@ -46,7 +46,7 @@ iso: $(TGT) $(GRUB_CFG)
mkdir -p $(OUT)/temp/boot/grub
cp $(TGT) $(OUT)/temp/secX/
cp $(GRUB_CFG) $(OUT)/temp/boot/grub/
grub-mkrescue -o $(ISO) $(OUT)/temp
grub-mkrescue -d /usr/lib/grub/i386-pc -o $(ISO) $(OUT)/temp
.PHONY: clean
clean:

View File

@ -1,5 +1,5 @@
#include "cdef.h"
#include "dlist.h"
#include "llist.h"
struct htable_node;
@ -15,13 +15,13 @@ struct htable_node
struct htable
{
uint32 bkts;
struct dlist *buf;
struct llist *buf;
htable_cmp_fp cmp_fp;
htable_hash_fp hash_fp;
};
void
htable_init(struct htable* table, htable_cmp_fp cmp_fp, htable_hash_fp hash_fp, struct dlist *buf, uint32 bkts);
htable_init(struct htable* table, htable_cmp_fp cmp_fp, htable_hash_fp hash_fp, struct llist *buf, uint32 bkts);
/**
* returns the overwritten object

View File

@ -8,7 +8,7 @@ struct dlist_node
struct dlist_node *next;
};
struct dlist
struct llist
{
struct dlist_node *head;
struct dlist_node *tail;
@ -16,17 +16,17 @@ struct dlist
};
void
lb_llist_init(struct dlist *list);
lb_llist_init(struct llist *list);
uint32
lb_llist_size(struct dlist *list);
lb_llist_size(struct llist *list);
void
lb_llist_insert(struct dlist *list, struct dlist_node *cur_node, struct dlist_node *new_node);
lb_llist_insert(struct llist *list, struct dlist_node *cur_node, struct dlist_node *new_node);
struct dlist_node *
lb_llist_remove(struct dlist *list, struct dlist_node *node);
lb_llist_remove(struct llist *list, struct dlist_node *node);
struct dlist_node *
@ -38,8 +38,8 @@ lb_llist_prev(struct dlist_node *node);
struct dlist_node *
lb_llist_first(struct dlist *list);
lb_llist_first(struct llist *list);
struct dlist_node *
lb_llist_last(struct dlist *list);
lb_llist_last(struct llist *list);

View File

@ -21,7 +21,7 @@ kmain(struct boot_info *boot_info)
}
// initialize memory manager
status = mm_pmm_init(boot_info);
//status = mm_pmm_init(boot_info);
if (!SX_SUCCESS(status))
{
goto end;

View File

@ -1,10 +1,10 @@
#include "clib.h"
#include "cdef.h"
#include "lb/htable.h"
#include "lb/dlist.h"
#include "lb/llist.h"
void
htable_init(struct htable *table, htable_cmp_fp cmp_fp, htable_hash_fp hash_fp, struct dlist *buf, uint32 bkts)
htable_init(struct htable *table, htable_cmp_fp cmp_fp, htable_hash_fp hash_fp, struct llist *buf, uint32 bkts)
{
table->hash_fp = hash_fp;
table->cmp_fp = cmp_fp;
@ -20,7 +20,7 @@ struct htable_node *
htable_insert(struct htable *table, struct htable_node *entry)
{
uint32 hash = table->hash_fp(entry) % table->bkts;
struct dlist *hlist = &table->buf[hash];
struct llist *hlist = &table->buf[hash];
struct htable_node *ret = NULL;
struct dlist_node *lnode = lb_llist_first(hlist);

View File

@ -1,4 +1,4 @@
#include "lb/dlist.h"
#include "lb/llist.h"
static void
llist_node_init(struct dlist_node *node)
@ -9,7 +9,7 @@ llist_node_init(struct dlist_node *node)
void
lb_llist_init(struct dlist *list)
lb_llist_init(struct llist *list)
{
list->head = NULL;
list->tail = NULL;
@ -18,13 +18,13 @@ lb_llist_init(struct dlist *list)
uint32
lb_llist_size(struct dlist *list)
lb_llist_size(struct llist *list)
{
return list->size;
}
void
lb_llist_insert(struct dlist *list, struct dlist_node *cur_node, struct dlist_node *new_node)
lb_llist_insert(struct llist *list, struct dlist_node *cur_node, struct dlist_node *new_node)
{
struct dlist_node *left_node;
struct dlist_node *right_node;
@ -92,7 +92,7 @@ lb_llist_insert(struct dlist *list, struct dlist_node *cur_node, struct dlist_no
* returns the next node
*/
struct dlist_node *
lb_llist_remove(struct dlist *list, struct dlist_node *node)
lb_llist_remove(struct llist *list, struct dlist_node *node)
{
struct dlist_node *ret;
@ -142,14 +142,14 @@ lb_llist_prev(struct dlist_node *node)
struct dlist_node *
lb_llist_first(struct dlist *list)
lb_llist_first(struct llist *list)
{
return list->head;
}
struct dlist_node *
lb_llist_last(struct dlist *list)
lb_llist_last(struct llist *list)
{
return list->tail;
}

View File

@ -1,6 +1,6 @@
#include "cdef.h"
#include "mlayout.h"
#include "lb/dlist.h"
#include "lb/llist.h"
/**
* Simplified Slab Allocator
@ -17,9 +17,9 @@ struct ssalloc_page_desc
struct ssalloc_obj_desc
{
struct dlist free_list;
struct dlist full_list;
struct dlist empty_list;
struct llist free_list;
struct llist full_list;
struct llist empty_list;
usize obj_size;
uint32 align;
};

View File

@ -1,6 +1,7 @@
include $(MK)/prologue.mk
SRC_$(d) := $(d)/pmm.c
SRC_$(d) :=
#$(d)/pmm.c
include $(MK)/stdrules.mk

View File

@ -1,7 +1,7 @@
#include "mm/pmm.h"
#include "lb/atree.h"
#include "lb/dlist.h"
#include "lb/llist.h"
#include "ke/rww_lock.h"
#include "clib.h"
#include "ke/intr.h"
@ -15,7 +15,7 @@ struct phys_page_desc
};
static struct a_tree active_tree;
static struct dlist free_list;
static struct llist free_list;
static struct rww_lock lock;
/*
@ -111,7 +111,7 @@ k_status mm_alloc_page(uintptr *out)
struct dlist_node *node = NULL;
struct phys_page_desc *page_info = NULL;
node = lb_llist_pop_front(&free_list);
//node = lb_dlist_pop_front(&free_list);
if (node != NULL)
{
page_info = OBTAIN_STRUCT_ADDR(node,
@ -186,7 +186,7 @@ k_status mm_free_page(uintptr base)
if (node != NULL)
{
page_info = OBTAIN_STRUCT_ADDR(node, struct phys_page_desc, tree_node);
lb_llist_push_back(&free_list, &page_info->free_list_node);
//lb_llist_push_back(&free_list, &page_info->free_list_node);
}
else
{

View File

@ -16,7 +16,6 @@ $(OUT)/$(d)/%.o: MOD:=$(MOD)
$(OBJ_$(d)): $(OUT)/$(d)/%.o: $(d)/%.c
$(MKDIR)
$(COMP)
$(GDEP)
$(OUT)/$(d)/%.a: MOD:=$(MOD)
@ -27,7 +26,6 @@ $(OBJAS_$(d)): $(OUT)/$(d)/%.a: $(d)/%.asm
$(OBJIN_$(d)): $(OUT)/$(d)/%: $(d)/%.in
$(MKDIR)
$(PREP)
$(GDEP)
# append all OBJECTS to OBJ
OBJ := $(OBJ) $(OBJ_$(d)) $(OBJAS_$(d))

View File

@ -1,6 +1,6 @@
#include "test_main.h"
#include "test_case.h"
#include "lb/dlist.h"
#include "lb/llist.h"
#include "clib.h"
#include <stdio.h>