4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Copyright (C) 2005-2006 Texas Instruments, Inc.
8 * This package is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * Bit masks for dbl_flags.
23 #define DBLL_NOLOAD 0x0 /* Don't load symbols, code, or data */
24 #define DBLL_SYMB 0x1 /* load symbols */
25 #define DBLL_CODE 0x2 /* load code */
26 #define DBLL_DATA 0x4 /* load data */
27 #define DBLL_DYNAMIC 0x8 /* dynamic load */
28 #define DBLL_BSS 0x20 /* Unitialized section */
30 #define DBLL_MAXPATHLENGTH 255
33 * ======== DBLL_Target ========
39 * ======== dbll_flags ========
40 * Specifies whether to load code, data, or symbols
42 typedef s32 dbll_flags
;
45 * ======== DBLL_Library ========
48 struct dbll_library_obj
;
51 * ======== dbll_sect_info ========
52 * For collecting info on overlay sections
54 struct dbll_sect_info
{
55 const char *name
; /* name of section */
56 u32 sect_run_addr
; /* run address of section */
57 u32 sect_load_addr
; /* load address of section */
58 u32 size
; /* size of section (target MAUs) */
59 dbll_flags type
; /* Code, data, or BSS */
63 * ======== dbll_sym_val ========
64 * (Needed for dynamic load library)
71 * ======== dbll_alloc_fxn ========
72 * Allocate memory function. Allocate or reserve (if reserved == TRUE)
73 * "size" bytes of memory from segment "space" and return the address in
74 * *dsp_address (or starting at *dsp_address if reserve == TRUE). Returns 0 on
75 * success, or an error code on failure.
77 typedef s32(*dbll_alloc_fxn
) (void *hdl
, s32 space
, u32 size
, u32 align
,
78 u32
*dsp_address
, s32 seg_id
, s32 req
,
82 * ======== dbll_close_fxn ========
84 typedef s32(*dbll_f_close_fxn
) (void *);
87 * ======== dbll_free_fxn ========
88 * Free memory function. Free, or unreserve (if reserved == TRUE) "size"
89 * bytes of memory from segment "space"
91 typedef bool(*dbll_free_fxn
) (void *hdl
, u32 addr
, s32 space
, u32 size
,
95 * ======== dbll_f_open_fxn ========
97 typedef void *(*dbll_f_open_fxn
) (const char *, const char *);
100 * ======== dbll_log_write_fxn ========
101 * Function to call when writing data from a section, to log the info.
102 * Can be NULL if no logging is required.
104 typedef int(*dbll_log_write_fxn
) (void *handle
,
105 struct dbll_sect_info
*sect
, u32 addr
,
109 * ======== dbll_read_fxn ========
111 typedef s32(*dbll_read_fxn
) (void *, size_t, size_t, void *);
114 * ======== dbll_seek_fxn ========
116 typedef s32(*dbll_seek_fxn
) (void *, long, int);
119 * ======== dbll_sym_lookup ========
120 * Symbol lookup function - Find the symbol name and return its value.
123 * handle - Opaque handle
124 * parg - Opaque argument.
125 * name - Name of symbol to lookup.
126 * sym - Location to store address of symbol structure.
129 * TRUE: Success (symbol was found).
130 * FALSE: Failed to find symbol.
132 typedef bool(*dbll_sym_lookup
) (void *handle
, void *parg
, void *rmm_handle
,
133 const char *name
, struct dbll_sym_val
** sym
);
136 * ======== dbll_tell_fxn ========
138 typedef s32(*dbll_tell_fxn
) (void *);
141 * ======== dbll_write_fxn ========
142 * Write memory function. Write "n" HOST bytes of memory to segment "mtype"
143 * starting at address "dsp_address" from the buffer "buf". The buffer is
144 * formatted as an array of words appropriate for the DSP.
146 typedef s32(*dbll_write_fxn
) (void *hdl
, u32 dsp_address
, void *buf
,
150 * ======== dbll_attrs ========
153 dbll_alloc_fxn alloc
;
155 void *rmm_handle
; /* Handle to pass to alloc, free functions */
156 dbll_write_fxn write
;
157 void *input_params
; /* Handle to pass to write, cinit function */
159 dbll_log_write_fxn log_write
;
160 void *log_write_handle
;
162 /* Symbol matching function and handle to pass to it */
163 dbll_sym_lookup sym_lookup
;
168 * These file manipulation functions should be compatible with the
169 * "C" run time library functions of the same name.
171 s32(*fread
) (void *, size_t, size_t, void *);
172 s32(*fseek
) (void *, long, int);
173 s32(*ftell
) (void *);
174 s32(*fclose
) (void *);
175 void *(*fopen
) (const char *, const char *);
179 * ======== dbll_close ========
180 * Close library opened with dbll_open.
182 * lib - Handle returned from dbll_open().
189 typedef void (*dbll_close_fxn
) (struct dbll_library_obj
*library
);
192 * ======== dbll_create ========
193 * Create a target object, specifying the alloc, free, and write functions.
195 * target_obj - Location to store target handle on output.
196 * pattrs - Attributes.
199 * -ENOMEM: Memory allocation failed.
203 * target_obj != NULL;
205 * Success: *target_obj != NULL.
206 * Failure: *target_obj == NULL.
208 typedef int(*dbll_create_fxn
) (struct dbll_tar_obj
**target_obj
,
209 struct dbll_attrs
*attrs
);
212 * ======== dbll_delete ========
213 * Delete target object and free resources for any loaded libraries.
215 * target - Handle returned from DBLL_Create().
222 typedef void (*dbll_delete_fxn
) (struct dbll_tar_obj
*target
);
225 * ======== dbll_exit ========
226 * Discontinue use of DBL module.
234 typedef void (*dbll_exit_fxn
) (void);
237 * ======== dbll_get_addr ========
238 * Get address of name in the specified library.
240 * lib - Handle returned from dbll_open().
241 * name - Name of symbol
242 * sym_val - Location to store symbol address on output.
245 * FALSE: Symbol not found.
253 typedef bool(*dbll_get_addr_fxn
) (struct dbll_library_obj
*lib
, char *name
,
254 struct dbll_sym_val
**sym_val
);
257 * ======== dbll_get_attrs ========
258 * Retrieve the attributes of the target.
260 * target - Handle returned from DBLL_Create().
261 * pattrs - Location to store attributes on output.
269 typedef void (*dbll_get_attrs_fxn
) (struct dbll_tar_obj
*target
,
270 struct dbll_attrs
*attrs
);
273 * ======== dbll_get_c_addr ========
274 * Get address of "C" name on the specified library.
276 * lib - Handle returned from dbll_open().
277 * name - Name of symbol
278 * sym_val - Location to store symbol address on output.
281 * FALSE: Symbol not found.
289 typedef bool(*dbll_get_c_addr_fxn
) (struct dbll_library_obj
*lib
, char *name
,
290 struct dbll_sym_val
**sym_val
);
293 * ======== dbll_get_sect ========
294 * Get address and size of a named section.
296 * lib - Library handle returned from dbll_open().
297 * name - Name of section.
298 * paddr - Location to store section address on output.
299 * psize - Location to store section size on output.
302 * -ENXIO: Section not found.
311 typedef int(*dbll_get_sect_fxn
) (struct dbll_library_obj
*lib
,
312 char *name
, u32
* addr
, u32
* size
);
315 * ======== dbll_init ========
316 * Initialize DBL module.
325 * Failure: refs >= 0.
327 typedef bool(*dbll_init_fxn
) (void);
330 * ======== dbll_load ========
331 * Load library onto the target.
334 * lib - Library handle returned from dbll_open().
335 * flags - Load code, data and/or symbols.
336 * attrs - May contain alloc, free, and write function.
337 * entry_pt - Location to store program entry on output.
340 * -EBADF: File read failed.
341 * -EILSEQ: Failure in dynamic loader library.
348 typedef int(*dbll_load_fxn
) (struct dbll_library_obj
*lib
,
350 struct dbll_attrs
*attrs
, u32
*entry
);
353 * ======== dbll_load_sect ========
354 * Load a named section from an library (for overlay support).
356 * lib - Handle returned from dbll_open().
357 * sec_name - Name of section to load.
358 * attrs - Contains write function and handle to pass to it.
361 * -ENXIO: Section not found.
362 * -ENOSYS: Function not implemented.
367 * attrs->write != NULL.
370 typedef int(*dbll_load_sect_fxn
) (struct dbll_library_obj
*lib
,
372 struct dbll_attrs
*attrs
);
375 * ======== dbll_open ========
376 * dbll_open() returns a library handle that can be used to load/unload
377 * the symbols/code/data via dbll_load()/dbll_unload().
379 * target - Handle returned from dbll_create().
380 * file - Name of file to open.
381 * flags - If flags & DBLL_SYMB, load symbols.
382 * lib_obj - Location to store library handle on output.
385 * -ENOMEM: Memory allocation failure.
386 * -EBADF: File open/read failure.
387 * Unable to determine target type.
393 * dbll_attrs fopen function non-NULL.
395 * Success: Valid *lib_obj.
396 * Failure: *lib_obj == NULL.
398 typedef int(*dbll_open_fxn
) (struct dbll_tar_obj
*target
, char *file
,
400 struct dbll_library_obj
**lib_obj
);
403 * ======== dbll_read_sect ========
404 * Read COFF section into a character buffer.
406 * lib - Library handle returned from dbll_open().
407 * name - Name of section.
408 * pbuf - Buffer to write section contents into.
412 * -ENXIO: Named section does not exists.
421 typedef int(*dbll_read_sect_fxn
) (struct dbll_library_obj
*lib
,
422 char *name
, char *content
,
426 * ======== dbll_set_attrs ========
427 * Set the attributes of the target.
429 * target - Handle returned from dbll_create().
430 * pattrs - New attributes.
438 typedef void (*dbll_set_attrs_fxn
) (struct dbll_tar_obj
*target
,
439 struct dbll_attrs
*attrs
);
442 * ======== dbll_unload ========
443 * Unload library loaded with dbll_load().
445 * lib - Handle returned from dbll_open().
446 * attrs - Contains free() function and handle to pass to it.
453 typedef void (*dbll_unload_fxn
) (struct dbll_library_obj
*library
,
454 struct dbll_attrs
*attrs
);
457 * ======== dbll_unload_sect ========
458 * Unload a named section from an library (for overlay support).
460 * lib - Handle returned from dbll_open().
461 * sec_name - Name of section to load.
462 * attrs - Contains free() function and handle to pass to it.
465 * -ENXIO: Named section not found.
473 typedef int(*dbll_unload_sect_fxn
) (struct dbll_library_obj
*lib
,
475 struct dbll_attrs
*attrs
);
478 dbll_close_fxn close_fxn
;
479 dbll_create_fxn create_fxn
;
480 dbll_delete_fxn delete_fxn
;
481 dbll_exit_fxn exit_fxn
;
482 dbll_get_attrs_fxn get_attrs_fxn
;
483 dbll_get_addr_fxn get_addr_fxn
;
484 dbll_get_c_addr_fxn get_c_addr_fxn
;
485 dbll_get_sect_fxn get_sect_fxn
;
486 dbll_init_fxn init_fxn
;
487 dbll_load_fxn load_fxn
;
488 dbll_load_sect_fxn load_sect_fxn
;
489 dbll_open_fxn open_fxn
;
490 dbll_read_sect_fxn read_sect_fxn
;
491 dbll_set_attrs_fxn set_attrs_fxn
;
492 dbll_unload_fxn unload_fxn
;
493 dbll_unload_sect_fxn unload_sect_fxn
;
496 #endif /* DBLDEFS_ */