iPXE
Defines | Functions | Variables
pxe_call.h File Reference

PXE API entry point. More...

#include <pxe_api.h>
#include <realmode.h>
#include <rmsetjmp.h>

Go to the source code of this file.

Defines

#define PXE_LOAD_SEGMENT   0
 PXE load address segment.
#define PXE_LOAD_OFFSET   0x7c00
 PXE load address offset.
#define PXE_LOAD_PHYS   ( ( PXE_LOAD_SEGMENT << 4 ) + PXE_LOAD_OFFSET )
 PXE physical load address.
#define ppxe   __use_text16 ( ppxe )
#define pxenv   __use_text16 ( pxenv )

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
struct s_PXE __text16 (ppxe)
 !PXE structure
struct s_PXENV __text16 (pxenv)
 PXENV+ structure.
void pxe_activate (struct net_device *netdev)
 Activate PXE stack.
int pxe_deactivate (void)
 Deactivate PXE stack.
int pxe_start_nbp (void)
 Start PXE NBP at 0000:7c00.
__asmcall void pxe_api_call (struct i386_all_regs *ix86)
 Dispatch PXE API call.
int pxe_api_call_weak (struct i386_all_regs *ix86)
 Dispatch weak PXE API call with PXE stack available.

Variables

rmjmp_buf pxe_restart_nbp
 PXENV_RESTART_TFTP jump buffer.

Detailed Description

PXE API entry point.

Definition in file pxe_call.h.


Define Documentation

#define PXE_LOAD_SEGMENT   0

PXE load address segment.

Definition at line 18 of file pxe_call.h.

#define PXE_LOAD_OFFSET   0x7c00

PXE load address offset.

Definition at line 21 of file pxe_call.h.

#define PXE_LOAD_PHYS   ( ( PXE_LOAD_SEGMENT << 4 ) + PXE_LOAD_OFFSET )

PXE physical load address.

Definition at line 24 of file pxe_call.h.

Referenced by pxenv_restart_tftp().

#define ppxe   __use_text16 ( ppxe )

Definition at line 28 of file pxe_call.h.

Referenced by pxe_init_structures(), pxe_loader_call(), pxe_start_nbp(), and undi_loader().

#define pxenv   __use_text16 ( pxenv )

Definition at line 32 of file pxe_call.h.

Referenced by pxe_activate(), pxe_init_structures(), pxe_start_nbp(), and undi_loader().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
struct s_PXE __text16 ( ppxe  ) [read]

!PXE structure

struct s_PXENV __text16 ( pxenv  ) [read]

PXENV+ structure.

void pxe_activate ( struct net_device netdev)

Activate PXE stack.

Parameters:
netdevNet device to use as PXE net device

Definition at line 276 of file pxe_call.c.

References __asm__(), __from_text16, devices_get(), hook_bios_interrupt(), int_1a_hooked, pxe_int_1a(), pxe_int_1a_vector, pxe_set_netdev(), pxenv, and REAL_CODE.

Referenced by pxe_exec(), pxe_notify(), pxenv_start_undi(), and startpxe_payload().

                                                {
        uint32_t discard_a;
        uint32_t discard_b;
        uint32_t discard_d;

        /* Ensure INT 1A is hooked */
        if ( ! int_1a_hooked ) {
                hook_bios_interrupt ( 0x1a, ( intptr_t ) pxe_int_1a,
                                      &pxe_int_1a_vector );
                devices_get();
                int_1a_hooked = 1;
        }

        /* Set PXE network device */
        pxe_set_netdev ( netdev );

        /* Notify BIOS of installation */
        __asm__ __volatile__ ( REAL_CODE ( "pushw %%cs\n\t"
                                           "popw %%es\n\t"
                                           "int $0x1a\n\t" )
                               : "=a" ( discard_a ), "=b" ( discard_b ),
                                 "=d" ( discard_d )
                               : "0" ( 0x564e ),
                                 "1" ( __from_text16 ( &pxenv ) ) );
}
int pxe_deactivate ( void  )

Deactivate PXE stack.

Return values:
rcReturn status code

Definition at line 307 of file pxe_call.c.

References DBGC, devices_put(), int_1a_hooked, NULL, pxe_int_1a(), pxe_int_1a_vector, pxe_netdev, pxe_set_netdev(), rc, strerror(), and unhook_bios_interrupt().

Referenced by pxe_exec(), pxe_notify(), pxenv_stop_undi(), and stoppxe_exec().

                            {
        int rc;

        /* Clear PXE network device */
        pxe_set_netdev ( NULL );

        /* Ensure INT 1A is unhooked, if possible */
        if ( int_1a_hooked ) {
                if ( ( rc = unhook_bios_interrupt ( 0x1a,
                                                    ( intptr_t ) pxe_int_1a,
                                                    &pxe_int_1a_vector ))!= 0){
                        DBGC ( &pxe_netdev, "PXE could not unhook INT 1A: %s\n",
                               strerror ( rc ) );
                        return rc;
                }
                devices_put();
                int_1a_hooked = 0;
        }

        return 0;
}
int pxe_start_nbp ( void  )

