commit ae12d85485bd7bf0434f13619f49274ad9c18d93 Author: Gleb Natapov Date: Sun Aug 24 10:59:25 2008 +0300 Use new io port interface for qemu<->BIOS communication. diff --git a/bios/rombios32.c b/bios/rombios32.c index 2dc1d25..bdbd0fd 100755 --- a/bios/rombios32.c +++ b/bios/rombios32.c @@ -443,25 +443,49 @@ void wrmsr_smp(uint32_t index, uint64_t val) p->ecx = 0; } +#ifdef BX_QEMU +#define QEMU_CFG_PORT 0x1234 +enum { + QEMU_CFG_SIGNATURE, + QEMU_CFG_UUID, + QEMU_CFG_CPUSPEED, + QEMU_CFG_MAX_ENTRY +}; + +int qemu_cfg_port; + +void qemu_cfg_select(int f) +{ + outb(QEMU_CFG_PORT, f); +} + +int qemu_cfg_port_probe() +{ + char *sig = "QEMU"; + int i; + + qemu_cfg_select(QEMU_CFG_SIGNATURE); + + for (i = 0; i < 4; i++) + if (inb(QEMU_CFG_PORT) != sig[i]) + return 0; + + return 1; +} + +void qemu_cfg_read(uint8_t *buf, int len) +{ + while (len--) + *(buf++) = inb(QEMU_CFG_PORT); +} +#endif + void uuid_probe(void) { #ifdef BX_QEMU - uint32_t eax, ebx, ecx, edx; - - // check if backdoor port exists - asm volatile ("outl %%eax, %%dx" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (0x564d5868), "c" (0xa), "d" (0x5658)); - if (ebx == 0x564d5868) { - uint32_t *uuid_ptr = (uint32_t *)bios_uuid; - // get uuid - asm volatile ("outl %%eax, %%dx" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (0x564d5868), "c" (0x13), "d" (0x5658)); - uuid_ptr[0] = eax; - uuid_ptr[1] = ebx; - uuid_ptr[2] = ecx; - uuid_ptr[3] = edx; + if(qemu_cfg_port) { + qemu_cfg_select(QEMU_CFG_UUID); + qemu_cfg_read(bios_uuid, 16); } else #endif { @@ -1830,6 +1854,24 @@ smbios_type_3_init(void *start) return start+2; } +static int qery_cpu_freq(void) +{ +#ifdef BX_QEMU + int cpu_speed; + + if(!qemu_cfg_port) + return 0; + + qemu_cfg_select(QEMU_CFG_CPUSPEED); + qemu_cfg_read((uint8_t*)&cpu_speed, 4); + + return cpu_speed; +#else + return 0; +#endif +} + + /* Type 4 -- Processor Information */ static void * smbios_type_4_init(void *start, unsigned int cpu_number) @@ -1852,8 +1894,8 @@ smbios_type_4_init(void *start, unsigned int cpu_number) p->voltage = 0; p->external_clock = 0; - p->max_speed = 0; /* unknown */ - p->current_speed = 0; /* unknown */ + p->max_speed = 0x0FA0; /* 4000 MHZ */ + p->current_speed = qery_cpu_freq(); /* unknown */ p->status = 0x41; /* socket populated, CPU enabled */ p->processor_upgrade = 0x01; /* other */ @@ -2058,6 +2100,10 @@ void rombios32_init(void) init_smp_msrs(); +#ifdef BX_QEMU + qemu_cfg_port = qemu_cfg_port_probe(); +#endif + ram_probe(); cpu_probe();