4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Code management module for DSPs. This module provides an interface
7 * interface for loading both static and dynamic code objects onto DSP
10 * Copyright (C) 2005-2006 Texas Instruments, Inc.
12 * This package is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 #include <dspbridge/dblldefs.h>
26 #define COD_MAXPATHLENGTH 255
27 #define COD_TRACEBEG "SYS_PUTCBEG"
28 #define COD_TRACEEND "SYS_PUTCEND"
29 #define COD_TRACECURPOS "BRIDGE_SYS_PUTC_current"
31 #define COD_NOLOAD DBLL_NOLOAD
32 #define COD_SYMB DBLL_SYMB
34 /* COD code manager handle */
37 /* COD library handle */
38 struct cod_libraryobj;
41 * Function prototypes for writing memory to a DSP system, allocating
42 * and freeing DSP memory.
44 typedef u32(*cod_writefxn) (void *priv_ref, u32 dsp_add,
45 void *pbuf, u32 ul_num_bytes, u32 mem_space);
48 * ======== cod_close ========
50 * Close a library opened with cod_open().
52 * lib - Library handle returned by cod_open().
56 * COD module initialized.
61 extern void cod_close(struct cod_libraryobj *lib);
64 * ======== cod_create ========
66 * Create an object to manage code on a DSP system. This object can be
67 * used to load an initial program image with arguments that can later
68 * be expanded with dynamically loaded object files.
69 * Symbol table information is managed by this object and can be retrieved
70 * using the cod_get_sym_value() function.
72 * manager: created manager object
73 * str_zl_file: ZL DLL filename, of length < COD_MAXPATHLENGTH.
76 * -ESPIPE: ZL_Create failed.
77 * -ENOSYS: attrs was not NULL. We don't yet support
78 * non default values of attrs.
80 * COD module initialized.
84 extern int cod_create(struct cod_manager **mgr,
88 * ======== cod_delete ========
90 * Delete a code manager object.
92 * cod_mgr_obj: handle of manager to be deleted
96 * COD module initialized.
100 extern void cod_delete(struct cod_manager *cod_mgr_obj);
103 * ======== cod_exit ========
105 * Discontinue usage of the COD module.
113 * Resources acquired in cod_init(void) are freed.
115 extern void cod_exit(void);
118 * ======== cod_get_base_lib ========
120 * Get handle to the base image DBL library.
122 * cod_mgr_obj: handle of manager to be deleted
123 * plib: location to store library handle on output.
127 * COD module initialized.
132 extern int cod_get_base_lib(struct cod_manager *cod_mgr_obj,
133 struct dbll_library_obj **plib);
136 * ======== cod_get_base_name ========
138 * Get the name of the base image DBL library.
140 * cod_mgr_obj: handle of manager to be deleted
141 * sz_name: location to store library name on output.
142 * usize: size of name buffer.
145 * -EPERM: Buffer too small.
147 * COD module initialized.
152 extern int cod_get_base_name(struct cod_manager *cod_mgr_obj,
153 char *sz_name, u32 usize);
156 * ======== cod_get_entry ========
158 * Retrieve the entry point of a loaded DSP program image
160 * cod_mgr_obj: handle of manager to be deleted
161 * entry_pt: pointer to location for entry point
165 * COD module initialized.
170 extern int cod_get_entry(struct cod_manager *cod_mgr_obj,
174 * ======== cod_get_loader ========
176 * Get handle to the DBL loader.
178 * cod_mgr_obj: handle of manager to be deleted
179 * loader: location to store loader handle on output.
183 * COD module initialized.
188 extern int cod_get_loader(struct cod_manager *cod_mgr_obj,
189 struct dbll_tar_obj **loader);
192 * ======== cod_get_section ========
194 * Retrieve the starting address and length of a section in the COFF file
195 * given the section name.
197 * lib Library handle returned from cod_open().
198 * str_sect: name of the section, with or without leading "."
199 * addr: Location to store address.
200 * len: Location to store length.
203 * -ESPIPE: Symbols could not be found or have not been loaded onto
206 * COD module initialized.
212 * 0: *addr and *len contain the address and length of the
214 * else: *addr == 0 and *len == 0;
217 extern int cod_get_section(struct cod_libraryobj *lib,
219 u32 *addr, u32 *len);
222 * ======== cod_get_sym_value ========
224 * Retrieve the value for the specified symbol. The symbol is first
225 * searched for literally and then, if not found, searched for as a
228 * lib: library handle returned from cod_open().
229 * pstrSymbol: name of the symbol
230 * value: value of the symbol
233 * -ESPIPE: Symbols could not be found or have not been loaded onto
236 * COD module initialized.
242 extern int cod_get_sym_value(struct cod_manager *cod_mgr_obj,
243 char *str_sym, u32 * pul_value);
246 * ======== cod_init ========
248 * Initialize the COD module's private state.
252 * TRUE if initialized; FALSE if error occured.
255 * A requirement for each of the other public COD functions.
257 extern bool cod_init(void);
260 * ======== cod_load_base ========
262 * Load the initial program image, optionally with command-line arguments,
263 * on the DSP system managed by the supplied handle. The program to be
264 * loaded must be the first element of the args array and must be a fully
265 * qualified pathname.
267 * hmgr: manager to load the code with
268 * num_argc: number of arguments in the args array
269 * args: array of strings for arguments to DSP program
270 * write_fxn: board-specific function to write data to DSP system
271 * arb: arbitrary pointer to be passed as first arg to write_fxn
272 * envp: array of environment strings for DSP exec.
275 * -EBADF: Failed to open target code.
277 * COD module initialized.
285 extern int cod_load_base(struct cod_manager *cod_mgr_obj,
286 u32 num_argc, char *args[],
287 cod_writefxn pfn_write, void *arb,
291 * ======== cod_open ========
293 * Open a library for reading sections. Does not load or set the base.
295 * hmgr: manager to load the code with
296 * sz_coff_path: Coff file to open.
297 * flags: COD_NOLOAD (don't load symbols) or COD_SYMB (load
299 * lib_obj: Handle returned that can be used in calls to cod_close
300 * and cod_get_section.
303 * -EBADF: Failed to open target code.
305 * COD module initialized.
307 * flags == COD_NOLOAD || flags == COD_SYMB.
308 * sz_coff_path != NULL.
311 extern int cod_open(struct cod_manager *hmgr,
313 u32 flags, struct cod_libraryobj **lib_obj);
316 * ======== cod_open_base ========
318 * Open base image for reading sections. Does not load the base.
320 * hmgr: manager to load the code with
321 * sz_coff_path: Coff file to open.
322 * flags: Specifies whether to load symbols.
325 * -EBADF: Failed to open target code.
327 * COD module initialized.
329 * sz_coff_path != NULL.
332 extern int cod_open_base(struct cod_manager *hmgr, char *sz_coff_path,
336 * ======== cod_read_section ========
338 * Retrieve the content of a code section given the section name.
340 * cod_mgr_obj - manager in which to search for the symbol
341 * str_sect - name of the section, with or without leading "."
342 * str_content - buffer to store content of the section.
344 * 0: on success, error code on failure
345 * -ESPIPE: Symbols have not been loaded onto the board.
347 * COD module initialized.
350 * str_content != NULL;
352 * 0: *str_content stores the content of the named section.
354 extern int cod_read_section(struct cod_libraryobj *lib,
356 char *str_content, u32 content_size);