aboutsummaryrefslogtreecommitdiff
path: root/src/hw
AgeCommit message (Collapse)AuthorFilesLines
2020-05-15acpi: skip kbd init if not presentGerd Hoffmann1-0/+4
Don't initialize the ps/2 keyboard in case the device is not listed in the ACPi DSDT table. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15virtio-mmio: print device typeGerd Hoffmann1-2/+19
2020-05-15virtio-mmio: add support for block devices.Gerd Hoffmann3-1/+74
Add and use bootprio_find_mmio_device() to figure the boot priority of virtio-mmio block devices. Add init_virtio_blk_mmio to initialize one virtio-mmio block device. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15virtio-mmio: add support for scsi devices.Gerd Hoffmann3-12/+65
Add new fields to struct virtio_lun_s for mmio support, add mmio parameter to virtio_scsi_init_lun(), so both pci and mmio devices can be handled. Add and use bootprio_find_scsi_mmio_device() to figure boot priority of devices connected to a virtio-mmio scsi controller. Finally add init_virtio_scsi_mmio() to initialize one virtio-mmio scsi controller. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15virtio-mmio: add support to vp_*() functionsGerd Hoffmann1-11/+57
Add support for virtio-mmio to the vp_*() helper functions. Both legacy and 1.0 virto-mmio versions are supported. They are very simliar anyway, only the virtqueue initialization is slightly different. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15virtio-mmio: device probing and initialization.Gerd Hoffmann3-0/+135
Add virtio_mmio_setup_one() to setup virtio mmio devices. Add vp_init_mmio() to initialize device struct. Because virtio-pci and virtio-mmio are quite simliar we reuse the infrastructure we already have for virtio-pci and just setup struct vp_cap for virtio-mmio. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-03-27pci: add mmconfig supportGerd Hoffmann2-12/+53
Add support for pci config space access via mmconfig bar. Enable for qemu q35 chipset. Main advantage is that we need only one instead of two io operations per config space access, which translates to one instead of two vmexits for virtualization. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200323145911.22319-3-kraxel@redhat.com
2020-03-27pci: factor out ioconfig_cmd()Gerd Hoffmann1-6/+11
Add helper function to calculate PORT_PCI_CMD value from bdf + addr. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200323145911.22319-2-kraxel@redhat.com
2020-03-17ps2port: adjust init routine to fix PS/2 keyboard issuesMatt DeVillier1-5/+13
PS/2 keyboards on Chromebooks with upstream coreboot + SeaBIOS often fail to init properly / register keystrokes. Modify ps2port init to match that of TianoCore, which doesn't have said issues. Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de> Message-Id: <248435f9-c169-e1db-fc3e-62185b74899c@molgen.mpg.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-03-16timer: add tsctimer_setfreq()Gerd Hoffmann1-1/+25
Add function to set tsc frequency directly, without calibration. Also tweak timer setup functions a bit: skip setup in case TimerPort has not the default value any more, i.e. another timer has been setup already. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200310102248.28412-1-kraxel@redhat.com
2020-03-06hw/usb-hid: Don't abort if setting key repeat rate failsMatt DeVillier1-1/+1
Since the USB stack doesn't handle stalled pipes, don't abort keyboard setup if the set_idle command fails, since it's a non-critical feature. Instead, log a warning. Test: build/boot Google Pixel Slate, observe keyboard functional Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2020-03-06usb-hid: Improve max packet size checkingKevin O'Connor1-22/+33
Some USB keyboards report 9 or 10-byte max packet sizes instead of the 8-byte max specified by the USB HID spec. Increase the available size and simplify the boundary checks. Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-14nvme: skip initializing non-bootable devicesGerd Hoffmann1-0/+7
Check NVMe devices whenever they are bootable, skip initialization in case they are not. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-01-14virtio-scsi: skip initializing non-bootable devicesGerd Hoffmann1-1/+10
Check each disk attached to a virtio-scsi device whenever it is bootable and skip initialization in case it isn't. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-01-14virtio: Do not init non-bootable devicesAlexey Kirillov2-2/+20
Because initializing a virtio-blk or virtio-scsi device requires a large amount of memory, you cannot create more than about 10 virtio devices. Since initialization is required for booting from media, we will not initialize those devices that are not in the boot order list. Signed-off-by: Alexey Kirillov <lekiravi@yandex-team.ru> Message-id: 20200107171917.7535-3-lekiravi@yandex-team.ru Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-11-18geometry: Apply LCHS values for boot devicesSam Eiderman9-0/+21
Boot devices which use overriden LCHS values are: * ata * ahci * scsi * esp * lsi * megasas * mpt * pvscsi * virtio * virtio-blk We use these values in get_translation() and setup_translation() by introducing a new translation type: "TRANSLATION_HOST". We treat this translation as TRANSLATION_NONE in fill_ata_edd(), although this does not really matter since now the translation between physical and logical geometry does not exist. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190626123816.8907-6-shmuel.eiderman@oracle.com>
2019-11-18Revert "geometry: Apply LCHS values for boot devices"Gerd Hoffmann9-21/+0
This reverts commit 9caa19be0e534c687081fbdfcd301406e728c98c.
2019-11-13tpm: Require a response to have minimum size of a valid response headerStefan Berger1-1/+2
Defend against a broken TPM 1.2 or TPM 2.0 that doesn't send at least a full response header in the response but less than 10 bytes. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-13ahci: zero-initialize port structGerd Hoffmann1-0/+1
Specifically port->drive.lchs needs clearing, otherwise seabios will try interpret whatever random crap happens to be there as disk geometry, which may or may not break boot depending on how lucky you are. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2019-11-06geometry: Apply LCHS values for boot devicesSam Eiderman9-0/+21
Boot devices which use overriden LCHS values are: * ata * ahci * scsi * esp * lsi * megasas * mpt * pvscsi * virtio * virtio-blk We use these values in get_translation() and setup_translation() by introducing a new translation type: "TRANSLATION_MACHINE". We treat this translation as TRANSLATION_NONE in fill_ata_edd(), although this does not really matter since now the translation between physical and logical geometry does not exist. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190612093704.47175-6-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-18virtio: extend virtio queue size to 256Denis Plotnikov1-1/+1
The goal of the patch is to work around a performance bug in guest linux kernels. Old linux kernels has a performance flaw in virtio block device access: on some frequent disk access patterns, e.g. 1M read, the kernel produces more block requests than needed. This happens because of virtio seg_max parameter set to 126 (virtqueue_size - 2) which limits the maximum block request to 516096 (126 * 4096_PAGE_SIZE) bytes. Setting seg_max > 126 fixes the issue, however, not all linux kernels allow that without increasing virtio virtqueue size. The old kernels have a restriction: virtqueue_size >= seg_max. In case of the restriction violation the old kernels crash. The restriction is relaxed in the recent linux kernels (ver >= 4.13) with: commit 44ed8089e991a60d614abe0ee4b9057a28b364e4 Author: Richard W.M. Jones Date: Thu Aug 10 17:56:51 2017 +0100 scsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN. and the recent linux kernels don't crash if total_sg > virtqueue size allowing to set seg_max to the needed value without virtqueue size increasing. To fix the performance flaw in the old linux kernels, it's needed to increse seg_max to 254, and comply the restriction by setting virtqueue_size to 256. This is achievable if seabios can support virtqueue size > 128 which this patch actually does. Windows kernels don't have virtqueue_size >= seg_max restriction and isn't affected with this kind of the performance bug. Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-23virtio-pci: Use %pP format in dprintf() callsKevin O'Connor1-6/+4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-04usb-ehci: Clear pipe token on pipe reallocateKevin O'Connor1-0/+1
Make sure to clear the token before reuse as it may otherwise have an incorrect toggle setting. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-12-10qemu: avoid debug prints if debugcon is not enabledStefano Garzarella2-2/+15
In order to speed up the boot phase, we can check the QEMU debugcon device, and disable the writes if it is not recognized. This patch allow us to save around 10 msec (time measured between SeaBIOS entry point and "linuxboot" entry point) when CONFIG_DEBUG_LEVEL=1 and debugcon is not enabled. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-11-27pvscsi: ring_desc do not have to be page alignedLiran Alon1-1/+1
In contrast to other allocations made by pvscsi_init_rings(), ring_desc is only used internally by SeaBIOS (not passed to device-controller) and there is not restriction which force it to be page aligned. Reviewed-by: Mark Kanda <mark.kanda@oracle.com> Signed-off-by: Liran Alon <liran.alon@oracle.com>
2018-11-10pvscsi: Scan all 64 possible targetsShmuel Eiderman1-1/+1
The max number of targets per PVSCSI controller is 64, not 7. This can easily be seen in QEMU PVSCSI emulation code (hw/scsi/vmw_pvscsi.c) as PVSCSI_MAX_DEVS, which defines the number of targets, have value of 64. Fixes: 83d60b3c474b ("Add pvscsi boot support") Reviewed-by: Liran Alon <liran.alon@oracle.com> Reviewed-by: Mark Kanda <mark.kanda@oracle.com> Signed-off-by: Shmuel Eiderman <shmuel.eiderman@oracle.com>
2018-09-05pci: recognize RH PCI legacy bridge resource reservation capabilityJing Liu1-0/+1
Enable the firmware recognizing RedHat legacy PCI bridge device ID, so QEMU can reserve additional PCI bridge resource capability. Change the debug level lower to 3 when it is non-QEMU bridge. Signed-off-by: Jing Liu <jing2.liu@linux.intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com> Message-id: 1535100781-3910-4-git-send-email-jing2.liu@linux.intel.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-09-03sdcard: Increase SDHCI_POWER_ON_TIME to 5msKevin O'Connor1-1/+1
It appears some sd cards need additional time to initialize after power on. Reported-by: Chris <coderight@gmail.com>. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-08-23nvme: fix I/O queue length calculation overflowMatt DeVillier1-2/+2
Commit cd47172 changed the I/O queue length calculation to use the Maximum Queue Entries Supported (MQES) value from the capabilities register, plus one, with a maximum value of NVME_PAGE_SIZE. An unintended effect from this is that due to length being an unsigned 16-bit int, a MQES value of 0xFFFF yields a length of zero, resulting in the queue allocation failing. Fix this by changing length to a u32. TEST: build/boot on a Purism Librem13v2 with a MyDigitalSSD BPX NVMe drive, which reports a MQES of 0xFFFF. Verify NVMe drive present in boot menu and OS boots successfully. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
2018-04-12tpm: Request access to locality 0Stefan Berger1-0/+2
The CRB driver has to request access to locality 0. Our QEMU CRB model will enforce that as well. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-21tpm: when CRB is active, select, lock it, and check addressesStefan Berger1-3/+1
Do not just indicate that the probing for the CRB interface was successful if we find it active. Instead, select it, lock it, and test the addresses for whether they can be used (must be 32 bit). Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-21tpm: revert return values for successful/failed CRB probingStefan Berger1-3/+3
The return values for successful/failed CRB probing were reverted. Fix it. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-21tpm: Wait for tpmRegValidSts flag on CRB interface before probingStefan Berger1-0/+10
Wait for the tpmRegValidSts flag on the TPM_LOC_STATE_x register to be set; we expect the locAssigned flag to not be set. Real hardware seems to set the tpmRegValidSts flag without for example requesting access to a locality. Tested-by: Stephen Douthit <stephend@silicom-usa.com> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-02tpm: Handle unimplemented TIS_REG_IFACE_ID in tis_get_tpm_version()Stephen Douthit1-5/+15
If a device reports 0xf in the InterfaceType field of the TPM_INTERFACE_ID, then the rest of the fields are invalid, and the InterfaceVersion field of the TPM_INTF_CAPABILITY register must be checked instead. Signed-off-by: Stephen Douthit <stephend@silicom-usa.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-02tpm: Wait for interface startup when probingStephen Douthit1-1/+12
This is based on wait_startup() from the Linux tpm_tis driver. Signed-off-by: Stephen Douthit <stephend@silicom-usa.com> Tested-by: Stephen Douthit <stephend@silicom-usa.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-02tpm: Refactor duplicated wait code in tis_wait_sts() & crb_wait_reg()Stephen Douthit1-47/+33
Signed-off-by: Stephen Douthit <stephend@silicom-usa.com> Tested-by: Stephen Douthit <stephend@silicom-usa.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-27tpm: add TPM CRB device supportMarc-André Lureau2-1/+221
The CRB device was introduced with TPM 2.0 to be physical-bus agnostic and defined in TCG PC Client Platform TPM Profile (PTP) Specification Family “2.0” Level 00 Revision 01.03 v22 It seems to be required with Windows 10. It is also a simpler device than FIFO/TIS. This patch only support locality 0 since also the CRB device in QEMU only supports this locality. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-27tpm: use get_tpm_version() callbackMarc-André Lureau1-1/+2
As originally intended. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-27tpm: generalize init_timeout()Marc-André Lureau1-10/+15
It seems both TIS & CRB devices share the same timeout. Make initialization function generic now. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-15floppy: Send 4 sense interrupt commands during controller initializationNikolay Nikolov1-1/+14
During initialization, real floppy controllers need 4 sense interrupt commands to clear the interrupt status (this represents the transition from "not ready" to "ready" for each of the four virtual floppy drives), instead of just one. This is described in detail in section 7.4 - Drive Polling of the Intel 82077AA datasheet. Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-15floppy: Wait for the floppy motor to reach a stable speed, after startingNikolay Nikolov1-2/+11
When starting up the floppy motor, wait for a certain amount of time, so that it can spin up and reach a stable speed. This delay is skipped, if the motor was already running (which can happen, since the floppy motor is intentionally kept spinning for 2 seconds after the previous floppy operation completes). Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-15floppy: Support up to 4 floppy drives when turning on the floppy motorNikolay Nikolov1-1/+1
The previous version allowed for only two floppies. Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-15floppy: Execute a SPECIFY command after sensing the media typeNikolay Nikolov1-2/+20
The SPECIFY command sets the Step Rate Time, Head Load Time, Head Unload Time and the DMA enable/disable bit. Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-15floppy: hold the DOR reset bit low for 4 microseconds, when resettingNikolay Nikolov1-0/+2
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-07floppy: Use timer_check() in floppy_wait_irq()Nikolay Nikolov1-4/+5
Use timer_check() instead of using floppy_motor_counter in BDA for the timeout check in floppy_wait_irq(). The problem with using floppy_motor_counter was that, after it reaches 0, it immediately stops the floppy motors, which is not what is supposed to happen on real hardware. Instead, after a timeout (like in the end of every floppy operation, regardless of the result - success, timeout or error), the floppy motors must be kept spinning for additional 2 seconds (the FLOPPY_MOTOR_TICKS). So, now the floppy_motor_counter is initialized to 255 (the max value) in the beginning of the floppy operation. For IRQ timeouts, a different timeout is used, specified by the new FLOPPY_IRQ_TIMEOUT constant (currently set to 5 seconds - a fairly conservative value, but should work reliably on most floppies). After the floppy operation, floppy_drive_pio() resets the floppy_motor_counter to 2 seconds (FLOPPY_MOTOR_TICKS). This is also consistent with what other PC BIOSes do. Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-07floppy: Reset the floppy motor count in floppy_drive_pio()Nikolay Nikolov1-0/+1
Reset the floppy motor count, so the motor keeps spinning 2 seconds after a floppy operation, performed by floppy_drive_pio(). Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-07floppy: Preserve motor and drive sel bits when resetting the floppy controllerNikolay Nikolov1-3/+6
In case of read or write errors, the floppy system is usually reset and the operation is retried. In that case, the floppy motor state must be preserved in order to avoid creating jitter and keep the floppy motor spinning smoothly at a constant speed. Additionally, the drive select bits should probably also be preserved, because some systems might need a small delay after selecting a new drive. In that case, the operation would be retried, without changing the currently selected drive. In floppy_enable_controller(), the IRQ bit is now enabled first, before the reset bit is set. I'm not completely sure whether this is necessary. It is done just in case some hardware introduces a delay between setting this bit and actually enabling the IRQ, which would cause us to miss the IRQ, sent by the controller immediately after reset. Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-07floppy: Introduce FLOPPY_DOR_XXX constantsNikolay Nikolov1-4/+13
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-07floppy: Introduce floppy_dor_mask()Nikolay Nikolov1-1/+7
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
2018-02-07floppy: Introduce the floppy_dor_read() functionNikolay Nikolov1-2/+8
Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>