Other Parts Discussed in Thread: SYSBIOS
TI的工程师,您好!
我在测试IPC通信时遇到了一个问题,我发现IPC MessageQ传输的时候会触发中断,而这个IPC中断将会打断其它中断的执行,比如将会打断定时器中断的处理(HWI中断优先级设置为4),这严重影响到了定时器内程序的执行。
cfg配置如下:
//BWC, add Program var
/* root of the configuration object model */
var Program = xdc.useModule('xdc.cfg.Program');
/* ================ General configuration ================ */
var Memory = xdc.useModule('xdc.runtime.Memory');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var Log = xdc.useModule('xdc.runtime.Log');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Hwi = xdc.useModule('ti.sysbios.family.c64p.Hwi');
var ECM = xdc.useModule('ti.sysbios.family.c64p.EventCombiner');
var System = xdc.useModule('xdc.runtime.System');
SysStd = xdc.useModule('xdc.runtime.SysStd');
var IntXbar = xdc.useModule('ti.sysbios.family.shared.vayu.IntXbar');
var halCache = xdc.useModule('ti.sysbios.hal.Cache');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var Deh = xdc.useModule('ti.deh.Deh');
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var ti_sysbios_timers_dmtimer_Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
var Event = xdc.useModule('ti.sysbios.knl.Event');
var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');
//var ti_sysbios_timers_timer64_Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');
//var ti_sysbios_timers_gptimer_Timer = xdc.useModule('ti.sysbios.timers.gptimer.Timer');
/* application uses the following modules and packages */
xdc.useModule('xdc.runtime.Assert');
xdc.useModule('xdc.runtime.Error');
/* Must be placed before pwr mgmt */
Idle.addFunc('&ti_deh_Deh_idleBegin');
System.SupportProxy = SysStd;
/*
* Enable Event Groups here and registering of ISR for specific GEM INTC is done
* using EventCombiner_dispatchPlug() and Hwi_eventMap() APIs
*/
var exception = xdc.useModule('ti.sysbios.family.c64p.Exception');
exception.enablePrint = true;
/* ================ BIOS configuration ================ */
var BIOS = xdc.useModule('ti.sysbios.BIOS');
/* Enable BIOS Task Scheduler */
BIOS.taskEnabled = true;
BIOS.heapSize = 0x300000;
BIOS.heapSection = "systemHeap";
BIOS.addUserStartupFunction('&IpcMgr_ipcStartup');
/* ================ Task configuration ================ */
/* No runtime stack checking is performed */
Task.checkStackFlag = false;
/* Reduce the number of task priorities */
Task.numPriorities = 16;
Task.common$.namedInstance = true;
/* ================ Driver configuration ================ */
/*use CSL package*/
var socType = "am571x";
var Csl = xdc.loadPackage('ti.csl');
Csl.Settings.deviceType = socType;
/* Load the OSAL package */
var osType = "tirtos"
var Osal = xdc.useModule('ti.osal.Settings');
Osal.osType = osType;
Osal.socType = socType;
/* Load the gpio package */
var GPIO = xdc.loadPackage('ti.drv.gpio');
GPIO.Settings.socType = socType;
/* Load the UART package */
var Uart = xdc.loadPackage('ti.drv.uart');
/* Load the I2C package */
var I2c = xdc.loadPackage('ti.drv.i2c');
//var Spi = xdc.loadPackage('ti.drv.spi');
//Spi.Settings.socType = socType;
//Spi.Settings.useDma = "true";
/* Load the Board package and set the board name */
var Board = xdc.loadPackage('ti.board');
Board.Settings.boardName = "idkAM571x";
/* root of the configuration object model */
var Program = xdc.useModule('xdc.cfg.Program');
/* load the configuration shared across cores */
Program.global.procName = "DSP1";
Program.sectMap[".tracebuf"] = "TRACE_BUF";
Program.sectMap[".errorbuf"] = "EXC_DATA";
Program.sectMap[".l2sram"] = "L2SRAM";
/*
* ======== IPC Configuration ========
*/
xdc.useModule('ti.ipc.ipcmgr.IpcMgr');
var ipc_cfg = xdc.loadCapsule("ipc.cfg.xs");
/*
* ======== SYS/BIOS Configuration ========
*/
if (Program.build.profile == "debug")
{
BIOS.libType = BIOS.LibType_Debug;
}
else
{
BIOS.libType = BIOS.LibType_Custom;
}
/* create a heap for MessageQ messages */
var params = new HeapBuf.Params;
params.align = 8;
params.blockSize = 512;
params.numBlocks = 256;
var msgHeap = HeapBuf.create(params);
var MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');
MessageQ.registerHeapMeta(msgHeap, 0);
/* Setup MessageQ transport */
var VirtioSetup = xdc.useModule('ti.ipc.transports.TransportRpmsgSetup');
MessageQ.SetupTransportProxy = VirtioSetup;
/* Setup NameServer remote proxy */
var NameServer = xdc.useModule("ti.sdo.utils.NameServer");
var NsRemote = xdc.useModule("ti.ipc.namesrv.NameServerRemoteRpmsg");
NameServer.SetupProxy = NsRemote;
/* Enable Memory Translation module that operates on the BIOS Resource Table */
var Resource = xdc.useModule('ti.ipc.remoteproc.Resource');
Resource.loadSegment = "EXT_CODE";
Resource.customTable = true;
/* Use SysMin because trace buffer address is required for Linux/QNX
* trace debug driver, plus provides better performance.
*/
var System = xdc.useModule('xdc.runtime.System');
var SysMin = xdc.useModule('ti.trace.SysMin');
System.SupportProxy = SysMin;
SysMin.bufSize = 0x8000;
/*
* ======== Instrumentation Configuration ========
*/
/* system logger */
var LoggerSys = xdc.useModule('xdc.runtime.LoggerSys');
var LoggerSysParams = new LoggerSys.Params();
var Defaults = xdc.useModule('xdc.runtime.Defaults');
Defaults.common$.logger = LoggerSys.create(LoggerSysParams);
/* enable runtime Diags_setMask() for non-XDC spec'd modules */
var Diags = xdc.useModule('xdc.runtime.Diags');
Diags.setMaskEnabled = true;
/* override diags mask for selected modules */
xdc.useModule('xdc.runtime.Main');
Diags.setMaskMeta("xdc.runtime.Main",
Diags.ENTRY | Diags.EXIT | Diags.INFO, Diags.RUNTIME_ON);
var Registry = xdc.useModule('xdc.runtime.Registry');
Registry.common$.diags_ENTRY = Diags.RUNTIME_OFF;
Registry.common$.diags_EXIT = Diags.RUNTIME_OFF;
Registry.common$.diags_INFO = Diags.RUNTIME_OFF;
Registry.common$.diags_USER1 = Diags.RUNTIME_OFF;
Registry.common$.diags_LIFECYCLE = Diags.RUNTIME_OFF;
Registry.common$.diags_STATUS = Diags.RUNTIME_OFF;
var Main = xdc.useModule('xdc.runtime.Main');
Main.common$.diags_ASSERT = Diags.ALWAYS_ON;
Main.common$.diags_INTERNAL = Diags.ALWAYS_ON;
/* Override the default resource table with my own */
var Resource = xdc.useModule('ti.ipc.remoteproc.Resource');
Resource.customTable = true;
var TimerSupport = xdc.useModule('ti.sysbios.family.shared.vayu.TimerSupport');
TimerSupport.availMask = 0xFFFF;
ti_sysbios_timers_dmtimer_Timer.timerSettings[4].intNum = 4;
var timer0Params = new Timer.Params();
timer0Params.instance.name = "timer0";
timer0Params.period = 10;
timer0Params.periodType = xdc.module("ti.sysbios.interfaces.ITimer").PeriodType_MICROSECS;
timer0Params.extFreq.lo = 20000000;
timer0Params.runMode = xdc.module("ti.sysbios.interfaces.ITimer").RunMode_CONTINUOUS;
timer0Params.arg = 100;
Program.global.timer0 = Timer.create(4, "&TimerFxn", timer0Params);
ti_sysbios_timers_dmtimer_Timer.timerSettings[12].intNum = 13;
var timer1Params = new Timer.Params();
timer1Params.instance.name = "timer1";
timer1Params.period = 1000;
timer1Params.periodType = xdc.module("ti.sysbios.interfaces.ITimer").PeriodType_MICROSECS;
timer1Params.extFreq.lo = 20000000;
timer1Params.runMode = xdc.module("ti.sysbios.interfaces.ITimer").RunMode_CONTINUOUS;
timer1Params.arg = 0;
Program.global.timer1 = Timer.create(12, "&TimerTick", timer1Params);
Clock.tickSource = Clock.TickSource_USER;
Clock.tickPeriod = 1000;
/* ================ Driver configuration ================ */
var drv = xdc.loadPackage ("ti.sdo.edma3.drv");
var rm = xdc.loadPackage ("ti.sdo.edma3.rm");
var rm = xdc.loadPackage ("ti.sdo.edma3.drv.sample");
BIOS.cpuFreq.lo = 750000000;
ECM.eventGroupHwiNum[0] = 7;
ECM.eventGroupHwiNum[1] = 8;
ECM.eventGroupHwiNum[2] = 9;
ECM.eventGroupHwiNum[3] = 10;
IPC测试程序如下:
/*
* Copyright (c) 2013-2014, 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.
*/
/*
* ======== Server.c ========
*
*/
/* this define must precede inclusion of any xdc header file */
#define Registry_CURDESC Test__Desc
#define MODULE_NAME "Server"
/* xdctools header files */
#include <xdc/std.h>
#include <xdc/runtime/Assert.h>
#include <xdc/runtime/Diags.h>
#include <xdc/runtime/Log.h>
#include <xdc/runtime/Registry.h>
#include <stdio.h>
/* package header files */
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/MultiProc.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* local header files */
#include "AppCommon.h"
/* module header file */
#include "Server.h"
/* module structure */
typedef struct {
UInt16 hostProcId; // host processor id
MessageQ_Handle slaveQue; // created locally
} Server_Module;
/* private data */
Registry_Desc Registry_CURDESC;
static Server_Module Module;
/*
* ======== Server_init ========
*/
Void Server_init(Void)
{
Registry_Result result;
/* register with xdc.runtime to get a diags mask */
result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);
/* initialize module object state */
Module.hostProcId = MultiProc_getId("HOST");
}
/*
* ======== Server_create ========
*/
Int Server_create()
{
Int status = 0;
MessageQ_Params msgqParams;
char msgqName[32];
/* enable some log events */
Diags_setMask(MODULE_NAME"+EXF");
/* create local message queue (inbound messages) */
MessageQ_Params_init(&msgqParams);
sprintf(msgqName, App_SlaveMsgQueName, MultiProc_getName(MultiProc_self()));
Module.slaveQue = MessageQ_create(msgqName, &msgqParams);
if (Module.slaveQue == NULL) {
status = -1;
goto leave;
}
Log_print0(Diags_INFO,"Server_create: server is ready");
Log_print1(Diags_INFO,"Server_create: server is ready %s", (String)msgqName);
leave:
Log_print1(Diags_EXIT, "<-- Server_create: %d", (IArg)status);
return (status);
}
/*
* ======== Server_exec ========
*/
Int Server_exec()
{
Int status;
Bool running = TRUE;
App_Msg * msg;
MessageQ_QueueId queId;
Log_print0(Diags_ENTRY | Diags_INFO, "--> Server_exec:");
while (running) {
/* wait for inbound message */
status = MessageQ_get(Module.slaveQue, (MessageQ_Msg *)&msg,
MessageQ_FOREVER);
if (status < 0) {
goto leave;
}
if (msg->cmd == App_CMD_SHUTDOWN) {
running = FALSE;
}
/* process the message */
//Log_print1(Diags_INFO, "Server_exec: processed cmd=0x%x", msg->cmd);
/* send message back */
queId = MessageQ_getReplyQueue(msg); /* type-cast not needed */
MessageQ_put(queId, (MessageQ_Msg)msg);
} /* while (running) */
leave:
Log_print1(Diags_EXIT, "<-- Server_exec: %d", (IArg)status);
return(status);
}
/*
* ======== Server_delete ========
*/
Int Server_delete()
{
Int status;
Log_print0(Diags_ENTRY, "--> Server_delete:");
/* delete the video message queue */
status = MessageQ_delete(&Module.slaveQue);
if (status < 0) {
goto leave;
}
leave:
if (status < 0) {
Log_error1("Server_finish: error=0x%x", (IArg)status);
}
/* disable log events */
Log_print1(Diags_EXIT, "<-- Server_delete: %d", (IArg)status);
Diags_setMask(MODULE_NAME"-EXF");
return(status);
}
/*
* ======== Server_exit ========
*/
Void Server_exit(Void)
{
/*
* Note that there isn't a Registry_removeModule() yet:
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=315448
*
* ... but this is where we'd call it.
*/
}
请问:如何知道IPC的中断优先级,且使定时器中断优先于IPC中断?
期待您的回复,谢谢!
