From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 01/14] dm: Initial import of design documents
Date: Wed, 8 Aug 2012 21:19:38 +0200 [thread overview]
Message-ID: <201208082119.38757.marex@denx.de> (raw)
In-Reply-To: <5022B9C4.5080107@wwwdotorg.org>
Dear Stephen Warren,
> On 08/08/2012 12:37 PM, Marek Vasut wrote:
> > Dear Stephen Warren,
> >
> >> 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.
> >
> > The drivers must be agnostic to where they're executed
> >
> >>> +
> >>> + /* 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.
> >
> > They can be called after reloc too.
> >
> >> Isn't the pre-relocation
> >> environment rather strict
> >
> > Yes
>
> Maybe I'm misinterpreting the exact definition of the stages, but isn't
> the pre-relocation stage restricted by e.g. a lack of ability to access
> global data, so you have to store everything in the "gd" global data
> pointer
Correct! That's why the early allocator must only use global-data-alike space.
> or something like that? If that's not the case, perhaps
> explicitly spelling out which restrictions do/don't exist in the
> definition of the stages above would be helpful to prevent anyone else
> reading them the wrong way.
That's the case actually ... just making the information more accurate might
help.
> >> and hence this will require a bunch of
> >> changes to driver code to initialize differently?
> >
> > No
>
> If what I said is above, that's certainly not true of most driver
> initialization code today, so migrating to an environment where global
> data wasn't allowed would require changes, wouldn't it?
Global data should eventually dissolve completely, yes. Drivers will definitelly
need adjustments.
> >> Why not just
> >> initialize everything after relocation; IIRC, that's how most things are
> >> initialized now, isn't it?
> >
> > You want eg. i2c bus running before relocation to init your DRAM
> > controller. Or serial console for debug output.
> >
> >> Related, if you're intending to allow drivers to be loaded from e.g. the
> >> filesystem later
> >
> > Not now, but we keep that in mind. Btw. (!) we're writing a bootloader
> > here, not an operating system.
>
> Sure. I was surprised when you wrote about that feature, but my comment
> was triggered by your patch series explicitly mentioning loading drivers
> at run-time.
Yes, we thought about it at the early stages, but postponed it later on to start
small.
> >> 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.
> >
> > Will there?
>
> Yes. If bind/probe are called early, then they can't use certain
> features like dynamic memory allocation.
Yes they can, see the early malloc patches.
> If they're called late, then
> those features are available. Now perhaps you can decide to disallow
> their use anyway so that the code doesn't care, but that would require
> careful enforcement through either detailed code review, or perhaps
> forcing affected functions to be stored in a particular linker section
> and checking for symbol references outside that section (e.g. like
> __init in the Linux kernel).
No, we want to be able to use dynamic allocation (we even need it for the driver
model to work at all).
Best regards,
Marek Vasut
next prev parent reply other threads:[~2012-08-08 19:19 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 ` [U-Boot] [PATCH 01/14] dm: Initial import of design documents Stephen Warren
2012-08-08 18:37 ` Marek Vasut
2012-08-08 19:11 ` Stephen Warren
2012-08-08 19:19 ` Marek Vasut [this message]
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=201208082119.38757.marex@denx.de \
--to=marex@denx.de \
--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