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

📄 syscon_platform_tty.c

📁 一个专门针对mips的bootloader程序源代码
💻 C
📖 第 1 页 / 共 2 页
字号:

/************************************************************************
 *
 *  syscon_platform_tty.c
 *
 *  Platform and TTY specific parts of SYSCON module
 *
 *
 * ######################################################################
 *
 * 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 <syscon_api.h>
#include <syscon.h>
#include <syserror.h>
#include <mips.h>
#include <sysdev.h>
#include <serial_api.h>
#include <serial_ti16550_api.h>
#include <product.h>
#include <atlas.h>
#include <sead.h>
#include <malta.h>
#include <icta.h>	/* Atlas specific */
#include <pb1000.h>

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

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

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

/* Select mapping of TTY1 on Malta (SuperIO device or discrete UART)	*/
static bool malta_tty1_on_texas	        = FALSE;  /* Default SuperIO	*/

/* Register size/spacing */
static UINT8  size8			= sizeof(UINT8);
static UINT8  size32			= sizeof(UINT32);
static UINT8  size64			= 2*sizeof(UINT32);

/**** Interrupt lines ****/

/* Atlas   */
static UINT32 intline_atlas_ti16550     = ICTA_INTSTATUS_SER_SHF;
static UINT32 intline_atlas_saa9730     = ICTA_INTSTATUS_CONINTBN_SHF;
/* SEAD    */
static UINT32 intline_sead_ti16550_0    = C0_STATUS_IM_HW0;
static UINT32 intline_sead_ti16550_1    = C0_STATUS_IM_HW1;
/* Malta */
static UINT32 intline_malta_ti16550_0   = MALTA_INTLINE_TTY0;
static UINT32 intline_malta_ti16550_1   = MALTA_INTLINE_TTY1;
static UINT32 intline_malta_ti16550_2   = C0_STATUS_IM_HW2;

/*  Major/minor device number mappings :
 *
 *	       TTY0         TTY1
 *     -----------------------------
 *     Atlas | TI16550(0)   SAA9730
 *     SEAD  | TI16550(0)   TI16550(1)
 *     Malta | TI16550(0)   TI16550(1)
 */

/* Atlas   */
static UINT32 atlas_major_tty0	        = SYS_MAJOR_SERIAL_TI16550;
static UINT32 atlas_minor_tty0	        = SERIAL_MINOR_TI16550_UART0;
static UINT32 atlas_major_tty1	        = SYS_MAJOR_SERIAL_SAA9730;
static UINT32 atlas_minor_tty1	        = SERIAL_MINOR_SAA9730_UART;
/* SEAD    */
static UINT32 sead_major_tty0	        = SYS_MAJOR_SERIAL_TI16550;
static UINT32 sead_minor_tty0	        = SERIAL_MINOR_TI16550_UART0;
static UINT32 sead_major_tty1	        = SYS_MAJOR_SERIAL_TI16550;
static UINT32 sead_minor_tty1	        = SERIAL_MINOR_TI16550_UART1;
/* Malta */
static UINT32 malta_major_tty0		= SYS_MAJOR_SERIAL_TI16550;
static UINT32 malta_minor_tty0		= SERIAL_MINOR_TI16550_UART0;
static UINT32 malta_major_tty1		= SYS_MAJOR_SERIAL_TI16550;
static UINT32 malta_minor_tty1		= SERIAL_MINOR_TI16550_UART1;

/* Alchemy - see serial_Au1000.c */
UINT32 pb1000_major_tty0;
UINT32 pb1000_minor_tty0;
UINT32 pb1000_major_tty1;
UINT32 pb1000_minor_tty1;


/*  Baudrate conversion tables for UART divisor latch.
 *
 *  This table is also used to compute minimum value of BRKRES,
 *  in order to avoid that 10 low bits in a row generates reset.
 *      A NULL sent with 8 bits, even parity generates
 *        Startbit                         Par Stopbit
 *               0  0  0  0  0  0  0  0  0  0  1
 *  At 75 baud, 10 bits equals 133 millisec,  and minimum value of
 *  BRKRES is computed to 'divisor value'>>4 (192 millisec)
 *
 *  Available baudrates are defined in serial_api.h :
 *
 *  SERIAL_BAUDRATE_075_BPS(1)
 *  SERIAL_BAUDRATE_110_BPS(2)
 *  SERIAL_BAUDRATE_150_BPS(3)
 *  SERIAL_BAUDRATE_300_BPS(4)
 *  SERIAL_BAUDRATE_600_BPS(5)
 *  SERIAL_BAUDRATE_1200_BPS(6)
 *  SERIAL_BAUDRATE_1800_BPS(7)
 *  SERIAL_BAUDRATE_2400_BPS(8)
 *  SERIAL_BAUDRATE_4800_BPS(9)
 *  SERIAL_BAUDRATE_7200_BPS(10)
 *  SERIAL_BAUDRATE_9600_BPS(11)
 *  SERIAL_BAUDRATE_14400_BPS(12)
 *  SERIAL_BAUDRATE_19200_BPS(13)
 *  SERIAL_BAUDRATE_38400_BPS(14)
 *  SERIAL_BAUDRATE_57600_BPS(15)
 *  SERIAL_BAUDRATE_115200_BPS(16)
 *  SERIAL_BAUDRATE_230400_BPS(17)
 *  SERIAL_BAUDRATE_460800_BPS(18)
 *  SERIAL_BAUDRATE_921600_BPS(19)
 */

