Debloat
This commit is contained in:
parent
96f3b9f0d5
commit
8e7c1cf6a2
9
Makefile
9
Makefile
|
@ -2,7 +2,7 @@
|
||||||
AS := nasm
|
AS := nasm
|
||||||
CC := clang
|
CC := clang
|
||||||
LD := lld
|
LD := lld
|
||||||
DAS := llvm-objdump
|
DAS := llvm-objdump-6.0
|
||||||
|
|
||||||
ifneq '$(AS_ENV)' ''
|
ifneq '$(AS_ENV)' ''
|
||||||
AS := $(AS_ENV)
|
AS := $(AS_ENV)
|
||||||
|
@ -72,16 +72,9 @@ PREP_FLAGS = -E \
|
||||||
-I$(INC_COMMON) \
|
-I$(INC_COMMON) \
|
||||||
$(C_FLAGS_$(MOD))
|
$(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 $@)
|
MKDIR = mkdir -p $(dir $@)
|
||||||
COMP = $(CC) $(C_FLAGS) -o $@ $<
|
COMP = $(CC) $(C_FLAGS) -o $@ $<
|
||||||
COMPAS = $(AS) $(AS_FLAGS) -o $@ $<
|
COMPAS = $(AS) $(AS_FLAGS) -o $@ $<
|
||||||
PREP = $(CC) $(PREP_FLAGS) $< > $@
|
PREP = $(CC) $(PREP_FLAGS) $< > $@
|
||||||
GDEP = $(CC) $(GDEP_FLAGS) -MF $(addsuffix .d, $@) $< > /dev/null
|
|
||||||
|
|
||||||
include Rules.top
|
include Rules.top
|
||||||
|
|
|
@ -46,7 +46,7 @@ iso: $(TGT) $(GRUB_CFG)
|
||||||
mkdir -p $(OUT)/temp/boot/grub
|
mkdir -p $(OUT)/temp/boot/grub
|
||||||
cp $(TGT) $(OUT)/temp/secX/
|
cp $(TGT) $(OUT)/temp/secX/
|
||||||
cp $(GRUB_CFG) $(OUT)/temp/boot/grub/
|
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
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "cdef.h"
|
#include "cdef.h"
|
||||||
#include "dlist.h"
|
#include "llist.h"
|
||||||
|
|
||||||
struct htable_node;
|
struct htable_node;
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@ struct htable_node
|
||||||
struct htable
|
struct htable
|
||||||
{
|
{
|
||||||
uint32 bkts;
|
uint32 bkts;
|
||||||
struct dlist *buf;
|
struct llist *buf;
|
||||||
htable_cmp_fp cmp_fp;
|
htable_cmp_fp cmp_fp;
|
||||||
htable_hash_fp hash_fp;
|
htable_hash_fp hash_fp;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
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
|
* returns the overwritten object
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct dlist_node
|
||||||
struct dlist_node *next;
|
struct dlist_node *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dlist
|
struct llist
|
||||||
{
|
{
|
||||||
struct dlist_node *head;
|
struct dlist_node *head;
|
||||||
struct dlist_node *tail;
|
struct dlist_node *tail;
|
||||||
|
@ -16,17 +16,17 @@ struct dlist
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
lb_llist_init(struct dlist *list);
|
lb_llist_init(struct llist *list);
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
lb_llist_size(struct dlist *list);
|
lb_llist_size(struct llist *list);
|
||||||
|
|
||||||
void
|
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 *
|
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 *
|
struct dlist_node *
|
||||||
|
@ -38,8 +38,8 @@ lb_llist_prev(struct dlist_node *node);
|
||||||
|
|
||||||
|
|
||||||
struct dlist_node *
|
struct dlist_node *
|
||||||
lb_llist_first(struct dlist *list);
|
lb_llist_first(struct llist *list);
|
||||||
|
|
||||||
|
|
||||||
struct dlist_node *
|
struct dlist_node *
|
||||||
lb_llist_last(struct dlist *list);
|
lb_llist_last(struct llist *list);
|
|
@ -21,7 +21,7 @@ kmain(struct boot_info *boot_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize memory manager
|
// initialize memory manager
|
||||||
status = mm_pmm_init(boot_info);
|
//status = mm_pmm_init(boot_info);
|
||||||
if (!SX_SUCCESS(status))
|
if (!SX_SUCCESS(status))
|
||||||
{
|
{
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "clib.h"
|
#include "clib.h"
|
||||||
#include "cdef.h"
|
#include "cdef.h"
|
||||||
#include "lb/htable.h"
|
#include "lb/htable.h"
|
||||||
#include "lb/dlist.h"
|
#include "lb/llist.h"
|
||||||
|
|
||||||
void
|
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->hash_fp = hash_fp;
|
||||||
table->cmp_fp = cmp_fp;
|
table->cmp_fp = cmp_fp;
|
||||||
|
@ -20,7 +20,7 @@ struct htable_node *
|
||||||
htable_insert(struct htable *table, struct htable_node *entry)
|
htable_insert(struct htable *table, struct htable_node *entry)
|
||||||
{
|
{
|
||||||
uint32 hash = table->hash_fp(entry) % table->bkts;
|
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 htable_node *ret = NULL;
|
||||||
struct dlist_node *lnode = lb_llist_first(hlist);
|
struct dlist_node *lnode = lb_llist_first(hlist);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "lb/dlist.h"
|
#include "lb/llist.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
llist_node_init(struct dlist_node *node)
|
llist_node_init(struct dlist_node *node)
|
||||||
|
@ -9,7 +9,7 @@ llist_node_init(struct dlist_node *node)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
lb_llist_init(struct dlist *list)
|
lb_llist_init(struct llist *list)
|
||||||
{
|
{
|
||||||
list->head = NULL;
|
list->head = NULL;
|
||||||
list->tail = NULL;
|
list->tail = NULL;
|
||||||
|
@ -18,13 +18,13 @@ lb_llist_init(struct dlist *list)
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
lb_llist_size(struct dlist *list)
|
lb_llist_size(struct llist *list)
|
||||||
{
|
{
|
||||||
return list->size;
|
return list->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 *left_node;
|
||||||
struct dlist_node *right_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
|
* returns the next node
|
||||||
*/
|
*/
|
||||||
struct dlist_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;
|
struct dlist_node *ret;
|
||||||
|
|
||||||
|
@ -142,14 +142,14 @@ lb_llist_prev(struct dlist_node *node)
|
||||||
|
|
||||||
|
|
||||||
struct dlist_node *
|
struct dlist_node *
|
||||||
lb_llist_first(struct dlist *list)
|
lb_llist_first(struct llist *list)
|
||||||
{
|
{
|
||||||
return list->head;
|
return list->head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct dlist_node *
|
struct dlist_node *
|
||||||
lb_llist_last(struct dlist *list)
|
lb_llist_last(struct llist *list)
|
||||||
{
|
{
|
||||||
return list->tail;
|
return list->tail;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
#include "cdef.h"
|
#include "cdef.h"
|
||||||
#include "mlayout.h"
|
#include "mlayout.h"
|
||||||
#include "lb/dlist.h"
|
#include "lb/llist.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplified Slab Allocator
|
* Simplified Slab Allocator
|
||||||
|
@ -17,9 +17,9 @@ struct ssalloc_page_desc
|
||||||
|
|
||||||
struct ssalloc_obj_desc
|
struct ssalloc_obj_desc
|
||||||
{
|
{
|
||||||
struct dlist free_list;
|
struct llist free_list;
|
||||||
struct dlist full_list;
|
struct llist full_list;
|
||||||
struct dlist empty_list;
|
struct llist empty_list;
|
||||||
usize obj_size;
|
usize obj_size;
|
||||||
uint32 align;
|
uint32 align;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
include $(MK)/prologue.mk
|
include $(MK)/prologue.mk
|
||||||
|
|
||||||
SRC_$(d) := $(d)/pmm.c
|
SRC_$(d) :=
|
||||||
|
#$(d)/pmm.c
|
||||||
|
|
||||||
include $(MK)/stdrules.mk
|
include $(MK)/stdrules.mk
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "mm/pmm.h"
|
#include "mm/pmm.h"
|
||||||
|
|
||||||
#include "lb/atree.h"
|
#include "lb/atree.h"
|
||||||
#include "lb/dlist.h"
|
#include "lb/llist.h"
|
||||||
#include "ke/rww_lock.h"
|
#include "ke/rww_lock.h"
|
||||||
#include "clib.h"
|
#include "clib.h"
|
||||||
#include "ke/intr.h"
|
#include "ke/intr.h"
|
||||||
|
@ -15,7 +15,7 @@ struct phys_page_desc
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct a_tree active_tree;
|
static struct a_tree active_tree;
|
||||||
static struct dlist free_list;
|
static struct llist free_list;
|
||||||
static struct rww_lock lock;
|
static struct rww_lock lock;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -111,7 +111,7 @@ k_status mm_alloc_page(uintptr *out)
|
||||||
|
|
||||||
struct dlist_node *node = NULL;
|
struct dlist_node *node = NULL;
|
||||||
struct phys_page_desc *page_info = 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)
|
if (node != NULL)
|
||||||
{
|
{
|
||||||
page_info = OBTAIN_STRUCT_ADDR(node,
|
page_info = OBTAIN_STRUCT_ADDR(node,
|
||||||
|
@ -186,7 +186,7 @@ k_status mm_free_page(uintptr base)
|
||||||
if (node != NULL)
|
if (node != NULL)
|
||||||
{
|
{
|
||||||
page_info = OBTAIN_STRUCT_ADDR(node, struct phys_page_desc, tree_node);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,6 @@ $(OUT)/$(d)/%.o: MOD:=$(MOD)
|
||||||
$(OBJ_$(d)): $(OUT)/$(d)/%.o: $(d)/%.c
|
$(OBJ_$(d)): $(OUT)/$(d)/%.o: $(d)/%.c
|
||||||
$(MKDIR)
|
$(MKDIR)
|
||||||
$(COMP)
|
$(COMP)
|
||||||
$(GDEP)
|
|
||||||
|
|
||||||
$(OUT)/$(d)/%.a: MOD:=$(MOD)
|
$(OUT)/$(d)/%.a: MOD:=$(MOD)
|
||||||
|
|
||||||
|
@ -27,7 +26,6 @@ $(OBJAS_$(d)): $(OUT)/$(d)/%.a: $(d)/%.asm
|
||||||
$(OBJIN_$(d)): $(OUT)/$(d)/%: $(d)/%.in
|
$(OBJIN_$(d)): $(OUT)/$(d)/%: $(d)/%.in
|
||||||
$(MKDIR)
|
$(MKDIR)
|
||||||
$(PREP)
|
$(PREP)
|
||||||
$(GDEP)
|
|
||||||
|
|
||||||
# append all OBJECTS to OBJ
|
# append all OBJECTS to OBJ
|
||||||
OBJ := $(OBJ) $(OBJ_$(d)) $(OBJAS_$(d))
|
OBJ := $(OBJ) $(OBJ_$(d)) $(OBJAS_$(d))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "test_main.h"
|
#include "test_main.h"
|
||||||
#include "test_case.h"
|
#include "test_case.h"
|
||||||
#include "lb/dlist.h"
|
#include "lb/llist.h"
|
||||||
#include "clib.h"
|
#include "clib.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue