dmmisc.c revision 285809
1/******************************************************************************* 2** 3*Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 4* 5*Redistribution and use in source and binary forms, with or without modification, are permitted provided 6*that the following conditions are met: 7*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 8*following disclaimer. 9*2. Redistributions in binary form must reproduce the above copyright notice, 10*this list of conditions and the following disclaimer in the documentation and/or other materials provided 11*with the distribution. 12* 13*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 14*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 15*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 16*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 17*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 18*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 19*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 20*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 21 22********************************************************************************/ 23#include <sys/cdefs.h> 24__FBSDID("$FreeBSD$"); 25#include <dev/pms/config.h> 26 27#include <dev/pms/freebsd/driver/common/osenv.h> 28#include <dev/pms/freebsd/driver/common/ostypes.h> 29#include <dev/pms/freebsd/driver/common/osdebug.h> 30 31#include <dev/pms/RefTisa/sallsdk/api/sa.h> 32#include <dev/pms/RefTisa/sallsdk/api/saapi.h> 33#include <dev/pms/RefTisa/sallsdk/api/saosapi.h> 34 35#ifdef FDS_DM 36#include <dev/pms/RefTisa/discovery/api/dm.h> 37#include <dev/pms/RefTisa/discovery/api/dmapi.h> 38#include <dev/pms/RefTisa/discovery/api/tddmapi.h> 39 40#include <dev/pms/RefTisa/discovery/dm/dmdefs.h> 41#include <dev/pms/RefTisa/discovery/dm/dmtypes.h> 42#include <dev/pms/RefTisa/discovery/dm/dmproto.h> 43 44osGLOBAL void 45*dm_memset(void *s, int c, bit32 n) 46{ 47 bit32 i; 48 49 char *dst = (char *)s; 50 for (i=0; i < n; i++) 51 { 52 dst[i] = (char) c; 53 } 54 return (void *)(&dst[i-n]); 55} 56 57osGLOBAL void 58*dm_memcpy(void *dst, void *src, bit32 count) 59{ 60 bit32 x; 61 unsigned char *dst1 = (unsigned char *)dst; 62 unsigned char *src1 = (unsigned char *)src; 63 64 for (x=0; x < count; x++) 65 dst1[x] = src1[x]; 66 67 return dst; 68 69} 70 71/** hexidecimal dump */ 72osGLOBAL void 73dmhexdump(const char *ptitle, bit8 *pbuf, int len) 74{ 75 int i; 76 DM_DBG1(("%s - dmhexdump(len=%d):\n", ptitle, (int)len)); 77 if (!pbuf) 78 { 79 DM_DBG1(("pbuf is NULL\n")); 80 return; 81 } 82 for (i = 0; i < len; ) 83 { 84 if (len - i > 4) 85 { 86 DM_DBG1((" 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", pbuf[i], pbuf[i+1], pbuf[i+2], pbuf[i+3])); 87 i += 4; 88 } 89 else 90 { 91 DM_DBG1((" 0x%02x,", pbuf[i])); 92 i++; 93 } 94 } 95 DM_DBG1(("\n")); 96} 97#endif /* FDS_ DM */ 98 99