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

📄 syscon.c

📁 MIPS YAMON, a famous monitor inc. source, make file and PDF manuals.
💻 C
📖 第 1 页 / 共 3 页
字号:
/************************************************************************ * *  syscon.c * *  SYSCON module, generic parts (except TTY related parts) * * ###################################################################### * * mips_start_of_legal_notice *  * Copyright (c) 2004 MIPS Technologies, Inc. All rights reserved. * * * Unpublished rights (if any) reserved under the copyright laws of the * United States of America and other countries. * * This code is proprietary to MIPS Technologies, Inc. ("MIPS * Technologies"). Any copying, reproducing, modifying or use of this code * (in whole or in part) that is not expressly permitted in writing by MIPS * Technologies or an authorized third party is strictly prohibited. At a * minimum, this code is protected under unfair competition and copyright * laws. Violations thereof may result in criminal penalties and fines. * * MIPS Technologies reserves the right to change this code to improve * function, design or otherwise. MIPS Technologies does not assume any * liability arising out of the application or use of this code, or of any * error or omission in such code. Any warranties, whether express, * statutory, implied or otherwise, including but not limited to the implied * warranties of merchantability or fitness for a particular purpose, are * excluded. Except as expressly provided in any written license agreement * from MIPS Technologies or an authorized third party, the furnishing of * this code does not give recipient any license to any intellectual * property rights, including any patent rights, that cover this code. * * This code shall not be exported, reexported, transferred, or released, * directly or indirectly, in violation of the law of any country or * international law, regulation, treaty, Executive Order, statute, * amendments or supplements thereto. Should a conflict arise regarding the * export, reexport, transfer, or release of this code, the laws of the * United States of America shall be the governing law. * * This code constitutes one or more of the following: commercial computer * software, commercial computer software documentation or other commercial * items. If the user of this code, 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 code, 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 code 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 code from MIPS Technologies or an authorized * third party. * * * *  * mips_end_of_legal_notice *  * ************************************************************************//************************************************************************ *  Include files ************************************************************************/#include <string.h>#include <stdio.h>#include <sysdefs.h>#include <sysdev.h>#include <syscon_api.h>#include <syscon.h>#include <sys_api.h>#include <syserror.h>#include <string.h>#include <product.h>#include <sysenv_api.h>#include <env_api.h>#include <eeprom_api.h>#include <io_api.h>#include <spd.h>#include <excep_api.h>#include <net_api.h>/************************************************************************ *  Definitions ************************************************************************//************************************************************************ *  Public variables ************************************************************************//************************************************************************ *  Static variables ************************************************************************//* stepping stones to reach routines linked in flash address area */UINT32 (*flash_determine_icache_linesize)(UINT32) = sys_determine_icache_linesize_flash;UINT32 (*flash_determine_icache_lines)(UINT32) = sys_determine_icache_lines_flash;UINT32 (*flash_determine_icache_assoc)(UINT32) = sys_determine_icache_assoc_flash;UINT32 (*flash_determine_dcache_linesize)(UINT32) = sys_determine_dcache_linesize_flash;UINT32 (*flash_determine_dcache_lines)(UINT32) = sys_determine_dcache_lines_flash;UINT32 (*flash_determine_dcache_assoc)(UINT32) = sys_determine_dcache_assoc_flash;/* Constant used for determining endianness */static const UINT32 endian_test = 0x12345678;/* Reset value of CP0 config register */static UINT32 config_init;/* Memory allocation pointers */static void *SYSCON_free;static void *SYSCON_last;/*  Keeps the memory chunk, to be allocated dynamically during  *  system initialization. */static UINT8  SYSCON_dynamic_memory[SYS_MALLOC_DYNAMIC_MEMORY_SIZE];/* Used for generic error string formatting */static UINT8 syscon_generic_error_string[200] ;/* Keeps the registered sys_error lookup function per subsystem */static t_sys_error_lookup registered_lookup[SYSERROR_DOMAIN_COUNT] ;/* Syscon error strings */static char* syscon_error_string[] ={    /* ERROR_SYSCON_OUT_OF_MEMORY    */ "Internal: Out of memory (SYSCON)",    /* ERROR_SYSCON_UNKNOWN_PARAM    */ "Internal: Invalid ID (SYSCON)",    /* ERROR_SYSCON_IP_UNKNOWN	     */	"IP address unknown",    /* ERROR_SYSCON_SUBNET_UNKNOWN   */	"Subnetmask unknown",    /* ERROR_SYSCON_GATEWAY_UNKNOWN  */	"Default gateway unknown",    /* ERROR_SYSCON_READ_ONLY_ID     */ "Internal: Read-only ID (SYSCON)",    /* ERROR_SYSCON_WRITE_ONLY_ID    */ "Internal: Write-only ID (SYSCON)",    /* ERROR_SYSCON_ENV_VAR_TOO_BIG  */ "Internal: Size of env. var too big (SYSCON)",    /* ERROR_SYSCON_INVALID_CHAR_POS */ "Internal: Invalid character position (SYSCON)"};/* Array for the SYSCON objects */static t_syscon_obj  syscon_objects[SYSCON_OBJ_COUNT];/************************************************************************ *  Static function prototypes ************************************************************************/static INT32 spd_read(     UINT32  minor,		/* Minor device number			*/    UINT32  offset,		/* Byte position			*/    UINT32  length,		/* Byte count				*/    void    *user_variable );   /* Buffer for data			*//************************************************************************ *  Implementation : Static functions ************************************************************************//************************************************************************ * *                          spd_read *  Description : *  ------------- * *  Read SPD eeprom data by calling EEPROM driver * *  Return values : *  --------------- * *  Driver return value (OK in case of no error) * ************************************************************************/static INT32 spd_read(     UINT32  minor,		/* Minor device number			*/    UINT32  offset,		/* Byte position			*/    UINT32  length,		/* Byte count				*/    void    *user_variable )    /* Buffer for data			*/{    t_EEPROM_read_descriptor readbuf;    readbuf.offset = offset;    readbuf.length = length;    readbuf.buffer = user_variable;    return IO_read( SYS_MAJOR_EEPROM_IIC, minor, &readbuf );}/************************************************************************ *  Implementation : Static functions registered for handling particular  *  SYSCON objects for particular platform(s) ************************************************************************//************************************************************************ *  board_sn_generic_read ************************************************************************/static UINT32board_sn_generic_read(     void   *param,    void   *data,    UINT32 size ){    t_sn_bcd  *sn;    char      *msg = (char *)param;    UINT8     number[3];    UINT32    i;    syscon_get_eeprom_data( NULL, &sn );      if( sn != NULL )    {        msg[0] = '\0';	for( i=0; i < SYS_SN_BCD_SIZE; i++ )        {            sprintf( number, "%d%d", (*sn)[i] >> 4, (*sn)[i] & 0xF );	    strcat( msg, number );        }	return OK;    }    else        return ERROR_SYSCON_UNKNOWN_PARAM;}/************************************************************************ *  com_en0_mac_addr_generic_read ************************************************************************/static UINT32com_en0_mac_addr_generic_read(    void   *param,    void   *data,    UINT32 size ){    t_mac_addr *mac_addr;    syscon_get_eeprom_data( &mac_addr, NULL );      if( mac_addr != NULL )    {        memcpy( param, mac_addr, sizeof(t_mac_addr) );	return OK;    }    else        return ERROR_SYSCON_UNKNOWN_PARAM;}/************************************************************************ *  com_en0_ip_addr_generic_read ************************************************************************/static UINT32com_en0_ip_addr_generic_read(    void   *param,    void   *data,    UINT32 size ){    return        env_get( "ipaddr", NULL, param, sizeof(UINT32) ) ?	    OK : ERROR_SYSCON_IP_UNKNOWN;}/************************************************************************ *  com_en0_ip_subnetmask_generic_read ************************************************************************/static UINT32com_en0_ip_subnetmask_generic_read(    void   *param,    void   *data,    UINT32 size ){    return         env_get( "subnetmask", NULL, param, sizeof(UINT32) ) ?	    OK : ERROR_SYSCON_SUBNET_UNKNOWN;}/************************************************************************ *  com_en0_ip_gatewayaddr_generic_read ************************************************************************/static UINT32com_en0_ip_gatewayaddr_generic_read(    void   *param,    void   *data,    UINT32 size ){    return        env_get( "gateway", NULL, param, sizeof(UINT32) ) ?	    OK : ERROR_SYSCON_GATEWAY_UNKNOWN;}/************************************************************************ *  com_en0_enable ************************************************************************/static UINT32com_en0_enable(    void   *param,    void   *data,    UINT32 size ){    sys_dma_enable( TRUE ) ;    return( OK ) ;}/************************************************************************ *  com_en0_disable ************************************************************************/static UINT32com_en0_disable(    void   *param,    void   *data,    UINT32 size ){    sys_dma_enable( FALSE ) ;    return( OK ) ;}/************************************************************************ *  board_malloc_generic_read ************************************************************************/static UINT32board_malloc_generic_read(    void   *param,    void   *data,    UINT32 size ){    t_sys_malloc *p_mem = param;    unsigned     fraction, number;    *(p_mem->memory) = SYSCON_free;    fraction	     =  (unsigned) SYSCON_free % (unsigned) p_mem->boundary;    number           =  (unsigned) SYSCON_free / (unsigned) p_mem->boundary;    if(fraction != 0)    {        /* align pointer */        *(p_mem->memory) = (void*)((number + 1) * p_mem->boundary);    }    /* Check fullfillment of memory request */    if((unsigned)((*(p_mem->memory)) + p_mem->size) > (unsigned) SYSCON_last)    {        p_mem->memory = NULL;        return ERROR_SYSCON_OUT_OF_MEMORY;    }    else    {        /* allocate memory */        SYSCON_free = (*(p_mem->memory)) + p_mem->size;	return OK;    }}/************************************************************************ *  board_free_mem_generic_read ************************************************************************/static UINT32board_free_mem_generic_read(    void   *param,    void   *data,    UINT32 size ){    *(UINT32 *)param = sys_freemem;    return OK;}/************************************************************************ *  board_appl_stack_size_generic_read ************************************************************************/static UINT32board_appl_stack_size_generic_read(    void   *param,    void   *data,    UINT32 size ){    *(UINT32 *)param = SYS_APPL_STACK_SIZE;    return OK;}/************************************************************************ *  board_stack_size_generic_read ************************************************************************/static UINT32board_stack_size_generic_read(    void   *param,    void   *data,    UINT32 size ){    *(UINT32 *)param = SYS_STACK_SIZE;    return OK;}/************************************************************************ *  board_cpu_clock_freq_generic_read ************************************************************************/static UINT32board_cpu_clock_freq_generic_read(    void   *param,    void   *data,    UINT32 size ){    *(UINT32 *)param = sys_cpufreq_hz;    return OK;}/************************************************************************ *  board_bus_clock_freq_generic_read ************************************************************************/static UINT32board_bus_clock_freq_generic_read(    void   *param,    void   *data,    UINT32 size ){    *(UINT32 *)param = sys_busfreq_hz;    return OK;}/************************************************************************ *  cpu_icache_size_generic_read ************************************************************************/static UINT32cpu_icache_size_generic_read(    void   *param,    void   *data,    UINT32 size ){    *(UINT32 *)param = sys_icache_linesize * sys_icache_lines;    return OK;}/************************************************************************ *  cpu_icache_linesize_generic_read ************************************************************************/static UINT32cpu_icache_linesize_generic_read(    void   *param,    void   *data,    UINT32 size ){    *(UINT32 *)param = sys_icache_linesize;    return OK;}/************************************************************************ *  cpu_icache_assoc_generic_read ************************************************************************/static UINT32cpu_icache_assoc_generic_read(    void   *param,    void   *data,    UINT32 size ){    *(UINT32 *)param = sys_icache_assoc;    return OK;}/************************************************************************ *  cpu_icache_avail_bpw_generic_read ************************************************************************/static UINT32cpu_icache_avail_bpw_generic_read(    void   *param,    void   *data,    UINT32 size ){     sys_cpu_cache_bpw( TRUE, (t_sys_array *)param );    return OK;}/************************************************************************ *  cpu_icache_avail_assoc_generic_read

⌨️ 快捷键说明

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