Hi Stefan,
I'm CC'ing the mailing list.
On Wed, Nov 24, 2010 at 11:45:17AM -0500, Stefan Berger wrote:
Hi Kevin,
while I am porting the BIOS code for TCG support to SeaBIOS, I am wondering about the following:
'When' is it recommendable to switch from 16 bit to 32bit.
To be honest, this has never really been done before in SeaBIOS, so I think we'll have to figure this out as we go. Since you need to access full memory, it looks like it will be required to jump into 32bit mode.
I am asking because the interface I am implementing allows callers to pass input and output data structures using es:di and ds:si, with es and ds allowed to be loaded with anything possible. So my strategy in the Bochs BIOS was to switch to 32 bit even before calling the interrupt handler, there doing the case statement for branching into the actual functions (switch (regs->al)) and passing 32 bit pointers converted from es:di and ds:si to the functions doing the work and reading from those memory locations.
This sounds okay to me - it should be possible to implement handle_1abb(regs) which does a call32(tcg32_1abb, regs). It's possible to do all the pointer conversion while in 32bit mode.
The 'thing' is also that several ones of the functions that can be called through the interrupt interface are also called from the implemented functions. Example:
Functions A,B,C can be called via the interrupt handler.
Function B also calls A. Function C also calls B.
This shouldn't really be an issue. The build should take care of this.
This is due to the hierarchical nature of the functions. Also, while for example B calls A, B fills a data structure (on the stack) that it passes to A. A of course can get the same data structure from the user calling the interrupt interface. So, by switching to 32 bit mode and converting to 32 bit pointers early I could previously avoid a lot of headaches with the segment registers in 16 bit mode and reading the data from wherever they may be. Would you have any concerns about switching to 32 bit mode early, so that the interrupt handler and anything subsequent runs in 32 bit mode?
I can't say for sure what will make sense without seeing the code first, but it sounds okay to me.
-Kevin
Regards, Stefan