Chameleon

Chameleon Commit Details

Date:2010-02-24 17:55:28 (14 years 1 month ago)
Author:Rekursor
Commit:114
Parents: 113
Message:Attempt to understand the asus mb reboot pb, added more constraints on orig/new smbios addresses retrieval and debug messages.
Changes:
M/trunk/i386/libsaio/smbios_patcher.c

File differences

trunk/i386/libsaio/smbios_patcher.c
506506
507507
508508
509
510
511
512
513
514
515
516
517
509
518510
519511
520512
......
739731
740732
741733
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764734
765735
766736
......
776746
777747
778748
779
749
780750
781751
782752
783753
784754
785
755
786756
787
788
789
790757
791758
792759
......
818785
819786
820787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
821823
822824
823825
824826
825
826
827
828827
829828
830829
// copy the old strings to new table
memcpy(newtablesptr, stringsptr, tablesptr-stringsptr);
#if 0
// DEBUG: display this original table 17
if (oldcur->type==6 || oldcur->type==17)
{
dumpPhysAddr("orig table:", oldcur, oldcur->length + ( tablesptr-stringsptr));
}
#endif
// point to next possible space for a string (deducting the second 0 char at the end)
// point to next possible space for a string (deducting the second 0 char at the end)
newtablesptr += tablesptr - stringsptr - 1;
if (nstrings == 0) { // if no string was found rewind to the first 0 char of the 0,0 terminator
newtablesptr--;
verbose("Patched DMI Table\n");
}
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
if (orig == NULL) orig = getAddressOfSmbiosTable();
if (patched == NULL) {
patched = smbios_dry_run(orig);
smbios_real_run(orig, patched);
}
switch (which) {
case SMBIOS_ORIGINAL:
return orig;
case SMBIOS_PATCHED:
return patched;
default:
printf("ERROR: invalid option for getSmbios() !!\n");
return NULL;
}
}
#define MAX_DMI_TABLES 64
typedef struct DmiNumAssocTag {
struct DMIHeader * dmi;
* Get a table structure entry from a type specification and a smbios address
* return NULL if table is not found
*/
static void getSmbiosTableStructure(struct SMBEntryPoint*smbios, int type, int min_length)
static void getSmbiosTableStructure(struct SMBEntryPoint *smbios)
{
struct DMIHeader * dmihdr=NULL;
SMBByte* p;
int i;
if (ftTablePairInit) {
if (ftTablePairInit && smbios!=NULL) {
ftTablePairInit = false;
bzero(DmiTablePair, sizeof(DmiTablePair));
if (smbios == NULL || type < 0 ) return;
#if DEBUG_SMBIOS
printf(">>> SMBIOSAddr=0x%08x\n", smbios);
printf(">>> DMI: addr=0x%08x, len=%d, count=%d\n", smbios->dmi.tableAddress,
}
}
/** Get soriginal or new smbios entry point, if sucessfull, 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
if (orig == NULL) orig = getAddressOfSmbiosTable();
if (patched == NULL) {
if (orig==NULL) {
printf("Could not find original SMBIOS !!\n");
getc();
return NULL;
}
patched = smbios_dry_run(orig);
if(patched==NULL) {
printf("Could not create new SMBIOS !!\n");
getc();
}
else {
smbios_real_run(orig, patched);
getSmbiosTableStructure(patched); // generate tables entry list for fast table finding
}
}
switch (which) {
case SMBIOS_ORIGINAL:
return orig;
case SMBIOS_PATCHED:
return patched;
default:
printf("ERROR: invalid option for getSmbios() !!\n");
return NULL;
}
}
/** Find first new dmi Table with a particular type */
struct DMIHeader* FindFirstDmiTableOfType(int type, int minlength)
{
if (ftTablePairInit)
getSmbiosTableStructure(getSmbios(SMBIOS_PATCHED),
type, minlength);
current_pos = 0;
return FindNextDmiTableOfType(type, minlength);
};

Archive Download the corresponding diff file

Revision: 114