What does this cast do?

Discussion in 'C Programming' started by robert, Jul 17, 2007.

  1. robert

    robert Guest

    Hi all, allow the code to explain:

    *((volatile unsigned char *) 0xe00e0f3c) = 0x00800000;

    If curious, this code is in local_bus_init() , in the u-boot
    bootloader for linux for a ppc proccessor.

    Robert
     
    robert, Jul 17, 2007
    #1
    1. Advertising

  2. robert

    Chris Dollin Guest

    robert wrote:

    > Hi all, allow the code to explain:
    >
    > *((volatile unsigned char *) 0xe00e0f3c) = 0x00800000;
    >
    > If curious, this code is in local_bus_init() , in the u-boot
    > bootloader for linux for a ppc proccessor.


    This is a non-Standard piece of code using implementation-defined
    cast magic to convert an integer (fx:OT which /probably/ expresses an
    address in some piece of Linux ppc kernel address space) to a
    pointer-to-volatile-unsigned-char, and then stores an integer
    value almost certainly too big to be represented by an unsigned
    char -- I'd expect it to be truncated to zero -- into that location.

    It's magic. For what it really does, you'd have to ask in a more
    specific newsgroup. Or perhaps in a PPC manual.

    --
    Far-Fetched Hedgehog
    "A facility for quotation covers the absence of original thought." /Gaudy Night/
     
    Chris Dollin, Jul 17, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MC

    does a cast become a null pointer ?

    MC, Aug 27, 2003, in forum: C Programming
    Replies:
    5
    Views:
    338
    Eric Sosman
    Aug 28, 2003
  2. Daniel Haude
    Replies:
    1
    Views:
    382
    Les Cargill
    Feb 1, 2004
  3. MSG

    to cast or not to cast malloc ?

    MSG, Feb 6, 2004, in forum: C Programming
    Replies:
    38
    Views:
    1,105
    Dan Pop
    Feb 10, 2004
  4. EvilRix
    Replies:
    8
    Views:
    669
    Martin Dickopp
    Feb 14, 2004
  5. Pavel
    Replies:
    7
    Views:
    556
    Pavel
    Sep 19, 2010
Loading...

Share This Page