This series converts the AHCI driver to run entirely in 32bit mode. Currently, ahci will only jump into 32bit mode when it needs to access the ahci device's PCI config space. However, if the code has to run anything in 32bit mode, it might as well run it all in 32bit mode. Doing this also shrinks the total SeaBIOS code size by a few KB.
In order for this to work, SeaBIOS needs to be able to transition from 32bit mode back to 16bit mode in order to use yield(). This requires tracking the stack segment when using call32() and restoring it if call16() is later called. It also requires getting off the "extra stack" if it is in use.
This series is a little bit uglier than I hoped, but I'm sending it out for further comments.
This series is also at: https://github.com/KevinOConnor/seabios/tree/testing
-Kevin
Kevin O'Connor (6): Rearrange stack_hop_back() call in wait_irq, check_irqs, and _farcall16. Minor - move call16 assembler in romlayout.S. Make __call16 use C calling convention and support two passed parameters. Update _farcall16() to pass segment of callregs explicitly. Support call16() calls after entering 32bit mode from call32(). Run ahci code entirely in 32bit mode.
Makefile | 4 +- src/block.c | 13 ++++-- src/hw/ahci.c | 15 ++----- src/hw/blockcmd.c | 5 ++- src/romlayout.S | 132 ++++++++++++++++++++++++++++++++---------------------- src/stacks.c | 78 +++++++++++++++++++------------- 6 files changed, 145 insertions(+), 102 deletions(-)
On Mi, 2013-10-02 at 21:38 -0400, Kevin O'Connor wrote:
This series converts the AHCI driver to run entirely in 32bit mode. Currently, ahci will only jump into 32bit mode when it needs to access the ahci device's PCI config space. However, if the code has to run anything in 32bit mode, it might as well run it all in 32bit mode.
Makes sense.
Doing this also shrinks the total SeaBIOS code size by a few KB.
Also some runtime memory allocations can be moved out of low memory.
xhci is another candidate to be ported to 32bit mode as it likewise jumps to 32bit mode for doorbell register access.
cheers, Gerd
On Mon, Oct 07, 2013 at 12:02:23PM +0200, Gerd Hoffmann wrote:
On Mi, 2013-10-02 at 21:38 -0400, Kevin O'Connor wrote:
This series converts the AHCI driver to run entirely in 32bit mode. Currently, ahci will only jump into 32bit mode when it needs to access the ahci device's PCI config space. However, if the code has to run anything in 32bit mode, it might as well run it all in 32bit mode.
Makes sense.
Doing this also shrinks the total SeaBIOS code size by a few KB.
Also some runtime memory allocations can be moved out of low memory.
xhci is another candidate to be ported to 32bit mode as it likewise jumps to 32bit mode for doorbell register access.
Yes, and it looks like the recently submitted "pvscsi" patch could also be converted.
What I don't like about the series is the "+ BUILD_BIOS_ADDR" in block.c. All the GET_GLOBAL(op->drive_g) in the disk drivers should probably get converted to GET_GLOBALFLAT(op->drive_gf) so these weird offsets aren't needed. The StackSeg manipulation in farcall16 and in the __call16 assembler is not nice either.
Thanks, -Kevin
On Wed, Oct 02, 2013 at 09:38:41PM -0400, Kevin O'Connor wrote:
This series converts the AHCI driver to run entirely in 32bit mode. Currently, ahci will only jump into 32bit mode when it needs to access the ahci device's PCI config space. However, if the code has to run anything in 32bit mode, it might as well run it all in 32bit mode. Doing this also shrinks the total SeaBIOS code size by a few KB.
In order for this to work, SeaBIOS needs to be able to transition from 32bit mode back to 16bit mode in order to use yield(). This requires tracking the stack segment when using call32() and restoring it if call16() is later called. It also requires getting off the "extra stack" if it is in use.
This series is a little bit uglier than I hoped, but I'm sending it out for further comments.
FYI, I have pushed this series.
-Kevin