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

📄 common.h

📁 Vitesse 24port gigabit Switch Source Code
💻 H
字号:
/*

    Copyright (c) 2002-2005 Vitesse Semiconductor Corporation "Vitesse".  
    All Rights Reserved.  Unpublished rights reserved under the copyright laws
    of the United States of America, other countries and international treaties.
    The software is provided without a fee. Permission to use, copy, store and 
    modify, the software and its source code is granted. Permission to integrate
    into other products, disclose, transmit and distribute the software in an
    absolute machine readable format (e.g. HEX file) is also granted. 

    The source code of the software may not be disclosed, transmitted or
    distributed without the written permission of Vitesse. The software and its
    source code may only be used in products utilizing a Vitesse VSC73xx product.
 
    This copyright notice must appear in any copy, modification, disclosure,
    transmission or distribution of the software. Vitesse retains all ownership,
    copyright, trade secret and proprietary rights in the software.  

    THIS SOFTWARE HAS BEEN PROVIDED "AS IS," WITHOUT EXPRESS OR IMPLIED WARRANTY
    INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR USE AND NON-INFRINGEMENT.

*/
#ifndef __COMMON_H__
#define __COMMON_H__

#include "swconf.h"

/*
** General types
*/
#define uchar   unsigned char
#define uint    unsigned int
#define ulong   unsigned long
#define ushort  unsigned short
#define bool    bit

typedef union {
    uchar  b [4];
    ushort w [2];
    ulong  l;
} ul_union_t;

#define MAC_ADDR_LEN 6
typedef uchar mac_addr_t [MAC_ADDR_LEN];

#define FALSE  0
#define TRUE   1

#define ARRAY_LENGTH( arr ) (sizeof(arr) / sizeof(arr[0]))


/*
** Macros for optimizing access to non-byte variables
*/

/* for read */
#define LOW_BYTE(v) ((uchar) (v))
#define HIGH_BYTE(v) ((uchar) (((ushort) (v)) >> 8))

/* for write */
#define BYTE_LOW(v) (*(((uchar *) (&v) + 1)))
#define BYTE_HIGH(v) (*((uchar *) (&v)))

/* convert 2 bytes to an ushort */
#define MK_USHORT(H,L)  ( (ushort)( ((H)<<8) | (L) ) )


/* 
** Define number of ports and related declarations
*/
#if !defined(LUTON_G16) && !defined(LUTON_G16R)
#define MIN_PORT   0
#define MAX_PORT  24
#define NO_OF_PORTS 24
#define port_bit_mask_t ulong
#define PORT_BIT_MASK(bit_no)  bit_mask_32((bit_no))
#define ALL_PORTS 0x00FFFFFF
#define WRITE_PORT_BIT_MASK(bit_no,bit_val,dst_ptr)  write_bit_32((bit_no), (bit_val), (dst_ptr))
#define TEST_PORT_BIT_MASK(bit_no,dst_ptr)  test_bit_32((bit_no), (dst_ptr))
#elif !defined(LUTON_G16R)
#define MIN_PORT   0
#define MAX_PORT  16
#define NO_OF_PORTS 16
#define port_bit_mask_t ulong
#define PORT_BIT_MASK(bit_no)  bit_mask_32((bit_no))
#define ALL_PORTS 0x0000FFFF
#define WRITE_PORT_BIT_MASK(bit_no,bit_val,dst_ptr)  write_bit_32((bit_no), (bit_val), (dst_ptr))
#define TEST_PORT_BIT_MASK(bit_no,dst_ptr)  test_bit_32((bit_no), (dst_ptr))
#else
#define MIN_PORT   8
#define MAX_PORT  24
#define NO_OF_PORTS 16
#define port_bit_mask_t ulong
#define PORT_BIT_MASK(bit_no)  bit_mask_32((bit_no))
#define ALL_PORTS 0x00FFFF00
#define WRITE_PORT_BIT_MASK(bit_no,bit_val,dst_ptr)  write_bit_32((bit_no), (bit_val), (dst_ptr))
#define TEST_PORT_BIT_MASK(bit_no,dst_ptr)  test_bit_32((bit_no), (dst_ptr))
#endif



#define TICKIT(EXPR)     EXPR

/* NULL xdata pointer */
#define XNULL ((void xdata*)0)

/* Max allowed VLAN Identifier */
#define MAX_ALLOWED_VLAN_ID 4094

#endif /* __COMMON_H__ */

⌨️ 快捷键说明

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