s u ......

Click here to load reader

Post on 21-Jan-2020

5 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • 362 AUTOSAR Compendium, Part 1 – Application & RTE

    13 Implementation Integration

    13 Implementation Integration

    13.1 Compiler Abstraction (Compiler.h)

    The compiler abstraction specifies definitions and macros for the abstraction of compiler specific keywords used for addressing data and code (pointers, variables, function etc.) within declarations and definitions.

    The file Compiler_Cfg.h contains the module / component specific parameters (ptrclass and memclass) that are passed to the macros defined in Compiler.h.

    13.1.1 Definitions

    Define Description AUTOMATIC Empty definition, used for the declaration of local pointers. TYPEDEF Empty definition, used within type definitions, where no memory qualifier can be specified. NULL_PTR NULL Pointer

    ((void *)0) INLINE Define for abstraction of the keyword “inline”. LOCAL_INLINE Define for abstraction of the keyword “inline” in functions with “static” scope.

    Table 209 Compiler Defines

    13.1.2 Memory Classes and Pointer Classes

    In the following table the is derived from the Software Component’s shortName.

    Memory type Syntax of memory class (memclass) and pointer class (ptrclass) macro parameter

    To be used for…

    Code _CODE code Constants _CONST global or static constants Pointer _APPL_DATA references on application data (expected to be in RAM

    or ROM) passed via API Pointer _APPL_CONST references on application constants (expected to be

    certainly in ROM, for instance pointer of Init-function) passed via API

    Pointer _APPL_CODE references on application functions. (e.g. call back function pointers)

    Variables _CALLOUT_CODE references on application functions. (e.g. callout function pointers)

    Variables _VAR_NOINIT all global or static variables that are never initialized Variables _VAR_POWER_ON_INIT all global or static variables that are initialized only after

    power on reset Variables _VAR_FAST all global or static variables that have at least one of the

    following properties:  accessed bitwise  frequently used  high number of accesses in source code

    Variables _VAR global or static variables that are initialized after every reset.

    Variables AUTOMATIC local non static variables Type Definitions TYPEDEF type definitions where no memory qualifier can be

    specified.

  • AUTOSAR Compendium, Part 1 – Application & RTE 363

    13 Implementation Integration

    Table 210 Memory Classes and Pointer Classes

    13.1.3 Macros for Functions, Pointers, Constants and Variables

    These macros ensure correct syntax of definitions and declarations independent of any specific compiler.

    Sh or

    t d es

    cr ip

    tio n

    an d

    ex am

    pl e

    Fu nc

    tio n

    de cl

    ar at

    io n

    an d

    de fin

    iti on

    F U N C ( v o i d , S w c t S h o r t N a m e _ C O D E ) R u n n a b l e C o d e ( v o i d ) ;

    Fu nc

    tio n

    re tu

    rn in

    g a

    po in

    te r t

    o a

    co ns

    ta nt

    F U N C _ P 2 C O N S T ( u i n t 1 6 , < P R E F I X > _ P B C F G , S w c t S h o r t N a m e _ C O D E )

    E x a m p l e F u n c t i o n ( v o i d ) ;

    Fu nc

    tio n

    re tu

    rn in

    g a

    po in

    te r t

    o a

    va ria

    bl e

    F U N C _ P 2 V A R ( u i n t 1 6 , < P R E F I X > _ P B C F G , S w c t S h o r t N a m e _ C O D E )

    E x a m p l e F u n c t i o n ( v o i d ) ;

    Po in

    te r t

    o va

    ria bl

    e P 2 V A R ( u i n t 8 , S P I _ V A R _ F A S T , S P I _ A P P L _ D A T A )

    S p i _ F a s t P o i n t e r T o A p p l D a t a ;

    Po in

    te r t

    o co

    ns ta

    nt

    P 2 C O N S T ( E e p _ C o n f i g T y p e , E E P _ V A R , E E P _ A P P L _ C O N S T )

    E e p _ C o n f i g u r a t i o n P t r ;

    Co ns

    ta nt

    p oi

    nt er

    to v

    ar ia

    bl e

    C O N S T P 2 V A R ( u i n t 8 , N V M _ V A R , N V M _ A P P L _ D A T A )

    N v M _ P o i n t e r T o R a m M i r r o r = A p p l _ R a m M i r r o r ;

    Co ns

    ta nt

    p oi

    nt er

    to c

    on st

    an t

    C O N S T P 2 C O N S T ( C a n _ P B C f g T y p e , C A N _ C O N S T , C A N _ P B C F G _ C O N S T )

    C a n _ P o s t b u i l d C f g D a t a = C a n P B C f g D a t a S e t ;

    Po in

    te r t

    o fu

    nc tio

    n t y p e d e f P 2 F U N C ( v o i d , N V M _ A P P L _ C O D E , N v M _ C b k F n c P t r T y p e ) ( v o i d ) ;

    Co ns

    ta nt

    C O N S T ( u i n t 8 , N V M _ C O N S T ) N v M _ C o n f i g u r a t i o n D a t a ;

    Va ria

    bl e

    V A R ( u i n t 8 , A U T O M A T I C ) N v M _ V e r y F r e q u e n t l y U s e d S t a t e ;

    fc tn

    am e:

    fu

    nc tio

    n na

    m e

    re sp

    ec tiv

    el y

    na m

    e of

    th e

    de fin

    ed ty

    pe

    m em

    cl as

    s:

    cl as

    si fic

    at io

    n of

    th e

    fu nc

    tio n/

    po in

    te r/

    co ns

    ta nt

    /v ar

    ia bl

    e its

    el f

    pt rc

    la ss

    : cl

    as si

    fic at

    io n

    of th

    e po

    in te

    r’s d

    is ta

    nc e

    → 13

    .1 .2

    M ac

    ro u

    sa ge

    (d ef

    in e)

    F U N C ( r e t t y p e , m e m c l a s s )

    F U N C _ P 2 C O N S T ( r e t t y p e , p t r c l a s s ,

    m e m c l a s s )

    F U N C _ P 2 V A R ( r e t t y p e , p t r c l a s s ,

    m e m c l a s s )

    P 2 V A R ( p t r t y p e , m e m c l a s s ,

    p t r c l a s s )

    P 2 C O N S T ( p t r t y p e , m e m c l a s s ,

    p t r c l a s s )

    C O N S T P 2 V A R ( p t r t y p e , m e m c l a s s ,

    p t r c l a s s )

    C O N S T P 2 C O N S T ( p t r t y p e , m e m c l a s s ,

    p t r c l a s s )

    P 2 F U N C ( r e t t y p e , p t r c l a s s ,

    f c t n a m e )

    C O N S T ( c o n s t t y p e , m e m c l a s s )

    V A R ( v a r t y p e , m e m c l a s s )

    va rt

    yp e:

    ty

    pe o

    f t he

    v ar

    ia bl

    e co

    ns tt

    yp e:

    ty

    pe o

    f t he

    c on

    st an

    t re

    ty pe

    :

    re tu

    rn ty

    pe o

    f t he

    fu nc

    tio n

    pt rt

    yp e:

    ty

    pe o

    f t he

    re fe

    re nc

    ed v

    ar ia

    bl e/

    co ns

    ta nt

    M ac

    ro

    F U N C

    F U N C _ P 2 C O N S T

    F U N C _ P 2 V A R

    P 2 V A R

    P 2 C O N S T

    C O N S T P 2 V A R

    C O N S T P 2 C O N S T

    P 2 F U N C

    C O N S T

    V A R

  • 364 AUTOSAR Compendium, Part 1 – Application & RTE

    13 Implementation Integration

    13.2 Memory Mapping (MemMap.h)

    In order to prevent unnecessary memory gaps (unused space in RAM), variables of different size (8, 16 and 32 bit) are mapped to specific memory sections depending on their size.

    Variables that do not need to be initialized after power-on reset can be mapped to a RAM section that is not initialized after a reset.

    Variables that are accessed via bit masks can be located within a RAM section that allows for bit manipulation instructions of the compiler (“Near Page” or “Zero Page”).

    When using external flash memory, modules with functions that are called very often can be mapped to the internal flash memory for faster access. Modules with functions that are called rarely or that have lower performance requirements can be mapped to external flash memory.

    Internal variables can be mapped into protected memory for memory protection, buffers for data exchange are mapped into unprotected memory.

    In order to support Partitions (→17) an additional separation of the module variables into different memory areas (of the Partitions) is supported.

    All memory allocated by the RTE is wrapped in segment declarations defined in the specification of Memory Mapping using RTE as the (Module Short Name).

    13.2.1 Include Strategy of MemMap.h

     Basic Software Modules include MemMap.h  Software Components include _MemMap.h

    (SWCT = shortName of the SwComponentType)

    13.2.2 ALIGNMENT

    The alignment is used for the Memory Allocation Keywords →13.2.4.

    Used for… BOOLEAN variables and constants of size 1 bit 8BIT variables and constants that have to be aligned to 8 bit. 16BIT variables and constants that have to be aligned to 16 bit. 32BIT variables and constants that have to be aligned to 32 bit. UNSPECIFIED variables, constants, structure, array and unions when

    SIZE (alignment) does not fit the criteria of 8, 16 or 32 bit. Table 211 ALIGNMENT

    13.2.3 INIT_POLICY

    The initialization policy