Compare commits
No commits in common. "627150b17061fb503b543812958cde27dd189a35" and "0d10e698dad2db6bbf84731416df00685be9d647" have entirely different histories.
627150b170
...
0d10e698da
|
|
@ -1 +0,0 @@
|
||||||
usingnamespace @import("../x86/x86.zig");
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
const std = @import("std");
|
|
||||||
const cpuid_c = @cImport(@cInclude("cpuid.h"));
|
|
||||||
|
|
||||||
const cpuid_ret = struct {
|
|
||||||
eax: u32,
|
|
||||||
ebx: u32,
|
|
||||||
ecx: u32,
|
|
||||||
edx: u32,
|
|
||||||
};
|
|
||||||
|
|
||||||
// static inline int cpuid_string(int code, uint32_t where[4]) {
|
|
||||||
// asm volatile("cpuid":"=a"(*where),"=b"(*(where+1)),
|
|
||||||
// "=c"(*(where+2)),"=d"(*(where+3)):"a"(code));
|
|
||||||
// return (int)where[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
fn getcpuid(leaf: u32) [4]u32 {
|
|
||||||
// cpuid_c.__cpuid(leaf, &ret.eax, &ret.ebx, &ret.ecx, &ret.edx);
|
|
||||||
var eax: u32 = undefined;
|
|
||||||
var ebx: u32 = undefined;
|
|
||||||
var ecx: u32 = undefined;
|
|
||||||
var edx: u32 = undefined;
|
|
||||||
asm volatile("cpuid"
|
|
||||||
: [eax] "={eax}" (eax),
|
|
||||||
[ebx] "={ebx}" (ebx),
|
|
||||||
[ecx] "={ecx}" (ecx),
|
|
||||||
[edx] "={edx}" (edx),
|
|
||||||
: [leaf] "{eax}" (leaf)
|
|
||||||
:
|
|
||||||
);
|
|
||||||
std.log.info("cpuid {x}: {x} {x} {x} {x}", .{leaf, eax, ebx, ecx, edx});
|
|
||||||
return .{eax, ebx, ecx, edx};
|
|
||||||
}
|
|
||||||
|
|
||||||
var vendor: [12]u8 = undefined;
|
|
||||||
pub fn getVendor() [12]u8 {
|
|
||||||
const v = getcpuid(0);
|
|
||||||
@memcpy(@ptrCast([*]u8, &vendor[0]), @ptrCast([*]const u8, &v[1]), 4);
|
|
||||||
@memcpy(@ptrCast([*]u8, &vendor[4]), @ptrCast([*]const u8, &v[3]), 4);
|
|
||||||
@memcpy(@ptrCast([*]u8, &vendor[8]), @ptrCast([*]const u8, &v[2]), 4);
|
|
||||||
std.log.notice("CPU vendor: {}", .{std.mem.span(&vendor)});
|
|
||||||
return vendor;
|
|
||||||
}
|
|
||||||
|
|
||||||
var name: [48]u8 = undefined;
|
|
||||||
pub fn getName() []u8 {
|
|
||||||
var i: u32 = 0x80000002;
|
|
||||||
while(i <= 0x80000004) : (i+=1) {
|
|
||||||
const v = getcpuid(i);
|
|
||||||
@memcpy(@ptrCast([*]u8, &name[(i-0x80000002)*16]), @ptrCast([*]const u8, &v), 16);
|
|
||||||
}
|
|
||||||
std.log.notice("CPU model name: {}", .{std.mem.span(&name)});
|
|
||||||
return std.mem.span(&name);
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
pub const cpuid = @import("cpuid.zig");
|
|
||||||
|
|
@ -5,21 +5,20 @@ const c_idt = @cImport(@cInclude("arch/x86_64/idt.h"));
|
||||||
export const int_msg = "INTERRUPTED!\n";
|
export const int_msg = "INTERRUPTED!\n";
|
||||||
|
|
||||||
comptime {
|
comptime {
|
||||||
asm(
|
@setEvalBranchQuota(2560000);
|
||||||
\\.macro isr_wrapperX number
|
comptime var i = 0;
|
||||||
\\ isr_wrapper\number:
|
var buf: [512]u8 = undefined;
|
||||||
\\ mov $\number, %rdi
|
inline while (i < 256) : (i += 1) {
|
||||||
\\ call interrupt_handler
|
const code = std.fmt.bufPrint(buf[0..512],
|
||||||
\\ iretq
|
\\.global isr_wrapper{}
|
||||||
\\.endm
|
\\.type isr_wrapper{}, @function
|
||||||
\\
|
\\isr_wrapper{}:
|
||||||
\\.altmacro
|
\\ mov ${}, %rdi
|
||||||
\\.set i,0
|
\\ call interrupt_handler
|
||||||
\\.rept 256
|
\\ iretq
|
||||||
\\ isr_wrapperX %i
|
, .{i,i,i,i}) catch unreachable;
|
||||||
\\ .set i,i+1
|
asm (code);
|
||||||
\\.endr
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn interrupt_handler(int_type: u64) void {
|
export fn interrupt_handler(int_type: u64) void {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
usingnamespace @import("../x86/x86.zig");
|
const x86 = @import("src/arch/x86/x86.zig");
|
||||||
pub const paging = @import("paging.zig");
|
pub const paging = @import("paging.zig");
|
||||||
pub const interrupt = @import("interrupt.zig");
|
pub const interrupt = @import("interrupt.zig");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue