Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

struct

Altera_Forum
Honored Contributor II
933 Views

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?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
243 Views

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 ---  

0 Kudos
Altera_Forum
Honored Contributor II
243 Views

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
0 Kudos
Reply