Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Real-Time Software Components (RTSC) » Creating a buffer in .cfg
Creating a buffer in .cfg [message #2609] Wed, 06 May 2009 19:35 Go to next message
Todd Mullanix is currently offline Todd Mullanix
Messages: 8
Registered: July 2009
Junior Member
I have a HeapFoo module that has an instance configuration parameter that
is an address (sharedAddr) and an Instance_State field attrs

HeapFoo.xdc
===========
instance:
config Ptr sharedAddr = null;
...
internal
struct Instance_State {
Attrs *attrs;
...

I have the following line assignment in the instance$static$init:
HeapFoo.xs
==========
instance$static$init() {
...
obj.attrs = $addr(params.sharedAddr);
...

I want to test this on multiple targets/platforms, so I have a Buffers
module:
Buffers.xdc
===========
module Buffers
{
config Char buf[length];
}


I create a buffer and assign it to sharedAddr
testHeapFoo.cfg
===============
Buffers = xdc.useModule('ti.sdo.ipc.testsHeaps.Buffers');
var buf = Buffers.buf;
buf.length = 1024;
...
heapParams.sharedAddr = buf;


The 1024 char buffer does get created (looked in the mapfile). But I'm
getting an build error. It is complaining about the obj.attrs =
$addr(params.sharedAddr); line
"js: "/ti/sdo/ipc/HeapFoo.xs", line 98: Cannot convert
ti.sdo.ipc.testsHeaps.Buffers/buf to java.lang.Long"

I also tried
heapParams.sharedAddr = buf.$addrof(0);

"js: "ti/sdo/ipc/HeapFoo.xs", line 98: Cannot convert
ti.sdo.ipc.testsHeaps.Buffers/buf/0.0 to java.lang.Long

I also tried changing the buf type in Buffers.xdc to Long...same thing.

Ideally, I'd like to just have a global variable in my testHeapFoo.c file
and reference that in the testHeapFoo.cfg file, but I don't think that is
possible.

Ideas? Did I just mess something up, or am I going down the wrong path.

Thanks,
Todd
Re: Creating a buffer in .cfg [message #2639 is a reply to message #2609] Wed, 06 May 2009 22:05 Go to previous messageGo to next message
Dave Russo is currently offline Dave Russo
Messages: 172
Registered: July 2009
Senior Member
Try removing the unnecessary (and undocumented) $adrr(). This function
is only used to create addresses from literal constants.

Todd Mullanix wrote:
> I have a HeapFoo module that has an instance configuration parameter
> that is an address (sharedAddr) and an Instance_State field attrs
>
> HeapFoo.xdc
> ===========
> instance:
> config Ptr sharedAddr = null;
> ...
> internal
> struct Instance_State {
> Attrs *attrs;
> ...
>
> I have the following line assignment in the instance$static$init:
> HeapFoo.xs
> ==========
> instance$static$init() {
> ...
> obj.attrs = $addr(params.sharedAddr);
> ...
>
> I want to test this on multiple targets/platforms, so I have a Buffers
> module:
> Buffers.xdc ===========
> module Buffers
> {
> config Char buf[length];
> }
>
>
> I create a buffer and assign it to sharedAddr
> testHeapFoo.cfg
> ===============
> Buffers = xdc.useModule('ti.sdo.ipc.testsHeaps.Buffers');
> var buf = Buffers.buf;
> buf.length = 1024;
> ...
> heapParams.sharedAddr = buf;
>
>
> The 1024 char buffer does get created (looked in the mapfile). But I'm
> getting an build error. It is complaining about the obj.attrs =
> $addr(params.sharedAddr); line
> "js: "/ti/sdo/ipc/HeapFoo.xs", line 98: Cannot convert
> ti.sdo.ipc.testsHeaps.Buffers/buf to java.lang.Long"
>
> I also tried heapParams.sharedAddr = buf.$addrof(0);
>
> "js: "ti/sdo/ipc/HeapFoo.xs", line 98: Cannot convert
> ti.sdo.ipc.testsHeaps.Buffers/buf/0.0 to java.lang.Long
>
> I also tried changing the buf type in Buffers.xdc to Long...same thing.
> Ideally, I'd like to just have a global variable in my testHeapFoo.c
> file and reference that in the testHeapFoo.cfg file, but I don't think
> that is possible.
>
> Ideas? Did I just mess something up, or am I going down the wrong path.
>
> Thanks,
> Todd
>
>
Re: Creating a buffer in .cfg [message #2715 is a reply to message #2639] Thu, 07 May 2009 11:52 Go to previous messageGo to next message
Todd Mullanix is currently offline Todd Mullanix
Messages: 8
Registered: July 2009
Junior Member
I had tried that and was getting the following error:
js: "ti/sdo/ipc/HeapFoo.xs", line 98: XDC runtime error:
ti.sdo.ipc.HeapFoo.Instance_State#0: incompatible assignment to attrs
:xdc.services.intern.xsr.Value$Arr@192a848::ti.sdo.ipc.testsHeaps.Buffers/buf
gmake: *** [package/cfg/debug/testBufStatic1_x674.h] Error 1

I'm thinking I need to change my "Attrs *" to a Ptr in the Instance_state
and cast everywhere in the code.

I used $addr() because I do want to support supplying a constant (e.g.
0x20000) to sharedAddr.
Re: Creating a buffer in .cfg [message #3147 is a reply to message #2609] Thu, 07 May 2009 15:54 Go to previous message
Eclipse User
Originally posted by: bob.biosbob.biz

assigning target pointer-values in the meta-domain attempts to mirror
the semantics of C in the following sense: "specific" pointer-values
(eg., of type 'Attr*') can be assigned to "generic" pointer-variables of
type 'Ptr' *without* a cast; but also, generic pointer-values of type
'Ptr' can be assigned to specific pointer-values *without* a cast as
well. [FYI -- C++ only allows specific => generic, which seems a little
more typesafe]. needless to say, direct assignment of one specific kind
of pointer to a *different* specific kind of is prohibited; some sort of
cast is required.

in this case, there are several different ways obj.attrs can be assigned
-- other than, of course, supplying a "specific" value of type 'Attrs*'.

as in C -- where you can write (Attrs*)(0x1234) -- you can use the
$addr(0x1234) operator to produce a "generic" pointer-value that can
then bev assigned to obj.attrs; the generated package/cfg/*.c file will
actually insert the (Attrs*) cast within the static initializer.

more elaborate, you can use the $addrof operator to obtain a "generic"
pointer to an element of an aggregate object -- either an element of an
array or else a field of a struct. this corresponds to static
initializers of the form '&arr[12]' or '&str.fld'. in the example here,
you can assign directly assign obj.attrs = Buffers.buf.$addror(0); note
that this value *could* have first assigned to 'sharedAddr', though this
step is really not necessary.

finally, you can use the $externPtr(symbol) operator to yield a
"generic" pointer value corresponding to this symbol....

here's a litte test Mod i put together....

module Mod {

struct Attrs {
Int x;
};

config Ptr sharedAddr;
config Attrs* attrs;
config Char buffer[length];

int main( int argc, char* argv[] );

}

in my .cfg script i then wrote....

var Mod = xdc.useModule('Mod');

Mod.buffer.length = 1024;
Mod.sharedAddr = Mod.buffer.$addrof(0);

Mod.attrs = Mod.sharedAddr;
Mod.attrs = Mod.buffer.$addrof(0); // same effect
Mod.attrs = $externPtr('myAttrs'); // global var
Mod.attrs = $addr(1234); // hard addr




Todd Mullanix wrote:
> I have a HeapFoo module that has an instance configuration parameter
> that is an address (sharedAddr) and an Instance_State field attrs
>
> HeapFoo.xdc
> ===========
> instance:
> config Ptr sharedAddr = null;
> ...
> internal
> struct Instance_State {
> Attrs *attrs;
> ...
>
> I have the following line assignment in the instance$static$init:
> HeapFoo.xs
> ==========
> instance$static$init() {
> ..
> obj.attrs = $addr(params.sharedAddr);
> ..
>
> I want to test this on multiple targets/platforms, so I have a Buffers
> module:
> Buffers.xdc ===========
> module Buffers
> {
> config Char buf[length];
> }
>
>
> I create a buffer and assign it to sharedAddr
> testHeapFoo.cfg
> ===============
> Buffers = xdc.useModule('ti.sdo.ipc.testsHeaps.Buffers');
> var buf = Buffers.buf;
> buf.length = 1024;
> ..
> heapParams.sharedAddr = buf;
>
>
> The 1024 char buffer does get created (looked in the mapfile). But I'm
> getting an build error. It is complaining about the obj.attrs =
> $addr(params.sharedAddr); line
> "js: "/ti/sdo/ipc/HeapFoo.xs", line 98: Cannot convert
> ti.sdo.ipc.testsHeaps.Buffers/buf to java.lang.Long"
>
> I also tried heapParams.sharedAddr = buf.$addrof(0);
>
> "js: "ti/sdo/ipc/HeapFoo.xs", line 98: Cannot convert
> ti.sdo.ipc.testsHeaps.Buffers/buf/0.0 to java.lang.Long
>
> I also tried changing the buf type in Buffers.xdc to Long...same thing.
> Ideally, I'd like to just have a global variable in my testHeapFoo.c
> file and reference that in the testHeapFoo.cfg file, but I don't think
> that is possible.
>
> Ideas? Did I just mess something up, or am I going down the wrong path.
>
> Thanks,
> Todd
>
>
Previous Topic:using specific version of gcc
Next Topic:Memory fill using configuration file
Goto Forum:
  


Current Time: Tue Jul 29 21:11:33 EDT 2014

Powered by FUDForum. Page generated in 0.02364 seconds