aboutsummaryrefslogtreecommitdiffstats
path: root/src/resume.c
Commit message (Collapse)AuthorAgeFilesLines
* resume: Don't attempt to use generic reboot mechanisms on QEMUKevin O'Connor2017-03-131-2/+2
| | | | | | | | | | | | | | | | 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>
* QEMU fw_cfg: Write fw_cfg back on S3 resumeBen Warren2017-02-211-0/+4
| | | | | | | | | | Any pointers to BIOS-allocated memory that were written back to QEMU fw_cfg files are replayed when resuming from S3 sleep. Signed-off-by: Ben Warren <ben@skyportsystems.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* smp: restore MSRs on S3 resumePaolo Bonzini2016-07-071-0/+1
| | | | | | | | | | | | | | | | | 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>
* resume: Make KVM soft reboot loop detection more flexibleKevin O'Connor2016-01-121-9/+0
| | | | | | | | | Move the check for soft reboot loops from resume.c to shadow.c and directly check for the case where the copy of the BIOS in flash appears to be a memory alias instead. This prevents a hang if an external reboot request occurs during the BIOS memcpy. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Implementation of the TCG BIOS extensionsStefan Berger2015-05-211-0/+3
| | | | | | | | | | | | | | | | | | | | This patch implements the main part of the TCG BIOS extensions. It provides the following functionality: - initialization of the TCPA ACPI table used for logging of measurements - initialization of the TPM by sending a sequence of commands to it - proper setup of the TPM before the BIOS hands over control to the bootloader - support for S3 resume; BIOS sends TPM_Startup(ST_STATE) to TPM - enable configuration of SeaBIOS to be built with TCGBIOS extensions All TCG BIOS extensions are activated with CONFIG_TCGBIOS. Structures that are needed in subsequent patches are also included in tcgbios.h at this point. The effect of this patch is that it initialized the TPM upon VM start and S3 resume. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
* If an int 1587 call is made from an option rom, stay in bigreal mode.Kevin O'Connor2014-05-061-3/+0
| | | | | | | | | | | 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>
* debug: Only call serial_debug_preinit() at startup.Kevin O'Connor2014-01-221-1/+0
| | | | | | | | | The serial_debug_preinit() function disables serial interrupts so that the OS doesn't get confused by "transmit buffer empty" interrupts caused when seabios writes to the serial port. It's unnecessary paranoia to keep rechecking that interrupts are disabled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* resume: restore piix pm config registers after resumeMarcel Apfelbaum2014-01-151-0/+2
| | | | | | | | | | | | | | | | 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>
* Move low-level hardware writing from output.c to new file hw/serialio.c.Kevin O'Connor2013-12-041-1/+1
| | | | | | | | | | 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>
* Remove ioport.h; disperse its contents to other header files.Kevin O'Connor2013-09-281-1/+0
| | | | | | | Move the inb(), insb(), etc. code from ioport.h to x86.h. Move the PORT_* definitions to their appropriate hardware files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move dma code to new file hw/dma.c.Kevin O'Connor2013-09-281-13/+0
| | | | | | | | | | | 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>
* Rename hw/cmos.h to hw/rtc.h and copy RTC code from clock.c to hw/rtc.c.Kevin O'Connor2013-09-281-3/+3
| | | | | | | | | Group the Real Time Clock code into hw/rtc.[ch]. Also, use rtc_read/write/mask function naming (instead of inb/outb_cmos) to be more consistent with other register accessors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move standard bda type info from biosvar.h to std/bda.h.Kevin O'Connor2013-09-181-1/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move fw/acpi.h to std/acpi.h.Kevin O'Connor2013-09-181-1/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move function definitions for output.c from util.h to new file output.h.Kevin O'Connor2013-09-181-5/+6
| | | | | | Also, sort the order of include files in the c files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move stacks.c definitions from util.h to new file stacks.h.Kevin O'Connor2013-09-181-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Rename util.c to string.c and introduce string.h.Kevin O'Connor2013-09-181-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move code cenetered around firmware initialization to src/fw/Kevin O'Connor2013-09-021-1/+1
| | | | | | Move many C files from the src/ directory to the new src/fw/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move code centered around specific hardware devices to src/hw/Kevin O'Connor2013-09-021-4/+4
| | | | | | Move many C files from the src/ directory to the new src/hw/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* PIC code cleanups.Kevin O'Connor2013-07-141-2/+2
| | | | | | | | | | | | Preface PIC functions with a pic_ to provide a more consistent naming. Convert the irqmask code to a more consistent pic_irqmask_read/write/mask form. Move code from pic.h to pic.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Try to detect an unsuccessful hard-reboot to prevent soft-reboot loops.Kevin O'Connor2013-02-231-0/+9
| | | | | | | | There have been various kvm bugs that prevent reboots from working properly. Generalize the existing test for a failed reboot to better catch these cases. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Add acpi_reboot() reset method using RESET_REGDavid Woodhouse2013-02-231-0/+3
| | | | Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
* Convert VAR16VISIBLE, VAR16EXPORT, and VAR32VISIBLE to VARFSEG.Kevin O'Connor2013-02-181-1/+1
| | | | | | | | | | | Convert all users of the alternative variable exports to VARFSEG. There isn't a significant distinction between the existing types of exports, so it's simpler to just use one type going forward. The new VARFSEG declaration is only emitting when in 32bit mode, so update and move some variables as needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Consistently use CONFIG_COREBOOT, CONFIG_QEMU, and runningOnXen().Kevin O'Connor2013-02-121-5/+1
| | | | | | | | | | | | | | | | | | | | | CONFIG_QEMU means compile to start from QEMU (and possibly Xen/KVM/Bochs) and definitely running under QEMU (or Xen/KVM/Bochs). CONFIG_COREBOOT means compile for coreboot and definitely running under coreboot. Places that used CONFIG_COREBOOT to mean "running on real hardware" have been changed to use !CONFIG_QEMU. CONFIG_QEMU_HARDWARE enables support for some virtual hardware devices even if QEMU didn't start SeaBIOS. usingXen() is replaced by runningOnXen(). runningOnQEMU() is added to hardware devices that are only safe to access when we are sure we are running under QEMU (or Xen/KVM/Bochs). Neither the coreboot nor the csm code currently enable runningOnQEMU, but future patches may. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* POST: Move cpu caching and dma setup to platform_hardware_setup().Kevin O'Connor2013-02-071-2/+2
| | | | | | | | | | | The CPU cache is enabled and DMA is disabled on all real-world POST entry situations, so no need to do this in the low-level "pre-init" phase. Instead, move it to the platform hardware setup stage. Also, move the setting of the reboot flags (which control reset-vector entry point handling) to ivt_init(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Normalize POST initialization function name suffixes.Kevin O'Connor2013-02-051-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The POST phase has to invoke many initialization functions, and these functions can have complex inter-dependencies. Try to categorize the functions into 4 classes: preinit - functions called very early in POST where function ordering is very important and the code has limited access to other interfaces. init - functions that initialize internal interfaces and standard external interfaces. This code is generally not dependent on particular hardware and typically does not communicate directly with any hardware devices. setup - functions which access hardware or are dependent on particular hardware or platform devices. prepboot - functions that finalize internal interfaces and that prepare for the boot phase. This patch attempts to normalize the suffixes - functions that used _init(), _setup(), _finalize(), or similar that did not follow the above pattern were renamed. Other than function name changes, there should be no code impact to this patch. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Rename call16 to farcall16.Kevin O'Connor2012-05-281-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Misc compile fixes for gcc v3.4.Kevin O'Connor2012-04-141-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mask interrupts on S3 resumeGleb Natapov2012-02-011-0/+1
| | | | | | | | | | i8259 clears interrupt mask on reset. Interrupt need to be masked again before enabling interrupts on CPU. Since option roms are called with interrupts enabled, resume should mask interrupts in i8259 before calling vgabios. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Simplify POST entry code by moving reboot logic from post.c to resume.c.Kevin O'Connor2011-07-101-38/+73
| | | | | | | | | | | | | | | | Detect a resume/reboot by inspecting HaveRunPost instead of inspecting the cmos reset code. Inspecting a global variable is both simpler and safer. Move the reboot logic from post.c to resume.c - this makes the code in post.c simpler as it is now only called once on machine startup. This also makes it easier to ensure all POST initialization code resides in the relocatable "init" sections. Also, rename _start() to handle_post() so that it is more in keeping with the entry_xxx() and handle_xxx() function naming. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Require a "_cfuncXX_" symbol prefix for inter-mode c function references.Kevin O'Connor2010-12-051-1/+1
| | | | | | | | | | | | The compiler can get confused when referencing a C function in a different mode. (It reasonably assumes that the C function in the current mode is desired.) To avoid this compiler confusion, introduce symbol prefixes (_cfunc16_, _cfunc32flat_, _cfunc32seg_) that must be used on C function symbols that are referenced from other compilation modes. This makes it less likely compiler confusion will occur. It will also makes it easier to implement and use vtable like operation structures.
* Don't pass return address to transition(32,16,16big) on stack.Kevin O'Connor2010-11-251-1/+1
| | | | | | It's difficult to have a uniform view of the stack when transition modes, so pass the return address in a register. As a result, the transition functions only access memory via the %cs selector now.
* Disable inlining on old compilers.Kevin O'Connor2010-03-201-0/+1
| | | | | | If the compiler can't restrict inlining by stack usage, then disable inlining in 16bit mode. Otherwise, old compilers produce code that uses too much stack space.
* Reduce #ifs by weeding out some cross-chunk function definitions.Kevin O'Connor2010-01-031-2/+0
| | | | | | | | | | Reduce the need for placing #if guards around functions that are marked as VISIBLE in another code chunk by declaring the functions as "weak" when they are not needed. It's still necessary to ensure that no C code references the data from a different chunk (or an -fwhole-program compile might try to keep a local reference).
* Be sure to add "void" to all function prototypes that take no args.Kevin O'Connor2010-01-031-2/+2
| | | | Omitting "void" leads to a K&R style declaration which was not intended.
* Introduce MODESEGMENT define; rename VISIBLE32 to VISIBLE32FLAT.Kevin O'Connor2009-12-261-2/+2
| | | | | Prepare for support of segmented 32bit code. Add new MODESEGMENT definition, and clarify existing 32bit mode defs.
* Replace common segment/offset pairs with struct segoff_s.Kevin O'Connor2009-09-091-8/+6
| | | | Introduce 'struct segoff_s' to more places.
* Add option for running vga rom during s3 resume.Kevin O'Connor2009-07-041-0/+2
| | | | | Add support for running the vga rom when the option CONFIG_S3_RESUME_VGA_INIT is set (default is off).
* Remove 0x09 as a normal post code (forward port from bochs).Kevin O'Connor2009-06-211-1/+0
|
* Avoid -fwhole-program on broken gcc instead of stopping build.Kevin O'Connor2009-06-151-4/+0
| | | | | Enhance build to detect and avoid gcc with broken -fwhole-program Also, remove workaround for older gcc that mess up global exports.
* Add support for gcc v3.x compilers.Kevin O'Connor2009-06-101-0/+2
| | | | | | | | Suppress __attribute__((externally_visible)) when no -fwhole-program Add switch hack for compilers without -fno-jump-tables Define memcpy() function (for compilers without -minline-all-stringops). Define call16_simpint as a macro (a param needs to be inlined). Make sure s3_resume is only defined in 32bit mode.
* Eliminate "_code32_" prefix on 32bit symbols referenced from 16bit code.Kevin O'Connor2009-05-231-2/+2
| | | | Use linking magic to eliminate the need for the _code32_ prefix.
* Minor - rename BX_PANIC to panic.Kevin O'Connor2009-02-081-2/+2
|
* Rename MAKE_FARPTR (and similar) to MAKE_FLATPTR.Kevin O'Connor2009-01-191-2/+2
| | | | | | | | The term "far pointer" is used in many 16bit specs, and it is different from what MAKE_FARPTR creates. So, use the term "flat pointer" in the code to distinguish between the two meanings. Also, use the suffix "_fl" consistently when working with "flat pointers".
* Fix apparent bug in 16bit resume code.Kevin O'Connor2009-01-191-13/+11
| | | | | | The BDA offsets were adding in 0x400 twice. Also, use lss insn instead of manually setting %ss and %sp. Also, don't force segment value into %eax.
* Add CONFIG_S3_RESUME to control support for S3 resume.Kevin O'Connor2009-01-171-10/+15
|
* Change license from GPLv3 to LGPLv3.Kevin O'Connor2009-01-151-1/+1
| | | | | | | | Change license of contributions from Kevin O'Connor from GPLv3 to LGPLv3 (or later). Since the work as a whole is based on Kevin's contributions and the "bochs bios" which has a license of LGPL (v2 or later), this effectively makes the work as a whole available under LGPLv3 (or later).
* Don't define bda as a macro in resume.c - it confuses AVOIDCOMBINE mode.Kevin O'Connor2009-01-021-1/+1
| | | | | | When using AVOIDCOMBINE, macros can have global scope. This caused the bda macro in resume.c to conflict with the bda variable in post.c.
* The BDA is at segment 0x0040 not 0x0000.Kevin O'Connor2009-01-021-1/+1
| | | | The interrupt vector table is technically at 0x0000.
* Make sure to manually export s3_resume() for old buggy gcc versions.Kevin O'Connor2008-12-191-0/+4
|