diff --git a/Makefile b/Makefile index 6ff4b0d..ba9a109 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ ARCH_OBJ := $(addprefix $(BUILD_DIR)/,$(ARCH_C_FILES:.c=.o) $(ARCH_ASM_FILES:.S= # Platform-independent kernel source files #################################### -KERNEL_SRC_DIRS := init kernel vm +KERNEL_SRC_DIRS := init kernel vm ds util KERNEL_C_FILES := $(foreach dir,$(KERNEL_SRC_DIRS),$(wildcard $(dir)/*.c)) KERNEL_OBJ := $(addprefix $(BUILD_DIR)/,$(KERNEL_C_FILES:.c=.o)) @@ -45,7 +45,7 @@ LDFLAGS := $(LDFLAGS) -g ALL_KERNEL_OBJECT_FILES := $(KERNEL_OBJ) $(ARCH_OBJ) $(LIBC_OBJ) ALL_KERNEL_DEPS := $(ALL_KERNEL_OBJECT_FILES:.o=.d) -all: $(BUILD_DIR)/$(KERNEL_EXEC) sandbox +all: $(BUILD_DIR)/$(KERNEL_EXEC) -include $(ALL_KERNEL_DEPS) diff --git a/ds/btree.c b/ds/btree.c index f57c8b7..ede4267 100644 --- a/ds/btree.c +++ b/ds/btree.c @@ -59,9 +59,6 @@ #include #include -#include -#include -#include #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -130,15 +127,7 @@ static inline int bf(btree_node_t *x) */ static void rotate_left(btree_t *tree, btree_node_t *x) { - assert(x != NULL); - btree_node_t *y = x->b_right; - assert(y != NULL); - - assert(y == x->b_left || y == x->b_right); - if (x->b_parent) { - assert(x == x->b_parent->b_left || x == x->b_parent->b_right); - } btree_node_t *p = x->b_parent; @@ -197,15 +186,7 @@ static void update_height_to_root(btree_node_t *x) */ static void rotate_right(btree_t *tree, btree_node_t *y) { - assert(y); - btree_node_t *x = y->b_left; - assert(x); - - assert(x == y->b_left || x == y->b_right); - if (y->b_parent) { - assert(y == y->b_parent->b_left || y == y->b_parent->b_right); - } btree_node_t *p = y->b_parent; @@ -338,10 +319,6 @@ static void insert_fixup(btree_t *tree, btree_node_t *w) goto next_ancestor; } - assert(x && y && z); - assert(x == y->b_left || x == y->b_right); - assert(y == z->b_left || y == z->b_right); - if (IS_LEFT_CHILD(z, y)) { if (IS_LEFT_CHILD(y, x)) { rotate_right(tree, z); diff --git a/ds/queue.c b/ds/queue.c index dcc441c..4d57bac 100644 --- a/ds/queue.c +++ b/ds/queue.c @@ -1,6 +1,4 @@ #include -#include -#include size_t queue_length(queue_t *q) { diff --git a/include/socks/queue.h b/include/socks/queue.h index e4d969a..c3adb2c 100644 --- a/include/socks/queue.h +++ b/include/socks/queue.h @@ -1,7 +1,7 @@ #ifndef SOCKS_QUEUE_H_ #define SOCKS_QUEUE_H_ -#include +#include #include #define QUEUE_CONTAINER(t, m, v) ((void *)((v) ? (uintptr_t)(v) - (offsetof(t, m)) : 0)) diff --git a/init/main.c b/init/main.c index 8295f86..5355764 100644 --- a/init/main.c +++ b/init/main.c @@ -1,23 +1,13 @@ #include -#include #include -#include +#include #include -#include - -static ml_cpu_block g_bootstrap_cpu = {0}; - -void bootstrap_cpu_init(void) -{ - ml_cpu_block_init(&g_bootstrap_cpu); - ml_cpu_block_use(&g_bootstrap_cpu); -} void kernel_init(uintptr_t arg) { ml_init(arg); for (int i = 0; i < 8; i++) { - printf("Line %d\n", i); + printk("Line %d\n", i); } } diff --git a/kernel/printk.c b/kernel/printk.c index 1b21bf6..802e8a0 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -5,5 +5,6 @@ static char log_buffer[LOG_BUFFER_SIZE] = {0}; int printk(const char *format, ...) { + (void)log_buffer; return 0; } diff --git a/libc/include/socks/libc/stdio.h b/libc/include/socks/libc/stdio.h index 6d2a8e6..f4c2b81 100644 --- a/libc/include/socks/libc/stdio.h +++ b/libc/include/socks/libc/stdio.h @@ -8,9 +8,6 @@ extern "C" { #endif -#define printf printf_ -int printf_(const char *format, ...); - #define sprintf sprintf_ int sprintf_(char *buffer, const char *format, ...); diff --git a/util/data_size.c b/util/data_size.c index 665bbe9..9f50843 100644 --- a/util/data_size.c +++ b/util/data_size.c @@ -1,5 +1,5 @@ #include -#include +#include struct magnitude { size_t threshold; diff --git a/vm/bootstrap.c b/vm/bootstrap.c index 4dcf9a8..7430c4f 100644 --- a/vm/bootstrap.c +++ b/vm/bootstrap.c @@ -5,7 +5,6 @@ #include #include #include -#include /* One vm_pg_data_t per NUMA node. */ static vm_pg_data_t *node_data = NULL; diff --git a/vm/cache.c b/vm/cache.c index 2445515..016b49b 100644 --- a/vm/cache.c +++ b/vm/cache.c @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include #include #define FREELIST_END ((unsigned int)-1) @@ -103,7 +103,7 @@ static vm_slab_t *alloc_slab(vm_cache_t *cache, vm_flags_t flags) return slab_hdr; } -static void destroy_slab(vm_slab_t *slab) +static void __used destroy_slab(vm_slab_t *slab) { } @@ -149,11 +149,9 @@ void *vm_cache_alloc(vm_cache_t *cache, vm_flags_t flags) if (!queue_empty(&cache->c_slabs_partial)) { /* prefer using up partially-full slabs before taking a fresh one */ queue_entry_t *slab_entry = queue_pop_front(&cache->c_slabs_partial); - assert(slab_entry); slab = QUEUE_CONTAINER(vm_slab_t, s_list, slab_entry); } else if (!queue_empty(&cache->c_slabs_empty)) { queue_entry_t *slab_entry = queue_pop_front(&cache->c_slabs_empty); - assert(slab_entry); slab = QUEUE_CONTAINER(vm_slab_t, s_list, slab_entry); } else { /* we've run out of slabs. create a new one */ diff --git a/vm/kmalloc.c b/vm/kmalloc.c index 8ce78fe..324b360 100644 --- a/vm/kmalloc.c +++ b/vm/kmalloc.c @@ -1,5 +1,5 @@ #include -#include +#include #define SIZE_N_CACHE(s) \ { .c_name = "size-" # s, .c_obj_size = s, .c_page_order = VM_PAGE_16K } diff --git a/vm/memblock.c b/vm/memblock.c index ac3178b..c654554 100644 --- a/vm/memblock.c +++ b/vm/memblock.c @@ -19,12 +19,10 @@ contributors may be used to endorse or promote products derived from this software without specific prior written permission. */ -#include "socks/types.h" -#include #include #include -#include -#include +#include +#include #include #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -252,8 +250,7 @@ static phys_addr_t do_alloc(size_t size) } if (allocated_base == ADDR_MAX) { - fprintf(stderr, "memblock: cannot allocate %zu byte buffer!\n", size); - abort(); + return 0; } int status = memblock_add_range(&memblock.reserved, allocated_base, size, MEMBLOCK_ALLOC); diff --git a/vm/page.c b/vm/page.c index d9ddb9b..7f3fad2 100644 --- a/vm/page.c +++ b/vm/page.c @@ -1,9 +1,7 @@ #include #include #include -#include -#include -#include +#include /* array of pages, one for each physical page frame present in RAM */ static vm_page_t *page_array = NULL; @@ -52,7 +50,6 @@ void tmp_set_vaddr_base(void *p, size_t len) phys_addr_t vm_virt_to_phys(void *p) { phys_addr_t x = (phys_addr_t)p - (phys_addr_t)tmp_vaddr_base; - assert(x < tmp_vaddr_len); return x; } @@ -74,8 +71,6 @@ void vm_page_init_array() page_array = memblock_alloc(sizeof(vm_page_t) * nr_pages); page_array_count = nr_pages; - printf("page_array covers 0x%zx bytes, %zu page frames\n", pmem_size, pmem_size / VM_PAGE_SIZE); - printf("page_array is %zu bytes long\n", sizeof(vm_page_t) * nr_pages); for (size_t i = 0; i < nr_pages; i++) { memset(&page_array[i], 0x0, sizeof page_array[i]); @@ -90,8 +85,6 @@ void vm_page_init_array() nr_reserved++; } } - - printf("%zu reserved page frames\n", nr_reserved); } vm_page_t *vm_page_get(phys_addr_t addr) diff --git a/vm/zone.c b/vm/zone.c index 80b5132..c74a07f 100644 --- a/vm/zone.c +++ b/vm/zone.c @@ -2,11 +2,7 @@ #include #include #include -#include -#include -#include -#include -#include +#include static vm_page_t *group_pages_into_block(vm_zone_t *z, phys_addr_t base, phys_addr_t limit, int order) { @@ -36,8 +32,6 @@ static void convert_region_to_blocks(vm_zone_t *zone, int reserved) { size_t block_frames = vm_bytes_to_pages(limit - base + 1); - printf("adding region %08zx-%08zx (%zu frames) to zone %s\n", - base, limit, block_frames, zone->z_info.zd_name); int reset_order = 0; for (int order = VM_PAGE_MAX_ORDER; order >= VM_PAGE_MIN_ORDER; ) { @@ -55,12 +49,6 @@ static void convert_region_to_blocks(vm_zone_t *zone, continue; } - printf("%s: %zu %s pages at %08" PRIxPTR "\n", - zone->z_info.zd_name, - order_frames, - reserved == 1 ? "reserved" : "free", - base); - phys_addr_t block_limit = base + (order_frames * VM_PAGE_SIZE) - 1; vm_page_t *block_page = group_pages_into_block(zone, base, block_limit, order); @@ -76,11 +64,6 @@ static void convert_region_to_blocks(vm_zone_t *zone, reset_order = 0; } - if (base > limit + 1) { - printf("too many pages created! %zx > %zx\n", base, limit); - abort(); - } - if (base == limit) { break; } @@ -93,8 +76,6 @@ void vm_zone_init(vm_zone_t *z, const vm_zone_descriptor_t *zone_info) return; } - printf("initialising zone %s (%08zx-%08zx)\n", - zone_info->zd_name, zone_info->zd_base, zone_info->zd_limit); memset(z, 0x0, sizeof *z); memcpy(&z->z_info, zone_info, sizeof *zone_info); z->z_lock = SPIN_LOCK_INIT;