PXE API in 32bit pmode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
DustWolf
Posts: 6
Joined: Sat Jul 12, 2008 8:21 am

PXE API in 32bit pmode

Post by DustWolf »

Hello,

Can PXE API be used from 32bit protected mode?

The PXE Specification is a bit vague on the area.

Thanks for the help in advance.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: PXE API in 32bit pmode

Post by Brendan »

Hi,
DustWolf wrote:Can PXE API be used from 32bit protected mode?
In theory, it can.
DustWolf wrote:The PXE Specification is a bit vague on the area.
The PXE Specification is vague in lots of areas - I don't think anyone here has figured out how to use PXE from protected mode (I use PXE from real mode). Maybe you could figure it out from the Etherboot/gPXE project's source code?


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
DustWolf
Posts: 6
Joined: Sat Jul 12, 2008 8:21 am

Re: PXE API in 32bit pmode

Post by DustWolf »

What I mean is... is the PXE API code 32bit?

I'm guessing if it's 16bit, it can't be used in 32bit pmode without some mode flipping at least.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: PXE API in 32bit pmode

Post by jal »

DustWolf wrote:What I mean is... is the PXE API code 32bit?

I'm guessing if it's 16bit, it can't be used in 32bit pmode without some mode flipping at least.
32 vs 16 bit and pmode vs rmode are of course separate issues, I hope you know that?


JAL
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: PXE API in 32bit pmode

Post by Brendan »

Hi,
DustWolf wrote:What I mean is... is the PXE API code 32bit?

I'm guessing if it's 16bit, it can't be used in 32bit pmode without some mode flipping at least.
The specification defines "the API", including function numbers, flag meanings, structure formats, etc.

It also defines two real mode interfaces to the API and two 16-bit protected mode interfaces to the API. These are "new" and "old" interfaces, where the old interface/s are provided for backward compatibility and shouldn't be used by new software unless the new interface/s aren't supported by the ROM (the new interfaces should be supported by the ROM for PXE 2.1 or later). It doesn't matter if you use the real mode interface or the protected mode interface, the underlying API is the same (same function numbers, same flag meanings, same structure formats, etc).

To get the newer protected mode interface to work you'd need to setup GDT entries to suit PXE, then tell PXE which GDT entries you've used for what (by changing fields in the !PXE structure). However, you can only find out the base address and limit needed for the GDT entries (and the number of GDT entries), and can't find out if they should be executable, or readable, or writable. For the first 7 you can probably guess from their names (and some testing), but for any additional GDT entries you're screwed (and you can't just have an "execute+read+write" segment because protected mode doesn't allow that; and just because you guess the right permissions for one network card doesn't mean it'll work on a different network card).

For the newer protected mode interface you'd also need to do something with the "StatusCallout" field in the !PXE structure because "The internal status call-out procedure uses BIOS I/O interrupts and will only work in real mode.". AFAIK it should be possible to set the "StatusCallout" field in the !PXE structure to -1 (or 0xFFFF:0xFFFF) to disable the status call-out feature (rather than replacing it with your own protected mode status call-out function), but I don't know if that's a good idea or not because I haven't been able to figure out exactly what the status callout function is actually meant to do. A simple guess would be that the PXE functions attempts to display error information on the screen using BIOS functions, but IMHO this doesn't make that much sense - if PXE was designed properly, then the PXE functions would all return standard error codes (which they do, although they aren't necessarily as standard as they could be), and your boot loader would decide what to display on the screen (if anything) and how it should be displayed to avoid making a mess of the rest of the screen; and there'd be no need for any status call-out function. Also note that the specification doesn't even tell you what the status callout function is meant to return or if it has any input parameters, so good luck writing your own protected mode status call-out function.

Despite all of this, it should be possible to write code that uses the newer protected mode interface that works most of the time. For example, you can determine if PXE needs more than 7 GDT descriptors and complain if it does (I have a feeling that people network card manufacturers don't know what's meant to happen with these extra segments either, and therefore could have decided to only use the standard segments to be sure). For the stausCallout mess, you could disabling it with "-1" and test that on several different network cards, then maybe try a dummy function and see when it's called, etc - with enough guesswork you'd be able to get something to work eventually.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply