Commit Graph

282 Commits

Author SHA1 Message Date
Eduardo Habkost 33fa7082b8 smbios: Make SMBios21Addr variable static
The variable is now only used inside biostables.c, there's no
need to make it global.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2021-12-18 11:39:13 -05:00
Eduardo Habkost b251b21b2b smbios: smbios_get_tables() function
The new function will be useful for code that just needs the
address and length of SMBIOS tables.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2021-12-18 11:39:12 -05:00
Eduardo Habkost 97f6c5b024 smbios: Rename code specific for SMBIOS 2.1 entry points
Rename copy_smbios(), smbios_next(), SMBIOS_SIGNATURE,
smbios_entry_point, and SMBiosAddr, to indicate they refer to
SMBIOS 2.1 entry points.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2021-12-18 11:39:12 -05:00
Eduardo Habkost 7b02616560 util.h: Delete unused get_smbios_entry_point() prototype
The get_smbios_entry_point() function doesn't exist, delete
unused prototype.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2021-12-18 11:39:12 -05:00
Gerd Hoffmann 654ba383b6 acpi: add dsdt parser
Create a list of devices found in the DSDT table.  Add helper functions
to find devices, walk the list and figure device informations like mmio
ranges and irqs.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:55:29 +02:00
Gerd Hoffmann c12a1dc75e virtio-mmio: add support for block devices.
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-15 13:37:07 +02:00
Gerd Hoffmann f82e82a5ab virtio-mmio: add support for scsi devices.
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-15 13:36:08 +02:00
Gerd Hoffmann 67cbfedb33 timer: add tsctimer_setfreq()
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-16 14:29:41 +01:00
Alexey Kirillov 7c40d945b9 boot: Detect strict boot order (HALT record) in function
Introduce is_bootprio_strict().
We will reuse this function in the next commit.

Signed-off-by: Alexey Kirillov <lekiravi@yandex-team.ru>
Message-id: 20200107171917.7535-2-lekiravi@yandex-team.ru
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-01-14 09:12:45 +01:00
Sam Eiderman d49496f94e geometry: Add boot_lchs_find_*() utility functions
Adding the following utility functions:

    * boot_lchs_find_pci_device
    * boot_lchs_find_scsi_device
    * boot_lchs_find_ata_device

These will be used to apply LCHS values received through fw_cfg.

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-5-shmuel.eiderman@oracle.com>
2019-11-18 14:58:37 +01:00
Gerd Hoffmann acc70aa8d1 Revert "geometry: Add boot_lchs_find_*() utility functions"
This reverts commit ad2910949b.
2019-11-18 14:58:37 +01:00
Sam Eiderman ad2910949b geometry: Add boot_lchs_find_*() utility functions
Adding the following utility functions:

    * boot_lchs_find_pci_device
    * boot_lchs_find_scsi_device
    * boot_lchs_find_ata_device

These will be used to apply LCHS values received through fw_cfg.

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-4-shmuel.eiderman@oracle.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-11-06 10:56:00 +01:00
Gerd Hoffmann 8acad25cd5 add get_keystroke_full() helper
Switch get_raw_keystroke() to return ax instead of ah, so it returns
both scan code and ascii code of the key pressed.

Add get_keystroke_full() function which passes up ax to the caller.

The get_keystroke() function continues to return the scancode only like
it did before.  It is a thin wrapper around get_keystroke_full() now
though.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-17 14:56:42 +02:00
Joseph Pacheco-Corwin 63d6967466 bootsplash: Added support for 16/24/32bpp in one function
Specifically added support for 16 and 32bpp files, in addition to
24bpp.  The function bmp_show() in bmp.c has had the hardcoded check
for 24bpp replaced with a general bpp check that uses a % to check for
remainder, and returns 1 if the remainder is >0.  The previous method
for adjusting the BMP data (raw_data_format_adjust_24bpp) relied on a
preset 3*bytes_per_line_src, this has been changed and the
multiplication is now performed in the function's arguments. This
change still allows someone else to reuse the same function for
1/2/4bpp support if necessary. The file util.h has been modified to
reflect this decision.

The changes to raw_data_format_adjust() is based on an abandoned patch
by Gert Menke (submitted March 14, 2017), credit to them for that
change and the addition of *bpp to bmp_get_info().

