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

📄 shell_platform.c

📁 一个专门针对mips的bootloader程序源代码
💻 C
字号:

/************************************************************************
 *
 *  shell_platform.c
 *
 *  Platform specific setup of shell
 *
 *
 * ######################################################################
 *
 * 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 <mips.h>
#include <sysdev.h>

#include <product.h>
#include <atlas.h>

#include <shell_api.h>
#include <sys_api.h>
#include <io_api.h>
#include <syscon_api.h>
#include <lan_api.h>

#include <stdio.h>
#include <string.h>

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

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

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

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

/************************************************************************
 *  Implementation : Public functions
 ************************************************************************/

/************************************************************************
 *
 *                          shell_arch
 *  Description :
 *  -------------
 *
 *  Platform specific setup of shell
 *
 *  Return values :
 *  ---------------
 *
 *  None
 *
 ************************************************************************/
void 
shell_arch(void)
{
    bool cache_configurable, mmu_configurable, sys_mmu_tlb;

    /* Common commands */

    shell_register_cmd( shell_cache_init()	  );
    shell_register_cmd( shell_cksum_init()        );
    shell_register_cmd( shell_compare_init()	  );
    shell_register_cmd( shell_copy_init()	  );
    shell_register_cmd( shell_cp0_init()	  );
    shell_register_cmd( shell_dis_init()	  );
    shell_register_cmd( shell_dump_init()	  );
    shell_register_cmd( shell_dump_dot_init()	  );
    shell_register_cmd( shell_echo_init()	  );
    shell_register_cmd( shell_edit_init()	  );
    shell_register_cmd( shell_erase_init()	  );
    shell_register_cmd( shell_fill_init()	  );
    shell_register_cmd( shell_flush_init()	  );
    shell_register_cmd( shell_gdb_init()	  );
    shell_register_cmd( shell_go_init()		  );
    shell_register_cmd( shell_load_init()	  );
    shell_register_cmd( shell_loaddata_init()	  );
    shell_register_cmd( shell_port_init()	  );
    shell_register_cmd( shell_search_init()	  );
    shell_register_cmd( shell_setenv_init()	  );
    shell_register_cmd( shell_sleep_init()	  );
    shell_register_cmd( shell_stty_init()	  );
    shell_register_cmd( shell_test_init()	  );
    shell_register_cmd( shell_unsetenv_init()	  );

    /**** Platform specific commands ****/
    switch( sys_platform )
    {
      case PRODUCT_ATLASA_ID :
        shell_register_cmd( shell_off_init()	   );
        shell_register_cmd( shell_date_init()      );
        shell_register_cmd( shell_pcicfg_init()    );
        shell_register_cmd( shell_reset_init()     );
        shell_register_cmd( shell_ping_init()      );
        shell_register_cmd( shell_info_init( TRUE, FALSE, TRUE, TRUE ) );

	/*  Microsoft SDB commands
	 *  Note : shell_stty_sdb_init must be
	 *  called after shell_info_init.
	 */
        shell_register_cmd( shell_dump_sdb_init()  );
        shell_register_cmd( shell_erase_sdb_init() );
        shell_register_cmd( shell_info_sdb_init()  );
        shell_register_cmd( shell_load_sdb_init()  );
        shell_register_cmd( shell_stty_sdb_init()  );
        shell_register_cmd( shell_test_sdb_init()  );

	break;
      case PRODUCT_MALTA_ID :
        shell_register_cmd( shell_date_init()      );
        shell_register_cmd( shell_pcicfg_init()    );
        shell_register_cmd( shell_reset_init()     );
        shell_register_cmd( shell_ping_init()      );
        shell_register_cmd( shell_info_init( TRUE, TRUE, TRUE, TRUE ) );
	break;
      case PRODUCT_SEAD_ID :
        shell_register_cmd( shell_off_init()	   );
        shell_register_cmd( shell_info_init( FALSE, FALSE, FALSE, FALSE ) );
	break;
      case PRODUCT_SEAD2_ID :
        shell_register_cmd( shell_reset_init()     );
        shell_register_cmd( shell_info_init( FALSE, FALSE, FALSE, FALSE ) );
	break;
      case PRODUCT_PB1000_ID:
        shell_register_cmd( shell_date_init()      ); 
        shell_register_cmd( shell_ping_init()      );
        shell_register_cmd( shell_pcicfg_init()    );
        shell_register_cmd( shell_ss_init() );
        shell_register_cmd( shell_info_init( FALSE, FALSE, TRUE, FALSE ) );
		break;
      default :
        break;
    }

    /**** Other dependencies ****/

    SYSCON_read( SYSCON_CPU_CACHE_CONFIGURABLE_ID,
		 &cache_configurable,
		 sizeof(bool) );

    SYSCON_read( SYSCON_CPU_MMU_CONFIGURABLE_ID,
		 &mmu_configurable,
		 sizeof(bool) );

    if( cache_configurable || mmu_configurable )
    {
        shell_register_cmd( shell_scpu_init(
				cache_configurable,
				mmu_configurable ) );
    }

    SYSCON_read( SYSCON_CPU_TLB_AVAIL_ID,
	         (void *)&sys_mmu_tlb,
	         sizeof( bool ) );

    if( sys_mmu_tlb )
        shell_register_cmd( shell_tlb_init() );
}


