📄 hal_if.h
字号:
#ifndef CYGONCE_HAL_HAL_IF_H#define CYGONCE_HAL_HAL_IF_H//=============================================================================//// hal_if.h//// HAL header for ROM/RAM calling interface.////=============================================================================//####ECOSGPLCOPYRIGHTBEGIN####// -------------------------------------------// This file is part of eCos, the Embedded Configurable Operating System.// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.// Copyright (C) 2002, 2003, 2004 Gary Thomas//// eCos is free software; you can redistribute it and/or modify it under// the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 or (at your option) any later version.//// eCos is distributed in the hope that it will be useful, but WITHOUT ANY// WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License// for more details.//// You should have received a copy of the GNU General Public License along// with eCos; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.//// As a special exception, if other files instantiate templates or use macros// or inline functions from this file, or you compile this file and link it// with other works to produce a work based on this file, this file does not// by itself cause the resulting work to be covered by the GNU General Public// License. However the source code for this file must still be made available// in accordance with section (3) of the GNU General Public License.//// This exception does not invalidate any other reasons why a work based on// this file might be covered by the GNU General Public License.//// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.// at http://sources.redhat.com/ecos/ecos-license/// -------------------------------------------//####ECOSGPLCOPYRIGHTEND####//=============================================================================//#####DESCRIPTIONBEGIN####//// Author(s): jskov// Contributors:jskov, woehler// Date: 2000-06-07// Purpose: HAL RAM/ROM calling interface// Description: ROM/RAM calling interface table definitions. The layout is a// combination of libbsp and vectors already in use by some// eCos platforms.// Usage: #include <cyg/hal/hal_if.h>// //####DESCRIPTIONEND####////=============================================================================#include <cyg/infra/cyg_type.h> // types & externC#include <cyg/hal/dbg-threads-api.h>#include <cyg/hal/dbg-thread-syscall.h>#include <stdarg.h>#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT// Architecture/var/platform may override the accessor macros.#include <cyg/hal/hal_arch.h>// Special monitor locking procedures. These are necessary when the monitor// and eCos share facilities, e.g. the network hardware.#ifdef CYGPKG_NET#include <cyg/hal/hal_intr.h>#include <cyg/hal/drv_api.h> // cyg_drv_dsr_lock(), etc#define _ENTER_MONITOR() \ cyg_uint32 ints; \ HAL_DISABLE_INTERRUPTS(ints); \ cyg_drv_dsr_lock()#define _EXIT_MONITOR() \ cyg_drv_dsr_unlock(); \ HAL_RESTORE_INTERRUPTS(ints)#else // !CYGPKG_NET#define _ENTER_MONITOR() CYG_EMPTY_STATEMENT#define _EXIT_MONITOR() CYG_EMPTY_STATEMENT#endif//--------------------------------------------------------------------------#ifndef _BSP_HANDLER_T_DEFINED#define _BSP_HANDLER_T_DEFINEDtypedef int (*bsp_handler_t)(int __irq_nr, void *__regs);#endif // _BSP_HANDLER_T_DEFINED//--------------------------------------------------------------------------// Communication interface table. CYGNUM_CALL_IF_CONSOLE_PROCS and// CYGNUM_CALL_IF_DEBUG_PROCS point to instances (possibly the same)// of this table.typedef enum { /* * For serial ports, the control function may be used to set and get the * current baud rate. Usage: * * err = (*__control)(COMMCTL_SETBAUD, int bits_per_second); * err => Zero if successful, -1 if error. * * baud = (*__control)(COMMCTL_GETBAUD); * baud => -1 if error, current baud otherwise. */ __COMMCTL_SETBAUD=0, __COMMCTL_GETBAUD, /* * Install and remove debugger interrupt handlers. These are the receiver * interrupt routines which are used to change control from a running * program to the debugger stub. */ __COMMCTL_INSTALL_DBG_ISR, __COMMCTL_REMOVE_DBG_ISR, /* * Disable comm port interrupt. Returns TRUE if interrupt was enabled, * FALSE otherwise. */ __COMMCTL_IRQ_DISABLE, /* * Enable comm port interrupt. */ __COMMCTL_IRQ_ENABLE, /* * Returns the number of the interrupt vector used by the debug * interrupt handler. */ __COMMCTL_DBG_ISR_VECTOR, /* * Returns the current timeout value and sets a new timeout. * Timeout resolution is in milliseconds. * old_timeout = (*__control)(__COMMCTL_SET_TIMEOUT, * cyg_int32 new_timeout); */ __COMMCTL_SET_TIMEOUT, /* * Forces driver to send all characters which may be buffered in * the driver. This only flushes the driver buffers, not necessarily * any hardware FIFO, etc. */ __COMMCTL_FLUSH_OUTPUT, /* * Forces driver to enable or disable flushes when a newline is * seen in the output stream. Flushing at line boundaries occurs * in the driver, not necessarily any hardware FIFO, etc. Line * buffering is optional and may only be available in some drivers. */ __COMMCTL_ENABLE_LINE_FLUSH, __COMMCTL_DISABLE_LINE_FLUSH,} __comm_control_cmd_t;#define CYGNUM_COMM_IF_CH_DATA 0#define CYGNUM_COMM_IF_WRITE 1#define CYGNUM_COMM_IF_READ 2#define CYGNUM_COMM_IF_PUTC 3#define CYGNUM_COMM_IF_GETC 4#define CYGNUM_COMM_IF_CONTROL 5#define CYGNUM_COMM_IF_DBG_ISR 6#define CYGNUM_COMM_IF_GETC_TIMEOUT 7#define CYGNUM_COMM_IF_TABLE_SIZE 8typedef volatile CYG_ADDRWORD hal_virtual_comm_table_t[CYGNUM_COMM_IF_TABLE_SIZE];// The below is a (messy) attempt at adding some type safety to the// above array. At the same time, the accessors allow the// implementation to be easily changed in the future (both tag->data// table and structure implementations have been suggested).typedef void* __comm_if_ch_data_t;typedef void (*__comm_if_write_t)(void* __ch_data, const cyg_uint8* __buf, cyg_uint32 __len);typedef int (*__comm_if_read_t)(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len);typedef void (*__comm_if_putc_t)(void* __ch_data, cyg_uint8 __ch);typedef cyg_uint8 (*__comm_if_getc_t)(void* __ch_data);typedef int (*__comm_if_control_t)(void *__ch_data, __comm_control_cmd_t __func, ...);typedef int (*__comm_if_dbg_isr_t)(void *__ch_data, int* __ctrlc, CYG_ADDRWORD __vector, CYG_ADDRWORD __data);typedef cyg_bool (*__comm_if_getc_timeout_t)(void* __ch_data, cyg_uint8* __ch);#define __call_COMM0(_n_,_rt_,_t_) \static __inline__ _rt_ \__call_COMM_##_n_(hal_virtual_comm_table_t t) \{ \ _rt_ res; \ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \ _ENTER_MONITOR(); \ res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp); \ _EXIT_MONITOR(); \ return res; \}#define __call_voidCOMM(_n_,_rt_,_t_) \static __inline__ _rt_ \__call_COMM_##_n_(hal_virtual_comm_table_t t) \{ \ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \ _ENTER_MONITOR(); \ ((_t_)(t[CYGNUM_COMM_##_n_]))(dp); \ _EXIT_MONITOR(); \}#define __call_COMM1(_n_,_rt_,_t_,_t1_) \static __inline__ _rt_ \__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_) \{ \ _rt_ res; \ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \ _ENTER_MONITOR(); \ res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_); \ _EXIT_MONITOR(); \ return res; \}#define __call_voidCOMM1(_n_,_rt_,_t_,_t1_) \static __inline__ _rt_ \__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_) \{ \ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \ _ENTER_MONITOR(); \ ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_); \ _EXIT_MONITOR(); \}#define __call_COMM2(_n_,_rt_,_t_,_t1_,_t2_) \static __inline__ _rt_ \__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_) \{ \ _rt_ res; \ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -