Increase the size of the stack to 16K

This commit is contained in:
Baptiste Wicht 2014-01-02 16:32:46 +01:00
parent 0ba1e62c26
commit c21164d102
5 changed files with 42 additions and 26 deletions

View File

@ -14,9 +14,9 @@ jmp rm_start
; Start in real mode ; Start in real mode
rm_start: rm_start:
; Set stack space (4K) and stack segment ; Set stack space (4K) and stack segment
mov ax, 0x70 xor ax, ax
mov ss, ax mov ss, ax
mov sp, 2048 mov sp, 0x4000
; Set data segment ; Set data segment
mov ax, 0x7C0 mov ax, 0x7C0
@ -90,7 +90,7 @@ rm_start:
; Run the stage 2 ; Run the stage 2
jmp dword 0x90:0x0 jmp dword 0x410:0x0
extensions_not_supported: extensions_not_supported:
mov si, extensions_not_supported_msg mov si, extensions_not_supported_msg
@ -115,7 +115,7 @@ DAP:
.null db 0x0 .null db 0x0
.count dw 2 .count dw 2
.offset dw 0 .offset dw 0
.segment dw 0x90 .segment dw 0x410
.lba dd 1 .lba dd 1
.lba48 dd 0 .lba48 dd 0

View File

@ -12,7 +12,8 @@ jmp second_step
%include "intel_16.asm" %include "intel_16.asm"
%include "sectors.asm" %include "sectors.asm"
KERNEL_BASE equ 0x200 ; 0x200:0x0 = 0x2000 FREE_BASE equ 0x4500
KERNEL_BASE equ 0x600 ; 0x600:0x0 (0x6000)
DAP: DAP:
.size db 0x10 .size db 0x10
@ -23,10 +24,10 @@ DAP:
.lba dd 0 .lba dd 0
.lba48 dd 0 .lba48 dd 0
; Loaded at 0x90:0x0 ; Loaded at 0x410:0x0 (0x4100)
second_step: second_step:
; Set data segment ; Set data segment
mov ax, 0x90 mov ax, 0x410
mov ds, ax mov ds, ax
; Used for disk access ; Used for disk access
@ -39,7 +40,7 @@ second_step:
; 1. Read the MBR to get partition table ; 1. Read the MBR to get partition table
mov byte [DAP.count], 1 mov byte [DAP.count], 1
mov word [DAP.offset], 0x1000 mov word [DAP.offset], FREE_BASE
mov word [DAP.segment], 0 mov word [DAP.segment], 0
mov dword [DAP.lba], 0 mov dword [DAP.lba], 0
@ -50,13 +51,13 @@ second_step:
jc read_failed jc read_failed
mov ax, [gs:(0x1000 + 446 + 8)] mov ax, [gs:(FREE_BASE + 446 + 8)]
mov [partition_start], ax mov [partition_start], ax
; 2. Read the VBR of the partition to get FAT informations ; 2. Read the VBR of the partition to get FAT informations
mov byte [DAP.count], 1 mov byte [DAP.count], 1
mov word [DAP.offset], 0x1000 mov word [DAP.offset], FREE_BASE
mov word [DAP.segment], 0 mov word [DAP.segment], 0
mov di, [partition_start] mov di, [partition_start]
@ -69,19 +70,19 @@ second_step:
jc read_failed jc read_failed
mov ah, [gs:(0x1000 + 13)] mov ah, [gs:(FREE_BASE + 13)]
mov [sectors_per_cluster], ah mov [sectors_per_cluster], ah
mov ax, [gs:(0x1000 + 14)] mov ax, [gs:(FREE_BASE + 14)]
mov [reserved_sectors], ax mov [reserved_sectors], ax
mov ah, [gs:(0x1000 + 16)] mov ah, [gs:(FREE_BASE + 16)]
mov [number_of_fat], ah mov [number_of_fat], ah
mov ax, [gs:(0x1000 + 36)] mov ax, [gs:(FREE_BASE + 36)]
mov [sectors_per_fat], ax mov [sectors_per_fat], ax
mov ax, [gs:(0x1000 + 44)] mov ax, [gs:(FREE_BASE + 44)]
mov [root_dir_start], ax mov [root_dir_start], ax
; fat_begin = partition_start + reserved_sectors ; fat_begin = partition_start + reserved_sectors
@ -108,7 +109,7 @@ second_step:
mov ah, [sectors_per_cluster] mov ah, [sectors_per_cluster]
mov byte [DAP.count], ah mov byte [DAP.count], ah
mov word [DAP.offset], 0x1000 mov word [DAP.offset], FREE_BASE
mov word [DAP.segment], 0 mov word [DAP.segment], 0
; Compute LBA from root_dir_start ; Compute LBA from root_dir_start
@ -128,7 +129,7 @@ second_step:
jc read_failed jc read_failed
mov si, 0x1000 mov si, FREE_BASE
xor cx, cx xor cx, cx
.next: .next:
@ -265,7 +266,7 @@ second_step:
; Read the FAT sector ; Read the FAT sector
mov word [DAP.count], 1 mov word [DAP.count], 1
mov word [DAP.offset], 0x100 mov word [DAP.offset], FREE_BASE
mov word [DAP.segment], 0x0 mov word [DAP.segment], 0x0
mov word [DAP.lba], ax mov word [DAP.lba], ax
@ -281,9 +282,9 @@ second_step:
shl si, 2 shl si, 2
; cluster low ; cluster low
mov ax, [gs:(0x100 + si)] mov ax, [gs:(FREE_BASE + si)]
; cluster high ; cluster high
mov bx, [gs:(0x100 + si + 2)] mov bx, [gs:(FREE_BASE + si + 2)]
cmp bx, 0x0FFF cmp bx, 0x0FFF
jl .ok jl .ok

View File

@ -2,14 +2,29 @@ ENTRY(kernel_main)
SECTIONS SECTIONS
{ {
/* This is where the micro kernel will load the code */ /* This is where the bootloader will load the code */
. = 0x2000; . = 0x6000;
.text_16 BLOCK(512) : ALIGN(512) .text_16 BLOCK(512) : ALIGN(512)
{ {
boot_16_64.o(.text) boot_16_64.o(.text)
} }
.rodata_16 BLOCK(512) : ALIGN(512)
{
boot_16_64.o(.rodata)
}
.bss_16 BLOCK(512) : ALIGN(512)
{
boot_16_64.o(.bss)
}
.data_16 BLOCK(512) : ALIGN(512)
{
boot_16_64.o(.data)
}
.text_32 BLOCK(512) : ALIGN(512) .text_32 BLOCK(512) : ALIGN(512)
{ {
boot_32_64.o(.text) boot_32_64.o(.text)

View File

@ -31,6 +31,10 @@ typedef uint64_t size_t;
#define CODE_16 #define CODE_16
#include "e820.hpp" //Just for the address of the e820 map #include "e820.hpp" //Just for the address of the e820 map
e820::bios_e820_entry e820::bios_e820_entries[e820::MAX_E820_ENTRIES];
int16_t e820::bios_e820_entry_count = 0;
namespace { namespace {
struct gdt_ptr { struct gdt_ptr {

View File

@ -7,10 +7,6 @@
#include "e820.hpp" #include "e820.hpp"
e820::bios_e820_entry e820::bios_e820_entries[e820::MAX_E820_ENTRIES];
int16_t e820::bios_e820_entry_count = 0;
namespace { namespace {
e820::mmapentry e820_mmap[e820::MAX_E820_ENTRIES]; e820::mmapentry e820_mmap[e820::MAX_E820_ENTRIES];