Skip to content

Commit

Permalink
mrr
Browse files Browse the repository at this point in the history
Signed-off-by: TalonFloof <[email protected]>
  • Loading branch information
TalonFloof committed Nov 25, 2024
1 parent 3534cc6 commit 9baeda2
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 26 deletions.
21 changes: 21 additions & 0 deletions kobold/hal/alarmqueue.zig
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,24 @@ pub const AlarmQueue = struct {
}
}
};

fn aqCommand(cmd: []const u8, iter: *std.mem.SplitIterator(u8, .sequence)) void {
_ = cmd;
var hartID = hal.arch.getHart().hartID;
if (iter.next()) |idStr| {
hartID = std.fmt.parseInt(usize, idStr, 0) catch hartID;
}
const hart = hal.hiList.?[hartID];
std.log.debug("Hart #{} AlarmQueue:\n Elapsed {} us\n NextInterval {} us\n", .{ hartID, hart.alarmQueue.timerCounter, hart.alarmQueue.timerNextInterval });
var n = hart.alarmQueue.list.first;
while (n) |node| {
std.log.debug(" 0x{x}: Deadline {} us Data 0x{x}\n Func 0x{x} ", .{ @intFromPtr(node), node.data.deadline, @intFromPtr(node.data.data), @intFromPtr(node.data.func) });
hal.debug.file.PrintSymbolName(@intFromPtr(node.data.func));
std.log.debug("\n", .{});
n = node.next;
}
}

pub fn initDebug() void {
hal.debug.NewDebugCommand("alarmQueue", "Dumps the pending events on a Hart's AlarmQueue", &aqCommand);
}
2 changes: 2 additions & 0 deletions kobold/hal/hal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub const arch: ArchInterface = archData.Interface;
pub const HartInfo = @import("hart.zig").HartInfo;
pub const memmodel = @import("memmodel.zig");
pub const debug = @import("debug/debug.zig");
const alarmqueue = @import("alarmqueue.zig");

