public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] Why are some global vars part of the image, and some not?
@ 2006-11-03 21:58 Timur Tabi
  2006-11-03 22:19 ` Timur Tabi
  2006-11-03 23:44 ` Wolfgang Denk
  0 siblings, 2 replies; 26+ messages in thread
From: Timur Tabi @ 2006-11-03 21:58 UTC (permalink / raw)
  To: u-boot

I have the following code in one of my files:

#ifdef CFG_SPD_BUS_NUM
static volatile unsigned int i2c_bus_num = CFG_SPD_BUS_NUM;
#else
static volatile unsigned int i2c_bus_num = 0;
#endif

static volatile struct fsl_i2c *i2c_dev[2] = {
	(struct fsl_i2c *) (CFG_IMMR + CFG_I2C_OFFSET),
#ifdef CFG_I2C2_OFFSET
	(struct fsl_i2c *) (CFG_IMMR + CFG_I2C2_OFFSET)
#endif
};

As you can see, I defined two static volatile global vars: i2c_bus_num and 
i2c_dev.

My U-Boot image is 0x294E0 bytes in size, and it's located at address 
0xFE000000.  When I run U-Boot, the address of i2c_bus_num is 0xfe02a114, and 
the address of i2c_dev[] is 0xfe028124.

In other words, i2c_dev[] is part of the actual U-Boot image, but i2c_bus_num, 
which is defined right next to it, isn't.  This means that i2c_dev[] is 
properly initialized, but i2c_bus_num is set to 0xFFFFFFFF (the value that 
erased flash has).

How is this possible?  How can two adjacent global variables be located is 
completely different memory segments?

-- 
Timur Tabi
Linux Kernel Developer @ Freescale

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2006-11-06 21:15 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-03 21:58 [U-Boot-Users] Why are some global vars part of the image, and some not? Timur Tabi
2006-11-03 22:19 ` Timur Tabi
2006-11-03 23:47   ` Wolfgang Denk
2006-11-04  0:09     ` Timur Tabi
2006-11-04  0:33       ` Wolfgang Denk
2006-11-03 23:44 ` Wolfgang Denk
2006-11-04  0:07   ` Timur Tabi
2006-11-04  0:31     ` Wolfgang Denk
2006-11-04  1:38       ` Timur Tabi
2006-11-04  2:04         ` Wolfgang Denk
2006-11-06 17:43           ` Scott Wood
2006-11-06 18:03             ` Jerry Van Baren
2006-11-06 18:08               ` Timur Tabi
2006-11-06 18:48                 ` Jerry Van Baren
2006-11-06 18:56                   ` Scott Wood
2006-11-06 19:06                     ` Jerry Van Baren
2006-11-06 19:46                       ` Scott Wood
2006-11-06 19:54                         ` Timur Tabi
2006-11-06 20:13                         ` Jerry Van Baren
2006-11-06 20:21                           ` Timur Tabi
2006-11-06 20:44                             ` Wolfgang Denk
2006-11-06 20:35                         ` Tolunay Orkun
2006-11-06 20:29                 ` Wolfgang Denk
2006-11-06 20:26             ` Wolfgang Denk
2006-11-06 20:48               ` Scott Wood
2006-11-06 21:15                 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox