From 14538777ff7645d51d27a239739c5335180ae947 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 15 Apr 2025 22:49:12 -0400 Subject: public cpu_print_regs fn --- kernel/cpu/cpu.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'kernel/cpu/cpu.c') diff --git a/kernel/cpu/cpu.c b/kernel/cpu/cpu.c index a77baac..df0b34f 100644 --- a/kernel/cpu/cpu.c +++ b/kernel/cpu/cpu.c @@ -1,3 +1,5 @@ +#include +#include #include "fpu.h" #include "pic.h" @@ -9,3 +11,64 @@ void cpu_init(void) idt_init(); fpu_init(); } + +void cpu_print_regs(struct cpu_regs *regs) +{ + kprintf("rax: %#016lx (%lu)\n", regs->rax, regs->rax); + kprintf("rbx: %#016lx (%lu)\n", regs->rbx, regs->rbx); + kprintf("rcx: %#016lx (%lu)\n", regs->rcx, regs->rcx); + kprintf("rdx: %#016lx (%lu)\n", regs->rdx, regs->rdx); + kprintf("rsi: %#016lx (%lu)\n", regs->rsi, regs->rsi); + kprintf("rdi: %#016lx (%lu)\n", regs->rdi, regs->rdi); + kprintf("rsp: %#016lx (%lu)\n", regs->rsp, regs->rsp); + kprintf("rbp: %#016lx (%lu)\n", regs->rbp, regs->rbp); + kprintf("r8 : %#016lx (%lu)\n", regs->r8, regs->r8); + kprintf("r9 : %#016lx (%lu)\n", regs->r9, regs->r9); + kprintf("r10: %#016lx (%lu)\n", regs->r10, regs->r10); + kprintf("r11: %#016lx (%lu)\n", regs->r11, regs->r11); + kprintf("r12: %#016lx (%lu)\n", regs->r12, regs->r12); + kprintf("r13: %#016lx (%lu)\n", regs->r13, regs->r13); + kprintf("r14: %#016lx (%lu)\n", regs->r14, regs->r14); + kprintf("r15: %#016lx (%lu)\n", regs->r15, regs->r15); + kprintf("rip: %#016lx (%lu)\n", regs->rip, regs->rip); + kprintf("rflags: %#016lx (%lu)\n", (uint64_t)regs->rflags.raw, + (uint64_t)regs->rflags.raw); + kputs("rflags: "); + if (regs->rflags.cf) + kputs("CF "); + if (regs->rflags.pf) + kputs("PF "); + if (regs->rflags.af) + kputs("AF "); + if (regs->rflags.zf) + kputs("ZF "); + if (regs->rflags.sf) + kputs("SF "); + if (regs->rflags.tf) + kputs("TF "); + if (regs->rflags.if_) + kputs("IF "); + if (regs->rflags.df) + kputs("DF "); + if (regs->rflags.of) + kputs("OF "); + if (regs->rflags.iopl) + kputs("IOPL "); + if (regs->rflags.nt) + kputs("NT "); + if (regs->rflags.md) + kputs("MD "); + if (regs->rflags.rf) + kputs("RF "); + if (regs->rflags.vm) + kputs("VM "); + if (regs->rflags.ac) + kputs("AC "); + if (regs->rflags.vif) + kputs("VIF "); + if (regs->rflags.vip) + kputs("VIP "); + if (regs->rflags.id) + kputs("ID "); + kputs("\n"); +} -- cgit v1.2.3-freya From a18fd19647c08e8467440e0262b725e17ff5c5b0 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Wed, 16 Apr 2025 16:48:12 -0400 Subject: add support for cpu feature checking, see, and avx --- build.zig | 1 - kernel/cpu/cpu.c | 203 ++++++++++++++++++++++++++++++++++++++++----- kernel/cpu/fpu.c | 13 --- kernel/cpu/fpu.h | 14 ---- kernel/include/comus/cpu.h | 65 +++++++++------ 5 files changed, 219 insertions(+), 77 deletions(-) delete mode 100644 kernel/cpu/fpu.c delete mode 100644 kernel/cpu/fpu.h (limited to 'kernel/cpu/cpu.c') diff --git a/build.zig b/build.zig index cd969f8..da70ba1 100644 --- a/build.zig +++ b/build.zig @@ -24,7 +24,6 @@ const kernel_src = &[_][]const u8{ "kernel/entry.S", // must be first "kernel/main.c", // main function "kernel/cpu/cpu.c", - "kernel/cpu/fpu.c", "kernel/cpu/idt.c", "kernel/cpu/idt.S", "kernel/cpu/pic.c", diff --git a/kernel/cpu/cpu.c b/kernel/cpu/cpu.c index df0b34f..3835b68 100644 --- a/kernel/cpu/cpu.c +++ b/kernel/cpu/cpu.c @@ -1,15 +1,174 @@ #include #include -#include "fpu.h" #include "pic.h" #include "idt.h" +static inline void fpu_init(void) +{ + size_t cr4; + uint16_t cw = 0x37F; + __asm__ volatile("mov %%cr4, %0" : "=r"(cr4)); + cr4 |= 0x200; + __asm__ volatile("mov %0, %%cr4" ::"r"(cr4)); + __asm__ volatile("fldcw %0" ::"m"(cw)); +} + +static inline void sse_init(void) +{ + size_t cr0, cr4; + __asm__ volatile("mov %%cr0, %0" : "=r"(cr0)); + cr0 &= ~0x4; // clear coprocessor emulation + cr0 |= 0x2; // set coprocessor monitoring + __asm__ volatile("mov %0, %%cr0" :: "r"(cr0)); + __asm__ volatile("mov %%cr4, %0" : "=r"(cr4)); + cr4 |= 1 << 9; // set CR4.OSFXSR + cr4 |= 1 << 10; // set CR4.OSXMMEXCPT + __asm__ volatile("mov %0, %%cr4" :: "r"(cr4)); +} + +static inline void fxsave_init(void) +{ + static char fxsave_region[512] __attribute__((aligned(16))); + __asm__ volatile("fxsave %0" :: "m"(fxsave_region)); +} + +static inline void xsave_init(void) +{ + size_t cr4; + __asm__ volatile("mov %%cr4, %0" : "=r"(cr4)); + cr4 |= 1 << 18; // set CR4.OSXSAVE + __asm__ volatile("mov %0, %%cr4" :: "r"(cr4)); +} + +static inline void avx_init(void) +{ + __asm__ volatile( + "pushq %rax;" + "pushq %rcx;" + "pushq %rdx;" + "xorq %rcx, %rcx;" + "xgetbv;" + "orq $7, %rax;" + "xsetbv;" + "popq %rdx;" + "popq %rcx;" + "popq %rax;" + ); +} + void cpu_init(void) { + struct cpu_feat feats; + cpu_feats(&feats); + pic_remap(); idt_init(); - fpu_init(); + if (feats.fpu) + fpu_init(); + if (feats.sse) { + sse_init(); + fxsave_init(); + } + if (feats.xsave) { + xsave_init(); + if (feats.avx) + avx_init(); + } +} + +void cpu_report(void) +{ + char vendor[12], name[48]; + struct cpu_feat feats; + + cpu_name(name); + cpu_vendor(vendor); + cpu_feats(&feats); + + kprintf("CPU\n"); + kprintf("Name: %.*s\n", 48, name); + kprintf("Vendor: %.*s\n", 12, vendor); + kputs("Features:"); + if (feats.fpu) + kputs(" FPU"); + if (feats.mmx) + kputs(" MMX"); + if (feats.sse) + kputs(" SSE"); + if (feats.sse2) + kputs(" SSE2"); + if (feats.sse3) + kputs(" SSE3"); + if (feats.ssse3) + kputs(" SSSE3"); + if (feats.sse41) + kputs(" SSE4.1"); + if (feats.sse42) + kputs(" SSE4.2"); + if (feats.sse4a) + kputs(" SSE4a"); + if (feats.avx) + kputs(" AVX"); + if (feats.xsave) + kputs(" XSAVE"); + if (feats.avx2) + kputs(" AVX2"); + if (feats.avx512) + kputs(" AVX-512"); + kputs("\n\n"); +} + +static inline void cpuid(uint32_t leaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) +{ + __asm__ volatile("cpuid" + : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + : "0" (leaf)); +} + +static inline void cpuid_count(uint32_t leaf, uint32_t subleaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) +{ + __asm__ volatile("cpuid" + : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + : "0" (leaf), "2" (subleaf)); +} + +void cpu_vendor(char vendor[12]) +{ + uint32_t ignore; + cpuid(0, &ignore, (uint32_t *)(vendor + 0), (uint32_t *)(vendor + 8), (uint32_t *)(vendor + 4)); +} + +void cpu_name(char name[48]) { + cpuid(0x80000002, (uint32_t *)(name + 0), (uint32_t *)(name + 4), (uint32_t *)(name + 8), (uint32_t *)(name + 12)); + cpuid(0x80000003, (uint32_t *)(name + 16), (uint32_t *)(name + 20), (uint32_t *)(name + 24), (uint32_t *)(name + 28)); + cpuid(0x80000004, (uint32_t *)(name + 32), (uint32_t *)(name + 36), (uint32_t *)(name + 40), (uint32_t *)(name + 44)); +} + +void cpu_feats(struct cpu_feat *feats) +{ + memset(feats, 0, sizeof(struct cpu_feat)); + + uint32_t ignore; + uint32_t ecx_1, edx_1; + uint32_t ebx_7; + + cpuid(1, &ignore, &ignore, &ecx_1, &edx_1); + cpuid_count(7, 0, &ignore, &ebx_7, &ignore, &ignore); + + feats->fpu = edx_1 & (1<<0) ? 1 : 0; + feats->mmx = edx_1 & (1<<23) ? 1 : 0; + feats->sse = edx_1 & (1<<25) ? 1 : 0; + feats->sse2 = edx_1 & (1<<26) ? 1 : 0; + feats->sse3 = ecx_1 & (1<<0) ? 1 : 0; + feats->ssse3 = ecx_1 & (1<<9) ? 1 : 0; + feats->sse41 = ecx_1 & (1<<19) ? 1 : 0; + feats->sse42 = ecx_1 & (1<<20) ? 1 : 0; + feats->sse4a = ecx_1 & (1<<6) ? 1 : 0; + feats->avx = ecx_1 & (1<<28) ? 1 : 0; + feats->xsave = ecx_1 & (1<<26) ? 1 : 0; + feats->avx2 = ebx_7 & (1<<5) ? 1 : 0; + feats->avx512 = ebx_7 & (7<<16) ? 1 : 0; } void cpu_print_regs(struct cpu_regs *regs) @@ -31,44 +190,44 @@ void cpu_print_regs(struct cpu_regs *regs) kprintf("r14: %#016lx (%lu)\n", regs->r14, regs->r14); kprintf("r15: %#016lx (%lu)\n", regs->r15, regs->r15); kprintf("rip: %#016lx (%lu)\n", regs->rip, regs->rip); - kprintf("rflags: %#016lx (%lu)\n", (uint64_t)regs->rflags.raw, - (uint64_t)regs->rflags.raw); + kprintf("rflags: %#016lx (%lu)\n", regs->rflags, regs->rflags); kputs("rflags: "); - if (regs->rflags.cf) + if (regs->rflags & (1<<0)) kputs("CF "); - if (regs->rflags.pf) + if (regs->rflags & (1<<2)) kputs("PF "); - if (regs->rflags.af) + if (regs->rflags & (1<<4)) kputs("AF "); - if (regs->rflags.zf) + if (regs->rflags & (1<<6)) kputs("ZF "); - if (regs->rflags.sf) + if (regs->rflags & (1<<7)) kputs("SF "); - if (regs->rflags.tf) + if (regs->rflags & (1<<8)) kputs("TF "); - if (regs->rflags.if_) + if (regs->rflags & (1<<9)) kputs("IF "); - if (regs->rflags.df) + if (regs->rflags & (1<<10)) kputs("DF "); - if (regs->rflags.of) + if (regs->rflags & (1<<11)) kputs("OF "); - if (regs->rflags.iopl) + if (regs->rflags & (3<<12)) kputs("IOPL "); - if (regs->rflags.nt) + if (regs->rflags & (1<<14)) kputs("NT "); - if (regs->rflags.md) + if (regs->rflags & (1<<15)) kputs("MD "); - if (regs->rflags.rf) + if (regs->rflags & (1<<16)) kputs("RF "); - if (regs->rflags.vm) + if (regs->rflags & (1<<17)) kputs("VM "); - if (regs->rflags.ac) + if (regs->rflags & (1<<18)) kputs("AC "); - if (regs->rflags.vif) + if (regs->rflags & (1<<19)) kputs("VIF "); - if (regs->rflags.vip) + if (regs->rflags & (1<<20)) kputs("VIP "); - if (regs->rflags.id) + if (regs->rflags & (1<<21)) kputs("ID "); kputs("\n"); } + diff --git a/kernel/cpu/fpu.c b/kernel/cpu/fpu.c deleted file mode 100644 index cafe6e5..0000000 --- a/kernel/cpu/fpu.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -#include "fpu.h" - -void fpu_init(void) -{ - size_t cr4; - uint16_t cw = 0x37F; - __asm__ volatile("mov %%cr4, %0" : "=r"(cr4)); - cr4 |= 0x200; - __asm__ volatile("mov %0, %%cr4" ::"r"(cr4)); - __asm__ volatile("fldcw %0" ::"m"(cw)); -} diff --git a/kernel/cpu/fpu.h b/kernel/cpu/fpu.h deleted file mode 100644 index edb4e81..0000000 --- a/kernel/cpu/fpu.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @file fpu.h - * - * @author Freya Murphy - * - * FPU functions - */ - -#ifndef FPU_H_ -#define FPU_H_ - -void fpu_init(void); - -#endif /* fpu.h */ diff --git a/kernel/include/comus/cpu.h b/kernel/include/comus/cpu.h index 9909a57..ffc1782 100644 --- a/kernel/include/comus/cpu.h +++ b/kernel/include/comus/cpu.h @@ -10,33 +10,24 @@ #define _CPU_H #include +#include -union cpu_rflags { - uint64_t raw; - struct { - uint64_t cf : 1; - uint64_t : 1; - uint64_t pf : 1; - uint64_t : 1; - uint64_t af : 1; - uint64_t : 1; - uint64_t zf : 1; - uint64_t sf : 1; - uint64_t tf : 1; - uint64_t if_ : 1; - uint64_t df : 1; - uint64_t of : 1; - uint64_t iopl : 2; - uint64_t nt : 1; - uint64_t md : 1; - uint64_t rf : 1; - uint64_t vm : 1; - uint64_t ac : 1; - uint64_t vif : 1; - uint64_t vip : 1; - uint64_t id : 1; - uint64_t : 42; - }; +struct cpu_feat { + // floating point + uint32_t fpu : 1; + // simd + uint32_t mmx : 1; + uint32_t sse : 1; + uint32_t sse2 : 1; + uint32_t sse3 : 1; + uint32_t ssse3 : 1; + uint32_t sse41 : 1; + uint32_t sse42 : 1; + uint32_t sse4a : 1; + uint32_t avx : 1; + uint32_t xsave : 1; + uint32_t avx2 : 1; + uint32_t avx512 : 1; }; struct cpu_regs { @@ -61,7 +52,7 @@ struct cpu_regs { // code segment uint64_t cs; // rflags - union cpu_rflags rflags; + uint64_t rflags; // stack pointer uint64_t rsp; // stack segment @@ -73,6 +64,26 @@ struct cpu_regs { */ void cpu_init(void); +/** + * Report all cpu information + */ +void cpu_report(void); + +/** + * @returns the name/model of the cpu + */ +void cpu_name(char name[48]); + +/** + * @returns the vendor of the cpu + */ +void cpu_vendor(char vendor[12]); + +/** + * @returns get features of the cpu + */ +void cpu_feats(struct cpu_feat *feats); + /** * Dump registers to output */ -- cgit v1.2.3-freya From 0ddc618b1d60ef6729326aa4e45b8280fcf51775 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Wed, 16 Apr 2025 16:51:25 -0400 Subject: fmt --- kernel/cpu/cpu.c | 130 ++++++++++++++++++++++++---------------------- kernel/drivers/acpi.c | 28 +++++----- kernel/memory/physalloc.c | 6 +-- 3 files changed, 84 insertions(+), 80 deletions(-) (limited to 'kernel/cpu/cpu.c') diff --git a/kernel/cpu/cpu.c b/kernel/cpu/cpu.c index 3835b68..136a1d8 100644 --- a/kernel/cpu/cpu.c +++ b/kernel/cpu/cpu.c @@ -18,19 +18,19 @@ static inline void sse_init(void) { size_t cr0, cr4; __asm__ volatile("mov %%cr0, %0" : "=r"(cr0)); - cr0 &= ~0x4; // clear coprocessor emulation - cr0 |= 0x2; // set coprocessor monitoring - __asm__ volatile("mov %0, %%cr0" :: "r"(cr0)); + cr0 &= ~0x4; // clear coprocessor emulation + cr0 |= 0x2; // set coprocessor monitoring + __asm__ volatile("mov %0, %%cr0" ::"r"(cr0)); __asm__ volatile("mov %%cr4, %0" : "=r"(cr4)); cr4 |= 1 << 9; // set CR4.OSFXSR cr4 |= 1 << 10; // set CR4.OSXMMEXCPT - __asm__ volatile("mov %0, %%cr4" :: "r"(cr4)); + __asm__ volatile("mov %0, %%cr4" ::"r"(cr4)); } static inline void fxsave_init(void) { static char fxsave_region[512] __attribute__((aligned(16))); - __asm__ volatile("fxsave %0" :: "m"(fxsave_region)); + __asm__ volatile("fxsave %0" ::"m"(fxsave_region)); } static inline void xsave_init(void) @@ -38,23 +38,21 @@ static inline void xsave_init(void) size_t cr4; __asm__ volatile("mov %%cr4, %0" : "=r"(cr4)); cr4 |= 1 << 18; // set CR4.OSXSAVE - __asm__ volatile("mov %0, %%cr4" :: "r"(cr4)); + __asm__ volatile("mov %0, %%cr4" ::"r"(cr4)); } static inline void avx_init(void) { - __asm__ volatile( - "pushq %rax;" - "pushq %rcx;" - "pushq %rdx;" - "xorq %rcx, %rcx;" - "xgetbv;" - "orq $7, %rax;" - "xsetbv;" - "popq %rdx;" - "popq %rcx;" - "popq %rax;" - ); + __asm__ volatile("pushq %rax;" + "pushq %rcx;" + "pushq %rdx;" + "xorq %rcx, %rcx;" + "xgetbv;" + "orq $7, %rax;" + "xsetbv;" + "popq %rdx;" + "popq %rcx;" + "popq %rax;"); } void cpu_init(void) @@ -119,30 +117,37 @@ void cpu_report(void) kputs("\n\n"); } -static inline void cpuid(uint32_t leaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) +static inline void cpuid(uint32_t leaf, uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) { - __asm__ volatile("cpuid" - : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) - : "0" (leaf)); + __asm__ volatile("cpuid" + : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) + : "0"(leaf)); } -static inline void cpuid_count(uint32_t leaf, uint32_t subleaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) +static inline void cpuid_count(uint32_t leaf, uint32_t subleaf, uint32_t *eax, + uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { - __asm__ volatile("cpuid" - : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) - : "0" (leaf), "2" (subleaf)); + __asm__ volatile("cpuid" + : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) + : "0"(leaf), "2"(subleaf)); } void cpu_vendor(char vendor[12]) { uint32_t ignore; - cpuid(0, &ignore, (uint32_t *)(vendor + 0), (uint32_t *)(vendor + 8), (uint32_t *)(vendor + 4)); + cpuid(0, &ignore, (uint32_t *)(vendor + 0), (uint32_t *)(vendor + 8), + (uint32_t *)(vendor + 4)); } -void cpu_name(char name[48]) { - cpuid(0x80000002, (uint32_t *)(name + 0), (uint32_t *)(name + 4), (uint32_t *)(name + 8), (uint32_t *)(name + 12)); - cpuid(0x80000003, (uint32_t *)(name + 16), (uint32_t *)(name + 20), (uint32_t *)(name + 24), (uint32_t *)(name + 28)); - cpuid(0x80000004, (uint32_t *)(name + 32), (uint32_t *)(name + 36), (uint32_t *)(name + 40), (uint32_t *)(name + 44)); +void cpu_name(char name[48]) +{ + cpuid(0x80000002, (uint32_t *)(name + 0), (uint32_t *)(name + 4), + (uint32_t *)(name + 8), (uint32_t *)(name + 12)); + cpuid(0x80000003, (uint32_t *)(name + 16), (uint32_t *)(name + 20), + (uint32_t *)(name + 24), (uint32_t *)(name + 28)); + cpuid(0x80000004, (uint32_t *)(name + 32), (uint32_t *)(name + 36), + (uint32_t *)(name + 40), (uint32_t *)(name + 44)); } void cpu_feats(struct cpu_feat *feats) @@ -156,19 +161,19 @@ void cpu_feats(struct cpu_feat *feats) cpuid(1, &ignore, &ignore, &ecx_1, &edx_1); cpuid_count(7, 0, &ignore, &ebx_7, &ignore, &ignore); - feats->fpu = edx_1 & (1<<0) ? 1 : 0; - feats->mmx = edx_1 & (1<<23) ? 1 : 0; - feats->sse = edx_1 & (1<<25) ? 1 : 0; - feats->sse2 = edx_1 & (1<<26) ? 1 : 0; - feats->sse3 = ecx_1 & (1<<0) ? 1 : 0; - feats->ssse3 = ecx_1 & (1<<9) ? 1 : 0; - feats->sse41 = ecx_1 & (1<<19) ? 1 : 0; - feats->sse42 = ecx_1 & (1<<20) ? 1 : 0; - feats->sse4a = ecx_1 & (1<<6) ? 1 : 0; - feats->avx = ecx_1 & (1<<28) ? 1 : 0; - feats->xsave = ecx_1 & (1<<26) ? 1 : 0; - feats->avx2 = ebx_7 & (1<<5) ? 1 : 0; - feats->avx512 = ebx_7 & (7<<16) ? 1 : 0; + feats->fpu = edx_1 & (1 << 0) ? 1 : 0; + feats->mmx = edx_1 & (1 << 23) ? 1 : 0; + feats->sse = edx_1 & (1 << 25) ? 1 : 0; + feats->sse2 = edx_1 & (1 << 26) ? 1 : 0; + feats->sse3 = ecx_1 & (1 << 0) ? 1 : 0; + feats->ssse3 = ecx_1 & (1 << 9) ? 1 : 0; + feats->sse41 = ecx_1 & (1 << 19) ? 1 : 0; + feats->sse42 = ecx_1 & (1 << 20) ? 1 : 0; + feats->sse4a = ecx_1 & (1 << 6) ? 1 : 0; + feats->avx = ecx_1 & (1 << 28) ? 1 : 0; + feats->xsave = ecx_1 & (1 << 26) ? 1 : 0; + feats->avx2 = ebx_7 & (1 << 5) ? 1 : 0; + feats->avx512 = ebx_7 & (7 << 16) ? 1 : 0; } void cpu_print_regs(struct cpu_regs *regs) @@ -192,42 +197,41 @@ void cpu_print_regs(struct cpu_regs *regs) kprintf("rip: %#016lx (%lu)\n", regs->rip, regs->rip); kprintf("rflags: %#016lx (%lu)\n", regs->rflags, regs->rflags); kputs("rflags: "); - if (regs->rflags & (1<<0)) + if (regs->rflags & (1 << 0)) kputs("CF "); - if (regs->rflags & (1<<2)) + if (regs->rflags & (1 << 2)) kputs("PF "); - if (regs->rflags & (1<<4)) + if (regs->rflags & (1 << 4)) kputs("AF "); - if (regs->rflags & (1<<6)) + if (regs->rflags & (1 << 6)) kputs("ZF "); - if (regs->rflags & (1<<7)) + if (regs->rflags & (1 << 7)) kputs("SF "); - if (regs->rflags & (1<<8)) + if (regs->rflags & (1 << 8)) kputs("TF "); - if (regs->rflags & (1<<9)) + if (regs->rflags & (1 << 9)) kputs("IF "); - if (regs->rflags & (1<<10)) + if (regs->rflags & (1 << 10)) kputs("DF "); - if (regs->rflags & (1<<11)) + if (regs->rflags & (1 << 11)) kputs("OF "); - if (regs->rflags & (3<<12)) + if (regs->rflags & (3 << 12)) kputs("IOPL "); - if (regs->rflags & (1<<14)) + if (regs->rflags & (1 << 14)) kputs("NT "); - if (regs->rflags & (1<<15)) + if (regs->rflags & (1 << 15)) kputs("MD "); - if (regs->rflags & (1<<16)) + if (regs->rflags & (1 << 16)) kputs("RF "); - if (regs->rflags & (1<<17)) + if (regs->rflags & (1 << 17)) kputs("VM "); - if (regs->rflags & (1<<18)) + if (regs->rflags & (1 << 18)) kputs("AC "); - if (regs->rflags & (1<<19)) + if (regs->rflags & (1 << 19)) kputs("VIF "); - if (regs->rflags & (1<<20)) + if (regs->rflags & (1 << 20)) kputs("VIP "); - if (regs->rflags & (1<<21)) + if (regs->rflags & (1 << 21)) kputs("ID "); kputs("\n"); } - diff --git a/kernel/drivers/acpi.c b/kernel/drivers/acpi.c index 41f7ba1..b4b219a 100644 --- a/kernel/drivers/acpi.c +++ b/kernel/drivers/acpi.c @@ -327,29 +327,29 @@ void acpi_report(void) { if (state.version == 0) { kprintf("ACPI 1.0\n"); - kprintf("%.*s: %#016lx\n", 4, (char *) &state.sdt.rsdt->h.signature, - (uintptr_t) state.sdt.rsdt); + kprintf("%.*s: %#016lx\n", 4, (char *)&state.sdt.rsdt->h.signature, + (uintptr_t)state.sdt.rsdt); } else { kprintf("ACPI 2.0\n"); - kprintf("%.*s: %#016lx\n", 4, (char *) &state.sdt.xsdt->h.signature, - (uintptr_t) state.sdt.xsdt); + kprintf("%.*s: %#016lx\n", 4, (char *)&state.sdt.xsdt->h.signature, + (uintptr_t)state.sdt.xsdt); } if (state.fadt) - kprintf("%.*s: %#016lx\n", 4, (char *) &state.fadt->h.signature, - (uintptr_t) state.fadt); + kprintf("%.*s: %#016lx\n", 4, (char *)&state.fadt->h.signature, + (uintptr_t)state.fadt); if (state.dsdt) - kprintf("%.*s: %#016lx\n", 4, (char *) &state.dsdt->h.signature, - (uintptr_t) state.dsdt); + kprintf("%.*s: %#016lx\n", 4, (char *)&state.dsdt->h.signature, + (uintptr_t)state.dsdt); if (state.apic) - kprintf("%.*s: %#016lx\n", 4, (char *) &state.apic->h.signature, - (uintptr_t) state.apic); + kprintf("%.*s: %#016lx\n", 4, (char *)&state.apic->h.signature, + (uintptr_t)state.apic); if (state.hept) - kprintf("%.*s: %#016lx\n", 4, (char *) &state.hept->h.signature, - (uintptr_t) state.hept); + kprintf("%.*s: %#016lx\n", 4, (char *)&state.hept->h.signature, + (uintptr_t)state.hept); if (state.waet) - kprintf("%.*s: %#016lx\n", 4, (char *) &state.waet->h.signature, - (uintptr_t) state.waet); + kprintf("%.*s: %#016lx\n", 4, (char *)&state.waet->h.signature, + (uintptr_t)state.waet); kprintf("\n"); } diff --git a/kernel/memory/physalloc.c b/kernel/memory/physalloc.c index 328502f..676e68e 100644 --- a/kernel/memory/physalloc.c +++ b/kernel/memory/physalloc.c @@ -21,9 +21,9 @@ struct memory_map phys_mmap; struct memory_segment *page_start; static const char *segment_type_str[] = { "Reserved", "Free", - "Reserved", "ACPI Reserved", - "Hibernation", "Defective", - "Unknown" }; + "Reserved", "ACPI Reserved", + "Hibernation", "Defective", + "Unknown" }; static int n_pages(const struct memory_segment *m) { -- cgit v1.2.3-freya