AnsweredAssumed Answered

Creating Mailboxes in L2

Question asked by AlClark on Jun 21, 2016
Latest reply on Jun 27, 2016 by stevek

Let's assume we want to create shared memory in L2 space that each core can access.

 

I didn't find any explicit examples of doing this, so here is my attempt and theory.

I am assuming that the linker will place each declaration in the order defined and that this is the only file that defines variables in this segment so that the linker doesn't encounter another file with declarations in this space and mess up the placement of these variables.

 

If this is not a true assumption, can someone show me how to define each variable at an absolute address?

Can someone review the following code and correct any errors?

 

We create a segment called seg_mailbox in each LDF with the same definition.

 

We may need to make adjustments to apt-sc589.c to define whatever read write access we need.

We may also need to consider some form of arbitration - lock functions, etc.

 

We then create a mailbox.asm or mailbox.c file for each core. One of these files will be the only one included in each core's source. These files will just declare variables that will be global within a core set of files and hopefully aliased with the same names and locations in the other core files.

 

Let's assume ASM for the SHARC cores:

 

.SECTION/DM  seg_mailbox;

 

.VAR _mailbox_array_1[256];

.VAR _mailbox_semaphore_a;

.VAR _mailbox_semaphone_b;.

.VAR _mailbox_semaphone_c;

.VAR _mailbox_semaphone_d;

.VAR _mailbox_array_2[32];

 

 

.GLOBAL _mailbox_array_1;

.GLOBAL _mailbox_semaphore_a;

.GLOBAL _mailbox_semaphone_b;.

.GLOBAL _mailbox_semaphone_c;

.GLOBAL _mailbox_semaphone_d;

.GLOBAL _mailbox_array_2;

 

 

Let's assume C for the ARM cores (could also have been used for SHARC cores but I like ASM)

 

#pragma section("seg_mailbox") // Do I need this for each variable?

int mailbox_array_1[256];

 

#pragma section("seg_mailbox") // Do I actually need  this for each variable?

int mailbox_semaphore_a;

 

#pragma section("seg_mailbox") // Do I actually need this for each variable?

int mailbox_semaphore_b;

 

#pragma section("seg_mailbox") // Do I actually need this for each variable?

int mailbox_semaphore_c;

 

#pragma section("seg_mailbox") // Do I actually need this for each variable?

int mailbox_semaphore_d;

 

#pragma section("seg_mailbox") // Do I actually need this for each variable?

int mailbox_array_2[32];

 

A corresponding header file might look like this:

 

#ifdef __ECC__ // C files

 

extern int mailbox_array_1[256];

extern int mailbox_semaphore_a;

extern int mailbox_semaphone_b;.

extern int mailbox_semaphone_c;

extern int mailbox_semaphone_d;

extern int mailbox_array_2[32];

 

#else // ASM files

 

.extern _mailbox_array_1;

.extern _mailbox_semaphore_a;

.extern _mailbox_semaphone_b;.

.extern _mailbox_semaphone_c;

.extern _mailbox_semaphone_d;

.extern _mailbox_array_2;

 

#endif

 

 

Al Clark

Danville Signal

Outcomes