* Parse Option ROM and return a valid VBT fileobject. * Caller has to make sure that it is a valid VBIOS. * Return a NULL fileobject on error. */
| 878 | * Return a NULL fileobject on error. |
| 879 | */ |
| 880 | static void parse_vbios(const struct fileobject *fo, |
| 881 | struct fileobject **vbt) |
| 882 | { |
| 883 | const optionrom_header_t *oh = (const optionrom_header_t *)fo->data; |
| 884 | size_t i; |
| 885 | |
| 886 | *vbt = NULL; |
| 887 | |
| 888 | if (!oh->vbt_offset) { |
| 889 | printerr("no VBT found\n"); |
| 890 | return; |
| 891 | } |
| 892 | |
| 893 | if (oh->vbt_offset > (fo->size - sizeof(struct vbt_header))) { |
| 894 | printerr("invalid VBT offset\n"); |
| 895 | return; |
| 896 | } |
| 897 | |
| 898 | struct fileobject *fo_vbt = malloc_fo_sub(fo, oh->vbt_offset); |
| 899 | if (fo_vbt) { |
| 900 | parse_vbt(fo_vbt, vbt); |
| 901 | free_fo(fo_vbt); |
| 902 | if (*vbt) |
| 903 | return; |
| 904 | } |
| 905 | printwarn("VBT wasn't found at specified offset of %04x\n", |
| 906 | oh->vbt_offset); |
| 907 | |
| 908 | for (i = sizeof(optionrom_header_t); |
| 909 | i <= fo->size - sizeof(struct vbt_header); i++) { |
| 910 | struct fileobject *fo_vbt = malloc_fo_sub(fo, i); |
| 911 | if (!fo_vbt) |
| 912 | break; |
| 913 | |
| 914 | parse_vbt(fo_vbt, vbt); |
| 915 | |
| 916 | free_fo(fo_vbt); |
| 917 | |
| 918 | if (*vbt) |
| 919 | return; |
| 920 | } |
| 921 | } |
| 922 | |
| 923 | /* Short VBT summary in human readable form */ |
| 924 | static void print_vbt(const struct fileobject *fo) |
no test coverage detected