Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh:xen-4.16
qemu-2.6
seabios.128kb.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File seabios.128kb.patch of Package qemu-2.6
From: Bruce Rogers <brogers@suse.com> Date: Thu, 19 Mar 2015 16:34:31 -0600 Subject: 128kb Eliminate some duplicate string segments to reduce bios image size In some build environments, we are running up against the 128K bios size limit. This change simply takes larger string segments which are used in printf style messages and uses a single copy, now referenced with a %s specifier, resulting in the needed space savings. Signed-off-by: Bruce Rogers <brogers@suse.com> --- src/apm.c | 6 ++++-- src/boot.c | 27 +++++++++++++++------------ src/bootsplash.c | 5 +++-- src/fw/biostables.c | 9 +++++---- src/fw/paravirt.c | 11 +++++++---- src/fw/pciinit.c | 23 +++++++++++++---------- src/hw/ps2port.c | 3 ++- src/hw/usb-hub.c | 9 +++++---- src/hw/usb-msc.c | 9 ++++++--- src/hw/usb-uhci.c | 3 ++- src/output.c | 10 +++++++--- src/output.h | 12 ++++++++---- src/vgahooks.c | 7 ++++--- 13 files changed, 81 insertions(+), 53 deletions(-) --- a/src/apm.c +++ b/src/apm.c @@ -89,38 +89,40 @@ handle_155306(struct bregs *regs) void apm_shutdown(void) { u16 pm1a_cnt = GET_GLOBAL(acpi_pm1a_cnt); if (pm1a_cnt) outw(0x2000, pm1a_cnt); irq_disable(); for (;;) hlt(); } +static const char *apm_standby = "APM standby request\n"; +static const char *apm_suspend = "APM suspend request\n"; // APM Set Power State static void handle_155307(struct bregs *regs) { if (regs->bx != 1) { set_success(regs); return; } switch (regs->cx) { case 1: - dprintf(1, "APM standby request\n"); + dprintf(1, "%s", apm_standby); break; case 2: - dprintf(1, "APM suspend request\n"); + dprintf(1, "%s", apm_suspend); break; case 3: apm_shutdown(); break; } set_success(regs); } static void handle_155308(struct bregs *regs) { set_success(regs); --- a/src/boot.c +++ b/src/boot.c @@ -17,24 +17,27 @@ #include "output.h" // dprintf #include "romfile.h" // romfile_loadint #include "std/disk.h" // struct mbr_s #include "string.h" // memset #include "util.h" // irqtimer_calc #include "tcgbios.h" // tpm_* /**************************************************************** * Boot priority ordering ****************************************************************/ +static const char *no_boot_dev_str = "No bootable device."; +static const char *boot_str = "Booting from "; +static const char *boot_fail_str = "Boot failed: "; static char **Bootorder VARVERIFY32INIT; static int BootorderCount; static void loadBootOrder(void) { if (!CONFIG_BOOTORDER) return; char *f = romfile_loadfile("bootorder", NULL); if (!f) return; @@ -579,25 +582,25 @@ bcv_prepboot(void) add_bev(IPL_TYPE_HARDDISK, 0); } /**************************************************************** * Boot code (int 18/19) ****************************************************************/ // Jump to a bootup entry point. static void call_boot_entry(struct segoff_s bootsegip, u8 bootdrv) { - dprintf(1, "Booting from %04x:%04x\n", bootsegip.seg, bootsegip.offset); + dprintf(1, "%s%04x:%04x\n", boot_str, bootsegip.seg, bootsegip.offset); struct bregs br; memset(&br, 0, sizeof(br)); br.flags = F_IF; br.code = bootsegip; // Set the magic number in ax and the boot drive in dl. br.dl = bootdrv; br.ax = 0xaa55; farcall16(&br); } // Boot from a disk (either floppy or harddrive) static void @@ -608,100 +611,100 @@ boot_disk(u8 bootdrv, int checksig) // Read sector struct bregs br; memset(&br, 0, sizeof(br)); br.flags = F_IF; br.dl = bootdrv; br.es = bootseg; br.ah = 2; br.al = 1; br.cl = 1; call16_int(0x13, &br); if (br.flags & F_CF) { - printf("Boot failed: could not read the boot disk\n\n"); + printf("%scould not read the boot disk\n\n", boot_fail_str); return; } if (checksig) { struct mbr_s *mbr = (void*)0; if (GET_FARVAR(bootseg, mbr->signature) != MBR_SIGNATURE) { - printf("Boot failed: not a bootable disk\n\n"); + printf("%snot a bootable disk\n\n", boot_fail_str); return; } } tpm_add_bcv(bootdrv, MAKE_FLATPTR(bootseg, 0), 512); /* Canonicalize bootseg:bootip */ u16 bootip = (bootseg & 0x0fff) << 4; bootseg &= 0xf000; call_boot_entry(SEGOFF(bootseg, bootip), bootdrv); } // Boot from a CD-ROM static void boot_cdrom(struct drive_s *drive_g) { if (! CONFIG_CDROM_BOOT) return; - printf("Booting from DVD/CD...\n"); + printf("%sDVD/CD...\n", boot_str); int status = cdrom_boot(drive_g); if (status) { - printf("Boot failed: Could not read from CDROM (code %04x)\n", status); + printf("%sCould not read from CDROM (code %04x)\n", boot_fail_str, status); return; } u8 bootdrv = CDEmu.emulated_drive; u16 bootseg = CDEmu.load_segment; tpm_add_cdrom(bootdrv, MAKE_FLATPTR(bootseg, 0), 512); /* Canonicalize bootseg:bootip */ u16 bootip = (bootseg & 0x0fff) << 4; bootseg &= 0xf000; call_boot_entry(SEGOFF(bootseg, bootip), bootdrv); } // Boot from a CBFS payload static void boot_cbfs(struct cbfs_file *file) { if (!CONFIG_COREBOOT_FLASH) return; - printf("Booting from CBFS...\n"); + printf("%sCBFS...\n", boot_str); cbfs_run_payload(file); } // Boot from a BEV entry on an optionrom. static void boot_rom(u32 vector) { - printf("Booting from ROM...\n"); + printf("%sROM...\n", boot_str); struct segoff_s so; so.segoff = vector; call_boot_entry(so, 0); } // Unable to find bootable device - warn user and eventually retry. static void boot_fail(void) { if (BootRetryTime == (u32)-1) - printf("No bootable device.\n"); + printf("%s\n", no_boot_dev_str); else - printf("No bootable device. Retrying in %d seconds.\n" - , BootRetryTime/1000); + printf("%s Retrying in %d seconds.\n", no_boot_dev_str, + BootRetryTime/1000); // Wait for 'BootRetryTime' milliseconds and then reboot. u32 end = irqtimer_calc(BootRetryTime); for (;;) { if (BootRetryTime != (u32)-1 && irqtimer_check(end)) break; yield_toirq(); } printf("Rebooting.\n"); reset(); } // Determine next boot method and attempt a boot using it. @@ -709,29 +712,29 @@ static void do_boot(int seq_nr) { if (! CONFIG_BOOT) panic("Boot support not compiled in.\n"); if (seq_nr >= BEVCount) boot_fail(); // Boot the given BEV type. struct bev_s *ie = &BEV[seq_nr]; switch (ie->type) { case IPL_TYPE_FLOPPY: - printf("Booting from Floppy...\n"); + printf("%sFloppy...\n", boot_str); boot_disk(0x00, CheckFloppySig); break; case IPL_TYPE_HARDDISK: - printf("Booting from Hard Disk...\n"); + printf("%sHard Disk...\n", boot_str); boot_disk(0x80, 1); break; case IPL_TYPE_CDROM: boot_cdrom((void*)ie->vector); break; case IPL_TYPE_CBFS: boot_cbfs((void*)ie->vector); break; case IPL_TYPE_BEV: boot_rom(ie->vector); break; case IPL_TYPE_HALT: --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -7,24 +7,25 @@ #include "bregs.h" // struct bregs #include "config.h" // CONFIG_* #include "farptr.h" // FLATPTR_TO_SEG #include "malloc.h" // free #include "output.h" // dprintf #include "romfile.h" // romfile_loadfile #include "stacks.h" // call16_int #include "std/vbe.h" // struct vbe_info #include "string.h" // memset #include "util.h" // enable_bootsplash +static const char *decode_failed_str = "_decode failed with return code "; /**************************************************************** * Helper functions ****************************************************************/ // Call int10 vga handler. static void call16_int10(struct bregs *br) { br->flags = F_IF; start_preempt(); call16_int(0x10, br); @@ -145,39 +146,39 @@ enable_bootsplash(void) int ret, width, height; int bpp_require = 0; if (type == 0) { jpeg = jpeg_alloc(); if (!jpeg) { warn_noalloc(); goto done; } /* Parse jpeg and get image size. */ dprintf(5, "Decoding bootsplash.jpg\n"); ret = jpeg_decode(jpeg, filedata); if (ret) { - dprintf(1, "jpeg_decode failed with return code %d...\n", ret); + dprintf(1, "jpeg%s%d...\n", decode_failed_str, ret); goto done; } jpeg_get_size(jpeg, &width, &height); } else { bmp = bmp_alloc(); if (!bmp) { warn_noalloc(); goto done; } /* Parse bmp and get image size. */ dprintf(5, "Decoding bootsplash.bmp\n"); ret = bmp_decode(bmp, filedata, filesize); if (ret) { - dprintf(1, "bmp_decode failed with return code %d...\n", ret); + dprintf(1, "bmp%s%d...\n", decode_failed_str, ret); goto done; } bmp_get_size(bmp, &width, &height); bpp_require = 24; } /* jpeg would use 16 or 24 bpp video mode, BMP use 24bpp mode only */ // Try to find a graphics mode with the corresponding dimensions. int videomode = find_videomode(vesa_info, mode_info, width, height, bpp_require); if (videomode < 0) { dprintf(1, "failed to find a videomode with %dx%d %dbpp (0=any).\n", --- a/src/fw/biostables.c +++ b/src/fw/biostables.c @@ -11,43 +11,44 @@ #include "memmap.h" // SYMBOL #include "output.h" // dprintf #include "romfile.h" // romfile_find #include "std/acpi.h" // struct rsdp_descriptor #include "std/mptable.h" // MPTABLE_SIGNATURE #include "std/pirtable.h" // struct pir_header #include "std/smbios.h" // struct smbios_entry_point #include "string.h" // memcpy #include "util.h" // copy_table #include "x86.h" // outb struct pir_header *PirAddr VARFSEG; +static const char *Copying_f_t = "Copying "; void copy_pir(void *pos) { struct pir_header *p = pos; if (p->signature != PIR_SIGNATURE) return; if (PirAddr) return; if (p->size < sizeof(*p)) return; if (checksum(pos, p->size) != 0) return; void *newpos = malloc_fseg(p->size); if (!newpos) { warn_noalloc(); return; } - dprintf(1, "Copying PIR from %p to %p\n", pos, newpos); + dprintf(1, "%sPIR %p > %p\n", Copying_f_t, pos, newpos); memcpy(newpos, pos, p->size); PirAddr = newpos; } void copy_mptable(void *pos) { struct mptable_floating_s *p = pos; if (p->signature != MPTABLE_SIGNATURE) return; if (!p->physaddr) return; @@ -59,25 +60,25 @@ copy_mptable(void *pos) dprintf(1, "Skipping MPTABLE copy due to large size (%d bytes)\n" , length + mpclength); return; } // Allocate final memory location. (In theory the config // structure can go in high memory, but Linux kernels before // v2.6.30 crash with that.) struct mptable_floating_s *newpos = malloc_fseg(length + mpclength); if (!newpos) { warn_noalloc(); return; } - dprintf(1, "Copying MPTABLE from %p/%x to %p\n", pos, p->physaddr, newpos); + dprintf(1, "%sMPTABLE %p/%x > %p\n", Copying_f_t, pos, p->physaddr, newpos); memcpy(newpos, pos, length); newpos->physaddr = (u32)newpos + length; newpos->checksum -= checksum(newpos, sizeof(*newpos)); memcpy((void*)newpos + length, (void*)p->physaddr, mpclength); } /**************************************************************** * ACPI ****************************************************************/ static int @@ -107,25 +108,25 @@ void copy_acpi_rsdp(void *pos) { if (RsdpAddr) return; int length = get_acpi_rsdp_length(pos, -1); if (length < 0) return; void *newpos = malloc_fseg(length); if (!newpos) { warn_noalloc(); return; } - dprintf(1, "Copying ACPI RSDP from %p to %p\n", pos, newpos); + dprintf(1, "%sACPI RSDP %p > %p\n", Copying_f_t, pos, newpos); memcpy(newpos, pos, length); RsdpAddr = newpos; } void *find_acpi_rsdp(void) { unsigned long start = SYMBOL(zonefseg_start); unsigned long end = SYMBOL(zonefseg_end); unsigned long pos; for (pos = ALIGN(start, 0x10); pos <= ALIGN_DOWN(end, 0x10); pos += 0x10) if (get_acpi_rsdp_length((void *)pos, end - pos) >= 0) @@ -280,25 +281,25 @@ copy_smbios(void *pos) return; if (checksum(pos, 0x10) != 0) return; if (memcmp(p->intermediate_anchor_string, "_DMI_", 5)) return; if (checksum(pos+0x10, p->length-0x10) != 0) return; struct smbios_entry_point *newpos = malloc_fseg(p->length); if (!newpos) { warn_noalloc(); return; } - dprintf(1, "Copying SMBIOS entry point from %p to %p\n", pos, newpos); + dprintf(1, "%sSMBIOS entry point %p > %p\n", Copying_f_t, pos, newpos); memcpy(newpos, pos, p->length); SMBiosAddr = newpos; } void display_uuid(void) { struct smbios_type_1 *tbl = smbios_next(SMBiosAddr, NULL); int minlen = offsetof(struct smbios_type_1, uuid) + sizeof(tbl->uuid); for (; tbl; tbl = smbios_next(SMBiosAddr, tbl)) if (tbl->header.type == 1 && tbl->header.length >= minlen) { u8 *uuid = tbl->uuid; --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -35,68 +35,71 @@ int PlatformRunningOn VARFSEG; int cfg_dma_enabled = 0; inline int qemu_cfg_dma_enabled(void) { return cfg_dma_enabled; } /* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx. It * should be used to determine that a VM is running under KVM. */ #define KVM_CPUID_SIGNATURE 0x40000000 +static const char *running_on = "Running on "; +static const char *running_on_qemu_str = "QEMU ("; + static void kvm_detect(void) { unsigned int eax, ebx, ecx, edx; char signature[13]; cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx); memcpy(signature + 0, &ebx, 4); memcpy(signature + 4, &ecx, 4); memcpy(signature + 8, &edx, 4); signature[12] = 0; if (strcmp(signature, "KVMKVMKVM") == 0) { - dprintf(1, "Running on KVM\n"); + dprintf(1, "%sKVM\n", running_on); PlatformRunningOn |= PF_KVM; } } static void qemu_detect(void) { if (!CONFIG_QEMU_HARDWARE) return; // check northbridge @ 00:00.0 u16 v = pci_config_readw(0, PCI_VENDOR_ID); if (v == 0x0000 || v == 0xffff) return; u16 d = pci_config_readw(0, PCI_DEVICE_ID); u16 sv = pci_config_readw(0, PCI_SUBSYSTEM_VENDOR_ID); u16 sd = pci_config_readw(0, PCI_SUBSYSTEM_ID); if (sv != 0x1af4 || /* Red Hat, Inc */ sd != 0x1100) /* Qemu virtual machine */ return; PlatformRunningOn |= PF_QEMU; switch (d) { case 0x1237: - dprintf(1, "Running on QEMU (i440fx)\n"); + dprintf(1, "%s%si440fx)\n", running_on, running_on_qemu_str); break; case 0x29c0: - dprintf(1, "Running on QEMU (q35)\n"); + dprintf(1, "%s%sq35)\n", running_on, running_on_qemu_str); break; default: - dprintf(1, "Running on QEMU (unknown nb: %04x:%04x)\n", v, d); + dprintf(1, "%s%sunknown nb: %04x:%04x)\n", running_on, running_on_qemu_str, v, d); break; } kvm_detect(); } void qemu_preinit(void) { qemu_detect(); if (!CONFIG_QEMU) return; --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -18,24 +18,28 @@ #include "malloc.h" // free #include "output.h" // dprintf #include "paravirt.h" // RamSize #include "romfile.h" // romfile_loadint #include "string.h" // memset #include "util.h" // pci_setup #include "x86.h" // outb #define PCI_DEVICE_MEM_MIN (1<<12) // 4k == page size #define PCI_BRIDGE_MEM_MIN (1<<21) // 2M == hugepage size #define PCI_BRIDGE_IO_MIN 0x1000 // mandated by pci bridge spec +static const char *pri_bus_str = "PCI: primary bus = "; +static const char *sec_bus_str = "PCI: secondary bus = "; +static const char *sub_bus_str = "PCI: subordinate bus = "; + static const char *region_type_name[] = { [ PCI_REGION_TYPE_IO ] = "io", [ PCI_REGION_TYPE_MEM ] = "mem", [ PCI_REGION_TYPE_PREFMEM ] = "prefmem", }; u64 pcimem_start = BUILD_PCIMEM_START; u64 pcimem_end = BUILD_PCIMEM_END; u64 pcimem64_start = BUILD_PCIMEM64_START; u64 pcimem64_end = BUILD_PCIMEM64_END; u64 pci_io_low_end = 0xa000; @@ -452,54 +456,52 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus) } } foreachbdf(bdf, bus) { class = pci_config_readw(bdf, PCI_CLASS_DEVICE); if (class != PCI_CLASS_BRIDGE_PCI) { continue; } dprintf(1, "PCI: %s bdf = 0x%x\n", __func__, bdf); u8 pribus = pci_config_readb(bdf, PCI_PRIMARY_BUS); if (pribus != bus) { - dprintf(1, "PCI: primary bus = 0x%x -> 0x%x\n", pribus, bus); + dprintf(1, "%s0x%x -> 0x%x\n", pri_bus_str, pribus, bus); pci_config_writeb(bdf, PCI_PRIMARY_BUS, bus); } else { - dprintf(1, "PCI: primary bus = 0x%x\n", pribus); + dprintf(1, "%s0x%x\n", pri_bus_str, pribus); } u8 secbus = pci_config_readb(bdf, PCI_SECONDARY_BUS); (*pci_bus)++; if (*pci_bus != secbus) { - dprintf(1, "PCI: secondary bus = 0x%x -> 0x%x\n", - secbus, *pci_bus); + dprintf(1, "%s0x%x -> 0x%x\n", sec_bus_str, secbus, *pci_bus); secbus = *pci_bus; pci_config_writeb(bdf, PCI_SECONDARY_BUS, secbus); } else { - dprintf(1, "PCI: secondary bus = 0x%x\n", secbus); + dprintf(1, "%s0x%x\n", sec_bus_str, secbus); } /* set to max for access to all subordinate buses. later set it to accurate value */ u8 subbus = pci_config_readb(bdf, PCI_SUBORDINATE_BUS); pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, 255); pci_bios_init_bus_rec(secbus, pci_bus); if (subbus != *pci_bus) { - dprintf(1, "PCI: subordinate bus = 0x%x -> 0x%x\n", - subbus, *pci_bus); + dprintf(1, "%s0x%x -> 0x%x\n", sub_bus_str, subbus, *pci_bus); subbus = *pci_bus; } else { - dprintf(1, "PCI: subordinate bus = 0x%x\n", subbus); + dprintf(1, "%s0x%x\n", sub_bus_str, subbus); } pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, subbus); } } static void pci_bios_init_bus(void) { u8 extraroots = romfile_loadint("etc/extra-pci-roots", 0); u8 pci_bus = 0; pci_bios_init_bus_rec(0 /* host bus */, &pci_bus); @@ -914,51 +916,52 @@ static void pci_bios_map_devices(struct pci_bus *busses) for (bus = 0; bus<=MaxPCIBus; bus++) { int type; for (type = 0; type < PCI_REGION_TYPE_COUNT; type++) pci_region_map_entries(busses, &busses[bus].r[type]); } } /**************************************************************** * Main setup code ****************************************************************/ +static const char *PCI_pass = "=== PCI new allocation pass ==="; void pci_setup(void) { if (!CONFIG_QEMU) return; dprintf(3, "pci setup\n"); dprintf(1, "=== PCI bus & bridge init ===\n"); if (pci_probe_host() != 0) { return; } pci_bios_init_bus(); dprintf(1, "=== PCI device probing ===\n"); pci_probe_devices(); pcimem_start = RamSize; pci_bios_init_platform(); - dprintf(1, "=== PCI new allocation pass #1 ===\n"); + dprintf(1, "%s\n", PCI_pass); struct pci_bus *busses = malloc_tmp(sizeof(*busses) * (MaxPCIBus + 1)); if (!busses) { warn_noalloc(); return; } memset(busses, 0, sizeof(*busses) * (MaxPCIBus + 1)); if (pci_bios_check_devices(busses)) return; - dprintf(1, "=== PCI new allocation pass #2 ===\n"); + dprintf(1, "%s\n", PCI_pass); pci_bios_map_devices(busses); pci_bios_init_devices(); free(busses); pci_enable_default_vga(); } --- a/src/hw/ps2port.c +++ b/src/hw/ps2port.c @@ -144,47 +144,48 @@ i8042_reboot(void) udelay(50); } } /**************************************************************** * Device commands. ****************************************************************/ #define PS2_RET_ACK 0xfa #define PS2_RET_NAK 0xfe +static const char *discarding_ps2 = "Discarding ps2 data "; static int ps2_recvbyte(int aux, int needack, int timeout) { u32 end = timer_calc(timeout); for (;;) { u8 status = inb(PORT_PS2_STATUS); if (status & I8042_STR_OBF) { u8 data = inb(PORT_PS2_DATA); dprintf(7, "ps2 read %x\n", data); if (!!(status & I8042_STR_AUXDATA) == aux) { if (!needack) return data; if (data == PS2_RET_ACK) return data; if (data == PS2_RET_NAK) { dprintf(1, "Got ps2 nak (status=%x)\n", status); return data; } } // This data not part of command - just discard it. - dprintf(1, "Discarding ps2 data %02x (status=%02x)\n", data, status); + dprintf(1, "%s%02x (status=%02x)\n", discarding_ps2, data, status); } if (timer_check(end)) { // Don't warn on second byte of a reset if (timeout > 100) warn_timeout(); return -1; } yield(); } } --- a/src/hw/usb-hub.c +++ b/src/hw/usb-hub.c @@ -2,24 +2,26 @@ // // Copyright (C) 2010 Kevin O'Connor <kevin@koconnor.net> // // This file may be distributed under the terms of the GNU LGPLv3 license. #include "config.h" // CONFIG_USB_HUB #include "output.h" // dprintf #include "string.h" // memset #include "usb.h" // struct usb_s #include "usb-hub.h" // struct usb_hub_descriptor #include "util.h" // timer_calc +static const char *port_hub_fail_str = "Failure on hub port "; + static int get_hub_desc(struct usb_pipe *pipe, struct usb_hub_descriptor *desc) { struct usb_ctrlrequest req; req.bRequestType = USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_DEVICE; req.bRequest = USB_REQ_GET_DESCRIPTOR; if (pipe->speed == USB_SUPERSPEED) req.wValue = USB_DT_HUB3<<8; else req.wValue = USB_DT_HUB<<8; req.wIndex = 0; req.wLength = sizeof(*desc); @@ -73,45 +75,44 @@ get_port_status(struct usbhub_s *hub, int port, struct usb_port_status *sts) { struct usb_ctrlrequest req; req.bRequestType = USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_OTHER; req.bRequest = USB_REQ_GET_STATUS; req.wValue = 0; req.wIndex = port + 1; req.wLength = sizeof(*sts); mutex_lock(&hub->lock); int ret = usb_send_default_control(hub->usbdev->defpipe, &req, sts); mutex_unlock(&hub->lock); return ret; } - // Check if device attached to port static int usb_hub_detect(struct usbhub_s *hub, u32 port) { struct usb_port_status sts; int ret = get_port_status(hub, port, &sts); if (ret) { - dprintf(1, "Failure on hub port %d detect\n", port); + dprintf(1, "%s%d detect\n", port_hub_fail_str, port); return -1; } return (sts.wPortStatus & USB_PORT_STAT_CONNECTION) ? 1 : 0; } // Disable port static void usb_hub_disconnect(struct usbhub_s *hub, u32 port) { int ret = clear_port_feature(hub, port, USB_PORT_FEAT_ENABLE); if (ret) - dprintf(1, "Failure on hub port %d disconnect\n", port); + dprintf(1, "%s%d disconnect\n", port_hub_fail_str, port); } // Reset device on port static int usb_hub_reset(struct usbhub_s *hub, u32 port) { int ret = set_port_feature(hub, port, USB_PORT_FEAT_RESET); if (ret) goto fail; // Wait for reset to complete. struct usb_port_status sts; @@ -133,25 +134,25 @@ usb_hub_reset(struct usbhub_s *hub, u32 port) // Reset complete. if (!(sts.wPortStatus & USB_PORT_STAT_CONNECTION)) // Device no longer present return -1; if (hub->usbdev->speed == USB_SUPERSPEED) return USB_SUPERSPEED; return ((sts.wPortStatus & USB_PORT_STAT_SPEED_MASK) >> USB_PORT_STAT_SPEED_SHIFT); fail: - dprintf(1, "Failure on hub port %d reset\n", port); + dprintf(1, "%s%d reset\n", port_hub_fail_str, port); usb_hub_disconnect(hub, port); return -1; } static struct usbhub_op_s HubOp = { .detect = usb_hub_detect, .reset = usb_hub_reset, .disconnect = usb_hub_disconnect, }; // Configure a usb hub and then find devices connected to it. int --- a/src/hw/usb-msc.c +++ b/src/hw/usb-msc.c @@ -41,24 +41,27 @@ struct cbw_s { u8 CBWCB[16]; } PACKED; #define CSW_SIGNATURE 0x53425355 // USBS struct csw_s { u32 dCSWSignature; u32 dCSWTag; u32 dCSWDataResidue; u8 bCSWStatus; } PACKED; +static const char *cant_config_str = "Unable to configure USB MSC "; +static const char *usb_transmission_fail = "USB transmission failed"; + static int usb_msc_send(struct usbdrive_s *udrive_gf, int dir, void *buf, u32 bytes) { struct usb_pipe *pipe; if (dir == USB_DIR_OUT) pipe = GET_GLOBALFLAT(udrive_gf->bulkout); else pipe = GET_GLOBALFLAT(udrive_gf->bulkin); return usb_send_bulk(pipe, dir, buf, bytes); } // Low-level usb command transmit function. @@ -109,25 +112,25 @@ usb_process_op(struct disk_op_s *op) if (!csw.bCSWStatus) return DISK_RET_SUCCESS; if (csw.bCSWStatus == 2) goto fail; if (blocksize) op->count -= csw.dCSWDataResidue / blocksize; return DISK_RET_EBADTRACK; fail: // XXX - reset connection - dprintf(1, "USB transmission failed\n"); + dprintf(1, "%s\n", usb_transmission_fail); return DISK_RET_EBADTRACK; } static int usb_msc_maxlun(struct usb_pipe *pipe) { struct usb_ctrlrequest req; req.bRequestType = USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; req.bRequest = 0xfe; req.wValue = 0; req.wIndex = 0; req.wLength = 1; @@ -151,25 +154,25 @@ usb_msc_lun_setup(struct usb_pipe *inpipe, struct usb_pipe *outpipe, memset(drive, 0, sizeof(*drive)); if (usb_32bit_pipe(inpipe)) drive->drive.type = DTYPE_USB_32; else drive->drive.type = DTYPE_USB; drive->bulkin = inpipe; drive->bulkout = outpipe; drive->lun = lun; int prio = bootprio_find_usb(usbdev, lun); int ret = scsi_drive_setup(&drive->drive, "USB MSC", prio); if (ret) { - dprintf(1, "Unable to configure USB MSC drive.\n"); + dprintf(1, "%sdrive.\n", cant_config_str); free(drive); return -1; } return 0; } /**************************************************************** * Setup ****************************************************************/ // Configure a usb msc device. int @@ -206,17 +209,17 @@ usb_msc_setup(struct usbdevice_s *usbdev) int lun, pipesused = 0; for (lun = 0; lun < maxlun + 1; lun++) { int ret = usb_msc_lun_setup(inpipe, outpipe, usbdev, lun); if (!ret) pipesused = 1; } if (!pipesused) goto fail; return 0; fail: - dprintf(1, "Unable to configure USB MSC device.\n"); + dprintf(1, "%sdevice.\n", cant_config_str); usb_free_pipe(usbdev, inpipe); usb_free_pipe(usbdev, outpipe); return -1; } --- a/src/hw/usb-uhci.c +++ b/src/hw/usb-uhci.c @@ -390,36 +390,37 @@ uhci_realloc_pipe(struct usbdevice_s *usbdev, struct usb_pipe *upipe pipe->iobase = cntl->iobase; // Add queue head to controller list. struct uhci_qh *control_qh = cntl->control_qh; pipe->qh.link = control_qh->link; barrier(); control_qh->link = (u32)&pipe->qh | UHCI_PTR_QH; if (eptype == USB_ENDPOINT_XFER_CONTROL) cntl->control_qh = &pipe->qh; return &pipe->pipe; } +static const char *Timeout_wait_pipe = "Timeout on wait_pipe "; static int wait_pipe(struct uhci_pipe *pipe, u32 end) { for (;;) { u32 el_link = GET_LOWFLAT(pipe->qh.element); if (el_link & UHCI_PTR_TERM) return 0; if (timer_check(end)) { warn_timeout(); u16 iobase = GET_LOWFLAT(pipe->iobase); struct uhci_td *td = (void*)(el_link & ~UHCI_PTR_BITS); - dprintf(1, "Timeout on wait_pipe %p (td=%p s=%x c=%x/%x)\n" + dprintf(1, "%s%p (td=%p s=%x c=%x/%x)\n", Timeout_wait_pipe , pipe, (void*)el_link, GET_LOWFLAT(td->status) , inw(iobase + USBCMD) , inw(iobase + USBSTS)); SET_LOWFLAT(pipe->qh.element, UHCI_PTR_TERM); uhci_waittick(iobase); return -1; } yield(); } } static int --- a/src/output.c +++ b/src/output.c @@ -8,24 +8,25 @@ #include "farptr.h" // GET_VAR #include "bregs.h" // struct bregs #include "config.h" // CONFIG_* #include "biosvar.h" // GET_GLOBAL #include "hw/serialio.h" // serial_debug_putc #include "malloc.h" // malloc_tmp #include "output.h" // dprintf #include "stacks.h" // call16_int #include "string.h" // memset #include "util.h" // ScreenAndDebug +static const char *WARNING = "WARNING - "; struct putcinfo { void (*func)(struct putcinfo *info, char c); }; /**************************************************************** * Debug output ****************************************************************/ void debug_banner(void) { @@ -497,41 +498,44 @@ void __warn_unimplemented(struct bregs *regs, int lineno, const char *fname) { if (CONFIG_DEBUG_LEVEL >= DEBUG_unimplemented) { dprintf(1, "unimplemented %s:%d:\n", fname, lineno); dump_regs(regs); } } // Report a detected internal inconsistency. void __warn_internalerror(int lineno, const char *fname) { - dprintf(1, "WARNING - internal error detected at %s:%d!\n" + dprintf(1, "%sinternal error detected at %s:%d!\n" + , WARNING , fname, lineno); } +static const char *Unable_allocate = "Unable to allocate resource at "; // Report on an allocation failure. void __warn_noalloc(int lineno, const char *fname) { - dprintf(1, "WARNING - Unable to allocate resource at %s:%d!\n" + dprintf(1, "%s%s%s:%d!\n" + , WARNING, Unable_allocate , fname, lineno); } // Report on a timeout exceeded. void __warn_timeout(int lineno, const char *fname) { - dprintf(1, "WARNING - Timeout at %s:%d!\n", fname, lineno); + dprintf(1, "%sTimeout at %s:%d!\n", WARNING, fname, lineno); } // Report a handler reporting an invalid parameter to the caller. void __set_invalid(struct bregs *regs, int lineno, const char *fname) { __warn_invalid(regs, lineno, fname); set_invalid_silent(regs); } // Report a call of an unimplemented function. void --- a/src/output.h +++ b/src/output.h @@ -7,54 +7,58 @@ // output.c void debug_banner(void); void panic(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) __noreturn; void printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); int snprintf(char *str, size_t size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); char * znprintf(size_t size, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void __dprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +static inline void ___dprintf(const char *fmt, ...) { }; struct bregs; void __debug_enter(struct bregs *regs, const char *fname); +static inline void ___debug_enter(struct bregs *regs, const char *fname) {}; void __debug_isr(const char *fname); +static inline void ___debug_isr(const char *fname) {}; void __debug_stub(struct bregs *regs, int lineno, const char *fname); +static inline void ___debug_stub(struct bregs *regs, int lineno, const char *fname) {}; void __warn_invalid(struct bregs *regs, int lineno, const char *fname); void __warn_unimplemented(struct bregs *regs, int lineno, const char *fname); void __warn_internalerror(int lineno, const char *fname); void __warn_noalloc(int lineno, const char *fname); void __warn_timeout(int lineno, const char *fname); void __set_invalid(struct bregs *regs, int lineno, const char *fname); void __set_unimplemented(struct bregs *regs, int lineno, const char *fname); void __set_code_invalid(struct bregs *regs, u32 linecode, const char *fname); void __set_code_unimplemented(struct bregs *regs, u32 linecode , const char *fname); void hexdump(const void *d, int len); #define dprintf(lvl, fmt, args...) do { \ if (CONFIG_DEBUG_LEVEL && (lvl) <= CONFIG_DEBUG_LEVEL) \ - __dprintf((fmt) , ##args ); \ + ___dprintf((fmt) , ##args ); \ } while (0) #define debug_enter(regs, lvl) do { \ if ((lvl) && (lvl) <= CONFIG_DEBUG_LEVEL) \ - __debug_enter((regs), __func__); \ + ___debug_enter((regs), __func__); \ } while (0) #define debug_isr(lvl) do { \ if ((lvl) && (lvl) <= CONFIG_DEBUG_LEVEL) \ - __debug_isr(__func__); \ + ___debug_isr(__func__); \ } while (0) #define debug_stub(regs) \ - __debug_stub((regs), __LINE__, __func__) + ___debug_stub((regs), __LINE__, __func__) #define warn_invalid(regs) \ __warn_invalid((regs), __LINE__, __func__) #define warn_unimplemented(regs) \ __warn_unimplemented((regs), __LINE__, __func__) #define warn_internalerror() \ __warn_internalerror(__LINE__, __func__) #define warn_noalloc() \ __warn_noalloc(__LINE__, __func__) #define warn_timeout() \ __warn_timeout(__LINE__, __func__) #define set_invalid(regs) \ __set_invalid((regs), __LINE__, __func__) --- a/src/vgahooks.c +++ b/src/vgahooks.c @@ -9,24 +9,25 @@ #include "config.h" // CONFIG_* #include "hw/pci.h" // pci_find_device #include "hw/pci_ids.h" // PCI_VENDOR_ID_VIA #include "hw/pci_regs.h" // PCI_VENDOR_ID #include "output.h" // dprintf #include "string.h" // strcmp #include "util.h" // handle_155f, handle_157f #define VH_VIA 1 #define VH_INTEL 2 #define VH_SMI 3 +static const char *Warning = "Warning: "; int VGAHookHandlerType VARFSEG; static void handle_155fXX(struct bregs *regs) { set_code_unimplemented(regs, RET_EUNSUPPORTED); } static void handle_157fXX(struct bregs *regs) { set_code_unimplemented(regs, RET_EUNSUPPORTED); @@ -35,36 +36,36 @@ handle_157fXX(struct bregs *regs) /**************************************************************** * Via hooks ****************************************************************/ int ViaFBsize VARFSEG, ViaRamSpeed VARFSEG; static void via_155f01(struct bregs *regs) { regs->eax = 0x5f; regs->cl = 2; // panel type = 2 = 1024 * 768 set_success(regs); - dprintf(1, "Warning: VGA panel type is hardcoded\n"); + dprintf(1, "%sVGA panel type is hardcoded\n", Warning); } static void via_155f02(struct bregs *regs) { regs->eax = 0x5f; regs->bx = 2; regs->cx = 0x401; // PAL + crt only regs->dx = 0; // TV Layout - default set_success(regs); - dprintf(1, "Warning: VGA TV/CRT output type is hardcoded\n"); + dprintf(1, "%sVGA TV/CRT output type is hardcoded\n", Warning); } static void via_155f18(struct bregs *regs) { int fbsize = GET_GLOBAL(ViaFBsize), ramspeed = GET_GLOBAL(ViaRamSpeed); if (fbsize < 0 || ramspeed < 0) { set_code_invalid(regs, RET_EUNSUPPORTED); return; } regs->eax = 0x5f; regs->ebx = 0x500 | (ramspeed << 4) | fbsize; @@ -156,25 +157,25 @@ via_setup(struct pci_device *pci) if (d) { ViaFBsize = getFBSize(d); ViaRamSpeed = getAMDRamSpeed(); return; } d = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855_MEMCTRL); if (d) { ViaFBsize = getFBSize(d); ViaRamSpeed = getViaRamSpeed(d); return; } - dprintf(1, "Warning: VGA memory size and speed is hardcoded\n"); + dprintf(1, "%sVGA memory size and speed is hardcoded\n", Warning); ViaFBsize = 5; // 32M frame buffer ViaRamSpeed = 4; // MCLK = DDR266 } /**************************************************************** * Intel VGA hooks ****************************************************************/ u8 IntelDisplayType VARFSEG, IntelDisplayId VARFSEG; static void
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor