Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:52

0001 /******************************************************************************
0002 *
0003 * Copyright (c) 2004 Freescale Semiconductor, Inc.
0004 *
0005 * Permission is hereby granted, free of charge, to any person obtaining a
0006 * copy of this software and associated documentation files (the "Software"),
0007 * to deal in the Software without restriction, including without limitation
0008 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0009 * and/or sell copies of the Software, and to permit persons to whom the
0010 * Software is furnished to do so, subject to the following conditions:
0011 *
0012 * The above copyright notice and this permission notice shall be included
0013 * in all copies or substantial portions of the Software.
0014 *
0015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0018 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0019 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0020 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0021 * OTHER DEALINGS IN THE SOFTWARE.
0022 *
0023 ******************************************************************************/
0024 
0025 #if defined(__rtems__) || defined(MPC5200_BAPI_LIBC_HEADERS)
0026 #include <string.h>
0027 #endif
0028 
0029 #include <bsp/bestcomm/include/ppctypes.h>
0030 #include <bsp/bestcomm/include/mgt5200/sdma.h>
0031 #include <bsp/bestcomm/include/mgt5200/mgt5200.h>
0032 
0033 #include <bsp/bestcomm/dma_image.h>
0034 #include <bsp/bestcomm/bestcomm_api.h>
0035 
0036 #ifdef __MWERKS__
0037 __declspec(section ".text") extern const uint32 taskTable;
0038 __declspec(section ".text") extern const uint32 taskTableBytes;
0039 __declspec(section ".text") extern const uint32 taskTableTasks;
0040 __declspec(section ".text") extern const uint32 offsetEntry;
0041 #else
0042 extern const uint32 taskTable [];
0043 extern const uint32 taskTableBytes;
0044 extern const uint32 taskTableTasks;
0045 extern const uint32 offsetEntry;
0046 #endif
0047 
0048 typedef struct SCTDT {
0049     uint32 start;
0050     uint32 stop;
0051     uint32 var;
0052     uint32 fdt;
0053     uint32 rsvd1;
0054     uint32 rsvd2;
0055     uint32 context;
0056     uint32 litbase;
0057 } SCTDT_T;
0058 
0059 
0060 /*!
0061  * \brief   Load BestComm tasks into SRAM.
0062  * \param   sdma    Base address of the BestComm register set
0063  *
0064  * The BestComm tasks must be loaded before any task can be setup,
0065  * enabled, etc. This might be called as part of a boot sequence before
0066  * any BestComm drivers are required.
0067  */
0068 void TasksLoadImage(sdma_regs *sdma)
0069 {
0070     uint32 i;
0071     SCTDT_T *tt;
0072 
0073     /* copy task table from source to destination */
0074     memcpy((void *)((uint8 *)(sdma->taskBar) - MBarPhysOffsetGlobal), taskTable, taskTableBytes);
0075     /* adjust addresses in task table */
0076     for (i=0; i < (uint32) taskTableTasks; i++) {
0077         tt = (SCTDT_T *)(((uint8 *)(sdma->taskBar) - MBarPhysOffsetGlobal) + (uint32) offsetEntry + (i * sizeof (SCTDT_T)));
0078         tt->start   += sdma->taskBar;
0079         tt->stop    += sdma->taskBar;
0080         tt->var     += sdma->taskBar;
0081         tt->fdt     = (sdma->taskBar & 0xFFFFFF00) + tt->fdt;
0082         tt->context += sdma->taskBar;
0083     }
0084 }