[pxe] Remove userptr_t from PXE API call dispatcher

Simplify the PXE API call dispatcher code by assuming that the PXE
parameter block is accessible via a direct pointer dereference.  This
avoids the need for the API call dispatcher to know the size of the
parameter block.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-04-24 23:36:32 +01:00
parent c1b558f59e
commit 8b3b4f2454
2 changed files with 10 additions and 21 deletions

View File

@@ -85,8 +85,6 @@ struct pxe_api_call {
* @ret exit PXE API call exit code
*/
PXENV_EXIT_t ( * entry ) ( union u_PXENV_ANY *params );
/** Length of parameters */
uint16_t params_len;
/** Opcode */
uint16_t opcode;
};
@@ -112,7 +110,6 @@ struct pxe_api_call {
( union u_PXENV_ANY *params ) ) _entry ) \
: ( ( PXENV_EXIT_t ( * ) \
( union u_PXENV_ANY *params ) ) _entry ) ), \
.params_len = sizeof ( _params_type ), \
.opcode = _opcode, \
}

View File

@@ -144,10 +144,10 @@ static struct profiler * pxe_api_profiler ( unsigned int opcode ) {
*/
__asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
uint16_t opcode = ix86->regs.bx;
userptr_t uparams = real_to_virt ( ix86->segs.es, ix86->regs.di );
struct profiler *profiler = pxe_api_profiler ( opcode );
union u_PXENV_ANY *params =
real_to_virt ( ix86->segs.es, ix86->regs.di );
struct pxe_api_call *call;
union u_PXENV_ANY params;
PXENV_EXIT_t ret;
/* Start profiling */
@@ -160,17 +160,13 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
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;
params->Status = PXENV_STATUS_FAILURE;
/* Hand off to relevant API routine */
ret = call->entry ( &params );
ret = call->entry ( params );
/* Copy modified parameter block back to caller and return */
copy_to_user ( uparams, 0, &params, call->params_len );
/* Return exit code in %ax */
ix86->regs.ax = ret;
/* Stop profiling, if applicable */
@@ -195,24 +191,20 @@ int pxe_api_call_weak ( struct i386_all_regs *ix86 ) {
* @ret ax PXE exit code
*/
__asmcall void pxe_loader_call ( struct i386_all_regs *ix86 ) {
userptr_t uparams = real_to_virt ( ix86->segs.es, ix86->regs.di );
struct s_UNDI_LOADER params;
struct s_UNDI_LOADER *params =
real_to_virt ( ix86->segs.es, ix86->regs.di );
PXENV_EXIT_t ret;
/* Copy parameter block from caller */
copy_from_user ( &params, uparams, 0, sizeof ( params ) );
/* Fill in ROM segment address */
ppxe.UNDIROMID.segment = ix86->segs.ds;
/* Set default status in case child routine fails to do so */
params.Status = PXENV_STATUS_FAILURE;
params->Status = PXENV_STATUS_FAILURE;
/* Call UNDI loader */
ret = undi_loader ( &params );
ret = undi_loader ( params );
/* Copy modified parameter block back to caller and return */
copy_to_user ( uparams, 0, &params, sizeof ( params ) );
/* Return exit code in %ax */
ix86->regs.ax = ret;
}