1 /**
2  * @file lv_uefi_private.h
3  *
4  */
5 
6 #ifndef __LV_UEFI_PRIVATE_H__
7 #define __LV_UEFI_PRIVATE_H__
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 
17 #include "../../lvgl.h"
18 
19 #if LV_USE_UEFI
20 
21 #include "lv_uefi.h"
22 
23 /*********************
24  *      DEFINES
25  *********************/
26 
27 /**********************
28  *      TYPEDEFS
29  **********************/
30 
31 /**********************
32  * GLOBAL PROTOTYPES
33  **********************/
34 
35 /**
36  * Internal cache for the image handle (source: application entry point)
37  */
38 extern EFI_HANDLE gLvEfiImageHandle;
39 /**
40  * Internal cache for the system table (source: application entry point)
41  */
42 extern EFI_SYSTEM_TABLE * gLvEfiST;
43 /**
44  * Internal cache for the boot services table (source: gLvEfiST)
45  */
46 extern EFI_BOOT_SERVICES * gLvEfiBS;
47 /**
48  * Internal cache for the boot runtime service table (source: gLvEfiST)
49  */
50 extern EFI_RUNTIME_SERVICES * gLvEfiRT;
51 
52 /**
53  * @brief Test if a protocol is installed at a handle.
54  * @param handle The handle on which the protocol might be installed.
55  * @param protocol The guid of the protocol.
56  * @return TRUE if the protocol is installed, FALSE if not.
57 */
58 bool lv_uefi_protocol_test(EFI_HANDLE handle, EFI_GUID * protocol);
59 
60 /**
61  * @brief Open a protocol.
62  * @param handle The handle on which the protocol is installed.
63  * @param protocol The guid of the protocol.
64  * @return A pointer to the interface, NULL if the protocol couldn't be opened.
65 */
66 void * lv_uefi_protocol_open(EFI_HANDLE handle, EFI_GUID * protocol);
67 
68 /**
69  * @brief Close a protocol.
70  * @param handle The handle on which the protocol is installed.
71  * @param protocol The guid of the protocol.
72 */
73 void lv_uefi_protocol_close(EFI_HANDLE handle, EFI_GUID * protocol);
74 
75 /**
76  * @brief Convert an UCS-2 string to an ASCII string.
77  * The string must contain only characters >= 0x20 and <= 0X7E.
78  * @param ucs2 The UCS-2 string.
79  * @param ascii The buffer to store the ASCII string.
80  * @param ascii_len The size of the buffer in ASCII characters.
81  * @return The number of characters written to the buffer or 0 if
82  * there was an error.
83 */
84 size_t lv_uefi_ucs2_to_ascii(const CHAR16 * ucs2, char * ascii, size_t ascii_len);
85 
86 /**
87  * @brief Convert an ASCII string to an UCS-2 string.
88  * The string must contain only characters >= 0x20 and <= 0X7E.
89  * @param ascii The ASCII string.
90  * @param ucs2 The buffer to store the UCS-2 string.
91  * @param ucs2_len The size of the buffer in UCS-2 characters.
92  * @return The number of bytes written to the buffer or 0 if
93  * there was an error.
94 */
95 size_t lv_uefi_ascii_to_ucs2(const char * ascii, CHAR16 * ucs2, size_t ucs2_len);
96 
97 /**********************
98  *      MACROS
99  **********************/
100 
101 #endif
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif //__LV_UEFI_PRIVATE_H__