AndroidFastbootPlatform.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /** @file
  2. Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef __ANDROID_FASTBOOT_PLATFORM_H__
  6. #define __ANDROID_FASTBOOT_PLATFORM_H__
  7. extern EFI_GUID gAndroidFastbootPlatformProtocolGuid;
  8. /*
  9. Protocol for platform-specific operations initiated by Android Fastboot.
  10. Based on Fastboot Protocol version 0.4. See
  11. system/core/fastboot/fastboot_protocol.txt in the AOSP source tree for more
  12. info.
  13. Doesn't support image verification.
  14. */
  15. /*
  16. Do any initialisation that needs to be done in order to be able to respond to
  17. commands.
  18. @retval EFI_SUCCESS Initialised successfully.
  19. @retval !EFI_SUCCESS Error in initialisation.
  20. */
  21. typedef
  22. EFI_STATUS
  23. (*FASTBOOT_PLATFORM_INIT) (
  24. VOID
  25. );
  26. /*
  27. To be called when Fastboot is finished and we aren't rebooting or booting an
  28. image. Undo initialisation, free resources.
  29. */
  30. typedef
  31. VOID
  32. (*FASTBOOT_PLATFORM_UN_INIT) (
  33. VOID
  34. );
  35. /*
  36. Flash the partition named (according to a platform-specific scheme)
  37. PartitionName, with the image pointed to by Buffer, whose size is BufferSize.
  38. @param[in] PartitionName Null-terminated name of partition to write.
  39. @param[in] BufferSize Size of Buffer in bytes.
  40. @param[in] Buffer Data to write to partition.
  41. @retval EFI_NOT_FOUND No such partition.
  42. @retval EFI_DEVICE_ERROR Flashing failed.
  43. */
  44. typedef
  45. EFI_STATUS
  46. (*FASTBOOT_PLATFORM_FLASH) (
  47. IN CHAR8 *PartitionName,
  48. IN UINTN BufferSize,
  49. IN VOID *Buffer
  50. );
  51. /*
  52. Erase the partition named PartitionName.
  53. @param[in] PartitionName Null-terminated name of partition to erase.
  54. @retval EFI_NOT_FOUND No such partition.
  55. @retval EFI_DEVICE_ERROR Erasing failed.
  56. */
  57. typedef
  58. EFI_STATUS
  59. (*FASTBOOT_PLATFORM_ERASE) (
  60. IN CHAR8 *PartitionName
  61. );
  62. /*
  63. If the variable referred to by Name exists, copy it (as a null-terminated
  64. string) into Value. If it doesn't exist, put the Empty string in Value.
  65. Variable names and values may not be larger than 60 bytes, excluding the
  66. terminal null character. This is a limitation of the Fastboot protocol.
  67. The Fastboot application will handle platform-nonspecific variables
  68. (Currently "version" is the only one of these.)
  69. @param[in] Name Null-terminated name of Fastboot variable to retrieve.
  70. @param[out] Value Caller-allocated buffer for null-terminated value of
  71. variable.
  72. @retval EFI_SUCCESS The variable was retrieved, or it doesn't exist.
  73. @retval EFI_DEVICE_ERROR There was an error looking up the variable. This
  74. does _not_ include the variable not existing.
  75. */
  76. typedef
  77. EFI_STATUS
  78. (*FASTBOOT_PLATFORM_GETVAR) (
  79. IN CHAR8 *Name,
  80. OUT CHAR8 *Value
  81. );
  82. /*
  83. React to an OEM-specific command.
  84. Future versions of this function might want to allow the platform to do some
  85. extra communication with the host. A way to do this would be to add a function
  86. to the FASTBOOT_TRANSPORT_PROTOCOL that allows the implementation of
  87. DoOemCommand to replace the ReceiveEvent with its own, and to restore the old
  88. one when it's finished.
  89. However at the moment although the specification allows it, the AOSP fastboot
  90. host application doesn't handle receiving any data from the client, and it
  91. doesn't support a data phase for OEM commands.
  92. @param[in] Command Null-terminated command string.
  93. @retval EFI_SUCCESS The command executed successfully.
  94. @retval EFI_NOT_FOUND The command wasn't recognised.
  95. @retval EFI_DEVICE_ERROR There was an error executing the command.
  96. */
  97. typedef
  98. EFI_STATUS
  99. (*FASTBOOT_PLATFORM_OEM_COMMAND) (
  100. IN CHAR8 *Command
  101. );
  102. typedef struct _FASTBOOT_PLATFORM_PROTOCOL {
  103. FASTBOOT_PLATFORM_INIT Init;
  104. FASTBOOT_PLATFORM_UN_INIT UnInit;
  105. FASTBOOT_PLATFORM_FLASH FlashPartition;
  106. FASTBOOT_PLATFORM_ERASE ErasePartition;
  107. FASTBOOT_PLATFORM_GETVAR GetVar;
  108. FASTBOOT_PLATFORM_OEM_COMMAND DoOemCommand;
  109. } FASTBOOT_PLATFORM_PROTOCOL;
  110. #endif