📄 common.h
字号:
/*----------------------------------------------------------------------------
* Copyright (c) 2001 by National Semiconductor Corporation
* National Semiconductor Corporation
* 2900 Semiconductor Drive
* Santa Clara, California 95051
*
* All rights reserved
*
*<<<-------------------------------------------------------------------------
* File Contents: Common definitions, the file is used with all .C files
*
* Project: USB firmware
* Author : Avi Fishman (Avi.Fishman@nsc.com)
* Date : Sep 97
*----------------------------------------------------------------------->>>*/
#include <asm.h>
#ifndef __common__
#define __common__
#define DEVELOP 1
#define PRODUCTION 2
#ifdef DEBUG
#define MODE DEVELOP
#else
#define MODE PRODUCTION
#endif
#ifdef VIO
#define dprintf(_x_) printf _x_
#else
#define dprintf(_x_)
#define puts(_x_)
#endif
#define FALSE 0
#define TRUE 1
#define OFF 0
#define ON 1
#ifndef NULL
#define NULL 0
#endif
#define FIREWALL_val 0xdead
#define SET_FIREWALL(loc) (* (int *)(loc) = FIREWALL_val)
#define CHK_FIREWALL(loc) assert (* (int *)(loc) == FIREWALL_val)
#define MAXUINT 0xffff
#define MAXINT 0x7fff
#define MAXULONG 0xffffffff
#define MAXLONG 0x7fffffff
#ifndef MKDECLARE
#define private static
#define public
#endif MKDECLARE
#define E_COMMAND FALSE
#define E_DATA TRUE
/*
** global types definitions
*/
typedef unsigned char u_char;
typedef unsigned __far char u_char_far;
typedef unsigned short u_short;
typedef unsigned __far short u_short_far;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned __far long u_long_far;
typedef int (*func_t)(void);
typedef void (*proc_t)(void);
typedef void (*handler_t)(void);
typedef int boolean ;
typedef unsigned char byte;
typedef unsigned int two_bytes;
typedef unsigned int word;
typedef unsigned long dword;
typedef u_long time_t; /* In clock-ticks */
/*
** macros for low-level busy-waits
*/
#define wait_until(x) do ; while (!(x))
#define wait_while(x) do ; while ((x))
/*
** hardware type related definitions
*/
#define SYS_CONST(x) ((int) &(x))
#define hw_char *(volatile unsigned char *)
#define hw_short *(volatile unsigned short *)
#define hw_int *(volatile unsigned int *)
/*
* 'exp' is done with no interrupts in between. This is particularly required
* in three cases:
* 1. read-modify-write operations on the foreground, on a variable which
* might be used for rmw in the background.
* 2. rmw operation on Bg process, while the same variable might be used for
* rmw on another Bg process.
* 3. On 16bits machine (vm16) when writing a 32bits variable (LONG) into the
* memory, in this case, two 'storw' operations are involve.
*/
static __inline__ int abs(int val)
{
return ((val > 0)? (val) : -(val));
}
static __inline__ int min(dword val1, dword val2)
{
return (((val1) < (val2))? (val1) : (val2));
}
# ifndef _QUOTE /* define _QUOTE just once */
# ifdef __STDC__
# define _QUOTE(s) #s
# else
# define _QUOTE(s) "s"
# endif
# endif
# define assert(cond) if(!(cond)) \
panic("assert failed: " _QUOTE(cond))
#ifndef MASK
#define MASK(i) ( 1 << (i) )
#endif defined MASK
#ifdef BPT
#define ROM_BPT \
__asm__("push $1,r0"); \
__asm__("movw $0,r0"); \
__asm__("lpr sp,carl"); \
__asm__("lpr r0,carh"); \
__asm__("movw $0xc1,r0"); \
__asm__("lpr r0,dcr"); \
__asm__("pop $1, r0");
#else
#define ROM_BPT
#endif BPT
#ifdef DEBUG
# define PANIC(x) panic(x)
#else
# define PANIC(x) panic(0)
#endif
#define SET_BIT(reg, bit_mask) ((reg) | (bit_mask))
#define CLEAR_BIT(reg, bit_mask) ((reg) & ~(bit_mask))
#define IS_BIT_SET(reg, bit_mask) ((reg) & (bit_mask))
#endif // __common__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -