1 /****************************************************************************/
2 /* MAIN.C - Skeleton Driver for COFF Loader Version 6.00 4/96 */
3 /****************************************************************************/
4 /* */
5 /* General: This module is a skeleton driver for a standalone COFF */
6 /* loader. This file is NOT part of the generic loader, but */
7 /* provides a sample interface to it that can provide a basis */
8 /* for a specific loader. YOU MUST CUSTOMIZE THIS PROGRAM */
9 /* FOR YOUR APPLICATION. In particular, you must write the */
10 /* function 'mem_write()' which is the low-level function to */
11 /* load target memory. */
12 /* */
13 /* Refer to the documentation provided with the loader for */
14 /* details on how to interface with it. */
15 /* */
16 /* Usage: cload <-options> filename */
17 /* Options: -b clear .bss section */
18 /* -q quiet mode (no banner) */
19 /* -r xxxx relocate by xxxx */
20 /* */
21 /*--------------------------------------------------------------------------*/
22 /* Functions defined in this module: */
23 /* */
24 /* main() - Main driver for loader. */
25 /* mem_write() - Load a buffer of raw data to the target. */
26 /* set_reloc_amount() - Determine relocation amount for each section. */
27 /* lookup_sym() - Stub for symbol lookup routine. */
28 /* myalloc() - Application version of 'malloc()'. */
29 /* mralloc() - Application version of 'realloc()'. */
30 /* load_msg() - Called by loader to write debug messages. */
31 /* */
32 /****************************************************************************/
33 #include "header.h"
35 #define READ_BIN "rb" /* HOST-SPECIFIC */
37 unsigned int reloc = 0; /* RELOCATION AMOUNT */
39 void mem_copy(unsigned char* dst, unsigned char* src, int nbytes)
40 {
41 int i = 0;
42 for(i = 0; i<nbytes; i++)
43 *(dst+i) = *(src+i);
44 }
46 /****************************************************************************/
47 /* */
48 /* MEM_WRITE() - Load a buffer of raw data to the target. */
49 /* */
50 /* THIS FUNCTION MUST BE CUSTOMIZED FOR YOUR APPLICATION ! */
51 /* */
52 /* (As supplied, this function simply dumps the data out to the screen.) */
53 /* */
54 /****************************************************************************/
55 int mem_write(unsigned char *buffer, /* POINTER TO DATA BUFFER */
56 unsigned int nbytes, /* NUMBER OF 8-BIT BYTES */
57 T_ADDR addr, /* TARGET DESTINATION ADDRESS */
58 unsigned char page) /* TARGET DESTINATION PAGE */
59 {
60 /*-----------------------------------------------------------------------*/
61 /* INSERT CUSTOM CODE HERE TO LOAD TARGET MEMORY. */
62 /*-----------------------------------------------------------------------*/
63 mem_copy((void*)addr, (void*)buffer, nbytes);
64 return 1;
65 }
68 /****************************************************************************/
69 /* */
70 /* SET_RELOC_AMOUNT() - Determine relocation amount for each section. */
71 /* */
72 /****************************************************************************/
73 int set_reloc_amount()
74 {
75 int i;
77 for (i = 0; i< n_sections; ++i) reloc_amount[i] = reloc;
78 return 1;
79 }
82 /****************************************************************************/
83 /* */
84 /* LOOKUP_SYM() - Stub for symbol lookup routine. */
85 /* */
86 /****************************************************************************/
87 void lookup_sym(int indx, SYMENT *sym, AUXENT *aux)
88 {}
91 /****************************************************************************/
92 /* */
93 /* LOAD_SYMS() - Stub for symbol load routine. This routine is only called */
94 /* if the global flag 'need_symbols' is TRUE. */
95 /* */
96 /****************************************************************************/
97 int load_syms(int need_reloc)
98 {
99 return 1;
100 }