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

Function set_chipdensity

util/ifdtool/ifdtool.c:1327–1382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1325}
1326
1327static void set_chipdensity(const char *filename, char *image, int size,
1328 unsigned int density)
1329{
1330 struct fcba *fcba = find_fcba(image, size);
1331 uint8_t mask, chip2_offset;
1332 if (!fcba)
1333 exit(EXIT_FAILURE);
1334
1335 printf("Setting chip density to ");
1336 decode_component_density(density);
1337 printf("\n");
1338
1339 switch (ifd_version) {
1340 case IFD_VERSION_1:
1341 /* fail if selected density is not supported by this version */
1342 if ( (density == COMPONENT_DENSITY_32MB) ||
1343 (density == COMPONENT_DENSITY_64MB) ||
1344 (density == COMPONENT_DENSITY_UNUSED) ) {
1345 printf("error: Selected density not supported in IFD version 1.\n");
1346 exit(EXIT_FAILURE);
1347 }
1348 mask = 0x7;
1349 chip2_offset = 3;
1350 break;
1351 case IFD_VERSION_1_5:
1352 case IFD_VERSION_2:
1353 mask = 0xf;
1354 chip2_offset = 4;
1355 break;
1356 default:
1357 printf("error: Unknown IFD version\n");
1358 exit(EXIT_FAILURE);
1359 break;
1360 }
1361
1362 /* clear chip density for corresponding chip */
1363 switch (selected_chip) {
1364 case 1:
1365 fcba->flcomp &= ~mask;
1366 break;
1367 case 2:
1368 fcba->flcomp &= ~(mask << chip2_offset);
1369 break;
1370 default: /*both chips*/
1371 fcba->flcomp &= ~(mask | (mask << chip2_offset));
1372 break;
1373 }
1374
1375 /* set the new density */
1376 if (selected_chip == 1 || selected_chip == 0)
1377 fcba->flcomp |= (density); /* first chip */
1378 if (selected_chip == 2 || selected_chip == 0)
1379 fcba->flcomp |= (density << chip2_offset); /* second chip */
1380
1381 write_image(filename, image, size);
1382}
1383
1384static int check_region(const struct frba *frba, unsigned int region_type)

Callers 1

mainFunction · 0.85

Calls 5

find_fcbaFunction · 0.85
exitFunction · 0.85
printfFunction · 0.85
decode_component_densityFunction · 0.85
write_imageFunction · 0.85

Tested by

no test coverage detected