/* TI16550C (Atlas TTY0, SEAD TTY0+TTY1) */
static t_SERIAL_baudrate_div serial_baudrate_div_ti16550c =
{
    SERIAL_ILLEGAL,   /*  0:  not defined   */
              3072,   /*  1:      75 baud   */
              2094,   /*  2:     110 baud   */
              1536,   /*  3:     150 baud   */
               768,   /*  4:     300 baud   */
               384,   /*  5:     600 baud   */
               192,   /*  6:   1.200 baud   */
               128,   /*  7:   1.800 baud   */
                96,   /*  8:   2.400 baud   */
                48,   /*  9:   4.800 baud   */
                32,   /* 10:   7.200 baud   */
                24,   /* 11:   9.600 baud   */
                16,   /* 12:  14.400 baud   */
                12,   /* 13:  19.200 baud   */
                 6,   /* 14:  38.400 baud   */
                 4,   /* 15:  57.600 baud   */
                 2,   /* 16: 115.200 baud   */
                 1,   /* 17: 230.400 baud   */
    SERIAL_ILLEGAL,   /* 18: 460.800 baud   */
    SERIAL_ILLEGAL    /* 19: 921.600 baud   */
};

/* SMSC (Malta TTY0+TTY1, i.e. SMSC SuperIO) */
static t_SERIAL_baudrate_div serial_baudrate_div_smsc =
{
    SERIAL_ILLEGAL,   /*  0:  not defined   */
              1536,   /*  1:      75 baud   */
              1047,   /*  2:     110 baud   */
               768,   /*  3:     150 baud   */
               384,   /*  4:     300 baud   */
	       192,   /*  5:     600 baud   */
	        96,   /*  6:   1.200 baud   */
		64,   /*  7:   1.800 baud   */
		48,   /*  8:   2.400 baud   */
		24,   /*  9:   4.800 baud   */
		16,   /* 10:   7.200 baud   */
		12,   /* 11:   9.600 baud   */
                 8,   /* 12:  14.400 baud   */
                 6,   /* 13:  19.200 baud   */
		 3,   /* 14:  38.400 baud   */
		 2,   /* 15:  57.600 baud   */
		 1,   /* 16: 115.200 baud   */
             32770,   /* 17: 230.400 baud   */
             32769,   /* 18: 460.800 baud   */
    SERIAL_ILLEGAL    /* 19: 921.600 baud   */
};

/* SAA9730 (Atlas TTY1) */
static t_SERIAL_baudrate_div serial_baudrate_div_saa9730 =
{
    SERIAL_ILLEGAL,   /*  0:  not defined   */
            0x0c04,   /*  1:      75 baud   */
            0x0831,   /*  2:     110 baud   */
            0x0601,   /*  3:     150 baud   */
            0x0300,   /*  4:     300 baud   */
            0x017f,   /*  5:     600 baud   */
               191,   /*  6:   1.200 baud   */
               127,   /*  7:   1.800 baud   */
                95,   /*  8:   2.400 baud   */
                47,   /*  9:   4.800 baud   */
                31,   /* 10:   7.200 baud   */
                23,   /* 11:   9.600 baud   */
                15,   /* 12:  14.400 baud   */
                11,   /* 13:  19.200 baud   */
                 5,   /* 14:  38.400 baud   */
                 3,   /* 15:  57.600 baud   */
                 1,   /* 16: 115.200 baud   */
                 0,   /* 17: 230.400 baud   */
    SERIAL_ILLEGAL,   /* 18: 460.800 baud   */
    SERIAL_ILLEGAL    /* 19: 921.600 baud   */
};

