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

📄 serial_api.h

📁 MIPS下的boottloader yamon 的源代码
💻 H
字号:

/************************************************************************
 *
 *      SERIAL_api.h
 *
 *      The 'serial_api' module defines the serial device driver
 *      interface to be used via 'IO' device driver services:
 *
 *        1) init  serial device:  configure and initialize serial driver
 *        2) open  serial device:  not used
 *        3) close serial device:  not used
 *        4) read  serial device:  read character
 *        5) write serial device:  write character
 *        6) ctrl  serial device:  write character string
 *
 *
 *
 * ######################################################################
 *
 * 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. 
 *
 ************************************************************************/

#ifndef SERIAL_API_H
#define SERIAL_API_H

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

#include <sysdefs.h>
#include <syserror.h>

/************************************************************************
 *   Serial device driver, ERROR completion codes
*************************************************************************/

/* Serial device driver, baudrate configuration definitions */
typedef enum SERIAL_baudrate_ids
{
    SERIAL_BAUDRATE_NOT_DEFINED =  0,
    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,
    SERIAL_BAUDRATE_MAX         = 20
} 
t_SERIAL_baudrate_ids;

#define SERIAL_ILLEGAL           0xff    /* ILLEGAL CONTROL VALUE	*/

typedef UINT16 t_SERIAL_baudrate_div[SERIAL_BAUDRATE_MAX];


/* Serial device driver, data bits configuration definitions */
typedef enum SERIAL_databits_ids
{
    SERIAL_DATABITS_NOT_DEFINED =  0,
    SERIAL_DATABITS_7           =  1,
    SERIAL_DATABITS_8           =  2,
    SERIAL_DATABITS_MAX         =  3
} 
t_SERIAL_databits_ids;

/* Serial device driver, parity configuration definitions */
typedef enum SERIAL_parity_ids
{
    SERIAL_PARITY_NOT_DEFINED   =  0,
    SERIAL_PARITY_NONE          =  1,
    SERIAL_PARITY_ODD           =  2,
    SERIAL_PARITY_EVEN          =  3,
    SERIAL_PARITY_MAX           =  4
} 
t_SERIAL_parity_ids;

/* Serial device driver, stop bits configuration definitions */
typedef enum SERIAL_stopbits_ids
{
    SERIAL_STOPBITS_NOT_DEFINED =  0,
    SERIAL_STOPBITS_10          =  1,
    SERIAL_STOPBITS_15          =  2,
    SERIAL_STOPBITS_20          =  3,
    SERIAL_STOPBITS_MAX         =  4
} 
t_SERIAL_stopbits_ids;

/* Serial device driver, flow control configuration definitions */
typedef enum SERIAL_flowctrl_ids
{
    SERIAL_FLOWCTRL_NOT_DEFINED =  0,
    SERIAL_FLOWCTRL_NONE        =  1,
    SERIAL_FLOWCTRL_HARDWARE    =  2,
    SERIAL_FLOWCTRL_XON_XOFF    =  3,
} 
t_SERIAL_flowctrl_ids;


/************************************************************************
 *  Serial device driver, minor device numbers
*************************************************************************/

/* Maximum number of TI16550 devices supported:                         */
#define SERIAL_MAX_16550_DEVICES        2
#define SERIAL_MINOR_TI16550_UART0	0    /* TI16550 UART subdev 0  */
#define SERIAL_MINOR_TI16550_UART1	1    /* TI16550 UART subdev 1  */

/* Maxinum number of Alchemy devices supported varies per processor */
#define SERIAL_MINOR_AU1x00_UART0 0
#define SERIAL_MINOR_AU1x00_UART1 1
#define SERIAL_MINOR_AU1x00_UART2 2
#define SERIAL_MINOR_AU1x00_UART3 3


/* Only one SAA9730 device */
#define SERIAL_MINOR_SAA9730_UART	0    /* SAA9730 UART            */

/************************************************************************
 *  Serial device driver, configuration enumerations
*************************************************************************/

typedef enum SERIAL_error_ids
{
    ERROR_SERIAL_NO_CHARACTER           /* No character present on chan */
		= ERROR_SERIAL,  
    ERROR_SERIAL_COMM_ERROR,            /* Communication error detected */
    ERROR_SERIAL_COMM_BREAK,            /* 'BREAK' detected */
    ERROR_SERIAL_UNKNOWN_DEVICE,        /* Unknown device               */
    ERROR_SERIAL_INVALID_BAUDRATE,      /* Invalid baudrate selected    */
    ERROR_SERIAL_INVALID_DATABITS,      /* Invalid databits selected    */
    ERROR_SERIAL_INVALID_PARITY,        /* Invalid parity selected      */
    ERROR_SERIAL_INVALID_STOPBITS,      /* Invalid stopbits selected    */
    ERROR_SERIAL_INVALID_ARGUMENT,      /* Invalid _ctrl argument       */

/******* ADD NEW IO ERROR TAGS JUST BEFORE THIS LINE ONLY *******/

} t_SERIAL_error_ids;


