public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Timur Tabi <timur@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Why are some global vars part of the image, and some not?
Date: Fri, 03 Nov 2006 18:07:07 -0600	[thread overview]
Message-ID: <454BD9AB.1000303@freescale.com> (raw)
In-Reply-To: <20061103234436.14D2F353C4E@atlas.denx.de>

Wolfgang Denk wrote:

> I'm not exactly sure what you  mean  by  the  "global  vars"  in  the
> Subject  line.  The declaration you show here says "static". This may
> or may not be what you mean.

To me, a variable defined outside of a function is a global variable, 
regardless as to whether it's "static" or not.  Technically, these variables 
are static globals, but I don't think removing the "static" would change what 
I'm seeing.  Would it?

>> As you can see, I defined two static volatile global vars: i2c_bus_num and 
>> i2c_dev.
> 
> Yes, and one of these is initialized with non-zero values (so it will
> go to the data segment), while the other is not (so it will go to
> bss).

I realized that about two minutes after I posted my email, which is why I 
posted a follow-up.

> THis is perfectly OK. Just check the variables after U-Boot has  been
> relocated to RAM and BSS has been initialized.

I can't.  This code is used to initialize the I2C bus, which is used to 
initialize SPD on DDR, which is obviously done before U-Boot is relocated.

These variables contain the I2C bus number.  On some boards, SPD is on bus 0, 
on some they're on bus 1.  So the compile-time initializer needs to be the 
right bus.

(An alternative would be to change i2c_read() and i2c_write() to take a bus 
number as a parameter, but that would change hundreds of files).

-- 
Timur Tabi
Linux Kernel Developer @ Freescale

  reply	other threads:[~2006-11-04  0:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=454BD9AB.1000303@freescale.com \
    --to=timur@freescale.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox