]> xenbits.xensource.com Git - seabios.git/log
seabios.git
10 years agouhci: Merge uhci_send_control with uhci_send_bulk
Kevin O'Connor [Wed, 31 Dec 2014 06:56:53 +0000 (01:56 -0500)]
uhci: Merge uhci_send_control with uhci_send_bulk

Merge both the control and bulk pipe sending functions into one new
function: uhci_send_pipe().  The two existing functions were similar,
and by merging them the resulting code supports more flexible control
transfers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoohci: Merge ohci_send_control with ohci_send_bulk
Kevin O'Connor [Wed, 31 Dec 2014 06:55:48 +0000 (01:55 -0500)]
ohci: Merge ohci_send_control with ohci_send_bulk

Merge both the control and bulk pipe sending functions into one new
function: ohci_send_pipe().  The two existing functions were similar,
and by merging them the resulting code supports more flexible control
transfers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoehci: Merge ehci_send_control with ehci_send_bulk
Kevin O'Connor [Wed, 31 Dec 2014 02:16:04 +0000 (21:16 -0500)]
ehci: Merge ehci_send_control with ehci_send_bulk

Merge both the control and bulk pipe sending functions into one new
function: ehci_send_pipe().  The two existing functions were similar,
and by merging them the resulting code supports more flexible control
transfers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoehci: Simplify fillTDbuffer() and rename
Kevin O'Connor [Thu, 1 Jan 2015 17:51:04 +0000 (12:51 -0500)]
ehci: Simplify fillTDbuffer() and rename

Simplify the calculation of the maximum transfer size per qtd,
simplify the fillTDbuffer() function so that it only fills the buffer
pointers, and rename fillTDbuffer() to ehci_fill_tdbuf().

Also, don't modify 'data' or 'datasize' so that usb_xfer_time() can
use 'datasize' at the end of the function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoehci: No need to support td array wrapping
Kevin O'Connor [Wed, 31 Dec 2014 01:50:44 +0000 (20:50 -0500)]
ehci: No need to support td array wrapping

The maximum bulk transfer is 64K and 4 QTDs can always transfer 64K.
So, there is no need to support a transfer with more than 4 QTDs.
Build the entire transaction and then submit it in one operation to
simplify the code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Support emulated text in gfx_read_char()
Kevin O'Connor [Tue, 6 Jan 2015 14:36:41 +0000 (09:36 -0500)]
vgabios: Support emulated text in gfx_read_char()

When emulating text mode on "coreboot framebuffer" SeaVGABIOS, return
a foreground and background attribute from gfx_read_char() and prefer
returning a space character (instead of null) on blank cells.

This also returns the foreground color (instead of always returning
zero) for regular graphics mode gfx_read_char() calls.  This seems
fine as tests show other vgabios implementations also return various
values here.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: implement read char in graphics mode
Paolo Bonzini [Fri, 2 Jan 2015 17:32:25 +0000 (12:32 -0500)]
vgabios: implement read char in graphics mode

GWBasic relies on this, so implement it to enable some serious retrocomputing.
There is no better way to do it than trying to match all characters one by one
against the current font.

This makes it possible to actually do something in SCREEN 1 and SCREEN 2
(without it, you can use graphics in the programs but not in direct mode).

I couldn't find documentation for what to return as the attribute, but
experimenting with DOSBox suggests 0 (and GWBasic accepts it).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: fix graphics operation with Bochs VGA in non-DISPI modes
Paolo Bonzini [Thu, 1 Jan 2015 20:27:46 +0000 (21:27 +0100)]
vgabios: fix graphics operation with Bochs VGA in non-DISPI modes

For legacy VGA modes that do not set the VBE_DISPI_ENABLED bit,
bochsvga_get_linelength returns 0.  Thus all characters are squashed
into the first scanline.  Fix this by falling back to stdvga for
the legacy modes.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agouhci: Increase bulk transfer STACKTDS to 16
Kevin O'Connor [Wed, 31 Dec 2014 06:42:38 +0000 (01:42 -0500)]
uhci: Increase bulk transfer STACKTDS to 16

Increase the number of simultaneous transfer descriptors that the
driver will build for uhci.  The old value of 4 was a leftover from
when SeaBIOS had a tiny 512 byte extra stack - now that there is a 2K
extra stack there is plenty of space for additional descriptors.
Using a value of 16 should allow for an entire 1ms frame of bulk
transfer content to be setup in advance (assuming the max packet size
is 64 bytes).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agouhci: Enable "depth" tree traversal for bulk transfers
Kevin O'Connor [Wed, 31 Dec 2014 06:40:07 +0000 (01:40 -0500)]
uhci: Enable "depth" tree traversal for bulk transfers

