Fixed line endings

This commit is contained in:
2021-06-22 23:57:27 +01:00
parent 1e64931ec2
commit d4ea9c52ff
145 changed files with 33869 additions and 33869 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +1,89 @@
// Copyright 2021 Kieron Morris
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Include->Multiboot - Multiboot Structures & Access.
@author(Kieron Morris <kjm@kieronmorris.me>)
}
unit multiboot;
interface
const
KERNEL_STACKSIZE = $4000;
MULTIBOOT_BOOTLOADER_MAGIC = $2BADB002;
type
Pelf_section_header_table_t = ^elf_section_header_table_t;
elf_section_header_table_t = packed record
num: uint32;
size: uint32;
addr: uint32;
shndx: uint32;
end;
Pmultiboot_info_t = ^multiboot_info_t;
multiboot_info_t = packed record
flags: uint32;
mem_lower: uint32;
mem_upper: uint32;
boot_device: uint32;
cmdline: uint32;
mods_count: uint32;
mods_addr: uint32;
elf_sec: elf_section_header_table_t;
mmap_length: uint32;
mmap_addr: uint32;
drives_legnth : uint32;
drives_addr: uint32;
config_table : uint32;
boot_loader_name : uint32;
apm_table: uint32;
vbe_control_info : uint32;
vbe_mode_info : uint32;
vbe_mode : uint16;
vbe_interface_seg : uint16;
vbe_interface_off : uint16;
vbe_interface_len : uint16;
framebuffer_addr : uint64;
framebuffer_pitch : uint32;
framebuffer_width : uint32;
framebuffer_height: uint32;
framebuffer_bpp : uint8;
end;
Pmodule_t = ^module_t;
module_t = packed record
mod_start: uint32;
mod_end: uint32;
name: uint32;
reserved: uint32;
end;
Pmemory_map_t = ^memory_map_t;
memory_map_t = packed record
size: uint32;
base_addr : uint64;
length : uint64;
mtype: uint32;
end;
var
multibootinfo : Pmultiboot_info_t = nil;
multibootmagic : uint32;
implementation
end.
// Copyright 2021 Kieron Morris
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Include->Multiboot - Multiboot Structures & Access.
@author(Kieron Morris <kjm@kieronmorris.me>)
}
unit multiboot;
interface
const
KERNEL_STACKSIZE = $4000;
MULTIBOOT_BOOTLOADER_MAGIC = $2BADB002;
type
Pelf_section_header_table_t = ^elf_section_header_table_t;
elf_section_header_table_t = packed record
num: uint32;
size: uint32;
addr: uint32;
shndx: uint32;
end;
Pmultiboot_info_t = ^multiboot_info_t;
multiboot_info_t = packed record
flags: uint32;
mem_lower: uint32;
mem_upper: uint32;
boot_device: uint32;
cmdline: uint32;
mods_count: uint32;
mods_addr: uint32;
elf_sec: elf_section_header_table_t;
mmap_length: uint32;
mmap_addr: uint32;
drives_legnth : uint32;
drives_addr: uint32;
config_table : uint32;
boot_loader_name : uint32;
apm_table: uint32;
vbe_control_info : uint32;
vbe_mode_info : uint32;
vbe_mode : uint16;
vbe_interface_seg : uint16;
vbe_interface_off : uint16;
vbe_interface_len : uint16;
framebuffer_addr : uint64;
framebuffer_pitch : uint32;
framebuffer_width : uint32;
framebuffer_height: uint32;
framebuffer_bpp : uint8;
end;
Pmodule_t = ^module_t;
module_t = packed record
mod_start: uint32;
mod_end: uint32;
name: uint32;
reserved: uint32;
end;
Pmemory_map_t = ^memory_map_t;
memory_map_t = packed record
size: uint32;
base_addr : uint64;
length : uint64;
mtype: uint32;
end;
var
multibootinfo : Pmultiboot_info_t = nil;
multibootmagic : uint32;
implementation
end.

View File

