aboutsummaryrefslogtreecommitdiff
path: root/src/romlayout.S
AgeCommit message (Collapse)AuthorFilesLines
2017-09-22add serial console supportGerd Hoffmann1-1/+49
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>
2016-09-12kbd: Generate interrupt events for SysReq, PrtScr, and BreakKevin O'Connor1-0/+2
Generate the appropriate interrupt events for the given keys. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-12-28nmi: Don't try to switch onto extra stack in NMI handlerKevin O'Connor1-1/+4
The NMI could occur when already on the extra stack, which would corrupt it. Always use the current stack on an NMI to avoid this. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15stacks: Use macro wrappers for call32() and stack_hop_back()Kevin O'Connor1-1/+1
The C code only uses _cfuncX_ prefixes for parameters to the call32(), stack_hop_back(), and call32_params() functions. It's simpler to use macro wrappers around those functions which provide the required prefix. This also changes the parameter order of stack_hop() and stack_hop_back() to use the more natural (func, params) ordering. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-09Always enable caching on transition32; backup/restore cr0 on call32Kevin O'Connor1-0/+1
Always enable caching at start of 32bit code and always make sure the paging flag is off. Because this alters the cr0 register, perform a backup and restore of it when using call32(). Also, rename get/setcr0() to cr0_read/write() to more closely match other register access functions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-09-14Use transition32_nmi_off from call32() and call16_back()Kevin O'Connor1-0/+1
The call32() and call16_back() functions will always disable NMI and enable a20 (via the call32_prep() function) so it is safe to use the _nmi_off variant of transition32. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-09-14Unify inline assembler in variants of call16 functionsKevin O'Connor1-9/+0
The assembler between call16(), call16big() and call16_sloppy() are very similar. Rework the functions so that a single version of the inline assembly can be used for all variants. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-09-03Simplify transition16/32 assembler codeKevin O'Connor1-49/+40
Backup and restore %eax only around code that needs to use %eax. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-06-01Add multiboot support.Vladimir Serbinenko1-0/+2
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-03-11smp: Fix smp race introduced in 0673b787Kevin O'Connor1-3/+6
In 0673b787 the QEMU SMP init code was changed to run in 32bit mode. Unfortunately, the transition32 assembler function is not multi-processor safe, because it modifies the global RTC index register. This race condition led to sporadic failures when emulating machines with a large number of processors. This patch changes the entry_smp code to use a variant of transition32 that does not touch the RTC registers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-12-03Minor - be consistent in placement of .code16/32 in romlayout.SKevin O'Connor1-6/+11
Place .code32 in those functions that need it, and make sure every function ends in .code16 mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-11-12Minor - comment updates in romlayout.SKevin O'Connor1-8/+8
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-11-12Use an aligned stack offset when entering on the extra stackKevin O'Connor1-12/+12
The size of 'struct bregs' is not evenly divisible by four and where the assembler placed a 'struct bregs' on the extra stack as part of entering into the C functions it caused the C functions to run with a non-aligned stack. It's technically not correct to use an unaligned stack and it is certainly less efficient. This patch avoids using BREGS_size (the sizeof struct bregs) and instead introduces PUSHBREGS_size (the size of the general purpose registers in struct bregs) in the assembler. Where the code actually did use the %cs:%ip and flags, an extra 8 (instead of 6) bytes are added to maintain a sane alignment. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-11-03Fix PNP regression introduced in 99cb8f3e due to missed conversionKevin O'Connor1-1/+1
Commit 99cb8f3e missed a conversion from 12(%esp) to BREGS_eax(%esp) causing winxp to break. Reported-by: Ian Campbell <Ian.Campbell@citrix.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27Do full BREGS backup/restore for pmm, pnp, and irqentry_extrastackKevin O'Connor1-41/+15
Although these entry points only require backup and restore of the registers that the C code clobbers, there is no harm in backing up some additional registers. This allows the BREGS macros to be used which makes the code a little more readable. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27Create assembler macros for saving and restoring 'struct bregs'Kevin O'Connor1-44/+5
Create macros SAVEBREGS_POP_DSEAX and RESTOREBREGS_DSEAX for saving and restoring the cpu state. These are similar to the existing PUSHBREGS and POPBREGS macros. This also fixes a bug in __farcall16 which inadvertently restored %ds in %es and vice-versa. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27Don't clobber %ax on ENTRY_INTO32 macroKevin O'Connor1-8/+2
There's no need to clobber %ax in ENTRY_INTO32. Now that %eax isn't clobbered, use ENTRY_INTO32 in entry_csm. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-15Move a20 code from system.c and ps2port.h to x86.hKevin O'Connor1-1/+0
Although the a20 functionality was originally implemented in the ps2 controller, that is just a historical artifact. It's a core feature of modern x86 cpus and the code is better located in the x86.h header. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-11Move call16() functions from romlayout.S to inline assembler in stacks.cKevin O'Connor1-42/+0
Use inline assembler in call16 type functions instead of using __call16() in romlayout.S. Since call16() and call16big() are now only called with %ss==0 they do not need to update the stack pointer. Only call16_sloppy() requires the stack manipulation code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-09-30pmm: Fix entry point to support non-zero %ssKevin O'Connor1-2/+3
If the pmm entry point was called with a non-zero stack segment, the pointer to the arguments on the stack would not be valid once the code transitioned to 32bit mode. Fix by adding the stack segment offset into the args pointer. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-07-01romlayout: Use "rep ; nop" not "rep nop".Ian Campbell1-1/+1
Fixes: Compiling (16bit) out/romlayout.o src/romlayout.S: Assembler messages: src/romlayout.S:285: Error: expecting string instruction after `rep' make: *** [out/romlayout.o] Error 1 Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2014-06-11build: Use customized entry point for each type of build.Kevin O'Connor1-2/+2
Set an appropriate elf entry point (entry_elf, entry_csm, reset_vector) for each type of build (coreboot, csm, qemu). Use that entry point when determining which sections to keep. Also, remove the '.export.' mechanism to keep a section in the final binary - it is no longer used. This allows the build to slightly reduce the overall size as entry_elf is no longer needed on non-coreboot builds and entry_csm is no longer needed on non-csm builds. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-05romlayout: Use .code16 not .code16gccDavid Woodhouse1-9/+9
There's no need to use .code16gcc where we are writing assembler code explicitly. It only affects word-size-ambiguous instructions, and we should just be explicit. And we are. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2014-06-04Move most of the VAR16FIXED() defs to misc.c.Kevin O'Connor1-3/+3
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04Remove old Bochs bios fixed address string at 0xfff00.Kevin O'Connor1-2/+0
There is no indication that the address 0xff00 is a BIOS standard, so don't emit the old Bochs copyright string at that fixed address. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04smp: Replace QEMU SMP init assembler code with C; run only in 32bit mode.Kevin O'Connor1-0/+20
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-04smm: Use a C struct to define the layout of the SMM area.Kevin O'Connor1-1/+1
Describe the memory layout using a struct instead of hard coded offsets. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04smm: Replace SMI assembler code with C code.Kevin O'Connor1-4/+18
Convert the SMI handler from assembly to C. This makes the handler easier to understand and enhance. The new handler will use references to the reserved memory at 0xf0000-0x100000. If the physical memory in that range is modified at runtime, then the SMI handler will cease to function properly (and may allow unintended code to run in SMM mode). However, that area is marked as reserved and is normally made read-only at runtime, so there is little risk in relying on it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-05-08Fix int 1589 calls when CONFIG_ENTRY_EXTRASTACK is enabled.Kevin O'Connor1-0/+10
The int 1589 call is entered in real mode and returns in protected mode. However, the code to use the "extra stack" does not support that. Fix this by never using the "extra stack" on int 1589 calls. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-09Small improvements to irqentry_extrastack assembler.Kevin O'Connor1-6/+2
Simplify the entry assembler slightly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-10-14Support call16() calls after entering 32bit mode from call32().Kevin O'Connor1-1/+15
When transitioning to 32bit via call32() track the stack segment register and support restoring it on call16() requests. This permits call16() to work properly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-10-14Update _farcall16() to pass segment of callregs explicitly.Kevin O'Connor1-29/+30
Don't use implicit passing of %es for the segment of the callregs pointer. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-10-14Make __call16 use C calling convention and support two passed parameters.Kevin O'Connor1-2/+8
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-10-14Minor - move call16 assembler in romlayout.S.Kevin O'Connor1-24/+29
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-28Remove ioport.h; disperse its contents to other header files.Kevin O'Connor1-4/+4
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>
2013-09-28Rename hw/cmos.h to hw/rtc.h and copy RTC code from clock.c to hw/rtc.c.Kevin O'Connor1-1/+1
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>
2013-09-18Split x86 specific functions out of util.c/h to new files x86.c/h.Kevin O'Connor1-1/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-02Move code centered around specific hardware devices to src/hw/Kevin O'Connor1-1/+1
Move many C files from the src/ directory to the new src/hw/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-03-03Support using the "extra stack" for all 16bit irq entry points.Kevin O'Connor1-0/+58
Using the internal stack reduces the amount of space that SeaBIOS uses on the caller's stack. This is known to help some very old operating systems (like DOS 1.0). However, there is a possibility that this will break any operating systems that calls a legacy 16bit irq in 16bit protected mode (no OSes have yet to be identified as doing this), so make the ability config dependent. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-03-03Separate out 16bit PCI-BIOS entry point from regular int 0x1a entry point.Kevin O'Connor1-2/+13
The PCI-BIOS entry point can be called in 16bit protected mode, so separate its entry code from the legacy 0x1a code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-18Minor assembler enhancements to __csm_return.Kevin O'Connor1-9/+8
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-18Remove unnecessary "export" declarations from assembler functions.Kevin O'Connor1-2/+2
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-17Clarify build generated "zone low" values.Kevin O'Connor1-2/+2
Rename datalow_base (and similar) to zonelow_base, and datalow_start (and similar) to varlow_start. This helps distinguish between the bounds for the runtime dynamic memory pool and the compile time global variables. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-12Unify return path for CSM to go via csm_return()David Woodhouse1-13/+10
This allows us to keep the entry_csm code simple, and ensures that we consistently do things like saving the PIC mask (and later setting UmbStart) on the way back to UEFI. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2013-02-08Undo incorrect assumptions about Xen in commit 6ca0460f.Kevin O'Connor1-1/+1
Xen invokes SeaBIOS via entry_post, not entry_elf. As a result commit 6ca0460f broke Xen. This change effectively undoes that commit. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-07POST: Reorganize post entry and "preinit" functions.Kevin O'Connor1-1/+1
Unlocking ram in handle_post() is tricky and only needed under qemu. Separate out that logic from the coreboot/xen paths by invoking handle_elf_post separately. This simplifies both the qemu and non-qemu code paths. Also, organize all the "pre-init" functions into one section of the file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-07Add CSM supportDavid Woodhouse1-0/+50
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-06-02Fix winxp boot regression introduced in ecdc655a.Kevin O'Connor1-33/+20
The winxp boot loader does something curious - it sets an int 0x1c handler, records the stack location, and then spins in place with irqs enabled. The 0x1c handler alters the memory just past the stack pointer so that when the timer irq returns the code jumps to a new location and stop spinning. The winxp code relies on the fact that a hw irq will always place 6 bytes at a specific location and that it can alter those bytes. The ecdc655a patch does a full backup/restore of the register state. Unfortunately, the restore overwrites the changes made by the winxp 0x1c handler. This patch reverts much of ecdc655a. Hardware irqs are still handled on the extra stack, but only the essential register state is backed up and restored. Also, stack_hop_back is changed to only use %sp when changing states - this enables the entry code to store just %esp instead of both %esp and %sp. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-30Run all hardware irq handlers on the extra stack.Kevin O'Connor1-6/+54
Jump into the extra stack for all hardware irq handlers. This reduces the overall stack requirements of SeaBIOS. Replace all users of call16_simpint with call16_int. Only the hardware irq handlers used the old call, and they need to use the new call to ensure the extra stack is properly re-entrant. Also, pass in a 'struct bregs' to the hardware irq handlers now. It was not done previously to save stack space. Now that the extra stack is used, that is no longer an issue. Note that should an old OS invoke a hardware irq in 16bit protected mode, then this patch could break that OS. However, the chances of this causing a regression seem small as several existing hardware irq handlers already do not work in 16bit protected mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-28Automatically hop off the extra stack when far calling 16bit code.Kevin O'Connor1-32/+37
Update the low level __farcall16 code to support a 'struct bregs' in a segment other than the stack segment. Automatically hop back from the extra stack on any farcall16() calls. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>