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.

Question about the priviledge mode

Other Parts Discussed in Thread: HALCOGEN, TMS570LS1227

Hi All

I am doing selftest such as ecc PBIST. I see most registers can only be accessed in priviledge mode. I know that modes other than user mode have privileged access rights. I also find that the halcogen puts most selftest functions in the int00 before main.

My question is :

Once power on(entering the int00), what mode is CPU at?

When the mode has been switched (into user mode)? i didt see any explicit fucntion call? or the mode will be switched into user mode automatically after main()?

I put some self test functions in the main() such as fmcECCcheck  and checkFlashECC which has to write the priviledged registers. But no error occur, and the registers look like can be written in main().

Can someone clarify this to me?

Thanks Leo

  • HI Leo,

      In the startup, the _coreInitRegisters_() function is called in the very beginning to initialize CPU registers in various different modes (i.e. supervisor, fiq, irq, and etc and finally the system mode). So the CPU remains in system mode when it enters the main(). Therefore, you can still access all the privilege protected registers in main() as the CPU is still in system mode. 

  • Dear Charles
    So while executing in main, it is not in user mode, it still in priveledge mode? am I right?
    in what occasion it will enter user mode?
    Best regards
    Leo
  • Hi Leo,
    You remain in system mode until your application changes to user mode. Normally if you are in an OS environment your application will be running in user mode. Your user mode application needs to make a supervisor call to the OS so that the CPU will take the SWI exception at vector 0x8. I will suggest you to reference the ARM TRM for details on the entry/exit of the modes and exception handling.
  • Charles
    I am using tms570ls1227 and there is no OS. My quesion is very direct:
    After entering my main() funcion, which mode will it be in, user mode or others with priviledge?
    Leo
  • Hi Leo,
    Yes, you are in privilege (system mode) when you enter main() if you use the HalCoGen to generate the startup file.