Samples: Use a macro for delay time in ResMgr sample

Defined a new macro for the delay used in the ResMgr sample.
This should allow this delay to be changed easily, if the
BIOS clock tickPeriod is changed.

Signed-off-by: Suman Anna <s-anna@ti.com>
Resources: Introduce new IpcMemory module

A new IpcMemory module is added to provide address translation
functions operating on the resource table. The IpcMemory module
now inherently includes the resource table as part of the module.
The table is statically created and allocated in the address
specified by IpcMemory.loadAddr. Default address is 0x3000.

Alternatively, the table location could be specified by segment.
If a valid segment is assigned to IpcMemory.loadSegment, the
base address of that segment will be used as the load address
overridng whatever value is assigned to IpcMemory.loadAddr.

The APIs provided by this module for translating virtual to
physical addresses and vice-versa are:
    Int IpcMemory_virtToPhys(UInt32 va, UInt32 *pa)
    Int IpcMemory_physToVirt(UInt32 pa, UInt32 *va)

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Configs: Include the IpcMemory module

Pull in the IpcMemory module that defines the BIOS
Resource Table. The Resource Table is automatically
linked in now by using this module, and is placed at
a common address for the two M3 cores. There is no
need for using a specific linker section mapping in
the base image configuration files.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Samples: Remove resource table trace from Core0 samples

In order to have the linker include the resource table in the
baseimage, the resource variable needs to be used in some form.
Otherwise the optimization in the linker detects that this is a
non-referenced variable and removes it from the baseimage. To
alleviate this, a dummy trace was used to make sure the resource
table section is present in the firmware binary.

The new IpcMemory module inherently adds this trace, and so the
trace in SysM3 samples is no longer required and is removed.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Resources: Add DMM/TILER register space to Resource Table

The DMM/TILER register space is added to the resource table, so that
it can be programmed into the L2MMU, and is accessible by Ducati. The
space is already configured properly in the AMMU.

Signed-off-by: Suman Anna <s-anna@ti.com>
Trace: Use proper locking for trace buffers in SMP mode

SysMin has a line buffer for each core and a module-wide
shared buffer, common to both the cores and used to flush
out line buffers one at a time. The tracing functionality
depends on locking of these buffers properly. The line buffer
is protected by disabling local core interrupts, and the
shared buffer is protected by acquiring a system lock.

The current code is re-enabling the local core interrupts
before checking whether the line buffer needs flushing. This
opens up a small window for the line buffer to be overwritten
by a different task or interrupt while the current thread is
waiting for the system lock to flush the core line buffer.
This is fixed by enabling the local core interrupts properly
after checking on the flush condition. Releasing the system
gate re-enables the core interrupts automatically, so there
is no need for enabling local interrupts specifically when
flushing the line buffer.

Signed-off-by: Suman Anna <s-anna@ti.com>
Build: Cleanup SMP-mode files properly

The BUILD_SMP variable has to be defined and have a value of
1 to define a SMP build. This has to be passed for both the
build and clean commands. The xdc clean invocation is missing
this and has been fixed.

Signed-off-by: Suman Anna <s-anna@ti.com>
Build: Update to newer XDC and IPC toolset

The build system is updated to use newer XDC (XDC 3.23.02.47) and
IPC (IPC 1.24.02.27) tools.

This newer toolset are the latest on the respective release streams,
and allow a single unified version of XDC and IPC tools between
the SMP and non-SMP versions.

The README has also been updated with the corresponding download
links.

Signed-off-by: Suman Anna <s-anna@ti.com>
SrvMgr: Cleanup types in rpmsg omx header

The types in the rpmsg_omx.h have been cleaned up to use
the standard types on the SYS/BIOS side.

Signed-off-by: Pradeep Venkatasubbarao <pradeepv@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
SrvMgr: Protect header against multiple inclusions

The ServiceMgr.h is missing the protection against
multiple includes. The C++ linkage also has been
fixed alongside.

Signed-off-by: Suman Anna <s-anna@ti.com>
SrvMgr: Enhance Service Manager to allow multiple services

The Service Manager module has been enhanced to allow different
services to use its infrastructure. This is done to allow other
IPC protocols to use the VirtQueue transport infrastructure
in tandem.

The OMX Service that is inherently tied into Service Manager
is now decoupled and moved out of the Service Manager code
and is built as an independent library.

