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

📄 info.c

📁 MIPS下的boottloader yamon 的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:

/************************************************************************
mfw: use "BOARD_STARTUP_MENU" in pb1000.h
 *
 *  info.c
 *
 *  Info command for shell
 *
 *  info [board | cpu | mem | pci | isa | lan | boot | all]
 *
 *
 * ######################################################################
 *
 * Copyright (c) 1999-2000 MIPS Technologies, Inc. All rights reserved. 
 * 
 * Unpublished rights reserved under the Copyright Laws of the United States of 
 * America. 
 * 
 * This document contains information that is proprietary to MIPS Technologies, 
 * Inc. ("MIPS Technologies"). Any copying, modifying or use of this information 
 * (in whole or in part) which is not expressly permitted in writing by MIPS 
 * Technologies or a contractually-authorized third party is strictly 
 * prohibited. At a minimum, this information is protected under unfair 
 * competition laws and the expression of the information contained herein is 
 * protected under federal copyright laws. Violations thereof may result in 
 * criminal penalties and fines. 
 * MIPS Technologies or any contractually-authorized third party reserves the 
 * right to change the information contained in this document to improve 
 * function, design or otherwise. MIPS Technologies does not assume any 
 * liability arising out of the application or use of this information. Any 
 * license under patent rights or any other intellectual property rights owned 
 * by MIPS Technologies or third parties shall be conveyed by MIPS Technologies 
 * or any contractually-authorized third party in a separate license agreement 
 * between the parties. 
 * The information contained in this document constitutes one or more of the 
 * following: commercial computer software, commercial computer software 
 * documentation or other commercial items. If the user of this information, or 
 * any related documentation of any kind, including related technical data or 
 * manuals, is an agency, department, or other entity of the United States 
 * government ("Government"), the use, duplication, reproduction, release, 
 * modification, disclosure, or transfer of this information, or any related 
 * documentation of any kind, is restricted in accordance with Federal 
 * Acquisition Regulation 12.212 for civilian agencies and Defense Federal 
 * Acquisition Regulation Supplement 227.7202 for military agencies. The use of 
 * this information by the Government is further restricted in accordance with 
 * the terms of the license agreement(s) and/or applicable contract terms and 
 * conditions covering this information from MIPS Technologies or any 
 * contractually-authorized third party. 
 *
 ************************************************************************/


/************************************************************************
 *  Include files
 ************************************************************************/

#include <sysdefs.h>
#include <syserror.h>
#include <shell_api.h>
#include <pci_api.h>
#include <isa_api.h>
#include <mips.h>
#include "shell.h"
#include <sysdev.h>
#include <serial_api.h>
#include <sysenv_api.h>
#include <lan_api.h>
#include <syscon_api.h>
#include <sys_api.h>
#include <stdio.h>
#include <string.h>
#include <io_api.h>
#include <env_api.h>
#include <pb1000.h>

/************************************************************************
 *  Definitions
 ************************************************************************/

typedef struct
{
    char *name;
    bool (*func)(void);
}
t_item;

#define MAX_ITEM	10
#define INDENT		30

/* Messages */

#define SUPPORT		"support@mips.com"
#define UPGRADE	        "DIMM Socket J11: PC100 SDRAM 3.3V 64-128Mbyte"
#define SDBREV		"MIPS SDB Version "
#define SDBREV_UNKNOWN  "MIPS SDB non-approved version"

#define CONFIGURATION   "\
JP1: Position \"TERM\" : Enable SCSI termination.\n\
JP2: Position \"TPWR\" : Enable SCSI termination power.\n\
JP3: Position \"16\"   : PCI bus frequency = 16MHz.\n\
     Position \"33\"   : PCI bus frequency = 33MHz.\n\
\n\
Do no fit any other jumpers.\n\
\n\
All switches in S5 should be OFF (up).\n\
Front panel switch S1 functions as per Harp SDB spec."

    
 #define SHELL_WELCOME_MSG				\
    "YAMON ROM Monitor, Revision "			\
    _REVMAJ_						\
    "."							\
    _REVMIN_						\
    ".\n"						\
    "Copyright (c) 1999-2004 "				\
    MIPS_NAME						\
    " - All Rights Reserved.\n\n"			\
    "For a list of available commands, type 'help'.\n"

/************************************************************************
 *  Public variables
 ************************************************************************/

/************************************************************************
 *  Static variables
 ************************************************************************/

