Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ const std: type = @import("std");

const arch: type = @import("config/arch/config.zig");
const compile: type = @import("config/compile/config.zig");
const SaturnLinkers = @import("linkers/linkers.zig") {};
const linkers = @import("linkers.zig") {};

comptime {
if(!@hasField(@TypeOf(linkers), @tagName(arch.options.Target)))
@compileError("");
}

pub const target: std.Target.Cpu.Arch = switch(arch.options.Target) {
.i386 => .x86,
Expand Down Expand Up @@ -78,7 +83,7 @@ pub fn build(b: *std.Build) void {
" linker error"
);
};
_ = file.write(@field(SaturnLinkers, @tagName(arch.options.Target))) catch {
_ = file.write(@field(linkers, @tagName(arch.options.Target))) catch {
@panic(
@tagName(arch.options.Target) ++
" linker error"
Expand Down
4 changes: 2 additions & 2 deletions config/kernel/mem/phys.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// │ Author: Linuxperoxo │
// └─────────────────────────────────────────────┘

pub const kernel_phys: u32 = 0x0010_0000;
pub const kernel_stack_base: u32 = 0x00F0_0000;
pub const kernel_base: u32 = 0x0010_0000;
pub const kernel_stack: u32 = 0x00F0_0000;
pub const kernel_paged_memory: u32 = 0x0100_0000;
pub const kernel_mmio: u32 = 0x000A_0000;
4 changes: 2 additions & 2 deletions kernel/arch/i386/i386.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const physio: type = root.code.physio;

const interfaces: type = root.interfaces;

pub const linker: type = @import("linker.zig");
pub const symbols: type = @import("symbols.zig");
pub const sections: type = @import("sections.zig");
pub const allocators: type = @import("allocators.zig");

Expand Down Expand Up @@ -49,7 +49,7 @@ pub const __SaturnArchDescription__: interfaces.arch.ArchDescription_T = .{
.segments = 1,
},
.allocators = .{
.spea = allocator
.spea = allocators.spea,
},
.extra = &[_]interfaces.arch.ArchDescription_T.Extra_T {
.{
Expand Down
8 changes: 4 additions & 4 deletions kernel/arch/i386/linker.zig → kernel/arch/i386/symbols.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ┌──────────────────────────────────────────────┐
// │ (c) 2025 Linuxperoxo • FILE: linker.zig │
// │ Author: Linuxperoxo │
// └──────────────────────────────────────────────┘
// ┌──────────────────────────────────────────────
// │ (c) 2025 Linuxperoxo • FILE: symbols.zig │
// │ Author: Linuxperoxo
// └──────────────────────────────────────────────

// arch section
pub const phys_i386_start = @extern(*anyopaque, .{
Expand Down
50 changes: 35 additions & 15 deletions kernel/asl/asl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const config: type = @import("root").config;
const fmt: type = @import("root").lib.utils.compile.fmt;
const aux: type = @import("aux.zig");

const phys: type = config.kernel.mem.phys;
const virtual: type = config.kernel.mem.virtual;

comptime {
if(!@hasDecl(code.arch, decls.what_is_decl(.arch))) @compileError(
"expected a declaration " ++ decls.what_is_decl(.arch) ++ " for architecture " ++
Expand All @@ -37,21 +40,38 @@ comptime {
// la na proprio config, ja que pode acontecer de alguma nao ser usada diretamente no codigo, mas ser
// usada dentro de um linker ou assembly, isso iria dar um erro de simbolo nao encontrado, ja que como
// nao foi usada dentro do proprio codigo zig, o compilador so iria ignorar e nem colocar o export nela
if(@field(code.arch, decls.what_is_decl(.arch)).symbols.segments == 1 ) asm(
&fmt.format(".set {s}, {d}\n", .{ "kernel_phys_address", config.kernel.mem.phys.kernel_phys }) ++
&fmt.format(".global {s}\n", .{ "kernel_phys_address" }) ++
&fmt.format(".set {s}, {d}\n", .{ "kernel_virtual_address", config.kernel.mem.virtual.kernel_text }) ++
&fmt.format(".global {s}\n", .{ "kernel_virtual_address" }) ++
&fmt.format(".set {s}, {d}\n", .{ "kernel_text_virtual", config.kernel.mem.virtual.kernel_text }) ++
&fmt.format(".global {s}\n", .{ "kernel_text_virtual" }) ++
&fmt.format(".set {s}, {d}\n", .{ "kernel_stack_base_virtual", config.kernel.mem.virtual.kernel_stack_base }) ++
&fmt.format(".global {s}\n", .{ "kernel_stack_base_virtual" }) ++
&fmt.format(".set {s}, {d}\n", .{ "kernel_data_virtual", config.kernel.mem.virtual.kernel_data }) ++
&fmt.format(".global {s}\n", .{ "kernel_data_virtual" }) ++
&fmt.format(".set {s}, {d}\n", .{ "kernel_paged_memory_virtual", config.kernel.mem.virtual.kernel_paged_memory }) ++
&fmt.format(".global {s}\n", .{ "kernel_paged_memory_virtual" }) ++
&fmt.format(".set {s}, {d}\n", .{ "kernel_mmio_virtual", config.kernel.mem.virtual.kernel_mmio }) ++
&fmt.format(".global {s}\n", .{ "kernel_mmio_virtual" })
asm(
// phys addrs
&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_phys_base", phys.kernel_base }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_phys_address" }) ++

&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_phys_stack", phys.kernel_stack }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_phys_stack" }) ++

&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_phys_paged_memory", phys.kernel_paged_memory }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_phys_paged_memory" }) ++

&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_phys_mmio", phys.kernel_mmio }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_phys_paged_mmio" }) ++

// virtual addrs
&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_virtual_base", virtual.kernel_text }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_virtual_base" }) ++

&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_virtual_text", virtual.kernel_text }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_virtual_text" }) ++

