PXENV_TFTP_READ_FILE
[PXE TFTP API]

TFTP/MTFTP READ FILE. More...


Data Structures

struct  s_PXENV_TFTP_READ_FILE
 Parameter block for pxenv_tftp_read_file(). More...

Defines

#define PXENV_TFTP_READ_FILE   0x0023
 PXE API function code for pxenv_tftp_read_file().

Typedefs

typedef struct
s_PXENV_TFTP_READ_FILE 
PXENV_TFTP_READ_FILE_t

Functions

PXENV_EXIT_t pxenv_tftp_read_file (struct s_PXENV_TFTP_READ_FILE *tftp_read_file)
 TFTP/MTFTP read file.


Detailed Description

TFTP/MTFTP READ FILE.

Define Documentation

#define PXENV_TFTP_READ_FILE   0x0023

PXE API function code for pxenv_tftp_read_file().

Definition at line 660 of file pxe_api.h.

Referenced by pxe_api_call().


Typedef Documentation

Definition at line 691 of file pxe_api.h.


Function Documentation

PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE tftp_read_file  ) 

TFTP/MTFTP read file.

Parameters:
tftp_read_file Pointer to a struct s_PXENV_TFTP_READ_FILE
s_PXENV_TFTP_READ_FILE::FileName File name
s_PXENV_TFTP_READ_FILE::BufferSize Size of the receive buffer
s_PXENV_TFTP_READ_FILE::Buffer Address of the receive buffer
s_PXENV_TFTP_READ_FILE::ServerIPAddress TFTP server IP address
s_PXENV_TFTP_READ_FILE::GatewayIPAddress Relay agent IP address
s_PXENV_TFTP_READ_FILE::McastIPAddress File's multicast IP address
s_PXENV_TFTP_READ_FILE::TFTPClntPort Client multicast UDP port
s_PXENV_TFTP_READ_FILE::TFTPSrvPort Server multicast UDP port
s_PXENV_TFTP_READ_FILE::TFTPOpenTimeOut Time to wait for first packet
s_PXENV_TFTP_READ_FILE::TFTPReopenDelay MTFTP inactivity timeout
Return values:
PXENV_EXIT_SUCCESS File downloaded successfully
PXENV_EXIT_FAILURE File not downloaded
s_PXENV_TFTP_READ_FILE::Status PXE status code
s_PXENV_TFTP_READ_FILE::BufferSize Length of downloaded file
Downloads an entire file via either TFTP or MTFTP into the buffer pointed to by s_PXENV_TFTP_READ_FILE::Buffer.

The PXE specification does not make it clear how the caller requests that MTFTP be used rather than TFTP (or vice versa). One reasonable guess is that setting s_PXENV_TFTP_READ_FILE::McastIPAddress to 0.0.0.0 would cause TFTP to be used instead of MTFTP, though it is conceivable that some PXE stacks would interpret that as "use the DHCP-provided multicast IP address" instead. Some PXE stacks will not implement MTFTP at all, and will always use TFTP.

It is not specified whether or not s_PXENV_TFTP_READ_FILE::TFTPSrvPort will be used as the TFTP server port for TFTP (rather than MTFTP) downloads. Callers should assume that the only way to access a TFTP server on a non-standard port is to use pxenv_tftp_open() and pxenv_tftp_read().

If s_PXENV_TFTP_READ_FILE::GatewayIPAddress is 0.0.0.0, normal IP routing will take place. See the relevant implementation note for more details.

It is interesting to note that s_PXENV_TFTP_READ_FILE::Buffer is an ADDR32_t type, i.e. nominally a flat physical address. Some PXE NBPs (e.g. NTLDR) are known to call pxenv_tftp_read_file() in real mode with s_PXENV_TFTP_READ_FILE::Buffer set to an address above 1MB. This means that PXE stacks must be prepared to write to areas outside base memory. Exactly how this is to be achieved is not specified, though using INT 15,87 is as close to a standard method as any, and should probably be used. Switching to protected-mode in order to access high memory will fail if pxenv_tftp_read_file() is called in V86 mode; it is reasonably to expect that a V86 monitor would intercept the relatively well-defined INT 15,87 if it wants the PXE stack to be able to write to high memory.

Things get even more interesting if pxenv_tftp_read_file() is called in protected mode, because there is then absolutely no way for the PXE stack to write to an absolute physical address. You can't even get around the problem by creating a special "access everything" segment in the s_PXE data structure, because the SEGDESC_t descriptors are limited to 64kB in size.

Previous versions of the PXE specification (e.g. WfM 1.1a) provide a separate API call, pxenv_tftp_read_file_pmode(), specifically to work around this problem. The s_PXENV_TFTP_READ_FILE_PMODE parameter block splits s_PXENV_TFTP_READ_FILE::Buffer into s_PXENV_TFTP_READ_FILE_PMODE::BufferSelector and s_PXENV_TFTP_READ_FILE_PMODE::BufferOffset, i.e. it provides a protected-mode segment:offset address for the data buffer. This API call is no longer present in version 2.1 of the PXE specification.

Etherboot makes the assumption that s_PXENV_TFTP_READ_FILE::Buffer is an offset relative to the caller's data segment, when pxenv_tftp_read_file() is called in protected mode.

On x86, you must set the s_PXE::StatusCallout field to a nonzero value before calling this function in protected mode. You cannot call this function with a 32-bit stack segment. (See the relevant implementation note for more details.)

Definition at line 471 of file pxe_tftp.c.

References pxe_tftp_connection::buffer, s_PXENV_TFTP_READ_FILE::Buffer, s_PXENV_TFTP_READ_FILE::BufferSize, DBG, EINPROGRESS, s_PXENV_TFTP_READ_FILE::FileName, pxe_tftp_connection::max_offset, phys_to_user(), pxe_tftp_close(), pxe_tftp_open(), PXENV_EXIT_FAILURE, PXENV_EXIT_SUCCESS, PXENV_STATUS, pxe_tftp_connection::rc, s_PXENV_TFTP_READ_FILE::ServerIPAddress, pxe_tftp_connection::size, s_PXENV_TFTP_READ_FILE::Status, step(), and UNULL.

Referenced by pxe_api_call(), and pxenv_restart_tftp().

00472                                                       {
00473         int rc;
00474 
00475         DBG ( "PXENV_TFTP_READ_FILE to %08x+%x", tftp_read_file->Buffer,
00476               tftp_read_file->BufferSize );
00477 
00478         /* Open TFTP file */
00479         if ( ( rc = pxe_tftp_open ( tftp_read_file->ServerIPAddress, 0,
00480                                     tftp_read_file->FileName, 0, 0 ) ) != 0 ) {
00481                 tftp_read_file->Status = PXENV_STATUS ( rc );
00482                 return PXENV_EXIT_FAILURE;
00483         }
00484 
00485         /* Read entire file */
00486         pxe_tftp.buffer = phys_to_user ( tftp_read_file->Buffer );
00487         pxe_tftp.size = tftp_read_file->BufferSize;
00488         while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS )
00489                 step();
00490         pxe_tftp.buffer = UNULL;
00491         tftp_read_file->BufferSize = pxe_tftp.max_offset;
00492 
00493         /* Close TFTP file */
00494         pxe_tftp_close ( rc );
00495 
00496         tftp_read_file->Status = PXENV_STATUS ( rc );
00497         return ( rc ? PXENV_EXIT_FAILURE : PXENV_EXIT_SUCCESS );
00498 }


Generated on Tue Apr 6 20:01:59 2010 for gPXE by  doxygen 1.5.7.1