~satchmo/libvmm#19: 
Implement convenience functions for Cpuid

For example, cpuid.vendor_id() could return an appropriate value so that users don't have to bit fiddle with ebx, edx, and ecx.

Status
REPORTED
Submitter
~satchmo
Assigned to
No-one
Submitted
4 years ago
Updated
4 years ago
Labels
Proposal

~satchmo 4 years ago

Not too sure whether this should be implemented. If we do, would we have to implement all cpuid-exposed details?

Perhaps users could provide their own wrappers as needed like this:

struct CPUVendorID {
    unsigned int ebx;
    unsigned int edx;
    unsigned int ecx;

    string toString() const {
        return string(reinterpret_cast<const char *>(this), 12);
    }
};

int main() {
    kvm::system kvm;
    kvm::Cpuid {kvm.supported_cpuid()};
    CpuVendorId {cpuid.entries[0].ebx, cpuid.entries[0].edx, cpuid.entries[0].ecx};
}
Register here or Log in to comment, or comment via email.