|
@@ -16,8 +16,6 @@
|
16
|
16
|
|
17
|
17
|
/*
|
18
|
18
|
* Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
|
19
|
|
- * Portions (C) 2010 Shao Miller <shao.miller@yrdsb.edu.on.ca>.
|
20
|
|
- * [PXE exit hook logic]
|
21
|
19
|
*
|
22
|
20
|
* This program is free software; you can redistribute it and/or
|
23
|
21
|
* modify it under the terms of the GNU General Public License as
|
|
@@ -234,9 +232,6 @@ static PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec ) {
|
234
|
232
|
return PXENV_EXIT_SUCCESS;
|
235
|
233
|
}
|
236
|
234
|
|
237
|
|
-segoff_t __data16 ( pxe_exit_hook ) = { 0, 0 };
|
238
|
|
-#define pxe_exit_hook __use_data16 ( pxe_exit_hook )
|
239
|
|
-
|
240
|
235
|
/**
|
241
|
236
|
* FILE API CHECK
|
242
|
237
|
*
|
|
@@ -253,57 +248,40 @@ segoff_t __data16 ( pxe_exit_hook ) = { 0, 0 };
|
253
|
248
|
*/
|
254
|
249
|
static PXENV_EXIT_t
|
255
|
250
|
pxenv_file_api_check ( struct s_PXENV_FILE_API_CHECK *file_api_check ) {
|
|
251
|
+ struct pxe_api_call *call;
|
|
252
|
+ unsigned int mask = 0;
|
|
253
|
+ unsigned int offset;
|
|
254
|
+
|
256
|
255
|
DBG ( "PXENV_FILE_API_CHECK" );
|
257
|
256
|
|
|
257
|
+ /* Check for magic value */
|
258
|
258
|
if ( file_api_check->Magic != 0x91d447b2 ) {
|
259
|
259
|
file_api_check->Status = PXENV_STATUS_BAD_FUNC;
|
260
|
260
|
return PXENV_EXIT_FAILURE;
|
261
|
|
- } else if ( file_api_check->Size <
|
262
|
|
- sizeof(struct s_PXENV_FILE_API_CHECK) ) {
|
|
261
|
+ }
|
|
262
|
+
|
|
263
|
+ /* Check for required parameter size */
|
|
264
|
+ if ( file_api_check->Size < sizeof ( *file_api_check ) ) {
|
263
|
265
|
file_api_check->Status = PXENV_STATUS_OUT_OF_RESOURCES;
|
264
|
266
|
return PXENV_EXIT_FAILURE;
|
265
|
|
- } else {
|
266
|
|
- file_api_check->Status = PXENV_STATUS_SUCCESS;
|
267
|
|
- file_api_check->Size = sizeof(struct s_PXENV_FILE_API_CHECK);
|
268
|
|
- file_api_check->Magic = 0xe9c17b20;
|
269
|
|
- file_api_check->Provider = 0x45585067; /* "iPXE" */
|
270
|
|
- file_api_check->APIMask = 0x0000007f; /* Functions e0-e6 */
|
271
|
|
- /* Check to see if we have a PXE exit hook */
|
272
|
|
- if ( pxe_exit_hook.segment | pxe_exit_hook.offset )
|
273
|
|
- /* Function e7, also */
|
274
|
|
- file_api_check->APIMask |= 0x00000080;
|
275
|
|
- file_api_check->Flags = 0; /* None defined */
|
276
|
|
- return PXENV_EXIT_SUCCESS;
|
277
|
267
|
}
|
278
|
|
-}
|
279
|
268
|
|
280
|
|
-/**
|
281
|
|
- * FILE EXIT HOOK
|
282
|
|
- *
|
283
|
|
- * @v file_exit_hook Pointer to a struct
|
284
|
|
- * s_PXENV_FILE_EXIT_HOOK
|
285
|
|
- * @v s_PXENV_FILE_EXIT_HOOK::Hook SEG16:OFF16 to jump to
|
286
|
|
- * @ret #PXENV_EXIT_SUCCESS Successfully set hook
|
287
|
|
- * @ret #PXENV_EXIT_FAILURE We're not an NBP build
|
288
|
|
- * @ret s_PXENV_FILE_EXIT_HOOK::Status PXE status code
|
289
|
|
- *
|
290
|
|
- */
|
291
|
|
-static PXENV_EXIT_t
|
292
|
|
-pxenv_file_exit_hook ( struct s_PXENV_FILE_EXIT_HOOK *file_exit_hook ) {
|
293
|
|
- DBG ( "PXENV_FILE_EXIT_HOOK" );
|
294
|
|
-
|
295
|
|
- /* Check to see if we have a PXE exit hook */
|
296
|
|
- if ( pxe_exit_hook.segment | pxe_exit_hook.offset ) {
|
297
|
|
- /* We'll jump to the specified SEG16:OFF16 during exit */
|
298
|
|
- pxe_exit_hook.segment = file_exit_hook->Hook.segment;
|
299
|
|
- pxe_exit_hook.offset = file_exit_hook->Hook.offset;
|
300
|
|
- file_exit_hook->Status = PXENV_STATUS_SUCCESS;
|
301
|
|
- return PXENV_EXIT_SUCCESS;
|
|
269
|
+ /* Determine supported calls */
|
|
270
|
+ for_each_table_entry ( call, PXE_API_CALLS ) {
|
|
271
|
+ offset = ( call->opcode - PXENV_FILE_MIN );
|
|
272
|
+ if ( offset <= ( PXENV_FILE_MAX - PXENV_FILE_MIN ) )
|
|
273
|
+ mask |= ( 1 << offset );
|
302
|
274
|
}
|
303
|
275
|
|
304
|
|
- DBG ( " not NBP" );
|
305
|
|
- file_exit_hook->Status = PXENV_STATUS_UNSUPPORTED;
|
306
|
|
- return PXENV_EXIT_FAILURE;
|
|
276
|
+ /* Fill in parameters */
|
|
277
|
+ file_api_check->Size = sizeof ( *file_api_check );
|
|
278
|
+ file_api_check->Magic = 0xe9c17b20;
|
|
279
|
+ file_api_check->Provider = 0x45585067; /* "iPXE" */
|
|
280
|
+ file_api_check->APIMask = mask;
|
|
281
|
+ file_api_check->Flags = 0; /* None defined */
|
|
282
|
+
|
|
283
|
+ file_api_check->Status = PXENV_STATUS_SUCCESS;
|
|
284
|
+ return PXENV_EXIT_SUCCESS;
|
307
|
285
|
}
|
308
|
286
|
|
309
|
287
|
/** PXE file API */
|
|
@@ -322,6 +300,4 @@ struct pxe_api_call pxe_file_api[] __pxe_api_call = {
|
322
|
300
|
struct s_PXENV_FILE_EXEC ),
|
323
|
301
|
PXE_API_CALL ( PXENV_FILE_API_CHECK, pxenv_file_api_check,
|
324
|
302
|
struct s_PXENV_FILE_API_CHECK ),
|
325
|
|
- PXE_API_CALL ( PXENV_FILE_EXIT_HOOK, pxenv_file_exit_hook,
|
326
|
|
- struct s_PXENV_FILE_EXIT_HOOK ),
|
327
|
303
|
};
|