From: Matthias Kruk Date: Tue, 3 Sep 2019 15:12:59 +0000 (+0900) Subject: Remove object files that were added in error; add current state of the source X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=fc9954747183df366d5dca5102229656d012d450;p=corax Remove object files that were added in error; add current state of the source --- diff --git a/Makefile b/Makefile index 7782996..f463b6e 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ DEPS = kernel OUTPUT = corax PHONY = $(DEPS) clean qemu -LAYOUT = $(shell setxkbmap -query | sed -nE 's/^layout:.*?([a-z]{2})$/\1/p') +#LAYOUT = $(shell setxkbmap -query | sed -nE 's/^layout:.*?([a-z]{2})$/\1/p') -foo: - $(eval setxkbmap -query | sed -nE 's/^layout:.*?([a-z]{2})$/\1/p') +#foo: +# $(eval setxkbmap -query | sed -nE 's/^layout:.*?([a-z]{2})$/\1/p') all: $(OUTPUT) qemu: - qemu-system-x86_64 -k ja -kernel $(OUTPUT) -m 512 + qemu-system-i386 -k ja -kernel $(OUTPUT) -m 128 -display gtk $(OUTPUT): $(DEPS) mv kernel/corax $(OUTPUT) diff --git a/config.h b/config.h index d0d930f..69b7f4f 100644 --- a/config.h +++ b/config.h @@ -22,7 +22,7 @@ #define CONFIG_KERNEL_STACK_SIZE 4096 #define CONFIG_USER_STACK_SIZE 4096 -#define CONFIG_APIC 1 +#define CONFIG_APIC 0 #define CONFIG_SMP 0 #define CONFIG_SMP_CPUS 1 diff --git a/kernel/arch/apic.o b/kernel/arch/apic.o deleted file mode 100644 index 78dd5e0..0000000 Binary files a/kernel/arch/apic.o and /dev/null differ diff --git a/kernel/arch/arch.o b/kernel/arch/arch.o deleted file mode 100644 index b02a94b..0000000 Binary files a/kernel/arch/arch.o and /dev/null differ diff --git a/kernel/arch/boot.S b/kernel/arch/boot.S index 7e53bf1..41b8551 100644 --- a/kernel/arch/boot.S +++ b/kernel/arch/boot.S @@ -38,6 +38,7 @@ loader: cli movl $_cpu, %esp addl $STACK0_TOP, %esp + movl %esp, %ebp pushl %eax pushl %ebx call corax diff --git a/kernel/arch/boot.o b/kernel/arch/boot.o deleted file mode 100644 index 18094cc..0000000 Binary files a/kernel/arch/boot.o and /dev/null differ diff --git a/kernel/arch/cpu.o b/kernel/arch/cpu.o deleted file mode 100644 index b4a094a..0000000 Binary files a/kernel/arch/cpu.o and /dev/null differ diff --git a/kernel/arch/cpu32.o b/kernel/arch/cpu32.o deleted file mode 100644 index 3562e2d..0000000 Binary files a/kernel/arch/cpu32.o and /dev/null differ diff --git a/kernel/arch/debug.o b/kernel/arch/debug.o deleted file mode 100644 index 2e59868..0000000 Binary files a/kernel/arch/debug.o and /dev/null differ diff --git a/kernel/arch/defs.h b/kernel/arch/defs.h index bf52790..72e9903 100644 --- a/kernel/arch/defs.h +++ b/kernel/arch/defs.h @@ -193,6 +193,6 @@ * 0x200 = IF * 0x400 = DF * 0x800 = OF - * 0x1000 = + * 0x1000 = */ #endif /* __DEFS_H */ diff --git a/kernel/arch/entry.o b/kernel/arch/entry.o deleted file mode 100644 index fb3c37a..0000000 Binary files a/kernel/arch/entry.o and /dev/null differ diff --git a/kernel/arch/i8259.S b/kernel/arch/i8259.S index dce961a..82c4124 100644 --- a/kernel/arch/i8259.S +++ b/kernel/arch/i8259.S @@ -30,13 +30,17 @@ _i8259_init: call dbg_printf /* TODO: initialise timer */ -/* call _i8259_getmask */ +#if 0 + call _i8259_getmask +#endif xorl %eax, %eax - movw $0xfffd, %ax + + /* 0x0001 = timer, 0x0002 = kbd */ + /* 0xfffd = mask all but kbd, 0xfffc = all but (timer | kbd) */ + movw $0xfffc, %ax movl %eax, (%esp) call _i8259_setmask addl $4, %esp - sti ret .global _i8259_getmask diff --git a/kernel/arch/i8259.o b/kernel/arch/i8259.o deleted file mode 100644 index 02d25b6..0000000 Binary files a/kernel/arch/i8259.o and /dev/null differ diff --git a/kernel/arch/init.S b/kernel/arch/init.S index 33ef2bf..ada755c 100644 --- a/kernel/arch/init.S +++ b/kernel/arch/init.S @@ -27,6 +27,7 @@ .extern _kernel_cr3 .extern pg_init .extern dbg_printf +.extern dbg_panic .extern _i8259_init .extern _apic_init @@ -136,13 +137,38 @@ _entries: .long _int_entry23 #endif /* CONFIG_APIC */ +_dbg_regs_str: + .ascii "EAX = %08x EBX = %08x\n" + .ascii "ECX = %08x EDX = %08x\n" + .ascii "ESI = %08x EDI = %08x\n" + .asciz "ESP = %08x EBP = %08x\n" + .section .text +.globl _print_regs + +_print_regs: + pushl %ebp + pushl %esp + pushl %edi + pushl %esi + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + pushl $_dbg_regs_str + call dbg_printf + addl $36, %esp + ret + arch_init: + call _print_regs + subl $24, %esp movl $_mem_start, %eax addl $4, %eax movl %eax, (_mem_start) + /* movl $_cpu, %eax addl $GDT_OFFSET, %eax @@ -160,7 +186,8 @@ arch_init: shll $3, %eax movl %eax, 8(%esp) call memset -*/ + */ + movl $_cpu, %eax addl $GDT_OFFSET, %eax movl $0, (%eax) @@ -231,19 +258,28 @@ arch_init: /* remap i8259 interrupts */ movb $0x11, %al outb %al, $PIC1_COMM - outb %al, $PIC2_COMM - movb $PIC1_VECTOR0, %al + movb $PIC1_VECTOR0, %al outb %al, $PIC1_DATA - movb $PIC2_VECTOR0, %al - outb %al, $PIC2_DATA movb $0x04, %al outb %al, $PIC1_DATA - movb $0x02, %al - outb %al, $PIC2_DATA movb $0x01, %al outb %al, $PIC1_DATA + + movb $0x11, %al + outb %al, $PIC2_COMM + movb $PIC2_VECTOR0, %al + outb %al, $PIC2_DATA + movb $0x02, %al + outb %al, $PIC2_DATA + movb $0x01, %al outb %al, $PIC2_DATA + + movl $128, %esi +0: subl $1, %esi xorl %eax, %eax + cmp %esi, 0 + jnz 0b + outb %al, $PIC1_DATA outb %al, $PIC2_DATA @@ -271,7 +307,7 @@ arch_init: addl $8, (%esp) addl $1, %esi jmp 0b - 1: +1: /* _idt_fill: @@ -356,7 +392,7 @@ arch_init: 0: #endif /* CONFIG_APIC */ call _i8259_init - 1: +1: popl %ebx orl %eax, %ebx @@ -381,9 +417,12 @@ arch_init: movl 12(%esp), %eax addl $16, %esp -*/ + */ + + sti + + call _print_regs - sti ret /* diff --git a/kernel/arch/init.o b/kernel/arch/init.o deleted file mode 100644 index fa77260..0000000 Binary files a/kernel/arch/init.o and /dev/null differ diff --git a/kernel/arch/interrupt.c b/kernel/arch/interrupt.c index 49d3768..05023fd 100644 --- a/kernel/arch/interrupt.c +++ b/kernel/arch/interrupt.c @@ -64,8 +64,8 @@ int _int_handle(stack_frame_t ctx) if(ctx.intn == INT_KEYBOARD) { extern struct cpu _cpu[CONFIG_SMP_CPUS]; - dbg_printf("Rebooting...\n"); - + dbg_printf("Keyboard interrupt\n"); +#if 0 /* hacky reboot: clear IDT entries for * #DF and #GP, then cause a #GP */ _cpu[CPU_ID].cpu_idt[EXC_DOUBLEFAULT].sd_low = 0; @@ -76,6 +76,7 @@ int _int_handle(stack_frame_t ctx) /* this is such a retarded thing to do, I don't see how this * could not cause a triple fault */ asm volatile("ljmp $0x30, $0xfee00020"); /* LEEROY JENKINS!!! */ +#endif } else if(ctx.intn != INT_TIMER) { dbg_printf("Interrupt %u occurred\n", ctx.intn); } diff --git a/kernel/arch/interrupt.o b/kernel/arch/interrupt.o deleted file mode 100644 index c3b4f2b..0000000 Binary files a/kernel/arch/interrupt.o and /dev/null differ diff --git a/kernel/arch/paging.c b/kernel/arch/paging.c index e3c9712..91b3ee6 100644 --- a/kernel/arch/paging.c +++ b/kernel/arch/paging.c @@ -131,9 +131,10 @@ void* pg_init(struct multiboot_info *info) { while((u32_t)mmap < (info->mmap_addr + info->mmap_length)) { u32_t attrs; u64_t addr; -/* - dbg_printf("Region: 0x%016llx - 0x%016llx [%u]\n", mmap->addr, mmap->addr + mmap->len, mmap->type); -*/ +#if 1 + dbg_printf("Region: 0x%016llx - 0x%016llx [%u]\n", + mmap->addr, mmap->addr + mmap->len, mmap->type); +#endif attrs = PAGE_ATTR_SIZE | PAGE_ATTR_WRITABLE | PAGE_ATTR_PRESENT; /* disable caching on reserved memory areas */ @@ -152,7 +153,9 @@ void* pg_init(struct multiboot_info *info) { pd = (page_table_t*)cr3; - for(addr = mmap->addr & ~(PAGE_SIZE_LARGE - 1); addr < (mmap->addr + mmap->len); addr += PAGE_SIZE_LARGE) { + for(addr = mmap->addr & ~(PAGE_SIZE_LARGE - 1); + addr < (mmap->addr + mmap->len); + addr += PAGE_SIZE_LARGE) { pd->pt_entries[addr >> 22] = (u32_t)addr | attrs; } @@ -271,7 +274,7 @@ void* pg_init(struct multiboot_info *info) { */ _kernel_cr3 = (u32_t)cr3; - dbg_printf("Enabling %s paging\n", _str_pg_mode[_pg_flags & 0x3]); + dbg_printf("Enabling %s paging\n", _str_pg_mode[_pg_flags & PG_MODE_MASK]); return((void*)(cr3 | _pg_flags)); } diff --git a/kernel/arch/paging.o b/kernel/arch/paging.o deleted file mode 100644 index 7e5594c..0000000 Binary files a/kernel/arch/paging.o and /dev/null differ diff --git a/kernel/arch/task.S b/kernel/arch/task.S index caf5d12..6a0360e 100644 --- a/kernel/arch/task.S +++ b/kernel/arch/task.S @@ -17,10 +17,12 @@ */ #define __ASSEMBLY_SOURCE - + #include #include "defs.h" +#define CPU_SIZE (TSS_OFFSET + TSS_SIZE + 4) +#define CUR_TASK (TSS_OFFSET + TSS_SIZE) .extern _cpu .global _task_prepare diff --git a/kernel/arch/task.o b/kernel/arch/task.o deleted file mode 100644 index 9e4cd05..0000000 Binary files a/kernel/arch/task.o and /dev/null differ diff --git a/kernel/core/core.o b/kernel/core/core.o deleted file mode 100644 index 3fb2790..0000000 Binary files a/kernel/core/core.o and /dev/null differ diff --git a/kernel/core/main.c b/kernel/core/main.c index 85e8641..1667eda 100644 --- a/kernel/core/main.c +++ b/kernel/core/main.c @@ -91,7 +91,6 @@ int corax(void *mb_info, u32_t magic) { u32_t p; /* - volatile register u64_t sysenter, sysexit; void *ptr; for(ptr = (void*)0xd0000; ptr < (void*)0xffffd; ptr++) { @@ -115,6 +114,9 @@ int corax(void *mb_info, u32_t magic) { /* void *ptr;*/ arch_init(mb_info); + + dbg_panic("fooooo", "baaaaar", __LINE__, "foobar"); + /* u64_t capabilities = cpu_get_capabilities(); dbg_printf("CPUID.01h = 0x%016llx\n", capabilities); @@ -123,15 +125,17 @@ int corax(void *mb_info, u32_t magic) { dbg_printf("This is cpu%u\n", cpu_get_id()); } */ +#if 0 + { + volatile register u64_t sysenter, sysexit; -/* - sysenter = cpu_timestamp(); - asm volatile("int $0xCC"); - sysexit = cpu_timestamp(); - - dbg_printf("Syscall took %llu cycles\n", sysexit - sysenter); -*/ + sysenter = cpu_timestamp(); + asm volatile("int $0xCC"); + sysexit = cpu_timestamp(); + dbg_printf("Syscall took %llu cycles\n", sysexit - sysenter); + } +#endif /* cpu_debug(); */ @@ -158,18 +162,21 @@ int corax(void *mb_info, u32_t magic) { } } */ - dbg_printf("Switching pstate\n"); + + asm volatile("int $0xcc"); + asm volatile("int $0xcc"); + /* p = cpu_set_pstate(1); dbg_printf("Entered P-state %u. (0x%x)\n", p & 0xffff, p); - dbg_printf("Initialisation complete. Nothing to do.\n"); - + dbg_printf("Initialisation complete. Nothing to do.\n"); */ +/* struct task tsk; _task_prepare(&tsk, (u32_t)_idle, (u32_t)&_stack + sizeof(_stack)); _task_switch(&tsk); - +*/ while(1) { asm volatile("hlt"); } diff --git a/kernel/core/main.o b/kernel/core/main.o deleted file mode 100644 index af67b10..0000000 Binary files a/kernel/core/main.o and /dev/null differ