Skip to content

Commit 8b3b4f2

Browse files
committed
[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>
1 parent c1b558f commit 8b3b4f2

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

src/arch/x86/include/pxe.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ struct pxe_api_call {
8585
* @ret exit PXE API call exit code
8686
*/
8787
PXENV_EXIT_t ( * entry ) ( union u_PXENV_ANY *params );
88-
/** Length of parameters */
89-
uint16_t params_len;
9088
/** Opcode */
9189
uint16_t opcode;
9290
};
@@ -112,7 +110,6 @@ struct pxe_api_call {
112110
( union u_PXENV_ANY *params ) ) _entry ) \
113111
: ( ( PXENV_EXIT_t ( * ) \
114112
( union u_PXENV_ANY *params ) ) _entry ) ), \
115-
.params_len = sizeof ( _params_type ), \
116113
.opcode = _opcode, \
117114
}
118115

src/arch/x86/interface/pxe/pxe_call.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ static struct profiler * pxe_api_profiler ( unsigned int opcode ) {
144144
*/
145145
__asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
146146
uint16_t opcode = ix86->regs.bx;
147-
userptr_t uparams = real_to_virt ( ix86->segs.es, ix86->regs.di );
148147
struct profiler *profiler = pxe_api_profiler ( opcode );
148+
union u_PXENV_ANY *params =
149+
real_to_virt ( ix86->segs.es, ix86->regs.di );
149150
struct pxe_api_call *call;
150-
union u_PXENV_ANY params;
151151
PXENV_EXIT_t ret;
152152

153153
/* Start profiling */
@@ -160,17 +160,13 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
160160
call = &pxenv_unknown_api;
161161
}
162162

163-
/* Copy parameter block from caller */
164-
copy_from_user ( &params, uparams, 0, call->params_len );
165-
166163
/* Set default status in case child routine fails to do so */
167-
params.Status = PXENV_STATUS_FAILURE;
164+
params->Status = PXENV_STATUS_FAILURE;
168165

169166
/* Hand off to relevant API routine */
170-
ret = call->entry ( &params );
167+
ret = call->entry ( params );
171168

172-
/* Copy modified parameter block back to caller and return */
173-
copy_to_user ( uparams, 0, &params, call->params_len );
169+
/* Return exit code in %ax */
174170
ix86->regs.ax = ret;
175171

176172
/* Stop profiling, if applicable */
@@ -195,24 +191,20 @@ int pxe_api_call_weak ( struct i386_all_regs *ix86 ) {
195191
* @ret ax PXE exit code
196192
*/
197193
__asmcall void pxe_loader_call ( struct i386_all_regs *ix86 ) {
198-
userptr_t uparams = real_to_virt ( ix86->segs.es, ix86->regs.di );
199-
struct s_UNDI_LOADER params;
194+
struct s_UNDI_LOADER *params =
195+
real_to_virt ( ix86->segs.es, ix86->regs.di );
200196
PXENV_EXIT_t ret;
201197

202-
/* Copy parameter block from caller */
203-
copy_from_user ( &params, uparams, 0, sizeof ( params ) );
204-
205198
/* Fill in ROM segment address */
206199
ppxe.UNDIROMID.segment = ix86->segs.ds;
207200

208201
/* Set default status in case child routine fails to do so */
209-
params.Status = PXENV_STATUS_FAILURE;
202+
params->Status = PXENV_STATUS_FAILURE;
210203

211204
/* Call UNDI loader */
212-
ret = undi_loader ( &params );
205+
ret = undi_loader ( params );
213206

214-
/* Copy modified parameter block back to caller and return */
215-
copy_to_user ( uparams, 0, &params, sizeof ( params ) );
207+
/* Return exit code in %ax */
216208
ix86->regs.ax = ret;
217209
}
218210

0 commit comments

Comments
 (0)