Back to home page

OSCL-LXR

 
 

    


0001 /* $Id: capiutil.h,v 1.5.6.2 2001/09/23 22:24:33 kai Exp $
0002  *
0003  * CAPI 2.0 defines & types
0004  *
0005  * From CAPI 2.0 Development Kit AVM 1995 (msg.c)
0006  * Rewritten for Linux 1996 by Carsten Paeth <calle@calle.de>
0007  *
0008  * This software may be used and distributed according to the terms
0009  * of the GNU General Public License, incorporated herein by reference.
0010  *
0011  */
0012 
0013 #ifndef __CAPIUTIL_H__
0014 #define __CAPIUTIL_H__
0015 
0016 #include <asm/types.h>
0017 
0018 #define CAPIMSG_BASELEN     8
0019 #define CAPIMSG_U8(m, off)  (m[off])
0020 #define CAPIMSG_U16(m, off) (m[off]|(m[(off)+1]<<8))
0021 #define CAPIMSG_U32(m, off) (m[off]|(m[(off)+1]<<8)|(m[(off)+2]<<16)|(m[(off)+3]<<24))
0022 #define CAPIMSG_LEN(m)      CAPIMSG_U16(m,0)
0023 #define CAPIMSG_APPID(m)    CAPIMSG_U16(m,2)
0024 #define CAPIMSG_COMMAND(m)  CAPIMSG_U8(m,4)
0025 #define CAPIMSG_SUBCOMMAND(m)   CAPIMSG_U8(m,5)
0026 #define CAPIMSG_CMD(m)      (((m[4])<<8)|(m[5]))
0027 #define CAPIMSG_MSGID(m)    CAPIMSG_U16(m,6)
0028 #define CAPIMSG_CONTROLLER(m)   (m[8] & 0x7f)
0029 #define CAPIMSG_CONTROL(m)  CAPIMSG_U32(m, 8)
0030 #define CAPIMSG_NCCI(m)     CAPIMSG_CONTROL(m)
0031 #define CAPIMSG_DATALEN(m)  CAPIMSG_U16(m,16) /* DATA_B3_REQ */
0032 
0033 static inline void capimsg_setu8(void *m, int off, __u8 val)
0034 {
0035     ((__u8 *)m)[off] = val;
0036 }
0037 
0038 static inline void capimsg_setu16(void *m, int off, __u16 val)
0039 {
0040     ((__u8 *)m)[off] = val & 0xff;
0041     ((__u8 *)m)[off+1] = (val >> 8) & 0xff;
0042 }
0043 
0044 static inline void capimsg_setu32(void *m, int off, __u32 val)
0045 {
0046     ((__u8 *)m)[off] = val & 0xff;
0047     ((__u8 *)m)[off+1] = (val >> 8) & 0xff;
0048     ((__u8 *)m)[off+2] = (val >> 16) & 0xff;
0049     ((__u8 *)m)[off+3] = (val >> 24) & 0xff;
0050 }
0051 
0052 #define CAPIMSG_SETLEN(m, len)      capimsg_setu16(m, 0, len)
0053 #define CAPIMSG_SETAPPID(m, applid) capimsg_setu16(m, 2, applid)
0054 #define CAPIMSG_SETCOMMAND(m,cmd)   capimsg_setu8(m, 4, cmd)
0055 #define CAPIMSG_SETSUBCOMMAND(m, cmd)   capimsg_setu8(m, 5, cmd)
0056 #define CAPIMSG_SETMSGID(m, msgid)  capimsg_setu16(m, 6, msgid)
0057 #define CAPIMSG_SETCONTROL(m, contr)    capimsg_setu32(m, 8, contr)
0058 #define CAPIMSG_SETDATALEN(m, len)  capimsg_setu16(m, 16, len)
0059 
0060 #endif              /* __CAPIUTIL_H__ */