659871ca857211ecbff6fb231bb58438dd67e164
1 /*****************************************************************************
2 * FILE PURPOSE: IBL wrapper for the coff loader
3 *****************************************************************************
4 * FILE NAME: osal.c
5 *
6 * DESCRIPTION: Provides a boot wrapper to attach the coff loader
7 * to the IBL.
8 *
9 *****************************************************************************/
10 #include "types.h"
11 #include "ibl.h"
12 #include "iblloc.h"
13 #include "header.h"
16 /*****************************************************************************
17 * FUNCTION PURPOSE: The main wrapper
18 *****************************************************************************
19 * DESCRIPTION: Attaches the coff loader to the IBL. The input parameters
20 * are associated with globals defined in cload.c.
21 *****************************************************************************/
22 void iblBootCoff (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *ientry_point)
23 {
25 /* Fin is declared as a FILE * in cload.c In osal.h FILE is
26 * defined to be BOOT_MODULE_FXN_TABLE, and reads/seeks
27 * are defined (in osal.h) to call through the BOOT_MODULE_FXN_TABLE
28 * calls. */
29 fin = bootFxn;
31 /* cload is the main coff loader function. It returns 0 on success.
32 * The entry point will be in the global entry_point declared in
33 * cload.c */
34 if (cload () == 0)
35 *ientry_point = entry_point;
36 else
37 *ientry_point = 0;
39 }
42 /******************************************************************************
43 * FUNCTION PURPOSE: Determine if a file could be a coff file
44 ******************************************************************************
45 * DESCRIPTION: Examines the magic number and returns TRUE if it is one of
46 * the coff numbers (different numbers for different versions
47 ******************************************************************************/
48 bool iblIsCoff (Uint16 cv)
49 {
50 if (ISCOFF(cv))
51 return (TRUE);
53 /* Try an endian swap an recheck */
54 cv = ((cv >> 8) & 0x00ff) | ((cv << 8) & 0xff00);
55 if (ISCOFF(cv))
56 return (TRUE);
58 return (FALSE);
60 }
62 /******************************************************************************
63 * This is copied directly from cload_main.c from the original source
64 ******************************************************************************/
65 unsigned int reloc = 0; /* RELOCATION AMOUNT */
66 int set_reloc_amount()
67 {
68 int i;
70 for (i = 0; i< n_sections; ++i) reloc_amount[i] = reloc;
71 return 1;
72 }