Chameleon

Chameleon Commit Details

Date:2010-02-24 22:31:47 (14 years 1 month ago)
Author:Rekursor
Commit:115
Parents: 114
Message:Fixed getSmbios() would be lately called if user forced a systemid value, fFixed potential problem with smbios address search, added a new pause() function that print a pause message and wait for a key. Avoided smbios read retries if it does not work the first time.
Changes:
M/trunk/i386/libsaio/console.c
M/trunk/i386/libsaio/smbios_patcher.c
M/trunk/i386/boot2/graphics.c
M/trunk/i386/libsaio/platform.c
M/trunk/i386/libsaio/cpu.c
M/trunk/i386/libsaio/fake_efi.c
M/trunk/i386/libsaio/pci.c
M/trunk/i386/libsaio/saio_internal.h
M/trunk/i386/boot2/options.c

File differences

trunk/i386/libsaio/console.c
152152
153153
154154
155
156
157
158
159
160
161
halt();
while (1);
}
/** Print a "Press a key to continue..." message and wait for a key press. */
void pause()
{
printf("Press a key to continue...");
getc();
}
trunk/i386/libsaio/smbios_patcher.c
277277
278278
279279
280
281280
282281
283282
284283
285284
286285
287
288
286
287
288
289
289290
290291
291292
292
293
293294
294295
295
296
296297
297298
298299
......
770771
771772
772773
773
774
775
774
775
776
777
778
779
780
781
782
776783
777784
778785
......
785792
786793
787794
788
795
796
789797
790798
791799
792800
801
802
793803
794
795
804
805
806
796807
797808
798
799
809
810
811
812
813
814
815
816
817
818
819
800820
801
802
803
804
805
806
807
808
809
810
821
811822
812
823
813824
814825
815826
......
817828
818829
819830
820
831
821832
833
834
822835
823836
824837
825838
826839
827840
841
828842
829843
830844
......
833847
834848
835849
850
851
836852
837853
838854
static struct SMBEntryPoint *getAddressOfSmbiosTable(void)
{
struct SMBEntryPoint*smbios;
/*
* The logic is to start at 0xf0000 and end at 0xfffff iterating 16 bytes at a time looking
* for the SMBIOS entry-point structure anchor (literal ASCII "_SM_").
*/
smbios = (struct SMBEntryPoint*) SMBIOS_RANGE_START;
while (smbios <= (struct SMBEntryPoint *)SMBIOS_RANGE_END) {
if (COMPARE_DWORD(smbios->anchor, SMTAG) && COMPARE_DWORD(smbios->dmi.anchor, DMITAG) &&
checksum8(smbios, sizeof(struct SMBEntryPoint)) == 0)
if (COMPARE_DWORD(smbios->anchor, SMTAG) &&
COMPARE_DWORD(smbios->dmi.anchor, DMITAG) &&
smbios->dmi.anchor[4]==DMITAG[4] &&
checksum8(smbios, sizeof(struct SMBEntryPoint)) == 0)
{
return smbios;
}
smbios = (((void*) smbios) + 16);
smbios = (struct SMBEntryPoint*) ( ((char*) smbios) + 16 );
}
printf("ERROR: Unable to find SMBIOS!\n");
sleep(5);
pause();
return NULL;
}
// verbose(">>>>>> DMI(%d): type=0x%02x, len=0x%d\n",i,dmihdr->type,dmihdr->length);
#endif
if (dmihdr->length < 4 || dmihdr->type == 127 /* EOT */) break;
DmiTablePair[DmiTablePairCount].dmi = dmihdr;
DmiTablePair[DmiTablePairCount].type = dmihdr->type;
DmiTablePairCount++;
if (DmiTablePairCount < MAX_DMI_TABLES) {
DmiTablePair[DmiTablePairCount].dmi = dmihdr;
DmiTablePair[DmiTablePairCount].type = dmihdr->type;
DmiTablePairCount++;
}
else {
printf("DMI table entries list is full! next entries won't be stored\n");
}
#if DEBUG_SMBIOS
printf("DMI header found for table type %d, length = %d\n", dmihdr->type, dmihdr->length);
#endif
}
}
/** Get soriginal or new smbios entry point, if sucessfull, the adresses are cached for next time */
/** 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
static bool first_time = true;
// whatever we are called with orig or new flag, initialize asap both structures
if (orig == NULL) orig = getAddressOfSmbiosTable();
if (patched == NULL) {
if (first_time) {
orig = getAddressOfSmbiosTable();
if (orig==NULL) {
printf("Could not find original SMBIOS !!\n");
getc();
return NULL;
pause();
} else {
patched = smbios_dry_run(orig);
if(patched==NULL) {
printf("Could not create new SMBIOS !!\n");
pause();
}
else {
smbios_real_run(orig, patched);
getSmbiosTableStructure(patched); // generate tables entry list for fast table finding
}
}
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
}
first_time = false;
}
switch (which) {
case SMBIOS_ORIGINAL:
return orig;
return patched;
default:
printf("ERROR: invalid option for getSmbios() !!\n");
return NULL;
break;
}
return NULL;
}
/** Find first new dmi Table with a particular type */
struct DMIHeader* FindFirstDmiTableOfType(int type, int minlength)
{
current_pos = 0;
return FindNextDmiTableOfType(type, minlength);
};
{
int i;
if (ftTablePairInit) getSmbios(SMBIOS_PATCHED);
for (i=current_pos; i < DmiTablePairCount; i++) {
if (type == DmiTablePair[i].type &&
DmiTablePair[i].dmi &&
trunk/i386/libsaio/platform.c
2525
2626
2727
28
2829
2930
3031
......
3435
3536
3637
37
38
38
39
3940
4041
4142
43
44
45
46
47
48
49
50
51
52
53
54
55
4256
4357
4458
59
60
4561
46
47
48
49
5062
PlatformInfo_t Platform;
/** Return if a CPU feature specified by feature is activated (true) or not (false) */
bool platformCPUFeature(uint32_t feature)
{
if (Platform.CPU.Features & feature) {
}
}
void scan_platform(void)
{
/** scan mem for memory autodection purpose */
void scan_mem() {
bool useAutodetection = false;
getBoolForKey(kUseMemDetect, &useAutodetection, &bootInfo->bootConfig);
if (useAutodetection) {
scan_memory(&Platform);
scan_spd(&Platform);
}
}
/**
Scan platform hardware information, called by the main entry point (common_boot() )
_before_ bootConfig xml parsing settings are loaded
*/
void scan_platform(void)
{
memset(&Platform, 0, sizeof(Platform));
build_pci_dt();
scan_cpu(&Platform);
// disabled for now as options can't be read yet here:
// scan_mem();
if (useAutodetection) {
scan_memory(&Platform);
scan_spd(&Platform);
}
}
trunk/i386/libsaio/cpu.c
369369
370370
371371
372
373
372
374373
375374
DBG("CPU: CPUFreq: %dMHz\n", p->CPU.CPUFrequency / 1000000);
DBG("CPU: NoCores/NoThreads: %d/%d\n", p->CPU.NoCores, p->CPU.NoThreads);
DBG("CPU: Features: 0x%08x\n", p->CPU.Features);
printf("(Press a key to continue...)\n");
getc();
pause();
#endif
}
trunk/i386/libsaio/pci.c
136136
137137
138138
139
140
139
141140
142141
143142
scan_pci_bus(root_pci_dev, 0);
#if DEBUG_PCI
dump_pci_dt(root_pci_dev->children);
printf("(Press a key to continue...)\n");
getc();
pause();
#endif
}
trunk/i386/libsaio/fake_efi.c
482482
483483
484484
485
485486
486487
487488
if (loadConfigFile(value, &bootInfo->smbiosConfig) == -1) {
verbose("No SMBIOS replacement found\n");
}
smbios_p = (EFI_PTR32) getSmbios(SMBIOS_PATCHED);// process smbios asap
}
/* Installs all the needed configuration table entries */
trunk/i386/libsaio/saio_internal.h
4646
4747
4848
49
49
5050
5151
5252
53
5354
5455
5556
extern int ebiosread(int dev, unsigned long long sec, int count);
extern int ebioswrite(int dev, long sec, int count);
extern int get_drive_info(int drive, struct driveInfo *dp);
extern int ebiosEjectMedia(int biosdev);
extern int ebiosEjectMedia(int biosdev);
extern void putc(int ch);
extern void putca(int ch, int attr, int repeat);
extern int getc(void);
extern void pause();
extern int readKeyboardStatus(void);
extern int readKeyboardShiftFlags(void);
extern unsigned int time18(void);
trunk/i386/boot2/graphics.c
124124
125125
126126
127
128
127
129128
130129
131130
132131
133132
134133
135
136
134
137135
138136
139137
modeInfo.ModeAttributes);
if (line++ >= 20) {
printf("(Press a key to continue...)");
getc();
pause();
line = 0;
clearScreenRows(0, 24);
setCursorPosition( 0, 0, 1 );
}
}
if (line != 0) {
printf("(Press a key to continue...)");
getc();
pause();
}
setActiveDisplayPage(0);
}
trunk/i386/boot2/options.c
613613
614614
615615
616
617
616
618617
619618
620619
621620
622621
623
624
622
625623
626624
627625
......
661659
662660
663661
664
665
662
666663
667664
668665
(unsigned long)(mp->length),
mp->type);
if (line++ > 20) {
printf("(Press a key to continue...)");
getc();
pause();
line = 0;
}
mp++;
}
if (line > 0) {
printf("(Press a key to continue...)");
getc();
pause();
}
setActiveDisplayPage(0);
dump_pci_dt(root_pci_dev->children);
printf("(Press a key to continue...)");
getc();
pause();
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
setActiveDisplayPage(0);

Archive Download the corresponding diff file

Revision: 115