Mods to pass the guest CPUID info from bochs to plex86.
This commit is contained in:
parent
dae4e3133e
commit
523fe341f8
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//// $Id: plex86-interface.cc,v 1.1 2003-01-01 17:34:09 kevinlawton Exp $
|
||||
//// $Id: plex86-interface.cc,v 1.2 2003-01-02 01:09:50 kevinlawton Exp $
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
////
|
||||
//// Copyright (C) 2002 Kevin P. Lawton
|
||||
@ -39,37 +39,30 @@ static void copyPlex86StateToBochs(BX_CPU_C *cpu);
|
||||
static void copyBochsDescriptorToPlex86(descriptor_t *, bx_descriptor_t *);
|
||||
static void copyPlex86DescriptorToBochs(BX_CPU_C *,
|
||||
bx_descriptor_t *, descriptor_t *);
|
||||
static int openFD(void);
|
||||
|
||||
static unsigned faultCount[32];
|
||||
|
||||
|
||||
int
|
||||
plex86Open(void)
|
||||
openFD(void)
|
||||
{
|
||||
cpuid_info_t bochsCPUID;
|
||||
|
||||
if (plex86State) {
|
||||
// This should be the first operation; no state should be set yet.
|
||||
fprintf(stderr, "plex86Open: plex86State = 0x%x\n", plex86State);
|
||||
return(-1); // Error.
|
||||
fprintf(stderr, "openFD: plex86State = 0x%x\n", plex86State);
|
||||
return(0); // Error.
|
||||
}
|
||||
|
||||
// Open a new VM.
|
||||
fprintf(stderr, "Opening VM.\n");
|
||||
fprintf(stderr, "Trying /dev/misc/plex86...");
|
||||
plex86FD = open("/dev/misc/plex86", O_RDWR);
|
||||
if (plex86FD >= 0) {
|
||||
fprintf(stderr, "OK.\n");
|
||||
}
|
||||
else {
|
||||
if (plex86FD < 0) {
|
||||
fprintf(stderr, "failed.\n");
|
||||
// Try the old name.
|
||||
fprintf(stderr, "Trying /dev/plex86...");
|
||||
plex86FD = open("/dev/plex86", O_RDWR);
|
||||
if (plex86FD >= 0) {
|
||||
fprintf(stderr, "OK.\n");
|
||||
}
|
||||
else {
|
||||
if (plex86FD < 0) {
|
||||
fprintf(stderr, "failed.\n");
|
||||
fprintf(stderr, "Did you load the kernel module?"
|
||||
" Read the toplevel README file!\n");
|
||||
@ -77,18 +70,37 @@ plex86Open(void)
|
||||
return(-1); // Error.
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "OK.\n");
|
||||
return(1); // OK.
|
||||
}
|
||||
|
||||
fprintf(stderr, "Zeroing guest CPUID info (complete this).\n");
|
||||
memset(&bochsCPUID, 0, sizeof(bochsCPUID));
|
||||
// xxx Fill in CPUID info here.
|
||||
unsigned
|
||||
plex86CpuInfo(BX_CPU_C *cpu)
|
||||
{
|
||||
cpuid_info_t bochsCPUID;
|
||||
|
||||
if (plex86FD < 0) {
|
||||
// If the plex86 File Descriptor has not been opened yet.
|
||||
if ( !openFD() ) {
|
||||
return(0); // Error.
|
||||
}
|
||||
}
|
||||
|
||||
bochsCPUID.vendorDWord0 = cpu->cpuidInfo.vendorDWord0;
|
||||
bochsCPUID.vendorDWord1 = cpu->cpuidInfo.vendorDWord1;
|
||||
bochsCPUID.vendorDWord2 = cpu->cpuidInfo.vendorDWord2;
|
||||
bochsCPUID.procSignature.raw = cpu->cpuidInfo.procSignature;
|
||||
bochsCPUID.featureFlags.raw = cpu->cpuidInfo.featureFlags;
|
||||
fprintf(stderr, "CPUID.family passing as %u\n",
|
||||
bochsCPUID.procSignature.fields.family);
|
||||
|
||||
fprintf(stderr, "Passing guest CPUID to plex86.\n");
|
||||
if ( ioctl(plex86FD, PLEX86_CPUID, &bochsCPUID) ) {
|
||||
perror("ioctl CPUID: ");
|
||||
return(-1); // Error.
|
||||
return(0); // Error.
|
||||
}
|
||||
|
||||
return(plex86FD); // File descriptor is return val.
|
||||
return(1); // OK.
|
||||
}
|
||||
|
||||
Bit8u *
|
||||
@ -99,8 +111,10 @@ plex86AllocateMemory(unsigned nMegs)
|
||||
plex86MemSize = nMegs * 1024 * 1024;
|
||||
|
||||
if (plex86FD < 0) {
|
||||
fprintf(stderr, "plex86AllocateMemory: FD not open.\n");
|
||||
return(0);
|
||||
// If the plex86 File Descriptor has not been opened yet.
|
||||
if ( !openFD() ) {
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate memory from the host OS for the virtual physical memory.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//// $Id: plex86-interface.h,v 1.1 2003-01-01 17:34:09 kevinlawton Exp $
|
||||
//// $Id: plex86-interface.h,v 1.2 2003-01-02 01:09:50 kevinlawton Exp $
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
////
|
||||
//// Copyright (C) 2002 Kevin P. Lawton
|
||||
@ -34,7 +34,7 @@ extern unsigned plex86MemSize;
|
||||
extern Bit8u *plex86PrintBuffer;
|
||||
extern guest_cpu_t *plex86GuestCPU;
|
||||
|
||||
extern int plex86Open(void);
|
||||
extern unsigned plex86CpuInfo(BX_CPU_C *cpu);
|
||||
extern unsigned char * plex86AllocateMemory(unsigned nMegs);
|
||||
extern unsigned plex86TearDown(void);
|
||||
extern unsigned plex86ExecuteInVM(BX_CPU_C *cpu);
|
||||
|
@ -1242,9 +1242,9 @@ ioctlAllocVPhys(vm_t *vm, unsigned long arg)
|
||||
|
||||
hostPrint("plex86: vm_t size is %u\n", sizeof(vm_t));
|
||||
/* Do not allow duplicate allocation. The file descriptor must be
|
||||
* opened, and the guest CPUID info filled in by this point.
|
||||
* opened. The guest CPUID info can be filled in later.
|
||||
*/
|
||||
if ( vm->vmState != (VMStateFDOpened | VMStateGuestCPUID) )
|
||||
if ( (vm->vmState & ~VMStateGuestCPUID) != VMStateFDOpened )
|
||||
return -Plex86ErrnoEBUSY;
|
||||
|
||||
if (vm->pages.guest_n_megs != 0)
|
||||
@ -1565,15 +1565,13 @@ getCpuCapabilities(void)
|
||||
:
|
||||
: "cc"
|
||||
);
|
||||
hostCpuIDInfo.maxval = eax;
|
||||
if (eax < 1)
|
||||
return(0); /* not enough capabilities */
|
||||
|
||||
/* Copy vendor string */
|
||||
* (Bit32u*) &hostCpuIDInfo.vendorID[0] = ebx;
|
||||
* (Bit32u*) &hostCpuIDInfo.vendorID[4] = edx;
|
||||
* (Bit32u*) &hostCpuIDInfo.vendorID[8] = ecx;
|
||||
hostCpuIDInfo.vendorID[12] = 0;
|
||||
/* Copy vendor string. */
|
||||
hostCpuIDInfo.vendorDWord0 = ebx;
|
||||
hostCpuIDInfo.vendorDWord1 = edx;
|
||||
hostCpuIDInfo.vendorDWord2 = ecx;
|
||||
|
||||
/* CPUID w/ EAX==1: Processor Signature & Feature Flags */
|
||||
asm volatile (
|
||||
|
@ -1,5 +1,5 @@
|
||||
/************************************************************************
|
||||
* $Id: plex86.h,v 1.1 2003-01-01 17:32:04 kevinlawton Exp $
|
||||
* $Id: plex86.h,v 1.2 2003-01-02 01:08:43 kevinlawton Exp $
|
||||
************************************************************************
|
||||
*
|
||||
* plex86: run multiple x86 operating systems concurrently
|
||||
@ -80,8 +80,9 @@ typedef union {
|
||||
} __attribute__ ((packed)) cr4_t;
|
||||
|
||||
typedef struct {
|
||||
Bit32u maxval; /* maximum val to pass to CPUID instruction */
|
||||
Bit8u vendorID[12+1]; /* 12 packed Vendor ID string bytes plus null */
|
||||
Bit32u vendorDWord0;
|
||||
Bit32u vendorDWord1;
|
||||
Bit32u vendorDWord2;
|
||||
union {
|
||||
Bit32u raw;
|
||||
struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user