PXE: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
No edit summary
m Bot: Replace deprecated source tag with syntaxhighlight
 
(One intermediate revision by the same user not shown)
Line 17:
The structure of the PXENV+ structure is as follows:
 
<sourcesyntaxhighlight lang="c">
// The Signature of the PXENV+ structure - contains "PXENV+".
uint8_t Signature[6];
Line 50:
// This is a far pointer to the "!PXE" structure, only present when the structure is present.
uint32_t PXEPtr;
</syntaxhighlight>
</source>
 
==== Recommended Usage ====
Line 67:
The structure of the !PXE structure is as follows:
 
<sourcesyntaxhighlight lang="c">
// The Signature of the !PXE structure - contains "!PXE".
uint8_t Signature[4];
Line 90:
 
// The rest of the fields don't matter much (in the rest of the article), and the Specifications can be referred.
</syntaxhighlight>
</source>
 
==== Recommended Usage ====
Line 112:
A example generic call function is as follows:
 
<sourcesyntaxhighlight lang="asm">
; Calls the PXE API, and abstracts things such that it works on both old and new APIs.
; @ds:di The address of the input buffer.
Line 127:
add sp, 6 ; Clean up the stack.
ret
</syntaxhighlight>
</source>
 
The PXE API returns a status flag in AX and the beginning of the input buffer passed. It is recommended to test both of these, where a non zero value indicates failure.
Line 143:
The "t_PXENV_CACHED_INFO" follows the following structure:
 
<sourcesyntaxhighlight lang="asm">
; Note - due to comfort reasons, the author has decided to provide the following snippet
; in Intel (NASM) Assembly. If someone wishes to change it to a more generic format, he is welcome.
Line 153:
.BufferSeg dw 0
.BufferLimit dw 0
</syntaxhighlight>
</source>
 
* '''.Status'''. This should be zero, and returns the status after the function call.
Line 165:
To do a call, put the address of the above structure in ES:DI, put the opcode, 0x0071, in BX, and call the generic call function. A example call to the above function is, as follows:
 
<sourcesyntaxhighlight lang="asm">
mov di, t_PXENV_GET_CACHED
mov bx, GET_CACHED_INFO ; 0x0071.
Line 174:
test ax, ax
jnz .Error
</syntaxhighlight>
</source>
 
Bootph has a little complex structure, and the Specification should be referenced to know more about it. For now, the following is what you may require:
Line 192:
PXENV_TFTP_OPEN, with opcode 0x0020 is required to open a file via TFTP. It takes a t_PXENV_TFTP_OPEN structure as a parameter, which has the following format:
 
<sourcesyntaxhighlight lang="asm">
t_PXENV_TFTP_OPEN:
.Status dw 0
Line 200:
.Port dw 0
.PacketSize dw 0
</syntaxhighlight>
</source>
 
* '''.Status'''. The status word.
Line 220:
The t_PXENV_TFTP_READ has the following structure:
 
<sourcesyntaxhighlight lang="asm">
t_PXENV_TFTP_READ:
.Status dw 0
Line 227:
.BufferOff dw 0
.BufferSeg dw 0
</syntaxhighlight>
</source>
 
* '''.Status'''. This contains the status returned after the function call.
Line 241:
With the above point in mind, the following pseudo code can be used to read a file:
 
<sourcesyntaxhighlight lang="c">
while (bytes_left > 0)
{
Line 255:
bytes_left -= PACKET_SIZE;
}
</syntaxhighlight>
</source>
 
===Closing===
Line 261:
The PXENV_TFTP_CLOSE, with opcode 0x0021, is perhaps the simplest function. It requires a input buffer, with the following format, to be passed to it:
 
<sourcesyntaxhighlight lang="asm">
t_PXENV_TFTP_CLOSE:
.Status dw 0
</syntaxhighlight>
</source>
 
* '''.Status'''. The Status returned after calling the function. The function would most probably ONLY fail if there is no active TFTP connection.