CeDOS - Commit e7120df2

Removed some unnecessary code (due to bootloader merge) and cleaned up some now unused variables
Celina Kalus
Fri, 17 Mar 2023 22:22:13 +0100
6 files changed, 25 insertions(+), 92 deletions(-)
M link.txtlink.txt

@@ -39,24 +39,20 @@

} >KERNEL_VMA } -__SS_LMA = LOADADDR(BOOT); -__SS_VMA = ADDR(BOOT); -__SS_SIZE = SIZEOF(BOOT); +__BOOT_LMA = LOADADDR(BOOT); +__BOOT_VMA = ADDR(BOOT); +__BOOT_SIZE = SIZEOF(BOOT); __KERNEL_LMA = LOADADDR(KERNEL); __KERNEL_VMA = ADDR(KERNEL); __KERNEL_SIZE = SIZEOF(KERNEL); - - -__APP_LMA = LOADADDR(APPLICATION); -__APP_VMA = ADDR(APPLICATION); -__APP_SIZE = SIZEOF(APPLICATION); - __ELF_LMA = LOADADDR(ELF); __ELF_VMA = ADDR(ELF); __ELF_SIZE = SIZEOF(ELF); __KERNEL_STACK_ADDR = 0xC0400000; -ASSERT(__SS_SIZE + __KERNEL_SIZE + __APP_SIZE + __ELF_SIZE <= 0x48 * 0x200, "bootloader payload too big!"); +ASSERT(__BOOT_SIZE <= 0x1000, "bootloader too big!"); +ASSERT(__KERNEL_SIZE <= 0x5000, "bootloader too big!"); +ASSERT(__ELF_SIZE <= 0x3000, "bootloader too big!");
M src/boot/linker.hsrc/boot/linker.h

@@ -6,10 +6,6 @@ #define LINKER_H

#include <stdint.h> -extern uint8_t __SS_VMA; -extern uint8_t __SS_LMA; -extern uint8_t __SS_SIZE; - extern uint8_t __KERNEL_VMA; extern uint8_t __KERNEL_LMA; extern uint8_t __KERNEL_SIZE;

@@ -17,10 +13,6 @@

extern uint8_t __APP_VMA; extern uint8_t __APP_LMA; extern uint8_t __APP_SIZE; - -#define SS_VMA (&__SS_VMA) -#define SS_LMA (&__SS_LMA) -#define SS_SIZE (uint32_t)(&__SS_SIZE) #define KERNEL_VMA (&__KERNEL_VMA) #define KERNEL_LMA (&__KERNEL_LMA)
D src/boot/main.c

@@ -1,47 +0,0 @@

-#include "linker.h" -#include "paging.h" - -/* -#define VGA_TEXTMODE_COLUMNS 80 -#define VGA_TEXTMODE_LINES 25 -#define VGA_TEXTMODE_CELLS (VGA_TEXTMODE_COLUMNS * VGA_TEXTMODE_LINES) - -#define VGA_TEXT_COLOR 0x02 - -uint8_t const *display_start = (uint8_t*)0xB8000; -uint8_t *display = (uint8_t*)0xB8000; - -void simple_clear(void) { - display = (uint8_t*)display_start; - - for (int i = 0; i < VGA_TEXTMODE_CELLS; i++) { - display[2 * i] = 0x00; - display[2 * i + 1] = 0x00; - } -} - -void simple_print(const char *src) { - while (*src) { - *display++ = *src++; - *display++ = VGA_TEXT_COLOR; - } -} - -void simple_println(const char *src) { - simple_print(src); - - while ((display - display_start) % (2 * VGA_TEXTMODE_COLUMNS)) { - display++; - display++; - } -} -*/ - -void copy_kernel(void) { - uint8_t *kernel_dest = (uint8_t*)0x00100000; - uint8_t *kernel_src = (uint8_t*)0x00010000; - - for (uint32_t i = 0; i < 0x8000; i++) { - kernel_dest[i] = kernel_src[i]; - } -}
M src/boot/paging.csrc/boot/paging.c

@@ -23,7 +23,7 @@ // map 4M of kernel to 0xC0000000

(*pdir)[PAGE_DIR_INDEX(KERNEL_VMA)].entry = MAKE_PAGE_ENTRY(kernel, 0b000000000011); for (uint32_t i = 0; i < 1 << 10; i++) { - (*kernel)[i].entry = MAKE_PAGE_ENTRY(0x100000 + PAGE_SIZE * i, 0b000000000011); + (*kernel)[i].entry = MAKE_PAGE_ENTRY(0x10000 + PAGE_SIZE * i, 0b000000000011); } // identity map first 4M of memory
M src/boot/stage1.ssrc/boot/entry.s

@@ -362,9 +362,25 @@ mov %eax, %es

mov %eax, %fs mov %eax, %gs mov %eax, %ss + + # create a page directory for the kernel that maps it to 0xC0000000 + # and identity maps the first 1M of memory + call create_kernel_environment + + # load kernel page directory + movl %eax, %cr3 - # jump to second stage code - ljmp $0x08, $__SS_START + # set paging enable and protection bit + movl %cr0, %eax + or $0x80000010, %eax + movl %eax, %cr0 + + # jump to kernel code + ljmp $8, $__KERNEL_START + + # loop until the heat death of the universe +loop: + jmp loop .section .data
D src/boot/stage2.s

@@ -1,24 +0,0 @@

-.section .text -.global __SS_START -__SS_START: - # copy the kernel code to 0x00100000 - call copy_kernel - - # create a page directory for the kernel that maps it to 0xC0000000 - # and identity maps the first 1M of memory - call create_kernel_environment - - # load kernel page directory - movl %eax, %cr3 - - # set paging enable and protection bit - movl %cr0, %eax - or $0x80000010, %eax - movl %eax, %cr0 - - # jump to kernel code - ljmp $8, $__KERNEL_START - - # loop until the heat death of the universe -loop: - jmp loop