pub const Writer = std.io.Writer(@TypeOf(.{}), error{}, arch.write);
pub const writer = Writer{ .context = .{} };
Expand All @@ -37,6 +38,7 @@ pub export fn HALInitialize(stackTop: usize, dtb: *allowzero anyopaque) callconv
arch.init(stackTop, dtb);
if (arch.memModel.layout == .Flat)
@panic("MMUless setups are not supported!");
alarmqueue.initDebug();
team.Init();
thread.Init();
_ = thread.NewThread(team.kteam.?, "Kobold Initialization Thread", @intFromPtr(&root.KoboldInit), null, 16);
Expand Down
1 change: 1 addition & 0 deletions kobold/kernel/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub fn panic(msg: []const u8, stacktrace: ?*std.builtin.StackTrace, retAddr: ?us
pub export fn KoboldInit() void {
_ = hal.AlignDown(u32, 0, 4096); // Prevents release builds from failing
std.log.info("Scheduling Started", .{});
hal.HALOops("Intentionally Triggered Oops");
while (true) {
hal.arch.waitForInt();
}
Expand Down
29 changes: 10 additions & 19 deletions kobold/kernel/vfs.zig
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
const std = @import("std");
const RedBlackTree = @import("perlib").RedBlackTree;
const fs = @import("perlib").fs;
pub const Scheme = fs.Scheme;
pub const Metadata = fs.Metadata;
pub const DirEntry = fs.DirEntry;

pub const DirEntry = struct {
entryType: u8,
name: [256]u8 = [_]u8{0} ** 256,
}

pub const Scheme = struct {
protocolName: [32]u8 = [_]u8{0} ** 32,
open: ?*fn ([]const u8, u16, *usize) c_long = null,
close: ?*fn (usize) c_long = null,
read: ?*fn (usize, []u8, usize) c_long = null,
readdir: ?*fn (usize, usize, *DirEntry) c_long = null,
write: ?*fn (usize, []const u8, usize) c_long = null,
ftruncate: ?*fn (usize, usize) c_long = null,
lseek: ?*fn (usize, isize, usize, ?*usize) c_long = null,
fstat: ?*fn (usize, *Metadata) c_long = null,
unlink: ?*fn (usize, []const u8) c_long = null,
rmdir: ?*fn (usize, []const u8) c_long = null,
};
// root:/
const SchemeTreeType = RedBlackTree(*Scheme, struct {
fn compare(a: *Scheme, b: *Scheme) std.math.Order {
return std.mem.order(u8, a.protocolName, b.protocolName);
}
}.compare);
40 changes: 40 additions & 0 deletions kobold/perLib/fs.zig
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
const std = @import("std");

pub const Metadata = extern struct {
mode: u32 = 0,
uid: u32 = 1,
gid: u32 = 1,
inode: usize = 0,
nlinks: u32 = 0,
size: usize = 0,
blockSize: usize = 0,
atime: i64 = 0,
reserved1: u64 = 0,
mtime: i64 = 0,
reserved2: u64 = 0,
ctime: i64 = 0,
reserved3: u64 = 0,
rdevmajor: u32 = 0,
rdevminor: u32 = 0,
blocksUsed: usize = 0,
};

pub const DirEntry = struct {
entryType: u8,
name: [256]u8 = [_]u8{0} ** 256,
};

pub const Scheme = struct {
protocolName: [32]u8 = [_]u8{0} ** 32,
open: ?*fn ([]const u8, u16, *usize) c_long = null,
close: ?*fn (usize) c_long = null,
read: ?*fn (usize, []u8, usize) c_long = null,
readdir: ?*fn (usize, usize, *DirEntry) c_long = null,
write: ?*fn (usize, []const u8, usize) c_long = null,
truncate: ?*fn (usize, usize) c_long = null,
lseek: ?*fn (usize, isize, usize, ?*usize) c_long = null,
fstat: ?*fn (usize, *Metadata) c_long = null,
fsync: ?*fn (usize) c_long = null,
unlink: ?*fn (usize, []const u8) c_long = null,
rmdir: ?*fn (usize, []const u8) c_long = null,
ioctl: ?*fn (usize, usize, ?[*c]?*anyopaque) c_long = null, // ?[*c]?*anyopaque = **void
};
2 changes: 2 additions & 0 deletions kobold/perLib/perlib.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const std = @import("std");
pub const Spinlock = @import("spinlock.zig").Spinlock;
pub const RedBlackTree = @import("rbtree.zig").RedBlackTree;
pub const fs = @import("fs.zig");

pub const KernelCall = enum {
Log,
Expand All @@ -13,6 +14,7 @@ pub const KernelCall = enum {
IRQFree,
FindPersonality,
GetDeviceTree, // ACPI-based systems will return the RSDP when you use this, otherwise return a parsed device tree
GetFramebuffer, // Optional, not all HALs will provide a result to this
IsACPIBased,
Sleep,
Stall,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 7 additions & 4 deletions kobold/personalities/PersonalityList/universal
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
PCI
ext2FS
DevFS
KoboldFS
USBStack
HIDStack
UserIPC
DiskScheme
HIDScheme
UserIPCScheme
NVMe
USBHID
USBMass
USBMass
UNIXFileScheme
SoundScheme
FramebufferScheme
6 changes: 3 additions & 3 deletions kobold/personalities/PersonalityList/x86_64-pc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ACPI
i8042HID
AHCI
PcUHCI
PcXHCI
ATA
UHCI
xHCI
IDE
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
2 changes: 2 additions & 0 deletions scripts/generateDebugFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
symbol = line.rstrip("\n").split(" ")
if len(symbol) == 1:
curFile = symbol[0].rstrip(":").split("/")[-1]
if curFile[-2:] == ".o":
curFile = curFile[:-2]
if len(curFile) > 0 and files.get(symbol[0]) == None:
files[curFile] = []
elif len(symbol) >= 4:
Expand Down

0 comments on commit 9baeda2

Please sign in to comment.