Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > What does this cast do?

Reply
Thread Tools

What does this cast do?

 
 
robert
Guest
Posts: n/a
 
      07-17-2007
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

 
Reply With Quote
 
 
 
 
Chris Dollin
Guest
Posts: n/a
 
      07-17-2007
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/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is the result of valid dynamic cast always equal to the result ofcorrespondent static cast? Pavel C++ 7 09-18-2010 11:35 PM
error C2440: 'return' : cannot convert from 'const char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Abhijit Bhadra C++ 2 12-01-2004 04:43 PM
malloc - to cast or not to cast, that is the question... EvilRix C Programming 8 02-14-2004 12:08 PM
to cast or not to cast malloc ? MSG C Programming 38 02-10-2004 03:13 PM
does a cast become a null pointer ? MC C Programming 5 08-28-2003 02:28 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57