Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/acpica/acpi_iort.c
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | iort_entry_lookup(struct iort_node *node, u_int id, u_int *outid) | ||||
struct iort_map_entry *entry; | struct iort_map_entry *entry; | ||||
int i, id_map; | int i, id_map; | ||||
id_map = iort_entry_get_id_mapping_index(node); | id_map = iort_entry_get_id_mapping_index(node); | ||||
entry = node->entries.mappings; | entry = node->entries.mappings; | ||||
for (i = 0; i < node->nentries; i++, entry++) { | for (i = 0; i < node->nentries; i++, entry++) { | ||||
if (i == id_map) | if (i == id_map) | ||||
continue; | continue; | ||||
if (entry->base <= id && id <= entry->end) | if (entry->base <= id && id < entry->end) | ||||
break; | break; | ||||
} | } | ||||
if (i == node->nentries) | if (i == node->nentries) | ||||
return (NULL); | return (NULL); | ||||
if ((entry->flags & ACPI_IORT_ID_SINGLE_MAPPING) == 0) | if ((entry->flags & ACPI_IORT_ID_SINGLE_MAPPING) == 0) | ||||
*outid = entry->outbase + (id - entry->base); | *outid = entry->outbase + (id - entry->base); | ||||
else | else | ||||
*outid = entry->outbase; | *outid = entry->outbase; | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | map_entry = ACPI_ADD_PTR(ACPI_IORT_ID_MAPPING, node_entry, | ||||
node_entry->MappingOffset); | node_entry->MappingOffset); | ||||
node->nentries = node_entry->MappingCount; | node->nentries = node_entry->MappingCount; | ||||
node->usecount = 0; | node->usecount = 0; | ||||
mapping = malloc(sizeof(*mapping) * node->nentries, M_DEVBUF, | mapping = malloc(sizeof(*mapping) * node->nentries, M_DEVBUF, | ||||
M_WAITOK | M_ZERO); | M_WAITOK | M_ZERO); | ||||
node->entries.mappings = mapping; | node->entries.mappings = mapping; | ||||
for (i = 0; i < node->nentries; i++, mapping++, map_entry++) { | for (i = 0; i < node->nentries; i++, mapping++, map_entry++) { | ||||
mapping->base = map_entry->InputBase; | mapping->base = map_entry->InputBase; | ||||
mapping->end = map_entry->InputBase + map_entry->IdCount - 1; | /* ARM DEN 0049D: "The number of IDs in the range minus one" */ | ||||
mapping->end = map_entry->InputBase + map_entry->IdCount + 1; | |||||
andrew: Won't this mean we have an off-by-one error in the opposite direction? | |||||
Done Inline ActionsHm, yeah, we actually do lookup with id <= entry->end instead of id < entry->end for some reason. If we change to id < entry->end, it won't. (We could also not do +1 but the comparison being inclusive on both ends seems odd to me) val_packett.cool: Hm, yeah, we actually do lookup with `id <= entry->end` instead of `id < entry->end` for some… | |||||
Not Done Inline Actions<= allows for entries at the end of the address space while < would require a 65 bit value for a 64 bit address space. andrew: `<=` allows for entries at the end of the address space while `<` would require a 65 bit value… | |||||
mapping->outbase = map_entry->OutputBase; | mapping->outbase = map_entry->OutputBase; | ||||
mapping->out_node_offset = map_entry->OutputReference; | mapping->out_node_offset = map_entry->OutputReference; | ||||
mapping->flags = map_entry->Flags; | mapping->flags = map_entry->Flags; | ||||
mapping->out_node = NULL; | mapping->out_node = NULL; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines |
Won't this mean we have an off-by-one error in the opposite direction?