@ -1,270 +1,270 @@
// Copyright 2021 Kieron Morris & Aaron Hance
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Kernel Main - Main Kernel Entry Point.
@author(Kieron Morris <kjm@kieronmorris.me>)
@author(Aaron Hance <ah@aaronhance.me>)
}
unit kernel;
interface
uses
multiboot, bios_data_area,
util,
gdt, idt, isr, irq, tss,
TMR_0_ISR,
console,
keyboard, mouse,
vmemorymanager, pmemorymanager, lmemorymanager,
tracer,
drivermanagement,
scheduler,
progmanager,
PCI,
strings,
USB,
testdriver,
E1000,
IDE,
storagemanagement,
lists,
net,
fat32,
isrmanager,
faults,
fonts,
RTC,
serial,
cpu,
md5,
base64,
rand,
terminal,
hashmap, vfs;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
implementation
procedure terminal_command_meminfo(params : PParamList);
begin
push_trace('kernel.terminal_command_meminfo');
console.writestringWND('Lower Memory = ', getTerminalHWND);
console.writeintWND(multibootinfo^.mem_lower, getTerminalHWND);
console.writestringlnWND('KB', getTerminalHWND);
console.writestringWND('Higher Memory = ', getTerminalHWND);
console.writeintWND(multibootinfo^.mem_upper, getTerminalHWND);
console.writestringlnWND('KB', getTerminalHWND);
console.writestringWND('Total Memory = ', getTerminalHWND);
console.writeintWND(((multibootinfo^.mem_upper + 1000) div 1024) + 1, getTerminalHWND);
console.writestringlnWND('MB', getTerminalHWND);
pop_trace;
end;
procedure terminal_command_bsod(params : PParamList);
begin
push_trace('kernel.terminal_command_bsod');
if ParamCount(params) > 1 then begin
bsod(getparam(0, params), getparam(1, params));
end else begin
console.writestringlnWND('Invalid number of params.', getTerminalHWND);
console.writestringlnWND('Usage: bsod <error> <info>', getTerminalHWND);
end;
pop_trace;
end;
procedure myUserLandFunction;
var
i : uint32;
begin
i:=0;
while true do begin
i:=i+1;
asm
MOV EAX, i
end;
end;
end;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain'];
var
c : uint8;
z : uint32;
dds : uint32;
pint : puint32;
pint2 : puint32;
keyboard_layout : array [0..1] of TKeyInfo;
i : uint32;
cEIP : uint32;
temp : uint32;
atmp : puint32;
test : puint8;
fb : puint16;
l : PLinkedListBase;
ulf : pointer;
HM : PHashMap;
begin
{ Serial Init }
serial.init();
{ Store Multiboot info }
multibootinfo:= mbinfo;
multibootmagic:= mbmagic;
{ Ensure tracer is frozen }
tracer.freeze();
{ Terminal Init }
terminal.init();
terminal.registerCommand('MEMINFO', @terminal_command_meminfo, 'Print Simple Memory Information.');
terminal.registerCommand('BSOD', @terminal_command_bsod, 'Force a Panic Screen.');
console.writestringln('Booting Asuro...');
console.writestringln('Checking for Multiboot Compliance');
{ Check for Multiboot }
if (multibootmagic <> MULTIBOOT_BOOTLOADER_MAGIC) then begin
console.setdefaultattribute(console.combinecolors($F800, $0000));
console.outputln('KERNEL', 'Multiboot Compliant Boot-Loader Needed!');
console.outputln('KERNEL', 'HALTING.');
BSOD('Multiboot Error', 'Multiboot Compliant Boot-Loader Needed!');
util.halt_and_catch_fire;
end;
{ GDT Init }
gdt.init();
asm
MOV dds, CS
end;
if dds = $08 then begin
console.outputln('KERNEL', 'GDT: LOAD SUCCESS.');
end else begin
console.outputln('KERNEL', 'GDT: LOAD FAIL.');
console.outputln('KERNEL', 'HALTING.');
BSOD('GDT', 'Failed to load the GDT correctly.');
end;
console.output('MULTIBOOT', 'Assigned Framebuffer: ');
console.writehexln(multibootinfo^.framebuffer_addr);
console.output('MULTIBOOT', 'Assigned Framebuffer Metrics: ');
console.writeint(multibootinfo^.framebuffer_width);
console.writestring('x');
console.writeint(multibootinfo^.framebuffer_height);
console.writestring('x');
console.writeintln(multibootinfo^.framebuffer_bpp);
{ Memory/CPU Init }
idt.init();
irq.init();
isrmanager.init();
faults.init();
RTC.init();
pmemorymanager.init();
vmemorymanager.init();
lmemorymanager.init();
tss.init();
scheduler.init();
{ Console Init }
console.init();
{ CPUID }
console.outputln('CPU', 'Init begin');
cpu.init();
console.outputln('CPU', 'Init end');
{ Call Tracer }
tracer.init();
{ VFS Init }
vfs.init();
{ Management Interfaces }
tracer.push_trace('kmain.DRVMGMT');
drivermanagement.init();
tracer.push_trace('kmain.STRMGMT');
storagemanagement.init();
{ Hook Timer for Ticks }
tracer.push_trace('kmain.TMR');
STI;
TMR_0_ISR.hook(uint32(@bios_data_area.tick_update));
{ Filsystems }
fat32.init();
{ Device Drivers }
tracer.push_trace('kmain.DEVDRV');
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT BEGIN.');
keyboard.init(keyboard_layout);
mouse.init();
testdriver.init();
E1000.init();
IDE.init();
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT END.');
{ Bus Drivers }
tracer.push_trace('kmain.BUSDRV');
console.outputln('KERNEL', 'BUS DRIVERS: INIT BEGIN.');
USB.init();
pci.init();
console.outputln('KERNEL', 'BUS DRIVERS: INIT END.');
{ Network Stack }
tracer.push_trace('kmain.NETDRV');
net.init;
tracer.push_trace('kmain.VMINIT');
//vm.init();
{ Init Progs }
progmanager.init();
{ Init Splash }
//tracer.push_trace('kmain.SPLASHINIT');
//splash.init();
{ End of Boot }
tracer.push_trace('kmain.EOB');
console.writestringln('');
console.setdefaultattribute(console.combinecolors($17E0, $0000));
console.writestringln('Asuro Booted Correctly!');
console.setdefaultattribute(console.combinecolors($FFFF, $0000));
writestringln(' ');
tracer.push_trace('kmain.END');
rand.srand((getDateTime.Seconds SHL 24) OR (getDateTime.Minutes SHL 16) OR (getDateTime.Hours SHL 8) OR (getDateTime.Day));
tracer.push_trace('kmain.TICK');
while true do begin
tracer.push_trace('kmain.RedrawWindows');
console.redrawWindows;
end;
end;
end.
// Copyright 2021 Kieron Morris & Aaron Hance
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Kernel Main - Main Kernel Entry Point.
@author(Kieron Morris <kjm@kieronmorris.me>)
@author(Aaron Hance <ah@aaronhance.me>)
}
unit kernel;
interface
uses
multiboot, bios_data_area,
util,
gdt, idt, isr, irq, tss,
TMR_0_ISR,
console,
keyboard, mouse,
vmemorymanager, pmemorymanager, lmemorymanager,
tracer,
drivermanagement,
scheduler,
progmanager,
PCI,
strings,
USB,
testdriver,
E1000,
IDE,
storagemanagement,
lists,
net,
fat32,
isrmanager,
faults,
fonts,
RTC,
serial,
cpu,
md5,
base64,
rand,
terminal,
hashmap, vfs;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
implementation
procedure terminal_command_meminfo(params : PParamList);
begin
push_trace('kernel.terminal_command_meminfo');
console.writestringWND('Lower Memory = ', getTerminalHWND);
console.writeintWND(multibootinfo^.mem_lower, getTerminalHWND);
console.writestringlnWND('KB', getTerminalHWND);
console.writestringWND('Higher Memory = ', getTerminalHWND);
console.writeintWND(multibootinfo^.mem_upper, getTerminalHWND);
console.writestringlnWND('KB', getTerminalHWND);
console.writestringWND('Total Memory = ', getTerminalHWND);
console.writeintWND(((multibootinfo^.mem_upper + 1000) div 1024) + 1, getTerminalHWND);
console.writestringlnWND('MB', getTerminalHWND);
pop_trace;
end;
procedure terminal_command_bsod(params : PParamList);
begin
push_trace('kernel.terminal_command_bsod');
if ParamCount(params) > 1 then begin
bsod(getparam(0, params), getparam(1, params));
end else begin
console.writestringlnWND('Invalid number of params.', getTerminalHWND);
console.writestringlnWND('Usage: bsod <error> <info>', getTerminalHWND);
end;
pop_trace;
end;
procedure myUserLandFunction;
var
i : uint32;
begin
i:=0;
while true do begin
i:=i+1;
asm
MOV EAX, i
end;
end;
end;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain'];
var
c : uint8;
z : uint32;
dds : uint32;
pint : puint32;
pint2 : puint32;
keyboard_layout : array [0..1] of TKeyInfo;
i : uint32;
cEIP : uint32;
temp : uint32;
atmp : puint32;
test : puint8;
fb : puint16;
l : PLinkedListBase;
ulf : pointer;
HM : PHashMap;
begin
{ Serial Init }
serial.init();
{ Store Multiboot info }
multibootinfo:= mbinfo;
multibootmagic:= mbmagic;
{ Ensure tracer is frozen }
tracer.freeze();
{ Terminal Init }
terminal.init();
terminal.registerCommand('MEMINFO', @terminal_command_meminfo, 'Print Simple Memory Information.');
terminal.registerCommand('BSOD', @terminal_command_bsod, 'Force a Panic Screen.');
console.writestringln('Booting Asuro...');
console.writestringln('Checking for Multiboot Compliance');
{ Check for Multiboot }
if (multibootmagic <> MULTIBOOT_BOOTLOADER_MAGIC) then begin
console.setdefaultattribute(console.combinecolors($F800, $0000));
console.outputln('KERNEL', 'Multiboot Compliant Boot-Loader Needed!');
console.outputln('KERNEL', 'HALTING.');
BSOD('Multiboot Error', 'Multiboot Compliant Boot-Loader Needed!');
util.halt_and_catch_fire;
end;
{ GDT Init }
gdt.init();
asm
MOV dds, CS
end;
if dds = $08 then begin
console.outputln('KERNEL', 'GDT: LOAD SUCCESS.');
end else begin
console.outputln('KERNEL', 'GDT: LOAD FAIL.');
console.outputln('KERNEL', 'HALTING.');
BSOD('GDT', 'Failed to load the GDT correctly.');
end;
console.output('MULTIBOOT', 'Assigned Framebuffer: ');
console.writehexln(multibootinfo^.framebuffer_addr);
console.output('MULTIBOOT', 'Assigned Framebuffer Metrics: ');
console.writeint(multibootinfo^.framebuffer_width);
console.writestring('x');
console.writeint(multibootinfo^.framebuffer_height);
console.writestring('x');
console.writeintln(multibootinfo^.framebuffer_bpp);
{ Memory/CPU Init }
idt.init();
irq.init();
isrmanager.init();
faults.init();
RTC.init();
pmemorymanager.init();
vmemorymanager.init();
lmemorymanager.init();
tss.init();
scheduler.init();
{ Console Init }
console.init();
{ CPUID }
console.outputln('CPU', 'Init begin');
cpu.init();
console.outputln('CPU', 'Init end');
{ Call Tracer }
tracer.init();
{ VFS Init }
vfs.init();
{ Management Interfaces }
tracer.push_trace('kmain.DRVMGMT');
drivermanagement.init();
tracer.push_trace('kmain.STRMGMT');
storagemanagement.init();
{ Hook Timer for Ticks }
tracer.push_trace('kmain.TMR');
STI;
TMR_0_ISR.hook(uint32(@bios_data_area.tick_update));
{ Filsystems }
fat32.init();
{ Device Drivers }
tracer.push_trace('kmain.DEVDRV');
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT BEGIN.');
keyboard.init(keyboard_layout);
mouse.init();
testdriver.init();
E1000.init();
IDE.init();
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT END.');
{ Bus Drivers }
tracer.push_trace('kmain.BUSDRV');
console.outputln('KERNEL', 'BUS DRIVERS: INIT BEGIN.');
USB.init();
pci.init();
console.outputln('KERNEL', 'BUS DRIVERS: INIT END.');
{ Network Stack }
tracer.push_trace('kmain.NETDRV');
net.init;
tracer.push_trace('kmain.VMINIT');
//vm.init();
{ Init Progs }
progmanager.init();
{ Init Splash }
//tracer.push_trace('kmain.SPLASHINIT');
//splash.init();
{ End of Boot }
tracer.push_trace('kmain.EOB');
console.writestringln('');
console.setdefaultattribute(console.combinecolors($17E0, $0000));
console.writestringln('Asuro Booted Correctly!');
console.setdefaultattribute(console.combinecolors($FFFF, $0000));
writestringln(' ');
tracer.push_trace('kmain.END');
rand.srand((getDateTime.Seconds SHL 24) OR (getDateTime.Minutes SHL 16) OR (getDateTime.Hours SHL 8) OR (getDateTime.Day));
tracer.push_trace('kmain.TICK');
while true do begin
tracer.push_trace('kmain.RedrawWindows');
console.redrawWindows;
end;
end;
end.