static char syntax_descr[500] = "Display information on the requested item (default boot).";

static char *info_board_name  = "board";
static char *info_cpu_name    = "cpu";
static char *info_mem_name    = "memory";
static char *info_pci_name    = "pci";
static char *info_isa_name    = "isa";
static char *info_uart_name   = "uart";
static char *info_lan_name    = "lan";
static char *info_boot_name   = "boot";
static char *info_all_name    = "all";
static char *boot_name        = "boot";
#define MAX_NAME_LEN	      6

static char *info_board_descr = "Board properties";
static char *info_cpu_descr   = "CPU properties";
static char *info_mem_descr   = "Memory properties";
static char *info_pci_descr   = "PCI autodiscovery/autoconfiguration";
static char *info_isa_descr   = "ISA bus configuration";
static char *info_uart_descr  = "Serial ports statistics";
static char *info_lan_descr   = "Ethernet statistics";
static char *info_boot_descr  = "Info displayed after reset";
static char *info_all_descr   = "All info";

static char    syntax[100];
static t_item  item[MAX_ITEM];
static UINT32  item_count = 0;
static bool    board_pci;
static bool    board_isa;
static bool    board_lan;
static bool    board_eeprom;
static bool    init_done = FALSE;

/************************************************************************
 *  Static function prototypes
 ************************************************************************/

static bool
check_config1(void);

static bool
check_ip(void);

static bool
check_eeprom(void);

static void
init_command( void );

static UINT32 
get_options(
    UINT32 argc,
    char   **argv,
    char   **name );

static UINT32
determine_total_flash( void );

static bool
disp_prid(
    UINT32 prid );

static bool
info_boot(void);

static bool
info_board(void);

static bool
info_cpu(void);

static bool
info_cpu_boot(void);

static bool
info_mem(void);

static bool
info_mem_boot(void);

static void
info_microsoft(void);

static bool
info_pci( void );

static bool
info_isa( void );

static bool
info_uart( void );

static bool
info_lan( void );

static void
determine_sdbrevision( 
    char *msg );

/************************************************************************
 *  Implementation : Static functions
 ************************************************************************/

/************************************************************************
 *                          check_config1
 ************************************************************************/
static bool
check_config1(void)
{
    UINT32 config1, config1_reset;

    if( SYSCON_read( SYSCON_CPU_CP0_CONFIG1_ID, 
		     &config1, 
		     sizeof(UINT32) ) != OK )
    {
        return FALSE;
    }

    if( SYSCON_read( SYSCON_CPU_CP0_CONFIG1_RESET_ID,
		     &config1_reset,
		     sizeof(UINT32) ) != OK )
    {
        return FALSE;
    }

    if( config1 == config1_reset )
    {
        return FALSE;
    }

    printf("\nWARNING: Non default cache configuration!");
    return TRUE;
}

/************************************************************************
 *                          check_ip
 ************************************************************************/
static bool
check_ip(void)
{
    UINT32 wdata;
    bool   errflag = FALSE;

    if( board_lan )
    {
        if(
	    (SYSCON_read(SYSCON_COM_EN0_IP_ADDR_ID, 
			 &wdata, 
			 sizeof(UINT32)) != OK)    ||
            (wdata == 0) )
        {
            printf("\nWARNING: Environment variable 'ipaddr' is undefined!");
	    errflag = TRUE;
        }

        if(
	    (SYSCON_read(SYSCON_COM_EN0_IP_SUBNETMASK_ID, 
			 &wdata, 
			 sizeof(UINT32)) != OK)    ||
            (wdata == 0) )
        {
            printf("\nWARNING: Environment variable 'subnetmask' is undefined!");
	    errflag = TRUE;
        }
    }

    return errflag;
}

/************************************************************************
 *                          check_eeprom
 ************************************************************************/
static bool
check_eeprom(void)
{
    t_mac_addr	mac;
    t_sn_ascii  sn;
    bool        errflag = FALSE;

    if( board_eeprom )
    {
        if( SYSCON_read(SYSCON_BOARD_SN_ID, &sn, sizeof(sn)) != OK )
	    errflag = TRUE;

        if( board_lan )
	{
            if( SYSCON_read(SYSCON_COM_EN0_MAC_ADDR_ID, 
		            &mac, 
			    sizeof(mac)) != OK )
            {
	        errflag = TRUE;
            }
        }
    }

    if( errflag )
    {
        printf("\nWARNING: EEPROM content is not valid!");
    }

    return errflag;
}

