Move cpuid() to cpu.h
This commit is contained in:
parent
513d0a2279
commit
2aed131364
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
@ -72,21 +72,6 @@ uint8_t bcd_to_int(uint8_t val) {
|
||||
return (val & 0x0f) + ((val & 0xf0) >> 4) * 10;
|
||||
}
|
||||
|
||||
int cpuid(uint32_t leaf, uint32_t subleaf,
|
||||
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) {
|
||||
uint32_t cpuid_max;
|
||||
asm volatile ("cpuid"
|
||||
: "=a" (cpuid_max)
|
||||
: "a" (leaf & 0x80000000)
|
||||
: "ebx", "ecx", "edx");
|
||||
if (leaf > cpuid_max)
|
||||
return 1;
|
||||
asm volatile ("cpuid"
|
||||
: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
|
||||
: "a" (leaf), "c" (subleaf));
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((noreturn)) void panic(const char *fmt, ...) {
|
||||
asm volatile ("cli" ::: "memory");
|
||||
|
||||
|
@ -18,9 +18,6 @@ uint64_t sqrt(uint64_t a_nInput);
|
||||
|
||||
uint8_t bcd_to_int(uint8_t val);
|
||||
|
||||
int cpuid(uint32_t leaf, uint32_t subleaf,
|
||||
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
|
||||
|
||||
__attribute__((noreturn)) void panic(const char *fmt, ...);
|
||||
|
||||
int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <lib/blib.h>
|
||||
#include <lib/print.h>
|
||||
#include <lib/rand.h>
|
||||
#include <sys/cpu.h>
|
||||
#include <mm/pmm.h>
|
||||
|
||||
// TODO: Find where this mersenne twister implementation is inspired from
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <drivers/vbe.h>
|
||||
#include <lib/term.h>
|
||||
#include <sys/pic.h>
|
||||
#include <sys/cpu.h>
|
||||
#include <fs/file.h>
|
||||
#include <mm/vmm.h>
|
||||
#include <mm/pmm.h>
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <lib/real.h>
|
||||
#include <lib/libc.h>
|
||||
#include <sys/smp.h>
|
||||
#include <sys/cpu.h>
|
||||
#include <drivers/vbe.h>
|
||||
#include <lib/term.h>
|
||||
#include <sys/pic.h>
|
||||
|
@ -10,6 +10,21 @@
|
||||
#define DWORD_PTR(PTR) (*((uint32_t *)(PTR)))
|
||||
#define QWORD_PTR(PTR) (*((uint64_t *)(PTR)))
|
||||
|
||||
static inline int cpuid(uint32_t leaf, uint32_t subleaf,
|
||||
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) {
|
||||
uint32_t cpuid_max;
|
||||
asm volatile ("cpuid"
|
||||
: "=a" (cpuid_max)
|
||||
: "a" (leaf & 0x80000000)
|
||||
: "ebx", "ecx", "edx");
|
||||
if (leaf > cpuid_max)
|
||||
return 1;
|
||||
asm volatile ("cpuid"
|
||||
: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
|
||||
: "a" (leaf), "c" (subleaf));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void outb(uint16_t port, uint8_t value) {
|
||||
asm volatile ("out %1, al" : : "a" (value), "Nd" (port) : "memory");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user