📄 gpfifo.h
字号:
/*============================================================================
____________________________________________________________________________
______________________________________________
SSSS M M CCCC Standard Microsystems Corporation
S MM MM SSSS C Austin Design Center
SSS M M M S C 11000 N. Mopac Expressway
S M M SSS C Stonelake Bldg. 6, Suite 500
SSSS M M S CCCC Austin, Texas 78759
SSSS ______________________________________________
____________________________________________________________________________
Copyright(C) 1999, Standard Microsystems Corporation
All Rights Reserved.
This program code listing is proprietary to SMSC and may not be copied,
distributed, or used without a license to do so. Such license may have
Limited or Restricted Rights. Please refer to the license for further
clarification.
____________________________________________________________________________
Notice: The program contained in this listing is a proprietary trade
secret of SMSC, Hauppauge, New York, and is copyrighted
under the United States Copyright Act of 1976 as an unpublished work,
pursuant to Section 104 and Section 408 of Title XVII of the United
States code. Unauthorized copying, adaption, distribution, use, or
display is prohibited by this law.
____________________________________________________________________________
Use, duplication, or disclosure by the Government is subject to
restrictions as set forth in subparagraph(c)(1)(ii) of the Rights
in Technical Data and Computer Software clause at DFARS 52.227-7013.
Contractor/Manufacturer is Standard Microsystems Corporation,
80 Arkay Drive, Hauppauge, New York, 1178-8847.
____________________________________________________________________________
____________________________________________________________________________
<module name> - <module description>
____________________________________________________________________________
comments tbd
____________________________________________________________________________
Revision History
Date Who Comment
________ ___ _____________________________________________________________
07/16/99 tbh -initial version
01/02/01 tbh -back port for the '100
03/15/01 tbh -merged 10x and 20x versions for improved maintainability
-converted api macros into functions to facilitate
implementation, and facilitate debugging with an ice
09/22/02 tbh eliminated unused code on 20x builds
============================================================================*/
//------------------------------------------------------------------------------
// IMPORTANT NOTE:
// The macro versions of the functions are faster, but trickier to use properly.
// they exist only to improve the performance of the kernel. If you personally
// choose to use the macro versions (to squeeze out evert ounce of performance)
// then you should make sure you understand any differences between the macros
// and the functions, and how that can affect your implementation.
//------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------
// Name:
// _gpfifo_purge
//
// Declaration:
// void _gpfifo_purge(uint8 fifo);
//
// Purpose:
// Pops the specified gpfifo until it is empty.
// Fast version for kernel.
//
// Arguments:
// 10x:
// fifo - a number 1..4 indicating the target gpfifo.
// 20x:
// The 20x does not have any gpfifos.
//
// Return:
// None.
//
// Notes:
// For the 10x family only.
// This macro uses the token pasting operator. Therefore, you cannot pass
// a symbolic constant for the fifo parameter, such as "myfifo". You must
// pass a literal numeric constant.
//
// This is the macro version of gpfifo_purge().
// It is faster than the function. Use where performance is critical.
//
// Since:
// MinimOS-1.0
//------------------------------------------------------------------------------
#define _gpfifo_purge(__fifo) \
{ while (!_gpfifo_is_empty((__fifo))) _gpfifo_rd((__fifo)); g_ndp##__fifo##npkt = 0; }
//+-----------------------------------------------------------------------------
// Name:
// _gpfifo_is_full
//
// Declaration:
// t_bool _gpfifo_is_full(uint8 fifo);
//
// Purpose:
// Checks to see if a gpfifo is full.
// Fast version for kernel.
//
// Arguments:
// 10x:
// fifo - a number 1..4 indicating the target gpfifo.
// 20x:
// The 20x does not have any gpfifos.
//
// Return:
// k_false - not empty.
// k_true - empty.
//
// Notes:
// For the 10x family only.
// This macro uses the token pasting operator. Therefore, you cannot pass
// a symbolic constant for the fifo parameter, such as "myfifo". You must
// pass a literal numeric constant.
//
// Notes:
// This is the macro version of gpfifo_is_full().
// It is faster than the function. Use where performance is critical.
//
// Since:
// MinimOS-1.0
//------------------------------------------------------------------------------
#define _gpfifo_is_full(__fifo) (x_gpfifo##__fifo##_sts & kbm_gpfifo_full)
//+-----------------------------------------------------------------------------
// Name:
// _gpfifo_is_empty
//
// Declaration:
// t_bool _gpfifo_is_empty(uint8 fifo);
//
// Purpose:
// Checks to see if a gpfifo is empty.
// Fast version for kernel.
//
// Arguments:
// 10x:
// fifo - a number 1..4 indicating the target gpfifo.
// 20x:
// The 20x does not have any gpfifos.
//
// Return:
// k_false - not empty.
// k_true - empty.
//
// Notes:
// For the 10x family only.
// This macro uses the token pasting operator. Therefore, you cannot pass
// a symboloc constant for the fifo parameter, such as "myfifo". You must
// pass a literal numeric constant.
//
// This is the macro version of gpfifo_is_empty().
// It is faster than the function. Use where performance is critical.
//
// Since:
// MinimOS-1.0
//------------------------------------------------------------------------------
#define _gpfifo_is_empty(__fifo) (x_gpfifo##__fifo##_sts & kbm_gpfifo_empty)
//+-----------------------------------------------------------------------------
// Name:
// _gpfifo_rd
//
// Declaration:
// uint8 _gpfifo_rd(uint8 fifo);
//
// Purpose:
// Pops a byte off a gpfifo.
// Fast version for kernel.
//
// Arguments:
// 10x:
// fifo - a number 1..4 indicating the target gpfifo.
// 20x:
// The 20x does not have any gpfifos.
//
// Return:
// The byte popped from the fifo.
//
// Notes:
// BEWARE OF UNDERFLOW - if you read an empty gpfifo the it will BREAK!
// This is a hardware annoyance. Be sure you check for not empty first.
// For the 10x family only.
// This macro uses the token pasting operator. Therefore, you cannot pass
// a symboloc constant for the fifo parameter, such as "myfifo". You must
// pass a literal numeric constant.
//
// This is the macro version of gpfifo_rd().
// It is faster than the function. Use where performance is critical.
//
// Since:
// MinimOS-1.0
//------------------------------------------------------------------------------
#define _gpfifo_rd(__fifo) (g_ndp##__fifo##npkt--, x_gpfifo##__fifo);
//+-----------------------------------------------------------------------------
// Name:
// _gpfifo_wr
//
// Declaration:
// void _gpfifo_wr(uint8 fifo, uint8 val);
//
// Purpose:
// Pushes a byte onto a gpfifo.
// Fast version for kernel.
//
// Arguments:
// 10x:
// fifo - a number 1..4 indicating the target gpfifo.
// val - the data byte to be pushed onto the fifo.
// 20x:
// The 20x does not have any gpfifos.
//
// Return:
// None.
//
// Notes:
// BEWARE OF OVERFLOW - if you write a full gpfifo the it will BREAK!
// This is a hardware annoyance. Be sure you check for not full first.
// For the 10x family only.
// This macro uses the token pasting operator. Therefore, you cannot pass
// a symboloc constant for the fifo parameter, such as "myfifo". You must
// pass a literal numeric constant.
//
// This is the macro version of gpfifo_wr().
// It is faster than the function. Use where performance is critical.
//
// Since:
// MinimOS-1.0
//------------------------------------------------------------------------------
#define _gpfifo_wr(__fifo, __datum) { x_gpfifo##__fifo = (__datum); g_ndp##__fifo##npkt++; }
//------------------------------------------------------------------------------
// prototypes
void gpfifo_purge(uint8 fifo) reentrant;
t_bool gpfifo_is_full(uint8 fifo) reentrant;
t_bool gpfifo_is_empty(uint8 fifo) reentrant;
uint8 gpfifo_rd(uint8 fifo) reentrant;
void gpfifo_wr(uint8 fifo, uint8 val) reentrant;
//------------------------------------------------------------------------------
// eliminate code stubs to help fit 242 in 48K masked rom
#ifdef k_20x_family
#define gpfifo_purge(__f)
#define gpfifo_is_full(__f)
#define gpfifo_is_empty(__f)
#define gpfifo_rd(__f)
#define gpfifo_wr(__f, __v)
#endif
//---eof------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -