Exemplo n.º 1
0
inline struct SMBEntryPoint *
getSmbios()
{
	const char *smbios_filename;
	char dirSpec[512];
	int len;
	struct SMBEntryPoint *orig_address;
	struct SMBEntryPoint *new_address;
	orig_address=getAddressOfSmbiosTable();

	if (!getValueForKey("SMBIOS", &smbios_filename, &len, &bootInfo->bootConfig))
		smbios_filename = "smbios.plist";
	
	sprintf(dirSpec, "%s", smbios_filename);
	if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1)
	{
		sprintf(dirSpec, "/Extra/%s", smbios_filename);
  	if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1)
		{
      sprintf(dirSpec, "bt(0,0)/Extra/%s", smbios_filename);
    	if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1)
      {
         verbose("No SMBIOS replacement found.\n");
      }
    }
	}

//	if( (loadConfigFile("/Extra/smbios.plist", &bootInfo->smbiosConfig)) == -1 )
//		loadConfigFile("bt(0,0)/Extra/smbios.plist", &bootInfo->smbiosConfig); // TODO: do we need this ?
		
	new_address = smbios_dry_run(orig_address);
	smbios_real_run(orig_address, new_address);
	return new_address;
}
Exemplo n.º 2
0
/** Get original or new smbios entry point, if sucessful, the adresses are cached for next time */
struct SMBEntryPoint *getSmbios(int which)
{
    static struct SMBEntryPoint *orig = NULL; // cached
    static struct SMBEntryPoint *patched = NULL; // cached

    // whatever we are called with orig or new flag, initialize asap both structures
    switch (which) {
    case SMBIOS_ORIGINAL:
        if (orig==NULL) {
            orig = getAddressOfSmbiosTable();
            getSmbiosTableStructure(orig); // generate tables entry list for fast table finding
        }
        return orig;
    case SMBIOS_PATCHED:
        if (orig==NULL &&  (orig = getAddressOfSmbiosTable())==NULL ) {
            printf("Could not find original SMBIOS !!\n");
            pause();
        }  else {
            patched = smbios_dry_run(orig);
            if(patched==NULL) {
                printf("Could not create new SMBIOS !!\n");
                pause();
            }
            else {
                smbios_real_run(orig, patched);
            }
        }

       return patched;
    default:
        printf("ERROR: invalid option for getSmbios() !!\n");
        break;
    }

    return NULL;
}
Exemplo n.º 3
0
static int getSMBIOSUUID(unsigned char *uuid)
{
	struct SMBEntryPoint	*smbios;
	struct DMIHeader	*dmihdr;
	SMBByte			*p;
	int			found;
	int			i;
	int			isZero;
	int			isOnes;
	
	smbios = getAddressOfSmbiosTable();	/* checks for _SM_ anchor and table header checksum */
	if (memcmp( &smbios->dmi.anchor[0], "_DMI_", 5) != 0) {
		return 0;
	}
	//verbose(">>> SMBIOSAddr=0x%08x\n", smbios);
	//verbose(">>> DMI: addr=0x%08x, len=0x%d, count=%d\n", smbios->dmi.tableAddress, smbios->dmi.tableLength, smbios->dmi.structureCount);
	i = 0;
	found = 0;
	p = (SMBByte *) smbios->dmi.tableAddress;
	while (i < smbios->dmi.structureCount && p + 4 <= (SMBByte *)smbios->dmi.tableAddress + smbios->dmi.tableLength) {
		dmihdr = (struct DMIHeader *) p;
		//verbose(">>>>>> DMI(%d): type=0x%02x, len=0x%d\n",i,dmihdr->type,dmihdr->length);
		if (dmihdr->length < 4) {
			break;
		}
		if (dmihdr->type == 127) {		/* end of table */
			break;
		}
		if (dmihdr->type == 1) {		/* 3.3.2 System Information */
			if (dmihdr->length >= 0x19) {
				found = 1;
			}
			break;
		}
		p = p + dmihdr->length;
		while ((p - (SMBByte *)smbios->dmi.tableAddress + 1 < smbios->dmi.tableLength) && (p[0] != 0x00 || p[1] != 0x00)) {
			p++;
		}
		p += 2;
		i++;
	}

	if (!found) {
		return 0;
	}

	verbose("Found SMBIOS System Information Table 1\n");
	p += 8;

	for (i=0, isZero=1, isOnes=1; i<UUID_LEN; i++) {
		if (p[i] != 0x00) isZero = 0;
		if (p[i] != 0xff) isOnes = 0;
	}
	if (isZero || isOnes) {	/* empty or setable means: no uuid present */
		verbose("No UUID present in SMBIOS System Information Table\n");
		return 0;
	}

	memcpy(uuid, p, UUID_LEN);

	return 1;
}