Commit Graph

83 Commits

Author SHA1 Message Date
Gerd Hoffmann cf16c3b2ea output: add support for uppercase hex numbers
... via "%X" format string.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200930111222.6020-2-kraxel@redhat.com
2020-10-13 11:01:08 +02:00
Kevin O'Connor 29ba89e67f output: Avoid thunking to 16bit mode in printf() if no vgabios
It is not necessary to call the vgabios if no vgabios has been
installed.  This reduces the amount of hardware accesses on qemu when
the bios is not initializing the display hardware, and it can reduce
the boot time by a couple of milliseconds.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-12-17 10:23:49 -05:00
Kevin O'Connor 4d8510cdcc pci: Split low-level pci code from higher-level 'struct pci_device' code
Split pci.c into pci.c and pcidevice.c.  The low-level code that
interacts directly with the PCI devices remains in pci.c, while
functions dealing with the higher level pci_device cache move to
pcidevice.c.  Only pci.c is needed in 16bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-02-03 10:38:42 -05:00
Kevin O'Connor 7b67300f7d pci: Implement '%pP' printf handler for 'struct pci_device' pointers
Handle '%pP' format descriptions as a pointer to a 'struct pci_device'
and display it in bus:device.function (%02x:%02x.%x) format.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-02-03 10:38:20 -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 f6b44b81e6 Set the color attribute when calling vgabios print character.
Set the color attribute in case the SeaBIOS console code is used while
the vgabios is in a graphics mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:23 -04:00
Kevin O'Connor bb1fcb4507 debug: Unify the SeaBIOS debug version banner.
Introduce debug_banner() and use it in all the places SeaBIOS version
is displayed for debugging purposes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-01-22 17:30:30 -05:00
Kevin O'Connor 940fc1fc58 debug: Only call serial_debug_preinit() at startup.
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>
2014-01-22 17:30:30 -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
Kevin O'Connor 4ade523a9d Remove ioport.h; disperse its contents to other header files.
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-28 22:10:31 -04:00
Kevin O'Connor 2d2fa31b37 Move function definitions for output.c from util.h to new file output.h.
Also, sort the order of include files in the c files.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 9dea59025f Move malloc code from pmm.c to new files malloc.c and malloc.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 3df600bbdf Move stacks.c definitions from util.h to new file stacks.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor fa9c66a656 Rename util.c to string.c and introduce string.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor ccee6e8491 Move code cenetered around firmware initialization to src/fw/
Move many C files from the src/ directory to the new src/fw/ directory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-02 21:25:21 -04:00
Gerd Hoffmann ebf03f7fb1 coreboot: add cbmem console support
Add support for logging to the coreboot cbmem console.
Limitation: only supported in 32bit mode.  Use 'cbmem -c'
to see the logs (coreboot and seabios) after bootup.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-07-14 14:31:16 -04:00
Gerd Hoffmann 2ca73ed004 config: allow DEBUG_IO for !QEMU
Make DEBUG_IO depend on QEMU_HARDWARE instead of QEMU, so
it can be enabled for seabios builds running indirectly
(coreboot, csm) on qemu.

Add runtime check for PF_QEMU to debug port console to make
sure we don't poke on random ports on physical hardware.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-06-12 21:42:15 -04:00
Kevin O'Connor 89a2f96de4 Convert VAR16VISIBLE, VAR16EXPORT, and VAR32VISIBLE to VARFSEG.
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>
2013-02-18 23:36:03 -05:00
Kevin O'Connor d83c87bb20 Normalize POST initialization function name suffixes.
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>
2013-02-05 20:00:29 -05:00
Ian Campbell 54f3b25a23 Xen: Autodetect debug I/O port at runtime instead of via Kconfig
This allows a common image which supports Xen to still print debug

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2012-07-02 11:14:51 -04:00
Kevin O'Connor 1297e5da56 Fix winxp boot regression introduced in ecdc655a.
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-06-02 20:30:58 -04:00
Kevin O'Connor ecdc655a86 Run all hardware irq handlers on the extra stack.
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-30 21:04:52 -04:00
Kevin O'Connor c04090d7de output: Add 64bit hex print support.
Based on patch by Gerd Hoffmann <kraxel@redhat.com>.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-03-06 07:18:38 -05:00
Julian Pidancet 7123d9834d Introduce config option to select which IO port to send debug output on
Introduce CONFIG_DEBUG_IO_PORT config option which allow user
to choose on which port to send debug on at configure time.

Bochs users are likely to use 0x402 (default) for debugging purposes,
whereas Xen uses 0xe9, as IO port address.

Signed-off-by: Julian Pidancet <julian.pidancet@citrix.com>
2012-02-01 22:00:34 -05:00
Kevin O'Connor 5044053c84 Fix serial port flushing code.
debug_serial() was doing a full flush while debug_serial_flush() was
only doing a partial flush.  Fix that.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2011-07-10 15:36:04 -04:00
Kevin O'Connor 422263deac Replace CONFIG_SCREEN_AND_DEBUG with "etc/screen-and-debug" file. 2011-07-05 20:56:07 -04:00
Kevin O'Connor d12e8a2aa4 Add Kconfig option to specify which serial port when serial debugging. 2011-05-10 23:36:11 -04:00
Kevin O'Connor ca2bc1c0cd Remove drive->desc field.
The description field is only available during the POST phase - it is
confusing to have it live in a structure available through all phases.

The description was only used by the boot menu code - pass each drive
description directly to the bootlist code.