/************************************************************************
 *
 *                          shell_arch_dma
 *  Description :
 *  -------------
 *
 *  Platform specific handling of DMA (enable/disable)
 *
 *  Return values :
 *  ---------------
 *
 *  None
 *
 ************************************************************************/
void
shell_arch_dma(
    bool enable )  /* TRUE -> Enable DMA devices, FALSE -> Disable	*/
{
    t_LAN_CTRL_desc ctrl;

	/* PBUpdate */
	
    ctrl.data    = NULL;
    ctrl.command = enable ? 
		       LAN_CTRL_START_CONTROLLER :
		       LAN_CTRL_STOP_CONTROLLER;

    switch( sys_platform )
    {
      case PRODUCT_MALTA_ID :
        IO_ctrl( SYS_MAJOR_LAN_AM79C973, 0, (void *)&ctrl );
	break;
      case PRODUCT_ATLASA_ID :
        IO_ctrl( SYS_MAJOR_LAN_SAA9730,  0, (void *)&ctrl );
	break;
      default :
        break;
    }
}


/************************************************************************
 *
 *                          shell_arch_info
 *  Description :
 *  -------------
 *
 *  Platform specific decoding of REVISION register
 *
 *  Return values :
 *  ---------------
 *
 *  TRUE : No ctrl-c detected, FALSE : ctrl-c detected
 *
 ************************************************************************/
bool
shell_arch_info( 
    UINT32 indent )
{
    UINT32 wdata;
    UINT32 major, minor;
    char   msg[80];
    char   *name;

    switch( sys_platform )
    {
	case PRODUCT_PB1000_ID:

		/* PBUpdate - printout revision information here */

		break;
      case PRODUCT_MALTA_ID :
      case PRODUCT_ATLASA_ID :
        /* Core board type/revision */
	if(SYSCON_read(SYSCON_BOARD_CORECARDID_ID, &wdata, sizeof(UINT32)) == 0)
	{
            if(SHELL_PUTS( "Core board type/revision =" )) return FALSE;

	    if( SYSCON_read( SYSCON_BOARD_CORECARD_NAME_ID, 
			 &name, sizeof(char *) ) == 0 )
	    {
                sprintf( msg, "0x%02x (%s)", wdata, name );
	    }
	    else
	    {
		sprintf( msg, "0x%02x", wdata );
	    }

	    if(SYSCON_read(SYSCON_BOARD_CORECARDREV_ID, &wdata, sizeof(UINT32)) == 0)
	    {
                sprintf( &msg[strlen(msg)], " / 0x%02x\n", wdata );
	    }

	    if(SHELL_PUTS_INDENT( msg, indent )) return FALSE;
        }
    
        /* FPGA revision */
	if(SYSCON_read(SYSCON_BOARD_FPGAREV_ID, &wdata, sizeof(UINT32)) == 0)
	{
            if(SHELL_PUTS( "FPGA revision =" )) return FALSE;
            sprintf( msg, "0x%04x\n", wdata );
            if(SHELL_PUTS_INDENT( msg, indent )) return FALSE;
        }

	break;

      case PRODUCT_SEAD_ID :
      case PRODUCT_SEAD2_ID :
        /* RTL ID/revision */      
        if(SYSCON_read(SYSCON_BOARD_RTL_ID, &wdata, sizeof(UINT32)) == 0)
        {
	    if(SHELL_PUTS( "RTL ID/revision =" )) return FALSE;

	    if( SYSCON_read( SYSCON_BOARD_RTL_NAME_ID, 
			 &name, sizeof(char *) ) == 0 )
	    {
	        sprintf( msg, "0x%02x (%s)", wdata, name );
            }
	    else
	    {
	        sprintf( msg, "0x%02x", wdata );
	    }

	    if( (SYSCON_read(SYSCON_BOARD_RTLREV_MAJOR_ID, 
			     &major, sizeof(UINT32)) == 0) &&
		(SYSCON_read(SYSCON_BOARD_RTLREV_MINOR_ID, 
			     &minor, sizeof(UINT32)) == 0) )
	    {
	        sprintf( &msg[strlen(msg)], " / %d.%d\n", 
		         major, minor );
	    }

	    if(SHELL_PUTS_INDENT( msg, indent )) return FALSE;
        }

	break;

      default :
        break;
    }

    return TRUE;
}

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



⌨️ 快捷键说明

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