RSO Sample Demo - LinkMem2

Location

$REVOLUTION_SDK_ROOT/build/demos/rsodemo/LinkMem2

Overview

Demo program showing allocation of a relocatable module to the external main memory (MEM2 area).
Module E (e.rso) allocated to the external main memory and module F (f.rso) allocated to the internal main memory are set to call functions from each other.

Description

Typically, the branch instructions (bx) only hold the 28-bit additions (±32MB). Therefore, when a relocatable module is placed in external main memory (MEM2), functions in internal main memory (MEM1) cannot be accessed. To avoid this, instruct the compiler to use 32-bit absolute address branching, using pragma.

When module E is placed in MEM2, the static module function (such as OSReport) and a function from module F in MEM1 (IsFThere) must be set as a branch, using the 32-bit absolute address.
For this reason, the sample program will set those functions as 32-bit absolute address branches when called within module E, as follows:


// from e.c source
#pragma section code_type ".text" data_mode=far_abs code_mode=far_abs
#pragma section RX ".init" ".init" data_mode=far_abs code_mode=far_abs 

#include <revolution.h>

#include "f.h"

#pragma section code_type ".text" data_mode=far_abs code_mode=pc_rel
#pragma section RX ".init" ".init" data_mode=far_abs code_mode=pc_rel

Also, because module F calls a module E function (IsEThere), they are set as follows:


// from f.c source
#pragma section code_type ".text" data_mode=far_abs code_mode=far_abs
#pragma section RX ".init" ".init" data_mode=far_abs code_mode=far_abs 

#include "e.h"

#pragma section code_type ".text" data_mode=far_abs code_mode=pc_rel
#pragma section RX ".init" ".init" data_mode=far_abs code_mode=pc_rel

Note as of 06/15/2006
Certain runtime codes may not be properly called in the 32-bit codes in the release version.
As a temporary remedy, use_lmw_stmw pragma is currently applied to avoid the use of those runtime codes.
This is applied to modules placed in the external main memory.
One example where this is used is e.c.
The same goes for the compile option -use_lmw_stmw on.


// from e.c source
#pragma use_lmw_stmw on

See Also

Demo Program List
RSOListInit, RSOLinkList, RSOUnLinkList, RSOFindExportSymbolAddr, RSOIsImportSymbolResolvedAll,

Revision History

06/14/2006 Initial version.


CONFIDENTIAL