1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32 33 34 35 36
37
38 import xdc.runtime.Error;
39 import xdc.runtime.Assert;
40 import xdc.runtime.IGateProvider;
41 import ti.sdo.utils.NameServer;
42
43 /*!
44 * DriverTable module
45 *
46 * This module maintains a table of {@link IDriver#Handle}. Other modules can
47 * lookup these handles by name and open channels for IO. The {@link Stream}
48 * module will open channels using this table. All names in this table have to
49 * be unique.
50 *
51 * This module allows addition of IDriver handles into the table at
52 * configuration time as well as at runtime. However, the total number of
53 * runtime entries have to be decided at configuration time. There is no limit
54 * to entries added statically.
55 *
56 * This module uses {@link ti.sdo.utils.NameServer} to maintain its table
57 */
58
59 module DriverTable {
60 /*!
61 * Max runtime entries that can be added.
62 *
63 * Currently this module requires total number of entries that need
64 * to be added at runtime to be identified at configuration time.
65 */
66 config UInt maxRuntimeEntries = 0;
67
68 /*!
69 * Gate used to make the table thread safe.
70 */
71 config IGateProvider.Handle gate = null;
72
73 /*!
74 * Length, in MAUs, of the name field in the table.
75 */
76 config UInt maxNameLen = 16;
77
78 /*!
79 * Section name is used to place the IDriver table.
80 */
81 metaonly config String tableSection = null;
82
83 /*!
84 * ======== add ========
85 * Add IDriver handle to the table at runtime.
86 *
87 * Will raise an error when name already exists in table.
88 * This API is not thread safe. Set {@link #gate} parameter
89 * to protect table if called from multiple threads.
90 *
91 * @param(name) name of entry
92 * @param(driverHandle) {@link IDriver#Handle}
93 * @param(eb) Error Block
94 */
95 Void add(String name, IDriver.Handle driverHandle, Error.Block *eb);
96
97 /*!
98 * ======== addMeta ========
99 * Add to IDriver handle to the table at configuration time.
100 *
101 * @param(name) name of entry
102 * @param(driverHandle) {@link IDriver#Handle}
103 */
104 metaonly Void addMeta(String name, IDriver.Handle driverHandle);
105
106 /*!
107 * ======== remove ========
108 * Remove entry from IDriver table at runtime.
109 *
110 * Will raise an error when name not found in table
111 * This API is not thread safe. Set {@link #gate} parameter
112 * to protect table if called from multiple threads.
113 *
114 * @param(name) name of entry
115 * @param(eb) error block
116 */
117 Void remove(String name, Error.Block *eb);
118
119 /*!
120 * ======== match ========
121 * @_nodoc
122 * match entry in IDriver table.
123 *
124 * This function matches the name with table entries and writes to
125 * the handle if it finds a match. If entry is not found it sets
126 * handle to null. It returns length matched.
127 * This API is not thread safe. Set {@link #gate} parameter
128 * to protect table if called from multiple threads.
129 *
130 * @param(name) name of entry
131 * @param(handle) pointer to IDriver handle.
132 * @param(eb) error block
133 * @b(returns) length matched
134 */
135 Int match(String name, IDriver.Handle *handle, Error.Block *eb);
136
137 internal:
138
139 /*!
140 * Structure of entry in metaonly table
141 */
142 struct Entry {
143 String name;
144 Ptr handle;
145 };
146
147 /*!
148 * Array for all statically configured table entries
149 */
150 metaonly config Entry staticEntries[];
151
152 struct Module_State {
153 NameServer.Handle drvTable;
154 };
155 }
156 157 158 159
160