xref: /freebsd/sys/dev/pms/RefTisa/discovery/dm/dmmisc.c (revision db33c6f3ae9d1231087710068ee4ea5398aacca7)
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 #include <dev/pms/config.h>
25 
26 #include <dev/pms/freebsd/driver/common/osenv.h>
27 #include <dev/pms/freebsd/driver/common/ostypes.h>
28 #include <dev/pms/freebsd/driver/common/osdebug.h>
29 
30 #include <dev/pms/RefTisa/sallsdk/api/sa.h>
31 #include <dev/pms/RefTisa/sallsdk/api/saapi.h>
32 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
33 
34 #ifdef FDS_DM
35 #include <dev/pms/RefTisa/discovery/api/dm.h>
36 #include <dev/pms/RefTisa/discovery/api/dmapi.h>
37 #include <dev/pms/RefTisa/discovery/api/tddmapi.h>
38 
39 #include <dev/pms/RefTisa/discovery/dm/dmdefs.h>
40 #include <dev/pms/RefTisa/discovery/dm/dmtypes.h>
41 #include <dev/pms/RefTisa/discovery/dm/dmproto.h>
42 
43 osGLOBAL void
44 *dm_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 
56 osGLOBAL void
57 *dm_memcpy(void *dst, void *src, bit32 count)
58 {
59   bit32 x;
60   unsigned char *dst1 = (unsigned char *)dst;
61   unsigned char *src1 = (unsigned char *)src;
62 
63   for (x=0; x < count; x++)
64     dst1[x] = src1[x];
65 
66   return dst;
67 
68 }
69 
70 /** hexidecimal dump */
71 osGLOBAL void
72 dmhexdump(const char *ptitle, bit8 *pbuf, int len)
73 {
74   int i;
75   DM_DBG1(("%s - dmhexdump(len=%d):\n", ptitle, (int)len));
76   if (!pbuf)
77   {
78     DM_DBG1(("pbuf is NULL\n"));
79     return;
80   }
81   for (i = 0; i < len; )
82   {
83     if (len - i > 4)
84     {
85       DM_DBG1((" 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", pbuf[i], pbuf[i+1], pbuf[i+2], pbuf[i+3]));
86       i += 4;
87     }
88     else
89     {
90       DM_DBG1((" 0x%02x,", pbuf[i]));
91       i++;
92     }
93   }
94   DM_DBG1(("\n"));
95 }
96 #endif /* FDS_ DM */
97 
98