20 #define LIBSMBIOS_SOURCE
30 #define SMI_DATA_FILE "/sys/devices/platform/dcdbas/smi_data"
31 #define SMI_PHYS_ADDR_FILE "/sys/devices/platform/dcdbas/smi_data_buf_phys_addr"
32 #define SMI_DO_REQUEST_FILE "/sys/devices/platform/dcdbas/smi_request"
33 #define SMI_BUF_SIZE_FILE "/sys/devices/platform/dcdbas/smi_data_buf_size"
47 SmiArchStrategy::SmiArchStrategy()
53 SmiArchStrategy::~SmiArchStrategy()
67 void SmiArchStrategy::lock()
74 throw smbios::InternalErrorImpl(
"Could not open file " SMI_DATA_FILE ". Check that dcdbas driver is properly loaded.");
78 throw smbios::InternalErrorImpl(
"Could not open file " SMI_DO_REQUEST_FILE ". Check that dcdbas driver is properly loaded.");
80 flock( fileno(tmpPrivPtr->
fh_data), LOCK_EX );
83 fwrite(
"0", 1, 1, tmpPrivPtr->
fh_doReq);
87 size_t SmiArchStrategy::getPhysicalBufferBaseAddress()
90 char tmpBuf[bufSize+1] = {0,};
97 throw smbios::InternalErrorImpl(
"Could not open file " SMI_PHYS_ADDR_FILE ". Check that dcdbas driver is properly loaded.");
100 size_t numBytes = fread(tmpBuf, 1, bufSize, fh);
104 throw smbios::InternalErrorImpl(
"Short read from physical address file. Driver problem?");
106 retval = strtoll(tmpBuf, NULL, 16);
113 const int bufSize=63;
114 char tmpBuf[bufSize+1] = {0,};
120 throw smbios::InternalErrorImpl(
"Could not open file " SMI_BUF_SIZE_FILE ". Check that dcdbas driver is properly loaded.");
122 snprintf(tmpBuf, bufSize,
"%d", newSize);
123 fwrite(tmpBuf, 1, bufSize, fh);
130 void SmiArchStrategy::addInputBuffer(
u8 *buffer,
size_t size)
133 fwrite(buffer, 1, size, tmpPrivPtr->
fh_data);
136 void SmiArchStrategy::getResultBuffer(
u8 *buffer,
size_t size)
140 int numbytes = fread(buffer, 1, size, tmpPrivPtr->
fh_data);
142 throw smbios::InternalErrorImpl(
"Short read from file handle");
146 void SmiArchStrategy::execute()
150 fwrite(
"1", 1, 1, tmpPrivPtr->
fh_doReq);
152 fseek(tmpPrivPtr->
fh_data, 0L, 0);
155 void SmiArchStrategy::finish()
158 flock( fileno(tmpPrivPtr->
fh_data), LOCK_UN );