e92636cc07c045157ee4ac6948a8200e535823e2
1 /************************************************************************************
2 * FILE PURPOSE: Boot a binary blob
3 ************************************************************************************
4 * FILE NAME: blob.c
5 *
6 * DESCRIPTION: A binary blob is booted.
7 *
8 * @file blob.c
9 *
10 * @brief
11 * This file reads data from the boot device as a binary blob
12 *
13 ************************************************************************************/
14 #include "types.h"
15 #include "ibl.h"
16 #include "iblloc.h"
17 #include "iblblob.h"
21 /**
22 * @b Description
23 * @n
24 *
25 * A simple read from the boot device is done until one of the following
26 * conditions occurs:
27 * - The complete data block is read
28 * - The read request fails
29 */
31 void iblBootBlob (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *entry, void *formatParams)
32 {
33 Int32 dataSize;
34 Uint32 remainSize;
35 Uint32 dummyVal;
36 Uint32 bytesRead = 0;
37 Int32 erVal = 0;
38 Uint8 *datap;
40 iblBinBlob_t *blobParams = (iblBinBlob_t *)formatParams;
42 datap = (Uint8 *)blobParams->startAddress;
43 *entry = 0;
45 for (remainSize = blobParams->sizeBytes; (remainSize > 0) && (erVal == 0); ) {
47 /* If there is any data waiting go ahead and process it */
48 dataSize = (*bootFxn->query)();
50 /* The query function will return a negative value when the stream has
51 * closed */
52 if (dataSize < 0)
53 break;
55 if (dataSize > remainSize)
56 dataSize = remainSize;
58 if (dataSize > 0) {
60 (*bootFxn->read)(datap, dataSize);
61 datap = datap + dataSize;
62 remainSize = remainSize - dataSize;
63 bytesRead = bytesRead + dataSize;
65 } else {
67 /* If there is no data waiting peek for more. On error assume
68 * that the device has completed the transfer. This is valid
69 * since the read includes a timeout. */
70 erVal = (*bootFxn->peek)((Uint8 *)&dummyVal, 1);
72 }
74 }
76 /* Assume that if any data was read the boot was successful.
77 * A check could be added to see if the entry address was
78 * actually written, but this assumes there was no data already
79 * at the entry point */
80 if (bytesRead > 0)
81 *entry = blobParams->branchAddress;
83 }