coreboot-v2/util/x86emu/yabel/debug.c
<<
>>
Prefs
   1/******************************************************************************
   2 * Copyright (c) 2004, 2008 IBM Corporation
   3 * Copyright (c) 2008, 2009 Pattrick Hueper <phueper@hueper.net>
   4 * All rights reserved.
   5 * This program and the accompanying materials
   6 * are made available under the terms of the BSD License
   7 * which accompanies this distribution, and is available at
   8 * http://www.opensource.org/licenses/bsd-license.php
   9 *
  10 * Contributors:
  11 *     IBM Corporation - initial implementation
  12 *****************************************************************************/
  13
  14#ifndef CONFIG_COREBOOT_V2
  15#include <cpu.h>
  16#endif
  17
  18#include "debug.h"
  19
  20u32 debug_flags = 0;
  21
  22void
  23dump(u8 * addr, u32 len)
  24{
  25        printf("\n%s(%p, %x):\n", __func__, addr, len);
  26        while (len) {
  27                unsigned int tmpCnt = len;
  28                unsigned char x;
  29                if (tmpCnt > 8)
  30                        tmpCnt = 8;
  31                printf("\n%p: ", addr);
  32                // print hex
  33                while (tmpCnt--) {
  34                        set_ci();
  35                        x = *addr++;
  36                        clr_ci();
  37                        printf("%02x ", x);
  38                }
  39                tmpCnt = len;
  40                if (tmpCnt > 8)
  41                        tmpCnt = 8;
  42                len -= tmpCnt;
  43                //reset addr ptr to print ascii
  44                addr = addr - tmpCnt;
  45                // print ascii
  46                while (tmpCnt--) {
  47                        set_ci();
  48                        x = *addr++;
  49                        clr_ci();
  50                        if ((x < 32) || (x >= 127)) {
  51                                //non-printable char
  52                                x = '.';
  53                        }
  54                        printf("%c", x);
  55                }
  56        }
  57        printf("\n");
  58}
  59
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.