iPXE
pxe_exit_hook.c
Go to the documentation of this file.
00001 /** @file
00002  *
00003  * PXE exit hook
00004  *
00005  */
00006 
00007 /*
00008  * Copyright (C) 2010 Shao Miller <shao.miller@yrdsb.edu.on.ca>.
00009  *
00010  * This program is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU General Public License as
00012  * published by the Free Software Foundation; either version 2 of the
00013  * License, or any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00023  * 02110-1301, USA.
00024  *
00025  * You can also choose to distribute this program under the terms of
00026  * the Unmodified Binary Distribution Licence (as given in the file
00027  * COPYING.UBDL), provided that you have satisfied its requirements.
00028  */
00029 
00030 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00031 
00032 #include <stdint.h>
00033 #include <realmode.h>
00034 #include <pxe.h>
00035 
00036 /** PXE exit hook */
00037 extern segoff_t __data16 ( pxe_exit_hook );
00038 #define pxe_exit_hook __use_data16 ( pxe_exit_hook )
00039 
00040 /**
00041  * FILE EXIT HOOK
00042  *
00043  * @v file_exit_hook                    Pointer to a struct
00044  *                                      s_PXENV_FILE_EXIT_HOOK
00045  * @v s_PXENV_FILE_EXIT_HOOK::Hook      SEG16:OFF16 to jump to
00046  * @ret #PXENV_EXIT_SUCCESS             Successfully set hook
00047  * @ret #PXENV_EXIT_FAILURE             We're not an NBP build
00048  * @ret s_PXENV_FILE_EXIT_HOOK::Status  PXE status code
00049  *
00050  */
00051 static PXENV_EXIT_t
00052 pxenv_file_exit_hook ( struct s_PXENV_FILE_EXIT_HOOK *file_exit_hook ) {
00053         DBG ( "PXENV_FILE_EXIT_HOOK" );
00054 
00055         /* We'll jump to the specified SEG16:OFF16 during exit */
00056         pxe_exit_hook.segment = file_exit_hook->Hook.segment;
00057         pxe_exit_hook.offset = file_exit_hook->Hook.offset;
00058         file_exit_hook->Status = PXENV_STATUS_SUCCESS;
00059         return PXENV_EXIT_SUCCESS;
00060 }
00061 
00062 /** PXE file API */
00063 struct pxe_api_call pxe_file_api_exit_hook __pxe_api_call =
00064         PXE_API_CALL ( PXENV_FILE_EXIT_HOOK, pxenv_file_exit_hook,
00065                        struct s_PXENV_FILE_EXIT_HOOK );