| 1265 | } |
| 1266 | |
| 1267 | static int list_channel(void) |
| 1268 | { |
| 1269 | rt_channel_t *channels; |
| 1270 | rt_ubase_t index, count; |
| 1271 | struct rt_object *object; |
| 1272 | struct rt_list_node *node; |
| 1273 | struct rt_object_information *information; |
| 1274 | |
| 1275 | RT_DEBUG_NOT_IN_INTERRUPT; |
| 1276 | |
| 1277 | const char *stat_strs[] = {"idle", "wait", "active"}; |
| 1278 | |
| 1279 | information = rt_object_get_information(RT_Object_Class_Channel); |
| 1280 | RT_ASSERT(information != RT_NULL); |
| 1281 | |
| 1282 | count = 0; |
| 1283 | rt_mutex_take(&_chn_obj_lock, RT_WAITING_FOREVER); |
| 1284 | /* get the count of IPC channels */ |
| 1285 | for (node = information->object_list.next; |
| 1286 | node != &(information->object_list); |
| 1287 | node = node->next) |
| 1288 | { |
| 1289 | count++; |
| 1290 | } |
| 1291 | rt_mutex_release(&_chn_obj_lock); |
| 1292 | |
| 1293 | if (count == 0) |
| 1294 | return 0; |
| 1295 | |
| 1296 | channels = (rt_channel_t *)rt_calloc(count, sizeof(rt_channel_t)); |
| 1297 | if (channels == RT_NULL) |
| 1298 | return 0; /* out of memory */ |
| 1299 | |
| 1300 | rt_mutex_take(&_chn_obj_lock, RT_WAITING_FOREVER); |
| 1301 | /* retrieve pointer of IPC channels */ |
| 1302 | for (index = 0, node = information->object_list.next; |
| 1303 | index < count && node != &(information->object_list); |
| 1304 | node = node->next) |
| 1305 | { |
| 1306 | object = rt_list_entry(node, struct rt_object, list); |
| 1307 | |
| 1308 | channels[index] = (rt_channel_t)object; |
| 1309 | index++; |
| 1310 | } |
| 1311 | rt_mutex_release(&_chn_obj_lock); |
| 1312 | |
| 1313 | rt_kprintf(" channel state\n"); |
| 1314 | rt_kprintf("-------- -------\n"); |
| 1315 | for (index = 0; index < count; index++) |
| 1316 | { |
| 1317 | if (channels[index] != RT_NULL) |
| 1318 | { |
| 1319 | rt_kprintf("%-*.s", RT_NAME_MAX, channels[index]->parent.parent.name); |
| 1320 | if (channels[index]->stat < 3) |
| 1321 | rt_kprintf(" %s\n", stat_strs[channels[index]->stat]); |
| 1322 | } |
| 1323 | } |
| 1324 |
nothing calls this directly
no test coverage detected