Rename project to Birth

This commit is contained in:
David Gonzalez Martin 2023-07-10 17:44:11 -06:00
parent 09e1c4104e
commit 795db5b69f
31 changed files with 121 additions and 138 deletions

View File

@ -1,6 +1,6 @@
# Rise: an attempt to write a better operating system # Birth: an attempt to write a better operating system
![Build status](https://img.shields.io/github/actions/workflow/status/davidgm94/rise/lightning.yml?branch=main) ![Build status](https://img.shields.io/github/actions/workflow/status/birth-software/birth/lightning.yml?branch=main)
An experiment of an operating system for modern 64-bit architectures which focuses on building robust, fast and usable system software and learning how to do it along the way. An experiment of an operating system for modern 64-bit architectures which focuses on building robust, fast and usable system software and learning how to do it along the way.

17
bochsrc
View File

@ -1,17 +0,0 @@
cpu: count=2, reset_on_triple_fault=0
display_library: x, options="gui_debug"
megs: 512
clock: sync=realtime, time0=local
ata0-master: type=disk, path="zig-cache/rise_Debug_x86_64_rise_bios_normal_exe.hdd", mode=flat
boot: c
log: ./bochsout.txt
mouse: enabled=0
magic_break: enabled=1

View File

@ -23,7 +23,7 @@ const ExecutionEnvironment = common.ExecutionEnvironment;
const FilesystemType = common.FilesystemType; const FilesystemType = common.FilesystemType;
const OptimizeMode = common.OptimizeMode; const OptimizeMode = common.OptimizeMode;
const QEMUOptions = common.QEMUOptions; const QEMUOptions = common.QEMUOptions;
const RiseProgram = common.RiseProgram; const BirthProgram = common.BirthProgram;
const Suffix = common.Suffix; const Suffix = common.Suffix;
const Target = common.Target; const Target = common.Target;
@ -76,9 +76,9 @@ pub fn build(b_arg: *Build) !void {
try mods.setDependencies(.uefi, &.{ .lib, .privileged }); try mods.setDependencies(.uefi, &.{ .lib, .privileged });
try mods.setDependencies(.limine_installer, &.{ .lib, .privileged }); try mods.setDependencies(.limine_installer, &.{ .lib, .privileged });
try mods.setDependencies(.privileged, &.{ .lib, .bootloader }); try mods.setDependencies(.privileged, &.{ .lib, .bootloader });
try mods.setDependencies(.cpu, &.{ .privileged, .lib, .bootloader, .rise }); try mods.setDependencies(.cpu, &.{ .privileged, .lib, .bootloader, .birth });
try mods.setDependencies(.rise, &.{.lib}); try mods.setDependencies(.birth, &.{.lib});
try mods.setDependencies(.user, &.{ .lib, .rise }); try mods.setDependencies(.user, &.{ .lib, .birth });
break :blk mods; break :blk mods;
}; };
@ -283,7 +283,7 @@ pub fn build(b_arg: *Build) !void {
.root_project_path = cpu_driver_path, .root_project_path = cpu_driver_path,
.target = target, .target = target,
.optimize_mode = optimize_mode, .optimize_mode = optimize_mode,
.modules = &.{ .lib, .bootloader, .privileged, .cpu, .rise }, .modules = &.{ .lib, .bootloader, .privileged, .cpu, .birth },
}); });
cpu_driver.force_pic = true; cpu_driver.force_pic = true;
@ -318,7 +318,7 @@ pub fn build(b_arg: *Build) !void {
.root_project_path = try std.mem.concat(b.allocator, u8, &.{ user_program_dir_path, "/", module.name }), .root_project_path = try std.mem.concat(b.allocator, u8, &.{ user_program_dir_path, "/", module.name }),
.target = user_target, .target = user_target,
.optimize_mode = optimize_mode, .optimize_mode = optimize_mode,
.modules = &.{ .lib, .user, .rise }, .modules = &.{ .lib, .user, .birth },
}); });
user_module.strip = false; user_module.strip = false;
@ -331,16 +331,16 @@ pub fn build(b_arg: *Build) !void {
for (bootloaders) |bootloader_struct| { for (bootloaders) |bootloader_struct| {
const bootloader = bootloader_struct.id; const bootloader = bootloader_struct.id;
for (bootloader_struct.protocols) |boot_protocol| { for (bootloader_struct.protocols) |boot_protocol| {
const rise_loader_path = "src/bootloader/rise/"; const birth_loader_path = "src/bootloader/birth/";
const limine_loader_path = "src/bootloader/limine/"; const limine_loader_path = "src/bootloader/limine/";
const bootloader_name = "loader"; const bootloader_name = "loader";
const bootloader_modules = [_]ModuleID{ .lib, .bootloader, .privileged }; const bootloader_modules = [_]ModuleID{ .lib, .bootloader, .privileged };
const bootloader_compile_step = switch (bootloader) { const bootloader_compile_step = switch (bootloader) {
.rise => switch (boot_protocol) { .birth => switch (boot_protocol) {
.bios => switch (architecture) { .bios => switch (architecture) {
.x86_64 => blk: { .x86_64 => blk: {
const bootloader_path = rise_loader_path ++ "bios"; const bootloader_path = birth_loader_path ++ "bios";
const executable = try addCompileStep(.{ const executable = try addCompileStep(.{
.kind = executable_kind, .kind = executable_kind,
.name = bootloader_name, .name = bootloader_name,
@ -362,7 +362,7 @@ pub fn build(b_arg: *Build) !void {
else => return Error.architecture_not_supported, else => return Error.architecture_not_supported,
}, },
.uefi => blk: { .uefi => blk: {
const bootloader_path = rise_loader_path ++ "uefi"; const bootloader_path = birth_loader_path ++ "uefi";
const executable = try addCompileStep(.{ const executable = try addCompileStep(.{
.kind = executable_kind, .kind = executable_kind,
.name = bootloader_name, .name = bootloader_name,
@ -420,7 +420,7 @@ pub fn build(b_arg: *Build) !void {
} }
const execution_environments: []const ExecutionEnvironment = switch (bootloader) { const execution_environments: []const ExecutionEnvironment = switch (bootloader) {
.rise, .limine => switch (boot_protocol) { .birth, .limine => switch (boot_protocol) {
.bios => switch (architecture) { .bios => switch (architecture) {
.x86_64 => &.{.qemu}, .x86_64 => &.{.qemu},
else => return Error.architecture_not_supported, else => return Error.architecture_not_supported,
@ -534,12 +534,12 @@ pub fn build(b_arg: *Build) !void {
} }
const Options = struct { const Options = struct {
arr: std.EnumArray(RiseProgram, *OptionsStep) = std.EnumArray(RiseProgram, *OptionsStep).initUndefined(), arr: std.EnumArray(BirthProgram, *OptionsStep) = std.EnumArray(BirthProgram, *OptionsStep).initUndefined(),
pub fn createOption(options_struct: *Options, rise_program: RiseProgram) void { pub fn createOption(options_struct: *Options, birth_program: BirthProgram) void {
const new_options = b.addOptions(); const new_options = b.addOptions();
new_options.addOption(RiseProgram, "program_type", rise_program); new_options.addOption(BirthProgram, "program_type", birth_program);
options_struct.arr.set(rise_program, new_options); options_struct.arr.set(birth_program, new_options);
} }
}; };
@ -681,14 +681,14 @@ const ModuleID = enum {
uefi, uefi,
limine, limine,
limine_installer, limine_installer,
/// This module contains code that is used by Rise privileged programs /// This module contains code that is used by birth privileged programs
privileged, privileged,
/// This module contains code that is unique to Rise CPU drivers /// This module contains code that is unique to birth CPU drivers
cpu, cpu,
/// This module contains code that is used by userspace programs /// This module contains code that is used by userspace programs
user, user,
/// This module contains code that is interacting between userspace and cpu in Rise /// This module contains code that is interacting between userspace and cpu in birth
rise, birth,
}; };
pub const Modules = struct { pub const Modules = struct {

View File

@ -1,6 +1,6 @@
{ {
"architecture": "x86_64", "architecture": "x86_64",
"bootloader": "rise", "bootloader": "birth",
"boot_protocol": "uefi", "boot_protocol": "uefi",
"execution_environment": "qemu", "execution_environment": "qemu",
"optimize_mode": "Debug", "optimize_mode": "Debug",

View File

@ -1,7 +1,6 @@
{ {
"sector_count": 131072, "sector_count": 131072,
"sector_size": 512, "sector_size": 512,
"image_name": "rise",
"partition_table": "gpt", "partition_table": "gpt",
"partition": { "partition": {
"name": "ESP", "name": "ESP",

View File

@ -1,8 +1,8 @@
const lib = @import("lib"); const lib = @import("lib");
pub const arch = @import("rise/arch.zig"); pub const arch = @import("birth/arch.zig");
pub const capabilities = @import("rise/capabilities.zig"); pub const capabilities = @import("birth/capabilities.zig");
pub const syscall = @import("rise/syscall.zig"); pub const syscall = @import("birth/syscall.zig");
/// This struct is the shared part that the user and the cpu see /// This struct is the shared part that the user and the cpu see
pub const UserScheduler = extern struct { pub const UserScheduler = extern struct {

View File

@ -1,15 +1,15 @@
const lib = @import("lib"); const lib = @import("lib");
const assert = lib.assert; const assert = lib.assert;
const rise = @import("rise"); const birth = @import("birth");
pub const UserScheduler = extern struct { pub const UserScheduler = extern struct {
generic: rise.UserScheduler, generic: birth.UserScheduler,
disabled_save_area: RegisterArena, disabled_save_area: RegisterArena,
}; };
pub const RegisterArena = extern struct { pub const RegisterArena = extern struct {
fpu: FPU align(lib.arch.stack_alignment), fpu: FPU align(lib.arch.stack_alignment),
registers: rise.arch.Registers, registers: birth.arch.Registers,
pub fn contextSwitch(register_arena: *align(lib.arch.stack_alignment) const RegisterArena) noreturn { pub fn contextSwitch(register_arena: *align(lib.arch.stack_alignment) const RegisterArena) noreturn {
assert(lib.isAligned(@intFromPtr(register_arena), lib.arch.stack_alignment)); assert(lib.isAligned(@intFromPtr(register_arena), lib.arch.stack_alignment));
@ -88,8 +88,8 @@ pub const Registers = extern struct {
) )
: :
: [registers] "{rdi}" (registers), : [registers] "{rdi}" (registers),
[ss] "i" (rise.arch.user_data_selector), [ss] "i" (birth.arch.user_data_selector),
[cs] "i" (rise.arch.user_code_selector), [cs] "i" (birth.arch.user_code_selector),
: "memory" : "memory"
); );
@ -129,9 +129,9 @@ pub const FPU = extern struct {
pub const user_code_selector = 0x43; pub const user_code_selector = 0x43;
pub const user_data_selector = 0x3b; pub const user_data_selector = 0x3b;
pub inline fn syscall(options: rise.syscall.Options, arguments: rise.syscall.Arguments) rise.syscall.Result { pub inline fn syscall(options: birth.syscall.Options, arguments: birth.syscall.Arguments) birth.syscall.Result {
var first: rise.syscall.Result.Rise.First = undefined; var first: birth.syscall.Result.Birth.First = undefined;
var second: rise.syscall.Result.Rise.Second = undefined; var second: birth.syscall.Result.Birth.Second = undefined;
asm volatile ( asm volatile (
\\syscall \\syscall
: [rax] "={rax}" (first), : [rax] "={rax}" (first),
@ -147,7 +147,7 @@ pub inline fn syscall(options: rise.syscall.Options, arguments: rise.syscall.Arg
); );
return .{ return .{
.rise = .{ .birth = .{
.first = first, .first = first,
.second = second, .second = second,
}, },

View File

@ -2,8 +2,8 @@ const lib = @import("lib");
const assert = lib.assert; const assert = lib.assert;
const PhysicalAddress = lib.PhysicalAddress; const PhysicalAddress = lib.PhysicalAddress;
const rise = @import("rise"); const birth = @import("birth");
const syscall = rise.syscall; const syscall = birth.syscall;
const Capabilities = @This(); const Capabilities = @This();
@ -127,13 +127,13 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
pub const Result = usize; pub const Result = usize;
pub const Arguments = []const u8; pub const Arguments = []const u8;
inline fn toResult(raw_result: syscall.Result.Rise) Result { inline fn toResult(raw_result: syscall.Result.Birth) Result {
return raw_result.second; return raw_result.second;
} }
inline fn resultToRaw(result: Result) syscall.Result { inline fn resultToRaw(result: Result) syscall.Result {
return syscall.Result{ return syscall.Result{
.rise = .{ .birth = .{
.first = .{}, .first = .{},
.second = result, .second = result,
}, },
@ -165,13 +165,13 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
pub const Result = u32; pub const Result = u32;
pub const Arguments = void; pub const Arguments = void;
inline fn toResult(raw_result: syscall.Result.Rise) Result { inline fn toResult(raw_result: syscall.Result.birth) Result {
return @as(Result, @intCast(raw_result.second)); return @as(Result, @intCast(raw_result.second));
} }
inline fn resultToRaw(result: Result) syscall.Result { inline fn resultToRaw(result: Result) syscall.Result {
return syscall.Result{ return syscall.Result{
.rise = .{ .birth = .{
.first = .{}, .first = .{},
.second = result, .second = result,
}, },
@ -188,12 +188,12 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
.get_command_buffer => struct { .get_command_buffer => struct {
pub const ErrorSet = Capabilities.ErrorSet(&.{}); pub const ErrorSet = Capabilities.ErrorSet(&.{});
pub const Result = noreturn; pub const Result = noreturn;
pub const Arguments = *rise.CommandBuffer; pub const Arguments = *birth.CommandBuffer;
pub const toResult = @compileError("noreturn unexpectedly returned"); pub const toResult = @compileError("noreturn unexpectedly returned");
inline fn toArguments(raw_arguments: syscall.Arguments) !Arguments { inline fn toArguments(raw_arguments: syscall.Arguments) !Arguments {
const ptr = @as(?*rise.CommandBuffer, @ptrFromInt(raw_arguments[0])) orelse return error.invalid_input; const ptr = @as(?*birth.CommandBuffer, @ptrFromInt(raw_arguments[0])) orelse return error.invalid_input;
return ptr; return ptr;
} }
@ -215,13 +215,13 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
pub const Result = PhysicalAddress; pub const Result = PhysicalAddress;
pub const Arguments = usize; pub const Arguments = usize;
inline fn toResult(raw_result: syscall.Result.Rise) Result { inline fn toResult(raw_result: syscall.Result.birth) Result {
return PhysicalAddress.new(raw_result.second); return PhysicalAddress.new(raw_result.second);
} }
inline fn resultToRaw(result: Result) syscall.Result { inline fn resultToRaw(result: Result) syscall.Result {
return syscall.Result{ return syscall.Result{
.rise = .{ .birth = .{
.first = .{}, .first = .{},
.second = result.value(), .second = result.value(),
}, },
@ -248,14 +248,14 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
inline fn resultToRaw(result: Result) syscall.Result { inline fn resultToRaw(result: Result) syscall.Result {
return syscall.Result{ return syscall.Result{
.rise = .{ .birth = .{
.first = .{}, .first = .{},
.second = result, .second = result,
}, },
}; };
} }
inline fn toResult(raw_result: syscall.Result.Rise) Result { inline fn toResult(raw_result: syscall.Result.birth) Result {
return raw_result.second; return raw_result.second;
} }
}, },
@ -325,7 +325,7 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
} }
break :blk syscall.Result{ break :blk syscall.Result{
.rise = .{ .birth = .{
.first = .{}, .first = .{},
.second = 0, .second = 0,
}, },
@ -338,7 +338,7 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
inline else => |comptime_error| @field(@This().ErrorSet.Enum, @errorName(comptime_error)), inline else => |comptime_error| @field(@This().ErrorSet.Enum, @errorName(comptime_error)),
}; };
return syscall.Result{ return syscall.Result{
.rise = .{ .birth = .{
.first = .{ .first = .{
.@"error" = @intFromEnum(error_enum), .@"error" = @intFromEnum(error_enum),
}, },
@ -351,16 +351,16 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
pub fn blocking(arguments: Arguments) @This().ErrorSet.Error!Result { pub fn blocking(arguments: Arguments) @This().ErrorSet.Error!Result {
const raw_arguments = if (Arguments != void) Types.argumentsToRaw(arguments) else [1]usize{0} ** raw_argument_count; const raw_arguments = if (Arguments != void) Types.argumentsToRaw(arguments) else [1]usize{0} ** raw_argument_count;
// TODO: make this more reliable and robust? // TODO: make this more reliable and robust?
const options = rise.syscall.Options{ const options = birth.syscall.Options{
.rise = .{ .birth = .{
.type = capability, .type = capability,
.command = @intFromEnum(command), .command = @intFromEnum(command),
}, },
}; };
const raw_result = rise.arch.syscall(options, raw_arguments); const raw_result = birth.arch.syscall(options, raw_arguments);
const raw_error_value = raw_result.rise.first.@"error"; const raw_error_value = raw_result.birth.first.@"error";
comptime { comptime {
assert(!@hasField(@This().ErrorSet.Enum, "ok")); assert(!@hasField(@This().ErrorSet.Enum, "ok"));
assert(!@hasField(@This().ErrorSet.Enum, "success")); assert(!@hasField(@This().ErrorSet.Enum, "success"));
@ -370,7 +370,7 @@ pub fn Syscall(comptime capability_type: Type, comptime command_type: Command(ca
return switch (raw_error_value) { return switch (raw_error_value) {
success => switch (Result) { success => switch (Result) {
noreturn => unreachable, noreturn => unreachable,
else => toResult(raw_result.rise), else => toResult(raw_result.birth),
}, },
else => switch (@as(@This().ErrorSet.Enum, @enumFromInt(raw_error_value))) { else => switch (@as(@This().ErrorSet.Enum, @enumFromInt(raw_error_value))) {
inline else => |comptime_error_enum| @field(@This().ErrorSet.Error, @tagName(comptime_error_enum)), inline else => |comptime_error_enum| @field(@This().ErrorSet.Error, @tagName(comptime_error_enum)),

View File

@ -2,20 +2,20 @@ const lib = @import("lib");
const assert = lib.assert; const assert = lib.assert;
const log = lib.log.scoped(.Syscall); const log = lib.log.scoped(.Syscall);
const rise = @import("rise"); const birth = @import("birth");
const capabilities = rise.capabilities; const capabilities = birth.capabilities;
pub const argument_count = 6; pub const argument_count = 6;
pub const Arguments = [argument_count]usize; pub const Arguments = [argument_count]usize;
pub const Convention = enum(u1) { pub const Convention = enum(u1) {
linux = 0, linux = 0,
rise = 1, birth = 1,
}; };
pub const Options = extern union { pub const Options = extern union {
general: General, general: General,
rise: Rise, birth: Birth,
linux: Linux, linux: Linux,
pub const General = packed struct(u64) { pub const General = packed struct(u64) {
@ -35,17 +35,17 @@ pub const Options = extern union {
pub fn NumberIntegerType(comptime convention: Convention) type { pub fn NumberIntegerType(comptime convention: Convention) type {
return switch (convention) { return switch (convention) {
.rise => Rise.IDInteger, .birth => birth.IDInteger,
.linux => u64, .linux => u64,
}; };
} }
}; };
pub const Rise = packed struct(u64) { pub const Birth = packed struct(u64) {
type: capabilities.Type, type: capabilities.Type,
command: capabilities.Subtype, command: capabilities.Subtype,
reserved: lib.IntType(.unsigned, @bitSizeOf(u64) - @bitSizeOf(capabilities.Type) - @bitSizeOf(capabilities.Subtype) - @bitSizeOf(Convention)) = 0, reserved: lib.IntType(.unsigned, @bitSizeOf(u64) - @bitSizeOf(capabilities.Type) - @bitSizeOf(capabilities.Subtype) - @bitSizeOf(Convention)) = 0,
convention: Convention = .rise, convention: Convention = .birth,
comptime { comptime {
Options.assertSize(@This()); Options.assertSize(@This());
@ -79,7 +79,7 @@ pub const Options = extern union {
pub const Result = extern union { pub const Result = extern union {
general: General, general: General,
rise: Rise, birth: Birth,
linux: Linux, linux: Linux,
pub const General = extern struct { pub const General = extern struct {
@ -90,7 +90,7 @@ pub const Result = extern union {
second: u64, second: u64,
}; };
pub const Rise = extern struct { pub const Birth = extern struct {
first: First, first: First,
second: Second, second: Second,
@ -99,7 +99,7 @@ pub const Result = extern union {
@"error": u16 = 0, @"error": u16 = 0,
padding2: u8 = 0, padding2: u8 = 0,
padding3: u7 = 0, padding3: u7 = 0,
convention: Convention = .rise, convention: Convention = .birth,
}; };
pub const Second = u64; pub const Second = u64;

View File

@ -283,7 +283,7 @@ pub const Information = extern struct {
@memset(page_counters, 0); @memset(page_counters, 0);
// Make sure pages are allocated to host the bootloader information and fetch memory entries from firmware (only non-UEFI) // Make sure pages are allocated to host the bootloader information and fetch memory entries from firmware (only non-UEFI)
if (bootloader_tag != .rise or protocol != .uefi) { if (bootloader_tag != .birth or protocol != .uefi) {
page_counters[total_allocation.index] = bootloader_information.getAlignedTotalSize() >> lib.arch.page_shifter(lib.arch.valid_page_sizes[0]); page_counters[total_allocation.index] = bootloader_information.getAlignedTotalSize() >> lib.arch.page_shifter(lib.arch.valid_page_sizes[0]);
const new_memory_map_entry_count = try bootloader_information.initializeMemoryMap(initialization); const new_memory_map_entry_count = try bootloader_information.initializeMemoryMap(initialization);
@ -307,7 +307,7 @@ pub const Information = extern struct {
const compressed_bundle = try initialization.filesystem.readFile("/bundle", compressed_bundle_buffer); const compressed_bundle = try initialization.filesystem.readFile("/bundle", compressed_bundle_buffer);
assert(compressed_bundle.len > 0); assert(compressed_bundle.len > 0);
if (bootloader_tag == .rise and protocol == .uefi) { if (bootloader_tag == .birth and protocol == .uefi) {
// Check if the memory map entry count matches here is not useful because probably it's going to be less as exiting boot services seems // Check if the memory map entry count matches here is not useful because probably it's going to be less as exiting boot services seems
// like making some deallocations // like making some deallocations
const new_memory_map_entry_count = @as(u32, @intCast(try bootloader_information.initializeMemoryMap(initialization))); const new_memory_map_entry_count = @as(u32, @intCast(try bootloader_information.initializeMemoryMap(initialization)));

View File

@ -269,7 +269,7 @@ export fn _start() callconv(.C) noreturn {
bios.A20Enable() catch @panic("A20 is not enabled"); bios.A20Enable() catch @panic("A20 is not enabled");
initialization.initialize() catch |err| @panic(@errorName(err)); initialization.initialize() catch |err| @panic(@errorName(err));
bootloader.Information.initialize(&initialization, .rise, .bios) catch |err| { bootloader.Information.initialize(&initialization, .birth, .bios) catch |err| {
@panic(@errorName(err)); @panic(@errorName(err));
}; };
} }

View File

@ -419,7 +419,7 @@ pub fn main() noreturn {
initialization.initialize() catch |err| { initialization.initialize() catch |err| {
@panic(@errorName(err)); @panic(@errorName(err));
}; };
bootloader.Information.initialize(&initialization, .rise, .uefi) catch |err| { bootloader.Information.initialize(&initialization, .birth, .uefi) catch |err| {
@panic(@errorName(err)); @panic(@errorName(err));
}; };
} }

View File

@ -2,7 +2,7 @@
TIMEOUT=0 TIMEOUT=0
# The entry name that will be displayed in the boot menu # The entry name that will be displayed in the boot menu
:Rise :Birth
# Change the protocol line depending on the used protocol. # Change the protocol line depending on the used protocol.
PROTOCOL=limine PROTOCOL=limine

View File

@ -1,7 +1,7 @@
// TODO: legacy stuff; refactor when SMP is implemented // TODO: legacy stuff; refactor when SMP is implemented
// pub fn initializeSMP(bootloader_information: *Information, madt: *const ACPI.MADT) void { // pub fn initializeSMP(bootloader_information: *Information, madt: *const ACPI.MADT) void {
// if (bootloader_information.bootloader != .rise) @panic("Protocol not supported"); // if (bootloader_information.bootloader != .birth) @panic("Protocol not supported");
// //
// const smp_records = bootloader_information.getSlice(.smps); // const smp_records = bootloader_information.getSlice(.smps);
// //

View File

@ -180,7 +180,7 @@ pub const DiskType = enum(u32) {
}; };
pub const FilesystemType = enum(u32) { pub const FilesystemType = enum(u32) {
rise = 0, birth = 0,
ext2 = 1, ext2 = 1,
fat32 = 2, fat32 = 2,
@ -221,7 +221,7 @@ pub const architecture_bootloader_map = blk: {
array[architectureIndex(.x86_64)] = &.{ array[architectureIndex(.x86_64)] = &.{
.{ .{
.id = .rise, .id = .birth,
.protocols = &.{ .bios, .uefi }, .protocols = &.{ .bios, .uefi },
}, },
.{ .{
@ -232,7 +232,7 @@ pub const architecture_bootloader_map = blk: {
// array[architectureIndex(.aarch64)] = &.{ // array[architectureIndex(.aarch64)] = &.{
// .{ // .{
// .id = .rise, // .id = .birth,
// .protocols = &.{.uefi}, // .protocols = &.{.uefi},
// }, // },
// .{ // .{
@ -243,7 +243,7 @@ pub const architecture_bootloader_map = blk: {
// array[architectureIndex(.riscv64)] = &.{ // array[architectureIndex(.riscv64)] = &.{
// .{ // .{
// .id = .rise, // .id = .birth,
// .protocols = &.{.uefi}, // .protocols = &.{.uefi},
// }, // },
// }; // };
@ -252,7 +252,7 @@ pub const architecture_bootloader_map = blk: {
}; };
pub const Bootloader = enum(u32) { pub const Bootloader = enum(u32) {
rise, birth,
limine, limine,
pub const Protocol = enum(u32) { pub const Protocol = enum(u32) {
@ -276,7 +276,6 @@ pub const ExecutionEnvironment = enum {
}; };
pub const ImageConfig = struct { pub const ImageConfig = struct {
image_name: []const u8,
sector_count: u64, sector_count: u64,
sector_size: u16, sector_size: u16,
partition_table: PartitionTableType, partition_table: PartitionTableType,
@ -398,7 +397,7 @@ pub const UserProgram = struct {
}; };
}; };
pub const RiseProgram = enum { pub const BirthProgram = enum {
bootloader, bootloader,
cpu, cpu,
user, user,

View File

@ -16,7 +16,7 @@ const stopCPU = privileged.arch.stopCPU;
const VirtualAddress = privileged.VirtualAddress; const VirtualAddress = privileged.VirtualAddress;
const VirtualMemoryRegion = privileged.VirtualMemoryRegion; const VirtualMemoryRegion = privileged.VirtualMemoryRegion;
const rise = @import("rise"); const birth = @import("birth");
pub const test_runner = @import("cpu/test_runner.zig"); pub const test_runner = @import("cpu/test_runner.zig");
pub const arch = @import("cpu/arch.zig"); pub const arch = @import("cpu/arch.zig");
@ -67,10 +67,10 @@ pub const Driver = extern struct {
/// This data structure holds the information needed to run a program in a core (cpu side) /// This data structure holds the information needed to run a program in a core (cpu side)
pub const UserScheduler = extern struct { pub const UserScheduler = extern struct {
capability_root_node: capabilities.Root, capability_root_node: capabilities.Root,
common: *rise.UserScheduler, common: *birth.UserScheduler,
padding: [padding_byte_count]u8 = .{0} ** padding_byte_count, padding: [padding_byte_count]u8 = .{0} ** padding_byte_count,
const total_size = @sizeOf(capabilities.Root) + @sizeOf(*rise.UserScheduler); const total_size = @sizeOf(capabilities.Root) + @sizeOf(*birth.UserScheduler);
const aligned_size = lib.alignForward(usize, total_size, lib.arch.valid_page_sizes[0]); const aligned_size = lib.alignForward(usize, total_size, lib.arch.valid_page_sizes[0]);
const padding_byte_count = aligned_size - total_size; const padding_byte_count = aligned_size - total_size;

View File

@ -2,7 +2,7 @@ const bootloader = @import("bootloader");
const cpu = @import("cpu"); const cpu = @import("cpu");
const lib = @import("lib"); const lib = @import("lib");
const privileged = @import("privileged"); const privileged = @import("privileged");
const rise = @import("rise"); const birth = @import("birth");
const Allocator = lib.Allocator; const Allocator = lib.Allocator;
const assert = lib.assert; const assert = lib.assert;
@ -415,8 +415,8 @@ export var idt = x86_64.IDT{};
export var user_stack: u64 = 0; export var user_stack: u64 = 0;
comptime { comptime {
assert(rise.arch.user_code_selector == x86_64.user_code_selector); assert(birth.arch.user_code_selector == x86_64.user_code_selector);
assert(rise.arch.user_data_selector == x86_64.user_data_selector); assert(birth.arch.user_data_selector == x86_64.user_data_selector);
} }
pub fn InterruptHandler(comptime interrupt_number: u64, comptime has_error_code: bool) fn () callconv(.Naked) noreturn { pub fn InterruptHandler(comptime interrupt_number: u64, comptime has_error_code: bool) fn () callconv(.Naked) noreturn {
@ -934,7 +934,7 @@ fn spawnInitBSP(init_file: []const u8, cpu_page_tables: paging.CPUPageTables) !n
scheduler_common_arch.disabled_save_area.registers.rsi = @intFromBool(is_init); scheduler_common_arch.disabled_save_area.registers.rsi = @intFromBool(is_init);
scheduler_common_arch.disabled_save_area.registers.rip = entry_point; // Set entry point scheduler_common_arch.disabled_save_area.registers.rip = entry_point; // Set entry point
scheduler_common_arch.disabled_save_area.registers.rsp = user_scheduler_virtual_address.offset(@offsetOf(rise.UserScheduler, "setup_stack")).value() + scheduler_common_arch.generic.setup_stack.len; scheduler_common_arch.disabled_save_area.registers.rsp = user_scheduler_virtual_address.offset(@offsetOf(birth.UserScheduler, "setup_stack")).value() + scheduler_common_arch.generic.setup_stack.len;
scheduler_common.setup_stack_lock.value = true; scheduler_common.setup_stack_lock.value = true;
scheduler_common_arch.disabled_save_area.registers.rflags = .{ .IF = true }; // Set RFLAGS scheduler_common_arch.disabled_save_area.registers.rflags = .{ .IF = true }; // Set RFLAGS
@ -1452,7 +1452,7 @@ fn spawnInitCommon(cpu_page_tables: paging.CPUPageTables) !SpawnInitCommonResult
}); });
init_cpu_scheduler.* = cpu.UserScheduler{ init_cpu_scheduler.* = cpu.UserScheduler{
.common = user_scheduler_virtual_address.access(*rise.UserScheduler), .common = user_scheduler_virtual_address.access(*birth.UserScheduler),
.capability_root_node = cpu.capabilities.Root{ .capability_root_node = cpu.capabilities.Root{
.static = .{ .static = .{
.cpu = true, .cpu = true,
@ -1478,7 +1478,7 @@ fn spawnInitCommon(cpu_page_tables: paging.CPUPageTables) !SpawnInitCommonResult
}, },
}; };
const higher_half_scheduler_common = scheduler_memory_physical_region.address.toHigherHalfVirtualAddress().access(*rise.UserScheduler); const higher_half_scheduler_common = scheduler_memory_physical_region.address.toHigherHalfVirtualAddress().access(*birth.UserScheduler);
// log.debug("Higher half: 0x{x}", .{@ptrToInt(higher_half_scheduler_common)}); // log.debug("Higher half: 0x{x}", .{@ptrToInt(higher_half_scheduler_common)});
higher_half_scheduler_common.disabled = true; higher_half_scheduler_common.disabled = true;
higher_half_scheduler_common.core_id = cpu.core_id; higher_half_scheduler_common.core_id = cpu.core_id;

View File

@ -2,7 +2,7 @@ const cpu = @import("cpu");
const lib = @import("lib"); const lib = @import("lib");
const log = lib.log; const log = lib.log;
const privileged = @import("privileged"); const privileged = @import("privileged");
const rise = @import("rise"); const birth = @import("birth");
const assert = lib.assert; const assert = lib.assert;
@ -24,11 +24,11 @@ const pcid_mask = 1 << pcid_bit;
/// - R10: argument 3 /// - R10: argument 3
/// - R8: argument 4 /// - R8: argument 4
/// - R9: argument 5 /// - R9: argument 5
fn riseSyscall(comptime Syscall: type, raw_arguments: rise.syscall.Arguments) Syscall.ErrorSet.Error!Syscall.Result { fn birthSyscall(comptime Syscall: type, raw_arguments: birth.syscall.Arguments) Syscall.ErrorSet.Error!Syscall.Result {
cpu.syscall_count += 1; cpu.syscall_count += 1;
comptime assert(Syscall == rise.capabilities.Syscall(Syscall.capability, Syscall.command)); comptime assert(Syscall == birth.capabilities.Syscall(Syscall.capability, Syscall.command));
const capability: rise.capabilities.Type = Syscall.capability; const capability: birth.capabilities.Type = Syscall.capability;
const command: rise.capabilities.Command(capability) = Syscall.command; const command: birth.capabilities.Command(capability) = Syscall.command;
const arguments = try Syscall.toArguments(raw_arguments); const arguments = try Syscall.toArguments(raw_arguments);
return if (cpu.user_scheduler.capability_root_node.hasPermissions(capability, command)) switch (capability) { return if (cpu.user_scheduler.capability_root_node.hasPermissions(capability, command)) switch (capability) {
@ -78,16 +78,16 @@ fn riseSyscall(comptime Syscall: type, raw_arguments: rise.syscall.Arguments) Sy
} else error.forbidden; } else error.forbidden;
} }
export fn syscall(registers: *const Registers) callconv(.C) rise.syscall.Result { export fn syscall(registers: *const Registers) callconv(.C) birth.syscall.Result {
const options = @as(rise.syscall.Options, @bitCast(registers.syscall_number)); const options = @as(birth.syscall.Options, @bitCast(registers.syscall_number));
const arguments = rise.syscall.Arguments{ registers.rdi, registers.rsi, registers.rdx, registers.r10, registers.r8, registers.r9 }; const arguments = birth.syscall.Arguments{ registers.rdi, registers.rsi, registers.rdx, registers.r10, registers.r8, registers.r9 };
return switch (options.general.convention) { return switch (options.general.convention) {
.rise => switch (options.rise.type) { .birth => switch (options.birth.type) {
inline else => |capability| switch (@as(rise.capabilities.Command(capability), @enumFromInt(options.rise.command))) { inline else => |capability| switch (@as(birth.capabilities.Command(capability), @enumFromInt(options.birth.command))) {
inline else => |command| blk: { inline else => |command| blk: {
const Syscall = rise.capabilities.Syscall(capability, command); const Syscall = birth.capabilities.Syscall(capability, command);
const result: Syscall.Result = riseSyscall(Syscall, arguments) catch |err| break :blk Syscall.errorToRaw(err); const result: Syscall.Result = birthSyscall(Syscall, arguments) catch |err| break :blk Syscall.errorToRaw(err);
break :blk Syscall.resultToRaw(result); break :blk Syscall.resultToRaw(result);
}, },
}, },

View File

@ -26,7 +26,7 @@ const init = @import("./x86/64/init.zig");
pub const syscall = @import("./x86/64/syscall.zig"); pub const syscall = @import("./x86/64/syscall.zig");
pub const entryPoint = init.entryPoint; pub const entryPoint = init.entryPoint;
const rise = @import("rise"); const birth = @import("birth");
var writer_lock: Spinlock = .released; var writer_lock: Spinlock = .released;

View File

@ -7,7 +7,7 @@ const log = lib.log.scoped(.capabilities);
const privileged = @import("privileged"); const privileged = @import("privileged");
const PhysicalAddress = lib.PhysicalAddress; const PhysicalAddress = lib.PhysicalAddress;
const PhysicalMemoryRegion = lib.PhysicalMemoryRegion; const PhysicalMemoryRegion = lib.PhysicalMemoryRegion;
const rise = @import("rise"); const birth = @import("birth");
const cpu = @import("cpu"); const cpu = @import("cpu");
pub const RootDescriptor = extern struct { pub const RootDescriptor = extern struct {
@ -149,7 +149,7 @@ pub const Scheduler = extern struct {
}; };
comptime { comptime {
assert(enumCount(Dynamic) + enumCount(Static) == enumCount(rise.capabilities.Type)); assert(enumCount(Dynamic) + enumCount(Static) == enumCount(birth.capabilities.Type));
} }
pub const Root = extern struct { pub const Root = extern struct {
@ -174,7 +174,7 @@ pub const Root = extern struct {
other.dynamic = root.dynamic; other.dynamic = root.dynamic;
} }
pub inline fn hasPermissions(root: *const Root, comptime capability_type: rise.capabilities.Type, command: rise.capabilities.Command(capability_type)) bool { pub inline fn hasPermissions(root: *const Root, comptime capability_type: birth.capabilities.Type, command: birth.capabilities.Command(capability_type)) bool {
return switch (capability_type) { return switch (capability_type) {
// static capabilities // static capabilities
inline .cpu, inline .cpu,

View File

@ -210,7 +210,7 @@ pub fn main() anyerror!void {
.buffer = host.ArrayList(u8).init(wrapped_allocator.zigUnwrap()), .buffer = host.ArrayList(u8).init(wrapped_allocator.zigUnwrap()),
}; };
try limine_cfg_generator.addField("TIMEOUT", "0"); try limine_cfg_generator.addField("TIMEOUT", "0");
try limine_cfg_generator.addEntryName("Rise"); try limine_cfg_generator.addEntryName("Birth");
try limine_cfg_generator.addField("PROTOCOL", "limine"); try limine_cfg_generator.addField("PROTOCOL", "limine");
try limine_cfg_generator.addField("DEFAULT_ENTRY", "0"); try limine_cfg_generator.addField("DEFAULT_ENTRY", "0");
try limine_cfg_generator.addField("KERNEL_PATH", try lib.concat(wrapped_allocator.zigUnwrap(), u8, &.{ "boot:///", loader_fat_path })); try limine_cfg_generator.addField("KERNEL_PATH", try lib.concat(wrapped_allocator.zigUnwrap(), u8, &.{ "boot:///", loader_fat_path }));
@ -233,7 +233,7 @@ pub fn main() anyerror!void {
else => unreachable, else => unreachable,
} }
}, },
.rise => switch (configuration.boot_protocol) { .birth => switch (configuration.boot_protocol) {
.bios => { .bios => {
const partition_first_usable_lba = gpt_partition_cache.gpt.header.first_usable_lba; const partition_first_usable_lba = gpt_partition_cache.gpt.header.first_usable_lba;
assert((fat_partition_cache.partition_range.first_lba - partition_first_usable_lba) * disk.sector_size > lib.alignForward(usize, loader_file.len, disk.sector_size)); assert((fat_partition_cache.partition_range.first_lba - partition_first_usable_lba) * disk.sector_size > lib.alignForward(usize, loader_file.len, disk.sector_size));

View File

@ -402,7 +402,7 @@ const limine_unique_partition_guid = GUID{
const FilesystemCacheTypes = blk: { const FilesystemCacheTypes = blk: {
var types: [Filesystem.Type.count]type = undefined; var types: [Filesystem.Type.count]type = undefined;
types[@intFromEnum(Filesystem.Type.rise)] = void; types[@intFromEnum(Filesystem.Type.birth)] = void;
types[@intFromEnum(Filesystem.Type.ext2)] = void; types[@intFromEnum(Filesystem.Type.ext2)] = void;
types[@intFromEnum(Filesystem.Type.fat32)] = FAT32.Cache; types[@intFromEnum(Filesystem.Type.fat32)] = FAT32.Cache;

View File

@ -3,9 +3,9 @@ const log = lib.log;
const assert = lib.assert; const assert = lib.assert;
const ExecutionMode = lib.Syscall.ExecutionMode; const ExecutionMode = lib.Syscall.ExecutionMode;
const rise = @import("rise"); const birth = @import("birth");
const capabilities = rise.capabilities; const capabilities = birth.capabilities;
pub const Syscall = rise.capabilities.Syscall; pub const Syscall = birth.capabilities.Syscall;
pub const arch = @import("user/arch.zig"); pub const arch = @import("user/arch.zig");
const core_state = @import("user/core_state.zig"); const core_state = @import("user/core_state.zig");
@ -75,7 +75,7 @@ fn schedulerInitDisabled(scheduler: *arch.Scheduler) void {
} }
pub var is_init = false; pub var is_init = false;
pub var command_buffer: rise.CommandBuffer = undefined; pub var command_buffer: birth.CommandBuffer = undefined;
pub export fn start(scheduler: *arch.Scheduler, arg_init: bool) callconv(.C) noreturn { pub export fn start(scheduler: *arch.Scheduler, arg_init: bool) callconv(.C) noreturn {
assert(arg_init); assert(arg_init);
@ -89,7 +89,7 @@ pub export fn start(scheduler: *arch.Scheduler, arg_init: bool) callconv(.C) nor
Syscall(.cpu, .shutdown).blocking({}) catch unreachable; Syscall(.cpu, .shutdown).blocking({}) catch unreachable;
} }
// export fn riseInitializeDisabled(scheduler: *arch.Scheduler, arg_init: bool) callconv(.C) noreturn { // export fn birthInitializeDisabled(scheduler: *arch.Scheduler, arg_init: bool) callconv(.C) noreturn {
// // TODO: delete when this code is unnecessary. In the meanwhile it counts as a sanity check // // TODO: delete when this code is unnecessary. In the meanwhile it counts as a sanity check
// assert(arg_init); // assert(arg_init);
// is_init = arg_init; // is_init = arg_init;

View File

@ -1,12 +1,12 @@
const lib = @import("lib"); const lib = @import("lib");
const log = lib.log; const log = lib.log;
const assert = lib.assert; const assert = lib.assert;
const rise = @import("rise"); const birth = @import("birth");
const user = @import("user"); const user = @import("user");
const FPU = rise.arch.FPU; const FPU = birth.arch.FPU;
const Registers = rise.arch.Registers; const Registers = birth.arch.Registers;
const RegisterArena = rise.arch.RegisterArena; const RegisterArena = birth.arch.RegisterArena;
const VirtualAddress = lib.VirtualAddress; const VirtualAddress = lib.VirtualAddress;
@ -17,7 +17,7 @@ const Thread = user.Thread;
const VirtualAddressSpace = user.VirtualAddressSpace; const VirtualAddressSpace = user.VirtualAddressSpace;
pub const Scheduler = extern struct { pub const Scheduler = extern struct {
common: rise.arch.UserScheduler, common: birth.arch.UserScheduler,
generic: user.Scheduler, generic: user.Scheduler,
pub fn initDisabled(scheduler: *Scheduler) void { pub fn initDisabled(scheduler: *Scheduler) void {
@ -50,7 +50,7 @@ pub fn _start() callconv(.Naked) noreturn {
unreachable; unreachable;
} }
pub inline fn setInitialState(register_arena: *RegisterArena, entry: VirtualAddress, stack_virtual_address: VirtualAddress, arguments: rise.syscall.Arguments) void { pub inline fn setInitialState(register_arena: *RegisterArena, entry: VirtualAddress, stack_virtual_address: VirtualAddress, arguments: birth.syscall.Arguments) void {
assert(stack_virtual_address.value() > lib.arch.valid_page_sizes[0]); assert(stack_virtual_address.value() > lib.arch.valid_page_sizes[0]);
assert(lib.isAligned(stack_virtual_address.value(), lib.arch.stack_alignment)); assert(lib.isAligned(stack_virtual_address.value(), lib.arch.stack_alignment));
var stack_address = stack_virtual_address; var stack_address = stack_virtual_address;

View File

@ -1,18 +1,20 @@
const lib = @import("lib"); const lib = @import("lib");
const assert = lib.assert; const assert = lib.assert;
const rise = @import("rise"); const birth = @import("birth");
// TODO: ref // TODO: ref
pub fn frameCreate(ref: usize, bytes: usize) !usize { pub fn frameCreate(ref: usize, bytes: usize) !usize {
return mappableCapabilityCreate(ref, .cpu_memory, bytes); return mappableCapabilityCreate(ref, .cpu_memory, bytes);
} }
fn mappableCapabilityCreate(ref: usize, mappable_capability: rise.capabilities.Type.Mappable, bytes: usize) !usize { fn mappableCapabilityCreate(ref: usize, mappable_capability: birth.capabilities.Type.Mappable, bytes: usize) !usize {
_ = mappable_capability; _ = mappable_capability;
_ = ref; _ = ref;
assert(bytes > 0); assert(bytes > 0);
} }
fn ramDescendantCreate(ref: usize, ) !usize { fn ramDescendantCreate(
ref: usize,
) !usize {
_ = ref; _ = ref;
} }

View File

@ -1,7 +1,7 @@
const lib = @import("lib"); const lib = @import("lib");
const log = lib.log.scoped(.thread); const log = lib.log.scoped(.thread);
const user = @import("user"); const user = @import("user");
const rise = @import("rise"); const birth = @import("birth");
const MoreCore = user.MoreCore; const MoreCore = user.MoreCore;
const MMUAwareVirtualAddressSpace = user.MMUAwareVirtualAddressSpace; const MMUAwareVirtualAddressSpace = user.MMUAwareVirtualAddressSpace;
@ -17,7 +17,7 @@ pub const Thread = extern struct {
next: ?*Thread, next: ?*Thread,
stack: [*]u8, stack: [*]u8,
stack_top: [*]align(lib.arch.stack_alignment) u8, stack_top: [*]align(lib.arch.stack_alignment) u8,
register_arena: rise.arch.RegisterArena align(lib.arch.stack_alignment), register_arena: birth.arch.RegisterArena align(lib.arch.stack_alignment),
core_id: u32, core_id: u32,
pub fn init(thread: *Thread, scheduler: *user.arch.Scheduler) void { pub fn init(thread: *Thread, scheduler: *user.arch.Scheduler) void {