static int debug_read_ch(char *buf, int max) { void *shared; int n, i = 0; struct smd_alloc_elm *ch_tbl; unsigned ch_type; unsigned shared_size; ch_tbl = smem_find(ID_CH_ALLOC_TBL, sizeof(*ch_tbl) * 64); if (!ch_tbl) goto fail; for (n = 0; n < SMD_CHANNELS; n++) { ch_type = SMD_CHANNEL_TYPE(ch_tbl[n].type); if (is_word_access_ch(ch_type)) shared_size = sizeof(struct smd_half_channel_word_access); else shared_size = sizeof(struct smd_half_channel); shared = smem_find(ID_SMD_CHANNELS + n, 2 * shared_size + SMD_BUF_SIZE); if (shared == 0) continue; i += dump_ch(buf + i, max - i, n, shared, (shared + shared_size + SMD_BUF_SIZE), get_half_ch_funcs(ch_type), SMD_BUF_SIZE); } fail: return i; }
static int debug_read_alloc_tbl(char *buf, int max) { struct smd_alloc_elm *shared; int n, i = 0; shared = smem_find(ID_CH_ALLOC_TBL, sizeof(struct smd_alloc_elm[64])); if (!shared) return 0; for (n = 0; n < 64; n++) { i += scnprintf(buf + i, max - i, "name=%s cid=%d ch type=%d " "xfer type=%d ref_count=%d\n", shared[n].name, shared[n].cid, SMD_CHANNEL_TYPE(shared[n].type), SMD_XFER_TYPE(shared[n].type), shared[n].ref_count); } return i; }
/** * print_smd_ch_table - Print the current state of every valid SMD channel in a * specific SMD channel allocation table to a human * readable formatted output. * * @s: the sequential file to print to * @tbl: a valid pointer to the channel allocation table to print from * @num_tbl_entries: total number of entries in the table referenced by @tbl * @ch_base_id: the SMEM item id corresponding to the array of channel * structures for the channels found in @tbl * @fifo_base_id: the SMEM item id corresponding to the array of channel fifos * for the channels found in @tbl * @pid: processor id to use for any SMEM operations * @flags: flags to use for any SMEM operations */ static void print_smd_ch_table(struct seq_file *s, struct smd_alloc_elm *tbl, unsigned num_tbl_entries, unsigned ch_base_id, unsigned fifo_base_id, unsigned pid, unsigned flags) { void *half_ch; unsigned half_ch_size; uint32_t ch_type; void *buffer; unsigned buffer_size; int n; /* * formatted, human readable channel state output, ie: ID|CHANNEL NAME |T|PROC |STATE |FIFO SZ|RDPTR |WRPTR |FLAGS |DATAPEN ------------------------------------------------------------------------------- 00|DS |S|APPS |CLOSED |0x02000|0x00000|0x00000|dcCiwrsb|0x00000 | | |MDMSW|OPENING|0x02000|0x00000|0x00000|dcCiwrsb|0x00000 ------------------------------------------------------------------------------- */ seq_printf(s, "%2s|%-19s|%1s|%-5s|%-7s|%-7s|%-7s|%-7s|%-8s|%-7s\n", "ID", "CHANNEL NAME", "T", "PROC", "STATE", "FIFO SZ", "RDPTR", "WRPTR", "FLAGS", "DATAPEN"); seq_puts(s, "-------------------------------------------------------------------------------\n"); for (n = 0; n < num_tbl_entries; ++n) { if (strlen(tbl[n].name) == 0) continue; seq_printf(s, "%2u|%-19s|%s|", tbl[n].cid, tbl[n].name, smd_xfer_type_to_str(SMD_XFER_TYPE(tbl[n].type))); ch_type = SMD_CHANNEL_TYPE(tbl[n].type); if (is_word_access_ch(ch_type)) half_ch_size = sizeof(struct smd_half_channel_word_access); else half_ch_size = sizeof(struct smd_half_channel); half_ch = smem_find(ch_base_id + n, 2 * half_ch_size, pid, flags); buffer = smem_get_entry(fifo_base_id + n, &buffer_size, pid, flags); if (half_ch && buffer) print_half_ch_state(s, half_ch, get_half_ch_funcs(ch_type), buffer_size / 2, smd_edge_to_local_pid(ch_type)); seq_puts(s, "\n"); seq_printf(s, "%2s|%-19s|%1s|", "", "", ""); if (half_ch && buffer) print_half_ch_state(s, half_ch + half_ch_size, get_half_ch_funcs(ch_type), buffer_size / 2, smd_edge_to_remote_pid(ch_type)); seq_puts(s, "\n"); seq_puts(s, "-------------------------------------------------------------------------------\n"); } }