/* SERIAL 'ctrl' service, command codes */
typedef enum SERIAL_ctrl_command_ids
{
    SERIAL_CTRL_POLL_BREAK = 0,      /* SERIAL poll for break or ctrl/c */
    SERIAL_CTRL_GET_STATISTICS,           /* SERIAL get uart statistics */
    SERIAL_CTRL_GET_LSR,        /* SERIAL get uart line status register */
    SERIAL_CTRL_RCV_IRQ,            /* SERIAL interrupt service routine */
    SERIAL_CTRL_RCV_IRQ_ON,          /* SERIAL set uart receive irq bit */
    SERIAL_CTRL_RCV_IRQ_OFF,       /* SERIAL clear uart receive irq bit */
    SERIAL_CTRL_FORCE_DTR,        /* SERIAL set uart dtr line on or off */
    SERIAL_CTRL_GET_MSR,       /* SERIAL get uart modem status register */
    SERIAL_CTRL_SEND_BREAK         /* SERIAL send BREAK on tx data line */
} 
t_SERIAL_ctrl_command_ids;


/************************************************************************
 *  Parameter definitions
*************************************************************************/


typedef struct UART_statistics {
  UINT32 ua_tx_bytes ;
  UINT32 ua_rx_bytes ;
  UINT32 ua_rx_overrun ;
  UINT32 ua_rx_parity ;
  UINT32 ua_rx_framing ;
  UINT32 ua_rx_break ;
  UINT32 ua_rx_irqs ;
  UINT32 ua_no_of_init ;
} 
t_UART_statistics ;


typedef struct SERIAL_ctrl_descriptor
{
    UINT32 sc_command ;    /* IN: 'ctrl' command (SERIAL_POLL_INTR,..)      */
    union {
       t_UART_statistics  sc_statistics;  /* OUT: statistics since last     */
                                          /*        call of SERIAL_init()   */
       UINT32             sc_linestat;    /* OUT: uart line status register */
       UINT32             sc_dtr;         /* IN:  uart dtr control          */
       UINT32             sc_msr;         /* OUT: uart modem status registr */
       UINT32             sc_fill[8];     /* IN/OUT for new ioctl commands  */
    } sc_arg;

} 
t_SERIAL_ctrl_descriptor ;


/************************************************************************
 *  Serial device driver services, called by IO subsystem 
 *  (open, close not used )
 ************************************************************************/



/************************************************************************
 *
 *                          SERIAL_TI16550_init
 *  Description :
 *  -------------
 *  This service initializes the serial driver and configures
 *  the applicable channels according to the configuration data, read
 *  from SYSCON
 *
 *  Parameters :
 *  ------------
 *
 *  'major',     IN,    major device number
 *  'minor',     IN,    not used
 *  'port',      IN,	port mapping (PORT_TTY0/PORT_TTY1)
 *
 *  Return values :
 *  ---------------
 *
 *  'OK'(=0)
 *
 ************************************************************************/
typedef INT32 (*t_serial_init_service)(
    UINT32 major,          /* IN: major device number			*/
    UINT32 minor,          /* IN: minor device number			*/
    UINT32 *port );        /* IN: port mapping				*/


/************************************************************************
 *
 *                          SERIAL_TI16550_read
 *  Description :
 *  -------------
 *  This service polls the specified channel for any present character.
 *  If any character is present, it will be read into the user allocated
 *  variable; if none present, completion = 'ERROR_SERIAL_NO_CHARACTER'
 *  will be returned.
 *
 *  Parameters :
 *  ------------
 *
 *  'major',     IN,    major device number
 *  'minor',     IN,    minor device number for multi device drivers
 *  'p_param',   OUT,   character read
 *
 *  Return values :
 *  ---------------
 *  'OK' = 0x00:                 character read into user variable
 *  'ERROR_SERIAL_NO_CHARACTER': no character present on channel
 *  'ERROR_SERIAL_COMM_ERROR':   communication error detected
 *  'ERROR_SERIAL_COMM_BREAK':   'BREAK' detected
 *
 ************************************************************************/
typedef INT32 (*t_serial_read_service)( 
    UINT32 major,          /* IN: major device number			*/
    UINT32 minor,          /* IN: minor device number			*/
    UINT8  *p_param );     /* OUT: character been read			*/


/************************************************************************
 *
 *                          SERIAL_TI16550_write
 *  Description :
 *  -------------
 *  This service writes a character on the specified channel
 *
 *  Parameters :
 *  ------------
 *
 *  'major',     IN,    major device number
 *  'minor',     IN,    minor device number for multi device drivers
 *  'p_param',   IN,    pointer to character to write
 *
 *  Return values :
 *  ---------------
 *  'OK' = 0x00:                 character has been written on channel
 *
 ************************************************************************/
typedef INT32 (*t_serial_write_service)( 
    UINT32 major,          /* IN: major device number			*/
    UINT32 minor,          /* IN: minor device number			*/
    UINT8  *p_param );     /* IN: pointer to character to write		*/


/************************************************************************
 *
 *                          SERIAL_TI16550_ctrl
 *  Description :
 *  -------------
 *  This service performs the actions defined by t_SERIAL_ctrl_command_ids
 *  on the specified channel.
 *
 *  Parameters :
 *  ------------
 *
 *  'major',     IN,    major device number
 *  'minor',     IN,    minor device number for multi device drivers
 *  'p_param',   INOUT, IOCTL structure
 *
 *  Return values :
 *  ---------------
 *  'OK' = 0x00:                 normal return
 *  ERROR_SERIAL_COMM_BREAK:     break or ctrl/c received 
 *  ERROR_SERIAL_COMM_ERROR:     receive error, characters lost
 *
 ************************************************************************/
typedef INT32 (*t_serial_ctrl_service)( 
    UINT32 major,          /* IN: major device number			*/
    UINT32 minor,          /* IN: minor device number			*/
    t_SERIAL_ctrl_descriptor *p_param ); /* INOUT: IOCTL structure	*/


#endif /* #ifndef SERIAL_API_H */

⌨️ 快捷键说明

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