Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

MPLAB
®
XC16 C Compiler Users Guide
DS50002071C-page 162 2012-2013 Microchip Technology Inc.
With the two major pieces of the puzzle in place, generate some variables and
accesses:
__external__ unsigned char bits[NUMBER_OF_BITS]
__attribute__((space(external(bit_memory))));
// inside main
__external__ unsigned char *bit;
bit = bits;
for (i = 0; i < 512; i++) {
printf("%d ",*bit++);
}
Apart from the __external__ CV-qualifiers, ordinary C statements can be used to
define and access variables in the external memory space.
10.7 EXTENDED DATA SPACE ACCESS
Qualifying a variable or pointer target as being accessible through the extended data
space window allows you to easily access objects that have been placed in a variety of
different memory spaces. These include: space(data) (and its subsets), eds,
space(eedata), space(prog), space(psv), space(auto_psv), and on some
devices space(pmp). Not all devices support all memory spaces.
To use this feature:
declare an object in an appropriate memory space
qualify the object with the __eds__ qualifier
For example:
__eds__ int var_a __attribute__((space(prog)));
__eds__ int var_b [10] __attribute__((eds));
__eds__ int *var_c;
__eds__ int *__eds__ *var_d __attribute__((space(psv)));
var_a - declares an int in Flash that is automatically accessed
var_b - declares an array of ints, located in eds; the elements of the array are auto-
matically accessed
var_c - declares a pointer to an int, where the destination may exist in any one of the
memory spaces supported by Extended Data Space pointers and will be automatically
accessed upon dereference; the pointer itself must live in a normal data space
var_d - declares a pointer to an int, where the destination may exist in any one of the
memory spaces supported by Extended Data Space pointers and will be automatically
accessed upon dereference; the pointer value exists in Flash and is also automatically
accessed.
The compiler will automatically assert the page attribute to scalar variable declarations;
this allows the compiler to generate more efficient code when accessing larger data
types. Remember, scalar variables do not include structures or arrays. To force paging
of a structure or array, please manually use the page attribute and the compiler will
prevent the object from crossing a page boundary.
For read access to __eds__ qualified variables, the compiler will automatically manip-
ulate the PSVPAG or DSRPAG register as appropriate. For devices that support
extended data space memory, the compiler will also manipulate the DSWPAG register.
Note: Some devices use DSRPAG to represent extended read access to FLASH
or the extended data space (EDS)

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh