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