View File

@ -1,125 +1,125 @@
; Copyright 2021 Kieron Morris
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; Kernel stub
;
;
; We are in 32bits protected mode
;
[bits 32]
;
; Export entrypoint
;
global _loader
;
; 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_GRAPHICS_FIELDS
MULTIBOOT_HEADER_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
;
; Kernel stack size
;
KERNEL_STACKSIZE equ 0x4000
KERNEL_VIRTUAL_BASE equ 0xC0000000
KERNEL_PAGE_NUMBER equ (KERNEL_VIRTUAL_BASE >> 22)
section .data
align 0x1000
_PageDirectory equ BootPageDirectory
global _PageDirectory
BootPageDirectory:
dd 0x00000083
times (KERNEL_PAGE_NUMBER - 1) dd 0
dd 0x00000083
times (1024 - KERNEL_PAGE_NUMBER - 1) dd 0
section .text
;
; Multiboot header
;
align 4
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_HEADER_CHECKSUM
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 1280
dd 1024
dd 16
;
; Entrypoint
;
loader equ _loader
;loader equ (_loader - 0xC0000000)
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
;
align 32
global KERNEL_STACK
KERNEL_STACK:
resb KERNEL_STACKSIZE
; Copyright 2021 Kieron Morris
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; Kernel stub
;
;
; We are in 32bits protected mode
;
[bits 32]
;
; Export entrypoint
;
global _loader
;
; 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_GRAPHICS_FIELDS
MULTIBOOT_HEADER_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
;
; Kernel stack size
;
KERNEL_STACKSIZE equ 0x4000
KERNEL_VIRTUAL_BASE equ 0xC0000000
KERNEL_PAGE_NUMBER equ (KERNEL_VIRTUAL_BASE >> 22)
section .data
align 0x1000
_PageDirectory equ BootPageDirectory
global _PageDirectory
BootPageDirectory:
dd 0x00000083
times (KERNEL_PAGE_NUMBER - 1) dd 0
dd 0x00000083
times (1024 - KERNEL_PAGE_NUMBER - 1) dd 0
section .text
;
; Multiboot header
;
align 4
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_HEADER_CHECKSUM
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 1280
dd 1024
dd 16
;
; Entrypoint
;
loader equ _loader
;loader equ (_loader - 0xC0000000)
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
;
align 32
global KERNEL_STACK
KERNEL_STACK:
resb KERNEL_STACKSIZE