Set the "depth" flag on bulk transactions.  Since SeaBIOS doesn't use
bandwidth reclamation, without the depth flag the uhci controller will
only transfer one bulk packet per 1 ms frame.  This results in a
maximum of 64 bytes per millisecond, which severely limits the
transfer rate.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agodocs: Add documentation on using readserial.py script
Kevin O'Connor [Wed, 31 Dec 2014 17:02:56 +0000 (12:02 -0500)]
docs: Add documentation on using readserial.py script

Update the debugging documentation with info on timing debug output
with readserial.py.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoreadserial: Enhance pipe support
Kevin O'Connor [Wed, 31 Dec 2014 05:18:05 +0000 (00:18 -0500)]
readserial: Enhance pipe support

Automatically close and open the pipe if it closes.  Also, better
document that the -f option is for pipes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Add support for OHCI bulk transfers
Kevin O'Connor [Mon, 29 Dec 2014 18:06:23 +0000 (13:06 -0500)]
usb: Add support for OHCI bulk transfers

Support bulk transfers (usb drives) on OHCI USB controllers.  Now that
there is support for 32bit only drive controllers, it is not that hard
to support disks on OHCI controllers, and it may be useful for some
old hardware.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoblock: Check for read/write requests over 64K
Kevin O'Connor [Mon, 29 Dec 2014 15:29:34 +0000 (10:29 -0500)]
block: Check for read/write requests over 64K

The standard BIOS disk read/write request interface should never get a
request for more than 64K of data.  Explicitly check for overly large
requests and reject them.  This way, the low-level drivers do not need
to check for or attempt to handle very large requests.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agocdrom: Break up very large read requests into smaller requests
Kevin O'Connor [Mon, 29 Dec 2014 15:15:57 +0000 (10:15 -0500)]
cdrom: Break up very large read requests into smaller requests

A cdrom boot image could be over 64K in size, but the low level
drivers may not support very large reads.  If a large cdrom image is
found, issue multiple reads so that a read request over 64K is never
issued.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoscsi: Don't export cdb_* functions
Kevin O'Connor [Mon, 29 Dec 2014 14:58:48 +0000 (09:58 -0500)]
scsi: Don't export cdb_* functions

The low-level cdb_* functions are now only used from within
cmdblock.c, so don't export them.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agocdrom: call scsi_process_op() instead of cdb_read()
Kevin O'Connor [Mon, 29 Dec 2014 14:48:24 +0000 (09:48 -0500)]
cdrom: call scsi_process_op() instead of cdb_read()

Use the scsi_process_op() function instead of the lower level
cdb_read() function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoscsi: Move process_scsi_op() to hw/blockcmd.c and rename
Kevin O'Connor [Mon, 29 Dec 2014 14:45:15 +0000 (09:45 -0500)]
scsi: Move process_scsi_op() to hw/blockcmd.c and rename

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoscsi: Move cdb_* functions above scsi_* functions
Kevin O'Connor [Mon, 29 Dec 2014 14:40:46 +0000 (09:40 -0500)]
scsi: Move cdb_* functions above scsi_* functions

This is just code movement - no code changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agodocs: Add page describing SeaBIOS final object linking
Kevin O'Connor [Sun, 28 Dec 2014 19:18:03 +0000 (14:18 -0500)]
docs: Add page describing SeaBIOS final object linking

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agodocs: Add info on MODE16/MODESEGMENT compile time flags
Kevin O'Connor [Sun, 28 Dec 2014 19:17:37 +0000 (14:17 -0500)]
docs: Add info on MODE16/MODESEGMENT compile time flags

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agodocs: Don't point to repo README files
Kevin O'Connor [Thu, 18 Dec 2014 22:36:12 +0000 (17:36 -0500)]
docs: Don't point to repo README files

Now that the README files have been simplified, don't point the wiki
pages to them.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoAdd wiki documentation to repository
Kevin O'Connor [Tue, 16 Dec 2014 13:53:24 +0000 (08:53 -0500)]
Add wiki documentation to repository

Add a docs/ directory that contains the contents of the SeaBIOS wiki
in markdown format.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agosdcard: Initial support for SD cards on PCI SDHCI controllers on QEMU
Kevin O'Connor [Tue, 16 Dec 2014 14:55:16 +0000 (09:55 -0500)]
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>
10 years agoSimplify README files - point to online documentation instead
Kevin O'Connor [Tue, 16 Dec 2014 02:44:13 +0000 (21:44 -0500)]
Simplify README files - point to online documentation instead

