Changeset 238 for soft/giet_vm/sys/sys_handler.c
- Timestamp:
- May 29, 2013, 1:24:09 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sys/sys_handler.c
r237 r238 31 31 &_gcd_read, /* 0x07 */ 32 32 &_heap_info, /* 0x08 */ 33 &_ get_proc_task_id,/* 0x09 */34 &_g et_global_task_id,/* 0x0A */33 &_local_task_id, /* 0x09 */ 34 &_global_task_id, /* 0x0A */ 35 35 &_sys_ukn, /* 0x0B */ 36 36 &_sys_ukn, /* 0x0C */ … … 69 69 } 70 70 71 72 71 //////////////////////////////////////////////////////////////////////////// 73 72 // _exit() … … 77 76 unsigned int date = _proctime(); 78 77 unsigned int proc_id = _procid(); 79 unsigned int task_id = _get_ proc_task_id();78 unsigned int task_id = _get_context_slot(CTX_LTID_ID); 80 79 81 80 // print death message … … 91 90 92 91 // goes to sleeping state 93 _set_context_slot( task_id,CTX_RUN_ID, 0);92 _set_context_slot(CTX_RUN_ID, 0); 94 93 95 94 // deschedule … … 97 96 } 98 97 99 100 98 ////////////////////////////////////////////////////////////////////////////// 101 99 // _procid() … … 103 101 // Max number or processors is 1024. 104 102 ////////////////////////////////////////////////////////////////////////////// 105 unsigned int _procid() { 103 unsigned int _procid() 104 { 106 105 unsigned int ret; 107 106 asm volatile("mfc0 %0, $15, 1" : "=r" (ret)); … … 109 108 } 110 109 111 112 110 ////////////////////////////////////////////////////////////////////////////// 113 111 // _proctime() 114 112 // Access CP0 and returns current processor's elapsed clock cycles since boot. 115 113 ////////////////////////////////////////////////////////////////////////////// 116 unsigned int _proctime() { 114 unsigned int _proctime() 115 { 117 116 unsigned int ret; 118 117 asm volatile("mfc0 %0, $9" : "=r" (ret)); … … 120 119 } 121 120 122 123 121 ////////////////////////////////////////////////////////////////////////////// 124 122 // _procnumber() … … 126 124 // specified by the cluster_id argument. 127 125 ////////////////////////////////////////////////////////////////////////////// 128 unsigned int _procs_number(unsigned int cluster_id, unsigned int * buffer) { 126 unsigned int _procs_number(unsigned int cluster_id, 127 unsigned int* buffer) 128 { 129 129 mapping_header_t * header = (mapping_header_t *) &seg_mapping_base; 130 130 mapping_cluster_t * cluster = _get_cluster_base(header); … … 139 139 } 140 140 141 142 int _get_vobj(char * vspace_name, char * vobj_name, unsigned int vobj_type, mapping_vobj_t ** res_vobj) { 141 ///////////////////////////////////////////////////////////////////////////// 142 // _local_task_id() 143 // Returns current task local index. 144 ///////////////////////////////////////////////////////////////////////////// 145 unsigned int _local_task_id() 146 { 147 return _get_context_slot(CTX_LTID_ID); 148 } 149 150 ///////////////////////////////////////////////////////////////////////////// 151 // _global_task_id() 152 // Returns current task global index. 153 ///////////////////////////////////////////////////////////////////////////// 154 unsigned int _global_task_id() 155 { 156 return _get_context_slot(CTX_GTID_ID); 157 } 158 159 ///////////////////////////////////////////////////////////////////////////// 160 // _get_vobj() 161 // This function writes in res_vobj a pointer on a vobj 162 // identified by the (vspace_name / vobj_name ) couple. 163 // The vobj_type argument is here only for the purpose of checking . 164 // returns 0: success, else: failed. 165 ///////////////////////////////////////////////////////////////////////////// 166 int _get_vobj( char* vspace_name, 167 char* vobj_name, 168 unsigned int vobj_type, 169 mapping_vobj_t** res_vobj ) 170 { 143 171 mapping_header_t * header = (mapping_header_t *) &seg_mapping_base; 144 172 mapping_vspace_t * vspace = _get_vspace_base(header); 145 mapping_vobj_t * vobj = _get_vobj_base(header);173 mapping_vobj_t * vobj = _get_vobj_base(header); 146 174 147 175 unsigned int vspace_id; … … 149 177 150 178 // scan vspaces 151 for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) { 152 if (_strncmp( vspace[vspace_id].name, vspace_name, 31) == 0) { 179 for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) 180 { 181 if (_strncmp( vspace[vspace_id].name, vspace_name, 31) == 0) 182 { 153 183 // scan vobjs 154 184 for (vobj_id = vspace[vspace_id].vobj_offset; 155 185 vobj_id < (vspace[vspace_id].vobj_offset + vspace[vspace_id].vobjs); 156 vobj_id++) { 157 158 if (_strncmp(vobj[vobj_id].name, vobj_name, 31) == 0) { 159 if (vobj[vobj_id].type != vobj_type) { 186 vobj_id++) 187 { 188 if (_strncmp(vobj[vobj_id].name, vobj_name, 31) == 0) 189 { 190 if (vobj[vobj_id].type != vobj_type) 191 { 160 192 _get_lock(&_tty_put_lock); 161 193 _puts("*** Error in _get_obj: wrong type\n"); … … 176 208 } 177 209 178 179 210 ///////////////////////////////////////////////////////////////////////////// 180 211 // _vobj_get_vbase() … … 184 215 // returns 0: success, else: failed. 185 216 ///////////////////////////////////////////////////////////////////////////// 186 unsigned int _vobj_get_vbase( 187 char * vspace_name, 188 char * vobj_name, 189 unsigned int vobj_type, 190 unsigned int * vobj_vaddr) { 191 mapping_vobj_t * res_vobj; 192 unsigned int ret; 193 if ((ret = _get_vobj(vspace_name, vobj_name, vobj_type, &res_vobj))) { 217 unsigned int _vobj_get_vbase( char* vspace_name, 218 char* vobj_name, 219 unsigned int vobj_type, 220 unsigned int* vobj_vaddr ) 221 { 222 mapping_vobj_t* res_vobj; 223 unsigned int ret; 224 if ((ret = _get_vobj(vspace_name, vobj_name, vobj_type, &res_vobj))) 225 { 194 226 return ret; 195 227 } 196 197 228 *vobj_vaddr = res_vobj->vaddr; 198 229 return 0; 199 230 } 200 201 231 202 232 ///////////////////////////////////////////////////////////////////////////// … … 207 237 // returns 0: success, else: failed. 208 238 ///////////////////////////////////////////////////////////////////////////// 209 unsigned int _vobj_get_length( 210 char * vspace_name, 211 char * vobj_name, 212 unsigned int vobj_type, 213 unsigned int * vobj_length) { 214 239 unsigned int _vobj_get_length( char* vspace_name, 240 char* vobj_name, 241 unsigned int vobj_type, 242 unsigned int* vobj_length ) 243 { 215 244 mapping_vobj_t * res_vobj; 216 245 unsigned int ret; 217 if ((ret = _get_vobj(vspace_name, vobj_name, vobj_type, &res_vobj))) { 246 if ((ret = _get_vobj(vspace_name, vobj_name, vobj_type, &res_vobj))) 247 { 218 248 return ret; 219 249 } 220 221 250 *vobj_length = res_vobj->length; 222 223 251 return 0; 224 252 } … … 229 257 // This functions masks interruptions before calling _ctx_switch 230 258 // (They are usually masked when we receive a isr_switch interrupt 231 // because we execute isrs with interrupt masked)259 // because we execute ISRs with interrupt masked) 232 260 //////////////////////////////////////////////////////////////// 233 void _context_switch() { 261 void _context_switch() 262 { 234 263 _it_disable(); 235 264 _ctx_switch();
Note: See TracChangeset
for help on using the changeset viewer.