30 #include <sys/types.h>
70 static FILE *
writePacket(
const char *fn,
const char *buffer,
size_t bufSize,
bool openclose)
72 static FILE *data_fh = 0;
74 data_fh = fopen(fn,
"wb");
77 throw RbuDriverIOErrorImpl(strerror(errno));
81 fwrite(buffer, 1, bufSize, data_fh);
83 throw RbuDriverIOErrorImpl(strerror(errno));
101 static void pktUpdateLoop(FILE *hdr_fh,
const char *packetFilename,
char *buffer,
size_t bufSize,
bool openclose)
103 cout <<
"Writing RBU data (" << bufSize <<
"bytes/dot): ";
105 fseek(hdr_fh, 0, SEEK_END);
106 size_t totalSizeBytes = ftell(hdr_fh);
114 FILE *data_fh =
writePacket(packetFilename, buffer, bufSize, openclose);
121 size_t numBytes = fread(&(pkt->
pktData), 1, bufSize -
sizeof(
rbu_packet) + 1, hdr_fh);
124 throw HdrFileIOErrorImpl(strerror(errno));
127 writePacket(packetFilename, buffer, bufSize, openclose);
139 cout <<
"Done writing packet data." << endl;
145 const int bufSize = 4096;
146 char *buffer[bufSize];
147 cout <<
"Writing RBU data (" << bufSize <<
"bytes/dot): ";
150 memset(buffer, 0, bufSize);
151 size_t readSz = fread(buffer, 1, bufSize, hdr_fh);
153 throw HdrFileIOErrorImpl(strerror(errno));
155 fwrite(buffer, 1, readSz, data_fh);
157 throw RbuDriverIOErrorImpl(strerror(errno));
158 cout <<
"." << flush;
167 static void setSize(
const char *fn,
size_t sz)
169 FILE *size_fh = fopen(fn,
"wb");
171 throw RbuDriverIOErrorImpl(strerror(errno));
173 ostringstream ost(
"");
175 cout <<
"writing (" << sz <<
") to file: " << fn << endl;
176 fwrite(ost.str().c_str(), 1, ost.str().length(), size_fh);
178 throw RbuDriverIOErrorImpl(strerror(errno));
186 char buffer[bufSize] = {0};
197 cout <<
"Prep driver for data load." << endl;
201 throw RbuDriverIOErrorImpl(strerror(errno));
203 fseek(hdr_fh, 0, SEEK_END);
204 size_t totalSizeBytes = ftell(hdr_fh);
216 cout <<
"BIOS staging is complete." << endl;
226 char buffer[bufSize] = {0};
237 cout <<
"Prep driver for data load." << endl;
241 throw RbuDriverIOErrorImpl(strerror(errno));
243 fseek(hdr_fh, 0, SEEK_END);
244 size_t totalSizeBytes = ftell(hdr_fh);
256 cout <<
"BIOS staging is complete." << endl;
268 type_fh = fopen(fn,
"wb");
270 throw RbuDriverIOErrorImpl(strerror(errno));
275 fwrite(
"mono\0", 1, 5, type_fh);
278 fwrite(
"packet\0", 1, 7, type_fh);
284 fwrite(
"init\0", 1, 7, type_fh);
289 throw RbuDriverIOErrorImpl(strerror(errno));
297 time_t start = time(NULL);
298 while( access(fn, F_OK) && (time(NULL) - start < wait))
310 throw RbuDriverIOErrorImpl(strerror(errno));
312 fwrite(&val, 1, 1, load_fh);
314 throw RbuDriverIOErrorImpl(strerror(errno));
322 char buffer[bufSize] = {0};
332 cout <<
"Prep driver for data load." << endl;
337 throw RbuDriverIOErrorImpl(strerror(errno));
345 cout <<
"Notify driver data is finished." << endl;
361 FILE *hdr_fh = hdr.
getFh();
370 cout <<
"Supported RBU type for this system: (MONOLITHIC"
371 << (supported_pt ==
pt_packet ?
", PACKET" :
"")
375 if( force_type !=
pt_any )
377 supported_pt = force_type;
386 cout <<
"Using RBU v2 driver. Initializing Driver. " << endl;
390 cout <<
"Setting RBU type in v2 driver to: "
391 << (supported_pt ==
pt_packet ?
"PACKET" :
"")
392 << (supported_pt ==
pt_mono ?
"MONOLITHIC" :
"")
393 << (forced ?
" (FORCED) ":
"" )
411 cout <<
"Using RBU v1 method: "
412 << (supported_pt ==
pt_packet ?
"PACKET" :
"")
413 << (supported_pt ==
pt_mono ?
"MONOLITHIC" :
"")
414 << (forced ?
" (FORCED) ":
"" )
431 cout <<
"Using RBU v0 driver. Initializing Driver. " << endl;
434 cout <<
"Setting RBU type in v0 driver to: "
435 << (supported_pt ==
pt_packet ?
"PACKET" :
"")
436 << (supported_pt ==
pt_mono ?
"MONOLITHIC" :
"")
437 << (forced ?
" (FORCED) ":
"" )
455 throw RbuNotSupportedImpl(
"Could not open Dell RBU driver.");
458 cout <<
"Activate CMOS bit to notify BIOS that update is ready on next boot." << endl;
461 cout <<
"Update staged sucessfully. BIOS update will occur on next reboot." << endl;
468 cout <<
"Cancel BIOS CMOS notification bit." << endl;
476 cout <<
"Free kernel driver memory." << endl;
480 cout <<
"Re-initialize driver for next user." << endl;
486 cout <<
"Re-initialize driver for next user." << endl;
494 cout <<
"Re-initialize driver for next user." << endl;
502 cout <<
"Could not determine RBU driver present, skipping." << endl;