Lines Matching refs:textbuf
581 ocs_ddump_startfile(ocs_textbuf_t *textbuf) in ocs_ddump_startfile() argument
583 ocs_textbuf_printf(textbuf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"); in ocs_ddump_startfile()
597 ocs_ddump_endfile(ocs_textbuf_t *textbuf) in ocs_ddump_endfile() argument
614 ocs_ddump_section(ocs_textbuf_t *textbuf, const char *name, uint32_t instance) in ocs_ddump_section() argument
616 ocs_textbuf_printf(textbuf, "<%s type=\"section\" instance=\"%d\">\n", name, instance); in ocs_ddump_section()
632 ocs_ddump_endsection(ocs_textbuf_t *textbuf, const char *name, uint32_t instance) in ocs_ddump_endsection() argument
634 ocs_textbuf_printf(textbuf, "</%s>\n", name); in ocs_ddump_endsection()
650 ocs_ddump_value(ocs_textbuf_t *textbuf, const char *name, const char *fmt, ...) in ocs_ddump_value() argument
659 ocs_textbuf_printf(textbuf, "<%s>%s</%s>\n", name, valuebuf, name); in ocs_ddump_value()
677 ocs_ddump_buffer(ocs_textbuf_t *textbuf, const char *name, uint32_t instance, void *buffer, uint32_… in ocs_ddump_buffer() argument
689 ocs_textbuf_printf(textbuf, "<%s type=\"buffer\" instance=\"%d\">\n", name, instance); in ocs_ddump_buffer()
694 ocs_textbuf_printf(textbuf, "%08x ", *dword++); in ocs_ddump_buffer()
696 ocs_textbuf_printf(textbuf, "\n"); in ocs_ddump_buffer()
700 ocs_textbuf_printf(textbuf, "</%s>\n", name); in ocs_ddump_buffer()
719 ocs_ddump_queue_entries(ocs_textbuf_t *textbuf, void *q_addr, uint32_t size, in ocs_ddump_queue_entries() argument
742 ocs_textbuf_printf(textbuf, "<qentries>\n"); in ocs_ddump_queue_entries()
748 ocs_textbuf_printf(textbuf, "[%04x] ", index); in ocs_ddump_queue_entries()
750 ocs_textbuf_printf(textbuf, "%08x ", *dword++); in ocs_ddump_queue_entries()
753 ocs_textbuf_printf(textbuf, "\n"); in ocs_ddump_queue_entries()
755 ocs_textbuf_printf(textbuf, " "); in ocs_ddump_queue_entries()
765 ocs_textbuf_printf(textbuf, "</qentries>\n"); in ocs_ddump_queue_entries()
1217 ocs_display_sparams(const char *prelabel, const char *reqlabel, int dest, void *textbuf, void *spar… in ocs_display_sparams() argument
1236 ocs_ddump_buffer((ocs_textbuf_t*) textbuf, reqlabel, 0, sparams, sizeof(fc_plogi_payload_t)); in ocs_display_sparams()
1623 static ocs_textbuf_segment_t *ocs_textbuf_segment_alloc(ocs_textbuf_t *textbuf);
1625 static ocs_textbuf_segment_t *ocs_textbuf_get_segment(ocs_textbuf_t *textbuf, uint32_t idx);
1628 ocs_textbuf_get_buffer(ocs_textbuf_t *textbuf) in ocs_textbuf_get_buffer() argument
1630 return ocs_textbuf_ext_get_buffer(textbuf, 0); in ocs_textbuf_get_buffer()
1634 ocs_textbuf_get_length(ocs_textbuf_t *textbuf) in ocs_textbuf_get_length() argument
1636 return ocs_textbuf_ext_get_length(textbuf, 0); in ocs_textbuf_get_length()
1640 ocs_textbuf_get_written(ocs_textbuf_t *textbuf) in ocs_textbuf_get_written() argument
1646 for (idx = 0; (n = ocs_textbuf_ext_get_written(textbuf, idx)) >= 0; idx++) { in ocs_textbuf_get_written()
1652 uint8_t *ocs_textbuf_ext_get_buffer(ocs_textbuf_t *textbuf, uint32_t idx) in ocs_textbuf_ext_get_buffer() argument
1654 ocs_textbuf_segment_t *segment = ocs_textbuf_get_segment(textbuf, idx); in ocs_textbuf_ext_get_buffer()
1661 int32_t ocs_textbuf_ext_get_length(ocs_textbuf_t *textbuf, uint32_t idx) in ocs_textbuf_ext_get_length() argument
1663 ocs_textbuf_segment_t *segment = ocs_textbuf_get_segment(textbuf, idx); in ocs_textbuf_ext_get_length()
1670 int32_t ocs_textbuf_ext_get_written(ocs_textbuf_t *textbuf, uint32_t idx) in ocs_textbuf_ext_get_written() argument
1672 ocs_textbuf_segment_t *segment = ocs_textbuf_get_segment(textbuf, idx); in ocs_textbuf_ext_get_written()
1680 ocs_textbuf_initialized(ocs_textbuf_t *textbuf) in ocs_textbuf_initialized() argument
1682 return (textbuf->ocs != NULL); in ocs_textbuf_initialized()
1686 ocs_textbuf_alloc(ocs_t *ocs, ocs_textbuf_t *textbuf, uint32_t length) in ocs_textbuf_alloc() argument
1688 ocs_memset(textbuf, 0, sizeof(*textbuf)); in ocs_textbuf_alloc()
1690 textbuf->ocs = ocs; in ocs_textbuf_alloc()
1691 ocs_list_init(&textbuf->segment_list, ocs_textbuf_segment_t, link); in ocs_textbuf_alloc()
1694 textbuf->allocation_length = OCS_TEXTBUF_MAX_ALLOC_LEN; in ocs_textbuf_alloc()
1696 textbuf->allocation_length = length; in ocs_textbuf_alloc()
1700 textbuf->extendable = TRUE; in ocs_textbuf_alloc()
1703 textbuf->max_allocation_length = length; in ocs_textbuf_alloc()
1706 return (ocs_textbuf_segment_alloc(textbuf) == NULL) ? -1 : 0; in ocs_textbuf_alloc()
1710 ocs_textbuf_segment_alloc(ocs_textbuf_t *textbuf) in ocs_textbuf_segment_alloc() argument
1714 if (textbuf->extendable) { in ocs_textbuf_segment_alloc()
1715 segment = ocs_malloc(textbuf->ocs, sizeof(*segment), OCS_M_ZERO | OCS_M_NOWAIT); in ocs_textbuf_segment_alloc()
1717 … segment->buffer = ocs_malloc(textbuf->ocs, textbuf->allocation_length, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_textbuf_segment_alloc()
1719 segment->buffer_length = textbuf->allocation_length; in ocs_textbuf_segment_alloc()
1721 ocs_list_add_tail(&textbuf->segment_list, segment); in ocs_textbuf_segment_alloc()
1722 textbuf->total_allocation_length += textbuf->allocation_length; in ocs_textbuf_segment_alloc()
1725 if (textbuf->total_allocation_length >= textbuf->max_allocation_length) { in ocs_textbuf_segment_alloc()
1726 textbuf->extendable = 0; in ocs_textbuf_segment_alloc()
1730 ocs_textbuf_segment_free(textbuf->ocs, segment); in ocs_textbuf_segment_alloc()
1750 ocs_textbuf_get_segment(ocs_textbuf_t *textbuf, uint32_t idx) in ocs_textbuf_get_segment() argument
1755 if (ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_get_segment()
1757 ocs_list_foreach(&textbuf->segment_list, segment) { in ocs_textbuf_get_segment()
1768 ocs_textbuf_init(ocs_t *ocs, ocs_textbuf_t *textbuf, void *buffer, uint32_t length) in ocs_textbuf_init() argument
1773 ocs_memset(textbuf, 0, sizeof(*textbuf)); in ocs_textbuf_init()
1775 textbuf->ocs = ocs; in ocs_textbuf_init()
1776 ocs_list_init(&textbuf->segment_list, ocs_textbuf_segment_t, link); in ocs_textbuf_init()
1783 ocs_list_add_tail(&textbuf->segment_list, segment); in ocs_textbuf_init()
1791 ocs_textbuf_free(ocs_t *ocs, ocs_textbuf_t *textbuf) in ocs_textbuf_free() argument
1796 if (ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_free()
1797 ocs_list_foreach_safe(&textbuf->segment_list, segment, n) { in ocs_textbuf_free()
1798 ocs_list_remove(&textbuf->segment_list, segment); in ocs_textbuf_free()
1802 ocs_memset(textbuf, 0, sizeof(*textbuf)); in ocs_textbuf_free()
1807 ocs_textbuf_printf(ocs_textbuf_t *textbuf, const char *fmt, ...) in ocs_textbuf_printf() argument
1811 if (ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_printf()
1813 ocs_textbuf_vprintf(textbuf, fmt, ap); in ocs_textbuf_printf()
1819 ocs_textbuf_vprintf(ocs_textbuf_t *textbuf, const char *fmt, va_list ap) in ocs_textbuf_vprintf() argument
1826 if (!ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_vprintf()
1833 segment = ocs_list_get_tail(&textbuf->segment_list); in ocs_textbuf_vprintf()
1837 if ((segment = ocs_textbuf_segment_alloc(textbuf)) == NULL) { in ocs_textbuf_vprintf()
1849 if (textbuf->extendable) { in ocs_textbuf_vprintf()
1854 if ((segment = ocs_textbuf_segment_alloc(textbuf)) == NULL) { in ocs_textbuf_vprintf()
1855 ocs_log_err(textbuf->ocs, "alloc segment failed\n"); in ocs_textbuf_vprintf()
1871 ocs_textbuf_putc(ocs_textbuf_t *textbuf, uint8_t c) in ocs_textbuf_putc() argument
1875 if (ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_putc()
1876 segment = ocs_list_get_tail(&textbuf->segment_list); in ocs_textbuf_putc()
1882 ocs_textbuf_segment_alloc(textbuf); in ocs_textbuf_putc()
1888 ocs_textbuf_puts(ocs_textbuf_t *textbuf, char *s) in ocs_textbuf_puts() argument
1890 if (ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_puts()
1892 ocs_textbuf_putc(textbuf, *s++); in ocs_textbuf_puts()
1898 ocs_textbuf_buffer(ocs_textbuf_t *textbuf, uint8_t *buffer, uint32_t buffer_length) in ocs_textbuf_buffer() argument
1902 if (!ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_buffer()
1919 case '"': ocs_textbuf_puts(textbuf, """); break; in ocs_textbuf_buffer()
1920 case '\'': ocs_textbuf_puts(textbuf, "'"); break; in ocs_textbuf_buffer()
1921 case '<': ocs_textbuf_puts(textbuf, "<"); break; in ocs_textbuf_buffer()
1922 case '>': ocs_textbuf_puts(textbuf, ">"); break; in ocs_textbuf_buffer()
1923 case '&': ocs_textbuf_puts(textbuf, "&"); break; in ocs_textbuf_buffer()
1924 default: ocs_textbuf_putc(textbuf, *s); break; in ocs_textbuf_buffer()
1932 ocs_textbuf_copy(ocs_textbuf_t *textbuf, uint8_t *buffer, uint32_t buffer_length) in ocs_textbuf_copy() argument
1936 if (!ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_copy()
1942 ocs_textbuf_putc(textbuf, *s++); in ocs_textbuf_copy()
1948 ocs_textbuf_remaining(ocs_textbuf_t *textbuf) in ocs_textbuf_remaining() argument
1950 if (ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_remaining()
1951 return ocs_segment_remaining(ocs_list_get_head(&textbuf->segment_list)); in ocs_textbuf_remaining()
1964 ocs_textbuf_reset(ocs_textbuf_t *textbuf) in ocs_textbuf_reset() argument
1970 if (ocs_textbuf_initialized(textbuf)) { in ocs_textbuf_reset()
1972 ocs_list_foreach_safe(&textbuf->segment_list, segment, n) { in ocs_textbuf_reset()
1976 ocs_list_remove(&textbuf->segment_list, segment); in ocs_textbuf_reset()
1977 ocs_textbuf_segment_free(textbuf->ocs, segment); in ocs_textbuf_reset()
2511 ocs_ddump_ramlog(ocs_textbuf_t *textbuf, ocs_ramlog_t *ramlog) in ocs_ddump_ramlog() argument
2521 ocs_ddump_section(textbuf, "driver-log", 0); in ocs_ddump_ramlog()
2524 ocs_ddump_section(textbuf, "startofday", 0); in ocs_ddump_ramlog()
2528 …ocs_textbuf_buffer(textbuf, ocs_textbuf_get_buffer(rltextbuf), ocs_textbuf_get_written(rltextbuf)); in ocs_ddump_ramlog()
2530 ocs_ddump_endsection(textbuf, "startofday", 0); in ocs_ddump_ramlog()
2533 ocs_ddump_section(textbuf, "recent", 0); in ocs_ddump_ramlog()
2540 …ocs_textbuf_buffer(textbuf, ocs_textbuf_get_buffer(rltextbuf), ocs_textbuf_get_written(rltextbuf)); in ocs_ddump_ramlog()
2543 ocs_ddump_endsection(textbuf, "recent", 0); in ocs_ddump_ramlog()
2544 ocs_ddump_endsection(textbuf, "driver-log", 0); in ocs_ddump_ramlog()