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.

CCS/TM4C1290NCZAD: how to set the Thread mode privilege level on TI-RTOS

Part Number: TM4C1290NCZAD
Other Parts Discussed in Thread: CC2564

Tool/software: Code Composer Studio

I have to create 2 threads (on TIRTOS). One should run in privilege mode and the other should run in unprivilege mode.

How can I to do this?

In ARM documentation I saw that the privilege/unprivilege information is stored in the CONTROL register (bit 0, nPRIV).

Which is the CONTROL register address?

How can I to write in this register? 

Thank you

  • Hello Luca,

    The CONTROL Register handles privilege mode vs unprivilege mode at a device level - you won't be able to tell it that only one RTOS Thread is in privilege mode.

    Also I don't really understand what you are trying to achieve here, can you explain further?

    For some background on what you are asking regarding the CONTROL register, Privilege levels offer additional protection for software. 

    In Unprivileged mode, software has:

    • Limited access to the Priority Mask register
    • No access to the system timer, NVIC, or system control block
    • Possibly restricted access to memory or peripherals (FPU, MPU, etc)

    In Privileged mode, software has:

    • use of all the instructions and has access to all resources

    For example, all ISRs operate in privileged mode.

    If that doesn't sound like what you are after and it's something specific only RTOS and not the device CONTROL register, then I can forward this onto the TI-RTOS team to comment on.

  • Hello Ralph,

    my application is composed by some threads. One of this thread mange the CAN while other threads uses the UART for the communication with the CC2564.

    When a generic thread need to write a CAN message, it writes this message in a buffer. The buffer is then processed by the thread that manages the CAN.

    What I have to do now is prevent all threads with the exception of the one that manages the CAN from accessing the CAN peripheral and some memory areas.

    For do this I have to use the MPU and I have to create one "Kernel" task and some "User" task.

    Reading the forum I understood that TIRTOS does not allow to create tasks / threads specifying the privileges (Is it right?), then I'm trying  to understand how i can to do that.

    thank you.

    Luca

  • TI-RTOS for TivaC does not support kernel/user space. You'll need to use different task priority levels and potentially other synchronization mechanisms (e.g. Semaphore, Gates, disabling/restoring interrupts, etc.).

    Todd

  • Hello at all,

    it is possible to manage directly the CONTROL register bypassing the TI-RTOS?

    Luca

  • Hello Luca,

    Yes that should be possible but it's unclear if that would help you with your application still.

    Luca Vanzolini said:
    What I have to do now is prevent all threads with the exception of the one that manages the CAN from accessing the CAN peripheral and some memory areas.

    You would have privilege mode on for every thread running on the device, there is no CONTROL register for specific peripherals. So are you suggesting that you would toggle the privilege mode while only in the CAN thread and use the MPU to block access for the other threads that way? That's about the only way I could see this working but it's not something I am familiar with in terms of how well that would in execution.

  • Hello Ralph,

    Yes, that was the idea.

    One other possibility can be reconfigure the "protected region" at every context switch (TI-RTOS should have a hook on the task switch, is it right?): if the new run task is the CAN manager task then the memory region must be configured as MPU_RGN_PERM_PRV_RW_USR_NO (next task can read and write). otherwise the memory region must be configured as MPU_RGN_PERM_PRV_RO_USR_NO (next task can only read).

    Do you you think it can works?

    Thank you.

    Best regards

    Luca

  • Hello Luca,

    On the surface it seems like it would work but it's not something we have tried so we can't say for sure. I think both ideas are worth exploring.

    The available hooks are:

    Hwi: Register, Create, Begin, End, and Delete.
    Swi: Register, Create, Ready, Begin, End, and Delete.
    Task: Register, Create, Ready, Switch, Exit, and Delete.

    Not sure how well these will work for what you want to do - I am not really experienced with the RTOS side of things.

    Couple notes to be aware of,

    1) There is no SYS/BIOS kernel support for dynamic MPU manipulation For TM4C devices, so you would need to use TivaWare API to achieve this. Which means you'd have to figure out how to leverage those hooks to then call TivaWare API's - again not an area I have experience with though maybe Todd can comment further on this.

    2) Review the MEM#18 device errata so you can aware of that.