Communicator e3000 MPE/iX Release 6.5 (Non-Platform Software Release C.65.00 (30216-90291)
36 Chapter3
Growth Solution
MPE/iX Large Files Overview
Problem Description
Due to the way that existing MPE/iX compilers emit instructions to access memory,
problems can result when accessing Large Files with a Large File pointer. Long pointers
on PA-RISC hardware are defined to have two separate parts; a space ID, and an offset
within that space. This also corresponds to the way virtual memory is defined in PA-RISC
-- a 64-bit address broken down into the high 32-bits defining the space of the address, and
the lower 32-bits defining the offset within that space.
When building instructions to access memory, the space ID must first be loaded into a
space register. The offset portion of the address is then loaded into a general register and
the space register/general register pair is used to de-reference virtual memory. When
adding to the pointer, the general register is incremented and then used in conjunction
with the space register that was previously loaded. When the maximum file size supported
on the system was 4GB (the size of each space), all valid file offsets were found within a
single space, and there was no need to change the space ID.
The advent of Large Files makes it possible for a single file to cross multiple space ID
boundaries. This presents a problem for existing code which uses long-mapped access.
When the general register holding the offset is incremented to the point that it overflows,
logically it should reference the first word in the next space. However, because the space ID
is held in a separate space register, the overflow of the general register is lost. The net
effect is that access loops back to the beginning of the current space rather than moving on
to the next space as intended.
Compatibility Issue
In order to prevent applications from inadvertently stumbling across this data access
problem, normal long-mapped access to Large Files has been made illegal. Any attempt to
open a Large File for long-mapped access (HPFOPEN option 21) results in an error. In order
to open a Large File for user-mapped access, a new large-mapped option must be passed
(HPFOPEN option 87). This new large-mapped option works on both Large Files as well as
normal-sized files. In programs that wish to continue to access Large Files through
user-mapped access, all instances of HPFOPEN calls for long-mapped access (option 21) need
to be changed to large-mapped access (option 87). The pointer that is returned is still a
64-bit pointer which is equivalent in every way to the pointer type returned by the
long-mapped option.
By specifying this new large-mapped access option, the option assumes that the caller is
indicating their awareness of cross space ID problem and ensures that the program logic
correctly handles any cross space ID buffer.
Workaround
The workaround to this problem is actually fairly simple. Any access that would normally
span a space ID boundary needs to be broken into two separate accesses, one for each side
of the space ID boundary. This can be done within the calling application directly, or by
calling the new intrinsics described in section 3 of this document. In order to open a Large
File for user-mapped access, the new HOP_OPTION_LARGE_MAPPED (87) option must be
passed instead of the long-mapped option.