You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pxe_loader.c 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /** @file
  2. *
  3. * PXE UNDI loader
  4. *
  5. */
  6. /*
  7. * Copyright (C) 2004 Michael Brown <mbrown@fensystems.co.uk>.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of the
  12. * License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23. #include "pxe.h"
  24. /* PXENV_UNDI_LOADER
  25. *
  26. * Status: working
  27. *
  28. * NOTE: This is not a genuine PXE API call; the loader has a separate
  29. * entry point. However, to simplify the mapping of the PXE API to
  30. * the internal Etherboot API, both are directed through the same
  31. * interface.
  32. */
  33. PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER *undi_loader ) {
  34. uint32_t loader_phys = virt_to_phys ( undi_loader );
  35. DBG ( "PXENV_UNDI_LOADER" );
  36. /* Set UNDI DS as our real-mode stack */
  37. use_undi_ds_for_rm_stack ( undi_loader->undi_ds );
  38. /* FIXME: These lines are borrowed from main.c. There should
  39. * probably be a single initialise() function that does all
  40. * this, but it's currently split interestingly between main()
  41. * and main_loop()...
  42. */
  43. /* CHECKME: Our init functions have probably already been
  44. called by the ROM prefix's call to setup(), haven't
  45. they? */
  46. /* We have relocated; the loader pointer is now invalid */
  47. undi_loader = phys_to_virt ( loader_phys );
  48. /* Install PXE stack to area specified by NBP */
  49. install_pxe_stack ( VIRTUAL ( undi_loader->undi_cs, 0 ) );
  50. /* Call pxenv_start_undi to set parameters. Why the hell PXE
  51. * requires these parameters to be provided twice is beyond
  52. * the wit of any sane man. Don't worry if it fails; the NBP
  53. * should call PXENV_START_UNDI separately anyway.
  54. */
  55. pxenv_start_undi ( &undi_loader->u.start_undi );
  56. /* Unhook stack; the loader is not meant to hook int 1a etc,
  57. * but the call the pxenv_start_undi will cause it to happen.
  58. */
  59. /* FIXME: can't use ENSURE_CAN_UNLOAD() thanks to newer gcc's
  60. * barfing on unnamed struct/unions. */
  61. /* ENSURE_CAN_UNLOAD ( undi_loader ); */
  62. /* Fill in addresses of !PXE and PXENV+ structures */
  63. PTR_TO_SEGOFF16 ( &pxe_stack->pxe, undi_loader->pxe_ptr );
  64. PTR_TO_SEGOFF16 ( &pxe_stack->pxenv, undi_loader->pxenv_ptr );
  65. undi_loader->u.Status = PXENV_STATUS_SUCCESS;
  66. return PXENV_EXIT_SUCCESS;
  67. }