diff --git a/Asuro.iso b/Asuro.iso index 5f70153b..3a0302cf 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/backup/linker.script.old b/backup/linker.script.old new file mode 100644 index 00000000..e0452f1b --- /dev/null +++ b/backup/linker.script.old @@ -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 = .; +} \ No newline at end of file diff --git a/backup/stub.asm.old b/backup/stub.asm.old new file mode 100644 index 00000000..c0701d27 --- /dev/null +++ b/backup/stub.asm.old @@ -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 diff --git a/bin/kernel.bin b/bin/kernel.bin index 50506ce5..ed4a38a4 100755 Binary files a/bin/kernel.bin and b/bin/kernel.bin differ diff --git a/iso/boot/asuro.bin b/iso/boot/asuro.bin index 50506ce5..ed4a38a4 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/bios_data_area.ppu b/lib/bios_data_area.ppu index 526b336e..ddf7d5d4 100644 Binary files a/lib/bios_data_area.ppu and b/lib/bios_data_area.ppu differ diff --git a/lib/console.o b/lib/console.o index 95001e8f..352280ef 100644 Binary files a/lib/console.o and b/lib/console.o differ diff --git a/lib/console.ppu b/lib/console.ppu index 16d5fec2..ba66f862 100644 Binary files a/lib/console.ppu and b/lib/console.ppu differ diff --git a/lib/irq.ppu b/lib/irq.ppu new file mode 100644 index 00000000..a158d4e1 Binary files /dev/null and b/lib/irq.ppu differ diff --git a/lib/isr1.ppu b/lib/isr1.ppu new file mode 100644 index 00000000..34c26278 Binary files /dev/null and b/lib/isr1.ppu differ diff --git a/lib/isr10.ppu b/lib/isr10.ppu new file mode 100644 index 00000000..b0a372df Binary files /dev/null and b/lib/isr10.ppu differ diff --git a/lib/isr11.ppu b/lib/isr11.ppu new file mode 100644 index 00000000..3640c4d9 Binary files /dev/null and b/lib/isr11.ppu differ diff --git a/lib/isr12.ppu b/lib/isr12.ppu new file mode 100644 index 00000000..dde436ef Binary files /dev/null and b/lib/isr12.ppu differ diff --git a/lib/isr13.ppu b/lib/isr13.ppu new file mode 100644 index 00000000..beca2174 Binary files /dev/null and b/lib/isr13.ppu differ diff --git a/lib/isr14.ppu b/lib/isr14.ppu new file mode 100644 index 00000000..6014de14 Binary files /dev/null and b/lib/isr14.ppu differ diff --git a/lib/isr15.ppu b/lib/isr15.ppu new file mode 100644 index 00000000..91f6247f Binary files /dev/null and b/lib/isr15.ppu differ diff --git a/lib/isr16.ppu b/lib/isr16.ppu new file mode 100644 index 00000000..2f4823ca Binary files /dev/null and b/lib/isr16.ppu differ diff --git a/lib/isr17.ppu b/lib/isr17.ppu new file mode 100644 index 00000000..e57f3268 Binary files /dev/null and b/lib/isr17.ppu differ diff --git a/lib/isr18.ppu b/lib/isr18.ppu new file mode 100644 index 00000000..562a61be Binary files /dev/null and b/lib/isr18.ppu differ diff --git a/lib/isr2.ppu b/lib/isr2.ppu new file mode 100644 index 00000000..dd2e79f6 Binary files /dev/null and b/lib/isr2.ppu differ diff --git a/lib/isr3.ppu b/lib/isr3.ppu new file mode 100644 index 00000000..0662ba7b Binary files /dev/null and b/lib/isr3.ppu differ diff --git a/lib/isr32.ppu b/lib/isr32.ppu new file mode 100644 index 00000000..ea26acca Binary files /dev/null and b/lib/isr32.ppu differ diff --git a/lib/isr33.ppu b/lib/isr33.ppu new file mode 100644 index 00000000..6f90486c Binary files /dev/null and b/lib/isr33.ppu differ diff --git a/lib/isr4.ppu b/lib/isr4.ppu new file mode 100644 index 00000000..320bbaad Binary files /dev/null and b/lib/isr4.ppu differ diff --git a/lib/isr40.ppu b/lib/isr40.ppu new file mode 100644 index 00000000..de168b9d Binary files /dev/null and b/lib/isr40.ppu differ diff --git a/lib/isr5.ppu b/lib/isr5.ppu new file mode 100644 index 00000000..b516d95f Binary files /dev/null and b/lib/isr5.ppu differ diff --git a/lib/isr6.ppu b/lib/isr6.ppu new file mode 100644 index 00000000..0b479177 Binary files /dev/null and b/lib/isr6.ppu differ diff --git a/lib/isr7.ppu b/lib/isr7.ppu new file mode 100644 index 00000000..f8876b25 Binary files /dev/null and b/lib/isr7.ppu differ diff --git a/lib/isr8.ppu b/lib/isr8.ppu new file mode 100644 index 00000000..069e94de Binary files /dev/null and b/lib/isr8.ppu differ diff --git a/lib/isr9.ppu b/lib/isr9.ppu new file mode 100644 index 00000000..695efec2 Binary files /dev/null and b/lib/isr9.ppu differ diff --git a/lib/isr_types.ppu b/lib/isr_types.ppu new file mode 100644 index 00000000..2ce65563 Binary files /dev/null and b/lib/isr_types.ppu differ diff --git a/lib/kernel.o b/lib/kernel.o index c27a5e71..73cab552 100644 Binary files a/lib/kernel.o and b/lib/kernel.o differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index 174b383f..55da24e4 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index b2cda7c3..8da7b19d 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpkernel.a b/lib/libpkernel.a index 919cd91a..c79e568b 100644 Binary files a/lib/libpkernel.a and b/lib/libpkernel.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index 1ed6cff2..11780910 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index 1b50e08f..8258f299 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/lib/stub.o b/lib/stub.o index d0c5e39e..0ec3473e 100644 Binary files a/lib/stub.o and b/lib/stub.o differ diff --git a/linker.script b/linker.script index e0452f1b..27f26c99 100644 --- a/linker.script +++ b/linker.script @@ -1,13 +1,16 @@ -ENTRY(kstart) +ENTRY(loader) SECTIONS { - .text 0x100000 : + . = 0xC0100000; + + .text : AT(ADDR(.text) - 0xC0000000) { text = .; _text = .; __text = .; *(.text) + *(.rodata*) . = ALIGN(4096); } - .data : + .data : AT(ADDR(.data) - 0xC0000000) { data = .; _data = .; __data = .; *(.data) @@ -21,11 +24,13 @@ SECTIONS LONG(end); . = ALIGN(4096); } - .bss : + .bss : AT(ADDR(.bss) - 0xC0000000) { - bss = .; _bss = .; __bss = .; + bss = .; _bss = .; __bss = .; _sbss = .; + *(COMMON) *(.bss) + _ebbbss = .; . = ALIGN(4096); } end = .; _end = .; __end = .; -} \ No newline at end of file +} diff --git a/src/bios_data_area.pas b/src/bios_data_area.pas index 0e933a76..f8486500 100644 --- a/src/bios_data_area.pas +++ b/src/bios_data_area.pas @@ -36,7 +36,7 @@ type PBDA = ^TBDA; const - BDA : PBDA = PBDA($0400); + BDA : PBDA = PBDA($C0000400); procedure tick_update(data : void); diff --git a/src/console.pas b/src/console.pas index 9a4b3406..993440c7 100644 --- a/src/console.pas +++ b/src/console.pas @@ -97,8 +97,8 @@ type var Console_Properties : TConsoleProperties; - Console_Memory : PVideoMemory = PVideoMemory($b8000); - Console_Matrix : P2DVideoMemory = P2DVideoMemory($b8000); + Console_Memory : PVideoMemory = PVideoMemory($C00b8000); + Console_Matrix : P2DVideoMemory = P2DVideoMemory($C00b8000); Console_Cursor : TCoord; procedure init(); [public, alias: 'console_init']; diff --git a/src/kernel.pas b/src/kernel.pas index 854ad05d..546971aa 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -20,9 +20,9 @@ implementation procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain']; var - c : uint8; - mbi : Pmultiboot_info_t; - mbm : uint32; + c : uint8; + mbi : Pmultiboot_info_t; + mbm : uint32; z : uint32; dds : uint32; @@ -46,9 +46,7 @@ begin irq.init(); STI; - isr32.hook(uint32(@bios_data_area.tick_update)); - console.debug:= true; asm @@ -62,6 +60,7 @@ begin console.setdefaultattribute(console.combinecolors(Red, Black)); console.writestringln('GDT: LOAD FAIL.'); end; + console.writestringln(''); console.setdefaultattribute(console.combinecolors(Green, Black)); console.writestringln('Asuro Booted Correctly!'); @@ -76,6 +75,7 @@ begin console.writestring('Total Memory = '); console.writeint(((mbinfo^.mem_upper + 1000) div 1024) +1); console.writestringln('MB'); + while(true)do begin end; console.setdefaultattribute(console.combinecolors(lYellow, Black)); util.halt_and_dont_catch_fire; diff --git a/src/stub/stub.asm b/src/stub/stub.asm index c0701d27..145819c4 100644 --- a/src/stub/stub.asm +++ b/src/stub/stub.asm @@ -10,12 +10,12 @@ ; ; Export entrypoint ; -[global kstart] +global _loader ; ; Import kernel entrypoint ; -[extern kmain] +extern kmain ; ; Posible multiboot header flags @@ -36,9 +36,18 @@ MULTIBOOT_HEADER_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEA ; Kernel stack size ; 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 - ; ; Multiboot header ; @@ -50,16 +59,38 @@ dd MULTIBOOT_HEADER_CHECKSUM ; ; 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: + mov dword [BootPageDirectory], 0 + invlpg [0] + mov esp, KERNEL_STACK+KERNEL_STACKSIZE ;Create kernel stack push eax ;Multiboot magic number + add ebx, KERNEL_VIRTUAL_BASE push ebx ;Multiboot info call kmain ;Call kernel entrypoint cli ;Clear interrupts hlt ;Halt machine section .bss - + ; ; Kernel stack location ;