aboutsummaryrefslogtreecommitdiff
path: root/mirai/crimson/classify/analyze.zig
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-27 18:52:18 +0530
committerBobby <[email protected]>2026-03-27 18:52:18 +0530
commitb45cfb5ede9f1a3dd7f7323bd218a4dcaaf76b76 (patch)
tree7ea4ab655b3c37cd2a5d35d21a228b763ba413aa /mirai/crimson/classify/analyze.zig
parentaec48b60740d9ea7060da6d494e3cf95b1aa8e18 (diff)
downloadakiba-b45cfb5ede9f1a3dd7f7323bd218a4dcaaf76b76.tar.xz
akiba-b45cfb5ede9f1a3dd7f7323bd218a4dcaaf76b76.zip
Refactor and implement interrupt handling and PIT driver
- Refactored CPU context structure for better readability. - Enhanced corpse and exception structures with clearer formatting. - Improved frame structure for consistency. - Added interrupt flag operations for enabling and disabling interrupts. - Implemented IDT (Interrupt Descriptor Table) operations including loading and setting gates. - Created PIC (Programmable Interrupt Controller) initialization and masking functions. - Developed PIT (Programmable Interval Timer) driver with initialization and handler functions. - Established common interrupt handler structure and exception handling stubs. - Added hardware IRQ handling for IRQs 0-15. - Introduced IDT entry and gate descriptor types for better organization. - Ensured proper handling of interrupt and exception vectors.
Diffstat (limited to 'mirai/crimson/classify/analyze.zig')
-rw-r--r--mirai/crimson/classify/analyze.zig29
1 files changed, 22 insertions, 7 deletions
diff --git a/mirai/crimson/classify/analyze.zig b/mirai/crimson/classify/analyze.zig
index e4287a4..b7c9818 100644
--- a/mirai/crimson/classify/analyze.zig
+++ b/mirai/crimson/classify/analyze.zig
@@ -1,16 +1,29 @@
//! Analyze Error Codes
pub const PageFaultError = struct {
- present: bool, write: bool, user: bool, reserved_write: bool, instruction_fetch: bool,
+ present: bool,
+ write: bool,
+ user: bool,
+ reserved_write: bool,
+ instruction_fetch: bool,
pub fn from_error_code(code: u64) PageFaultError {
return PageFaultError{
- .present = (code & 1) != 0, .write = (code & 2) != 0, .user = (code & 4) != 0,
- .reserved_write = (code & 8) != 0, .instruction_fetch = (code & 16) != 0,
+ .present = (code & 1) != 0,
+ .write = (code & 2) != 0,
+ .user = (code & 4) != 0,
+ .reserved_write = (code & 8) != 0,
+ .instruction_fetch = (code & 16) != 0,
};
}
- pub fn is_not_present(self: PageFaultError) bool { return !self.present; }
- pub fn is_write_access(self: PageFaultError) bool { return self.write; }
- pub fn is_execute_access(self: PageFaultError) bool { return self.instruction_fetch; }
+ pub fn is_not_present(self: PageFaultError) bool {
+ return !self.present;
+ }
+ pub fn is_write_access(self: PageFaultError) bool {
+ return self.write;
+ }
+ pub fn is_execute_access(self: PageFaultError) bool {
+ return self.instruction_fetch;
+ }
pub fn description(self: PageFaultError) []const u8 {
if (self.instruction_fetch) return if (self.present) "Execute on non-executable page" else "Execute on non-present page";
if (self.write) return if (self.present) "Write to read-only page" else "Write to non-present page";
@@ -19,7 +32,9 @@ pub const PageFaultError = struct {
};
pub const SelectorError = struct {
- external: bool, table: u2, index: u13,
+ external: bool,
+ table: u2,
+ index: u13,
pub fn from_error_code(code: u64) SelectorError {
return SelectorError{ .external = (code & 1) != 0, .table = @truncate((code >> 1) & 0x3), .index = @truncate((code >> 3) & 0x1FFF) };
}