diff options
-rw-r--r-- | hw/fsp/fsp-codeupdate.c | 32 | ||||
-rw-r--r-- | hw/fsp/fsp-dump.c | 24 | ||||
-rw-r--r-- | hw/fsp/fsp-op-panel.c | 12 | ||||
-rw-r--r-- | include/opal.h | 12 |
4 files changed, 43 insertions, 37 deletions
diff --git a/hw/fsp/fsp-codeupdate.c b/hw/fsp/fsp-codeupdate.c index 3ace928..b5e2622 100644 --- a/hw/fsp/fsp-codeupdate.c +++ b/hw/fsp/fsp-codeupdate.c @@ -835,8 +835,8 @@ static int get_lid_data(struct opal_sg_list *list, /* Reset TCE start address */ tce_start = 0; - for (sg = list; sg; sg = sg->next) { - length = (sg->length & ~(SG_LIST_VERSION << 56)) - 16; + for (sg = list; sg; sg = (struct opal_sg_list*)be64_to_cpu(sg->next)) { + length = (be64_to_cpu(sg->length) & ~(SG_LIST_VERSION << 56)) - 16; num_entries = length / sizeof(struct opal_sg_entry); if (num_entries <= 0) return -1; @@ -848,8 +848,8 @@ static int get_lid_data(struct opal_sg_list *list, * Continue until we get data block which * contains LID data */ - if (lid_offset > entry->length) { - lid_offset -= entry->length; + if (lid_offset > be64_to_cpu(entry->length)) { + lid_offset -= be64_to_cpu(entry->length); continue; } @@ -858,16 +858,16 @@ static int get_lid_data(struct opal_sg_list *list, * Map only required pages, instead of * mapping entire entry. */ - map_act = entry->length; - map_size = entry->length; + map_act = be64_to_cpu(entry->length); + map_size = be64_to_cpu(entry->length); /* First TCE mapping */ if (!tce_start) { tce_start = PSI_DMA_CODE_UPD + (lid_offset & 0xfff); - map_act = entry->length - lid_offset; + map_act = be64_to_cpu(entry->length) - lid_offset; lid_offset &= ~0xfff; - map_size = entry->length - lid_offset; + map_size = be64_to_cpu(entry->length) - lid_offset; } /* Check pending LID size to map */ @@ -885,7 +885,9 @@ static int get_lid_data(struct opal_sg_list *list, lid_size -= map_act; /* TCE mapping */ - code_update_tce_map(buf_pos, entry->data + lid_offset, + code_update_tce_map(buf_pos, + (void*)(be64_to_cpu(entry->data) + + lid_offset), map_size); buf_pos += map_size; /* Reset LID offset count */ @@ -989,7 +991,7 @@ static int fsp_flash_firmware(void) if (!list) goto out; entry = &list->entry[0]; - header = (struct update_image_header *)entry->data; + header = (struct update_image_header *)be64_to_cpu(entry->data); idx_entry = (void *)header + be16_to_cpu(header->lid_index_offset); /* FIXME: @@ -1086,8 +1088,8 @@ static int64_t validate_sglist(struct opal_sg_list *list) int length, num_entries, i; prev_entry = NULL; - for (sg = list; sg; sg = sg->next) { - length = (sg->length & ~(SG_LIST_VERSION << 56)) - 16; + for (sg = list; sg; sg = (struct opal_sg_list*)be64_to_cpu(sg->next)) { + length = (be64_to_cpu(sg->length) & ~(SG_LIST_VERSION << 56)) - 16; num_entries = length / sizeof(struct opal_sg_entry); if (num_entries <= 0) return -1; @@ -1096,7 +1098,7 @@ static int64_t validate_sglist(struct opal_sg_list *list) entry = &sg->entry[i]; /* All entries must be aligned */ - if (((uint64_t)entry->data) & 0xfff) + if (((uint64_t)be64_to_cpu(entry->data)) & 0xfff) return OPAL_PARAMETER; /* All non-terminal entries size must be aligned */ @@ -1129,14 +1131,14 @@ static int64_t fsp_opal_update_flash(struct opal_sg_list *list) rc = OPAL_SUCCESS; goto out; } - length = (list->length & ~(SG_LIST_VERSION << 56)) - 16; + length = (be64_to_cpu(list->length) & ~(SG_LIST_VERSION << 56)) - 16; num_entries = length / sizeof(struct opal_sg_entry); if (num_entries <= 0) goto out; /* Validate image header */ entry = &list->entry[0]; - rc = validate_candidate_image((uint64_t)entry->data, + rc = validate_candidate_image((uint64_t)be64_to_cpu(entry->data), VALIDATE_BUF_SIZE, &result); if (!rc && (result != VALIDATE_FLASH_AUTH && result != VALIDATE_INVALID_IMG)) { diff --git a/hw/fsp/fsp-dump.c b/hw/fsp/fsp-dump.c index 941224f..c324b27 100644 --- a/hw/fsp/fsp-dump.c +++ b/hw/fsp/fsp-dump.c @@ -411,8 +411,8 @@ static int64_t validate_dump_sglist(struct opal_sg_list *list, prev_entry = NULL; *size = 0; - for (sg = list; sg; sg = sg->next) { - length = sg->length - 16; + for (sg = list; sg; sg = (struct opal_sg_list*)be64_to_cpu(sg->next)) { + length = be64_to_cpu(sg->length) - 16; num_entries = length / sizeof(struct opal_sg_entry); if (num_entries <= 0) return OPAL_PARAMETER; @@ -422,11 +422,11 @@ static int64_t validate_dump_sglist(struct opal_sg_list *list, *size += entry->length; /* All entries must be aligned */ - if (((uint64_t)entry->data) & 0xfff) + if (((uint64_t)be64_to_cpu(entry->data)) & 0xfff) return OPAL_PARAMETER; /* All non-terminal entries size must be aligned */ - if (prev_entry && (prev_entry->length & 0xfff)) + if (prev_entry && (be64_to_cpu(prev_entry->length) & 0xfff)) return OPAL_PARAMETER; prev_entry = entry; @@ -458,8 +458,8 @@ static int64_t map_dump_buffer(void) fetch_off = fetch_remain; tce_off = sg_off = 0; - for (sg = dump_data; sg; sg = sg->next) { - num_entries = (sg->length - 16) / + for (sg = dump_data; sg; sg = (struct opal_sg_list*)be64_to_cpu(sg->next)) { + num_entries = (be64_to_cpu(sg->length) - 16) / sizeof(struct opal_sg_entry); if (num_entries <= 0) return OPAL_PARAMETER; @@ -468,8 +468,8 @@ static int64_t map_dump_buffer(void) entry = &sg->entry[i]; /* Continue until we get offset */ - if ((sg_off + entry->length) < dump_offset) { - sg_off += entry->length; + if ((sg_off + be64_to_cpu(entry->length)) < dump_offset) { + sg_off += be64_to_cpu(entry->length); continue; } @@ -480,10 +480,10 @@ static int64_t map_dump_buffer(void) */ if (!tce_off) { buf_off = (dump_offset - sg_off) & ~0xfff; - length = entry->length - buf_off; + length = be64_to_cpu(entry->length) - buf_off; } else { buf_off = 0; - length = entry->length; + length = be64_to_cpu(entry->length); } /* Adjust length for last mapping */ @@ -493,11 +493,11 @@ static int64_t map_dump_buffer(void) } /* Adjust offset */ - sg_off += entry->length; + sg_off += be64_to_cpu(entry->length); fetch_off -= length; /* TCE mapping */ - dump_tce_map(tce_off, entry->data + buf_off, length); + dump_tce_map(tce_off, (void*)(be64_to_cpu(entry->data) + buf_off), length); tce_off += length; /* TCE mapping complete */ diff --git a/hw/fsp/fsp-op-panel.c b/hw/fsp/fsp-op-panel.c index 93d1266..8c3c893 100644 --- a/hw/fsp/fsp-op-panel.c +++ b/hw/fsp/fsp-op-panel.c @@ -189,13 +189,17 @@ static int64_t __opal_write_oppanel(oppanel_line_t *lines, uint64_t num_lines, op_src.total_size = sizeof(op_src); op_src.word2 = 0; /* should be unneeded */ - len = lines[0].line_len > 16 ? 16 : lines[0].line_len; + len = be64_to_cpu(lines[0].line_len); + if (len > 16) + len = 16; memset(op_src.ascii + len, ' ', 16-len); - memcpy(op_src.ascii, lines[0].line, len); + memcpy(op_src.ascii, (void*)be64_to_cpu(lines[0].line), len); if (num_lines > 1) { - len = lines[1].line_len > 16 ? 16 : lines[1].line_len; - memcpy(op_src.ascii + 16, lines[1].line, len); + len = be64_to_cpu(lines[1].line_len); + if (len > 16) + len = 16; + memcpy(op_src.ascii + 16, (void*)be64_to_cpu(lines[1].line), len); memset(op_src.ascii + 16 + len, ' ', 16-len); } diff --git a/include/opal.h b/include/opal.h index 1a538fd..bf0365b 100644 --- a/include/opal.h +++ b/include/opal.h @@ -779,8 +779,8 @@ enum { }; typedef struct oppanel_line { - const char *line; - __be64 line_len; + __be64 line; + __be64 line_len; } oppanel_line_t; /* @@ -791,8 +791,8 @@ typedef struct oppanel_line { * size except the last one in the list to be as well. */ struct opal_sg_entry { - void *data; - long length; + __be64 data; + __be64 length; }; /* @@ -801,8 +801,8 @@ struct opal_sg_entry { * length = VER | length */ struct opal_sg_list { - unsigned long length; - struct opal_sg_list *next; + __be64 length; + __be64 next; struct opal_sg_entry entry[]; }; |