diff --git a/.gitignore b/.gitignore index e4da6f9..830d0fd 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ dcetestdec *.mak *.xem3 ducati/ti/dce/package +/ducati/ti/dce/baseimage/package/ +/ducati/ti/dce/lib/ diff --git a/dce.h b/dce.h index 4e76e2a..f9eb050 100644 --- a/dce.h +++ b/dce.h @@ -41,6 +41,7 @@ void * dce_alloc(int sz); void dce_free(void *ptr); void dce_set_fd(int fd); +int dce_get_fd(); /* avoid some messy stuff in xdc/std.h which pisses of gcc.. */ #define xdc__ARGTOPTR @@ -50,6 +51,7 @@ void dce_set_fd(int fd); struct omap_device * dce_init(void); void dce_deinit(struct omap_device *dev); #define XDM_MEMTYPE_BO 10 +#define XDM_MEMTYPE_BO_OFFSET 11 #endif #endif /* __DCE_H__ */ diff --git a/ducati/config.bld b/ducati/config.bld index f3803f3..91eda6a 100644 --- a/ducati/config.bld +++ b/ducati/config.bld @@ -68,11 +68,28 @@ var M3 = xdc.useModule('ti.targets.arm.elf.M3'); M3.rootDir = arm_cgtools_rootdir; M3.ccOpts.suffix += " -ms -pds=71"; M3.lnkOpts.prefix += " --retain=.resource_table"; -/* Set default platform and list of all interested platforms for M3 */ -M3.platforms = [ - "ti.platform.omap4430.core0", - "ti.platform.omap4430.core1", - ]; + +/* Default platforms for M3 in non-SMP mode */ +var regPlatforms = [ + "ti.platform.omap4430.core0", + "ti.platform.omap4430.core1", + "ti.platform.omap54xx.core0", + "ti.platform.omap54xx.core1", + ]; + +/* Default platforms for M3 in SMP mode */ +var smpPlatforms = [ + "ti.platform.omap4430.ipu", + "ti.platform.omap54xx.ipu", + ]; + + +if (java.lang.System.getenv("FOR_SMP") == '1') { + M3.platforms = smpPlatforms; +} else { + M3.platforms = regPlatforms; +} + M3.platform = M3.platforms[0]; /* Uncomment the required targets */ @@ -81,3 +98,13 @@ Build.targets = [ M3, ]; + + +/* Eliminate profiles that aren't 'debug' or 'release' */ +for (var t = 0; t < Build.targets.length; t++) { + for (prof in Build.targets[t].profiles) { + if ((prof != "debug") && (prof != "release")) { + delete Build.targets[t].profiles[prof]; + } + } +} diff --git a/ducati/ti/dce/dce_core0.cfg b/ducati/ti/dce/baseimage/dce_core0.cfg similarity index 100% rename from ducati/ti/dce/dce_core0.cfg rename to ducati/ti/dce/baseimage/dce_core0.cfg diff --git a/ducati/ti/dce/baseimage/dce_ipu.cfg b/ducati/ti/dce/baseimage/dce_ipu.cfg new file mode 100644 index 0000000..1fa5ebb --- /dev/null +++ b/ducati/ti/dce/baseimage/dce_ipu.cfg @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2011, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +xdc.loadCapsule("ti/configs/omap4430/IpcCommon.cfg.xs"); +xdc.includeFile("ti/configs/omap4430/DucatiSmp.cfg"); +xdc.includeFile("ti/configs/omap4430/DucatiAmmu.cfg"); + +var Program = xdc.useModule('xdc.cfg.Program'); +var Memory = xdc.useModule('xdc.runtime.Memory'); +var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem'); +var GateHwi = xdc.useModule('ti.sysbios.gates.GateHwi'); + + +Program.global.enableSMP = true; +HeapMem.common$.gate = GateHwi.create(); + +var heapMemParams = new HeapMem.Params; +heapMemParams.size = 0x19FFFF0; // TODO check this size, maybe we can go up? +heapMemParams.sectionName = ".systemHeap"; +var heap0 = HeapMem.create(heapMemParams); +Memory.defaultHeapInstance = heap0; +Program.global.heap0 = heap0; + +/* + * Setup memory map. + */ + +Program.sectMap[".systemHeap"] = "EXT_HEAP"; + +/* Work-around for .const loading issues with MPEG4/VC1 codecs.. move AMMU + * tables out of .const into .txt so that they have valid data when AMMU + * is programmed (which happens before cinit initializes rw sections.. + * which is what .const becomes due to rw var mistakenly placed on .const + */ +Program.sectMap[".const:ti_sysbios_hal_ammu_AMMU_mmuInitConfig__C"] = "EXT_CODE"; +Program.sectMap[".const:ti_sysbios_hal_ammu_AMMU_numLargePages__C"] = "EXT_CODE"; +Program.sectMap[".const:ti_sysbios_hal_ammu_AMMU_numLinePages__C"] = "EXT_CODE"; +Program.sectMap[".const:ti_sysbios_hal_ammu_AMMU_numMediumPages__C"] = "EXT_CODE"; +Program.sectMap[".const:ti_sysbios_hal_ammu_AMMU_numSmallPages__C"] = "EXT_CODE"; + +/* + * ======== CODEC ENGINE configurations ======== + */ + +var Global = xdc.useModule('ti.sdo.ce.osal.Global'); +Global.runtimeEnv = Global.DSPBIOS; + +xdc.useModule('ti.sdo.ce.global.Settings').profile = "debug"; +xdc.loadPackage('ti.sdo.ce.video').profile = "debug"; +xdc.loadPackage('ti.sdo.ce.video3').profile = "debug"; +xdc.loadPackage('ti.sdo.ce.alg').profile = "debug"; +xdc.useModule('ti.sdo.fc.global.Settings').profile = "debug"; +xdc.loadPackage('ti.sdo.fc.rman').profile = "debug"; +xdc.loadPackage('ti.sdo.fc.ires.hdvicp').profile = "debug"; +xdc.loadPackage('ti.sdo.fc.ires.tiledmemory').profile = "debug"; + +var ipcSettings = xdc.useModule('ti.sdo.ce.ipc.Settings'); +ipcSettings.ipc = xdc.useModule('ti.sdo.ce.ipc.bios.Ipc'); +// set to true to enable debugging of codec engine +xdc.useModule('ti.sdo.ce.Settings').checked = true; + +/* Enable Memory Translation module that operates on the BIOS Resource Table */ +var IpcMemory = xdc.useModule('ti.resources.IpcMemory'); + + + +//set All heaps of dskts as the default heap0 +var DSKT2 = xdc.useModule('ti.sdo.fc.dskt2.DSKT2'); +DSKT2.DARAM0 = "heap0"; +DSKT2.DARAM1 = "heap0"; +DSKT2.DARAM2 = "heap0"; +DSKT2.SARAM0 = "heap0"; +DSKT2.SARAM1 = "heap0"; +DSKT2.SARAM2 = "heap0"; +DSKT2.ESDATA = "heap0"; +DSKT2.IPROG = "heap0"; +DSKT2.EPROG = "heap0"; +DSKT2.DSKT2_HEAP = "heap0"; + +var HDVICP2 = xdc.useModule('ti.sdo.fc.ires.hdvicp.HDVICP2'); +HDVICP2.memoryBaseAddress[0] = 0xBB000000; +HDVICP2.registerBaseAddress[0] = 0xBA000000; +HDVICP2.resetControlAddress[0] = 0xAA306F10; +HDVICP2.resetFxn = "ivahd_reset"; + +xdc.useModule('ti.sdo.fc.rman.RMAN'); + +// Load HDVICP2 support lib end decoder/encoder APIs: +var HDVICP20API = xdc.useModule('ti.sdo.codecs.hdvicp20api.HDVICP20API'); +var VIDDEC3 = xdc.useModule('ti.sdo.ce.video3.IVIDDEC3'); +var VIDENC2 = xdc.useModule('ti.sdo.ce.video2.IVIDENC2'); + +// load whatever codecs are available in the build +var codecs = []; + +function loadCodec(pkg, name) +{ + try { + var codec = xdc.useModule(pkg); + print('loading: ' + name); + codecs.push({ name: name, mod: codec, local: true }); + } catch(e) { + print('no package: ' + pkg); + } +} + +loadCodec('ti.sdo.codecs.h264dec.ce.H264DEC', 'ivahd_h264dec'); +loadCodec('ti.sdo.codecs.mpeg4dec.ce.MPEG4DEC', 'ivahd_mpeg4dec'); +loadCodec('ti.sdo.codecs.jpegvdec.ce.JPEGVDEC', 'ivahd_jpegvdec'); +loadCodec('ti.sdo.codecs.vc1vdec.ce.VC1VDEC', 'ivahd_vc1vdec'); +loadCodec('ti.sdo.codecs.mpeg2vdec.ce.MPEG2VDEC','ivahd_mpeg2vdec'); +loadCodec('ti.sdo.codecs.h264enc.ce.H264ENC', 'ivahd_h264enc'); +loadCodec('ti.sdo.codecs.mpeg4enc.ce.MPEG4ENC', 'ivahd_mpeg4enc'); +loadCodec('ti.sdo.codecs.jpegvenc.ce.JPEGVENC', 'ivahd_jpegvenc'); + +var engine = xdc.useModule('ti.sdo.ce.Engine'); +var myEngine = engine.create("ivahd_vidsvr", codecs); + +xdc.useModule('ti.sysbios.knl.Task'); diff --git a/ducati/ti/dce/iresman_tiledmemory.c b/ducati/ti/dce/baseimage/iresman_tiledmemory.c similarity index 99% rename from ducati/ti/dce/iresman_tiledmemory.c rename to ducati/ti/dce/baseimage/iresman_tiledmemory.c index 4627840..a2e7721 100644 --- a/ducati/ti/dce/iresman_tiledmemory.c +++ b/ducati/ti/dce/baseimage/iresman_tiledmemory.c @@ -44,7 +44,7 @@ #include #include -#include "dce_priv.h" +#include static IRESMAN_PersistentAllocFxn * allocFxn; /* Memory alloc function */ diff --git a/ducati/ti/dce/main.c b/ducati/ti/dce/baseimage/main.c similarity index 80% rename from ducati/ti/dce/main.c rename to ducati/ti/dce/baseimage/main.c index f814c22..695a7b1 100644 --- a/ducati/ti/dce/main.c +++ b/ducati/ti/dce/baseimage/main.c @@ -47,14 +47,8 @@ #include #include -#include "dce_priv.h" - - -/* include resource table in core0/sysm3 build, but with a sane data size */ -#define DATA_SIZE 0x02000000 /* 32MiB */ -typedef unsigned int u32; -#include - +/* Legacy function to allow Linux side rpmsg sample tests to work: */ +extern void start_ping_tasks(); int main(int argc, char **argv) { @@ -63,22 +57,13 @@ int main(int argc, char **argv) /* Set up interprocessor notifications */ System_printf("%s starting..\n", MultiProc_getName(MultiProc_self())); - System_printf("%d resources at 0x%x\n", - sizeof(resources) / sizeof(struct resource), resources); - - /* Plug vring interrupts, and spin until host handshake complete. */ - VirtQueue_startup(); - hostId = MultiProc_getId("HOST"); MessageQCopy_init(hostId); - dce_init(); - - DEBUG("Completed IPC setup and Server Bringup"); + /* Some background ping testing tasks, used by rpmsg samples: */ + start_ping_tasks(); BIOS_start(); - DEBUG("Completed BIOS Bringup"); - return 0; } diff --git a/ducati/ti/dce/baseimage/package.bld b/ducati/ti/dce/baseimage/package.bld new file mode 100644 index 0000000..ed28ee6 --- /dev/null +++ b/ducati/ti/dce/baseimage/package.bld @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2011, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * ======== package.bld ======== + */ + +var testBld = xdc.loadCapsule("ti/sdo/ipc/build/test.bld"); +var commonBld = xdc.loadCapsule("ti/sdo/ipc/build/common.bld"); + +/* + * Export everything necessary to build this package with (almost) no + * generated files. + */ +Pkg.attrs.exportAll = true; + +/* + * ======== testArray ======== + * + * Example: + * var testArray = [ + * {name: Test1}, + * {name: Test2, sources: ["Test"], config: "Test", refOutput: "Test", timeout: "15", buildTargets: ["C64", "C28_large"]} + * ]; + */ + +var testArray = [ + {name: 'ducati-m3-core0', sources: ["main", "ping_tasks", "iresman_tiledmemory"], config: "dce_core0", copts: "-D CORE0 --gcc", buildPlatforms: ["ti.platform.omap4430.core0"]}, + {name: 'ducati-m3-ipu', sources: ["main", "ping_tasks", "iresman_tiledmemory"], config: "dce_ipu", copts: "-D IPU --gcc", buildPlatforms: ["ti.platform.omap4430.ipu"]}, +]; + +arguments = ["profile=debug platform=all"]; + +testBld.buildTests(testArray, arguments); diff --git a/ducati/ti/dce/baseimage/package.xdc b/ducati/ti/dce/baseimage/package.xdc new file mode 100644 index 0000000..b9e3f1f --- /dev/null +++ b/ducati/ti/dce/baseimage/package.xdc @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * ======== package.xdc ======== + * + */ +requires ti.dce; + + +/*! + * ======== ti.dce.baseimage ======== + */ +package ti.dce.baseimage [1,0,0,0] { +} diff --git a/ducati/ti/dce/baseimage/ping_tasks.c b/ducati/ti/dce/baseimage/ping_tasks.c new file mode 100644 index 0000000..d691cab --- /dev/null +++ b/ducati/ti/dce/baseimage/ping_tasks.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2011, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * ======== ping_tasks.c ======== + * + * Works with the rpmsg_client_sample and rpmsg_server_sample Linux drivers. + */ + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#define APP_NUM_ITERATIONS 100000 + +Void copyTaskFxn(UArg arg0, UArg arg1) +{ + MessageQCopy_Handle handle; + Char buffer[128]; + UInt32 myEndpoint = 0; + UInt32 remoteEndpoint; + UInt16 dstProc; + UInt16 len; + Int i; + + System_printf("copyTask %d: Entered...:\n", arg0); + + dstProc = MultiProc_getId("HOST"); + + MessageQCopy_init(dstProc); + + /* Create the messageQ for receiving (and get our endpoint for sending). */ + handle = MessageQCopy_create(arg0, &myEndpoint); + + NameMap_register("rpmsg-client-sample", arg0); + + for (i = 0; i < APP_NUM_ITERATIONS; i++) { + /* Await a character message: */ + MessageQCopy_recv(handle, (Ptr)buffer, &len, &remoteEndpoint, + MessageQCopy_FOREVER); + + buffer[len] = '\0'; + System_printf("copyTask %d: Received data: %s, len:%d\n", i + 1, + buffer, len); + + /* Send data back to remote endpoint: */ + MessageQCopy_send(dstProc, remoteEndpoint, myEndpoint, (Ptr)buffer, len); + } + + /* Teardown our side: */ + MessageQCopy_delete(&handle); + + /* Free MessageQCopy module wide resources: */ + MessageQCopy_finalize(); +} + +void start_ping_tasks() +{ + Task_Params params; + + /* Respond to ping tests from Linux side rpmsg sample drivers: */ + Task_Params_init(¶ms); + params.instance->name = "copy0"; + params.priority = 3; + params.arg0 = 50; + Task_create(copyTaskFxn, ¶ms, NULL); + + Task_Params_init(¶ms); + params.instance->name = "copy1"; + params.priority = 3; + params.arg0 = 51; + Task_create(copyTaskFxn, ¶ms, NULL); +} diff --git a/ducati/ti/dce/dce.c b/ducati/ti/dce/dce.c index e53a060..d4c9e72 100644 --- a/ducati/ti/dce/dce.c +++ b/ducati/ti/dce/dce.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include #include @@ -65,6 +67,8 @@ uint32_t dce_debug = 1; +#define MEMORYSTATS_DEBUG + /* AFAIK both TILER and heap are cached on ducati side.. so from wherever a9 * allocates, we need to deal with cache to avoid coherency issues.. * @@ -190,6 +194,9 @@ static int engine_close(void *msg) static int codec_create(void *msg) { +#ifdef MEMORYSTATS_DEBUG + Memory_Stats stats; +#endif struct dce_rpc_codec_create_req *req = msg; struct dce_rpc_codec_create_rsp *rsp = msg; void *sparams = H2P((MemHeader *)req->sparams); @@ -202,6 +209,12 @@ static int codec_create(void *msg) dce_clean(sparams); DEBUG("<< codec=%08x", rsp->codec); +#ifdef MEMORYSTATS_DEBUG + Memory_getStats(NULL, &stats); + INFO("Total: %d\tFree: %d\tLargest: %d", stats.totalSize, + stats.totalFreeSize, stats.largestFreeSize); +#endif + return sizeof(*rsp); } @@ -362,12 +375,21 @@ static int codec_process(void *msg) static int codec_delete(void *msg) { +#ifdef MEMORYSTATS_DEBUG + Memory_Stats stats; +#endif struct dce_rpc_codec_delete_req *req = msg; DEBUG(">> codec=%08x, codec_id=%d", req->codec, req->codec_id); codec_fxns[req->codec_id].delete((void *)req->codec); DEBUG("<<"); +#ifdef MEMORYSTATS_DEBUG + Memory_getStats(NULL, &stats); + INFO("Total: %d\tFree: %d\tLargest: %d", stats.totalSize, + stats.totalFreeSize, stats.largestFreeSize); +#endif + return 0; } @@ -446,7 +468,7 @@ Bool dce_init(void) INFO("Creating DCE server thread..."); - /* Respond to ping tests from Linux side rpmsg sample drivers: */ + /* Create DCE task. */ Task_Params_init(¶ms); params.instance->name = "dce-server"; params.priority = Thread_Priority_ABOVE_NORMAL; diff --git a/ducati/ti/dce/ivahd.c b/ducati/ti/dce/ivahd.c index 601bc5a..45a0d9d 100644 --- a/ducati/ti/dce/ivahd.c +++ b/ducati/ti/dce/ivahd.c @@ -54,9 +54,10 @@ #include #include #include +#include +#include - -#define MEMORYSTATS_DEBUG 1 +//#define MEMORYSTATS_DEBUG static uint32_t ivahd_base = 0; static uint32_t ivahd_m5div = 0x1f; @@ -261,7 +262,15 @@ void ivahd_release(void) Hwi_restore(hwiKey); } -unsigned int SyslinkMemUtils_VirtToPhys(Ptr vaddr); +static unsigned int SyslinkMemUtils_VirtToPhys(Ptr Addr) +{ + unsigned int pa; + + if( !Addr || IpcMemory_virtToPhys((unsigned int) Addr, &pa)) { + return (0); + } + return (pa); +} void *MEMUTILS_getPhysicalAddr(Ptr vaddr) { diff --git a/ducati/ti/dce/package.bld b/ducati/ti/dce/package.bld index 4b75114..74f50f2 100644 --- a/ducati/ti/dce/package.bld +++ b/ducati/ti/dce/package.bld @@ -32,9 +32,13 @@ /* * ======== package.bld ======== */ +/* explicit references to global objects */ +var Build = xdc.useModule('xdc.bld.BuildEnvironment'); +var Pkg = xdc.useModule('xdc.bld.PackageContents'); -var testBld = xdc.loadCapsule("ti/sdo/ipc/build/test.bld"); -var commonBld = xdc.loadCapsule("ti/sdo/ipc/build/common.bld"); +/* clean lib folder */ +Pkg.generatedFiles.$add("lib/"); +Pkg.libDir = "package/"; /* * Export everything necessary to build this package with (almost) no @@ -42,20 +46,33 @@ var commonBld = xdc.loadCapsule("ti/sdo/ipc/build/common.bld"); */ Pkg.attrs.exportAll = true; -/* - * ======== testArray ======== - * - * Example: - * var testArray = [ - * {name: Test1}, - * {name: Test2, sources: ["Test"], config: "Test", refOutput: "Test", timeout: "15", buildTargets: ["C64", "C28_large"]} - * ]; - */ +/* Set libs parameters */ +var lib = { + name: "ti.dce", + sources: [ "dce", "ivahd" ], + libAttrs: { + copts: "-D CORE0 --gcc", + } +}; + + +/* ==== loop over all targets in build array ==== */ +for (var j = 0; j < Build.targets.length; j++) { + var targ = Build.targets[j]; + + /* ==== loop over all profiles ==== */ + for (var profile in targ.profiles) { -var testArray = [ - {name: 'ducati-m3-core0', sources: ["main", "dce", "iresman_tiledmemory", "ivahd"], config: "dce_core0", copts: "-D CORE0 --gcc", buildPlatforms: ["ti.platform.omap4430.core0"]}, -]; + /* name = lib/profile/name.a+suffix */ + var name = "lib/" + profile + "/" + lib.name; + var libAttrs = "libAttrs" in lib ? lib.libAttrs : {}; + /* must set profile explicitly */ + libAttrs.profile = profile; -arguments = ["profile=debug platform=all"]; + /* build the library */ + var library = Pkg.addLibrary(name, targ, libAttrs); -testBld.buildTests(testArray, arguments); + /* add the source files */ + library.addObjects(lib.sources); + } + } diff --git a/ducati/ti/dce/package.xdc b/ducati/ti/dce/package.xdc index adb66a0..859cfc3 100644 --- a/ducati/ti/dce/package.xdc +++ b/ducati/ti/dce/package.xdc @@ -34,6 +34,13 @@ * */ +requires ti.ipc.rpmsg; +requires ti.srvmgr; +requires ti.resmgr; +requires ti.sdo.ce; +requires ti.sdo.ce.video2; +requires ti.sdo.ce.video3; + /*! * ======== ti.dce ======== */ diff --git a/ducati/ti/dce/package.xs b/ducati/ti/dce/package.xs new file mode 100644 index 0000000..c52b861 --- /dev/null +++ b/ducati/ti/dce/package.xs @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2011-2012, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * ======== package.xs ======== + * + */ + + +/* + * ======== init ======== + */ +function init() +{ + /* + * install a SYS/BIOS startup function + * it will be called during BIOS_start() + */ + var BIOS = xdc.useModule('ti.sysbios.BIOS'); + BIOS.addUserStartupFunction('&dce_init'); +} + +/* + * ======== getLibs ======== + */ +function getLibs(prog) +{ + var name = this.$name + ".a" + prog.build.target.suffix; + var lib = ""; + + lib= "lib/" + this.profile + "/" + name; + + if (java.io.File(this.packageBase + lib).exists()) { + return lib; + } + + /* all ti.targets return whole_program_debug library by default */ + if (prog.build.target.$name.match(/^ti\.targets\./)) { + lib = "lib/" + "whole_program_debug/" + name; + if (java.io.File(this.packageBase + lib).exists()) { + return lib; + } + } + + /* all other targets, return release library by default */ + else { + lib = "lib/" + "release/" + name; + if (java.io.File(this.packageBase + lib).exists()) { + return lib; + } + } + + /* could not find any library, throw exception */ + throw Error("Library not found: " + name); +} + diff --git a/firmware/ducati-m3-core0.xem3 b/firmware/ducati-m3-core0.xem3 index 0a108bb..a70bc06 100644 Binary files a/firmware/ducati-m3-core0.xem3 and b/firmware/ducati-m3-core0.xem3 differ diff --git a/libdce.c b/libdce.c index 490f7f8..0aacbdf 100644 --- a/libdce.c +++ b/libdce.c @@ -68,6 +68,7 @@ static int ioctl_base; uint32_t dce_debug = 3; void dce_set_fd(int dce_fd) { fd = dce_fd; } +int dce_get_fd () { return fd; } /* * Memory allocation/mapping @@ -403,7 +404,7 @@ static int init(void) pthread_mutex_lock(&mutex); - if (count > 0) { + if (count++ > 0) { goto out; } @@ -495,8 +496,6 @@ static int init(void) ioctl_base = req.ioctl_base; dev = omap_device_new(fd); - - count++; } out: @@ -508,9 +507,7 @@ static void deinit(void) { pthread_mutex_lock(&mutex); - count--; - - if (count > 0) { + if (--count > 0) { goto out; }