⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 print.c

📁 Vitesse 24port gigabit Switch Source Code
💻 C
字号:
/*

    Copyright (c) 2002-2005 Vitesse Semiconductor Corporation "Vitesse".  
    All Rights Reserved.  Unpublished rights reserved under the copyright laws
    of the United States of America, other countries and international treaties.
    The software is provided without a fee. Permission to use, copy, store and 
    modify, the software and its source code is granted. Permission to integrate
    into other products, disclose, transmit and distribute the software in an
    absolute machine readable format (e.g. HEX file) is also granted. 

    The source code of the software may not be disclosed, transmitted or
    distributed without the written permission of Vitesse. The software and its
    source code may only be used in products utilizing a Vitesse VSC73xx product.
 
    This copyright notice must appear in any copy, modification, disclosure,
    transmission or distribution of the software. Vitesse retains all ownership,
    copyright, trade secret and proprietary rights in the software.  

    THIS SOFTWARE HAS BEEN PROVIDED "AS IS," WITHOUT EXPRESS OR IMPLIED WARRANTY
    INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR USE AND NON-INFRINGEMENT.

*/
#include <string.h>
#include "common.h"
#include "print.h"
#include "uartdrv.h"
#include "misc1.h"
#include "hwconf.h"
#include "hwport.h"

#ifndef NO_DEBUG_IF

/* ************************************************************************ **
 *
 *
 * Defines
 *
 *
 *
 * ************************************************************************ */

#define LEFT  0
#define RIGHT 1

/* ************************************************************************ **
 *
 *
 * Typedefs and enums
 *
 *
 *
 * ************************************************************************ */

/* ************************************************************************ **
 *
 *
 * Prototypes for local functions
 *
 *
 *
 * ************************************************************************ */


/* ************************************************************************ **
 *
 *
 * Local data
 *
 *
 *
 * ************************************************************************ */

/* ************************************************************************ */
void print_str (const char *s)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print a 0-terminated string.
 * Remarks     : s points to string.
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    while (*s != 0) {
        uart_put_byte(*s++);
    }
}

/* ************************************************************************ */
void print_hex_b (uchar value)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print value of a byte as 2 hex nibbles.
 * Remarks     : value holds byte value to print. 
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    uart_put_byte(hex_to_ascii_nib(value >> 4));
    uart_put_byte(hex_to_ascii_nib(value & 0x0f));
}

/* ************************************************************************ */
void print_hex_w (ushort value)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print value of a word (16-bit integer) as 4 hex nibbles.
 * Remarks     : value holds word value to print. 
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    print_hex_b(value >> 8);
    print_hex_b(value & 0xff);
}

/* ************************************************************************ */
void print_hex_dw (ulong value)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print value of a dword (32-bit integer) as 8 hex nibbles.
 * Remarks     : value holds dword value to print. 
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    print_hex_w(value >> 16);
    print_hex_w(value & 0xffff);
}

#ifndef UNMANAGED_REDUCED_DEBUG_IF
/* ************************************************************************ */
void print_dec (ulong value)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print value of a dword (32-bit integer) as a decimal number.
 * Remarks     : value holds dword value to print.
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    uchar buf [10];
    uchar no_of_digits;

    /* Determine number of significant digits and isolate digits */
    no_of_digits = 0;
    while (value > 0) {
        buf[no_of_digits] = value % 10;
        value = value / 10;
        no_of_digits++;
    }

    /* Print each significant digit */
    if (no_of_digits == 0) {
        uart_put_byte('0');
    }
    else {
        no_of_digits--;
        while (no_of_digits != 0xff) {
            uart_put_byte(buf[no_of_digits] + '0');
            no_of_digits--;
        }
    }
}
#endif

#ifndef UNMANAGED_REDUCED_DEBUG_IF
/* ************************************************************************ */
void print_dec_8_right_2 (uchar value)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print value of a byte as a 2-digit decimal number.
 * Remarks     : value holds byte value to print.
 * Restrictions: Value may not exceed 99.
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    if (value > 9) {
        uart_put_byte(((value / 10) % 10) + '0');
    }
    else {
        uart_put_byte(' ');
    }
    uart_put_byte((value % 10) + '0');
}
#endif


/* ************************************************************************ */
void print_hex_prefix (void)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print a hex prefix, i.e. print "0x".
 * Remarks     :
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    uart_put_byte('0');
    uart_put_byte('x');
}

/* ************************************************************************ */
void print_cr_lf (void)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print a <CR> (0x0d) and a <LF> (0x0a).
 * Remarks     :
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    uart_put_byte('\r');
    uart_put_byte('\n');
}

#ifndef UNMANAGED_REDUCED_DEBUG_IF
/* ************************************************************************ */
void print_ch (uchar ch)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print a single char.
 * Remarks     : ch holds char to print in ASCII format.
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    uart_put_byte(ch);
}
#endif

#ifndef UNMANAGED_REDUCED_DEBUG_IF
/* ************************************************************************ */
void print_spaces (uchar count)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print a specified number of spaces.
 * Remarks     : count holds number of spaces to print.
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    while (count-- > 0) {
        uart_put_byte(' ');
    }
}
#endif


#ifndef UNMANAGED_REDUCED_DEBUG_IF
/* ************************************************************************ */
void print_mac_addr (const uchar *mac_addr)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print mac address in format xx-xx-xx-xx-xx-xx.
 * Remarks     : mac_addr points to a 6-byte array holding mac address.
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    uchar j;

    for (j = 0; j < 6; j++) {
        print_hex_b(*mac_addr++);
        if (j < 5) {
            print_ch('-');
        }
    }
}
#endif

#ifndef UNMANAGED_REDUCED_DEBUG_IF
/* ************************************************************************ */
void print_port_mac_addr (uchar port_no)
/* ------------------------------------------------------------------------ --
 * Purpose     : Print mac address for the specified port in format 
 *               xx-xx-xx-xx-xx-xx.
 * Remarks     : 
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    mac_addr_t mac_addr;

    get_mac_addr(port_no, mac_addr);
    print_mac_addr(mac_addr);
}
#endif


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -