MCPcopy Create free account
hub / github.com/coreboot/coreboot / new_layout

Function new_layout

util/ifdtool/ifdtool.c:2032–2195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2030}
2031
2032static void new_layout(const char *filename, char *image, int size,
2033 const char *layout_fname)
2034{
2035 FILE *romlayout;
2036 char tempstr[256];
2037 char layout_region_name[256];
2038 unsigned int i, j;
2039 int region_number;
2040 struct region current_regions[MAX_REGIONS];
2041 struct region new_regions[MAX_REGIONS];
2042 int new_extent = 0;
2043 char *new_image;
2044
2045 /* load current descriptor map and regions */
2046 struct frba *frba = find_frba(image, size);
2047 if (!frba)
2048 exit(EXIT_FAILURE);
2049
2050 for (i = 0; i < max_regions; i++) {
2051 current_regions[i] = get_region(frba, i);
2052 new_regions[i] = get_region(frba, i);
2053 }
2054
2055 /* read new layout */
2056 romlayout = fopen(layout_fname, "r");
2057
2058 if (!romlayout) {
2059 perror("Could not read layout file.\n");
2060 exit(EXIT_FAILURE);
2061 }
2062
2063 while (!feof(romlayout)) {
2064 char *tstr1, *tstr2;
2065
2066 if (2 != fscanf(romlayout, "%255s %255s\n", tempstr,
2067 layout_region_name))
2068 continue;
2069
2070 region_number = region_num(layout_region_name);
2071 if (region_number < 0)
2072 continue;
2073
2074 tstr1 = strtok(tempstr, ":");
2075 tstr2 = strtok(NULL, ":");
2076 if (!tstr1 || !tstr2) {
2077 fprintf(stderr, "Could not parse layout file.\n");
2078 exit(EXIT_FAILURE);
2079 }
2080 new_regions[region_number].base = strtol(tstr1,
2081 (char **)NULL, 16);
2082 new_regions[region_number].limit = strtol(tstr2,
2083 (char **)NULL, 16);
2084 new_regions[region_number].size =
2085 new_regions[region_number].limit -
2086 new_regions[region_number].base + 1;
2087
2088 if (new_regions[region_number].size < 0)
2089 new_regions[region_number].size = 0;

Callers 1

mainFunction · 0.85

Calls 15

find_frbaFunction · 0.85
exitFunction · 0.85
get_regionFunction · 0.85
fopenFunction · 0.85
perrorFunction · 0.85
region_numFunction · 0.85
fprintfFunction · 0.85
fcloseFunction · 0.85
printfFunction · 0.85
regions_collideFunction · 0.85
strlenFunction · 0.85
next_pow2Function · 0.85

Tested by

no test coverage detected