refactor: namespace restructure of entire codebase
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Reorganize all source files into a hierarchical namespace structure with dot-separated unit names matching directory paths. Major changes: - src/prog/ -> src/app/ (app.*.pas) - src/fault/ -> src/arch/x86/fault/ (arch.x86.fault.*.pas) - src/isr/ -> src/arch/x86/isr/ (arch.x86.isr.*.pas) - src/include/ -> src/core/ (core.*.pas) + src/arch/x86/ - src/driver/ subtree reorganized with driver.* namespace prefixes - src/driver/storage/con/ -> src/driver/storage/ctl/ (Windows reserved name fix) - src/driver/storage/ split into con(ctl)/fs/vol/ subdirectories - src/driver/net/ flattened from l1-l5 layers to driver.net.*.pas - kernel.pas -> asuro.pas, faults.pas -> arch.x86.faults.pas - stdio.pas/syslog.pas -> io/io.stdio.pas, io/io.syslog.pas - processmanager.pas -> proc/proc.mgr.pas - lmemorymanager.pas -> memory/memory.heap.pas - Build scripts moved to toolchain/ - Added compat/ shims for lmemorymanager and types - Added doc/namespace.md tracking the refactor 197 files changed, 6292 insertions(+), 5526 deletions(-)
This commit is contained in:
1 parent
e922f086c2
commit
6fa008ed79
197 files changed
+6291
-5525
No files matched your search
@@ -0,0 +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->BIOS_Data_Area - Data Structures Controlled by the BIOS.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.bda;
|
||||
|
||||
interface
|
||||
|
||||
type
|
||||
TBDA = bitpacked record
|
||||
COM1 : uint16;
|
||||
COM2 : uint16;
|
||||
COM3 : uint16;
|
||||
COM4 : uint16;
|
||||
LPT1 : uint16;
|
||||
LPT2 : uint16;
|
||||
LPT3 : uint16;
|
||||
EBDA : uint16;
|
||||
Hardware_Flags : uint16;
|
||||
Keyboard_Flags : uint16;
|
||||
Keyboard_Buffer : ARRAY[0..31] OF uint8;
|
||||
Display_Mode : uint8;
|
||||
BaseIO : uint16;
|
||||
Ticks : uint16;
|
||||
HDD_Count : uint8;
|
||||
Keyboard_Start : uint16;
|
||||
Keyboard_End : uint16;
|
||||
Keyboard_State : uint8;
|
||||
end;
|
||||
PBDA = ^TBDA;
|
||||
|
||||
TMCFG = bitpacked record
|
||||
Signature : Array[0..3] of Char;
|
||||
Table_Length : uint32;
|
||||
Revision : Byte;
|
||||
Checksum : Byte;
|
||||
OEM_ID : Array[0..5] of Byte;
|
||||
OEM_Table_ID : uint64;
|
||||
OEM_Revision : uint32;
|
||||
Creator_ID : uint32;
|
||||
Creator_Revision : uint32;
|
||||
Reserved : uint64;
|
||||
end;
|
||||
PMCFG = ^TMCFG;
|
||||
|
||||
TCounters = record
|
||||
c16 : uint16;
|
||||
c32 : uint32;
|
||||
c64 : uint64;
|
||||
end;
|
||||
|
||||
const
|
||||
BDA : PBDA = PBDA($C0000400);
|
||||
|
||||
var
|
||||
Counters : TCounters;
|
||||
|
||||
procedure tick_update(data : void);
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
arch.x86.memory.virtual;
|
||||
|
||||
procedure tick_update(data : void);
|
||||
begin
|
||||
//BDA^.Ticks:= BDA^.Ticks + 1;
|
||||
inc(BDA^.Ticks);
|
||||
inc(Counters.c16);
|
||||
inc(Counters.c32);
|
||||
inc(Counters.c64);
|
||||
end;
|
||||
|
||||
end.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,55 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Faults - Fault Registration & Detouring.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.faults;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
arch.x86.fault.ace, arch.x86.fault.bpe, arch.x86.fault.btsse, arch.x86.fault.cfe, arch.x86.fault.csoe, arch.x86.fault.dbge, arch.x86.fault.dbz, arch.x86.fault.dfe, arch.x86.fault.gpf, arch.x86.fault.idoe, arch.x86.fault.iope, arch.x86.fault.mce,
|
||||
arch.x86.fault.nce, arch.x86.fault.nmie, arch.x86.fault.oobe, arch.x86.fault.pf, arch.x86.fault.sfe, arch.x86.fault.snpe, arch.x86.fault.uie;
|
||||
|
||||
procedure init;
|
||||
|
||||
implementation
|
||||
|
||||
procedure init;
|
||||
begin
|
||||
arch.x86.fault.ace.register();
|
||||
arch.x86.fault.bpe.register();
|
||||
arch.x86.fault.btsse.register();
|
||||
arch.x86.fault.cfe.register();
|
||||
arch.x86.fault.csoe.register();
|
||||
arch.x86.fault.dbge.register();
|
||||
arch.x86.fault.dbz.register();
|
||||
arch.x86.fault.dfe.register();
|
||||
arch.x86.fault.gpf.register();
|
||||
arch.x86.fault.idoe.register();
|
||||
arch.x86.fault.iope.register();
|
||||
arch.x86.fault.mce.register();
|
||||
arch.x86.fault.nce.register();
|
||||
arch.x86.fault.nmie.register();
|
||||
arch.x86.fault.oobe.register();
|
||||
arch.x86.fault.pf.register();
|
||||
arch.x86.fault.sfe.register();
|
||||
arch.x86.fault.snpe.register();
|
||||
arch.x86.fault.uie.register();
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,122 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Global Descriptor Table - Data Structures & Interface.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.gdt;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
io.syslog;
|
||||
|
||||
type
|
||||
TGDT_Entry = packed record
|
||||
limit_low : uint16;
|
||||
base_low : uint16;
|
||||
base_middle : uint8;
|
||||
access : uint8;
|
||||
granularity : uint8;
|
||||
base_high : uint8;
|
||||
end;
|
||||
PGDT_Entry = ^TGDT_Entry;
|
||||
|
||||
TGDT_Pointer = packed record
|
||||
limit : uint16;
|
||||
base : uint32;
|
||||
end;
|
||||
|
||||
var
|
||||
gdt_entries : array[0..1023] of TGDT_Entry;
|
||||
gdt_pointer : TGDT_Pointer;
|
||||
|
||||
procedure init();
|
||||
procedure set_gate(Gate_Number : uint32; Base : uint32; Limit : uint32; Access : uint8; Granularity : uint8);
|
||||
procedure flush;
|
||||
procedure reload;
|
||||
|
||||
implementation
|
||||
|
||||
procedure flush_gdt(gdt_pointer : uint32); assembler; nostackframe;
|
||||
asm
|
||||
MOV EAX, gdt_pointer
|
||||
LGDT [EAX]
|
||||
MOV AX, $10
|
||||
MOV DS, AX
|
||||
MOV ES, AX
|
||||
MOV FS, AX
|
||||
MOV GS, AX
|
||||
MOV SS, AX
|
||||
db $EA // Bypass stupid inline ASM restrictions-
|
||||
dw @@flush, $08 // by assembling the farjump instruction ourselves.
|
||||
@@flush: // It's just data, honest gov'.
|
||||
end;
|
||||
|
||||
procedure flush;
|
||||
begin
|
||||
io.syslog.logln('GDT','FLUSH.');
|
||||
flush_gdt(uint32(@gdt_pointer));
|
||||
end;
|
||||
|
||||
procedure reload_gdt(gdt_ptr : uint32); assembler;
|
||||
asm
|
||||
MOV EAX, gdt_ptr
|
||||
LGDT [EAX]
|
||||
end;
|
||||
|
||||
procedure reload;
|
||||
begin
|
||||
io.syslog.logln('GDT','RELOAD.');
|
||||
reload_gdt(uint32(@gdt_pointer));
|
||||
end;
|
||||
|
||||
procedure set_gate(Gate_Number : uint32; Base : uint32; Limit : uint32; Access : uint8; Granularity : uint8);
|
||||
var
|
||||
lLimit : uint32;
|
||||
|
||||
begin
|
||||
lLimit:= (Gate_Number + 1) * 8;
|
||||
lLimit:= lLimit - 1;
|
||||
if lLimit > gdt_pointer.limit then begin
|
||||
gdt_pointer.limit:= lLimit;
|
||||
end;
|
||||
gdt_entries[Gate_Number].base_low := (Base AND $FFFF);
|
||||
gdt_entries[Gate_Number].base_middle := (Base SHR 16) AND $FF;
|
||||
gdt_entries[Gate_Number].base_high := (Base SHR 24) AND $FF;
|
||||
gdt_entries[Gate_Number].limit_low := (Limit AND $FFFF);
|
||||
gdt_entries[Gate_Number].granularity := ((Limit SHR 16) AND $0F) OR (Granularity AND $F0);
|
||||
gdt_entries[Gate_Number].access := Access;
|
||||
io.syslog.log('GDT','GATE ');
|
||||
io.syslog.writeint(Gate_Number);
|
||||
io.syslog.writestringln(' SET.');
|
||||
end;
|
||||
|
||||
procedure init();
|
||||
begin
|
||||
io.syslog.logln('GDT','INIT START.');
|
||||
gdt_pointer.limit:= 0;
|
||||
gdt_pointer.base := uint32(@gdt_entries);
|
||||
set_gate($00, $00, $00, $00, $00); //OFFSET: 0
|
||||
set_gate($01, $00, $FFFFFFFF, $9A, $CF); //OFFSET: 8
|
||||
set_gate($02, $00, $FFFFFFFF, $92, $CF); //OFFSET: 16
|
||||
set_gate($03, $00, $FFFFFFFF, $FA, $CF); //OFFSET: 24
|
||||
set_gate($04, $00, $FFFFFFFF, $F2, $CF); //OFFSET: 32
|
||||
flush;
|
||||
io.syslog.logln('GDT','INIT END.');
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +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.
|
||||
|
||||
{
|
||||
Interrupt Descriptor Table - Structures & Interface.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.idt;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util, io.syslog;
|
||||
|
||||
const
|
||||
ISR_RING_0 = $8E;
|
||||
ISR_RING_1 = $AE;
|
||||
ISR_RING_2 = $CE;
|
||||
ISR_RING_3 = $EE;
|
||||
|
||||
type
|
||||
TIDT_Entry = packed record
|
||||
base_low : uint16;
|
||||
selector : uint16;
|
||||
always_0 : uint8;
|
||||
flags : uint8;
|
||||
base_high : uint16;
|
||||
end;
|
||||
PIDT_Entry = ^TIDT_Entry;
|
||||
|
||||
TIDT_Pointer = packed record
|
||||
limit : uint16;
|
||||
base : uint32;
|
||||
end;
|
||||
PIDT_Pointer = ^TIDT_Pointer;
|
||||
|
||||
var
|
||||
IDT_Entries : Array [0..255] of TIDT_Entry;
|
||||
IDT_Pointer : TIDT_Pointer;
|
||||
|
||||
procedure init();
|
||||
procedure set_gate(Number : uint8; Base : uint32; Selector : uint16; Flags : uint8);
|
||||
|
||||
implementation
|
||||
|
||||
procedure load(idt_pointer : uint32); assembler; nostackframe;
|
||||
asm
|
||||
MOV EAX, idt_pointer
|
||||
LIDT [EAX]
|
||||
end;
|
||||
|
||||
procedure set_gate(Number : uint8; Base : uint32; Selector : uint16; Flags : uint8);
|
||||
begin
|
||||
IDT_Entries[Number].base_high:= (Base and $FFFF0000) SHR 16;
|
||||
IDT_Entries[Number].base_low:= (Base and $0000FFFF);
|
||||
IDT_Entries[Number].selector:= Selector;
|
||||
IDT_Entries[Number].flags:= Flags;
|
||||
IDT_Entries[Number].always_0:= $00;
|
||||
io.syslog.log('IDT','GATE ');
|
||||
io.syslog.writeint(Number);
|
||||
io.syslog.writestringln(' SET.');
|
||||
load(uint32(@IDT_Pointer));
|
||||
end;
|
||||
|
||||
procedure init();
|
||||
begin
|
||||
io.syslog.logln('IDT','INIT START.');
|
||||
IDT_Pointer.limit:= (sizeof(TIDT_Entry) * 256) - 1;
|
||||
IDT_Pointer.base:= uint32(@IDT_Entries);
|
||||
io.syslog.logln('IDT','CLEAR.');
|
||||
core.util.memset(uint32(@IDT_Entries[0]), 0, sizeof(TIDT_Entry) * 256);
|
||||
io.syslog.logln('IDT','LOAD.');
|
||||
load(uint32(@IDT_Pointer));
|
||||
io.syslog.logln('IDT','INIT END.');
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,56 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Interrupt Request Line - Initialization & Remapping.
|
||||
|
||||
@author(Aaron Hance <[email protected]>)
|
||||
}
|
||||
unit arch.x86.irq;
|
||||
|
||||
interface
|
||||
|
||||
uses core.util, arch.x86.util, io.syslog;
|
||||
|
||||
procedure init();
|
||||
|
||||
implementation
|
||||
|
||||
procedure init();
|
||||
begin
|
||||
io.syslog.logln('IRQ','INIT START.');
|
||||
outb($20, $11);
|
||||
io_wait;
|
||||
outb($A0, $11);
|
||||
io_wait;
|
||||
outb($21, $20);
|
||||
io_wait;
|
||||
outb($A1, $28);
|
||||
io_wait;
|
||||
outb($21, $04);
|
||||
io_wait;
|
||||
outb($A1, $02);
|
||||
io_wait;
|
||||
outb($21, $01);
|
||||
io_wait;
|
||||
outb($A1, $01);
|
||||
io_wait;
|
||||
outb($21, $00);
|
||||
io_wait;
|
||||
outb($A1, $00);
|
||||
io_wait;
|
||||
io.syslog.logln('IRQ','INIT END.');
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,33 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
ISR Driver - Initialization (stub).
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.isr;
|
||||
|
||||
interface
|
||||
|
||||
procedure init();
|
||||
|
||||
implementation
|
||||
|
||||
procedure init();
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +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 <[email protected]>)
|
||||
}
|
||||
unit arch.x86.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.
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,128 @@
|
||||
; 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 ; Identity map first 4MB (for boot transition)
|
||||
times (KERNEL_PAGE_NUMBER - 1) dd 0
|
||||
dd 0x00000083 ; 0xC0000000 -> phys 0x00000000 (0-4MB)
|
||||
dd 0x00400083 ; 0xC0400000 -> phys 0x00400000 (4-8MB)
|
||||
dd 0x00800083 ; 0xC0800000 -> phys 0x00800000 (8-12MB)
|
||||
dd 0x00C00083 ; 0xC0C00000 -> phys 0x00C00000 (12-16MB)
|
||||
times (1024 - KERNEL_PAGE_NUMBER - 4) 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 1600
|
||||
dd 1200
|
||||
dd 32
|
||||
|
||||
;
|
||||
; 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
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.ace - Alignment Check Exception.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.ace;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(true);
|
||||
BSOD('AC', 'Alignment Check Exception.');
|
||||
io.syslog.writestringln('Alignment Check Exception.');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(17, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(17, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.bpe - Break Point Exception.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.bpe;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(false);
|
||||
BSOD('BE', 'Breakpoint Exception.');
|
||||
io.syslog.writestringln('Breakpoint Exception');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(3, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(3, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.btsse - Bad TSS Exception.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.btsse;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(true);
|
||||
BSOD('TSS', 'Bad TSS Exception.');
|
||||
io.syslog.writestringln('Bad TSS Exception.');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(10, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(10, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.cfe - Coprocessor Fault Exception.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.cfe;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(false);
|
||||
BSOD('CF', 'Coprocessor Fault Exception.');
|
||||
io.syslog.writestringln('Coprocessor Fault Exception.');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(16, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(16, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.csoe - Coprocessor Seg Overruun Exception.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.csoe;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(false);
|
||||
BSOD('CSO', 'Coprocessor Seg Overrun Exception.');
|
||||
io.syslog.writestringln('Coprocessor Seg Overrun Exception.');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(9, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(9, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.dbge - Debug Exception.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.dbge;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(false);
|
||||
BSOD('DE', 'Debug Exception');
|
||||
io.syslog.writestringln('Debug Exception.');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(1, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(1, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.dbz - Divide By Zero Exception.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.dbz;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(false);
|
||||
BSOD('arch.x86.fault.dbz', 'Divide By Zero Exception.');
|
||||
io.syslog.writestringln('Divide by Zero Exception.');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(0, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(0, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.dfe - Double Fault Exception.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.dfe;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(true);
|
||||
BSOD('DF', 'Double Fault.');
|
||||
io.syslog.writestringln('Double Fault.');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(8, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(8, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,55 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Fault->arch.x86.fault.gpf - General Protection Fault.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
}
|
||||
unit arch.x86.fault.gpf;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
core.util, arch.x86.util,
|
||||
io.syslog,
|
||||
arch.x86.isr.types,
|
||||
arch.x86.isr.mgr,
|
||||
arch.x86.idt;
|
||||
|
||||
procedure register();
|
||||
|
||||
implementation
|
||||
|
||||
procedure Main();
|
||||
var
|
||||
i : uint32;
|
||||
Regs : PRegisters;
|
||||
|
||||
begin
|
||||
CLI;
|
||||
correctInterruptRegisters(true);
|
||||
BSOD('arch.x86.fault.gpf', 'General Protection Fault.');
|
||||
io.syslog.writestringln('General Protection Fault.');
|
||||
arch.x86.util.halt_and_catch_fire;
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
arch.x86.isr.mgr.registerISR(13, @Main);
|
||||
//memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||
//arch.x86.idt.set_gate(13, uint32(@Main), $08, ISR_RING_0);
|
||||
end;
|
||||
|
||||
end.
|
||||
Loaded 20 of 197 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user