Changeset e309f77 in rtems
- Timestamp:
- 02/14/19 03:00:05 (5 years ago)
- Branches:
- 5, master
- Children:
- 3ecb207
- Parents:
- e214ff4b
- git-author:
- Chris Johns <chrisj@…> (02/14/19 03:00:05)
- git-committer:
- Chris Johns <chrisj@…> (02/14/19 22:55:16)
- Location:
- cpukit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/include/rtems/rtl/rtl-allocator.h
re214ff4b re309f77 46 46 47 47 /** 48 * Define the allocation command the loader requires. 49 */ 50 enum rtems_rtl_alloc_cmd { 51 RTEMS_RTL_ALLOC_NEW, /**< Allocate new memory. */ 52 RTEMS_RTL_ALLOC_DEL, /**< Delete allocated memory. */ 53 RTEMS_RTL_ALLOC_WR_ENABLE, /**< Enable writes to the memory. */ 54 RTEMS_RTL_ALLOC_WR_DISABLE, /**< Disable writes to the memory. */ 55 }; 56 57 /** 58 * The allocator command type. 59 */ 60 typedef enum rtems_rtl_alloc_cmd rtems_rtl_alloc_cmd; 61 62 /** 48 63 * The number of tags. 49 64 */ … … 54 69 * overridded for customised allocation schemes or memory maps. 55 70 * 56 * @param allocation If true the request is to allocate memory else free.71 * @param allocation The request command. 57 72 * @param tag The type of allocation request. 58 73 * @param address Pointer to the memory address. If an allocation the value is … … 64 79 * not used if deleting or freeing a previous allocation. 65 80 */ 66 typedef void (*rtems_rtl_allocator)( bool allocate,81 typedef void (*rtems_rtl_allocator)(rtems_rtl_alloc_cmd cmd, 67 82 rtems_rtl_alloc_tag tag, 68 83 void** address, … … 108 123 109 124 /** 125 * The Runtime Loader allocator enable write on a bloc of allocated memory. 126 * 127 * @param tag The type of allocation request. Must match the address. 128 * @param address The memory address to write enable. A NULL is ignored. 129 */ 130 void rtems_rtl_alloc_wr_enable (rtems_rtl_alloc_tag tag, void* address); 131 132 /** 133 * The Runtime Loader allocator disable write on a bloc of allocated memory. 134 * 135 * @param tag The type of allocation request. Must match the address. 136 * @param address The memory address to write disable. A NULL is ignored. 137 */ 138 void rtems_rtl_alloc_wr_disable (rtems_rtl_alloc_tag tag, void* address); 139 140 /** 110 141 * Hook the Runtime Loader allocatior. A handler can call the previous handler 111 142 * in the chain to use it for specific tags. The default handler uses the … … 137 168 void rtems_rtl_alloc_indirect_del (rtems_rtl_alloc_tag tag, 138 169 rtems_rtl_ptr* handle); 170 171 /** 172 * Return the default tag for text sections. 173 * 174 * @return The text tag. 175 */ 176 rtems_rtl_alloc_tag rtems_rtl_alloc_text_tag (void); 177 178 /** 179 * Return the default tag for const sections. 180 * 181 * @return The const tag. 182 */ 183 rtems_rtl_alloc_tag rtems_rtl_alloc_const_tag (void); 184 185 /** 186 * Return the default tag for exception sections. 187 * 188 * @return The eh tag. 189 */ 190 rtems_rtl_alloc_tag rtems_rtl_alloc_eh_tag (void); 191 192 /** 193 * Return the default tag for data sections. 194 * 195 * @return The data tag. 196 */ 197 rtems_rtl_alloc_tag rtems_rtl_alloc_data_tag (void); 198 199 /** 200 * Return the default tag for bss sections. 201 * 202 * @return The bss tag. 203 */ 204 rtems_rtl_alloc_tag rtems_rtl_alloc_bss_tag (void); 139 205 140 206 /** -
cpukit/libdl/rtl-alloc-heap.c
re214ff4b re309f77 19 19 20 20 void 21 rtems_rtl_alloc_heap ( bool allocate,21 rtems_rtl_alloc_heap (rtems_rtl_alloc_cmd cmd, 22 22 rtems_rtl_alloc_tag tag, 23 23 void** address, 24 24 size_t size) 25 25 { 26 if ( allocate)26 if (cmd == RTEMS_RTL_ALLOC_NEW) 27 27 *address = malloc (size); 28 else 28 else if (cmd == RTEMS_RTL_ALLOC_DEL) 29 29 { 30 30 free (*address); -
cpukit/libdl/rtl-alloc-heap.h
re214ff4b re309f77 26 26 * Allocator handler for the standard libc heap. 27 27 * 28 * @param allocation If true the request is to allocate memory else free.28 * @param cmd The allocation command. 29 29 * @param tag The type of allocation request. 30 30 * @param address Pointer to the memory address. If an allocation the value is … … 36 36 * not used if deleting or freeing a previous allocation. 37 37 */ 38 void rtems_rtl_alloc_heap( bool allocate,38 void rtems_rtl_alloc_heap(rtems_rtl_alloc_cmd cmd, 39 39 rtems_rtl_alloc_tag tag, 40 40 void** address, -
cpukit/libdl/rtl-allocator.c
re214ff4b re309f77 58 58 * allocator. 59 59 */ 60 if (rtl )61 rtl->allocator.allocator ( true, tag, &address, size);60 if (rtl != NULL) 61 rtl->allocator.allocator (RTEMS_RTL_ALLOC_NEW, tag, &address, size); 62 62 63 63 rtems_rtl_unlock (); … … 70 70 * Only zero the memory if asked to and the allocation was successful. 71 71 */ 72 if (address && zero)72 if (address != NULL && zero) 73 73 memset (address, 0, size); 74 74 … … 85 85 rtems_rtl_trace_tag_label (tag), address); 86 86 87 if (rtl && address) 88 rtl->allocator.allocator (false, tag, &address, 0); 87 if (rtl != NULL && address != NULL) 88 rtl->allocator.allocator (RTEMS_RTL_ALLOC_DEL, tag, &address, 0); 89 90 rtems_rtl_unlock (); 91 } 92 93 void 94 rtems_rtl_alloc_wr_enable (rtems_rtl_alloc_tag tag, void* address) 95 { 96 rtems_rtl_data* rtl = rtems_rtl_lock (); 97 98 if (rtems_rtl_trace (RTEMS_RTL_TRACE_ALLOCATOR)) 99 printf ("rtl: alloc: wr-enable: addr=%p\n", address); 100 101 if (rtl != NULL && address != NULL) 102 rtl->allocator.allocator (RTEMS_RTL_ALLOC_WR_ENABLE, 103 tag, 104 address, 105 0); 106 107 rtems_rtl_unlock (); 108 } 109 110 void 111 rtems_rtl_alloc_wr_disable (rtems_rtl_alloc_tag tag, void* address) 112 { 113 rtems_rtl_data* rtl = rtems_rtl_lock (); 114 115 if (rtems_rtl_trace (RTEMS_RTL_TRACE_ALLOCATOR)) 116 printf ("rtl: alloc: wr-enable: addr=%p\n", address); 117 118 if (rtl != NULL && address != NULL) 119 rtl->allocator.allocator (RTEMS_RTL_ALLOC_WR_DISABLE, 120 tag, 121 address, 122 0); 89 123 90 124 rtems_rtl_unlock (); … … 149 183 rtems_rtl_alloc_del (tag, &handle->pointer); 150 184 } 185 } 186 187 rtems_rtl_alloc_tag 188 rtems_rtl_alloc_text_tag (void) 189 { 190 return RTEMS_RTL_ALLOC_READ_EXEC; 191 } 192 193 rtems_rtl_alloc_tag 194 rtems_rtl_alloc_const_tag (void) 195 { 196 return RTEMS_RTL_ALLOC_READ; 197 } 198 199 rtems_rtl_alloc_tag 200 rtems_rtl_alloc_eh_tag (void) 201 { 202 return RTEMS_RTL_ALLOC_READ; 203 } 204 205 rtems_rtl_alloc_tag 206 rtems_rtl_alloc_data_tag (void) 207 { 208 return RTEMS_RTL_ALLOC_READ_WRITE; 209 } 210 211 rtems_rtl_alloc_tag 212 rtems_rtl_alloc_bss_tag (void) 213 { 214 return RTEMS_RTL_ALLOC_READ_WRITE; 151 215 } 152 216 … … 162 226 if (text_size) 163 227 { 164 *text_base = rtems_rtl_alloc_new ( RTEMS_RTL_ALLOC_READ_EXEC,228 *text_base = rtems_rtl_alloc_new (rtems_rtl_alloc_text_tag (), 165 229 text_size, false); 166 230 if (!*text_base) … … 172 236 if (const_size) 173 237 { 174 *const_base = rtems_rtl_alloc_new ( RTEMS_RTL_ALLOC_READ,238 *const_base = rtems_rtl_alloc_new (rtems_rtl_alloc_const_tag (), 175 239 const_size, false); 176 240 if (!*const_base) … … 184 248 if (eh_size) 185 249 { 186 *eh_base = rtems_rtl_alloc_new ( RTEMS_RTL_ALLOC_READ,250 *eh_base = rtems_rtl_alloc_new (rtems_rtl_alloc_eh_tag (), 187 251 eh_size, false); 188 252 if (!*eh_base) … … 196 260 if (data_size) 197 261 { 198 *data_base = rtems_rtl_alloc_new ( RTEMS_RTL_ALLOC_READ_WRITE,262 *data_base = rtems_rtl_alloc_new (rtems_rtl_alloc_data_tag (), 199 263 data_size, false); 200 264 if (!*data_base) … … 208 272 if (bss_size) 209 273 { 210 *bss_base = rtems_rtl_alloc_new ( RTEMS_RTL_ALLOC_READ_WRITE,274 *bss_base = rtems_rtl_alloc_new (rtems_rtl_alloc_bss_tag (), 211 275 bss_size, false); 212 276 if (!*bss_base) -
cpukit/libdl/rtl-obj.c
re214ff4b re309f77 1001 1001 static bool 1002 1002 rtems_rtl_obj_sections_loader (uint32_t mask, 1003 rtems_rtl_alloc_tag tag, 1003 1004 rtems_rtl_obj* obj, 1004 1005 int fd, … … 1014 1015 if (rtems_rtl_trace (RTEMS_RTL_TRACE_LOAD_SECT)) 1015 1016 printf ("rtl: loading section: mask:%08" PRIx32 " base:%p\n", mask, base); 1017 1018 rtems_rtl_alloc_wr_enable (tag, base); 1016 1019 1017 1020 while (!rtems_chain_is_tail (sections, node)) … … 1040 1043 { 1041 1044 sect->base = 0; 1045 rtems_rtl_alloc_wr_disable (tag, base); 1042 1046 return false; 1043 1047 } … … 1068 1072 } 1069 1073 1074 rtems_rtl_alloc_wr_disable (tag, base); 1075 1070 1076 return true; 1071 1077 } … … 1169 1175 */ 1170 1176 if (!rtems_rtl_obj_sections_loader (RTEMS_RTL_OBJ_SECT_TEXT, 1177 rtems_rtl_alloc_text_tag (), 1171 1178 obj, fd, obj->text_base, handler, data) || 1172 1179 !rtems_rtl_obj_sections_loader (RTEMS_RTL_OBJ_SECT_CONST, 1180 rtems_rtl_alloc_const_tag (), 1173 1181 obj, fd, obj->const_base, handler, data) || 1174 1182 !rtems_rtl_obj_sections_loader (RTEMS_RTL_OBJ_SECT_EH, 1183 rtems_rtl_alloc_eh_tag (), 1175 1184 obj, fd, obj->eh_base, handler, data) || 1176 1185 !rtems_rtl_obj_sections_loader (RTEMS_RTL_OBJ_SECT_DATA, 1186 rtems_rtl_alloc_data_tag (), 1177 1187 obj, fd, obj->data_base, handler, data) || 1178 1188 !rtems_rtl_obj_sections_loader (RTEMS_RTL_OBJ_SECT_BSS, 1189 rtems_rtl_alloc_bss_tag (), 1179 1190 obj, fd, obj->bss_base, handler, data)) 1180 1191 {
Note: See TracChangeset
for help on using the changeset viewer.