Compare commits

...

4 Commits

Author SHA1 Message Date
Quinten Kock 0d10e698da add arch-specific stuff safely 2020-12-26 23:24:33 +01:00
Quinten Kock ab2ef5a415 reduce static kernel memory 2020-12-26 23:24:12 +01:00
Quinten Kock c7b7137292 add seperate sections 2020-12-26 23:23:43 +01:00
Quinten Kock 940f077480 fix compile 2020-12-26 02:24:15 +01:00
5 changed files with 34 additions and 11 deletions

View File

@ -12,22 +12,30 @@ SECTIONS
.text ALIGN(4K) :
{
_text_start = .;
/* KEEP(*(.text*)) */
}
_text_end = .;
.rodata ALIGN(4K) :
{
_rodata_start = .;
/* KEEP(*(.rodata*)) */
}
_rodata_end = .;
.data ALIGN(4K) :
{
_data_start = .;
/* KEEP(*(.data*)) */
}
_data_end = .;
.bss ALIGN(4K) :
{
_bss_start = .;
/* KEEP(*(COMMON)) */
/* KEEP(*(.bss*)) */
}
_bss_end = .;
}

View File

@ -1,5 +1,5 @@
const std = @import("std");
var buf: [1024*1024]u8 = undefined;
var buf: [512*1024]u8 = undefined;
pub var KAlloc = std.heap.FixedBufferAllocator.init(&buf);
// pub var KAlloc = std.heap.GeneralPurposeAllocator(.{.thread_safe=false}){.backing_allocator = &GlobAlloc.allocator};

View File

@ -31,9 +31,24 @@ struct stivale2_header header2 = {
.tags = (uint64_t)&smp_request
};
extern void* _text_start;
extern void* _text_end;
extern void* _rodata_start;
extern void* _rodata_end;
extern void* _data_start;
extern void* _data_end;
extern void* _bss_start;
extern void* _bss_end;
void stivale2_main(struct stivale2_struct *info) {
parse_stivale2(info);
// print_stivale2_memmap(info);
print_stivale2_memmap(info);
printf("text section: %x-%x\n", &_text_start, &_text_end);
printf("rodata section: %x-%x\n", &_rodata_start, &_rodata_end);
printf("data section: %x-%x\n", &_data_start, &_data_end);
printf("bss section: %x-%x\n", &_bss_start, &_bss_end);
uint64_t* cr3;
__asm__ __volatile__ (
@ -45,7 +60,7 @@ void stivale2_main(struct stivale2_struct *info) {
printf("PAGE TABLE AT: %x\n", cr3);
loadgdt();
print_gdt();
// print_gdt();
setup_ints();

View File

@ -20,7 +20,6 @@ void setup_idt();
void setup_ints() {
setup_idt();
init_idt();
set_idt_ent(0x80, (uint64_t)&isr_wrapper128, 0, 0, INT64);
__asm__ volatile("int $0x80");

View File

@ -56,14 +56,15 @@ export fn zigmain() void {
const msg = std.fmt.allocPrint(alloc, "Hello {}!", .{"ziguser"});
std.log.debug("message: {}", .{msg});
// var cr3: usize = asm volatile (
// "mov %%cr3, %%rax" : [cr3] "={rax}" (-> usize) ::
// );
// std.log.info("cr3 = {x}", .{cr3});
if(@hasDecl(arch, "paging")) {
arch.paging.showActive();
arch.paging.activate();
}
// const page_lvl4 = @intToPtr(*[512]u64, cr3);
// arch.paging.showTable(page_lvl4.*);
if(@hasDecl(arch, "cpuid")) {
_ = arch.cpuid.getVendor();
_ = arch.cpuid.getName();
}
// time.displayTime(debug.AWriter) catch unreachable;