Signed-off-by: Joseph S. Pacheco-Corwin <hammersamatom@gmail.com>
2019-02-04 21:20:27 -05:00
Gerd Hoffmann 14221cd86e pretty boot menu entry for cdrom drives
Show the volume label of bootable cdroms.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-10-05 13:28:27 +02:00
Gerd Hoffmann d6728f301d add serial console support
Redirect int10 calls to serial console output.
Parse serial input and queue key events.
The serial console can work both as primary display
and in parallel to another vga display (splitmode).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2017-09-22 11:13:22 -04:00
Gerd Hoffmann 90fa511527 kbd: make enqueue_key public, add ascii_to_keycode
serial console wants queue key events and needs to map ascii chars to
the keycode, so make enqueue_key public and also exports a helper
function so sercon can use the scan_to_keycode mapping table.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2017-09-22 11:13:22 -04:00
Kevin O'Connor c68aff57ce resume: Don't attempt to use generic reboot mechanisms on QEMU
On QEMU it's necessary to manually reset the BIOS memory region
between 0xc0000-0x100000 on a reboot.  After this manual memory reset
is completed, it's not valid to use the generic reset mechanisms.
Rename qemu_prep_reset() to qemu_reboot() and change the function to
immediately reboot after the code memcpy.

This fixes a bug that could cause code corruption on reboots - calling
the udelay() function (as invoked by i8042_reboot and/or pci_reboot)
was not valid after the BIOS was memcpy'd.

Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Tested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-13 11:47:36 -04:00
Kevin O'Connor 9ec57de1db acpi: Generalize find_fadt() and find_tcpa_by_rsdp() into find_acpi_table()
The find_fadt() and find_tcpa_by_rsdp() functions are very similar.
Create a new find_acpi_table() function and replace the two functions
with this new function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-27 15:04:48 -05:00
Kevin O'Connor 8cdf0c5ab9 version: Update header files now that version.c is not auto generated
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-05 13:44:12 -04:00
Paolo Bonzini 54e3a88609 smp: restore MSRs on S3 resume
Currently the MTRRs and MSR_IA32_FEATURE_CONTROL are not restored on S3
resume.  Because these have to be applied to all processors, SMP setup
has to be added to S3 resume.