The README file and README.CSM file have gotten a bit out of date.
Instead of maintaining technical information in the README file, point
new users to the SeaBIOS wiki.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Update USB hub code to support super speed hubs
Kevin O'Connor [Fri, 12 Dec 2014 19:16:43 +0000 (14:16 -0500)]
usb: Update USB hub code to support super speed hubs

Super speed hubs (usb3 spec) have specific initialization
requirements.  Add the code necessary to detect and initialize these
hubs.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoEliminate FUNCFSEG - only force portions of inline asm to f-segment
Kevin O'Connor [Wed, 3 Dec 2014 17:53:01 +0000 (12:53 -0500)]
Eliminate FUNCFSEG - only force portions of inline asm to f-segment

The FUNCFSEG macro was introduced to force a C function into the
f-segment.  This was needed for some C functions that used inline
assembler that contained some 16bit code.  Instead of forcing the
entire C function into the f-segment, just force the small subset of
inline assembler into the f-segment.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoUse macros for .code16/32 mode switches in inline asm in stacks.c
Kevin O'Connor [Wed, 3 Dec 2014 17:39:28 +0000 (12:39 -0500)]
Use macros for .code16/32 mode switches in inline asm in stacks.c

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoMinor - be consistent in placement of .code16/32 in romlayout.S
Kevin O'Connor [Wed, 3 Dec 2014 17:22:14 +0000 (12:22 -0500)]
Minor - be consistent in placement of .code16/32 in romlayout.S

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>
10 years agofloppy: Make sure to yield() during floppy PIO
Kevin O'Connor [Sat, 29 Nov 2014 18:04:46 +0000 (13:04 -0500)]
floppy: Make sure to yield() during floppy PIO

The floppy Programmed IO code really should yield while the controller
is busy.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agobuild: set LC_ALL=C
Gerd Hoffmann [Wed, 3 Dec 2014 14:14:57 +0000 (15:14 +0100)]
build: set LC_ALL=C

Avoids tools such as layoutrom stumble over localized messages.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-By: Patrick Georgi <pgeorgi@google.com>
10 years agoadd scripts/tarball.sh
Gerd Hoffmann [Mon, 17 Nov 2014 07:32:00 +0000 (08:32 +0100)]
add scripts/tarball.sh

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agopciinit: Fix build warning in mch_pci_slot_get_irq()
Kevin O'Connor [Wed, 12 Nov 2014 23:00:30 +0000 (18:00 -0500)]
pciinit: Fix build warning in mch_pci_slot_get_irq()

Some old versions of gcc warn that 'irq might be used uninitialized'.
Replace the switch statement with an if statement to suppress the
warning.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoFix build issue on gcc34
Kevin O'Connor [Wed, 12 Nov 2014 22:49:33 +0000 (17:49 -0500)]
Fix build issue on gcc34

Older versions of gcc may not inline on_extra_stack() and thus cause a
link error when compiling in 32bit segmented mode.  Test for MODE16
explicitly in stack_hop_back() to prevent the problem.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoMinor - comment updates in romlayout.S
Kevin O'Connor [Wed, 5 Nov 2014 17:04:53 +0000 (12:04 -0500)]
Minor - comment updates in romlayout.S

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoUse an aligned stack offset when entering on the extra stack
Kevin O'Connor [Wed, 5 Nov 2014 14:05:36 +0000 (09:05 -0500)]
Use an aligned stack offset when entering on the extra stack

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>
10 years agovgabios: Add software cursor capability
Kevin O'Connor [Sat, 18 Oct 2014 02:15:42 +0000 (22:15 -0400)]
vgabios: Add software cursor capability

Add mechanism for drawing a cursor to the framebuffer to implement a
cursor in software.  The timer interrupt is "hooked" so that the
cursor can blink.  This can be useful for "coreboot native vga".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Support emulating text mode attributes while in graphics mode
Kevin O'Connor [Thu, 30 Oct 2014 16:09:19 +0000 (12:09 -0400)]
vgabios: Support emulating text mode attributes while in graphics mode

Add support for simple text mode attribute emulation while in graphics
mode.  This improves text highlighting and background color on some
boot-loaders.  Enable it only for CBVGA vgabios and only when a text
mode is requested.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoMinor - move PORT_PS2_CTRLB from hw/ps2port.h to hw/timer.c
Kevin O'Connor [Mon, 3 Nov 2014 14:48:21 +0000 (09:48 -0500)]
Minor - move PORT_PS2_CTRLB from hw/ps2port.h to hw/timer.c

