Vault 7: Projects

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

Supported Data Types and Variables
2012-2013 Microchip Technology Inc. DS50002071C-page 127
8.11 COMPILER-SPECIFIC TYPE QUALIFIERS
The MPLAB XC16 C Compiler supports special type qualifiers, all of which allow the
user to control how variables are accessed.
8.11.1 __psv__ Type Qualifier
The __psv__ qualifier can be applied to variables or pointer targets that have been
allocated to the program memory space. It indicates how the variable or pointer targets
will be accessed/read. Allocation of variables to the program memory space is a sepa-
rate process and is made using the space attribute, so this qualifier is often used in
conjunction with that attribute when the variable is defined. For example:
__psv__ unsigned int __attribute__((space(psv))) myPSVvar = 0x1234;
__psv__ char * myPSVpointer;
The pointer in this example does not use the space attribute as it is located in data
memory, but the qualifier indicates how the pointer targets are to be accessed. For
more information on the space attribute and how to allocate variables to the Flash
memory, see Section 8.12 Variable Attributes. For basic information on the
memory layout and how program memory is accessed by the device, see
Section 10.2 Address Spaces.
When variables qualified as __psv__ are read, the compiler will manage the selection
of the program memory page visible in the data memory window. This means that you
do not need to adjust the PSVPAG SFR explicitly in your source code, but the gener-
ated code may be slightly less efficient than that produced if this window was managed
by hand.
The compiler will assume that any object or pointer target qualified with __psv__ will
wholly fit within a single PSV page. Such is the case for objects allocated memory using
the psv or auto_psv space attribute. If this is not the case, then you should use the
__prog__ qualifier (see Section 8.11.2 __prog__ Type Qualifier) and an
appropriate space attribute.
8.11.2 __prog__ Type Qualifier
The __prog__ qualifier is similar to the __psv__ qualifier (see
Section 8.11.1 __psv__ Type Qualifier), but indicates to the compiler that the qual-
ified variable or pointer target may straddle PSV pages. As a result, the compiler will
generate code so these qualified objects can be read correctly, regardless of which
page they are allocated to. This code may be longer than that to access variables or
pointer targets which are qualified __psv__. For example:
__prog__ unsigned int __attribute__((space(prog))) myPROGvar = 0x1234;
__prog__ char * myPROGpointer;
The pointer in this example does not use the space attribute as it is located in data
memory, but the qualifier indicates how the pointer targets are to be accessed. For
more information on the space attribute and how to allocate variables to the Flash
memory, see Section 8.12 Variable Attributes. And, see Section 10.2 Address
Spaces for basic information on the memory layout and how program memory is
accessed by the device.

e-Highlighter

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

Un-highlight all Un-highlight selectionu Highlight selectionh