1    /*
     2     * Copyright (c) 2015, Texas Instruments Incorporated
     3     * All rights reserved.
     4     *
     5     * Redistribution and use in source and binary forms, with or without
     6     * modification, are permitted provided that the following conditions
     7     * are met:
     8     *
     9     * *  Redistributions of source code must retain the above copyright
    10     *    notice, this list of conditions and the following disclaimer.
    11     *
    12     * *  Redistributions in binary form must reproduce the above copyright
    13     *    notice, this list of conditions and the following disclaimer in the
    14     *    documentation and/or other materials provided with the distribution.
    15     *
    16     * *  Neither the name of Texas Instruments Incorporated nor the names of
    17     *    its contributors may be used to endorse or promote products derived
    18     *    from this software without specific prior written permission.
    19     *
    20     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    22     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    23     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    27     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    28     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    29     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    30     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31     */
    32    /*
    33     *  ======== Core.xdc ========
    34     */
    35    
    36    import xdc.runtime.Error;
    37    
    38    /*!
    39     *  ======== Core ========
    40     *  Core Identification Module.
    41     *
    42     *  The Core module is used to define which core within a dual core
    43     *  "R5" subsystem an application is being built for.
    44     *
    45     *  At runtime, a comparison is made between the configured Core.id
    46     *  and the value of MPIDR (bits 7:0). If they do not agree, an Error
    47     *  is raised.
    48     *
    49     *  Core 0's vector table is placed at 0x100 and Core 1's vector table
    50     *  is placed at 0x20000.
    51     *
    52     *  @a(Bootup sequence)
    53     *  When each Cortex-R core comes out of reset, it initializes the
    54     *  stack pointer and calls the reset callback function
    55     *  (see {@link #resetFunc}) and then continues executing the
    56     *  bootup sequence.
    57     *
    58     *  On a lockstep device, the bootup sequence involves calling
    59     *  _c_int00() while on dual-core devices, the bootup sequence
    60     *  involves setting up IPC between the 2 Cortex-R cores to
    61     *  synchronize their startup.
    62     *
    63     *  The reset callback function is called very early in the
    64     *  bootup sequence and can be used to detect the reset source and
    65     *  take the appropriate action. Here's an example showing how to
    66     *  register a reset callback function:
    67     *
    68     *  @p(code)
    69     *  var Core = xdc.useModule('ti.sysbios.family.arm.v7r.tms570.Core');
    70     *  Core.resetFunc = '&myfunc';
    71     *  @p
    72     */
    73    
    74    @ModuleStartup          /* to configure static timers */
    75    @Template ("./Core.xdt")
    76    
    77    module Core inherits ti.sysbios.interfaces.ICore
    78    {
    79        /*! Reset function type definition. */
    80        typedef Void (*ResetFuncPtr)(void);
    81    
    82        /*!
    83         *  Error raised if Core.id does not match the contents
    84         *  of MPIDR [7:0] register.
    85         */
    86        config Error.Id E_mismatchedIds = {
    87            msg: "E_mismatchedIds: Core_Id: %d does not match hardware core Id: %d"
    88        };
    89    
    90        override config UInt numCores;
    91    
    92        /*!
    93         *  R5 Core ID, default is Core 0
    94         *
    95         *  Used for making static decisions based on Core ID
    96         */
    97        config UInt id = 0;
    98    
    99        /*!
   100         *  ======== resetFunc ========
   101         *  Reset Function Pointer
   102         */
   103        metaonly config ResetFuncPtr resetFunc = null;
   104    
   105        @Macro
   106        override UInt hwiDisable();
   107    
   108        @Macro
   109        override UInt hwiEnable();
   110    
   111        @Macro
   112        override Void hwiRestore(UInt key);
   113    
   114    internal:
   115    
   116        /*
   117         *  ======== overrideHwiResetFunc ========
   118         *  This flag is set if this module installs its own resetFunc
   119         *  as Hwi.resetFunc and is used by various sections of code to
   120         *  determine whether or not to generate certain functions.
   121         */
   122        metaonly config Bool overrideHwiResetFunc = false;
   123    
   124        /*
   125         *  ======== startCore1 ========
   126         *  Signal Core1. Called by Core0.
   127         */
   128        Void startCore1();
   129    
   130        /*
   131         *  ======== resetC ========
   132         */
   133        Void resetC();
   134    }