There are two differences between the boot and resume paths.  First,
romfile_* is not usable in the resume paths so we separate out the
remaining common code to a new smp_scan function.  Second, smp_msr has
to be walked on the BSP as well, so we extract that out of handle_smp
and into a new function smp_write_msrs.  Then, resume can call
smp_write_msrs on the BSP followed by smp_scan to initialize the APs.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-07 11:51:18 -04:00
Kevin O'Connor 62ff9d5f64 pci: Move code in pci.c that is specific to pciinit.c to pciinit.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-02-03 10:38:42 -05:00
Kevin O'Connor a48f602c20 post: Always set HaveRunPost prior to setting any other global variable
The HaveRunPost flag controls whether post or reboot handling is
entered on a reset signal.  The flag needs to be set before any other
global variable because an external reboot signal could occur at any
time.  (If any global variable is modified prior to setting
HaveRunPost then the code might enter post with global variables in a
dirty state.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-01-12 14:22:33 -05:00
Stefan Berger 320df85010 tpm: Add a menu for TPM configuration
This patch adds an new menu entry to the main menu. This menu item enables
the user to enter a TPM control menu which allows control of those aspects
of the TPM's state that can only be controlled while in the firmware
and while physical presence can be asserted.

If the machine has a TPM, the boot menu will look as follows, with
the new menu item accessible by pressing the 't' key.

Select boot device:

1. ata0-1: QEMU HARDDISK ATA-7 Hard-Disk (6144 MiBytes)
2. Legacy option rom
3. iPXE (PCI 00:03.0)

t. TPM Menu

Upon pressing t the TPM submenu will be shown:

The Trusted Platform Module (TPM) is a hardware device in this machine.
It can help verify the integrity of system software.

The current state of the TPM is:
  Enabled and active
  Ownership has not been taken
  A user can take ownership of the TPM

Available options are:
 d. Disable the TPM
 v. Deactivate the TPM
 p. Prevent installation of an owner

If no change is desired or if this menu was reached by mistake, press ESC to
reboot the machine.

The TPM menu only shows those options that are currently accessible considering
the state of the TPM.

The patch adds several functions for sending those messages to the TPM
required for supporting those menu items.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-12-20 14:36:15 -05:00
Kevin O'Connor eb59924776 util.h: Minor - HaveRunPost is in misc.c not resume.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-11-20 11:00:52 -05:00
Kevin O'Connor efd70a5006 build: Report gcc and binutils versions in debug log
Attempt to extract the gcc and binutils versions.  Report that
information in the debug log.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:55:10 -04:00
Kevin O'Connor bd5f6c7432 Add minimal support for machines without hardware interrupts
Some Chromebooks (with Baytrail CPUs) apparently do not support
routing of legacy interrupts.  This patch adds minimal support for
running SeaBIOS in such an environment.  Even with this patch, it is
known that old operating systems and even some recent bootloaders will
not function without real hardware interrupts.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-08-24 11:02:13 -04:00
Kevin O'Connor 8c76bd6811 Minor - move declaration of CDRom_locks to code that uses it
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-24 13:17:38 -04:00
Kevin O'Connor 1785645243 block: Rename process_XXX_op() functions to XXX_process_op()
Rename disk driver dispatch functions to a consistent naming style.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-14 14:40:08 -04:00
Vladimir Serbinenko 1b911d7aed Add multiboot support.
I've been successfully using SeaBIOS as secondary bootloader. In more details
I have GRUB2-as-payload in flash together with coreboot. SeaBIOS binary is on
the HDD and loaded by GRUB when needed. This has an unfortunate consequence
that I have to keep vga oprom in flash even if usually I boot without it. This
patches makes bios.bin.elf multiboot executable with files passed as modules.
Example:

menuentry "SeaBIOS (mb)" --unrestricted {
   root=ahci0,2
   multiboot /bios.bin.elf
   module /vgabios_x230.rom name=pci8086,0166.rom
}

the parameter name= specifies under which name SeaBIOS will see it.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-06-01 12:11:36 -04:00
Stefan Berger 5aa2a75463 Support for BIOS interrupt handler
This patch implements the TCG BIOS interrupt handler 1ah. It is for
example used by trusted grub.

This patch adds an implementation of SHA1 (following NIST specs., IETF RFC 3147
and Wikipedia) for speeding up measurements of code. Trusted Grub for example
makes use of this interface and measures (calculates SHA1) of the Linux kernel
and initrd. Those files can be rather large and hunting their bytes through
the TIS interface as part of the int handler commands invoked by trusted grub
does take quite some time due to the many vmexits the interface is creating
(one per byte).

There is also a threshold for the size of data to hash (100k) below which
the TPM is used and above the internal faster SHA1 algorithm is used.

This patch for example enables trusted grub to interact with the TPM
and take additional measurements.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-05-21 13:16:06 -04:00
Kevin O'Connor 72691a5299 sdcard: Initial support for SD cards on PCI SDHCI controllers on QEMU
This adds basic read/write support for SD cards emulated by QEMU.
This code is not expected to work on real hardware, because the
current controller and card initialization is not robust.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-12-29 09:17:06 -05:00
Kevin O'Connor 43197a2aec Abstract reset call (and possible 16bit mode switch) into reset() function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-06 13:49:33 -04:00
Kevin O'Connor ca34ce5aaa Move most of the VAR16FIXED() defs to misc.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04 11:06:58 -04:00
Kevin O'Connor 0673b78700 smp: Replace QEMU SMP init assembler code with C; run only in 32bit mode.
Change the multi-processor init code to trampoline into 32bit mode on
each of the additional processors.  Implement an atomic lock so that
each processor performs its initialization serially.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04 11:06:58 -04:00
Kevin O'Connor c029a912d3 Move cdemu call interface and disk_ret helper code to disk.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04 11:06:58 -04:00
Kevin O'Connor 02f7676421 cdemu: store internal cdemu fields in standard "el-torito" spec format.
Store the fields necessary to export the "el-torito" spec information
directly in an internal copy of the "el-torito" struct.  This
simplifies the interface and obviates the need for an internal home
grown struct with the same info.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04 11:06:58 -04:00
Gerd Hoffmann a217de9329 acpi: remove PORT_ACPI_PM_BASE constant
Use the new acpi_pm_base variable instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-20 12:15:30 +02:00
Kevin O'Connor 6c68e7adfa If an int 1587 call is made from an option rom, stay in bigreal mode.
Modify the int 1587 handler to check if the POST phase is still
running.  If it is, use bigreal mode segment limits so that the caller
remains in bigreal mode when the 1587 handler completes.  This helps
with SeaVGABIOS' use of "direct" framebuffer accesses (an option rom
may attempt to display text during its option rom execution which can
cause SeaVGABIOS to make the int 1587 calls).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-05-06 12:10:36 -04:00
Gabriel L. Somlo d85c22e44e SMBIOS: Check for aggregate tables & entry point in fw_cfg
Check fw_cfg for the presence of an aggregate set of smbios
tables (etc/smbios/smbios-tables) and an entry point structure
(etc/smbios/smbios-anchor), and, if found, use them instead of
generating entries locally.

We ensure the presence of a type 0 (bios information) structure
by generating it locally if necessary, which is expected to be
the common case.

Signed-off-by: Gabriel L. Somlo <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-06 15:49:07 +02:00
Kevin O'Connor 5ab18be0b3 coreboot: Make coreboot table searching available to other code.
Make the coreboot table searching code available to code outside
coreboot.c, and make it runnable from 16bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:23 -04:00
Kevin O'Connor 3bd2dc6d5c Use biostables.c for copying bios tables even when generating them.
Use the biostables.c copy_pir(), copy_smbios(), copy_acpi_rsdp(), and
copy_mptable() code even when using the legacy bios table generation
code.  This unifies the final bios table deployment code between qemu,
coreboot, and csm.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-07 16:37:52 -04:00
Kevin O'Connor 19646a4b51 Move PirAddr definition from pirtable.c to biostables.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-07 15:55:23 -04:00
Kevin O'Connor d18c9f04e2 smbios: Move smbios parsing logic from smbios.c to biostables.c.
After this change, src/fw/smbios.c only contains the legacy code for
generating SMBIOS tables.  This change only contains code movement -
no logic is changed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-07 15:48:12 -04:00
Kevin O'Connor 836b4d8a38 acpi: Move acpi parsing logic from acpi.c to biostables.c / paravirt.c.
After this change, src/fw/acpi.c only contains the legacy code for
generating ACPI tables.  This change only contains code movement - no
logic is changed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-07 15:42:04 -04:00
Marcel Apfelbaum 40d020f562 resume: restore piix pm config registers after resume
On resume, the OS queries the power management event that
caused it. In order to complete this task, it executes some
reads to the piix pm io space. This all happens before the
OS has a chance to restore the PCI config space for devices,
so it is bios's responsibility to make sure the pm IO space
is configured correctly. (During suspend, the piix pm
configuration space is lost).

Note: For 'ordinary' pci devices the config space is
saved by the OS on sleep and restored on resume.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
2014-01-15 11:01:58 -05:00
Kevin O'Connor 4cd522e673 Move low-level hardware writing from output.c to new file hw/serialio.c.
Avoid hardware specific code in output.c.  This will reduce the amount
of change needed to output.c as support for more serial hardware is
added.

This patch also renames some functions to improve the naming scheme.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:17 -05:00
Michael S. Tsirkin ff5f7921d9 biostables: support looking up RSDP
Will be used when it's loaded from QEMU.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-06 12:24:57 +01:00
Jonathan A. Kollasch e9a3e12c5a vgahooks: add SM720 VGA BIOS hooks for WIN Enterprises MB-60470
Add vgahooks to support the SMI SM720 VGA BIOS used on the
WIN Enterprises MB-60470.  The response from smi_157f14() is necessary
for the CRT output to turn on.  The response from smi_157f02() is used
to configure which connector(s) output is routed to.

As I lack hardware to test LCD panel output, I've selected CRT-only
output on the MB-60470 as this prevents the CRT output from being scaled
to the resolution of the LCD panel.

Signed-off-by: Jonathan A. Kollasch <jakllsch@kollasch.net>
2013-10-26 10:13:30 -04:00
Kevin O'Connor 7b9f29736a Move dma code to new file hw/dma.c.
Move the DMA controller code in resume.c and hw/floppy.c to a new file
hw/dma.c.  This centralizes the DMA controller code into one place.

Also, don't unmask the floppy DRQ during floppy setup - there is no
reason to unmask the DRQ prior to a command being programmed into the
DMA controller.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-28 22:09:07 -04:00