diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/Makefile | 3 | ||||
-rw-r--r-- | sys/dev/fdt/fdt.c | 29 | ||||
-rw-r--r-- | sys/include/printf.h | 2 | ||||
-rw-r--r-- | sys/sys/init.c | 12 | ||||
-rw-r--r-- | sys/sys/mm/kalloc.c | 2 | ||||
-rw-r--r-- | sys/sys/printf.c | 21 |
6 files changed, 18 insertions, 51 deletions
diff --git a/sys/Makefile b/sys/Makefile index a766174..385cf7a 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -13,7 +13,6 @@ SRC=\ sys/printf.c\ sys/mm/kalloc.c\ sys/smp/spinlock.c\ - dev/fdt/fdt.c ${BUILDDIR}/kernel.elf: ${SRC} @@ -28,7 +27,7 @@ ${BUILDDIR}/kernel.elf: ${SRC} -I ../include\ -I ./include\ ${CFLAGS} -T sys/kernel.lds ${LDFLAGS}\ - -L../lib/${BUILDDIR}/\ + -L../lib/libc/${BUILDDIR}/\ -l:libc.a\ -o $@ diff --git a/sys/dev/fdt/fdt.c b/sys/dev/fdt/fdt.c deleted file mode 100644 index 9a8f1af..0000000 --- a/sys/dev/fdt/fdt.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <fdt.h> -#include <sbi.h> -#include <printf.h> -#include <stdint.h> - -void -fdt_walk(struct fdt_header *header) -{ - if (fdt_uint32(header->magic) != FDT_HEADER_MAGIC) { - printf("corrupted or invalid fdt"); - } - printf("parsing fdt @%p...\n", header); - printf("header->totalsize: %d\n", fdt_uint32(header->totalsize)); - printf("header->off_dt_struct: %d\n", fdt_uint32(header->off_dt_struct)); - printf("header->off_dt_strings: %d\n", fdt_uint32(header->off_dt_strings)); - printf("header->off_mem_rsvmap: %d\n", fdt_uint32(header->off_mem_rsvmap)); - printf("header->version: %d\n", fdt_uint32(header->version)); - printf("header->last_comp_version: %d\n", fdt_uint32(header->last_comp_version)); - printf("header->boot_cpuid_phys: %d\n", fdt_uint32(header->boot_cpuid_phys)); - printf("header->size_dt_strings: %d\n", fdt_uint32(header->size_dt_strings)); - printf("header->size_dt_struct: %d\n", fdt_uint32(header->size_dt_struct)); - - printf("walking the memory reservation block...\n"); - struct fdt_reserve_entry *p = header + fdt_uint32(header->off_mem_rsvmap); -// do { -// printf("reserved entry at %p with size %i\n", p->address, p->size); -// p++; -// } while (!(p->size == 0 && p->address == 0)); -} diff --git a/sys/include/printf.h b/sys/include/printf.h index fd9a092..bcd9e75 100644 --- a/sys/include/printf.h +++ b/sys/include/printf.h @@ -1,8 +1,6 @@ #ifndef _KPRINTF_H #define _KPRINTF_H -int puts(const char *); void printf_init(void); -void printf(const char *, ...); #endif /* _KPRINTF_H */ diff --git a/sys/sys/init.c b/sys/sys/init.c index 4867be6..b21ac84 100644 --- a/sys/sys/init.c +++ b/sys/sys/init.c @@ -1,6 +1,7 @@ -#include <fdt.h> +#include <libfdt.h> #include <kalloc.h> #include <spinlock.h> +#include <stdio.h> #include <printf.h> #include <sbi.h> #include <stdint.h> @@ -16,20 +17,13 @@ init(unsigned long hartid, struct fdt_header *fdt) { printf("booting from hart #%d\n", hartid); - if (fdt_uint32(fdt->magic) == FDT_HEADER_MAGIC) - printf("found flattened device tree at %p!\n", (uint64_t)fdt); - - printf("parsing device tree!\n"); - fdt_walk(fdt); printf("setting up the heap at %p\n", HEAP_START); kalloc_init(); printf_init(); printf("done!\n"); - // printf("printing free pages:\n"); - ///walkfree(); + printf("bringing up other harts...\n"); - // todo: detect harts and reserved mem from device tree for optimal memory usage. for (int i = 0; i < NPROC; ++i) { if (i == hartid) { printf("skipping hart #%d\n", i); diff --git a/sys/sys/mm/kalloc.c b/sys/sys/mm/kalloc.c index b2c19d9..6cf888a 100644 --- a/sys/sys/mm/kalloc.c +++ b/sys/sys/mm/kalloc.c @@ -1,10 +1,10 @@ #include <stddef.h> #include <spinlock.h> -#include <fdt.h> #include <stdint.h> #include <string.h> #include <printf.h> #include <kalloc.h> +#include <stdio.h> extern uint64_t HEAP_START; diff --git a/sys/sys/printf.c b/sys/sys/printf.c index 03bf8cc..e8cc468 100644 --- a/sys/sys/printf.c +++ b/sys/sys/printf.c @@ -1,3 +1,4 @@ +#include <stdio.h> #include <printf.h> #include <stdint.h> #include <spinlock.h> @@ -8,16 +9,20 @@ static char digits[] = "0123456789abcdef"; static spinlock_t mutex; -int +inline void +putchar(const char c) +{ + sbi_console_putchar(c); +} + +void puts(const char *str) { do { - sbi_console_putchar(*str); + putchar(*str); } while (*(str++) != '\0'); } -#define PUTCHAR(c) sbi_console_putchar(c) - static void printint(int xx, int base, int sign) { @@ -38,7 +43,7 @@ printint(int xx, int base, int sign) if (sign) buf[i++] = '-'; while (--i >= 0) - PUTCHAR(buf[i]); + putchar(buf[i]); } @@ -48,7 +53,7 @@ printptr(uint64_t x) int i; puts("0x"); for (i = 0; i < (sizeof(uint64_t) * 2); i++, x <<= 4) - PUTCHAR(digits[x >> (sizeof(int64_t) * 8 - 4)]); + putchar(digits[x >> (sizeof(int64_t) * 8 - 4)]); } void @@ -64,7 +69,7 @@ printf(const char *fmt, ...) for (i = 0; (c = fmt[i] & 0xff) != 0; i++) { if (c != '%') { - PUTCHAR(c); + putchar(c); continue; } c = fmt[++i] & 0xff; @@ -83,7 +88,7 @@ printf(const char *fmt, ...) printptr(va_arg(ap, uint64_t)); break; case '%': - PUTCHAR('%'); + putchar('%'); break; } } |