/************************************************************************
 *                          info
 ************************************************************************/
static MON_FUNC(info)
{
    /* Options */
    char   *name;
    UINT32 rc;

    rc = get_options( argc, argv, &name );

    if( rc != OK )
        return rc;
    else
        return shell_disp_info( name );
}


/************************************************************************
 *                          info_sdb
 ************************************************************************/
static MON_FUNC(info_sdb)
{
    /* Microsoft Windows CE validation */
  
    if( argc != 1 )
    {
        if( *(argv[1]) == '-' )
	{
	    shell_error_data = argv[1]; 
	    return SHELL_ERROR_OPTION;
        }
	else
	    return SHELL_ERROR_SYNTAX;
    }

    info_microsoft();
    SHELL_PUTC( '\n' );
    
    return OK;
}


/************************************************************************
 *                          register_item
 ************************************************************************/
static void
register_item( 
    char *name,
    char *descr,
    bool (*func)(void) )
{
    static bool first_name  = TRUE;
    static bool first_descr = TRUE;
    UINT32 i;

    if( name )
    {
        strcat( syntax, first_name ? " " : " | " );
        strcat( syntax, name );

	first_name = FALSE;
    }

    if( descr )
    {
       strcat( syntax_descr, 
	           first_descr ?
	               "\n\nThe following information displays can be requested:\n\n" :
		       "\n" );

       strcat( syntax_descr, name );
       strcat( syntax_descr, " : " );
       for( i = strlen(name); i < MAX_NAME_LEN; i++ )
           strcat( syntax_descr, " " );
       strcat( syntax_descr, descr );

       first_descr = FALSE;
   }

    item[item_count].name = name;
    item[item_count].func = func;
    item_count++;
}

/************************************************************************
 *                          determine_total_flash
 ************************************************************************/
static UINT32
determine_total_flash( void )
{
    UINT32 flash_size = 0;
    UINT32 wdata;

    if(SYSCON_read( SYSCON_BOARD_SYSTEMFLASH_SIZE_ID,  
		    &wdata, sizeof(wdata) ) == OK)
    {
        flash_size += wdata;
    }

    if(SYSCON_read( SYSCON_BOARD_MONITORFLASH_SIZE_ID, &wdata,
	            sizeof(wdata) ) == OK)
    {
        flash_size += wdata;
    }

    if(SYSCON_read( SYSCON_BOARD_FILEFLASH_SIZE_ID, &wdata,
		        sizeof(wdata) ) == OK)
    {
        flash_size += wdata;
    }

    return flash_size;
}


/************************************************************************
 *                          disp_prid
 ************************************************************************/
static bool
disp_prid(
    UINT32 prid )
{
    UINT8 bdata;
    char  msg[80];
    char  *name;

    /* Processor Company ID */
    if(SHELL_PUTS( "Processor Company ID =" )) return TRUE;

    bdata = REGFIELD( prid, C0_PRID_COMP );
    sprintf( msg, "0x%02x", bdata );
    if(SHELL_PUTS_INDENT( msg, INDENT )) return;

    name = sys_decode_compid( bdata );

    if( name )
        sprintf( msg, " (%s)\n", name );
    else
        sprintf( msg, "\n" );

    if(SHELL_PUTS( msg )) return;

    /* Processor ID/Revision */
    if(SHELL_PUTS( "Processor ID/revision =" )) return TRUE;

    bdata = REGFIELD( prid, C0_PRID_PRID );
    sprintf( msg, "0x%02x", bdata );
    if(SHELL_PUTS_INDENT( msg, INDENT )) return TRUE;

/*    name = sys_decode_procid();

    if( name )
    {
        sprintf( msg, " (%s)", name );
        if(SHELL_PUTS( msg )) return TRUE;
    }

*/

    sprintf( msg, " / 0x%02x\n", REGFIELD( prid, C0_PRID_REV ) );

    return (SHELL_PUTS_INDENT( msg, INDENT ));
}


/************************************************************************
 *                          info_microsoft
 ************************************************************************/
static void
info_microsoft( void )
{
    UINT8  bdata;
    UINT32 wdata;
    UINT32 flash_size;
    char   msg[80];
    char   *name;

    if(SHELL_PUTS( "\nSDB Information List :" )) return;
    

⌨️ 快捷键说明

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