RSO Sample Demo - LinkMem2

Location

$REVOLUTION_SDK_ROOT/build/demos/rsodemo/LinkMem2

Overview

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

Description

Typically, branch instructions (bx) have only a 28-bit offset (± 32 MB). Therefore, when a dynamic 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 branching in the 32-bit absolute address 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 function as a branch of 32-bit absolute address 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 2006/06/15:
Certain runtime codes may not be properly called in 32-bit codes in the release version.
As a temporary remedy, use_lmw_stmw pragma is currently applied to avoid the use of those run-time codes.
This is applied to modules placed in the external main memory.
This is used in e.c in the sample.

This is also true for the compile option -use_lmw_stmw on.


// from e.c source
#pragma use_lmw_stmw on

See Also

Sample List
RSOListInit, RSOLinkList, RSOUnLinkList, RSOFindExportSymbolAddr, RSOIsImportSymbolResolvedAll,

Revision History

2006/06/14 Initial version.


CONFIDENTIAL