~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/SLOF/clients/net-snk/app/biosemu/debug.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * Copyright (c) 2004, 2008 IBM Corporation
 
3
 * All rights reserved.
 
4
 * This program and the accompanying materials
 
5
 * are made available under the terms of the BSD License
 
6
 * which accompanies this distribution, and is available at
 
7
 * http://www.opensource.org/licenses/bsd-license.php
 
8
 *
 
9
 * Contributors:
 
10
 *     IBM Corporation - initial implementation
 
11
 *****************************************************************************/
 
12
 
 
13
#include <cpu.h>
 
14
 
 
15
#include "debug.h"
 
16
 
 
17
uint32_t debug_flags = 0;
 
18
 
 
19
void
 
20
dump(uint8_t * addr, uint32_t len)
 
21
{
 
22
        printf("\n\r%s(%p, %x):\n", __FUNCTION__, addr, len);
 
23
        while (len) {
 
24
                unsigned int tmpCnt = len;
 
25
                unsigned char x;
 
26
                if (tmpCnt > 8)
 
27
                        tmpCnt = 8;
 
28
                printf("\n\r%p: ", addr);
 
29
                // print hex
 
30
                while (tmpCnt--) {
 
31
                        set_ci();
 
32
                        x = *addr++;
 
33
                        clr_ci();
 
34
                        printf("%02x ", x);
 
35
                }
 
36
                tmpCnt = len;
 
37
                if (tmpCnt > 8)
 
38
                        tmpCnt = 8;
 
39
                len -= tmpCnt;
 
40
                //reset addr ptr to print ascii
 
41
                addr = addr - tmpCnt;
 
42
                // print ascii
 
43
                while (tmpCnt--) {
 
44
                        set_ci();
 
45
                        x = *addr++;
 
46
                        clr_ci();
 
47
                        if ((x < 32) || (x >= 127)) {
 
48
                                //non-printable char
 
49
                                x = '.';
 
50
                        }
 
51
                        printf("%c", x);
 
52
                }
 
53
        }
 
54
        printf("\n");
 
55
}