-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding elf32 support base, adding multiboot infos, adding functions n…
…ames to stack trace un debug
- Loading branch information
Showing
17 changed files
with
305 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
all : | ||
@zig build | ||
@zig build -Ddebug=false | ||
|
||
debug: | ||
@zig build -Ddebug=true | ||
|
||
run : fclean | ||
@zig build run | ||
@zig build run -Ddebug=false | ||
|
||
run-debug : fclean | ||
@zig build run -Ddebug=true | ||
|
||
run-debugger : fclean | ||
@zig build run-debug -Ddebug=true | ||
|
||
clean: | ||
@rm -rf .zig_cache | ||
|
||
fclean : clean | ||
fclean: | ||
@rm -rf zig-out | ||
|
||
.PHONY : all run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,3 @@ pub fn disableInts() void | |
{ | ||
asm volatile("cli"); | ||
} | ||
|
||
pub fn init() void | ||
{ | ||
idt.idtInit(); | ||
gdt.gdtInit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const boot = @import("../../boot.zig"); | ||
const elf32 = @import("../../sys/elf32.zig"); | ||
|
||
const MULTIBOOT_INFO_ELF_SHDR = 0x00000020; | ||
const MULTIBOOT_INFO_AOUT_SYMS = 0x00000010; | ||
|
||
const AoutSymbolTable = extern struct | ||
{ | ||
tabsize: u32, | ||
strsize: u32, | ||
addr: u32, | ||
reserved: u32, | ||
}; | ||
|
||
const ElfSectionHeaderTable = extern struct | ||
{ | ||
num: u32, | ||
size: u32, | ||
addr: u32, | ||
shndx: u32, | ||
}; | ||
|
||
const MultibootInfo = extern struct | ||
{ | ||
flags: u32, | ||
mem_lower: u32, | ||
mem_upper: u32, | ||
boot_device: u32, | ||
cmdline: u32, | ||
mods_count: u32, | ||
mods_addr: u32, | ||
|
||
u: extern union | ||
{ | ||
aout_sym: AoutSymbolTable, | ||
elf_sec: ElfSectionHeaderTable, | ||
}, | ||
|
||
mmap_length: u32, | ||
mmap_addr: u32, | ||
drives_length: u32, | ||
drives_addr: u32, | ||
config_table: u32, | ||
boot_loader_name: u32, | ||
}; | ||
|
||
pub fn populateBootData(boot_data: *boot.Boot, info: *MultibootInfo) void | ||
{ | ||
boot_data.cmdline = @ptrFromInt(info.cmdline); | ||
boot_data.total_mem = info.mem_lower + info.mem_upper; | ||
if((info.flags & MULTIBOOT_INFO_ELF_SHDR) != 0) | ||
{ | ||
boot_data.shdr = @ptrFromInt(info.u.elf_sec.addr); | ||
boot_data.shdr_num = info.u.elf_sec.num; | ||
|
||
for(0..boot_data.shdr_num) |i| | ||
{ | ||
const shdr: *elf32.SectionHeader = &boot_data.shdr.?[i]; | ||
if(shdr.sh_type == elf32.SHT_SYMTAB) | ||
{ | ||
boot_data.symtab = @ptrCast(shdr); | ||
boot_data.symtab_num = shdr.sh_size / @sizeOf(elf32.Symbol); | ||
} | ||
if(shdr.sh_type == elf32.SHT_STRTAB and boot_data.strtab == null) | ||
boot_data.strtab = shdr; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const elf32 = @import("sys/elf32.zig"); | ||
|
||
pub const Boot = struct | ||
{ | ||
cmdline: [*:0]const u8 = undefined, | ||
total_mem: usize = 0, | ||
|
||
shdr: ?[*]elf32.SectionHeader = null, | ||
shdr_num: usize = 0, | ||
|
||
symtab: ?*elf32.SectionHeader = null, | ||
symtab_num: usize = 0, | ||
|
||
strtab: ?*elf32.SectionHeader = null, | ||
}; | ||
|
||
pub var kboot_data: Boot = .{}; |
Oops, something went wrong.