mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[cpu] Reimplement CPUID features as util::bitset
The cpu::cpu_id class no longer looks up all known features in the constructor, but instead provides access to the map of supported features as a bitset from the verify() method. It also exposes the brand_name() method instead of loading the brand name string in the constructor and storing it as part of the object.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <new>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <util/bitset.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "cpu.h"
|
||||
@@ -30,18 +31,23 @@ cpu_validate()
|
||||
{
|
||||
cpu::cpu_id cpu;
|
||||
|
||||
log::info(logs::boot, "CPU: %s", cpu.brand_name());
|
||||
char brand_name[50];
|
||||
cpu.brand_name(brand_name);
|
||||
|
||||
cpu::cpu_id::features features = cpu.validate();
|
||||
|
||||
log::info(logs::boot, "CPU: %s", brand_name);
|
||||
log::debug(logs::boot, " Vendor is %s", cpu.vendor_id());
|
||||
|
||||
log::debug(logs::boot, " Higest basic CPUID: 0x%02x", cpu.highest_basic());
|
||||
log::debug(logs::boot, " Higest ext CPUID: 0x%02x", cpu.highest_ext() & ~cpu::cpu_id::cpuid_extended);
|
||||
|
||||
#define CPU_FEATURE_OPT(name, ...) \
|
||||
log::debug(logs::boot, " Supports %9s: %s", #name, cpu.has_feature(cpu::feature::name) ? "yes" : "no");
|
||||
log::debug(logs::boot, " Supports %9s: %s", #name, features[cpu::feature::name] ? "yes" : "no");
|
||||
|
||||
#define CPU_FEATURE_REQ(name, feat_leaf, feat_sub, regname, bit) \
|
||||
CPU_FEATURE_OPT(name, feat_leaf, feat_sub, regname, bit); \
|
||||
kassert(cpu.has_feature(cpu::feature::name), "Missing required CPU feature " #name );
|
||||
log::debug(logs::boot, " Supports %9s: %s", #name, features[cpu::feature::name] ? "yes" : "no"); \
|
||||
kassert(features[cpu::feature::name], "Missing required CPU feature " #name );
|
||||
|
||||
#include "cpu/features.inc"
|
||||
#undef CPU_FEATURE_OPT
|
||||
|
||||
Reference in New Issue
Block a user