Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / common / boot / grub2 / lib / hexdump.c
blob9b79f45b8fc4ce24ef8bb0c4b430cd00fdf43e19
1 /* hexdump.c - hexdump function */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2008 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/types.h>
21 #include <grub/misc.h>
22 #include <grub/lib/hexdump.h>
24 void
25 hexdump (unsigned long bse, char *buf, int len)
27 int pos;
28 char line[80];
30 while (len > 0)
32 int cnt, i;
34 pos = grub_sprintf (line, "%08lx ", bse);
35 cnt = 16;
36 if (cnt > len)
37 cnt = len;
39 for (i = 0; i < cnt; i++)
41 pos += grub_sprintf (&line[pos], "%02x ", (unsigned char) buf[i]);
42 if ((i & 7) == 7)
43 line[pos++] = ' ';
46 for (; i < 16; i++)
48 pos += grub_sprintf (&line[pos], " ");
49 if ((i & 7) == 7)
50 line[pos++] = ' ';
53 line[pos++] = '|';
55 for (i = 0; i < cnt; i++)
56 line[pos++] = ((buf[i] >= 32) && (buf[i] < 127)) ? buf[i] : '.';
58 line[pos++] = '|';
60 line[pos] = 0;
62 grub_printf ("%s\n", line);
64 bse += 16;
65 buf += 16;
66 len -= cnt;