diff options
| -rw-r--r-- | .gitignore | 5 | ||||
| -rw-r--r-- | Makefile | 70 | ||||
| -rw-r--r-- | TODO.txt | 4 | ||||
| -rw-r--r-- | arch/riscv/include/csr.h | 2 | ||||
| -rw-r--r-- | arch/riscv/include/vmap.h | 17 | ||||
| -rw-r--r-- | arch/riscv/init-link.S | 14 | ||||
| -rw-r--r-- | arch/riscv/init/init.c | 41 | ||||
| -rw-r--r-- | arch/riscv/kernel-link.S | 14 | ||||
| -rw-r--r-- | arch/riscv/kernel.its (renamed from kernel.its) | 0 | ||||
| -rw-r--r-- | arch/riscv/riscv-link.S | 12 | ||||
| -rw-r--r-- | arch/riscv/source.mk | 12 | ||||
| -rw-r--r-- | arch/source.mk | 3 | ||||
| -rw-r--r-- | fs/kernel.itb | bin | 2340 -> 0 bytes | |||
| -rw-r--r-- | include/apos/init.h | 4 | ||||
| -rw-r--r-- | include/apos/link.lds.h | 43 | ||||
| -rw-r--r-- | include/apos/types.h | 4 | ||||
| -rw-r--r-- | init.a | bin | 20856 -> 0 bytes | |||
| -rw-r--r-- | init.c | 389 | ||||
| -rw-r--r-- | init.debug | bin | 5712 -> 0 bytes | |||
| -rw-r--r-- | kernel.a | bin | 7734 -> 0 bytes | |||
| -rwxr-xr-x | scripts/mkobjs | 57 | ||||
| -rwxr-xr-x | scripts/prepend | 11 |
22 files changed, 204 insertions, 498 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..feb9659 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.o +*.bin +*.elf +*.ld +deps.mk @@ -1,41 +1,53 @@ -CFLAGS := -fno-pie -g -ffreestanding -nostdlib -INCLUDE_DIRS := include +DO != echo > deps.mk +CFLAGS := -fno-pie -ggdb3 -ffreestanding -nostdlib +INCLUDE_DIRS := include -all: kernel.bin +all: apos.bin -KERNEL_SOURCES := -INIT_SOURCES := -LINKER_SOURCE := -TARGET ?= riscv -CROSS_COMPILER ?= riscv64-unknown-elf- -CC := gcc -AR := ar -CPP := cpp -OBJCOPY := objcopy -OBJCOPY_FLAGS := -Obinary +ARCH ?= riscv +CROSS_COMPILE ?= riscv64-unknown-elf- -include arch/source.mk +# Common programs +CC := gcc +AR := ar +CPP := cpp +OBJCOPY ?= objcopy +OBJCOPY_FLAGS ?= -Obinary -INCLUDE_FLAGS := $(addprefix -I,$(INCLUDE_DIRS)) -KERNEL_OBJECTS := $(patsubst %.c,%.o,$(KERNEL_SOURCES)) -KERNEL_OBJECTS := $(patsubst %.S,%.o,$(KERNEL_OBJECTS)) +KERNEL_SOURCES := +KERNEL_LINK := +INIT_SOURCES := +INIT_LINK := +INCLUDE_DIRS := include -LINKER_FILE := $(patsubst %.S,%.ld,$(LINKER_SOURCE)) +include arch/$(ARCH)/source.mk -kernel.bin: kernel.elf - $(CROSS_COMPILER)$(OBJCOPY) $(OBJCOPY_FLAGS) $< $@ +INCLUDE_FLAGS != ./scripts/prepend -I $(INCLUDE_DIRS) -kernel.elf: $(KERNEL_OBJECTS) | $(LINKER_FILE) - $(CROSS_COMPILER)$(CC) -T$(LINKER_FILE) $(CFLAGS) $(INCLUDE_FLAGS) $^ -o $@ +KERNEL_OBJECTS != ./scripts/mkobjs $(CROSS_COMPILE)$(CC) $(CFLAGS)\ + $(INCLUDE_FLAGS) --kern-files $(KERNEL_SOURCES) -%.o: %.c - $(CROSS_COMPILER)$(CC) $(CFLAGS) $(INCLUDE_FLAGS) -c $< -o $@ +KERNEL_LD != ./scripts/mkobjs $(CROSS_COMPILE)$(CPP)\ + $(INCLUDE_FLAGS) --kern-lds $(KERNEL_LINK) -%.o: %.S - $(CROSS_COMPILER)$(CC) $(CFLAGS) $(INCLUDE_FLAGS) -c $< -o $@ +INIT_OBJECTS != ./scripts/mkobjs $(CROSS_COMPILE)$(CC) $(CFLAGS)\ + $(INCLUDE_FLAGS) --init-files $(INIT_SOURCES) -$(LINKER_FILE): $(LINKER_SOURCE) - $(CROSS_COMPILER)$(CPP) $(INCLUDE_FLAGS) $< | sed -n '/^[^#]/p' > $@ +INIT_LD != ./scripts/mkobjs $(CROSS_COMPILE)$(CPP)\ + $(INCLUDE_FLAGS) --init-lds $(INIT_LINK) + +include deps.mk + +apos.bin: kernel.elf init.elf + $(CROSS_COMPILE)$(OBJCOPY) $(OBJCOPY_FLAGS) kernel.elf kernel.bin + $(CROSS_COMPILE)$(OBJCOPY) $(OBJCOPY_FLAGS) init.elf init.bin + cat init.bin kernel.bin > $@ + +kernel.elf: $(KERNEL_OBJECTS) $(KERNEL_LD) + $(CROSS_COMPILE)$(CC) -T$(KERNEL_LD) $(CFLAGS) $(INCLUDE_FLAGS) $(KERNEL_OBJECTS) -o $@ + +init.elf: $(INIT_OBJECTS) $(INIT_LD) + $(CROSS_COMPILE)$(CC) -T$(INIT_LD) $(CFLAGS) $(INCLUDE_FLAGS) $(INIT_OBJECTS) -o $@ clean: - rm $(KERNEL_OBJECTS) $(INIT_OBJECTS) $(LINKER_FILE) kernel.bin kernel.elf + rm $(KERNEL_OBJECTS) $(INIT_OBJECTS) $(INIT_LD) $(KERNEL_LD) kernel.bin kernel.elf init.bin init.elf apos.bin diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..b5a4900 --- /dev/null +++ b/TODO.txt @@ -0,0 +1,4 @@ ++ Add in sensible defines (uint64_t etc.) ++ Improve build process (Kbuild? nah, regular config.h files) ++ Automate booting and starting qemu etc. (make run) ++ Add in pmem/vmem routines (both .init and .text!) diff --git a/arch/riscv/include/csr.h b/arch/riscv/include/csr.h index 13f96cb..694000b 100644 --- a/arch/riscv/include/csr.h +++ b/arch/riscv/include/csr.h @@ -3,4 +3,6 @@ #define csr_write(csr, val) +#define SATP_MODE_39 0x8000000000000000 + #endif /* APOS_CSR_H */ diff --git a/arch/riscv/include/vmap.h b/arch/riscv/include/vmap.h index 3dac3a1..a1cf52f 100644 --- a/arch/riscv/include/vmap.h +++ b/arch/riscv/include/vmap.h @@ -3,15 +3,14 @@ #include <apos/sizes.h> -#define VM_V (1 << 1) -#define VM_R (1 << 2) -#define VM_W (1 << 3) -#define VM_X (1 << 4) -#define VM_U (1 << 5) -#define VM_G (1 << 6) -#define VM_A (1 << 7) -#define VM_D (1 << 8) -#define VM_AL 0xff +#define VM_V (1 << 0) +#define VM_R (1 << 1) +#define VM_W (1 << 2) +#define VM_X (1 << 3) +#define VM_U (1 << 4) +#define VM_G (1 << 5) +#define VM_A (1 << 6) +#define VM_D (1 << 7) #define VM_TOP (-1) #define VM_KERN (VM_TOP - SZ_1G) diff --git a/arch/riscv/init-link.S b/arch/riscv/init-link.S new file mode 100644 index 0000000..db18822 --- /dev/null +++ b/arch/riscv/init-link.S @@ -0,0 +1,14 @@ +#include <apos/link.lds.h> +#include <vmap.h> + +OUTPUT_ARCH(riscv) +ENTRY(_start) + +SECTIONS { + . = ABSOLUTE(PM_KERN); + .text ALIGN(4K) : AT(0) { + *(.init.start) + *(.text); + . = ALIGN(4K); + } +} diff --git a/arch/riscv/init/init.c b/arch/riscv/init/init.c index cdcfbb7..69dbc0a 100644 --- a/arch/riscv/init/init.c +++ b/arch/riscv/init/init.c @@ -2,19 +2,20 @@ #include <apos/init.h> #include <apos/sizes.h> #include <pages.h> +#include <csr.h> #include <vmap.h> struct page_ret { size_t left; size_t num; - void *top; + size_t top; }; extern void main(struct mm_pagearr_info *pageinfo); -void __init init_zero(void *ptr, size_t bytes) +void __init init_zero(size_t ptr, size_t bytes) { - char *byte_ptr = ptr; + char *byte_ptr = (char *)ptr; /* Not entirely sure if it would be faster to use a larget type than * char, Linux seems to have memset16/32/64 but I guess I should check @@ -24,7 +25,7 @@ void __init init_zero(void *ptr, size_t bytes) *byte_ptr++ = 0; } -struct page_ret __init init_pages(size_t ram_size, void *ram_top, +struct page_ret __init init_pages(size_t ram_size, size_t ram_top, size_t page_size, size_t struct_size) { size_t num_pages = ram_size / page_size; @@ -33,7 +34,7 @@ struct page_ret __init init_pages(size_t ram_size, void *ram_top, struct page_ret pageret; pageret.top = ram_top - size_pages; pageret.num = num_pages; - pageret.left = ram_size - (size_pages * page_size); + pageret.left = ram_size - (num_pages * page_size); init_zero(pageret.top, size_pages); @@ -55,12 +56,13 @@ void __init init_enter_vm(unsigned long *root_page) { asm volatile ("csrw 0x180, %0\n" "sfence.vma\n" : - : "rK" (root_page) + : "rK" (SATP_MODE_39 | ((unsigned long)root_page >> 12)) : "memory"); } -void call_main() +void __init call_main() { + while(1){}; } void __init init(void *ram_base, void *ram_top, void *initrd, void *fdt, void *boot) @@ -71,37 +73,42 @@ void __init init(void *ram_base, void *ram_top, void *initrd, void *fdt, void *b struct page_ret pageret; /* create crude page status map at the top of physical RAM */ - pageret = init_pages(ram_size, ram_top, + pageret = init_pages(ram_size, (size_t)ram_top, SZ_512G, sizeof(struct terapages)); + pagearr.tera_top = (struct terapages *)pageret.top; pagearr.tera_num = pageret.num; - pagearr.tera_top = pageret.top; pageret = init_pages(pageret.left, pageret.top, SZ_1G, sizeof(struct gigapages)); + pagearr.giga_top = (struct gigapages *)pageret.top; pagearr.giga_num = pageret.num; - pagearr.giga_top = pageret.top; pageret = init_pages(pageret.left, pageret.top, SZ_2M, sizeof(struct megapages)); + pagearr.mega_top = (struct megapages *)pageret.top; pagearr.mega_num = pageret.num; - pagearr.mega_top = pageret.top; pageret = init_pages(pageret.left, pageret.top, SZ_4K, sizeof(struct kilopages)); + pagearr.kilo_top = (struct kilopages *)pageret.top; pagearr.kilo_num = pageret.num; - pagearr.kilo_top = pageret.top; unsigned long *root_page = (unsigned long *) (init_align_down((size_t)pagearr.kilo_top, SZ_4K) - SZ_4K); + unsigned long *mid_page = (unsigned long)root_page - SZ_4K; + unsigned long *bot_page = (unsigned long)mid_page - SZ_4K; + /* TODO: should init insert page data into the created arrays? */ + unsigned long root_addr = (((unsigned long)boot >> 12) >> 18) & 0x1ff; + unsigned long mid_addr = (((unsigned long)boot >> 12) >> 9) & 0x1ff; + unsigned long bot_addr = (((unsigned long)boot >> 12) >> 0) & 0x1ff; - /* map .text.* into top part of RAM */ - root_page[511] = ((unsigned long)&main & VM_AL) | VM_V | VM_R | VM_W | VM_X; + root_page[root_addr] = (((unsigned long)mid_page & ~0x3ff) >> 2) | VM_V; + mid_page[mid_addr] = ((unsigned long)bot_page & ~0x3ff) >> 2 | VM_V; + bot_page[bot_addr] = (((unsigned long)boot & ~0x3ff) >> 2) | VM_V | VM_R | VM_W | VM_X; - /* temporarily map .init.* so that our current physical address matches - * the virtual address */ - root_page[0] = 0 | VM_V | VM_R | VM_W | VM_X; + //root_page[0] = (((unsigned long)ram_base & ~0x3ff) >> 2) | VM_V | VM_R | VM_W | VM_X; /* enter virtual memory */ init_enter_vm(root_page); diff --git a/arch/riscv/kernel-link.S b/arch/riscv/kernel-link.S new file mode 100644 index 0000000..873c7de --- /dev/null +++ b/arch/riscv/kernel-link.S @@ -0,0 +1,14 @@ +#include <apos/link.lds.h> +#include <vmap.h> + +OUTPUT_ARCH(riscv) +ENTRY(main) + +SECTIONS { + . = ABSOLUTE(VM_KERN); + .text ALIGN(4K) : AT(0) { + *(.text.start); + *(.text); + . = ALIGN(4K); + } +} diff --git a/kernel.its b/arch/riscv/kernel.its index f984d40..f984d40 100644 --- a/kernel.its +++ b/arch/riscv/kernel.its diff --git a/arch/riscv/riscv-link.S b/arch/riscv/riscv-link.S index ffdf590..0950850 100644 --- a/arch/riscv/riscv-link.S +++ b/arch/riscv/riscv-link.S @@ -1,20 +1,22 @@ +#include <apos/link.lds.h> #include <vmap.h> OUTPUT_ARCH(riscv) ENTRY(_start) SECTIONS { - . = 0; /* no offset */ - .init : { + . = ABSOLUTE(PM_KERN); + .init ALIGN(4K) : AT(0) { *(.init.start); *(.init.text); *(.init.data); . = ALIGN(4K); } - .text ALIGN(VM_KERN) : AT(ADDR(.init) + SIZEOF(.init)) { - *(.init.start); + . = ABSOLUTE(VM_KERN); + .text ALIGN(4K) : AT(SIZEOF(.init)) { *(.text.start); - *(.text); + *(.text.text); + *(.text.data); } } diff --git a/arch/riscv/source.mk b/arch/riscv/source.mk index f52750c..8bd67ee 100644 --- a/arch/riscv/source.mk +++ b/arch/riscv/source.mk @@ -1,5 +1,9 @@ -LOCAL_KERNEL_SOURCES := main.c init/head.S init/init.c -KERNEL_SOURCES += $(addprefix arch/riscv/,$(LOCAL_KERNEL_SOURCES)) +KERNEL_LOCAL != ./scripts/prepend arch/riscv/ main.c +KERNEL_SOURCES += $(KERNEL_LOCAL) -INCLUDE_DIRS += arch/riscv/include -LINKER_SOURCE := arch/riscv/riscv-link.S +INIT_LOCAL != ./scripts/prepend arch/riscv/init/ init.c head.S +INIT_SOURCES += $(INIT_LOCAL) + +INCLUDE_DIRS += arch/riscv/include +KERNEL_LINK := arch/riscv/kernel-link.S +INIT_LINK := arch/riscv/init-link.S diff --git a/arch/source.mk b/arch/source.mk deleted file mode 100644 index 1b21b56..0000000 --- a/arch/source.mk +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(TARGET),riscv) -include arch/riscv/source.mk -endif diff --git a/fs/kernel.itb b/fs/kernel.itb Binary files differdeleted file mode 100644 index 0d9f740..0000000 --- a/fs/kernel.itb +++ /dev/null diff --git a/include/apos/init.h b/include/apos/init.h index 1c4bc9d..82f1774 100644 --- a/include/apos/init.h +++ b/include/apos/init.h @@ -3,7 +3,7 @@ #include <apos/compiler_attributes.h> -#define __init __section(".init.text") -#define __initdata __section(".init.data") +#define __init +#define __initdata #endif /* APOS_INIT_H */ diff --git a/include/apos/link.lds.h b/include/apos/link.lds.h index aa9f2e2..ddb1f65 100644 --- a/include/apos/link.lds.h +++ b/include/apos/link.lds.h @@ -1,45 +1,8 @@ #ifndef APOS_LINK_LDS_H #define APOS_LINK_LDS_H -#define DWARF_DEBUG \ - /* DWARF 1 */ \ - .debug 0 : { *(.debug) } \ - .line 0 : { *(.line) } \ - /* GNU DWARF 1 extensions */ \ - .debug_srcinfo 0 : { *(.debug_srcinfo) } \ - .debug_sfnames 0 : { *(.debug_sfnames) } \ - /* DWARF 1.1 and DWARF 2 */ \ - .debug_aranges 0 : { *(.debug_aranges) } \ - .debug_pubnames 0 : { *(.debug_pubnames) } \ - /* DWARF 2 */ \ - .debug_info 0 : { *(.debug_info \ - .gnu.linkonce.wi.*) } \ - .debug_abbrev 0 : { *(.debug_abbrev) } \ - .debug_line 0 : { *(.debug_line) } \ - .debug_frame 0 : { *(.debug_frame) } \ - .debug_str 0 : { *(.debug_str) } \ - .debug_loc 0 : { *(.debug_loc) } \ - .debug_macinfo 0 : { *(.debug_macinfo) } \ - .debug_pubtypes 0 : { *(.debug_pubtypes) } \ - /* DWARF 3 */ \ - .debug_ranges 0 : { *(.debug_ranges) } \ - /* SGI/MIPS DWARF 2 extensions */ \ - .debug_weaknames 0 : { *(.debug_weaknames) } \ - .debug_funcnames 0 : { *(.debug_funcnames) } \ - .debug_typenames 0 : { *(.debug_typenames) } \ - .debug_varnames 0 : { *(.debug_varnames) } \ - /* GNU DWARF 2 extensions */ \ - .debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) } \ - .debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) } \ - /* DWARF 4 */ \ - .debug_types 0 : { *(.debug_types) } \ - /* DWARF 5 */ \ - .debug_addr 0 : { *(.debug_addr) } \ - .debug_line_str 0 : { *(.debug_line_str) } \ - .debug_loclists 0 : { *(.debug_loclists) } \ - .debug_macro 0 : { *(.debug_macro) } \ - .debug_names 0 : { *(.debug_names) } \ - .debug_rnglists 0 : { *(.debug_rnglists) } \ - .debug_str_offsets 0 : { *(.debug_str_offsets) } +#ifndef PM_KERN +#define PM_KERN 0 +#endif #endif /* APOS_LINK_LDS_H */ diff --git a/include/apos/types.h b/include/apos/types.h new file mode 100644 index 0000000..2e30080 --- /dev/null +++ b/include/apos/types.h @@ -0,0 +1,4 @@ +#ifdef APOS_TYPES_H +#define APOS_TYPES_H + +#endif /* APOS_TYPES_H */ Binary files differ@@ -1,389 +0,0 @@ - -Symtab for file arch/riscv/init/head.S at 0x55d5c1168a50 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: asm - -Line table: - - line 6 at 0x83800000 (stmt) - line 8 at 0x83800004 (stmt) - line 10 at 0x83800006 (stmt) - line 0 at 0x8380000a (stmt) - -Blockvector: - -block #000, object at 0x55d5c1168ae0, 0 syms/buckets in 0x83800000..0x8380000a - block #001, object at 0x55d5c1168a80 under 0x55d5c1168ae0, 0 syms/buckets in 0x83800000..0x8380000a - - -Symtab for file arch/riscv/init/init.c at 0x55d5c113f9f0 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector: - -block #000, object at 0x55d5c1168880, 0 syms/buckets in 0x83800000..0x83800000 - block #001, object at 0x55d5c11687c0 under 0x55d5c1168880, 4 syms/buckets in 0x83800000..0x83800000 - typedef char pagemask_t; - typedef long unsigned int long unsigned int; - typedef long double long double; - struct megapages { - lockbit_t lockbit[64]; - pagemask_t empty[64]; - pagemask_t full[64]; - struct kilopages kilo[512]; - }; - - struct mm_pagearr_info { - short int tera_num; - struct terapages *tera_top; - short int giga_num; - struct gigapages *giga_top; - short int mega_num; - struct megapages *mega_top; - short int kilo_num; - struct kilopages *kilo_top; - }; - - struct page_ret { - size_t left; - size_t num; - void *top; - }; - - typedef long int long int; - typedef long unsigned int size_t; - typedef int int; - typedef long long int long long int; - typedef char char; - typedef char lockbit_t; - struct kilopages { - pagemask_t page[64]; - }; - - struct gigapages { - lockbit_t lockbit[64]; - pagemask_t empty[64]; - pagemask_t full[64]; - struct megapages mega[512]; - }; - - struct terapages { - lockbit_t lockbit[64]; - pagemask_t empty[64]; - pagemask_t full[64]; - struct gigapages giga[512]; - }; - - typedef short int short int; - -Compunit user: 0x55d5c115e2e0 - -Symtab for file /usr/lib/gcc/riscv64-unknown-elf/8.3.0/include/stddef.h at 0x55d5c113f990 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/init/init.c - - -Symtab for file arch/riscv/include/pages.h at 0x55d5c113f9c0 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/init/init.c - - -Symtab for file include/apos/init.h at 0x55d5c113fa20 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/init/init.c - - -Symtab for file include/apos/compiler_attributes.h at 0x55d5c113fa50 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/init/init.c - - -Symtab for file include/apos/sizes.h at 0x55d5c113fa80 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/init/init.c - - -Symtab for file arch/riscv/include/vmap.h at 0x55d5c113fab0 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/init/init.c - - -Symtab for file arch/riscv/main.c at 0x55d5c115e3f0 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector: - -block #000, object at 0x55d5c113f860, 0 syms/buckets in 0x83800000..0x83800000 - block #001, object at 0x55d5c113f7a0 under 0x55d5c113f860, 3 syms/buckets in 0x83800000..0x83800000 - struct kilopages { - pagemask_t page[64]; - }; - - struct gigapages { - lockbit_t lockbit[64]; - pagemask_t empty[64]; - pagemask_t full[64]; - struct megapages mega[512]; - }; - - struct terapages { - lockbit_t lockbit[64]; - pagemask_t empty[64]; - pagemask_t full[64]; - struct gigapages giga[512]; - }; - - typedef char lockbit_t; - struct megapages { - lockbit_t lockbit[64]; - pagemask_t empty[64]; - pagemask_t full[64]; - struct kilopages kilo[512]; - }; - - struct mm_pagearr_info { - short int tera_num; - struct terapages *tera_top; - short int giga_num; - struct gigapages *giga_top; - short int mega_num; - struct megapages *mega_top; - short int kilo_num; - struct kilopages *kilo_top; - }; - - typedef short int short int; - typedef char pagemask_t; - typedef char char; - typedef long unsigned int long unsigned int; - -Compunit user: 0x55d5c115e2e0 - -Symtab for file arch/riscv/include/pages.h at 0x55d5c115e3c0 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/main.c - - -Symtab for file include/apos/main.h at 0x55d5c115e420 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/main.c - - -Symtab for file include/apos/compiler_attributes.h at 0x55d5c115e450 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector same as owning compunit: arch/riscv/main.c - - -Symtab for file <artificial> at 0x55d5c115e2e0 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Blockvector: - -block #000, object at 0x55d5c115dc10, 2 syms/buckets in 0x8380000a..0x8380000a - void init(void *, void *, void *, void *, void *); block object 0x55d5c1158ff0, 0x83800160..0x838002f4 section .init - void init_enter_vm(long unsigned int *); block object 0x55d5c115c820, 0x83800144..0x83800160 - long unsigned int init_align_down(size_t, size_t); block object 0x55d5c115cf00, 0x838000e4..0x83800116 - void init_zero(void *, size_t); block object 0x55d5c115da60, 0x8380000a..0x83800046 - void main(struct mm_pagearr_info *); block object 0x55d5c1159400, 0x43800000..0x4380000c section .init - void call_main(); block object 0x55d5c11595f0, 0x4380000c..0x43800018 section .init - long unsigned int init_align_up(size_t, size_t); block object 0x55d5c115cb50, 0x83800116..0x83800144 - struct page_ret { - size_t left; - size_t num; - void *top; - } init_pages(size_t, void *, size_t, size_t); block object 0x55d5c115d500, 0x83800046..0x838000e4 - block #001, object at 0x55d5c115db20 under 0x55d5c115dc10, 0 syms/buckets in 0x8380000a..0x8380000a - block #002, object at 0x55d5c1159400 under 0x55d5c115db20, 1 syms/buckets in 0x43800000..0x4380000c, function main - struct mm_pagearr_info { - short int tera_num; - struct terapages *tera_top; - short int giga_num; - struct gigapages *giga_top; - short int mega_num; - struct megapages *mega_top; - short int kilo_num; - struct kilopages *kilo_top; - } *pageinfo; computed at runtime - block #003, object at 0x55d5c11595f0 under 0x55d5c115db20, 0 syms/buckets in 0x4380000c..0x43800018, function call_main - block #004, object at 0x55d5c115da60 under 0x55d5c115db20, 3 syms/buckets in 0x8380000a..0x83800046, function init_zero - void *ptr; computed at runtime - long unsigned int bytes; computed at runtime - char *byte_ptr; computed at runtime - block #005, object at 0x55d5c115d500 under 0x55d5c115db20, 7 syms/buckets in 0x83800046..0x838000e4, function init_pages - long unsigned int ram_size; computed at runtime - void *ram_top; computed at runtime - long unsigned int page_size; computed at runtime - long unsigned int struct_size; computed at runtime - long unsigned int num_pages; computed at runtime - long unsigned int size_pages; computed at runtime - struct page_ret { - size_t left; - size_t num; - void *top; - } pageret; computed at runtime - block #006, object at 0x55d5c115cf00 under 0x55d5c115db20, 3 syms/buckets in 0x838000e4..0x83800116, function init_align_down - long unsigned int num; computed at runtime - long unsigned int a; computed at runtime - long unsigned int rem; computed at runtime - block #007, object at 0x55d5c115cb50 under 0x55d5c115db20, 2 syms/buckets in 0x83800116..0x83800144, function init_align_up - long unsigned int num; computed at runtime - long unsigned int a; computed at runtime - block #008, object at 0x55d5c115c820 under 0x55d5c115db20, 1 syms/buckets in 0x83800144..0x83800160, function init_enter_vm - long unsigned int *root_page; computed at runtime - block #009, object at 0x55d5c1158ff0 under 0x55d5c115db20, 9 syms/buckets in 0x83800160..0x838002f4, function init - void *ram_base; computed at runtime - void *ram_top; computed at runtime - void *initrd; computed at runtime - void *fdt; computed at runtime - void *boot; computed at runtime - long unsigned int ram_size; computed at runtime - struct mm_pagearr_info { - short int tera_num; - struct terapages *tera_top; - short int giga_num; - struct gigapages *giga_top; - short int mega_num; - struct megapages *mega_top; - short int kilo_num; - struct kilopages *kilo_top; - } pagearr; computed at runtime - struct page_ret { - size_t left; - size_t num; - void *top; - } pageret; computed at runtime - long unsigned int *root_page; computed at runtime - -Compunit include: 0x55d5c115e3f0 -Compunit include: 0x55d5c113f9f0 - -Symtab for file arch/riscv/main.c at 0x55d5c11185d0 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Line table: - - line 5 at 0x43800000 (stmt) - line 0 at 0x4380000c (stmt) - line 0 at 0x4380000c (stmt) - line 0 at 0x8380000a (stmt) - -Blockvector same as owning compunit: <artificial> - - -Symtab for file arch/riscv/init/init.c at 0x55d5c1118600 -Compilation directory is /home/kimi/Documents/Projects/aposkern -Read from object file /home/kimi/Documents/Projects/aposkern/kernel.debug (0x55d5c11488f0) -Language: c - -Line table: - - line 63 at 0x4380000c (stmt) - line 64 at 0x43800012 (stmt) - line 0 at 0x43800018 (stmt) - line 16 at 0x8380000a (stmt) - line 16 at 0x8380000a (stmt) - line 17 at 0x83800018 (stmt) - line 24 at 0x83800022 (stmt) - line 24 at 0x8380002e (stmt) - line 23 at 0x83800032 (stmt) - line 23 at 0x8380003e (stmt) - line 25 at 0x83800040 (stmt) - line 29 at 0x83800046 (stmt) - line 30 at 0x83800062 (stmt) - line 31 at 0x83800072 (stmt) - line 34 at 0x83800082 (stmt) - line 34 at 0x83800090 (stmt) - line 35 at 0x83800094 (stmt) - line 36 at 0x8380009c (stmt) - line 36 at 0x838000a8 (stmt) - line 36 at 0x838000b0 (stmt) - line 38 at 0x838000b4 (stmt) - line 40 at 0x838000c2 (stmt) - line 41 at 0x838000d8 (stmt) - line 44 at 0x838000e4 (stmt) - line 45 at 0x838000f2 (stmt) - line 46 at 0x83800102 (stmt) - line 47 at 0x8380010e (stmt) - line 50 at 0x83800116 (stmt) - line 51 at 0x83800126 (stmt) - line 51 at 0x83800134 (stmt) - line 52 at 0x8380013a (stmt) - line 55 at 0x83800144 (stmt) - line 56 at 0x8380014e (stmt) - line 60 at 0x8380015a (stmt) - line 67 at 0x83800160 (stmt) - line 68 at 0x8380017c (stmt) - line 68 at 0x83800188 (stmt) - line 74 at 0x8380018c (stmt) - line 76 at 0x838001ac (stmt) - line 76 at 0x838001b0 (stmt) - line 77 at 0x838001bc (stmt) - line 77 at 0x838001c0 (stmt) - line 79 at 0x838001c4 (stmt) - line 81 at 0x838001f8 (stmt) - line 81 at 0x838001fc (stmt) - line 82 at 0x83800208 (stmt) - line 82 at 0x8380020c (stmt) - line 84 at 0x83800210 (stmt) - line 86 at 0x83800242 (stmt) - line 86 at 0x83800246 (stmt) - line 87 at 0x83800252 (stmt) - line 87 at 0x83800256 (stmt) - line 89 at 0x8380025a (stmt) - line 91 at 0x8380028a (stmt) - line 91 at 0x8380028e (stmt) - line 92 at 0x8380029a (stmt) - line 92 at 0x8380029e (stmt) - line 95 at 0x838002a2 (stmt) - line 95 at 0x838002a6 (stmt) - line 95 at 0x838002b0 (stmt) - line 94 at 0x838002b4 (stmt) - line 100 at 0x838002b8 (stmt) - line 100 at 0x838002c0 (stmt) - line 100 at 0x838002c4 (stmt) - line 100 at 0x838002ce (stmt) - line 100 at 0x838002d2 (stmt) - line 104 at 0x838002d4 (stmt) - line 107 at 0x838002dc (stmt) - line 110 at 0x838002e4 (stmt) - line 111 at 0x838002ec (stmt) - line 0 at 0x838002f4 (stmt) - -Blockvector same as owning compunit: <artificial> - diff --git a/init.debug b/init.debug Binary files differdeleted file mode 100644 index fb09633..0000000 --- a/init.debug +++ /dev/null diff --git a/kernel.a b/kernel.a Binary files differdeleted file mode 100644 index 30b9249..0000000 --- a/kernel.a +++ /dev/null diff --git a/scripts/mkobjs b/scripts/mkobjs new file mode 100755 index 0000000..188465b --- /dev/null +++ b/scripts/mkobjs @@ -0,0 +1,57 @@ +#!/bin/sh + +genobj () { + path=$(dirname "$1")/ + obj=$(echo "$1" | sed "s/\\.[cS]/.${command_suffix}.o/") + $cc_command -MM -MP $n | \ + sed "s|\\(.*\)\\.o|${path}\\1.${command_suffix}.o|" >> deps.mk + + echo "$obj: $n" >> deps.mk + echo " $cc_command -c $1 -o $obj" >> deps.mk + + cc_objs="$cc_objs $obj" +} + +genlink () { + link=$(echo "$1" | sed 's/\.S/.ld/') + echo "$link: $1" >> deps.mk + echo " $cc_command $1 | sed -n '/^[^#]/p' > $link" >> deps.mk + + cc_objs="$cc_objs $link" +} + +for n in "$@" +do + case "$n" in + --kern-files) + command_suffix=k + command_func=genobj + continue + ;; + + --kern-lds) + command_func=genlink + continue + ;; + + --init-files) + command_suffix=i + command_func=genobj + continue + ;; + + --init-lds) + command_func=genlink + continue + ;; + esac + + if [ "$command_func" = "" ] + then + cc_command="$cc_command $n" + else + $command_func "$n" + fi +done + +echo "$cc_objs" diff --git a/scripts/prepend b/scripts/prepend new file mode 100755 index 0000000..ef10da1 --- /dev/null +++ b/scripts/prepend @@ -0,0 +1,11 @@ +#!/bin/sh + +prep="$1" +shift + +for n in "$@" +do + ret="$ret $prep$n" +done + +echo "$ret" |
