Fix VBIOS header and PCIR */
| 979 | |
| 980 | /* Fix VBIOS header and PCIR */ |
| 981 | static int fix_vbios_header(struct fileobject *fo) |
| 982 | { |
| 983 | if (!fo || fo->size < sizeof(optionrom_header_t)) |
| 984 | return 1; |
| 985 | |
| 986 | optionrom_header_t *oh = (optionrom_header_t *)fo->data; |
| 987 | |
| 988 | /* Fix size alignment */ |
| 989 | if (fo->size % 512) { |
| 990 | print("Aligning size to 512\n"); |
| 991 | fo = remalloc_fo(fo, (fo->size + 511) / 512 * 512); |
| 992 | if (!fo) |
| 993 | return 1; |
| 994 | oh = (optionrom_header_t *)fo->data; |
| 995 | } |
| 996 | |
| 997 | /* Fix size field */ |
| 998 | oh->size = fo->size / 512; |
| 999 | |
| 1000 | /* Fix checksum field */ |
| 1001 | oh->checksum = -(checksum_vbios(oh) - oh->checksum); |
| 1002 | |
| 1003 | return 0; |
| 1004 | } |
| 1005 | |
| 1006 | /* Return the VBT structure size in bytes */ |
| 1007 | static size_t vbt_size(const struct fileobject *fo) |
no test coverage detected