This is achieved through the following:
1. The internal functions to create and delete different
   instances of a service are made public through the API,
   ServiceMgr_createService and ServiceMgr_deleteService.
   The signature of these functions remain identical to the
   previous internal functions:
     UInt32 ServiceMgr_createService(Char * name, UInt32 * endpt);
     UInt32 ServiceMgr_deleteService(UInt32 addr);

2. A new API, ServiceMgr_registerSrvTask, is added that allows
   an external library to register its service task function
   with the ServiceMgr module. The registration is expected to
   be fairly early during the base image execution. All the task
   parameters are to be initialized before registering with
   ServiceMgr.
     Bool ServiceMgr_registerSrvTask(UInt16 reserved,
                                     Task_FuncPtr func,
                                     Task_Params *taskParams)

3. A new API, ServiceMgr_start, is added that allows all the
   registered services to be started. All service registrations
   has to be done before a call to this function. The reserved
   argument is to be used for future scalability for starting
   services with different processors, and is currently
   ignored.
     UInt ServiceMgr_start(UInt16 reserved);

OMX Service is registered and included in the executable at
configuration time.

Simultaneous support for non-SMP and SMP-mode libraries has
also been added.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Configs: Include the OMX Service Manager module

The OMX Service Manager module has to be invoked in the
config files to link the ti.srvmgr.omx library in the
final base images, and register the OMX service with the
ServiceMgr module.

Signed-off-by: Suman Anna <s-anna@ti.com>
Samples: Invoke ServiceMgr_start specifically

Executables have to specifically invoke ServiceMgr_start to
start all the service tasks registered with the ServiceMgr
module. This change is needed to support the new enhancements
implemented in the ServiceMgr module - necessary to start the
the decoupled OMX Service task.

Signed-off-by: Suman Anna <s-anna@ti.com>
SrvMgr: Add support for OMAPRPC mechanism

OMAPRPC is a generic RPC on top of Service Manager.

Simultaneous support for non-SMP and SMP-mode libraries has
also been added.

Signed-off-by: Erik Rainey <erik.rainey@gmail.com>
Signed-off-by: Jesse Villarreal <jesse.villarreal@ti.com>
Signed-off-by: Alberto Aguirre <a-aguirre@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
ResMgr: Correct for coding style in internal structures

The internal structures and enums used by ResMgr have
been adjusted for the SYS/BIOS coding style. The enums
in the exposed header are not being change to not
break compatibility.

Signed-off-by: Suman Anna <s-anna@ti.com>
IPC: Rename the vring buffer macros and variables

The vring macros and variables used for defining the locations of
the vring buffers are virtual addresses (or device addresses),
and hence have been renamed appropriately.

Signed-off-by: Suman Anna <s-anna@ti.com>
IPC: Handle unknown mbox messages correctly

The VirtQueue ISR function interprets a certain set of mailbox
messages, and all others as a notification of unprocessed
message(s) on a VirtQueue indicated by the value of the
mailbox message.

A check is added to verify that such index received is within the
valid virtqueue index range. This check prevents any out-of-bound
array accesses and related potential crashes/hangs.

Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Samples: Update the ResMgr sample to check for proper status

Resmgr Sample is modified to check for proper return status for
each of the resource request and release function calls. The sample
now prints an easy-to-read succeeded or failed status with the
corresponding status codes for various combinations of the resource
and constraints requests.

The sample has also been updated properly to support the different
resource request variations for OMAP5.

Signed-off-by: Chandra Sekhar.Anagani <chandu@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Merge branch 'rpmsg-1.20' into master

Merged 1.20.02.04 into master in preparation for a
newer version of sysbios-rpmsg to support SMP/BIOS
with v3.4 kernel.

Conflicts:
	src/ti/examples/srvmgr/resmgr_task.c
	src/ti/resources/IpcMemory.xdt
	src/ti/resources/IpcMemory.xs
	src/ti/resources/package.bld
	src/ti/resources/package.xs
	src/ti/resources/rsc_table.h

Signed-off-by: Suman Anna <s-anna@ti.com>
IPC: Correct VirtQueue_getAvailBuf based on review

A review of VirtQueue revealed the index to the available ring
buffer was being calculated differently than lguest from which
it was modelled. It worked given the current usage model, but
to be more correct, it should be updated to match what Linux
side does.

This change was verified to work by asserting that head index
was the same in both cases under sample tests. A minor trace
change to display the ring.avail addr is also added.

Signed-off-by: G Anthony <a0783926@ti.com>
Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>