The PORT_PS2_CTRLB port is only used by timers - it's just a
historical artifact that it was part of the original ps2 controller.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agomegasas: read addional PCI I/O bar
Hannes Reinecke [Thu, 6 Nov 2014 13:31:56 +0000 (14:31 +0100)]
megasas: read addional PCI I/O bar

Some newer cards have the I/O bar at BAR 0, so we need to check
that, too, if we cannot get an address for BAR 2.
Without this patch the new 'megasas-gen2' emulation in qemu
is not detected.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoFix PNP regression introduced in 99cb8f3e due to missed conversion
Kevin O'Connor [Mon, 3 Nov 2014 14:45:51 +0000 (09:45 -0500)]
Fix PNP regression introduced in 99cb8f3e due to missed conversion

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>
10 years agovgabios: Add support for reading framebuffer in "direct" mode
Kevin O'Connor [Fri, 17 Oct 2014 04:20:14 +0000 (00:20 -0400)]
vgabios: Add support for reading framebuffer in "direct" mode

Support reading high memory "direct" framebuffers and translating the
results to 8 bit attribute values.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Fill in available legacy modes in video_func_static at runtime
Kevin O'Connor [Thu, 23 Oct 2014 20:37:08 +0000 (16:37 -0400)]
vgabios: Fill in available legacy modes in video_func_static at runtime

Instead of hard coding the list of modes, fill them in from the list
of supported modes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Move standard table definitions to std/vga.h
Kevin O'Connor [Thu, 23 Oct 2014 20:24:36 +0000 (16:24 -0400)]
vgabios: Move standard table definitions to std/vga.h

Move the standard video bios definitions into a new header file.
Also, define a struct with the layout for the static functionality
table.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Only set the dcc_index=8 if stdvga ports are available
Kevin O'Connor [Thu, 23 Oct 2014 19:54:59 +0000 (15:54 -0400)]
vgabios: Only set the dcc_index=8 if stdvga ports are available

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Only init BDA device details in init_bios_area()
Kevin O'Connor [Thu, 23 Oct 2014 17:04:17 +0000 (13:04 -0400)]
vgabios: Only init BDA device details in init_bios_area()

Don't set the device details when changing modes, and don't set mode
details outside of mode setting.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Refactor get/set_cursor_shape() code
Kevin O'Connor [Thu, 23 Oct 2014 00:57:37 +0000 (20:57 -0400)]
vgabios: Refactor get/set_cursor_shape() code

Rework the code so that it is possible to calculate the current cursor
shape even when not changing it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Set cursor shape fixes
Kevin O'Connor [Thu, 23 Oct 2014 00:27:28 +0000 (20:27 -0400)]
vgabios: Set cursor shape fixes

The "cursor scaling" mode is determined by the first bit of the
video_ctl bda value, not the modeset_ctl value.  Also, on a
set_scan_lines() call, the shape should be set to lines-3/lines-2 and
the shape must be set after char_height has been updated.

The existing cursor shape code matches the legacy "lgpl vgabios", but
the behavior doesn't match bios documentation nor observations with an
ati vga bios.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Rename vbe_flags to flags
Kevin O'Connor [Tue, 21 Oct 2014 19:15:44 +0000 (15:15 -0400)]
vgabios: Rename vbe_flags to flags

Allow the custom bda field vbe_flags to be used for flags outside of
vbe.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Don't pass vmode_g to vgafb_move_chars() / vgafb_clear_chars()
Kevin O'Connor [Sat, 18 Oct 2014 01:47:10 +0000 (21:47 -0400)]
vgabios: Don't pass vmode_g to vgafb_move_chars() / vgafb_clear_chars()

Now that a pointer to the current video mode info struct is cached in
memory, it's not necessary to pass the struct into the vgafb code.
The vgafb code can lookup the struct itself.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Cache a pointer to the current mode struct in the BDA
Kevin O'Connor [Sat, 18 Oct 2014 01:37:23 +0000 (21:37 -0400)]
vgabios: Cache a pointer to the current mode struct in the BDA

Cache a pointer to the current mode 'vgamode_s' struct in the BDA to
avoid doing a linear scan of all available vga modes when the struct
is needed.

