/*
* File: DataSource.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
*
* Freescale Semiconductor, Inc.
* Proprietary & Confidential
*
* This source code and the algorithms implemented therein constitute
* confidential information and may comprise trade secrets of Freescale Semiconductor, Inc.
* or its associates, and any use thereof is subject to the terms and
* conditions of the Confidential Disclosure Agreement pursual to which this
* source code was originally received.
*/
unsigned IVTDataSource::getData(unsigned offset, unsigned maxBytes, uint8_t * buffer)
{
// Bail if the offset is out of range.
if (offset >= sizeof(m_ivt))
{
return 0;
}
// If we have an associated target, and the IVT self pointer is not set, then
// fill in the self pointer from the target address.
if (m_target && !m_isSelfSet)
{
m_ivt.self = ENDIAN_HOST_TO_LITTLE_U32(m_target->getBeginAddress());
}
// Truncate max bytes at the end of the IVT.
maxBytes = std::min<unsigned>(maxBytes, sizeof(m_ivt) - offset);
// Copy into output buffer.
if (maxBytes)
{
memcpy(buffer, (uint8_t *)&m_ivt + offset, maxBytes);
}