static const char *get_hob_type_string(void *hob_ptr) { EFI_PEI_HOB_POINTERS hob; const char *hob_type_string = NULL; const EFI_GUID fsp_reserved_guid = FSP_RESERVED_MEMORY_RESOURCE_HOB_GUID; const EFI_GUID mrc_guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID; const EFI_GUID bootldr_tmp_mem_guid = FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID; const EFI_GUID bootldr_tolum_guid = FSP_BOOTLOADER_TOLUM_HOB_GUID; const EFI_GUID graphics_info_guid = EFI_PEI_GRAPHICS_INFO_HOB_GUID; hob.Header = (EFI_HOB_GENERIC_HEADER *)hob_ptr; switch (hob.Header->HobType) { case EFI_HOB_TYPE_HANDOFF: hob_type_string = "EFI_HOB_TYPE_HANDOFF"; break; case EFI_HOB_TYPE_MEMORY_ALLOCATION: hob_type_string = "EFI_HOB_TYPE_MEMORY_ALLOCATION"; break; case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR: hob_type_string = "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR"; break; case EFI_HOB_TYPE_GUID_EXTENSION: hob_type_string = "EFI_HOB_TYPE_GUID_EXTENSION"; if (compare_guid(&bootldr_tmp_mem_guid, &hob.Guid->Name)) hob_type_string = "FSP_BOOTLOADER_TEMP_MEMORY_HOB"; else if (compare_guid(&fsp_reserved_guid, &hob.Guid->Name)) hob_type_string = "FSP_RESERVED_MEMORY_RESOURCE_HOB"; else if (compare_guid(&mrc_guid, &hob.Guid->Name)) hob_type_string = "FSP_NON_VOLATILE_STORAGE_HOB"; else if (compare_guid(&bootldr_tolum_guid, &hob.Guid->Name)) hob_type_string = "FSP_BOOTLOADER_TOLUM_HOB_GUID"; else if (compare_guid(&graphics_info_guid, &hob.Guid->Name)) hob_type_string = "EFI_PEI_GRAPHICS_INFO_HOB_GUID"; break; case EFI_HOB_TYPE_MEMORY_POOL: hob_type_string = "EFI_HOB_TYPE_MEMORY_POOL"; break; case EFI_HOB_TYPE_UNUSED: hob_type_string = "EFI_HOB_TYPE_UNUSED"; break; case EFI_HOB_TYPE_END_OF_HOB_LIST: hob_type_string = "EFI_HOB_TYPE_END_OF_HOB_LIST"; break; default: hob_type_string = "EFI_HOB_TYPE_UNRECOGNIZED"; break; } return hob_type_string; }
static void process_avb_1722_1_acmp_listener_packet(unsigned char message_type, avb_1722_1_acmp_packet_t* pkt) { if (compare_guid(pkt->listener_guid, &my_guid)==0) return; if (acmp_listener_state != ACMP_LISTENER_WAITING) return; store_rcvd_cmd_resp(&acmp_listener_rcvd_cmd_resp, pkt); switch (message_type) { case ACMP_CMD_CONNECT_TX_RESPONSE: acmp_listener_state = ACMP_LISTENER_CONNECT_TX_RESPONSE; break; case ACMP_CMD_DISCONNECT_TX_RESPONSE: acmp_listener_state = ACMP_LISTENER_DISCONNECT_TX_RESPONSE; break; case ACMP_CMD_CONNECT_RX_COMMAND: acmp_listener_state = ACMP_LISTENER_CONNECT_RX_COMMAND; break; case ACMP_CMD_DISCONNECT_RX_COMMAND: acmp_listener_state = ACMP_LISTENER_DISCONNECT_RX_COMMAND; break; case ACMP_CMD_GET_RX_STATE_COMMAND: acmp_listener_state = ACMP_LISTENER_GET_STATE; break; } }
/* * Returns the next instance of the matching resource HOB from the starting HOB. */ void *get_next_resource_hob(const EFI_GUID *guid, const void *hob_start) { EFI_PEI_HOB_POINTERS hob; hob.Raw = (UINT8 *)hob_start; while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, hob.Raw)) != NULL) { if (compare_guid(guid, &hob.ResourceDescriptor->Owner)) break; hob.Raw = GET_NEXT_HOB(hob.Raw); } return hob.Raw; }
/* Returns the next instance of the matched GUID HOB from the starting HOB. */ void *get_next_guid_hob(const EFI_GUID * guid, const void *hob_start) { EFI_PEI_HOB_POINTERS hob; hob.Raw = (uint8_t *)hob_start; while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_GUID_EXTENSION, hob.Raw)) != NULL) { if (compare_guid(guid, &hob.Guid->Name)) break; hob.Raw = GET_NEXT_HOB(hob.Raw); } return hob.Raw; }
// for parent_type see HasCustomDebugInformation table at // https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/specs/PortablePdb-Metadata.md static const char* lookup_custom_debug_information (MonoImage* image, guint32 token, uint8_t parent_type, guint8* guid) { MonoTableInfo *tables = image->tables; MonoTableInfo *table = &tables[MONO_TABLE_CUSTOMDEBUGINFORMATION]; locator_t loc; if (!table->base) return 0; loc.idx = (mono_metadata_token_index (token) << 5) | parent_type; loc.col_idx = MONO_CUSTOMDEBUGINFORMATION_PARENT; loc.t = table; if (!mono_binary_search (&loc, table->base, table->rows, table->row_size, table_locator)) return NULL; // Great we found one of possibly many CustomDebugInformations of this entity they are distinguished by KIND guid // First try on this index found by binary search...(it's most likeley to be only one and binary search found the one we want) if (compare_guid (guid, (guint8*)mono_metadata_guid_heap (image, mono_metadata_decode_row_col (table, loc.result, MONO_CUSTOMDEBUGINFORMATION_KIND)))) return mono_metadata_blob_heap (image, mono_metadata_decode_row_col (table, loc.result, MONO_CUSTOMDEBUGINFORMATION_VALUE)); // Move forward from binary found index, until parent token differs for (int i = loc.result + 1; i < table->rows; i++) { if (mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_PARENT) != loc.idx) break; if (compare_guid (guid, (guint8*)mono_metadata_guid_heap (image, mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_KIND)))) return mono_metadata_blob_heap (image, mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_VALUE)); } // Move backward from binary found index, until parent token differs for (int i = loc.result - 1; i >= 0; i--) { if (mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_PARENT) != loc.idx) break; if (compare_guid (guid, (guint8*)mono_metadata_guid_heap (image, mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_KIND)))) return mono_metadata_blob_heap (image, mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_VALUE)); } return NULL; }
avb_status_t process_avb_1722_1_adp_packet(avb_1722_1_adp_packet_t* pkt, chanend c_tx) { unsigned message_type = GET_1722_1_MSG_TYPE(((avb_1722_1_packet_header_t*)pkt)); guid_t zero_guid = { 0 }; switch (message_type) { case ENTITY_DISCOVER: { if ( compare_guid(pkt->entity_guid, &my_guid) || compare_guid(pkt->entity_guid, &zero_guid) ) { if (adp_advertise_state == ADP_ADVERTISE_WAITING) adp_advertise_state = ADP_ADVERTISE_ADVERTISE_1; } return AVB_1722_1_OK; } case ENTITY_AVAILABLE: { if (avb_1722_1_entity_database_add(pkt)) { /* We only indicate ADP_DISCOVERY_ADDED state if a new (unseen) entity was added, * and not if an existing entity was updated */ adp_discovery_state = ADP_DISCOVERY_ADDED; } return AVB_1722_1_OK; } case ENTITY_DEPARTING: { avb_1722_1_entity_database_remove(pkt); adp_discovery_state = ADP_DISCOVERY_REMOVED; return AVB_1722_1_OK; } } return AVB_1722_1_OK; }
avb_status_t process_avb_1722_1_aecp_packet(unsigned char dest_addr[6], avb_1722_1_aecp_packet_t *pkt, chanend c_tx) { int message_type = GET_1722_1_MSG_TYPE(((avb_1722_1_packet_header_t*)pkt)); if (compare_guid(pkt->target_guid, &my_guid)==0) return AVB_1722_1_OK; switch (message_type) { case AECP_CMD_AVDECC_MSG_COMMAND: { avb_1722_1_aecp_avdecc_msg_t *msg = &(pkt->data.avdecc); process_avb_1722_1_aecp_avdecc_msg(msg); break; } case AECP_CMD_ADDRESS_ACCESS_COMMAND: { break; } case AECP_CMD_AVC_COMMAND: { # if AVB_1722_1_USE_AVC uint32_t length = 0 ; struct ethernet_hdr_t *eth_hdr = (ethernet_hdr_t*) &avb_1722_1_buf[0]; avb_1722_1_packet_header_t *pkt_hdr = (avb_1722_1_packet_header_t*) (eth_hdr + 1); avb_1722_1_aecp_avc_t* payload = (avb_1722_1_aecp_avc_t*)avb_1722_1_create_aecp_packet(dest_addr, AECP_CMD_AVC_RESPONSE, pkt); bcopy(pkt->data.payload, payload, 514); length = ((uint32_t)payload->avc_length[0] << 8) | payload->avc_length[1]; processAVCCommand(payload->avc_command_response, &length); payload->avc_length[0] = (length >> 8) & 0xff; payload->avc_length[1] = length & 0xff; SET_1722_1_DATALENGTH(pkt_hdr, length+12); mac_tx(c_tx, avb_1722_1_buf, sizeof(ethernet_hdr_t)+sizeof(avb_1722_1_packet_header_t)+36+length, ETH_BROADCAST); #endif break; } case AECP_CMD_VENDOR_UNIQUE_COMMAND: { break; } case AECP_CMD_EXTENDED_COMMAND: { break; } default: // This node is not expecting a response break; } return AVB_1722_1_OK; }
EFIAPI get_next_guid_hob( CONST EFI_GUID * guid, CONST VOID *hob_start ) { EFI_PEI_HOB_POINTERS hob; hob.Raw = (UINT8 *)hob_start; while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_GUID_EXTENSION, hob.Raw)) != NULL) { if (compare_guid(guid, &hob.Guid->Name)) break; hob.Raw = GET_NEXT_HOB(hob.Raw); } return hob.Raw; }
static void process_avb_1722_1_acmp_controller_packet(unsigned char message_type, avb_1722_1_acmp_packet_t* pkt) { int inflight_index = 0; if (acmp_controller_state != ACMP_CONTROLLER_WAITING) return; if (compare_guid(pkt->controller_guid, &my_guid) == 0) return; inflight_index = acmp_get_inflight_from_sequence_id(CONTROLLER, ntoh_16(pkt->sequence_id)); if (inflight_index < 0) return; // We don't have an inflight entry for this command if (message_type != (acmp_controller_inflight_commands[inflight_index].command.message_type + 1)) return; store_rcvd_cmd_resp(&acmp_controller_cmd_resp, pkt); switch (message_type) { case ACMP_CMD_CONNECT_RX_RESPONSE: acmp_controller_state = ACMP_CONTROLLER_CONNECT_RX_RESPONSE; break; case ACMP_CMD_DISCONNECT_RX_RESPONSE: acmp_controller_state = ACMP_CONTROLLER_DISCONNECT_RX_RESPONSE; break; case ACMP_CMD_GET_TX_STATE_RESPONSE: acmp_controller_state = ACMP_CONTROLLER_GET_RX_STATE_RESPONSE; break; case ACMP_CMD_GET_RX_STATE_RESPONSE: acmp_controller_state = ACMP_CONTROLLER_GET_RX_STATE_RESPONSE; break; case ACMP_CMD_GET_TX_CONNECTION_RESPONSE: acmp_controller_state = ACMP_CONTROLLER_GET_TX_CONNECTION_RESPONSE; break; default: { acmp_controller_state = ACMP_CONTROLLER_WAITING; break; } } }