public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 01/14] dm: Initial import of design documents
Date: Wed, 08 Aug 2012 12:20:32 -0600	[thread overview]
Message-ID: <5022ADF0.4090101@wwwdotorg.org> (raw)
In-Reply-To: <1344426150-1229-1-git-send-email-marex@denx.de>

On 08/08/2012 05:42 AM, Marek Vasut wrote:
> From: Marek Vasut <marek.vasut@gmail.com>
> 
> This patch contains UDM-design.txt, which is document containing
> general description of the driver model. The remaining files contains
> descriptions of conversion process of particular subsystems.

> diff --git a/doc/driver-model/UDM-design.txt b/doc/driver-model/UDM-design.txt

> +II) Driver core initialization stages
> +-------------------------------------
> +
> +The drivers have to be initialized in two stages, since the U-Boot bootloader
> +runs in two stages itself. The first stage is the one which is executed before
> +the bootloader itself is relocated. The second stage then happens after
> +relocation.
> +
> +  1) First stage
> +  --------------
> +
> +  The first stage runs after the bootloader did very basic hardware init. This
> +  means the stack pointer was configured, caches disabled and that's about it.
> +  The problem with this part is the memory management isn't running at all. To
> +  make things even worse, at this point, the RAM is still likely uninitialized
> +  and therefore unavailable.
> +
> +  2) Second stage
> +  ---------------
> +
> +  At this stage, the bootloader has initialized RAM and is running from it's
> +  final location. Dynamic memory allocations are working at this point. Most of
> +  the driver initialization is executed here.

Given the above descriptions of the two stages, ...

> +III) The drivers
> +----------------
> +
> +  1) The structure of a driver
> +  ----------------------------
> +
> +  The driver will contain a structure located in a separate section, which
> +  will allow linker to create a list of compiled-in drivers at compile time.
> +  Let's call this list "driver_list".
> +
> +  struct driver __attribute__((section(driver_list))) {
> +    /* The name of the driver */
> +    char		name[STATIC_CONFIG_DRIVER_NAME_LENGTH];
> +
> +    /*
> +     * This function should connect this driver with cores it depends on and
> +     * with other drivers, likely bus drivers
> +     */
> +    int			(*bind)(struct instance *i);

... the comments here should probably say which stage each function will
be run at.

> +
> +    /* This function actually initializes the hardware. */
> +    int			(*probe)(struct instance *i);
> +
> +    /*
> +     * The function of the driver called when U-Boot finished relocation.
> +     * This is particularly important to eg. move pointers to DMA buffers
> +     * and such from the location before relocation to their final location.
> +     */
> +    int			(*reloc)(struct instance *i);

The need for this function implies that some other functions (both bind
and probe?) are to be called before relocation. Isn't the pre-relocation
environment rather strict, and hence this will require a bunch of
changes to driver code to initialize differently? Why not just
initialize everything after relocation; IIRC, that's how most things are
initialized now, isn't it?

Related, if you're intending to allow drivers to be loaded from e.g. the
filesystem later, that will happen after relocation. There will then be
a discrepancy between the environment where bind/probe get run for a
built-in driver vs. a dynamically loaded driver.

  parent reply	other threads:[~2012-08-08 18:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-08 11:42 [U-Boot] [PATCH 01/14] dm: Initial import of design documents Marek Vasut
2012-08-08 11:42 ` [U-Boot] [PATCH 02/14] dm: Add Driver cores design document Marek Vasut
2012-09-02 16:00   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 03/14] dm: Add GPIO API transition document Marek Vasut
2012-09-02 16:01   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 04/14] dm: Add MMC subsystem analysis Marek Vasut
2012-09-02 16:01   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 05/14] dm: Add networking " Marek Vasut
2012-09-02 16:01   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 06/14] dm: Add SPI API transition document Marek Vasut
2012-09-02 16:01   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 07/14] dm: Add block device document Marek Vasut
2012-09-02 16:02   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 08/14] dm: Add POWER API transition document Marek Vasut
2012-09-02 16:02   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 09/14] dm: Hwmon UDM subsystem analysis added Marek Vasut
2012-09-02 16:02   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 10/14] dm: Driver model analysis document for Watchdog subsystem has been added Marek Vasut
2012-09-02 16:02   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 11/14] dm: add PCI design document Marek Vasut
2012-09-02 16:02   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 12/14] dm: Add pcmcia " Marek Vasut
2012-09-02 16:02   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 13/14] dm: RTC subsystem analysis added Marek Vasut
2012-09-02 16:02   ` Wolfgang Denk
2012-08-08 11:42 ` [U-Boot] [PATCH 14/14] dm: Add twserial device document Marek Vasut
2012-09-02 16:03   ` Wolfgang Denk
2012-08-08 18:20 ` Stephen Warren [this message]
2012-08-08 18:37   ` [U-Boot] [PATCH 01/14] dm: Initial import of design documents Marek Vasut
2012-08-08 19:11     ` Stephen Warren
2012-08-08 19:19       ` Marek Vasut
2012-09-02 16:00 ` Wolfgang Denk
2012-09-02 16:31   ` Vikram Narayanan
2012-09-02 16:49     ` Marek Vasut
2012-09-02 20:29     ` 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=5022ADF0.4090101@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --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