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; }
struct smd_half_channel_access *get_half_ch_funcs(unsigned ch_type) { static struct smd_half_channel_access byte_access = { .set_state = set_state, .get_state = get_state, .set_fDSR = set_fDSR, .get_fDSR = get_fDSR, .set_fCTS = set_fCTS, .get_fCTS = get_fCTS, .set_fCD = set_fCD, .get_fCD = get_fCD, .set_fRI = set_fRI, .get_fRI = get_fRI, .set_fHEAD = set_fHEAD, .get_fHEAD = get_fHEAD, .set_fTAIL = set_fTAIL, .get_fTAIL = get_fTAIL, .set_fSTATE = set_fSTATE, .get_fSTATE = get_fSTATE, .set_fBLOCKREADINTR = set_fBLOCKREADINTR, .get_fBLOCKREADINTR = get_fBLOCKREADINTR, .set_tail = set_tail, .get_tail = get_tail, .set_head = set_head, .get_head = get_head, }; static struct smd_half_channel_access word_access = { .set_state = set_state_word_access, .get_state = get_state_word_access, .set_fDSR = set_fDSR_word_access, .get_fDSR = get_fDSR_word_access, .set_fCTS = set_fCTS_word_access, .get_fCTS = get_fCTS_word_access, .set_fCD = set_fCD_word_access, .get_fCD = get_fCD_word_access, .set_fRI = set_fRI_word_access, .get_fRI = get_fRI_word_access, .set_fHEAD = set_fHEAD_word_access, .get_fHEAD = get_fHEAD_word_access, .set_fTAIL = set_fTAIL_word_access, .get_fTAIL = get_fTAIL_word_access, .set_fSTATE = set_fSTATE_word_access, .get_fSTATE = get_fSTATE_word_access, .set_fBLOCKREADINTR = set_fBLOCKREADINTR_word_access, .get_fBLOCKREADINTR = get_fBLOCKREADINTR_word_access, .set_tail = set_tail_word_access, .get_tail = get_tail_word_access, .set_head = set_head_word_access, .get_head = get_head_word_access, }; if (is_word_access_ch(ch_type)) return &word_access; else return &byte_access; }
/** * 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"); } }