1285809Sscottl/******************************************************************************* 2285809Sscottl*Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 3285809Sscottl* 4285809Sscottl*Redistribution and use in source and binary forms, with or without modification, are permitted provided 5285809Sscottl*that the following conditions are met: 6285809Sscottl*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7285809Sscottl*following disclaimer. 8285809Sscottl*2. Redistributions in binary form must reproduce the above copyright notice, 9285809Sscottl*this list of conditions and the following disclaimer in the documentation and/or other materials provided 10285809Sscottl*with the distribution. 11285809Sscottl* 12285809Sscottl*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 13285809Sscottl*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14285809Sscottl*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 15285809Sscottl*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 16285809Sscottl*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17285809Sscottl*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18285809Sscottl*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 19285809Sscottl*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 20285809Sscottl 21285809Sscottl********************************************************************************/ 22285809Sscottl/*******************************************************************************/ 23285809Sscottl/*! \file saframe.c 24285809Sscottl * \brief The file implements the functions to read frame content 25285809Sscottl */ 26285809Sscottl 27285809Sscottl 28285809Sscottl/******************************************************************************/ 29285809Sscottl#include <sys/cdefs.h> 30285809Sscottl__FBSDID("$FreeBSD$"); 31285809Sscottl#include <dev/pms/config.h> 32285809Sscottl 33285809Sscottl#include <dev/pms/RefTisa/sallsdk/spc/saglobal.h> 34285809Sscottl#ifdef SA_ENABLE_TRACE_FUNCTIONS 35285809Sscottl#ifdef siTraceFileID 36285809Sscottl#undef siTraceFileID 37285809Sscottl#endif 38285809Sscottl#define siTraceFileID 'D' 39285809Sscottl#endif 40285809Sscottl 41285809Sscottl/******************************************************************************/ 42285809Sscottl/*! \brief Read 32 bits from a frame 43285809Sscottl * 44285809Sscottl * Read 32 bits from a frame 45285809Sscottl * 46285809Sscottl * \param agRoot Handles for this instance of SAS/SATA LLL 47285809Sscottl * \param agFrame The frame handler 48285809Sscottl * \param frameOffset Offset in bytes from the beginning of valid frame bytes or IU 49285809Sscottl to the 32-bit value to read 50285809Sscottl * 51285809Sscottl * \return The read value 52285809Sscottl * 53285809Sscottl */ 54285809Sscottl/*******************************************************************************/ 55285809SscottlGLOBAL bit32 saFrameReadBit32( 56285809Sscottl agsaRoot_t *agRoot, 57285809Sscottl agsaFrameHandle_t agFrame, 58285809Sscottl bit32 frameOffset 59285809Sscottl ) 60285809Sscottl{ 61285809Sscottl bit8 *payloadAddr; 62285809Sscottl bit32 value = 0; 63285809Sscottl 64285809Sscottl smTraceFuncEnter(hpDBG_VERY_LOUD, "zr"); 65285809Sscottl 66285809Sscottl if ( agNULL != agFrame ) 67285809Sscottl { 68285809Sscottl /* Find the address of the payload */ 69285809Sscottl payloadAddr = (bit8 *)(agFrame) + frameOffset; 70285809Sscottl 71285809Sscottl /* read one DW Data */ 72285809Sscottl value = *(bit32 *)payloadAddr; 73285809Sscottl } 74285809Sscottl 75285809Sscottl 76285809Sscottl /* (5) return value */ 77285809Sscottl smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zr"); 78285809Sscottl return value; 79285809Sscottl} 80285809Sscottl 81285809Sscottl/******************************************************************************/ 82285809Sscottl/*! \brief Read a block from a frame 83285809Sscottl * 84285809Sscottl * Read a block from a frame 85285809Sscottl * 86285809Sscottl * \param agRoot Handles for this instance of SAS/SATA LLL 87285809Sscottl * \param agFrame The frame handler 88285809Sscottl * \param frameOffset The offset of the frame to start read 89285809Sscottl * \param frameBuffer The pointer to the destination of data read from the frame 90285809Sscottl * \param frameBufLen Number of bytes to read from the frame 91285809Sscottl * 92285809Sscottl * \return -void- 93285809Sscottl * 94285809Sscottl */ 95285809Sscottl/*******************************************************************************/ 96285809SscottlGLOBAL void saFrameReadBlock ( 97285809Sscottl agsaRoot_t *agRoot, 98285809Sscottl agsaFrameHandle_t agFrame, 99285809Sscottl bit32 frameOffset, 100285809Sscottl void *frameBuffer, 101285809Sscottl bit32 frameBufLen 102285809Sscottl ) 103285809Sscottl{ 104285809Sscottl bit8 *payloadAddr; 105285809Sscottl bit32 i; 106285809Sscottl 107285809Sscottl smTraceFuncEnter(hpDBG_VERY_LOUD, "zi"); 108285809Sscottl 109285809Sscottl /* Sanity check */ 110285809Sscottl SA_ASSERT(frameBufLen < 4096, "saFrameReadBlock read more than 4k"); 111285809Sscottl 112285809Sscottl if ( agNULL != agFrame ) 113285809Sscottl { 114285809Sscottl /* Find the address of the payload */ 115285809Sscottl payloadAddr = (bit8 *)(agFrame) + frameOffset; 116285809Sscottl /* Copy the frame data to the destination frame buffer */ 117285809Sscottl for ( i = 0; i < frameBufLen; i ++ ) 118285809Sscottl { 119285809Sscottl *(bit8 *)((bit8 *)frameBuffer + i) = *(bit8 *)(payloadAddr + i); 120285809Sscottl } 121285809Sscottl } 122285809Sscottl 123285809Sscottl smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zi"); 124285809Sscottl} 125285809Sscottl 126