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