/* Au1x00 UART divisors for CPU freq of 396 MHz. */
static t_SERIAL_baudrate_div serial_baudrate_div_Au1000 =
{
    SERIAL_ILLEGAL,   /*  0:  not defined   */
    SERIAL_ILLEGAL,   /*  1:      75 baud   */
    SERIAL_ILLEGAL,   /*  2:     110 baud   */
    SERIAL_ILLEGAL,   /*  3:     150 baud   */
    SERIAL_ILLEGAL,   /*  4:     300 baud   */
    SERIAL_ILLEGAL,   /*  5:     600 baud   */
    SERIAL_ILLEGAL,   /*  6:   1.200 baud   */
    SERIAL_ILLEGAL,   /*  7:   1.800 baud   */
    SERIAL_ILLEGAL,   /*  8:   2.400 baud   */
    SERIAL_ILLEGAL,   /*  9:   4.800 baud   */
    SERIAL_ILLEGAL,   /* 10:   7.200 baud   */
               645,   /* 11:   9.600 baud   */
    SERIAL_ILLEGAL,   /* 12:  14.400 baud   */
               322,   /* 13:  19.200 baud   */
               161,   /* 14:  38.400 baud   */
               107,   /* 15:  57.600 baud   */
                54,   /* 16: 115.200 baud   */
    SERIAL_ILLEGAL,   /* 17: 230.400 baud   */
    SERIAL_ILLEGAL,   /* 18: 460.800 baud   */
    SERIAL_ILLEGAL    /* 19: 921.600 baud   */
};

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

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


static UINT32
board_ti16c550c_base0_atlas_read(
    void *param,
    void *data )
{
    *(void **)param = (void *)ATLAS_TI16C550_BASE;
    return OK;
}


static UINT32
board_ti16c550c_base0_sead_read(
    void *param,
    void *data )
{
    *(void **)param = (void *)SEAD_TI16C550_DEV0_BASE;
    return OK;
}


static UINT32
board_ti16c550c_base0_malta_read(
    void *param,
    void *data )
{
    *(void **)param = (void *)MALTA_UART0ADR;
    return OK;
}


static UINT32
board_ti16c550c_base1_sead_read(
    void *param,
    void *data )
{
    *(void **)param = (void *)SEAD_TI16C550_DEV1_BASE;
    return OK;
}


static UINT32
board_ti16c550c_base1_malta_read(
    void *param,
    void *data )
{
    *(void **)param = 
        malta_tty1_on_texas ?
	    (void *)MALTA_TI16C550_BASE :
	    (void *)MALTA_UART1ADR;

    return OK;
}


static UINT32
com_baudrate_div_read(
    void *param,
    void *data )
{
    *(t_SERIAL_baudrate_div **)param = (t_SERIAL_baudrate_div *)data;
    return OK;
}

static UINT32
com_baudrate_verify_write(
    void *param,
    void *data )
{
    /*  No write is actually performed. Object is only used to verify
     *  that baudrate is valid.
     *  Return OK if baudrate is valid, else ERROR_SYSCON_UNKNOWN_PARAM.
     */
    UINT8		  baudrate = *(UINT8 *)param; 
    t_SERIAL_baudrate_div *array   = (t_SERIAL_baudrate_div *)data;
 
    return    
        ( ( baudrate > SERIAL_BAUDRATE_921600_BPS ) ||
          ( baudrate < SERIAL_BAUDRATE_075_BPS    ) ||
	  ( (*array)[baudrate] == SERIAL_ILLEGAL  ) 
	) ?
	    ERROR_SYSCON_UNKNOWN_PARAM : OK;
}


static UINT32
board_reg_size1_malta_read(
    void *param,
    void *data )
{
    return malta_tty1_on_texas ?
        syscon_uint8_read( param, (void *)&size32 ) :
        syscon_uint8_read( param, (void *)&size8 );
}


static UINT32
board_reg_space1_malta_read(
    void *param,
    void *data )
{
    return malta_tty1_on_texas ?
        syscon_uint8_read( param, (void *)&size64 ) :
        syscon_uint8_read( param, (void *)&size8 );
}


static UINT32
board_reg_ic1_malta_read(
    void *param,
    void *data )
{
    return malta_tty1_on_texas ?
        syscon_false_read( param, data ) :
	syscon_true_read( param, data );
}


static UINT32
board_baudrate1_div_malta_read(
    void *param,
    void *data )
{
    return malta_tty1_on_texas ?
	com_baudrate_div_read( param, (void *)&serial_baudrate_div_ti16550c) :
	com_baudrate_div_read( param, (void *)&serial_baudrate_div_smsc);
}


static UINT32
board_intline1_malta_read(
    void *param,
    void *data )
{
    return malta_tty1_on_texas ?
        syscon_uint32_read( param, &intline_malta_ti16550_2 ) :
        syscon_uint32_read( param, &intline_malta_ti16550_1 );
}


static UINT32
board_bigend1_malta_read(
    void *param,
    void *data )
{
    return malta_tty1_on_texas ?
        syscon_endian_big_read( param, data ) :
        syscon_false_read( param, data );

⌨️ 快捷键说明

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