1 /*
2 *
3 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
38 /****************************************************************************
39 * FILE PURPOSE: Local inter-module definitions for the IBL
40 ****************************************************************************
41 * FILE NAME: iblloc.h
42 *
43 * DESCRIPTION: Defines global structures used throughout the IBL
44 *
45 * @file iblloc.h
46 *
47 * @brief
48 * Provides global inter-module definitions
49 *
50 *****************************************************************************/
51 #ifndef IBLLOC_H
52 #define IBLLOC_H
54 #include "types.h"
56 typedef struct BOOT_MODULE_FXN_TABLE
57 {
58 /**
59 * @brief The API is called by the kernel to open the specific
60 * boot module. This is used by boot module to initialize themselves
61 * and the peripheral drivers.
62 */
63 Int32 (*open)(void* ptr_driver, void (*asyncComplete)(void *));
65 /**
66 * @brief The API is called by the kernel to close the boot module
67 * Boot Modules use this API and to close themselves and the peripheral
68 * drivers.
69 */
70 Int32 (*close)(void);
72 /**
73 * @brief The API is called by the kernel to read a specific number
74 * of bytes from the boot module and to populate the data buffer.
75 */
76 Int32 (*read)(Uint8* ptr_buf, Uint32 num_bytes);
78 /**
79 * @brief The API is called by the kernel to write a specific number
80 * of bytes to the boot module from the data buffer. This is *optional*
81 */
82 Int32 (*write)(Uint8* ptr_buf, Uint32 num_bytes);
84 /**
85 * @brief This API is called by the kernal to peek at some bytes
86 * without removing them from the buffer
87 */
88 Int32 (*peek)(Uint8 *ptr_buf, Uint32 num_bytes);
90 /**
91 * @brief This API is called by the kernel to move the read/write
92 * pointers in the buffer. The values of parameter from
93 * match those of fseek - 0 = from start of file,
94 * 1 = from current position, 2 = from end of file.
95 * Returns 0 if the seek is successful, -1 if it failed.
96 */
97 Int32 (*seek)(Int32 loc, Int32 from);
99 /**
100 * @brief This API is called by the kernel to determine how much data
101 * is currently available for immediate read. Returns -1 if
102 * the stream has been closed.
103 */
104 Int32 (*query)(void);
107 }BOOT_MODULE_FXN_TABLE;
110 /* Prototypes */
111 Uint32 iblBoot (BOOT_MODULE_FXN_TABLE *bootFxn, int32 dataFormat, void *formatParams);
113 /* Stdlibs referenced through functions to use a single copy in the two stage boot */
114 void *iblMalloc (Uint32 size);
115 void iblFree (void *mem);
116 void *iblMemset (void *mem, Int32 ch, Uint32 n);
117 void *iblMemcpy (void *s1, const void *s2, Uint32 n);
119 /* squash printfs */
120 void mprintf(char *x, ...);
123 /* Initial Boot Devices */
124 #define BOOT_DEVICE_INVALID -1
125 #define BOOT_DEVICE_I2C 0
126 #define BOOT_DEVICE_SPI_NOR 1
127 #define BOOT_DEVICE_SPI_NAND 2
129 BOOT_MODULE_FXN_TABLE *iblInitI2c (void);
130 BOOT_MODULE_FXN_TABLE *iblInitSpiNor (void);
131 BOOT_MODULE_FXN_TABLE *iblInitSpiNand (void);
133 #endif /* _IBLLOC_H */