Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

struct

The following code works fine:

# define RAMSHADOWBASE 0x01010000# define TESTVARIABLE (*(unsigned int*)RAMSHADOWBASE)

Now I want to add a struct on the same way. Thus I want to place a structure on a predefined adress in RAM memory.

Struct looks like:

struct Defs

{

unsigned int Nr;

unsigned int Place;

} lacingHole[40];

Somebody a solution for this?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Nobody a solution????

    --- Quote Start ---

    originally posted by innotronics@Jan 9 2007, 10:40 AM

    the following code works fine:

    # define ramshadowbase 0x01010000# define testvariable (*(unsigned int*)ramshadowbase)

    now i want to add a struct on the same way. thus i want to place a structure on a predefined adress in ram memory.

    struct looks like:

    struct defs

    {

    unsigned int nr;

    unsigned int place;

    } lacinghole[40];

    somebody a solution for this?

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=20433)

    --- quote end ---

    --- Quote End ---

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi innotronics,

    There are two common ways of accomplishing what (I believe) you want:

    1, access the structure via a pointer:
    #define DEFSBASE  0x01010000
    struct Defs *pDefs = (struct Defs *) DEFSBASE;
    ...
    pDefs->Nr = <<whatever>>

    or ...

    2. put the structure in a named section ...
    struct Defs  myDefs __attribute__ ((section (",defs")));
    myDefs.Nr = <<whatever>>

    ... then locate the section where you want in your linker command file.
    __defs_start = .;
        .defs :
        {
       *(.defs)
        }

    Regards,

    --Scott