void myprintk(const char *myDrvName, const char *devname,
const char *template, ...);
-/** Print the hexadecimal contents of a data buffer to a supplied print buffer.
- * @param dest the print buffer where text characters will be
- * written
- * @param destSize the maximum number of bytes that can be written
- * to #dest
- * @param src the buffer that contains the data that is to be
- * hex-dumped
- * @param srcLen the number of bytes at #src to be hex-dumped
- * @param bytesToDumpPerLine output will be formatted such that at most this
- * many of the input data bytes will be represented
- * on each line of output
- * @return the number of text characters written to #dest
- * (not including the trailing '\0' byte)
- * @ingroup internal
- */
-int visor_hexDumpToBuffer(char *dest,
- int destSize,
- char *prefix,
- char *src,
- int srcLen,
- int bytesToDumpPerLine);
-
/*--------------------------------*
*--- GENERAL MESSAGEQ STUFF ---*
*--------------------------------*/
visorchannel_dump_section(VISORCHANNEL *chan, char *s,
int off, int len, struct seq_file *seq)
{
- char *buf = NULL, *fmtbuf = NULL;
+ char *buf, *tbuf, *fmtbuf;
int fmtbufsize = 0;
- int i = 0;
+ int i;
int errcode = 0;
fmtbufsize = 100 * COVQ(len, 16);
goto Away;
}
seq_printf(seq, "channel %s:\n", s);
- visor_hexDumpToBuffer(fmtbuf, fmtbufsize, " ", buf, len, 16);
- for (i = 0; fmtbuf[i] != '\0'; i++)
- seq_printf(seq, "%c", fmtbuf[i]);
+ tbuf = buf;
+ while (len > 0) {
+ i = (len < 16) ? len : 16;
+ hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
+ seq_printf(seq, "%s\n", fmtbuf);
+ tbuf += 16;
+ len -= 16;
+ }
Away:
if (buf != NULL) {
#define MYDRVNAME "timskmodutils"
-BOOL Debug_Malloc_Enabled = FALSE;
-
-/** Print the hexadecimal contents of a data buffer to a supplied print buffer.
- * @param dest the print buffer where text characters will
- * be written
- * @param destSize the maximum number of bytes that can be written
- * to #dest
- * @param src the buffer that contains the data that is to be
- * hex-dumped
- * @param srcLen the number of bytes at #src to be hex-dumped
- * @param bytesToDumpPerLine output will be formatted such that at most
- * this many of the input data bytes will be
- * represented on each line of output
- * @return the number of text characters written to #dest
- * (not including the trailing '\0' byte)
- * @ingroup internal
- */
-int visor_hexDumpToBuffer(char *dest, int destSize, char *prefix, char *src,
- int srcLen, int bytesToDumpPerLine)
-{
- int i = 0;
- int pos = 0;
- char printable[bytesToDumpPerLine + 1];
- char hex[(bytesToDumpPerLine * 3) + 1];
- char *line = NULL;
- int linesize = 1000;
- int linelen = 0;
- int currentlen = 0;
- char emptystring[] = "";
- char *pfx = prefix;
- int baseaddr = 0;
- int rc = 0;
-
- line = vmalloc(linesize);
- if (line == NULL)
- RETINT(currentlen);
-
- if (pfx == NULL || (strlen(pfx) > 50))
- pfx = emptystring;
- memset(hex, ' ', bytesToDumpPerLine * 3);
- hex[bytesToDumpPerLine * 3] = '\0';
- memset(printable, ' ', bytesToDumpPerLine);
- printable[bytesToDumpPerLine] = '\0';
- if (destSize > 0)
- dest[0] = '\0';
-
- for (i = 0; i < srcLen; i++) {
- pos = i % bytesToDumpPerLine;
- if ((pos == 0) && (i > 0)) {
- hex[bytesToDumpPerLine*3] = '\0';
- linelen = sprintf(line, "%s%-6.6x %s %s\n", pfx,
- baseaddr, hex, printable);
- if ((currentlen) + (linelen) >= destSize)
- RETINT(currentlen);
- strcat(dest, line);
- currentlen += linelen;
- memset(hex, ' ', bytesToDumpPerLine * 3);
- memset(printable, ' ', bytesToDumpPerLine);
- baseaddr = i;
- }
- sprintf(hex + (pos * 3), "%-2.2x ", (uint8_t)(src[i]));
- *(hex + (pos * 3) + 3) = ' '; /* get rid of null */
- if (((uint8_t)(src[i]) >= ' ') && (uint8_t)(src[i]) < 127)
- printable[pos] = src[i];
- else
- printable[pos] = '.';
- }
- pos = i%bytesToDumpPerLine;
- if (i > 0) {
- hex[bytesToDumpPerLine * 3] = '\0';
- linelen = sprintf(line, "%s%-6.6x %s %s\n",
- pfx, baseaddr, hex, printable);
- if ((currentlen) + (linelen) >= destSize)
- RETINT(currentlen);
- strcat(dest, line);
- currentlen += linelen;
- }
- RETINT(currentlen);
-
-Away:
- if (line)
- vfree(line);
- return rc;
-}
-EXPORT_SYMBOL_GPL(visor_hexDumpToBuffer);
-
-
/** Callers to interfaces that set __GFP_NORETRY flag below
* must check for a NULL (error) result as we are telling the
* kernel interface that it is okay to fail.