Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

efi_entry.c 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <stdlib.h>
  19. #include <gpxe/efi/efi.h>
  20. #include <gpxe/uuid.h>
  21. /** Image handle passed to entry point */
  22. EFI_HANDLE efi_image_handle;
  23. /** System table passed to entry point */
  24. EFI_SYSTEM_TABLE *efi_systab;
  25. /** Declared used EFI protocols */
  26. static struct efi_protocol efi_protocols[0] \
  27. __table_start ( struct efi_protocol, efi_protocols );
  28. static struct efi_protocol efi_protocols_end[0] \
  29. __table_end ( struct efi_protocol, efi_protocols );
  30. /**
  31. * EFI entry point
  32. *
  33. * @v image_handle Image handle
  34. * @v systab System table
  35. * @ret efirc EFI return status code
  36. */
  37. EFI_STATUS EFIAPI efi_entry ( EFI_HANDLE image_handle,
  38. EFI_SYSTEM_TABLE *systab ) {
  39. EFI_BOOT_SERVICES *bs;
  40. struct efi_protocol *prot;
  41. EFI_STATUS efirc;
  42. /* Store image handle and system table pointer for future use */
  43. efi_image_handle = image_handle;
  44. efi_systab = systab;
  45. /* Sanity checks */
  46. if ( ! systab )
  47. return EFI_NOT_AVAILABLE_YET;
  48. if ( ! systab->ConOut )
  49. return EFI_NOT_AVAILABLE_YET;
  50. if ( ! systab->BootServices ) {
  51. DBGC ( systab, "EFI provided no BootServices entry point\n" );
  52. return EFI_NOT_AVAILABLE_YET;
  53. }
  54. if ( ! systab->RuntimeServices ) {
  55. DBGC ( systab, "EFI provided no RuntimeServices entry "
  56. "point\n" );
  57. return EFI_NOT_AVAILABLE_YET;
  58. }
  59. DBGC ( systab, "EFI handle %p systab %p\n", image_handle, systab );
  60. /* Look up required protocols */
  61. bs = systab->BootServices;
  62. for ( prot = efi_protocols ; prot < efi_protocols_end ; prot++ ) {
  63. if ( ( efirc = bs->LocateProtocol ( &prot->u.guid, NULL,
  64. prot->protocol ) ) != 0 ) {
  65. DBGC ( systab, "EFI does not provide protocol %s\n",
  66. uuid_ntoa ( &prot->u.uuid ) );
  67. return efirc;
  68. }
  69. DBGC ( systab, "EFI protocol %s is at %p\n",
  70. uuid_ntoa ( &prot->u.uuid ), *(prot->protocol) );
  71. }
  72. /* Call to main() */
  73. return RC_TO_EFIRC ( main () );
  74. }