1/******************************************************************************* 2*Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 3* 4*Redistribution and use in source and binary forms, with or without modification, are permitted provided 5*that the following conditions are met: 6*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7*following disclaimer. 8*2. Redistributions in binary form must reproduce the above copyright notice, 9*this list of conditions and the following disclaimer in the documentation and/or other materials provided 10*with the distribution. 11* 12*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 13*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 15*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 16*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 19*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 20 21********************************************************************************/ 22#include <sys/cdefs.h> 23#include <dev/pms/config.h> 24 25#include <dev/pms/freebsd/driver/common/osenv.h> 26#include <dev/pms/freebsd/driver/common/ostypes.h> 27#include <dev/pms/freebsd/driver/common/osdebug.h> 28 29#include <dev/pms/RefTisa/tisa/api/titypes.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#include <dev/pms/RefTisa/sat/api/sm.h> 36#include <dev/pms/RefTisa/sat/api/smapi.h> 37#include <dev/pms/RefTisa/sat/api/tdsmapi.h> 38 39#include <dev/pms/RefTisa/sat/src/smdefs.h> 40#include <dev/pms/RefTisa/sat/src/smproto.h> 41#include <dev/pms/RefTisa/sat/src/smtypes.h> 42 43FORCEINLINE void* 44sm_memset(void *s, int c, bit32 n) 45{ 46/* bit32 i; 47 48 char *dst = (char *)s; 49 for (i=0; i < n; i++) 50 { 51 dst[i] = (char) c; 52 } 53 return (void *)(&dst[i-n]); 54*/ 55 return memset(s, c, n); 56} 57 58FORCEINLINE void* 59sm_memcpy(void *dst, const void *src, bit32 count) 60{ 61/* 62 bit32 x; 63 unsigned char *dst1 = (unsigned char *)dst; 64 unsigned char *src1 = (unsigned char *)src; 65 66 for (x=0; x < count; x++) 67 dst1[x] = src1[x]; 68 69 return dst; 70*/ 71 return memcpy(dst, src, count); 72} 73 74osGLOBAL char 75*sm_strncpy(char *dst, const char *src, bit32 len) 76{ 77/* char *ret = dst; 78 do { 79 if (!len--) 80 return ret; 81 } while ((*dst++ = *src++)); 82 while (len--) 83 *dst++ = 0; 84 return ret; 85*/ return strncpy(dst, src, len); 86} 87 88/** hexidecimal dump */ 89osGLOBAL void 90smhexdump(const char *ptitle, bit8 *pbuf, size_t len) 91{ 92 size_t i; 93 SM_DBG1(("%s - smhexdump(len=%d):\n", ptitle, (int)len)); 94 if (!pbuf) 95 { 96 SM_DBG1(("pbuf is NULL\n")); 97 return; 98 } 99 for (i = 0; i < len; ) 100 { 101 if (len - i > 4) 102 { 103 SM_DBG1((" 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", pbuf[i], pbuf[i+1], pbuf[i+2], pbuf[i+3])); 104 i += 4; 105 } 106 else 107 { 108 SM_DBG1((" 0x%02x,", pbuf[i])); 109 i++; 110 } 111 } 112 SM_DBG1(("\n")); 113} 114 115 116