Where are they?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Where are they?

Jump to solution
2,629 Views
fish_yu
Contributor III

hello,everyone

Firstly, I will say that Thank really EAI's help.
Sencondly, i want to know where are they. where are the defination of variable. and i am confused with a function or a micro. Although The function are not compiled by cw compiler, The MQX RTOS use it to initialize kernal. I don't know how to work and compile.
In mqx_prv.h, on line 775. there is a macro that is #if MQX_USE_INLINE_MACROS. According to C language spec, Between #if MQX_USE_INLINE_MACROS and #endif that is on line 785, the compiler can't compiled.
However, the macro _QUEUE_INIT(queue,max)  usually is called by many funtions. For example, in the file named mqx.c, there is a kernal function named _mqx_init_kernel_data_internal() on line 158. In the function, You will found a macro named PSP_MEM_STOREBLOCK_ALIGNMENT , it is not define in all files, But I don't know why designed by MQX RTOS.  Is it initialize a zero for SP_MEM_STOREBLOCK_ALIGNMENT ?
My second problem is a function or a macro named _QUEUE_INIT(queue,max) in mqx_prv.h
on line 776.

Because of the defination of the macro between another macro, the macro named MQX_USE_INLINE_MACROS decide the _QUEUE_INIT(queue,max)  to compile. But In the mqx_prv.h, MQX_USE_INLINE_MACROS is zero that is defined  in file named small_ram_config.h on line 84.

According this case, The compiler can not compiled. But in fact, the psp project and bsp project may compiled successfully.  At the same time, The macro named _QUEUE_INIT(queue,max) usually called by many functions in many file.    Could you help me to explain the case?

Finally, Thank you for reading.
Fish_Yu

Message Edited by fish_yu on 2009-06-22 10:01 PM
0 Kudos
1 Solution
930 Views
EAI
Contributor IV

Fish_yu, 

eGuy (Jeff) provided a good explanation. Simply re-read the original code:

 

In qu_init.c, line 40:

#define MQX_FORCE_USE_INLINE_MACROS 1

 

In mqx_cnfg.h

#ifdef MQX_FORCE_USE_INLINE_MACROS
#undef  MQX_USE_INLINE_MACROS
#define MQX_USE_INLINE_MACROS  MQX_FORCE_USE_INLINE_MACROS
#endif

So regardless of how you set MQX_USE_INLINE_MACROS, qu_init.c will use inline macros (which is the intent).

View solution in original post

0 Kudos
6 Replies
930 Views
fish_yu
Contributor III

Dear eguy

In your message, you wirted No matter MQX_USE_INLINE_MACROS=0 or 1, _QUEUE_INIT is always defined and compiled. if MQX_USE_INLINE_MACROS=1 Line 776 is compiled (mqx_prv.h), otherwise Line 784 is compiled.According your writed, The macro between #if MQX_USE_INLINE_MACROS and #endif, the code compile only #define _QUEUE_INIT(queue, max) _queue_init((QUEUE_STRUCT_PTR)(queue), max).But in _queue_init((QUEUE_STRUCT_PTR)(queue), there is a same macro _QUEUE_INIT(queue, max) that called in qu_init.c in a function named _queue_init().Can you understand what i writed? They are called by itself. Please note that the compiler only compile  code after #else.Could you explain how to compile?At second, About variable PSP_MEM_STOREBLOCK_ALIGNMENT, You writed that If PSP_MEM_STOREBLOCK_ALIGNMENT is not defined,PSP_CFG_MEM_STOREBLOCK_ALIGNMENT  is default to 0, otherwise it is set to whatever value PSP_CFG_MEM_STOREBLOCK_ALIGNMENT is defined.According your mean, The variables should initialize zero?How to initialize? They are very different.

Message Edited by fish_yu on 2009-06-23 07:43 PM
0 Kudos
930 Views
eGuy
Contributor IV

Kernel data is initialized to ZERO in mqx.c ( V3.1 line128)

   /* Initialize the kernel data to zero. */
   _mem_zero((pointer)kernel_data, (_mem_size)sizeof(KERNEL_DATA_STRUCT));

 

This causes

   kernel_data->PSP_CFG_MEM_STOREBLOCK_ALIGNMENT initial value is ZERO

Message Edited by eGuy on 2009-06-23 04:26 PM
0 Kudos
930 Views
fish_yu
Contributor III
Thank you for your help, Thanl you very much.
0 Kudos
931 Views
EAI
Contributor IV

Fish_yu, 

eGuy (Jeff) provided a good explanation. Simply re-read the original code:

 

In qu_init.c, line 40:

#define MQX_FORCE_USE_INLINE_MACROS 1

 

In mqx_cnfg.h

#ifdef MQX_FORCE_USE_INLINE_MACROS
#undef  MQX_USE_INLINE_MACROS
#define MQX_USE_INLINE_MACROS  MQX_FORCE_USE_INLINE_MACROS
#endif

So regardless of how you set MQX_USE_INLINE_MACROS, qu_init.c will use inline macros (which is the intent).

0 Kudos
930 Views
fish_yu
Contributor III

Thank really you for yout help.

 

I finally understand that code how to work.

 

But the code Why design in this way? It is very complicated.Why not design a simple code for the RTOS ?

0 Kudos
930 Views
eGuy
Contributor IV

I didn't see any problems here.

 

PSP_CFG_MEM_STOREBLOCK_ALIGNMENT is the number of reserved fields for PSP pads the STOREBLOCK_STRUCT (MQX V3.1 mqx_prv.h line1286 ). If PSP_MEM_STOREBLOCK_ALIGNMENT is not defined, PSP_CFG_MEM_STOREBLOCK_ALIGNMENT  is default to 0, otherwise it is set to whatever value PSP_CFG_MEM_STOREBLOCK_ALIGNMENT is defined. I think it is left there in case in the future other processor need to align cache line (MQX3.1 mcf5225.c line 52).

 

No matter MQX_USE_INLINE_MACROS=0 or 1, _QUEUE_INIT is always defined and compiled. if MQX_USE_INLINE_MACROS=1 Line 776 is compiled (mqx_prv.h), otherwise Line 784 is compiled.

( Please notice that there is"#else" between the #if MQX_USE_INLINE_MACROS  and #endif )

 

Hope this helps.

 

 

Jeff

0 Kudos