1 /*\r
2 * Copyright (c) 2014, Mentor Graphics Corporation\r
3 * All rights reserved.\r
4 *\r
5 * Redistribution and use in source and binary forms, with or without\r
6 * modification, are permitted provided that the following conditions are met:\r
7 *\r
8 * 1. Redistributions of source code must retain the above copyright notice,\r
9 * this list of conditions and the following disclaimer.\r
10 * 2. Redistributions in binary form must reproduce the above copyright notice,\r
11 * this list of conditions and the following disclaimer in the documentation\r
12 * and/or other materials provided with the distribution.\r
13 * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
14 * contributors may be used to endorse or promote products derived from this\r
15 * software without specific prior written permission.\r
16 *\r
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
27 * POSSIBILITY OF SUCH DAMAGE.\r
28 */\r
29 \r
30 /**************************************************************************\r
31 * FILE NAME\r
32 *\r
33 * config.c\r
34 *\r
35 * COMPONENT\r
36 *\r
37 * OpenAMP stack.\r
38 *\r
39 * DESCRIPTION\r
40 *\r
41 *\r
42 **************************************************************************/\r
43 \r
44 #include "config.h"\r
45 \r
46 /* Start and end addresses of firmware image for remotes. These are defined in the\r
47 * object files that are obtained by converting the remote ELF Image into object\r
48 * files. These symbols are not used for remotes.\r
49 */\r
50 extern unsigned char _binary_firmware1_start;\r
51 extern unsigned char _binary_firmware1_end;\r
52 \r
53 extern unsigned char _binary_firmware2_start;\r
54 extern unsigned char _binary_firmware2_end;\r
55 \r
56 #define FIRMWARE1_START (void *)&_binary_firmware1_start\r
57 #define FIRMWARE1_END (void *)&_binary_firmware1_end\r
58 \r
59 #define FIRMWARE2_START (void *)&_binary_firmware2_start\r
60 #define FIRMWARE2_END (void *)&_binary_firmware2_end\r
61 \r
62 /* Init firmware table */\r
63 \r
64 const struct firmware_info fw_table[] = { { "firmware1",\r
65 (unsigned int) FIRMWARE1_START, (unsigned int) FIRMWARE1_END },\r
66 { "firmware2", (unsigned int) FIRMWARE2_START,\r
67 (unsigned int) FIRMWARE2_END } };\r
68 \r
69 /**\r
70 * config_get_firmware\r
71 *\r
72 * Searches the given firmware in firmware table list and provides\r
73 * it to caller.\r
74 *\r
75 * @param fw_name - name of the firmware\r
76 * @param start_addr - pointer t hold start address of firmware\r
77 * @param size - pointer to hold size of firmware\r
78 *\r
79 * returns - status of function execution\r
80 *\r
81 */\r
82 \r
83 int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size) {\r
84 int idx;\r
85 for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));\r
86 idx++) {\r
87 if (!env_strncmp((char *) fw_table[idx].name, fw_name,\r
88 sizeof(fw_table[idx].name))) {\r
89 *start_addr = fw_table[idx].start_addr;\r
90 *size = fw_table[idx].end_addr - fw_table[idx].start_addr + 1;\r
91 return 0;\r
92 }\r
93 }\r
94 return -1;\r
95 }