This uses an additional two bytes in the BDA (at offset 0xbc).  It's
possible this could conflict with some other software, but that seams
unlikely because that part of the BDA seems reserved for BIOS and
VGABIOS uses.  (And neither SeaBIOS nor Bochs BIOS currently make use
of that area.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agovgabios: Don't declare custom internal BDA storage in std/bda.h
Kevin O'Connor [Sat, 18 Oct 2014 01:17:48 +0000 (21:17 -0400)]
vgabios: Don't declare custom internal BDA storage in std/bda.h

The vgabios uses storage in the BDA at offset 0xb9 for internal custom
storage (the contents do not appear to be part of any bios standard).
Move the description of this custom vgabios area from std/bda.h to
vgasrc/vgabios.h.  Add two new macros (GET_BDA_EXT and SET_BDA_EXT).
This should make it more clear that the area is for custom internal
storage.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoRemove unused macro ENTRY_ST
Kevin O'Connor [Tue, 21 Oct 2014 18:39:47 +0000 (14:39 -0400)]
Remove unused macro ENTRY_ST

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoDo full BREGS backup/restore for pmm, pnp, and irqentry_extrastack
Kevin O'Connor [Tue, 21 Oct 2014 18:34:06 +0000 (14:34 -0400)]
Do full BREGS backup/restore for pmm, pnp, and irqentry_extrastack

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>
10 years agoCreate assembler macros for saving and restoring 'struct bregs'
Kevin O'Connor [Tue, 21 Oct 2014 06:23:02 +0000 (02:23 -0400)]
Create assembler macros for saving and restoring 'struct bregs'

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>
10 years agoDon't clobber %ax on ENTRY_INTO32 macro
Kevin O'Connor [Tue, 21 Oct 2014 07:19:55 +0000 (03:19 -0400)]
Don't clobber %ax on ENTRY_INTO32 macro

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>
10 years agoUse 32bit memcpy in int1587 when applicable
Kevin O'Connor [Tue, 21 Oct 2014 03:06:04 +0000 (23:06 -0400)]
Use 32bit memcpy in int1587 when applicable

If the amount of data to be copied is an even number of four, then
copy the data in four byte chunks.  This 32bit copy is more efficient,
in particular when copying to/from memory mapped io.  This should
improve the performance of framebuffer draws in cbvga SeaVGABIOS.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Use usb_realloc_pipe for pipe alloc, update, and free.
Kevin O'Connor [Thu, 16 Oct 2014 18:03:39 +0000 (14:03 -0400)]
usb: Use usb_realloc_pipe for pipe alloc, update, and free.

Now that the usb controller drivers all support the realloc method,
use that for all pipe allocations, reallocations, and freeing.  This
gives the driver more control over the pipe life cycle.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoehci: Export ehci_realloc_pipe() instead of ehci_alloc_pipe()
Kevin O'Connor [Thu, 16 Oct 2014 17:40:42 +0000 (13:40 -0400)]
ehci: Export ehci_realloc_pipe() instead of ehci_alloc_pipe()

Support alloc, update, and free from the single exported function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoohci: Export ohci_realloc_pipe() instead of ohci_alloc_pipe()
Kevin O'Connor [Thu, 16 Oct 2014 17:36:41 +0000 (13:36 -0400)]
ohci: Export ohci_realloc_pipe() instead of ohci_alloc_pipe()

Support alloc, update, and free from the single exported function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agouhci: Export uhci_realloc_pipe() instead of uhci_alloc_pipe()
Kevin O'Connor [Thu, 16 Oct 2014 17:33:35 +0000 (13:33 -0400)]
uhci: Export uhci_realloc_pipe() instead of uhci_alloc_pipe()

Support alloc, update, and free from the single exported function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoxhci: Change xhci_update_pipe() to xhci_realloc_pipe() and use for alloc too
Kevin O'Connor [Thu, 16 Oct 2014 17:23:08 +0000 (13:23 -0400)]
xhci: Change xhci_update_pipe() to xhci_realloc_pipe() and use for alloc too

Instead of exporting both xhci_alloc_pipe() and xhci_update_pipe(),
export only xhci_realloc_pipe() and support alloc, update, and free
from it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Clarify usb freelist manipulations
Kevin O'Connor [Thu, 16 Oct 2014 16:31:42 +0000 (12:31 -0400)]
usb: Clarify usb freelist manipulations

Rename usb_getFreePipe() to usb_get_freelist().  Add usb_is_freelist()
and usb_add_freelist() functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Rename free_pipe() to usb_free_pipe()
Kevin O'Connor [Thu, 16 Oct 2014 15:59:45 +0000 (11:59 -0400)]
usb: Rename free_pipe() to usb_free_pipe()

Also, pass in usbdev to usb_free_pipe().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Rename send_default_control() to usb_send_default_control()
Kevin O'Connor [Thu, 16 Oct 2014 16:11:12 +0000 (12:11 -0400)]
usb: Rename send_default_control() to usb_send_default_control()

This is just function renaming - no code implementation changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Rename findEndPointDesc() to usb_find_desc()
Kevin O'Connor [Thu, 16 Oct 2014 16:08:00 +0000 (12:08 -0400)]
usb: Rename findEndPointDesc() to usb_find_desc()

This is just function renaming - no code implementation changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Rename usb_getFrameExp() to usb_get_period()
Kevin O'Connor [Thu, 16 Oct 2014 16:05:09 +0000 (12:05 -0400)]
usb: Rename usb_getFrameExp() to usb_get_period()

This is just function renaming - no code implementation changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Rename ?hci_control() to ?hci_send_control()
Kevin O'Connor [Thu, 16 Oct 2014 15:55:16 +0000 (11:55 -0400)]
usb: Rename ?hci_control() to ?hci_send_control()

This is just function renaming - no code implementation changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoBackup and restore a20 on call32_sloppy()
Kevin O'Connor [Sat, 11 Oct 2014 17:27:16 +0000 (13:27 -0400)]
Backup and restore a20 on call32_sloppy()

Previously, the a20 line would always be enabled and left on after
call32_sloppy().  The setting should really be backed up and restored
on each call.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoMove a20 code from system.c and ps2port.h to x86.h
Kevin O'Connor [Sat, 11 Oct 2014 17:16:12 +0000 (13:16 -0400)]
Move a20 code from system.c and ps2port.h to x86.h

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>
10 years agoImplement call32 mechanism using SMIs.
Kevin O'Connor [Fri, 11 Apr 2014 15:20:41 +0000 (11:20 -0400)]
Implement call32 mechanism using SMIs.

Add support for jumping into 32bit mode using a System Management Mode
(SMM) handler.  When available, this allows SeaBIOS to transition to
32bit mode even when called in vm86 mode.  It will also prevent the
clobbering of the segment registers.

Currently, the SMM mode is only supported in QEMU when running in TCG
mode.  Also, QEMU v2.1 (or later) is needed for it to work when in
vm86 mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoFully restore 16bit state during call16_sloppy()
Kevin O'Connor [Tue, 30 Sep 2014 16:55:54 +0000 (12:55 -0400)]
Fully restore 16bit state during call16_sloppy()

When transitioning back to 16bit mode from within call32(), restore
the full state (cmos index, gdt, fs/gs) in addition to restoring the
original stack.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoBreak up call32() into call32() and call32_sloppy()
Kevin O'Connor [Tue, 30 Sep 2014 16:13:44 +0000 (12:13 -0400)]
Break up call32() into call32() and call32_sloppy()

This separates call32() into two functions.  It also moves the
call16_sloppy() code next to the call32_sloppy() code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoMove call16() functions from romlayout.S to inline assembler in stacks.c
Kevin O'Connor [Wed, 24 Sep 2014 21:48:28 +0000 (17:48 -0400)]
Move call16() functions from romlayout.S to inline assembler in stacks.c

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>
10 years agobuild: Support declaring 32bit C functions that must reside in the f-segment
Kevin O'Connor [Wed, 24 Sep 2014 19:58:12 +0000 (15:58 -0400)]
build: Support declaring 32bit C functions that must reside in the f-segment

Add support for a FUNCFSEG macro that will force a "32bit flat" C
function to be located in the f-segment.  This is useful for 32bit
code with inline assembler that thunks to 16bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoUpdate reset() to use call16_back()
Kevin O'Connor [Tue, 30 Sep 2014 04:17:44 +0000 (00:17 -0400)]
Update reset() to use call16_back()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoSimplify farcall16 code
Kevin O'Connor [Tue, 30 Sep 2014 04:11:38 +0000 (00:11 -0400)]
Simplify farcall16 code

With this change, farcall16() is only used for external API calls and
is only invoked from a 32bit mode entered directly via transition32.
farcall16big() is also only used for external API calls and is only
invoked from a 32bit mode entered directly via transition32.

call16_int() now calls _farcall16() directly, and it will use normal
16bit mode or big real mode as required.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoTrack when entering via call32() and use the same mode for stack_hop_back()
Kevin O'Connor [Tue, 30 Sep 2014 03:59:47 +0000 (23:59 -0400)]
Track when entering via call32() and use the same mode for stack_hop_back()

If 32bit mode is entered directly via transition32, then use a simple
call16() when hopping back to 16bit mode.  Use only call16big() during
post and when entering 32bit mode via call32().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoUpdate stack_hop_back() to jump to 16bit mode if called in 32bit mode.
Kevin O'Connor [Mon, 29 Sep 2014 23:39:31 +0000 (19:39 -0400)]
Update stack_hop_back() to jump to 16bit mode if called in 32bit mode.

Also, update callers to rely on this feature.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoUpdate invoke_mouse_handler() to use need_hop_back()
Kevin O'Connor [Mon, 29 Sep 2014 23:23:45 +0000 (19:23 -0400)]
Update invoke_mouse_handler() to use need_hop_back()

Make the mouse handler stack_hop_back() code similar to the other
users that use need_stack_hop().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoAdd need_hop_back() call that determines if stack_hop_back is needed
Kevin O'Connor [Mon, 29 Sep 2014 23:18:25 +0000 (19:18 -0400)]
Add need_hop_back() call that determines if stack_hop_back is needed

Also, use need_hop_back() instead of on_extra_stack() in code that
determines whether or not to call stack_hop_back().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoMove stack hop code below call32/call16 code in stacks.c
Kevin O'Connor [Mon, 29 Sep 2014 23:08:57 +0000 (19:08 -0400)]
Move stack hop code below call32/call16 code in stacks.c

This change is a just code movement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agopmm: Fix entry point to support non-zero %ss
Kevin O'Connor [Tue, 30 Sep 2014 13:37:26 +0000 (09:37 -0400)]
pmm: Fix entry point to support non-zero %ss

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>
10 years agoRevert "Use the extra stack for 16bit USB and PS2 keyboard/mouse commands."
Kevin O'Connor [Tue, 30 Sep 2014 13:17:14 +0000 (09:17 -0400)]
Revert "Use the extra stack for 16bit USB and PS2 keyboard/mouse commands."

It's not valid to pass a pointer to a stack variable through the
stack_hop() call (because the call changes the stack segment).  This
bug was probably not noticed before because by default
(CONFIG_ENTRY_EXTRASTACK) SeaBIOS uses the extra stack on all 16bit
entry points, and the internal stack_hop() with that config option is
effectively a no-op.

This reverts commit d488a7683d90bf8fae7ceb8c3ad9e95fbbd92079.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoehci: Fix bug in hub port assignment
Kevin O'Connor [Fri, 12 Sep 2014 15:59:23 +0000 (11:59 -0400)]
ehci: Fix bug in hub port assignment

The usbdev->port field is zero indexed, while the USB spec expects the
port values to start at one.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Perform device detect polling on all usb controllers.
Kevin O'Connor [Wed, 10 Sep 2014 15:33:01 +0000 (11:33 -0400)]
usb: Perform device detect polling on all usb controllers.

Move the 100ms (USB_TIME_SIGATT) device detect polling from the
ohci/uhci/usb-hub code to the generic usb_hub_port_setup() code.  This
extends the 100ms polling to ehci and xhci controllers.  The code in
usb_hub_port_setup() now compares USB_TIME_SIGATT to the start of
usb_enumerate(), which may make boots faster when threads are
disabled.

This patch also changes the meaning of the return code for
hub->op->detect() calls.  Now 1 indicates device found, 0 indicates
device not found, and -1 indicates permanent failure.

Also, the xhci controller generic delay of 100ms is replaced with a
20ms root hub power stabilize time.  This in combination with the
100ms for USB_TIME_SIGATT should be closer to the USB2 spec (the USB3
spec does not seem to declare an equivalent of USB_TIME_SIGATT).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoehci: Stall uhci/ohci init only until default port routing is done.
Kevin O'Connor [Wed, 10 Sep 2014 15:04:26 +0000 (11:04 -0400)]
ehci: Stall uhci/ohci init only until default port routing is done.

Now that uhci and ohci will continually poll for a device connect, the
ehci controller only needs to ensure that the default routing is setup
properly before allowing uhci and ohci to be initialized.

This also fixes two error paths in configure_ehci() that were not
properly updating PendingEHCIPorts.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoohci: Repeatedly poll for device detect for 100ms.
Kevin O'Connor [Wed, 10 Sep 2014 14:37:52 +0000 (10:37 -0400)]
ohci: Repeatedly poll for device detect for 100ms.

According to the USB2 specification, a device may take up to 100ms
(USB_TIME_SIGATT) after port power stabilizes to be detected.  So,
continually recheck for a device connection event.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agouhci: Repeatedly poll for device detect for 100ms.
Kevin O'Connor [Wed, 10 Sep 2014 14:33:36 +0000 (10:33 -0400)]
uhci: Repeatedly poll for device detect for 100ms.

According to the USB2 specification, a device may take up to 100ms
(USB_TIME_SIGATT) after port power stabilizes to be detected.  So,
continually recheck for a device connection event.

Technically, the uhci root hub ports are always powered up, but it's
not possible to know how long the machine has been on, so it's better
to be safe here.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoxhci: Change xhci_hub_detect() to use connect status instead of link state.
Kevin O'Connor [Wed, 10 Sep 2014 14:24:04 +0000 (10:24 -0400)]
xhci: Change xhci_hub_detect() to use connect status instead of link state.

Use the connect status bit to determine if a device is connected
instead of the port link state state machine status.  This makes the
driver more similar to the other drivers and may help diagnose devices
that take longer to boot up.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb-hub: Enable power to all ports prior to calling usb_enumerate().
Kevin O'Connor [Wed, 10 Sep 2014 14:18:02 +0000 (10:18 -0400)]
usb-hub: Enable power to all ports prior to calling usb_enumerate().

Don't perform port power up in the detect code.  Instead do it prior
to calling usb_enumerate().  This makes the code more similar to the
usb root hub drivers.  It can also reduce the total boot time when
threads are disabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoehci: Move port power up from ehci_hub_detect() to check_ehci_ports().
Kevin O'Connor [Wed, 10 Sep 2014 14:02:20 +0000 (10:02 -0400)]
ehci: Move port power up from ehci_hub_detect() to check_ehci_ports().

Don't perform port power up in the detect code.  Instead do it prior
to calling usb_enumerate().  This makes the code more similar to the
ohci and xhci drivers.  It can also reduce the total boot time when
threads are disabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoxhci: Add xhci_check_ports() and xhci_free_pipes() functions.
Kevin O'Connor [Wed, 10 Sep 2014 13:10:42 +0000 (09:10 -0400)]
xhci: Add xhci_check_ports() and xhci_free_pipes() functions.

Add these two functions so that the xhci code is more similar to the
other USB controllers.  Also, store the temporary hub structure on the
stack instead of in struct usb_xhci_s.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoxhci: Move root hub and setup code to top of file.
Kevin O'Connor [Wed, 10 Sep 2014 12:51:50 +0000 (08:51 -0400)]
xhci: Move root hub and setup code to top of file.

Move the setup code to the top of the file so that like code is
together and to make the code layout more similar to the other usb
controllers.

This change is purely code movement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoxhci: Use high memory instead of low memory for internal storage.
Kevin O'Connor [Wed, 10 Sep 2014 13:31:43 +0000 (09:31 -0400)]
xhci: Use high memory instead of low memory for internal storage.

Now that the driver runs exclusively in 32bit mode, avoid using the
scarce low memory resource.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoxhci: Remove 16bit code wrappers.
Kevin O'Connor [Wed, 10 Sep 2014 12:31:28 +0000 (08:31 -0400)]
xhci: Remove 16bit code wrappers.

The usb-xhci.c file is only compiled in 32bit mode now, so remove all
the 16bit macros.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoxhci: Call usb_desc2pipe() on xhci_update_pipe().
Kevin O'Connor [Tue, 9 Sep 2014 23:31:45 +0000 (19:31 -0400)]
xhci: Call usb_desc2pipe() on xhci_update_pipe().

Make sure to call usb_desc2pipe() when updating a pipe settings.  This
ensures that pipe->devaddr is properly updated.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agousb: Fix usb_xfer_time() to work when called in 16bit mode.
Kevin O'Connor [Tue, 9 Sep 2014 22:24:00 +0000 (18:24 -0400)]
usb: Fix usb_xfer_time() to work when called in 16bit mode.

Make sure to wrap accesses to the usb_pipe struct with GET_LOWFLAT so
that it works in 16bit mode.  This bug impacts both ehci and uhci usb
controllers (it should not impact ohci and xhci as those never call
the function in 16bit mode).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agobuild: Update kconfig to version in Linux 3.16.
Kevin O'Connor [Sun, 24 Aug 2014 02:06:21 +0000 (22:06 -0400)]
build: Update kconfig to version in Linux 3.16.

Update kconfig (from Linux v3.13) to the latest version (Linux v3.16).

This copies kconfig from Linux with only the changes necessary to work
with the SeaBIOS build (the equivalent of the earlier SeaBIOS 0da7bfdf
commit) and the changes necessary to always emit symbols (SeaBIOS
b623e7c5 commit).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 years agoMinor - remove stray tab from src/fw/smm.c.
Kevin O'Connor [Sat, 23 Aug 2014 16:10:29 +0000 (12:10 -0400)]
Minor - remove stray tab from src/fw/smm.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>