1 // SPDX-License-Identifier:     GPL-2.0+
2 /*
3  *  EFI Human Interface Infrastructure ... Configuration
4  *
5  *  Copyright (c) 2017 Leif Lindholm
6  *  Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
7  */
8 
9 #include <common.h>
10 #include <efi_loader.h>
11 
12 const efi_guid_t efi_guid_hii_config_routing_protocol
13 		= EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID;
14 const efi_guid_t efi_guid_hii_config_access_protocol
15 		= EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID;
16 
17 /*
18  * EFI_HII_CONFIG_ROUTING_PROTOCOL
19  */
20 
21 static efi_status_t EFIAPI
extract_config(const struct efi_hii_config_routing_protocol * this,const efi_string_t request,efi_string_t * progress,efi_string_t * results)22 extract_config(const struct efi_hii_config_routing_protocol *this,
23 	       const efi_string_t request,
24 	       efi_string_t *progress,
25 	       efi_string_t *results)
26 {
27 	EFI_ENTRY("%p, \"%ls\", %p, %p", this, request, progress, results);
28 
29 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
30 }
31 
32 static efi_status_t EFIAPI
export_config(const struct efi_hii_config_routing_protocol * this,efi_string_t * results)33 export_config(const struct efi_hii_config_routing_protocol *this,
34 	      efi_string_t *results)
35 {
36 	EFI_ENTRY("%p, %p", this, results);
37 
38 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
39 }
40 
41 static efi_status_t EFIAPI
route_config(const struct efi_hii_config_routing_protocol * this,const efi_string_t configuration,efi_string_t * progress)42 route_config(const struct efi_hii_config_routing_protocol *this,
43 	     const efi_string_t configuration,
44 	     efi_string_t *progress)
45 {
46 	EFI_ENTRY("%p, \"%ls\", %p", this, configuration, progress);
47 
48 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
49 }
50 
51 static efi_status_t EFIAPI
block_to_config(const struct efi_hii_config_routing_protocol * this,const efi_string_t config_request,const u8 * block,const efi_uintn_t block_size,efi_string_t * config,efi_string_t * progress)52 block_to_config(const struct efi_hii_config_routing_protocol *this,
53 		const efi_string_t config_request,
54 		const u8 *block,
55 		const efi_uintn_t block_size,
56 		efi_string_t *config,
57 		efi_string_t *progress)
58 {
59 	EFI_ENTRY("%p, \"%ls\", %p, %zu, %p, %p", this, config_request,
60 		  block, block_size, config, progress);
61 
62 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
63 }
64 
65 static efi_status_t EFIAPI
config_to_block(const struct efi_hii_config_routing_protocol * this,const efi_string_t config_resp,const u8 * block,const efi_uintn_t * block_size,efi_string_t * progress)66 config_to_block(const struct efi_hii_config_routing_protocol *this,
67 		const efi_string_t config_resp,
68 		const u8 *block,
69 		const efi_uintn_t *block_size,
70 		efi_string_t *progress)
71 {
72 	EFI_ENTRY("%p, \"%ls\", %p, %p, %p", this, config_resp,
73 		  block, block_size, progress);
74 
75 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
76 }
77 
78 static efi_status_t EFIAPI
get_alt_config(const struct efi_hii_config_routing_protocol * this,const efi_string_t config_resp,const efi_guid_t * guid,const efi_string_t name,const struct efi_device_path * device_path,const efi_string_t alt_cfg_id,efi_string_t * alt_cfg_resp)79 get_alt_config(const struct efi_hii_config_routing_protocol *this,
80 	       const efi_string_t config_resp,
81 	       const efi_guid_t *guid,
82 	       const efi_string_t name,
83 	       const struct efi_device_path *device_path,
84 	       const efi_string_t alt_cfg_id,
85 	       efi_string_t *alt_cfg_resp)
86 {
87 	EFI_ENTRY("%p, \"%ls\", %pUl, \"%ls\", %p, \"%ls\", %p",
88 		  this, config_resp, guid, name, device_path,
89 		  alt_cfg_id, alt_cfg_resp);
90 
91 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
92 }
93 
94 /*
95  * EFI_HII_ACCESS_PROTOCOL
96  */
97 
98 efi_status_t EFIAPI
extract_config_access(const struct efi_hii_config_access_protocol * this,const efi_string_t request,efi_string_t * progress,efi_string_t * results)99 extract_config_access(const struct efi_hii_config_access_protocol *this,
100 		      const efi_string_t request,
101 		      efi_string_t *progress,
102 		      efi_string_t *results)
103 {
104 	EFI_ENTRY("%p, \"%ls\", %p, %p", this, request, progress, results);
105 
106 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
107 };
108 
109 efi_status_t EFIAPI
route_config_access(const struct efi_hii_config_access_protocol * this,const efi_string_t configuration,efi_string_t * progress)110 route_config_access(const struct efi_hii_config_access_protocol *this,
111 		    const efi_string_t configuration,
112 		    efi_string_t *progress)
113 {
114 	EFI_ENTRY("%p, \"%ls\", %p", this, configuration, progress);
115 
116 	return EFI_EXIT(EFI_OUT_OF_RESOURCES);
117 };
118 
119 efi_status_t EFIAPI
form_callback(const struct efi_hii_config_access_protocol * this,efi_browser_action_t action,efi_question_id_t question_id,u8 type,union efi_ifr_type_value * value,efi_browser_action_request_t * action_request)120 form_callback(const struct efi_hii_config_access_protocol *this,
121 	      efi_browser_action_t action,
122 	      efi_question_id_t question_id,
123 	      u8 type,
124 	      union efi_ifr_type_value *value,
125 	      efi_browser_action_request_t *action_request)
126 {
127 	EFI_ENTRY("%p, 0x%zx, 0x%x, 0x%x, %p, %p", this, action,
128 		  question_id, type, value, action_request);
129 
130 	return EFI_EXIT(EFI_DEVICE_ERROR);
131 };
132 
133 const struct efi_hii_config_routing_protocol efi_hii_config_routing = {
134 	.extract_config = extract_config,
135 	.export_config = export_config,
136 	.route_config = route_config,
137 	.block_to_config = block_to_config,
138 	.config_to_block = config_to_block,
139 	.get_alt_config = get_alt_config
140 };
141 
142 const struct efi_hii_config_access_protocol efi_hii_config_access = {
143 	.extract_config_access = extract_config_access,
144 	.route_config_access = route_config_access,
145 	.form_callback = form_callback
146 };
147