Add a helper (znprintf) to automatically malloc_tmp the required
space.

Also, fixup ramdisk handling - it was using an incorrect floppy
priority.
2010-12-29 21:41:19 -05:00
Kevin O'Connor 1d7d893029 Fix bvprintf() to respect padding for hex printing.
Fix bvprintf to respect space padding when printing hex numbers
and the caller specifies alignment without zero padding, eg. %2x
as opposed to %02x

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2010-06-19 12:05:57 -04:00
Kevin O'Connor 7fb8ba866e Add a generic "internal error" warning function. 2010-02-28 17:26:25 -05:00
Kevin O'Connor cfdc13f37f Introduce standard warnings for allocation failures and timeouts.
There is no need for custom warnings for many common failures.
Introduce a common warning which is consistent and more visible.
2010-02-14 13:07:54 -05:00
Kevin O'Connor 1ca05b0f39 Be sure to add "void" to all function prototypes that take no args.
Omitting "void" leads to a K&R style declaration which was not intended.
2010-01-03 17:43:37 -05:00
Kevin O'Connor 871e0a0c14 Add support for 32bit PCI BIOS entry.
Create a new code blob (code32seg) with support for 32bit functions
    that need to utilize explicit segment accesses.
This code blob uses global variables relative to %gs and with a
    dynamic code offset (determined by get_global_offset()).
Add BIOS32 structure and code.
Add code for 32bit PCI BIOS code.
2009-12-30 12:14:53 -05:00
Kevin O'Connor 52a300f1c1 Introduce MODESEGMENT define; rename VISIBLE32 to VISIBLE32FLAT.
Prepare for support of segmented 32bit code.
Add new MODESEGMENT definition, and clarify existing 32bit mode defs.
2009-12-26 23:32:57 -05:00
Kevin O'Connor dfefeb5438 Distinguish between debug reports for unimplemented vs invalid calls.
Don't use "fail" in the debug output - as this confuses users.
When reporting on an invalid parameter - use the word "invalid".
When reporting on an unimplemented call - state it is unimplemented.
Add separate debug levels for unimplemented vs invalid calls.
Also, increase the debug level of several entry points.
2009-12-13 13:04:17 -05:00
Kevin O'Connor 2be312c112 Update snprintf to return the number of bytes used. 2009-11-24 09:37:53 -05:00
Kevin O'Connor c604f2f6be Improve debugging output from threads.
Show the "thread id" on each debug message sent from a thread.
Also, cleanup translation dprintf() so it looks nicer withe thread output.
2009-10-24 19:56:11 -04:00
Kevin O'Connor 43562769f9 Cleanup 'debuginfo' variable in output; add comment. 2009-10-12 09:48:12 -04:00
Kevin O'Connor ebd426bf13 Really fix linker issue with "debuginfo" variable.
The 16bit and 32bit code can't share debuginfo because it points to
    code and must point to 16bit code in 16bit mode.  Introduce two
    separate variables - one for 32bit mode and one for 16bit mode.
2009-10-08 08:51:24 -04:00
Kevin O'Connor b2fd1f3a3b Add VAR16VISIBLE to debuginfo - older gcc doesn't optimize out. 2009-10-08 08:13:13 -04:00
Kevin O'Connor 9ed6b62c32 Add snprintf support.
Extend bvprintf() code to support building a string.
Don't flush the serial port from printf if CONFIG_SCREEN_AND_DEBUG not
    set.
2009-10-07 21:41:08 -04:00
Kevin O'Connor 462cb50af6 Silence gcc asm deprectation warning in output.c.
gcc prefers asm parameters not be casts.
2009-10-07 20:59:45 -04:00
Kevin O'Connor 114592f000 Initial support for USB, UHCI, and USB Keyboards.
This adds preliminary support for USB controllers and keyboards.
Add support for UHCI controllers.
Add support for "HID" USB keyboards.
Also, fix bug in hexdump() - len need not be power of 4.
2009-09-28 21:32:08 -04:00
Kevin O'Connor f8e800dea4 Interrupts should be enabled when calling 16bit code.
Set most code paths to have interrupts on when calling 16bit code.
This fixes at least one optionrom that needed irqs on.
2009-09-24 21:01:16 -04:00
Kevin O'Connor 9f985427ff Replace common segment/offset pairs with struct segoff_s.
Introduce 'struct segoff_s' to more places.
2009-09-09 11:34:39 -04:00
Kevin O'Connor b9e62d2415 Add option CONFIG_SCREEN_AND_DEBUG to control printf and debugging.
New option controls whether or not printf content is also written to
    the debug ports.
2009-08-02 13:18:27 -04:00
Kevin O'Connor f513c91a32 In register dump, show %esp - not address of regs.
The address of the callers stack can be inferred from the address of
    'regs' - do the math in the dump function.
2009-05-27 22:27:10 -04:00
Kevin O'Connor 7da210c73a Support %ebp register in 'struct bregs'.
Save/restore %ebp on irq entry.
Support saving and restoring %ebp on call16.
Enable display of %ebp in register dumps.
2009-05-16 23:57:08 -04:00
Kevin O'Connor 3e832bb238 Flush debugging serial output after every line.
Wait for the serial port to be ready after every debug function.
This fixes an issue with serial port detection.
2009-05-15 22:22:12 -04:00
Kevin O'Connor c151b3bf75 Improve serial port detection.
Add port names for serial port registers.
When detecting serial port, ignore top two bits of IIR register.
2009-05-12 22:59:41 -04:00