00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #define LIBSMBIOS_SOURCE
00021 #include "smbios/compat.h"
00022
00023 #include <sstream>
00024
00025 #include "smbios/IMemory.h"
00026 #include "SmbiosImpl.h"
00027
00028
00029 #include "smbios/message.h"
00030
00031 using namespace smbiosLowlevel;
00032 using namespace std;
00033
00034 #if defined(DEBUG_SMBIOS_STRATEGY)
00035 # define DCOUT(line) do { cout << line; } while(0)
00036 # define DCERR(line) do { cerr << line; } while(0)
00037 #else
00038 # define DCOUT(line) do {} while(0)
00039 # define DCERR(line) do {} while(0)
00040 #endif
00041
00042 #if 1
00043 #define EFIVARS_FILE_le266 "/proc/efi/systab"
00044 #define EFIVARS_FILE_gt266 "/sys/firmware/efi/systab"
00045 #else
00046
00047 #define EFIVARS_FILE_le266 "/home/michael_e_brown/cc/libsmbios_proj/libsmbios/foo.txt"
00048 #define EFIVARS_FILE_gt266 "/home/michael_e_brown/cc/libsmbios_proj/libsmbios/foo.txt"
00049 #endif
00050
00051 namespace smbios
00052 {
00053
00054
00055 void SmbiosLinuxEFIStrategy::getSmbiosTableHeader(smbiosLowlevel::smbios_table_entry_point *table_header, bool strict)
00056 {
00057 ParseExceptionImpl parseException;
00058 parseException.setMessageString(_("EFI support not found"));
00059
00060 FILE *fh = NULL;
00061 if ( (fh=fopen(EFIVARS_FILE_le266, "r")) == NULL &&
00062 (fh=fopen(EFIVARS_FILE_gt266, "r")) == NULL)
00063 throw(parseException);
00064
00065 DCERR("Found EFI systab. Reading offset..." << endl);
00066
00067
00068 char line[256] = {0,};
00069 while(NULL != fgets(line, sizeof(line)-1, fh))
00070 {
00071 char *varName=line;
00072 char *varValue=line;
00073 varValue = strchr(line, '=');
00074 if(!varValue)
00075 continue;
00076
00077 *(varValue++) = '\0';
00078 if (0 == strcmp(varName, "SMBIOS"))
00079 {
00080
00081
00082 offset = strtol(varValue, NULL, 0);
00083 DCERR("Found SMBIOS address: " << hex << offset << "." << endl);
00084 }
00085 }
00086 fclose(fh);
00087
00088 if(offset)
00089 SmbiosMemoryStrategy::getSmbiosTableHeader(table_header, strict);
00090 else
00091 throw(parseException);
00092
00093 DCERR("Parsed SMBIOS table." << endl);
00094 }
00095 }