&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_virtual_stack", virtual.kernel_stack_base }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_virtual_stack" }) ++

&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_virtual_data", virtual.kernel_data }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_virtual_data" }) ++

&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_virtual_paged_memory", virtual.kernel_paged_memory }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_virtual_paged_memory" }) ++

&fmt.format(".set {s}, {d}\n", .{ "kernel_mem_virtual_mmio", virtual.kernel_mmio }) ++
&fmt.format(".global {s}\n", .{ "kernel_mem_virtual_mmio" })
);

const arch_decl_type: type = decls.what_is_decl_type(.arch);
Expand Down
7 changes: 2 additions & 5 deletions lib/saturn/interfaces/arch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const modules: type = @import("root").config.modules;
const fusium: type = @import("root").config.fusium;

pub const Target_T: type = @TypeOf(@import("root").config.arch.options.Target);

pub const ArchDescription_T: type = struct {
usable: bool,
entry: struct {
Expand Down Expand Up @@ -35,7 +36,7 @@ pub const ArchDescription_T: type = struct {
entry: *const fn() callconv(.c) void,
sync: *const fn() void,
},
symbols: Symbols_T,
symbols: ?[]const[]const u8,
extra: ?[]const Extra_T,
data: ?[]const Data_T,
allocators: ?Allocators_T,
Expand Down Expand Up @@ -74,10 +75,6 @@ pub const ArchDescription_T: type = struct {
},
};

pub const Symbols_T: type = struct {
segments: u1,
};

pub const Data_T: type = struct {
label: []const u8,
section: ?[]const u8,
Expand Down
2 changes: 1 addition & 1 deletion linkers/linkers.zig → linkers.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// │ Author: Linuxperoxo │
// └───────────────────────────────────────────────┘

@"i386": []const u8 = @embedFile("i386/i386-linker.ld"),
@"i386": []const u8 = @embedFile("linkers/i386/i386-linker.ld"),
26 changes: 11 additions & 15 deletions linkers/i386/i386-linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ SECTIONS {
* opensaturn_phys_address: difined in kernel/loader.zig
* opensaturn_virtual_address: difined in kernel/loader.zig
*/
phys_init = kernel_phys_address;
phys_init = kernel_mem_phys_base;

opensaturn_text_virtual = kernel_text_virtual;
opensaturn_text_virtual = kernel_mem_virtual;
opensaturn_data_virtual = kernel_data_virtual;

phys_init_atlas_header = phys_init;
Expand All @@ -19,28 +19,24 @@ SECTIONS {
KEEP(*(.opensaturn.data.atlas.header))
}

PROVIDE(
phys_i386_start = .
);
PROVIDE(linker_mem_phys_opensaturn_arch_start = .);

.opensaturn.arch : {
PROVIDE(linker_mem_phys_opensaturn_arch_section_text_start = .);
/* .text expurgated after jmp to kernel */
KEEP(*(.i386.text)) /* free page for kernel after arch init */
PROVIDE(linker_mem_phys_opensaturn_arch_section_text_end = .);

. = ALIGN(4096);
PROVIDE(
phys_i386_data_start = .
);
KEEP(*(.i386.data)) /* TMP DATA */
PROVIDE(
phys_i386_data_end = .
);

PROVIDE(linker_mem_phys_opensaturn_arch_section_data_start = .);
KEEP(*(.i386.data))
PROVIDE(linker_mem_phys_opensaturn_arch_section_data_end = .);
}

. = ALIGN(4096);

PROVIDE(
phys_i386_end = .
);
PROVIDE(linker_mem_phys_opensaturn_arch_end = .);

PROVIDE(
phys_address_opensaturn_start = phys_i386_end
Expand Down
19 changes: 0 additions & 19 deletions mm/i386/mm.zig

This file was deleted.

Loading