Chameleon

Chameleon Commit Details

Date:2010-01-29 22:28:33 (14 years 2 months ago)
Author:Rekursor
Commit:45
Parents: 44
Message:Fixed display cosmetics of UUID, generalized its formatted printing
Changes:
M/trunk/i386/libsaio/fake_efi.c
M/trunk/version
M/trunk/CHANGES
M/trunk/i386/libsaio/convert.c

File differences

trunk/version
1
1
2.0-RC5pre4
2.0-RC5pre5
trunk/CHANGES
1
2
3
4
5
16
27
38
- Fixed display cosmetics of UUID, now a convert.c file contains all
conversions api, to be completed by function that we should reuse.
- Fixed SystemType would be always forced to a value, now optionally changed
only if ovveriden
- Kept SystemID as the only option to change manually the system-id
For theses reasons, SystemId from bootConfig and SMUUID from smbiosConfig aer now DEPRECATED.
trunk/i386/libsaio/convert.c
88
99
1010
11
11
1212
1313
14
15
16
17
18
19
14
15
16
17
18
19
20
21
2022
2123
2224
#include "convert.h"
/** Transform a 16 bytes hexadecimal value UUID to a string */
const char * getStringFromUUID(const EFI_CHAR8* uuid)
const char * getStringFromUUID(const EFI_CHAR8* eUUID)
{
static char msg[UUID_LEN*2 + 8] = "";
if (uuid) sprintf(msg, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
(int)uuid[0], (int)uuid[1], (int)uuid[2], (int)uuid[3],
(int)uuid[4], (int)uuid[5], (int)uuid[6], (int)uuid[7],
(int)uuid[8], (int)uuid[9], (int)uuid[10],(int)uuid[11],
(int)uuid[12],(int)uuid[13],(int)uuid[14],(int)uuid[15]);
return uuid ? msg : "";
if (!eUUID) return "";
const unsigned char * uuid = (unsigned char*) eUUID;
sprintf(msg, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5], uuid[6], uuid[7],
uuid[8], uuid[9], uuid[10],uuid[11],
uuid[12],uuid[13],uuid[14],uuid[15]);
return msg ;
}
/** Parse an UUID string into an (EFI_CHAR8*) buffer */
trunk/i386/libsaio/fake_efi.c
349349
350350
351351
352
352
353353
354354
355355
356356
357357
358
359
358
359
360360
361361
362362
363363
364
364365
365366
366367
......
369370
370371
371372
372
373
374
373375
374376
375377
......
390392
391393
392394
393
395
394396
395397
396398
......
403405
404406
405407
406
407
408
408409
409410
410411
......
421422
422423
423424
424
425
425426
426427
427428
428429
429
430
430431
431432
432433
......
444445
445446
446447
447
448
448449
449450
450451
#define DEBUG_SMBIOS 0
/* Get the SystemID from the bios dmi info */
static EFI_CHAR8* getSmbiosUUID()
static EFI_CHAR8* getSmbiosUUID()
{
struct SMBEntryPoint*smbios;
struct DMIHeader*dmihdr;
SMBByte*p;
inti, found, isZero, isOnes;
static EFI_CHAR8 uuid[UUID_LEN+1]="";
static EFI_CHAR8 uuid[UUID_LEN];
smbios = getAddressOfSmbiosTable();/* checks for _SM_ anchor and table header checksum */
if (memcmp( &smbios->dmi.anchor[0], "_DMI_", 5) != 0) {
return 0;
}
#if DEBUG_SMBIOS
verbose(">>> SMBIOSAddr=0x%08x\n", smbios);
verbose(">>> DMI: addr=0x%08x, len=0x%d, count=%d\n", smbios->dmi.tableAddress,
i = 0;
found = 0;
p = (SMBByte *) smbios->dmi.tableAddress;
while (i < smbios->dmi.structureCount && p + 4 <= (SMBByte *)smbios->dmi.tableAddress + smbios->dmi.tableLength) {
while (i < smbios->dmi.structureCount && p + 4 <= (SMBByte *)smbios->dmi.tableAddress + smbios->dmi.tableLength)
{
dmihdr = (struct DMIHeader *) p;
#if DEBUG_SMBIOS
verbose(">>>>>> DMI(%d): type=0x%02x, len=0x%d\n",i,dmihdr->type,dmihdr->length);
}
if (!found) return 0;
verbose("Found SMBIOS System Information Table 1\n");
p += 8;
return 0;
}
memcpy(uuid, p, UUID_LEN+1);
uuid[UUID_LEN]=0;
memcpy(uuid, p, UUID_LEN);
return uuid;
}
if(!sysId || !ret) { // try bios dmi info UUID extraction
ret = getSmbiosUUID();
sysId = getStringFromUUID(ret);
sysId = 0;
}
if(!ret) // no bios dmi UUID available, set a fixed value for system-id
ret=getUUIDFromString((sysId = (const char*) SYSTEM_ID));
verbose("Customizing SystemID with : %s\n", sysId);
verbose("Customizing SystemID with : %s\n", getStringFromUUID(ret)); // apply a nice formatting to the displayed output
return ret;
}
/* Export system-type only if it has been overrriden by the SystemType option */
Platform.Type = 1;/* Desktop */
if (getValueForKey(kSystemType, &value, &len, &bootInfo->bootConfig) && value != NULL)
if (getValueForKey(kSystemType, &value, (int*) &len, &bootInfo->bootConfig) && value != NULL)
{
if (Platform.Type > 6)
verbose("Error: system-type must be 0..6. Defaulting to 1!\n");

Archive Download the corresponding diff file

Revision: 45