2006-08-02 23:08:10 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
* License, or any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-07-20 19:55:45 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
* 02110-1301, USA.
|
2015-03-02 13:29:46 +00:00
|
|
|
*
|
|
|
|
|
* You can also choose to distribute this program under the terms of
|
|
|
|
|
* the Unmodified Binary Distribution Licence (as given in the file
|
|
|
|
|
* COPYING.UBDL), provided that you have satisfied its requirements.
|
2006-08-02 23:08:10 +00:00
|
|
|
*/
|
|
|
|
|
|
2015-03-02 13:29:46 +00:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
2009-05-01 15:41:06 +01:00
|
|
|
|
2010-04-19 20:16:01 +01:00
|
|
|
#include <ipxe/uaccess.h>
|
|
|
|
|
#include <ipxe/init.h>
|
2014-05-03 00:52:43 +01:00
|
|
|
#include <ipxe/profile.h>
|
2015-09-15 13:43:35 +01:00
|
|
|
#include <ipxe/netdevice.h>
|
2016-02-16 15:48:03 +00:00
|
|
|
#include <rmsetjmp.h>
|
2006-08-02 23:08:10 +00:00
|
|
|
#include <registers.h>
|
2006-08-08 20:43:33 +00:00
|
|
|
#include <biosint.h>
|
2006-08-02 23:08:10 +00:00
|
|
|
#include <pxe.h>
|
2007-01-13 17:23:44 +00:00
|
|
|
#include <pxe_call.h>
|
2006-08-02 23:08:10 +00:00
|
|
|
|
|
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* PXE API entry point
|
|
|
|
|
*/
|
|
|
|
|
|
2013-04-29 19:58:25 +01:00
|
|
|
/* Disambiguate the various error causes */
|
|
|
|
|
#define EINFO_EPXENBP \
|
|
|
|
|
__einfo_uniqify ( EINFO_EPLATFORM, 0x01, \
|
|
|
|
|
"External PXE NBP error" )
|
|
|
|
|
#define EPXENBP( status ) EPLATFORM ( EINFO_EPXENBP, status )
|
|
|
|
|
|
2006-08-08 20:43:33 +00:00
|
|
|
/** Vector for chaining INT 1A */
|
|
|
|
|
extern struct segoff __text16 ( pxe_int_1a_vector );
|
|
|
|
|
#define pxe_int_1a_vector __use_text16 ( pxe_int_1a_vector )
|
|
|
|
|
|
|
|
|
|
/** INT 1A handler */
|
|
|
|
|
extern void pxe_int_1a ( void );
|
|
|
|
|
|
2009-06-28 20:08:58 +01:00
|
|
|
/** INT 1A hooked flag */
|
|
|
|
|
static int int_1a_hooked = 0;
|
|
|
|
|
|
2016-01-11 16:21:08 +00:00
|
|
|
/** Real-mode code segment size */
|
[build] Formalise mechanism for accessing absolute symbols
In a position-dependent executable, where all addresses are fixed
at link time, we can use the standard technique as documented by
GNU ld to get the value of an absolute symbol, e.g.:
extern char _my_symbol[];
printf ( "Absolute symbol value is %x\n", ( ( int ) _my_symbol ) );
This technique may not work in a position-independent executable.
When dynamic relocations are applied, the runtime addresses will no
longer be equal to the link-time addresses. If the code to obtain the
address of _my_symbol uses PC-relative addressing, then it will
calculate the runtime "address" of the absolute symbol, which will no
longer be equal the the link-time "address" (i.e. the correct value)
of the absolute symbol.
Define macros ABS_SYMBOL(), ABS_VALUE_INIT(), and ABS_VALUE() that
provide access to the correct values of absolute symbols even in
position-independent code, and use these macros wherever absolute
symbols are accessed.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2025-05-09 14:25:59 +01:00
|
|
|
extern size_t ABS_SYMBOL ( _text16_memsz );
|
|
|
|
|
#define _text16_memsz ABS_VALUE ( _text16_memsz )
|
2016-01-11 16:21:08 +00:00
|
|
|
|
|
|
|
|
/** Real-mode data segment size */
|
[build] Formalise mechanism for accessing absolute symbols
In a position-dependent executable, where all addresses are fixed
at link time, we can use the standard technique as documented by
GNU ld to get the value of an absolute symbol, e.g.:
extern char _my_symbol[];
printf ( "Absolute symbol value is %x\n", ( ( int ) _my_symbol ) );
This technique may not work in a position-independent executable.
When dynamic relocations are applied, the runtime addresses will no
longer be equal to the link-time addresses. If the code to obtain the
address of _my_symbol uses PC-relative addressing, then it will
calculate the runtime "address" of the absolute symbol, which will no
longer be equal the the link-time "address" (i.e. the correct value)
of the absolute symbol.
Define macros ABS_SYMBOL(), ABS_VALUE_INIT(), and ABS_VALUE() that
provide access to the correct values of absolute symbols even in
position-independent code, and use these macros wherever absolute
symbols are accessed.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2025-05-09 14:25:59 +01:00
|
|
|
extern size_t ABS_SYMBOL (_data16_memsz );
|
|
|
|
|
#define _data16_memsz ABS_VALUE ( _data16_memsz )
|
2016-01-11 16:21:08 +00:00
|
|
|
|
2014-05-03 00:52:43 +01:00
|
|
|
/** PXENV_UNDI_TRANSMIT API call profiler */
|
|
|
|
|
static struct profiler pxe_api_tx_profiler __profiler =
|
|
|
|
|
{ .name = "pxeapi.tx" };
|
|
|
|
|
|
|
|
|
|
/** PXENV_UNDI_ISR API call profiler */
|
|
|
|
|
static struct profiler pxe_api_isr_profiler __profiler =
|
|
|
|
|
{ .name = "pxeapi.isr" };
|
|
|
|
|
|
|
|
|
|
/** PXE unknown API call profiler
|
|
|
|
|
*
|
|
|
|
|
* This profiler can be used to measure the overhead of a dummy PXE
|
|
|
|
|
* API call.
|
|
|
|
|
*/
|
|
|
|
|
static struct profiler pxe_api_unknown_profiler __profiler =
|
|
|
|
|
{ .name = "pxeapi.unknown" };
|
|
|
|
|
|
|
|
|
|
/** Miscellaneous PXE API call profiler */
|
|
|
|
|
static struct profiler pxe_api_misc_profiler __profiler =
|
|
|
|
|
{ .name = "pxeapi.misc" };
|
|
|
|
|
|
2006-08-02 23:08:10 +00:00
|
|
|
/**
|
|
|
|
|
* Handle an unknown PXE API call
|
|
|
|
|
*
|
|
|
|
|
* @v pxenv_unknown Pointer to a struct s_PXENV_UNKNOWN
|
|
|
|
|
* @ret #PXENV_EXIT_FAILURE Always
|
|
|
|
|
* @err #PXENV_STATUS_UNSUPPORTED Always
|
|
|
|
|
*/
|
|
|
|
|
static PXENV_EXIT_t pxenv_unknown ( struct s_PXENV_UNKNOWN *pxenv_unknown ) {
|
|
|
|
|
pxenv_unknown->Status = PXENV_STATUS_UNSUPPORTED;
|
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-11 01:35:49 +00:00
|
|
|
/** Unknown PXE API call list */
|
|
|
|
|
struct pxe_api_call pxenv_unknown_api __pxe_api_call =
|
|
|
|
|
PXE_API_CALL ( PXENV_UNKNOWN, pxenv_unknown, struct s_PXENV_UNKNOWN );
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Locate PXE API call
|
|
|
|
|
*
|
|
|
|
|
* @v opcode Opcode
|
|
|
|
|
* @ret call PXE API call, or NULL
|
|
|
|
|
*/
|
|
|
|
|
static struct pxe_api_call * find_pxe_api_call ( uint16_t opcode ) {
|
|
|
|
|
struct pxe_api_call *call;
|
|
|
|
|
|
|
|
|
|
for_each_table_entry ( call, PXE_API_CALLS ) {
|
|
|
|
|
if ( call->opcode == opcode )
|
|
|
|
|
return call;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-03 00:52:43 +01:00
|
|
|
/**
|
|
|
|
|
* Determine applicable profiler (for debugging)
|
|
|
|
|
*
|
|
|
|
|
* @v opcode PXE opcode
|
|
|
|
|
* @ret profiler Profiler
|
|
|
|
|
*/
|
|
|
|
|
static struct profiler * pxe_api_profiler ( unsigned int opcode ) {
|
|
|
|
|
|
|
|
|
|
/* Determine applicable profiler */
|
|
|
|
|
switch ( opcode ) {
|
|
|
|
|
case PXENV_UNDI_TRANSMIT:
|
|
|
|
|
return &pxe_api_tx_profiler;
|
|
|
|
|
case PXENV_UNDI_ISR:
|
|
|
|
|
return &pxe_api_isr_profiler;
|
|
|
|
|
case PXENV_UNKNOWN:
|
|
|
|
|
return &pxe_api_unknown_profiler;
|
|
|
|
|
default:
|
|
|
|
|
return &pxe_api_misc_profiler;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-02 23:08:10 +00:00
|
|
|
/**
|
|
|
|
|
* Dispatch PXE API call
|
|
|
|
|
*
|
|
|
|
|
* @v bx PXE opcode
|
|
|
|
|
* @v es:di Address of PXE parameter block
|
|
|
|
|
* @ret ax PXE exit code
|
|
|
|
|
*/
|
2008-11-18 16:18:32 -08:00
|
|
|
__asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
|
2011-12-11 01:35:49 +00:00
|
|
|
uint16_t opcode = ix86->regs.bx;
|
2014-05-03 00:52:43 +01:00
|
|
|
struct profiler *profiler = pxe_api_profiler ( opcode );
|
2025-04-24 23:36:32 +01:00
|
|
|
union u_PXENV_ANY *params =
|
|
|
|
|
real_to_virt ( ix86->segs.es, ix86->regs.di );
|
2011-12-11 01:35:49 +00:00
|
|
|
struct pxe_api_call *call;
|
2006-08-02 23:08:10 +00:00
|
|
|
PXENV_EXIT_t ret;
|
|
|
|
|
|
2014-05-03 00:52:43 +01:00
|
|
|
/* Start profiling */
|
|
|
|
|
profile_start ( profiler );
|
|
|
|
|
|
2011-12-11 01:35:49 +00:00
|
|
|
/* Locate API call */
|
|
|
|
|
call = find_pxe_api_call ( opcode );
|
|
|
|
|
if ( ! call ) {
|
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNKNOWN_%04x\n", opcode );
|
|
|
|
|
call = &pxenv_unknown_api;
|
2006-08-02 23:08:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set default status in case child routine fails to do so */
|
2025-04-24 23:36:32 +01:00
|
|
|
params->Status = PXENV_STATUS_FAILURE;
|
2006-08-02 23:08:10 +00:00
|
|
|
|
|
|
|
|
/* Hand off to relevant API routine */
|
2025-04-24 23:36:32 +01:00
|
|
|
ret = call->entry ( params );
|
2011-12-11 01:35:49 +00:00
|
|
|
|
2025-04-24 23:36:32 +01:00
|
|
|
/* Return exit code in %ax */
|
2006-08-02 23:08:10 +00:00
|
|
|
ix86->regs.ax = ret;
|
2014-05-03 00:52:43 +01:00
|
|
|
|
|
|
|
|
/* Stop profiling, if applicable */
|
|
|
|
|
profile_stop ( profiler );
|
2006-08-02 23:08:10 +00:00
|
|
|
}
|
2006-08-08 20:43:33 +00:00
|
|
|
|
2009-10-06 19:15:06 -04:00
|
|
|
/**
|
|
|
|
|
* Dispatch weak PXE API call with PXE stack available
|
|
|
|
|
*
|
|
|
|
|
* @v ix86 Registers for PXE call
|
|
|
|
|
* @ret present Zero (PXE stack present)
|
|
|
|
|
*/
|
2011-12-11 01:35:49 +00:00
|
|
|
int pxe_api_call_weak ( struct i386_all_regs *ix86 ) {
|
2009-10-06 19:15:06 -04:00
|
|
|
pxe_api_call ( ix86 );
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-03 23:41:35 +01:00
|
|
|
/**
|
|
|
|
|
* Dispatch PXE loader call
|
|
|
|
|
*
|
|
|
|
|
* @v es:di Address of PXE parameter block
|
|
|
|
|
* @ret ax PXE exit code
|
|
|
|
|
*/
|
2008-11-18 16:18:32 -08:00
|
|
|
__asmcall void pxe_loader_call ( struct i386_all_regs *ix86 ) {
|
2025-04-24 23:36:32 +01:00
|
|
|
struct s_UNDI_LOADER *params =
|
|
|
|
|
real_to_virt ( ix86->segs.es, ix86->regs.di );
|
2007-07-03 23:41:35 +01:00
|
|
|
PXENV_EXIT_t ret;
|
|
|
|
|
|
2008-08-27 23:45:59 +01:00
|
|
|
/* Fill in ROM segment address */
|
|
|
|
|
ppxe.UNDIROMID.segment = ix86->segs.ds;
|
|
|
|
|
|
2007-07-03 23:41:35 +01:00
|
|
|
/* Set default status in case child routine fails to do so */
|
2025-04-24 23:36:32 +01:00
|
|
|
params->Status = PXENV_STATUS_FAILURE;
|
2007-07-03 23:41:35 +01:00
|
|
|
|
|
|
|
|
/* Call UNDI loader */
|
2025-04-24 23:36:32 +01:00
|
|
|
ret = undi_loader ( params );
|
2007-07-03 23:41:35 +01:00
|
|
|
|
2025-04-24 23:36:32 +01:00
|
|
|
/* Return exit code in %ax */
|
2007-07-03 23:41:35 +01:00
|
|
|
ix86->regs.ax = ret;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-08 20:43:33 +00:00
|
|
|
/**
|
|
|
|
|
* Calculate byte checksum as used by PXE
|
|
|
|
|
*
|
|
|
|
|
* @v data Data
|
|
|
|
|
* @v size Length of data
|
|
|
|
|
* @ret sum Checksum
|
|
|
|
|
*/
|
|
|
|
|
static uint8_t pxe_checksum ( void *data, size_t size ) {
|
|
|
|
|
uint8_t *bytes = data;
|
|
|
|
|
uint8_t sum = 0;
|
|
|
|
|
|
|
|
|
|
while ( size-- ) {
|
|
|
|
|
sum += *bytes++;
|
|
|
|
|
}
|
|
|
|
|
return sum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2007-01-14 02:20:10 +00:00
|
|
|
* Initialise !PXE and PXENV+ structures
|
2006-08-08 20:43:33 +00:00
|
|
|
*
|
|
|
|
|
*/
|
2009-06-28 19:40:16 +01:00
|
|
|
static void pxe_init_structures ( void ) {
|
2006-08-08 20:43:33 +00:00
|
|
|
uint32_t rm_cs_phys = ( rm_cs << 4 );
|
|
|
|
|
uint32_t rm_ds_phys = ( rm_ds << 4 );
|
|
|
|
|
|
|
|
|
|
/* Fill in missing segment fields */
|
2007-01-14 02:20:10 +00:00
|
|
|
ppxe.EntryPointSP.segment = rm_cs;
|
|
|
|
|
ppxe.EntryPointESP.segment = rm_cs;
|
|
|
|
|
ppxe.Stack.segment_address = rm_ds;
|
|
|
|
|
ppxe.Stack.Physical_address = rm_ds_phys;
|
|
|
|
|
ppxe.UNDIData.segment_address = rm_ds;
|
|
|
|
|
ppxe.UNDIData.Physical_address = rm_ds_phys;
|
|
|
|
|
ppxe.UNDICode.segment_address = rm_cs;
|
|
|
|
|
ppxe.UNDICode.Physical_address = rm_cs_phys;
|
|
|
|
|
ppxe.UNDICodeWrite.segment_address = rm_cs;
|
|
|
|
|
ppxe.UNDICodeWrite.Physical_address = rm_cs_phys;
|
2006-08-08 20:43:33 +00:00
|
|
|
pxenv.RMEntry.segment = rm_cs;
|
|
|
|
|
pxenv.StackSeg = rm_ds;
|
|
|
|
|
pxenv.UNDIDataSeg = rm_ds;
|
|
|
|
|
pxenv.UNDICodeSeg = rm_cs;
|
|
|
|
|
pxenv.PXEPtr.segment = rm_cs;
|
|
|
|
|
|
|
|
|
|
/* Update checksums */
|
2007-01-14 02:20:10 +00:00
|
|
|
ppxe.StructCksum -= pxe_checksum ( &ppxe, sizeof ( ppxe ) );
|
2006-08-08 20:43:33 +00:00
|
|
|
pxenv.Checksum -= pxe_checksum ( &pxenv, sizeof ( pxenv ) );
|
|
|
|
|
}
|
2007-06-30 14:56:35 +01:00
|
|
|
|
2009-06-28 19:40:16 +01:00
|
|
|
/** PXE structure initialiser */
|
|
|
|
|
struct init_fn pxe_init_fn __init_fn ( INIT_NORMAL ) = {
|
|
|
|
|
.initialise = pxe_init_structures,
|
|
|
|
|
};
|
|
|
|
|
|
2009-06-28 20:08:58 +01:00
|
|
|
/**
|
|
|
|
|
* Activate PXE stack
|
|
|
|
|
*
|
|
|
|
|
* @v netdev Net device to use as PXE net device
|
|
|
|
|
*/
|
|
|
|
|
void pxe_activate ( struct net_device *netdev ) {
|
[pxe] Invoke INT 1a,564e when PXE stack is activated
Invoke INT 1a,564e whenever a PXE stack is activated, passing the
address of the PXENV+ structure in %es:%bx. This is designed to allow
a BIOS to be notified when a PXE stack has been installed, providing
an opportunity for start-of-day commands such as setting the MAC
address according to a policy chosen by the BIOS.
PXE defines INT 1a,5650 as a means of locating the PXENV+ structure:
this call returns %ax=0x564e and the address of the PXENV+ structure
in %es:%bx. We choose INT 1a,564e as a fairly natural notification
call, using the parameters as would be returned by INT 1a,5650.
The full calling convention (documented as per section 3.1 of the PXE
specification) is:
INT 1a,564e - PXE installation notification
Enter:
%ax = 0x564e
%es = 16-bit segment address of the PXENV+ structure
%bx = 16-bit offset of the PXENV+ structure
Exit:
%edx may be trashed (as is the case for INT 1a,5650)
All other register contents must be preserved
CF is cleared
IF is preserved
All other flags are undefined
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-15 13:20:17 +01:00
|
|
|
uint32_t discard_a;
|
|
|
|
|
uint32_t discard_b;
|
|
|
|
|
uint32_t discard_d;
|
2009-06-28 20:08:58 +01:00
|
|
|
|
|
|
|
|
/* Ensure INT 1A is hooked */
|
|
|
|
|
if ( ! int_1a_hooked ) {
|
2016-02-16 16:24:30 +00:00
|
|
|
hook_bios_interrupt ( 0x1a, ( intptr_t ) pxe_int_1a,
|
2009-06-28 20:08:58 +01:00
|
|
|
&pxe_int_1a_vector );
|
2011-01-27 20:35:48 +00:00
|
|
|
devices_get();
|
2009-06-28 20:08:58 +01:00
|
|
|
int_1a_hooked = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set PXE network device */
|
|
|
|
|
pxe_set_netdev ( netdev );
|
[pxe] Invoke INT 1a,564e when PXE stack is activated
Invoke INT 1a,564e whenever a PXE stack is activated, passing the
address of the PXENV+ structure in %es:%bx. This is designed to allow
a BIOS to be notified when a PXE stack has been installed, providing
an opportunity for start-of-day commands such as setting the MAC
address according to a policy chosen by the BIOS.
PXE defines INT 1a,5650 as a means of locating the PXENV+ structure:
this call returns %ax=0x564e and the address of the PXENV+ structure
in %es:%bx. We choose INT 1a,564e as a fairly natural notification
call, using the parameters as would be returned by INT 1a,5650.
The full calling convention (documented as per section 3.1 of the PXE
specification) is:
INT 1a,564e - PXE installation notification
Enter:
%ax = 0x564e
%es = 16-bit segment address of the PXENV+ structure
%bx = 16-bit offset of the PXENV+ structure
Exit:
%edx may be trashed (as is the case for INT 1a,5650)
All other register contents must be preserved
CF is cleared
IF is preserved
All other flags are undefined
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-15 13:20:17 +01:00
|
|
|
|
|
|
|
|
/* 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 ) ) );
|
2009-06-28 20:08:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deactivate PXE stack
|
|
|
|
|
*
|
|
|
|
|
* @ret rc Return status code
|
|
|
|
|
*/
|
|
|
|
|
int pxe_deactivate ( void ) {
|
|
|
|
|
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,
|
2016-02-16 16:24:30 +00:00
|
|
|
( intptr_t ) pxe_int_1a,
|
2009-06-28 20:08:58 +01:00
|
|
|
&pxe_int_1a_vector ))!= 0){
|
2016-01-11 16:20:05 +00:00
|
|
|
DBGC ( &pxe_netdev, "PXE could not unhook INT 1A: %s\n",
|
|
|
|
|
strerror ( rc ) );
|
2009-06-28 20:08:58 +01:00
|
|
|
return rc;
|
|
|
|
|
}
|
2011-01-27 20:35:48 +00:00
|
|
|
devices_put();
|
2009-06-28 20:08:58 +01:00
|
|
|
int_1a_hooked = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-21 03:10:03 +01:00
|
|
|
/** Jump buffer for PXENV_RESTART_TFTP */
|
|
|
|
|
rmjmp_buf pxe_restart_nbp;
|
|
|
|
|
|
2007-06-30 14:56:35 +01:00
|
|
|
/**
|
|
|
|
|
* Start PXE NBP at 0000:7c00
|
|
|
|
|
*
|
|
|
|
|
* @ret rc Return status code
|
|
|
|
|
*/
|
|
|
|
|
int pxe_start_nbp ( void ) {
|
2010-05-21 03:10:03 +01:00
|
|
|
int jmp;
|
2009-02-23 08:43:27 +00:00
|
|
|
int discard_b, discard_c, discard_d, discard_D;
|
2013-04-29 19:58:25 +01:00
|
|
|
uint16_t status;
|
2007-06-30 14:56:35 +01:00
|
|
|
|
2016-02-16 16:28:12 +00:00
|
|
|
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 );
|
2016-01-11 16:21:08 +00:00
|
|
|
|
2010-05-21 03:10:03 +01:00
|
|
|
/* Allow restarting NBP via PXENV_RESTART_TFTP */
|
|
|
|
|
jmp = rmsetjmp ( pxe_restart_nbp );
|
|
|
|
|
if ( jmp )
|
2016-01-11 16:20:05 +00:00
|
|
|
DBGC ( &pxe_netdev, "PXE NBP restarting (%x)\n", jmp );
|
2010-05-21 03:10:03 +01:00
|
|
|
|
2007-06-30 14:56:35 +01:00
|
|
|
/* Far call to PXE NBP */
|
2013-06-07 13:46:27 +01:00
|
|
|
__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
|
|
|
|
|
"movw %%cx, %%es\n\t"
|
2009-02-23 08:43:27 +00:00
|
|
|
"pushw %%es\n\t"
|
|
|
|
|
"pushw %%di\n\t"
|
2008-09-24 21:23:50 +01:00
|
|
|
"sti\n\t"
|
2007-06-30 14:56:35 +01:00
|
|
|
"lcall $0, $0x7c00\n\t"
|
2013-06-07 13:46:27 +01:00
|
|
|
"popl %%ebp\n\t" /* discard */
|
|
|
|
|
"popl %%ebp\n\t" /* gcc bug */ )
|
2013-04-29 19:58:25 +01:00
|
|
|
: "=a" ( status ), "=b" ( discard_b ),
|
2009-02-23 08:43:27 +00:00
|
|
|
"=c" ( discard_c ), "=d" ( discard_d ),
|
|
|
|
|
"=D" ( discard_D )
|
|
|
|
|
: "a" ( 0 ), "b" ( __from_text16 ( &pxenv ) ),
|
2009-02-17 22:28:46 -08:00
|
|
|
"c" ( rm_cs ),
|
2009-02-23 08:43:27 +00:00
|
|
|
"d" ( virt_to_phys ( &pxenv ) ),
|
|
|
|
|
"D" ( __from_text16 ( &ppxe ) )
|
2013-06-07 13:46:27 +01:00
|
|
|
: "esi", "memory" );
|
2013-04-29 19:58:25 +01:00
|
|
|
if ( status )
|
|
|
|
|
return -EPXENBP ( status );
|
2007-06-30 14:56:35 +01:00
|
|
|
|
2013-04-29 19:58:25 +01:00
|
|
|
return 0;
|
2007-06-30 14:56:35 +01:00
|
|
|
}
|
2011-12-11 01:35:49 +00:00
|
|
|
|
2015-09-15 13:43:35 +01:00
|
|
|
/**
|
|
|
|
|
* Notify BIOS of existence of network device
|
|
|
|
|
*
|
|
|
|
|
* @v netdev Network device
|
2023-09-13 16:29:59 +01:00
|
|
|
* @v priv Private data
|
2015-09-15 13:43:35 +01:00
|
|
|
* @ret rc Return status code
|
|
|
|
|
*/
|
2023-09-13 16:29:59 +01:00
|
|
|
static int pxe_notify ( struct net_device *netdev, void *priv __unused ) {
|
2015-09-15 13:43:35 +01:00
|
|
|
|
|
|
|
|
/* Do nothing if we already have a network device */
|
|
|
|
|
if ( pxe_netdev )
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* Activate (and deactivate) PXE stack to notify BIOS */
|
|
|
|
|
pxe_activate ( netdev );
|
|
|
|
|
pxe_deactivate();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** PXE BIOS notification driver */
|
|
|
|
|
struct net_driver pxe_driver __net_driver = {
|
|
|
|
|
.name = "PXE",
|
|
|
|
|
.probe = pxe_notify,
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-04 18:48:19 +00:00
|
|
|
REQUIRING_SYMBOL ( pxe_api_call );
|
2011-12-11 01:35:49 +00:00
|
|
|
REQUIRE_OBJECT ( pxe_preboot );
|
|
|
|
|
REQUIRE_OBJECT ( pxe_undi );
|
|
|
|
|
REQUIRE_OBJECT ( pxe_udp );
|
|
|
|
|
REQUIRE_OBJECT ( pxe_tftp );
|
|
|
|
|
REQUIRE_OBJECT ( pxe_file );
|