Made Kernel 'Higher-Half' and enabled paging.

git-svn-id: https://spexeah.com:8443/svn/Asuro@85 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron 2017-05-17 23:24:05 +00:00
parent 7a8034196b
commit 019f6ccabf
43 changed files with 153 additions and 18 deletions

BIN
Asuro.iso

Binary file not shown.

31
backup/linker.script.old Normal file
View File

@ -0,0 +1,31 @@
ENTRY(kstart)
SECTIONS
{
.text 0x100000 :
{
text = .; _text = .; __text = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
kimage_text = .;
LONG(text);
kimage_data = .;
LONG(data);
kimage_bss = .;
LONG(bss);
kimage_end = .;
LONG(end);
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}

68
backup/stub.asm.old Normal file
View File

@ -0,0 +1,68 @@
;
; Kernel stub
;
;
; We are in 32bits protected mode
;
[bits 32]
;
; Export entrypoint
;
[global kstart]
;
; Import kernel entrypoint
;
[extern kmain]
;
; Posible multiboot header flags
;
MULTIBOOT_MODULE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_MAP equ 1<<1
MULTIBOOT_GRAPHICS_FIELDS equ 1<<2
MULTIBOOT_ADDRESS_FIELDS equ 1<<16
;
; Multiboot header defines
;
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_MODULE_ALIGN | MULTIBOOT_MEMORY_MAP
MULTIBOOT_HEADER_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
;
; Kernel stack size
;
KERNEL_STACKSIZE equ 0x4000
section .text
;
; Multiboot header
;
align 4
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_HEADER_CHECKSUM
;
; Entrypoint
;
kstart:
mov esp, KERNEL_STACK+KERNEL_STACKSIZE ;Create kernel stack
push eax ;Multiboot magic number
push ebx ;Multiboot info
call kmain ;Call kernel entrypoint
cli ;Clear interrupts
hlt ;Halt machine
section .bss
;
; Kernel stack location
;
align 32
KERNEL_STACK:
resb KERNEL_STACKSIZE

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/irq.ppu Normal file

Binary file not shown.

BIN
lib/isr1.ppu Normal file

Binary file not shown.

BIN
lib/isr10.ppu Normal file

Binary file not shown.

BIN
lib/isr11.ppu Normal file

Binary file not shown.

BIN
lib/isr12.ppu Normal file

Binary file not shown.

BIN
lib/isr13.ppu Normal file

Binary file not shown.

BIN
lib/isr14.ppu Normal file

Binary file not shown.

BIN
lib/isr15.ppu Normal file

Binary file not shown.

BIN
lib/isr16.ppu Normal file

Binary file not shown.

BIN
lib/isr17.ppu Normal file

Binary file not shown.

BIN
lib/isr18.ppu Normal file

Binary file not shown.

BIN
lib/isr2.ppu Normal file

Binary file not shown.

BIN
lib/isr3.ppu Normal file

Binary file not shown.

BIN
lib/isr32.ppu Normal file

Binary file not shown.

BIN
lib/isr33.ppu Normal file

Binary file not shown.

BIN
lib/isr4.ppu Normal file

Binary file not shown.

BIN
lib/isr40.ppu Normal file

Binary file not shown.

BIN
lib/isr5.ppu Normal file

Binary file not shown.

BIN
lib/isr6.ppu Normal file

Binary file not shown.

BIN
lib/isr7.ppu Normal file

Binary file not shown.

BIN
lib/isr8.ppu Normal file

Binary file not shown.

BIN
lib/isr9.ppu Normal file

Binary file not shown.

BIN
lib/isr_types.ppu Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,13 +1,16 @@
ENTRY(kstart) ENTRY(loader)
SECTIONS SECTIONS
{ {
.text 0x100000 : . = 0xC0100000;
.text : AT(ADDR(.text) - 0xC0000000)
{ {
text = .; _text = .; __text = .; text = .; _text = .; __text = .;
*(.text) *(.text)
*(.rodata*)
. = ALIGN(4096); . = ALIGN(4096);
} }
.data : .data : AT(ADDR(.data) - 0xC0000000)
{ {
data = .; _data = .; __data = .; data = .; _data = .; __data = .;
*(.data) *(.data)
@ -21,10 +24,12 @@ SECTIONS
LONG(end); LONG(end);
. = ALIGN(4096); . = ALIGN(4096);
} }
.bss : .bss : AT(ADDR(.bss) - 0xC0000000)
{ {
bss = .; _bss = .; __bss = .; bss = .; _bss = .; __bss = .; _sbss = .;
*(COMMON)
*(.bss) *(.bss)
_ebbbss = .;
. = ALIGN(4096); . = ALIGN(4096);
} }
end = .; _end = .; __end = .; end = .; _end = .; __end = .;

View File

@ -36,7 +36,7 @@ type
PBDA = ^TBDA; PBDA = ^TBDA;
const const
BDA : PBDA = PBDA($0400); BDA : PBDA = PBDA($C0000400);
procedure tick_update(data : void); procedure tick_update(data : void);

View File

@ -97,8 +97,8 @@ type
var var
Console_Properties : TConsoleProperties; Console_Properties : TConsoleProperties;
Console_Memory : PVideoMemory = PVideoMemory($b8000); Console_Memory : PVideoMemory = PVideoMemory($C00b8000);
Console_Matrix : P2DVideoMemory = P2DVideoMemory($b8000); Console_Matrix : P2DVideoMemory = P2DVideoMemory($C00b8000);
Console_Cursor : TCoord; Console_Cursor : TCoord;
procedure init(); [public, alias: 'console_init']; procedure init(); [public, alias: 'console_init'];

View File

@ -46,9 +46,7 @@ begin
irq.init(); irq.init();
STI; STI;
isr32.hook(uint32(@bios_data_area.tick_update)); isr32.hook(uint32(@bios_data_area.tick_update));
console.debug:= true; console.debug:= true;
asm asm
@ -62,6 +60,7 @@ begin
console.setdefaultattribute(console.combinecolors(Red, Black)); console.setdefaultattribute(console.combinecolors(Red, Black));
console.writestringln('GDT: LOAD FAIL.'); console.writestringln('GDT: LOAD FAIL.');
end; end;
console.writestringln(''); console.writestringln('');
console.setdefaultattribute(console.combinecolors(Green, Black)); console.setdefaultattribute(console.combinecolors(Green, Black));
console.writestringln('Asuro Booted Correctly!'); console.writestringln('Asuro Booted Correctly!');
@ -76,6 +75,7 @@ begin
console.writestring('Total Memory = '); console.writestring('Total Memory = ');
console.writeint(((mbinfo^.mem_upper + 1000) div 1024) +1); console.writeint(((mbinfo^.mem_upper + 1000) div 1024) +1);
console.writestringln('MB'); console.writestringln('MB');
while(true)do begin end;
console.setdefaultattribute(console.combinecolors(lYellow, Black)); console.setdefaultattribute(console.combinecolors(lYellow, Black));
util.halt_and_dont_catch_fire; util.halt_and_dont_catch_fire;

View File

@ -10,12 +10,12 @@
; ;
; Export entrypoint ; Export entrypoint
; ;
[global kstart] global _loader
; ;
; Import kernel entrypoint ; Import kernel entrypoint
; ;
[extern kmain] extern kmain
; ;
; Posible multiboot header flags ; Posible multiboot header flags
@ -36,9 +36,18 @@ MULTIBOOT_HEADER_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEA
; Kernel stack size ; Kernel stack size
; ;
KERNEL_STACKSIZE equ 0x4000 KERNEL_STACKSIZE equ 0x4000
KERNEL_VIRTUAL_BASE equ 0xC0000000
KERNEL_PAGE_NUMBER equ (KERNEL_VIRTUAL_BASE >> 22)
section .data
align 0x1000
BootPageDirectory:
dd 0x00000083
times (KERNEL_PAGE_NUMBER - 1) dd 0
dd 0x00000083
times (1024 - KERNEL_PAGE_NUMBER - 1) dd 0
section .text section .text
; ;
; Multiboot header ; Multiboot header
; ;
@ -50,9 +59,31 @@ dd MULTIBOOT_HEADER_CHECKSUM
; ;
; Entrypoint ; Entrypoint
; ;
loader equ _loader
global loader
_loader:
mov ecx, (BootPageDirectory - KERNEL_VIRTUAL_BASE)
mov cr3, ecx
mov ecx, cr4
or ecx, 0x00000010
mov cr4, ecx
mov ecx, cr0
or ecx, 0x80000000
mov cr0, ecx
lea ecx, [kstart]
jmp ecx
kstart: kstart:
mov dword [BootPageDirectory], 0
invlpg [0]
mov esp, KERNEL_STACK+KERNEL_STACKSIZE ;Create kernel stack mov esp, KERNEL_STACK+KERNEL_STACKSIZE ;Create kernel stack
push eax ;Multiboot magic number push eax ;Multiboot magic number
add ebx, KERNEL_VIRTUAL_BASE
push ebx ;Multiboot info push ebx ;Multiboot info
call kmain ;Call kernel entrypoint call kmain ;Call kernel entrypoint
cli ;Clear interrupts cli ;Clear interrupts