98aa8ac0083c7f196edeea472fd678a2647db4a1
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: IBL wrapper for the coff loader
40 *****************************************************************************
41 * FILE NAME: osal.c
42 *
43 * DESCRIPTION: Provides a boot wrapper to attach the coff loader
44 * to the IBL.
45 *
46 *****************************************************************************/
47 #include "types.h"
48 #include "ibl.h"
49 #include "iblloc.h"
50 #include "header.h"
53 /*****************************************************************************
54 * FUNCTION PURPOSE: The main wrapper
55 *****************************************************************************
56 * DESCRIPTION: Attaches the coff loader to the IBL. The input parameters
57 * are associated with globals defined in cload.c.
58 *****************************************************************************/
59 void iblBootCoff (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *ientry_point)
60 {
62 /* Fin is declared as a FILE * in cload.c In osal.h FILE is
63 * defined to be BOOT_MODULE_FXN_TABLE, and reads/seeks
64 * are defined (in osal.h) to call through the BOOT_MODULE_FXN_TABLE
65 * calls. */
66 fin = bootFxn;
68 /* cload is the main coff loader function. It returns 0 on success.
69 * The entry point will be in the global entry_point declared in
70 * cload.c */
71 if (cload () == 0)
72 *ientry_point = entry_point;
73 else
74 *ientry_point = 0;
76 }
79 /******************************************************************************
80 * FUNCTION PURPOSE: Determine if a file could be a coff file
81 ******************************************************************************
82 * DESCRIPTION: Examines the magic number and returns TRUE if it is one of
83 * the coff numbers (different numbers for different versions
84 ******************************************************************************/
85 bool iblIsCoff (Uint16 cv)
86 {
87 if (ISCOFF(cv))
88 return (TRUE);
90 /* Try an endian swap an recheck */
91 cv = ((cv >> 8) & 0x00ff) | ((cv << 8) & 0xff00);
92 if (ISCOFF(cv))
93 return (TRUE);
95 return (FALSE);
97 }
99 /******************************************************************************
100 * This is copied directly from cload_main.c from the original source
101 ******************************************************************************/
102 unsigned int reloc = 0; /* RELOCATION AMOUNT */
103 int set_reloc_amount()
104 {
105 int i;
107 for (i = 0; i< n_sections; ++i) reloc_amount[i] = reloc;
108 return 1;
109 }