1 /*
2  * dspbridge/mpu_driver/src/dynload/module_list.h
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * Copyright (C) 2008 Texas Instruments, Inc.
7  *
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.
11  *
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.
15  */
16 
17 /*
18  * This C header file gives the layout of the data structure created by the
19  * dynamic loader to describe the set of modules loaded into the DSP.
20  *
21  * Linked List Structure:
22  * ----------------------
23  * The data structure defined here is a singly-linked list.  The list
24  * represents the set of modules which are currently loaded in the DSP memory.
25  * The first entry in the list is a header record which contains a flag
26  * representing the state of the list.  The rest of the entries in the list
27  * are module records.
28  *
29  * Global symbol  _DLModules designates the first record in the list (i.e. the
30  * header record).  This symbol must be defined in any program that wishes to
31  * use DLLview plug-in.
32  *
33  * String Representation:
34  * ----------------------
35  * The string names of the module and its sections are stored in a block of
36  * memory which follows the module record itself.  The strings are ordered:
37  * module name first, followed by section names in order from the first
38  * section to the last.  String names are tightly packed arrays of 8-bit
39  * characters (two characters per 16-bit word on the C55x).  Strings are
40  * zero-byte-terminated.
41  *
42  * Creating and updating the list:
43  * -------------------------------
44  * Upon loading a new module into the DSP memory the dynamic loader inserts a
45  * new module record as the first module record in the list.  The fields of
46  * this module record are initialized to reflect the properties of the module.
47  * The dynamic loader does NOT increment the flag/counter in the list's header
48  * record.
49  *
50  * Upon unloading a module from the DSP memory the dynamic loader removes the
51  * module's record from this list.  The dynamic loader also increments the
52  * flag/counter in the list's header record to indicate that the list has been
53  * changed.
54  */
55 
56 #ifndef _MODULE_LIST_H_
57 #define _MODULE_LIST_H_
58 
59 #include <linux/types.h>
60 
61 /* Global pointer to the modules_header structure */
62 #define MODULES_HEADER "_DLModules"
63 #define MODULES_HEADER_NO_UNDERSCORE "DLModules"
64 
65 /* Initial version number */
66 #define INIT_VERSION 1
67 
68 /* Verification number -- to be recorded in each module record */
69 #define VERIFICATION 0x79
70 
71 /* forward declarations */
72 struct dll_module;
73 struct dll_sect;
74 
75 /* the first entry in the list is the modules_header record;
76  * its address is contained in the global _DLModules pointer */
77 struct modules_header {
78 
79 	/*
80 	 * Address of the first dll_module record in the list or NULL.
81 	 * Note: for C55x this is a word address (C55x data is
82 	 * word-addressable)
83 	 */
84 	u32 first_module;
85 
86 	/* Combined storage size (in target addressable units) of the
87 	 * dll_module record which follows this header record, or zero
88 	 * if the list is empty.  This size includes the module's string table.
89 	 * Note: for C55x the unit is a 16-bit word */
90 	u16 first_module_size;
91 
92 	/* Counter is incremented whenever a module record is removed from
93 	 * the list */
94 	u16 update_flag;
95 
96 };
97 
98 /* for each 32-bits in above structure, a bitmap, LSB first, whose bits are:
99  * 0 => a 32-bit value, 1 => 2 16-bit values */
100 /* swapping bitmap for type modules_header */
101 #define MODULES_HEADER_BITMAP 0x2
102 
103 /* information recorded about each section in a module */
104 struct dll_sect {
105 
106 	/* Load-time address of the section.
107 	 * Note: for C55x this is a byte address for program sections, and
108 	 * a word address for data sections.  C55x program memory is
109 	 * byte-addressable, while data memory is word-addressable. */
110 	u32 sect_load_adr;
111 
112 	/* Run-time address of the section.
113 	 * Note 1: for C55x this is a byte address for program sections, and
114 	 * a word address for data sections.
115 	 * Note 2: for C55x two most significant bits of this field indicate
116 	 * the section type: '00' for a code section, '11' for a data section
117 	 * (C55 addresses are really only 24-bits wide). */
118 	u32 sect_run_adr;
119 
120 };
121 
122 /* the rest of the entries in the list are module records */
123 struct dll_module {
124 
125 	/* Address of the next dll_module record in the list, or 0 if this is
126 	 * the last record in the list.
127 	 * Note: for C55x this is a word address (C55x data is
128 	 * word-addressable) */
129 	u32 next_module;
130 
131 	/* Combined storage size (in target addressable units) of the
132 	 * dll_module record which follows this one, or zero if this is the
133 	 * last record in the list.  This size includes the module's string
134 	 * table.
135 	 * Note: for C55x the unit is a 16-bit word. */
136 	u16 next_module_size;
137 
138 	/* version number of the tooling; set to INIT_VERSION for Phase 1 */
139 	u16 version;
140 
141 	/* the verification word; set to VERIFICATION */
142 	u16 verification;
143 
144 	/* Number of sections in the sects array */
145 	u16 num_sects;
146 
147 	/* Module's "unique" id; copy of the timestamp from the host
148 	 * COFF file */
149 	u32 timestamp;
150 
151 	/* Array of num_sects elements of the module's section records */
152 	struct dll_sect sects[1];
153 };
154 
155 /* for each 32 bits in above structure, a bitmap, LSB first, whose bits are:
156  * 0 => a 32-bit value, 1 => 2 16-bit values */
157 #define DLL_MODULE_BITMAP 0x6	/* swapping bitmap for type dll_module */
158 
159 #endif /* _MODULE_LIST_H_ */
160