Start PXE NBP at 0000:7c00.

Return values:
rcReturn status code

Definition at line 337 of file pxe_call.c.

References __asm__(), __from_text16, _data16_memsz, _text16_memsz, DBGC, EPXENBP, jmp, net_device::name, ppxe, pxe_netdev, pxenv, REAL_CODE, rm_cs, rm_ds, rmsetjmp, status, and virt_to_phys().

Referenced by pxe_exec().

                           {
        int jmp;
        int discard_b, discard_c, discard_d, discard_D;
        uint16_t status;

        DBGC ( &pxe_netdev, "PXE NBP starting with netdev %s, code %04x:%04zx, "
               "data %04x:%04zx\n", ( pxe_netdev ? pxe_netdev->name : "<none>"),
               rm_cs, _text16_memsz, rm_ds, _data16_memsz );

        /* Allow restarting NBP via PXENV_RESTART_TFTP */
        jmp = rmsetjmp ( pxe_restart_nbp );
        if ( jmp )
                DBGC ( &pxe_netdev, "PXE NBP restarting (%x)\n", jmp );

        /* Far call to PXE NBP */
        __asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
                                           "movw %%cx, %%es\n\t"
                                           "pushw %%es\n\t"
                                           "pushw %%di\n\t"
                                           "sti\n\t"
                                           "lcall $0, $0x7c00\n\t"
                                           "popl %%ebp\n\t" /* discard */
                                           "popl %%ebp\n\t" /* gcc bug */ )
                               : "=a" ( status ), "=b" ( discard_b ),
                                 "=c" ( discard_c ), "=d" ( discard_d ),
                                 "=D" ( discard_D )
                               : "a" ( 0 ), "b" ( __from_text16 ( &pxenv ) ),
                                 "c" ( rm_cs ),
                                 "d" ( virt_to_phys ( &pxenv ) ),
                                 "D" ( __from_text16 ( &ppxe ) )
                               : "esi", "memory" );
        if ( status )
                return -EPXENBP ( status );

        return 0;
}
__asmcall void pxe_api_call ( struct i386_all_regs ix86)

Dispatch PXE API call.

Parameters:
bxPXE opcode
es:diAddress of PXE parameter block
Return values:
axPXE exit code

Definition at line 145 of file pxe_call.c.

References i386_regs::ax, i386_regs::bx, copy_from_user(), copy_to_user(), DBGC, i386_regs::di, pxe_api_call::entry, i386_seg_regs::es, find_pxe_api_call(), opcode, pxe_api_call::params_len, profile_start(), profile_stop(), pxe_api_profiler(), pxe_netdev, PXENV_STATUS_FAILURE, real_to_user(), i386_all_regs::regs, ret, i386_all_regs::segs, and u_PXENV_ANY::Status.

Referenced by pxe_api_call_weak().

                                                           {
        uint16_t opcode = ix86->regs.bx;
        userptr_t uparams = real_to_user ( ix86->segs.es, ix86->regs.di );
        struct profiler *profiler = pxe_api_profiler ( opcode );
        struct pxe_api_call *call;
        union u_PXENV_ANY params;
        PXENV_EXIT_t ret;

        /* Start profiling */
        profile_start ( profiler );

        /* Locate API call */
        call = find_pxe_api_call ( opcode );
        if ( ! call ) {
                DBGC ( &pxe_netdev, "PXENV_UNKNOWN_%04x\n", opcode );
                call = &pxenv_unknown_api;
        }

        /* Copy parameter block from caller */
        copy_from_user ( &params, uparams, 0, call->params_len );

        /* Set default status in case child routine fails to do so */
        params.Status = PXENV_STATUS_FAILURE;

        /* Hand off to relevant API routine */
        ret = call->entry ( &params );

        /* Copy modified parameter block back to caller and return */
        copy_to_user ( uparams, 0, &params, call->params_len );
        ix86->regs.ax = ret;

        /* Stop profiling, if applicable */
        profile_stop ( profiler );
}
int pxe_api_call_weak ( struct i386_all_regs ix86)

Dispatch weak PXE API call with PXE stack available.

Parameters:
ix86Registers for PXE call
Return values:
presentZero (PXE stack present)

Definition at line 186 of file pxe_call.c.

References pxe_api_call().

Referenced by int22().

                                                     {
        pxe_api_call ( ix86 );
        return 0;
}

Variable Documentation

PXENV_RESTART_TFTP jump buffer.

Definition at line 330 of file pxe_call.c.

Referenced by pxenv_restart_tftp().