RSO Sample Demo LinkFar

Location

$REVOLUTION_SDK_ROOT/build/demos/rsodemo/LinkFar

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 MEM2 and module F (f.rso) allocated to MEM1 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. One workaround is to obtain a buffer in the range that can be jumped to with a normal branch instruction (28 bits), output the instruction for the 32-bit absolute address branch to that buffer, and then link to that buffer.

When module G is placed in MEM2, the static module function (such as OSReport) and a function from module H in MEM1 (IsHThere) must be set as a branch using the 32-bit absolute address.
In addition, because module H calls the module G function (IsGThere), this must also be made into a branch using 32-bit absolute address branching.

In the sample, the above process occurs in the local functions LinkFar or LinkFarMem2.
Get the required buffer size with RSOGetFarCodeSize, allocate the buffer, and then output the instruction code to the buffer with RSOLinkFar to link to the buffer.

Note: The buffer obtained should be in the same main memory (MEM2 or MEM1) as the referencing module. In addition, the code in the module is overwritten normally after linking. Thus, when using RSOLinkListFixed, proceed to RSO_FL_INTERNAL at the deallocation stage.

See Also

Sample List
RSOLinkFar, RSOGetFarCodeSize,

Revision History

2006/09/25 Initial version.


CONFIDENTIAL