1 // SPDX-License-Identifier: Intel
3 * Copyright (C) 2013, Intel Corporation
4 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
11 * Returns the next instance of a HOB type from the starting HOB.
13 * @type: HOB type to search
14 * @hob_list: A pointer to the HOB list
16 * @return A HOB object with matching type; Otherwise NULL.
18 const struct hob_header *hob_get_next_hob(uint type, const void *hob_list)
20 const struct hob_header *hdr;
24 /* Parse the HOB list until end of list or matching type is found */
25 while (!end_of_hob(hdr)) {
26 if (hdr->type == type)
29 hdr = get_next_hob(hdr);
36 * Returns the next instance of the matched GUID HOB from the starting HOB.
38 * @guid: GUID to search
39 * @hob_list: A pointer to the HOB list
41 * @return A HOB object with matching GUID; Otherwise NULL.
43 const struct hob_header *hob_get_next_guid_hob(const efi_guid_t *guid,
46 const struct hob_header *hdr;
47 struct hob_guid *guid_hob;
50 while ((hdr = hob_get_next_hob(HOB_TYPE_GUID_EXT, hdr))) {
51 guid_hob = (struct hob_guid *)hdr;
52 if (!guidcmp(guid, &guid_hob->name))
54 hdr = get_next_hob(hdr);
61 * This function retrieves a GUID HOB data buffer and size.
63 * @hob_list: A HOB list pointer.
64 * @len: A pointer to the GUID HOB data buffer length.
65 * If the GUID HOB is located, the length will be updated.
66 * @guid A pointer to HOB GUID.
68 * @return NULL: Failed to find the GUID HOB.
69 * @return others: GUID HOB data buffer pointer.
71 void *hob_get_guid_hob_data(const void *hob_list, u32 *len,
72 const efi_guid_t *guid)
74 const struct hob_header *guid_hob;
76 guid_hob = hob_get_next_guid_hob(guid, hob_list);
81 *len = get_guid_hob_data_size(guid_hob);
83 return get_guid_hob_data(guid_hob);