This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Interruptions and exceptions Bios 6

Other Parts Discussed in Thread: TMS320C6670, SYSBIOS

Hello, everyone.

I was trying to test the Memory Protetection Example at (http://processors.wiki.ti.com/index.php/MemoryProtectionOnKeystoneDevices), but I realized that I must use Sys/Bios in my end aplication. So, what I need is to translate the configuration to the bios environment, but I don't undersatand well how to use the hardware interruptions and exceptions. I'm running it on a TMS320C6670.

This is the basic code I've trying to probe.

#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/family/c64p/Hwi.h>
#include <ti/sysbios/family/c64p/Exception.h>
#include <ti/sysbios/family/c64p/MemoryProtect.h>
//#include <ti/sysbios/hal/Hwi.h>
//#include <ti/sysbios/knl/Task.h>

#include "various.h"

void myIsr10(UArg inval)
{
    //System_printf("This function does nothing but %d!", inval);
    //System_flush();
}

void excep_handler(void)
{
    //System_printf("An Exception had occurred.");
    //System_flush();
}

void excep_handler_intn(void)
{
    //System_printf("An Internal Exception had occurred.");
    //System_flush();
}

void excep_handler_extn(void)
{
    //System_printf("An External Exception had occurred.");
    //System_flush();
}

void main()
{
    int idx;
    int* locopointer;

    Hwi_Handle myHwi10;
    Hwi_Params myHwi10Params;
    Error_Block eb;

    /*
     * use ROV->SysMin to view the characters in the circular buffer
     */
    //System_printf("enter main()\n");
    //System_flush();
    
    //Memory protection events enable.
    Exception_evtExpMaskEnable(10);
    Exception_evtExpMaskEnable(120);
    Exception_evtExpMaskEnable(122);
    Exception_evtExpMaskEnable(124);
    Exception_evtExpMaskEnable(126);
    while(!Exception_Module_startupDone());

    //Memory protection configuration.
    MemoryProtect_setPA((Ptr)0x0C0A0100, 0x400, (MemoryProtect_MPPA_LOCAL | MemoryProtect_MPPA_SR));
    MemoryProtect_setPA((Ptr)0x0C0A0500, 0x400, 0x00);
    while(!MemoryProtect_Module_startupDone());

    //Access try in protected zones.
    //doCoreAccessTest(0x0C0A0010,EAccessType_Write);
    locopointer = (int*)0x0c0a0025;
    //Escribe en sección con permisos de solo lectura.
    for(idx = 0; idx < 50; idx++)
    {
        locopointer[idx] = idx;
    }
    //Escribe en sección sin ningún permiso.
    locopointer = (int*)0x0c0a0485;
    for(idx = 0; idx < 50; idx++)
    {
        locopointer[idx] = idx;
    }

    Error_init(&eb);
    Hwi_Params_init(&myHwi10Params);
    myHwi10Params.arg = 0;
    myHwi10Params.enableInt = TRUE;

    myHwi10 = Hwi_create(10, myIsr10, &myHwi10Params, &eb);
    if (myHwi10 == NULL)
        System_abort("Hwi create failed");
    else
        System_printf("Hwi created succesfully.");
    Hwi_enable();

    BIOS_start();        /* enable interrupts and start SYS/BIOS */
}

In the *.cfg file I instantiated an Hwi, an Exception and a MemoryProtect modules, although I wold prefer to do everything in runtime.

In the config file I assigned the hook functions to the Exception module, as seen:

/** Crea un Exception handler estático.*/
Exception.enableExternalMPC = true;
Exception.enablePrint = true;
Exception.exceptionHook = "&excep_handler";
Exception.internalHook = "&excep_handler_intn";
Exception.internalHook = "&excep_handler_extn";

I don't need all of them. I just want a function to execute when a memory access error occurs, to know what kind of access was tried. In the Hwi handler I the C code I assingned another function to exec when a hardware interrupt occurs.

My question are:

1) The Events of the Exception_evtExpMaskEnable and the Hwi_create are the 128 ones of the System Event Mapping of the CorePac?

2) What memory protection hardware is magaged by the MemoryProtect? The registers configured are the MPAX of the Core? What about the MPAX of the MCSM?

3) The MemoryProtect module says it enables the Exceptions by default. Do I have to use the Exception_evtExpMaskEnable to active them by hand? I tryed to do it with the events 10, 120, 122, 124 y 126 (the ones related with the memory protection). Do I have to use the Event Combiner or something to map the interruptions?

4) What else is missing or what am I doing wrong? When I run the code in the simulator I expected an exception to happen when it attempted to write the memory. However, nothing happends until BIOS_start() goes to the IDLE cycle.

An other questions about CCS:

1) When I launch the Debug session, I don't find the option "Graph" in the Tools menu. How can I active it?