Where are the Cortex-specific functions like __wfi () defined in Keil?

I am working on production code for a Cortex-M0 controller using uVision Keil 4.71.0.0 IDE. Our code must respect MISRA rules and is regularly reviewed by QA-C.

My problem is that some controller-specific functions like __wfi()

, __current_sp()

etc. don't seem to be defined anywhere and QA-C is complaining about them:

340:                __wfi();
                       ^
Msg(5:3335) No function declaration.
Implicit declaration inserted: 'extern int __wfi();'.
CC Coding Rule 6 <next>

      

Right-clicking on a function name in Keil and selecting Go to Definition confirms that the function is not defined:

Source Browser: '__wfi' - undefined Definition/Reference!

      

Does Keil provide an official header file for prototypes of such functions? Hardcoding such prototypes in our project code or throwing QA-C exceptions will require a formal review process, which I would like to avoid.

+3


source to share


3 answers


I don't think these are normal functions, but the non-standard inline functions that end up in the generated binary are replaced with assembler code. Watch this.

There are 3 MISRA rules here and they do not necessarily agree with each other:

  • All code must conform to ISO C.
  • All functions must have prototypes.
  • All use of assembly language must be encapsulated and documented.


What I would do is move all these "function calls" into a separate file and document so that this file contains all the inline assembly calls in your program. You probably need such a file in order to pass other MISRA rules regarding inline assembly. Indicate that these functions are used to encapsulate assembler. Then exclude it from static code analysis, unless the static analyzer supports this assembler and / or "built-in ARM" functions.

If you do it this way, I think you will meet 100% MISRA without having to increase the deflection. Just point out that ARM embedded is your way of encapsulating an embedded assembly.

+2


source


They are called internal compilers and I'm not sure if they need to be declared. They are basically extensions of the compiler-supplied language.



+2


source


As written bevor it is from the compiler. I don't think you have them at source. Maybee you will find something written in the Keil or ARM Compiler Manual that helps you (I don't have KEIl already to see for myself).

It might be possible to get a definition for this function with a special Compiler command (IAR Compiler has something like this).

If this all doesn't work, you can make an exception in QA-C (don't know it) to ignore this function because it's from the compiler, or specify a dummy function for QA-C.

Founbd this

http://www.keil.com/support/man/docs/armccref/armccref_CJADIFCI.htm

0


source