This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

uCOSII to 8051 warning message.

I am using uCOSII V2.52
I am using the Keil C compiler V7.02
Large memory model.

Everything compiles but, I get one warning that worries me.

Not sure if I can post the uCOSII code or not, but if you have uCOSII V2.52 check out the file and line number below.

File Name: OS_TASK.C
Line Number: 174
Keil Warning #196 mspace probably invalid.

The keil warning #196 says (The conversion of a constant to a pointer constant yields and invalid memory space).

Maybe somebody has ran into this while compiling uCOSII with Keil 7.02 compiler. Any help would be apreciated. Thanks :)

Parents
  • What data space does OSTCBPrioTable live in? Xdata? data?

    The cast in (OS_TCB *)1 converts the integer "1" to a generic pointer. Since the 8051 has so many different address spaces, "generic" pointers need an extra byte of tag information to tell them where they point. Since the integer constant "1" doesn't have an address space tag, that generic pointer is going to have to make some assumption about to which address space (mspace) it should point. And that assumption might well be wrong.

    You can make the warning go away by explicitly identifying the memory space in the cast: (OS_TCB xdata *)1. The compiler is then sure of what the mspace byte ought to be, since it will trust what you told it. Of course, that assumes that you know where the pointer should point.

    It seems unlikely that you just happen to have a task control block that lives at address 1 in any address space. So, casting the value to a pointer doesn't seem very useful. I'd assume, then, that the OS treats a OS_TCB* value of 1 as a special flag to mean something else (idle? uninitialized? who knows?). In that case, I'd guess that the mspace warning might be irrelevant, since a pointer with that value would never actually get dereferenced.

Reply
  • What data space does OSTCBPrioTable live in? Xdata? data?

    The cast in (OS_TCB *)1 converts the integer "1" to a generic pointer. Since the 8051 has so many different address spaces, "generic" pointers need an extra byte of tag information to tell them where they point. Since the integer constant "1" doesn't have an address space tag, that generic pointer is going to have to make some assumption about to which address space (mspace) it should point. And that assumption might well be wrong.

    You can make the warning go away by explicitly identifying the memory space in the cast: (OS_TCB xdata *)1. The compiler is then sure of what the mspace byte ought to be, since it will trust what you told it. Of course, that assumes that you know where the pointer should point.

    It seems unlikely that you just happen to have a task control block that lives at address 1 in any address space. So, casting the value to a pointer doesn't seem very useful. I'd assume, then, that the OS treats a OS_TCB* value of 1 as a special flag to mean something else (idle? uninitialized? who knows?). In that case, I'd guess that the mspace warning might be irrelevant, since a pointer with that value would never actually get dereferenced.

Children
  • "You can make the warning go away by explicitly identifying the memory space in the cast"

    C51 provides a predefined symbol which identifies the current memory model and, thus, the default mspace - see the manual.

    This might help you in determining the mspace for the above-mentioned cast?