From 9ad9e387e9806be0093be97b2e0952a7fab968e9 Mon Sep 17 00:00:00 2001 From: grehan Date: Fri, 18 Oct 2013 22:05:17 +0000 Subject: MFC r256709: Eliminate unconditional debug printfs. Linux writes to these nominally read-only registers, so avoid having bhyve write warning messages to stdout when the reg writes can be safely ignored. Change the WPRINTF to DPRINTF which is conditional. Approved by: re (delphij) --- usr.sbin/bhyve/mptbl.c | 150 +++++++++---------------------------------------- 1 file changed, 26 insertions(+), 124 deletions(-) (limited to 'usr.sbin/bhyve/mptbl.c') diff --git a/usr.sbin/bhyve/mptbl.c b/usr.sbin/bhyve/mptbl.c index 74db2ea..5687d90 100644 --- a/usr.sbin/bhyve/mptbl.c +++ b/usr.sbin/bhyve/mptbl.c @@ -71,6 +71,9 @@ __FBSDID("$FreeBSD$"); #define MPEP_FEATURES (0xBFEBFBFF) /* XXX Intel i7 */ +/* Number of i/o intr entries */ +#define MPEII_MAX_IRQ 16 + /* Define processor entry struct since gets it wrong */ typedef struct BPROCENTRY { u_char type; @@ -155,14 +158,14 @@ mpt_build_bus_entries(bus_entry_ptr mpeb) memset(mpeb, 0, sizeof(*mpeb)); mpeb->type = MPCT_ENTRY_BUS; - mpeb->bus_id = ISA; - memcpy(mpeb->bus_type, MPE_BUSNAME_ISA, MPE_BUSNAME_LEN); + mpeb->bus_id = 0; + memcpy(mpeb->bus_type, MPE_BUSNAME_PCI, MPE_BUSNAME_LEN); mpeb++; memset(mpeb, 0, sizeof(*mpeb)); mpeb->type = MPCT_ENTRY_BUS; - mpeb->bus_id = PCI; - memcpy(mpeb->bus_type, MPE_BUSNAME_PCI, MPE_BUSNAME_LEN); + mpeb->bus_id = 1; + memcpy(mpeb->bus_type, MPE_BUSNAME_ISA, MPE_BUSNAME_LEN); } static void @@ -177,9 +180,8 @@ mpt_build_ioapic_entries(io_apic_entry_ptr mpei, int id) mpei->apic_address = IOAPIC_PADDR; } -#ifdef notyet static void -mpt_build_ioint_entries(struct mpe_ioint *mpeii, int num_pins, int id) +mpt_build_ioint_entries(int_entry_ptr mpie, int num_pins, int id) { int pin; @@ -189,28 +191,27 @@ mpt_build_ioint_entries(struct mpe_ioint *mpeii, int num_pins, int id) * just use the default config, tweek later if needed. */ - /* Run through all 16 pins. */ for (pin = 0; pin < num_pins; pin++) { - memset(mpeii, 0, sizeof(*mpeii)); - mpeii->entry_type = MP_ENTRY_IOINT; - mpeii->src_bus_id = MPE_BUSID_ISA; - mpeii->dst_apic_id = id; + memset(mpie, 0, sizeof(*mpie)); + mpie->type = MPCT_ENTRY_INT; + mpie->src_bus_id = 1; + mpie->dst_apic_id = id; /* * All default configs route IRQs from bus 0 to the first 16 * pins of the first I/O APIC with an APIC ID of 2. */ - mpeii->dst_apic_intin = pin; + mpie->dst_apic_int = pin; switch (pin) { case 0: /* Pin 0 is an ExtINT pin. */ - mpeii->intr_type = MPEII_INTR_EXTINT; + mpie->int_type = INTENTRY_TYPE_EXTINT; break; case 2: /* IRQ 0 is routed to pin 2. */ - mpeii->intr_type = MPEII_INTR_INT; - mpeii->src_bus_irq = 0; + mpie->int_type = INTENTRY_TYPE_INT; + mpie->src_bus_irq = 0; break; case 5: case 10: @@ -218,118 +219,20 @@ mpt_build_ioint_entries(struct mpe_ioint *mpeii, int num_pins, int id) /* * PCI Irqs set to level triggered. */ - mpeii->intr_flags = MPEII_FLAGS_TRIGMODE_LEVEL; - mpeii->src_bus_id = MPE_BUSID_PCI; + mpie->int_flags = INTENTRY_FLAGS_TRIGGER_LEVEL; + mpie->src_bus_id = 0; + /* fall through.. */ default: /* All other pins are identity mapped. */ - mpeii->intr_type = MPEII_INTR_INT; - mpeii->src_bus_irq = pin; + mpie->int_type = INTENTRY_TYPE_INT; + mpie->src_bus_irq = pin; break; } - mpeii++; + mpie++; } } -#define COPYSTR(dest, src, bytes) \ - memcpy(dest, src, bytes); \ - str[bytes] = 0; - -static void -mptable_dump(struct mp_floating_pointer *mpfp, struct mp_config_hdr *mpch) -{ - static char str[16]; - int i; - char *cur; - - union mpe { - struct mpe_proc *proc; - struct mpe_bus *bus; - struct mpe_ioapic *ioapic; - struct mpe_ioint *ioint; - struct mpe_lint *lnit; - char *p; - }; - - union mpe mpe; - - printf(" MP Floating Pointer :\n"); - COPYSTR(str, mpfp->signature, 4); - printf("\tsignature:\t%s\n", str); - printf("\tmpch paddr:\t%x\n", mpfp->mptable_paddr); - printf("\tlength:\t%x\n", mpfp->length); - printf("\tspecrec:\t%x\n", mpfp->specrev); - printf("\tchecksum:\t%x\n", mpfp->checksum); - printf("\tfeature1:\t%x\n", mpfp->feature1); - printf("\tfeature2:\t%x\n", mpfp->feature2); - printf("\tfeature3:\t%x\n", mpfp->feature3); - printf("\tfeature4:\t%x\n", mpfp->feature4); - - printf(" MP Configuration Header :\n"); - COPYSTR(str, mpch->signature, 4); - printf(" signature: %s\n", str); - printf(" length: %x\n", mpch->length); - printf(" specrec: %x\n", mpch->specrev); - printf(" checksum: %x\n", mpch->checksum); - COPYSTR(str, mpch->oemid, MPCH_OEMID_LEN); - printf(" oemid: %s\n", str); - COPYSTR(str, mpch->prodid, MPCH_PRODID_LEN); - printf(" prodid: %s\n", str); - printf(" oem_ptr: %x\n", mpch->oem_ptr); - printf(" oem_sz: %x\n", mpch->oem_sz); - printf(" nr_entries: %x\n", mpch->nr_entries); - printf(" apic paddr: %x\n", mpch->lapic_paddr); - printf(" ext_length: %x\n", mpch->ext_length); - printf(" ext_checksum: %x\n", mpch->ext_checksum); - - cur = (char *)mpch + sizeof(*mpch); - for (i = 0; i < mpch->nr_entries; i++) { - mpe.p = cur; - switch(*mpe.p) { - case MP_ENTRY_PROC: - printf(" MP Processor Entry :\n"); - printf(" lapic_id: %x\n", mpe.proc->lapic_id); - printf(" lapic_version: %x\n", mpe.proc->lapic_version); - printf(" proc_flags: %x\n", mpe.proc->proc_flags); - printf(" proc_signature: %x\n", mpe.proc->proc_signature); - printf(" feature_flags: %x\n", mpe.proc->feature_flags); - cur += sizeof(struct mpe_proc); - break; - case MP_ENTRY_BUS: - printf(" MP Bus Entry :\n"); - printf(" busid: %x\n", mpe.bus->busid); - COPYSTR(str, mpe.bus->busname, MPE_BUSNAME_LEN); - printf(" busname: %s\n", str); - cur += sizeof(struct mpe_bus); - break; - case MP_ENTRY_IOAPIC: - printf(" MP IOAPIC Entry :\n"); - printf(" ioapi_id: %x\n", mpe.ioapic->ioapic_id); - printf(" ioapi_version: %x\n", mpe.ioapic->ioapic_version); - printf(" ioapi_flags: %x\n", mpe.ioapic->ioapic_flags); - printf(" ioapi_paddr: %x\n", mpe.ioapic->ioapic_paddr); - cur += sizeof(struct mpe_ioapic); - break; - case MP_ENTRY_IOINT: - printf(" MP IO Interrupt Entry :\n"); - printf(" intr_type: %x\n", mpe.ioint->intr_type); - printf(" intr_flags: %x\n", mpe.ioint->intr_flags); - printf(" src_bus_id: %x\n", mpe.ioint->src_bus_id); - printf(" src_bus_irq: %x\n", mpe.ioint->src_bus_irq); - printf(" dst_apic_id: %x\n", mpe.ioint->dst_apic_id); - printf(" dst_apic_intin: %x\n", mpe.ioint->dst_apic_intin); - cur += sizeof(struct mpe_ioint); - break; - case MP_ENTRY_LINT: - printf(" MP Local Interrupt Entry :\n"); - cur += sizeof(struct mpe_lint); - break; - } - - } -} -#endif - void mptable_add_oemtbl(void *tbl, int tblsz) { @@ -346,6 +249,7 @@ mptable_build(struct vmctx *ctx, int ncpu, int ioapic) io_apic_entry_ptr mpei; bproc_entry_ptr mpep; mpfps_t mpfp; + int_entry_ptr mpie; char *curraddr; char *startaddr; @@ -381,12 +285,10 @@ mptable_build(struct vmctx *ctx, int ncpu, int ioapic) mpch->entry_count++; } -#ifdef notyet - mpt_build_ioint_entries((struct mpe_ioint*)curraddr, MPEII_MAX_IRQ, - ncpu + 1); - curraddr += sizeof(struct mpe_ioint) * MPEII_MAX_IRQ; + mpie = (int_entry_ptr) curraddr; + mpt_build_ioint_entries(mpie, MPEII_MAX_IRQ, ncpu + 1); + curraddr += sizeof(*mpie) * MPEII_MAX_IRQ; mpch->entry_count += MPEII_MAX_IRQ; -#endif if (oem_tbl_start) { mpch->oem_table_pointer = curraddr - startaddr + MPTABLE_BASE; -- cgit v1.1