All of lore.kernel.org
 help / color / mirror / Atom feed
* CELF Project Proposal - Device tree support for QEMU system emulation.
@ 2009-12-17  4:46 ` Rob Landley
  0 siblings, 0 replies; 11+ messages in thread
From: Rob Landley @ 2009-12-17  4:46 UTC (permalink / raw)
  To: CE Linux Developers List; +Cc: devicetree-discuss, qemu-devel

For background of CELF project proposals, see:

  http://elinux.org/CELF_Open_Project_Proposal_2010

Summary:

Integrate a flattened device tree parser into the emulator QEMU, so QEMU can 
create board emulations on the fly (at runtime) from the same data files the 
Linux kernel uses to attach drivers to hardware.

Proposer:

Rob Landley

Description:

Currently, the QEMU is emulating system boards via hardwired .c files, which 
explicitly set up the resources for each emulation in a separate C function.  
In theory, QEMU could parse the same device tree data format the Linux kernel 
uses to set up its hardware resources,  and then pass hardware resources along 
to kernels it invokes through its built-in bootloader (I.E. with the -kernel 
option).  This could allow new boards to be added to qemu simply by supplying 
device tree files at runtime (assuming emulations for the appropriate 
peripherals had already been implemented in QEMU).

The Device Tree format is a reasonably generic data file describing hardware 
layout.  It is documented in the linux kernel source at:

  Documentation/powerpc/booting-without-of.txt

It started as the data structure Open Firmware used to describe supported 
hardware to operating systems, and was picked up by bootloaders such as u-
boot.  It allows the Linux kernel to parse a generic data structure at boot 
time to configure itself for the current hardware layout, instead of hardwiring 
board support in individual .c files.

Device trees are created using an ascii format to describe a board layout, 
which is converted into a flattened binary representation by dtc (the "device 
tree compiler", included in current linux kernel sources in scripts/dtc).  A 
bootloader supporting device trees loads the flattened device tree into memory 
as a binary blob, and passes the linux kernel a pointer to this blob in a 
register.  The kernel then uses a built-in device tree parser to understand 
the board's hardware layout and initialize itself.  (Depending on kernel 
.config, this information may also be queried from userspace via a /proc 
interface.)

At the device tree BOF at OLS in 2008, a number of developers expressed 
interest in extending device tree support to other architectures (such as arm, 
mips, and sh4).  As a result, device tree development was moved off of the 
PowerPC mailing list to its own list, for the purpose of genericizing it to 
more architectures:

  https://lists.ozlabs.org/listinfo/devicetree-discuss

The Linux MAINTAINERS entry for device tree support is:

  OPEN FIRMWARE AND FLATTENED DEVICE TREE
  M:      Grant Likely <grant.likely@secretlab.ca>
  L:      devicetree-discuss@lists.ozlabs.org
  W:      http://fdt.secretlab.ca
  S:      Maintained
  F:      drivers/of
  F:      include/linux/of*.h
  K:      of_get_property

In theory, at some future date the kernel will no longer need hardwired .c 
files describing the layout of boards for any of these architectures.  Instead 
it can have a device tree for each board, which can be statically linked into 
the kernel binary if necessary.

If the kenrnel doesn't need board support hardwared in .c files, there's no 
reason QEMU needs it either.

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds

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

* [Qemu-devel] CELF Project Proposal - Device tree support for QEMU system emulation.
@ 2009-12-17  4:46 ` Rob Landley
  0 siblings, 0 replies; 11+ messages in thread
From: Rob Landley @ 2009-12-17  4:46 UTC (permalink / raw)
  To: CE Linux Developers List; +Cc: devicetree-discuss, qemu-devel

For background of CELF project proposals, see:

  http://elinux.org/CELF_Open_Project_Proposal_2010

Summary:

Integrate a flattened device tree parser into the emulator QEMU, so QEMU can 
create board emulations on the fly (at runtime) from the same data files the 
Linux kernel uses to attach drivers to hardware.

Proposer:

Rob Landley

Description:

Currently, the QEMU is emulating system boards via hardwired .c files, which 
explicitly set up the resources for each emulation in a separate C function.  
In theory, QEMU could parse the same device tree data format the Linux kernel 
uses to set up its hardware resources,  and then pass hardware resources along 
to kernels it invokes through its built-in bootloader (I.E. with the -kernel 
option).  This could allow new boards to be added to qemu simply by supplying 
device tree files at runtime (assuming emulations for the appropriate 
peripherals had already been implemented in QEMU).

The Device Tree format is a reasonably generic data file describing hardware 
layout.  It is documented in the linux kernel source at:

  Documentation/powerpc/booting-without-of.txt

It started as the data structure Open Firmware used to describe supported 
hardware to operating systems, and was picked up by bootloaders such as u-
boot.  It allows the Linux kernel to parse a generic data structure at boot 
time to configure itself for the current hardware layout, instead of hardwiring 
board support in individual .c files.

Device trees are created using an ascii format to describe a board layout, 
which is converted into a flattened binary representation by dtc (the "device 
tree compiler", included in current linux kernel sources in scripts/dtc).  A 
bootloader supporting device trees loads the flattened device tree into memory 
as a binary blob, and passes the linux kernel a pointer to this blob in a 
register.  The kernel then uses a built-in device tree parser to understand 
the board's hardware layout and initialize itself.  (Depending on kernel 
.config, this information may also be queried from userspace via a /proc 
interface.)

At the device tree BOF at OLS in 2008, a number of developers expressed 
interest in extending device tree support to other architectures (such as arm, 
mips, and sh4).  As a result, device tree development was moved off of the 
PowerPC mailing list to its own list, for the purpose of genericizing it to 
more architectures:

  https://lists.ozlabs.org/listinfo/devicetree-discuss

The Linux MAINTAINERS entry for device tree support is:

  OPEN FIRMWARE AND FLATTENED DEVICE TREE
  M:      Grant Likely <grant.likely@secretlab.ca>
  L:      devicetree-discuss@lists.ozlabs.org
  W:      http://fdt.secretlab.ca
  S:      Maintained
  F:      drivers/of
  F:      include/linux/of*.h
  K:      of_get_property

In theory, at some future date the kernel will no longer need hardwired .c 
files describing the layout of boards for any of these architectures.  Instead 
it can have a device tree for each board, which can be statically linked into 
the kernel binary if necessary.

If the kenrnel doesn't need board support hardwared in .c files, there's no 
reason QEMU needs it either.

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds

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

* Re: [Qemu-devel] CELF Project Proposal - Device tree support for QEMU system emulation.
  2009-12-17  4:46 ` [Qemu-devel] " Rob Landley
@ 2009-12-17 20:29     ` Anthony Liguori
  -1 siblings, 0 replies; 11+ messages in thread
From: Anthony Liguori @ 2009-12-17 20:29 UTC (permalink / raw)
  To: Rob Landley
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	qemu-devel-qX2TKyscuCcdnm+yROfE0A, CE Linux Developers List,
	Paul Brook

Rob Landley wrote:
> For background of CELF project proposals, see:
>
>   http://elinux.org/CELF_Open_Project_Proposal_2010
>
> Summary:
>
> Integrate a flattened device tree parser into the emulator QEMU, so QEMU can 
> create board emulations on the fly (at runtime) from the same data files the 
> Linux kernel uses to attach drivers to hardware.
>   

See

http://thread.gmane.org/gmane.comp.emulators.qemu/44869

I'm not sure why Paul never pushed it but I think he was able to create 
the syborg board purely from a device tree.

Regards,

Anthony Liguori

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

* Re: [Qemu-devel] CELF Project Proposal - Device tree support for QEMU system emulation.
@ 2009-12-17 20:29     ` Anthony Liguori
  0 siblings, 0 replies; 11+ messages in thread
From: Anthony Liguori @ 2009-12-17 20:29 UTC (permalink / raw)
  To: Rob Landley
  Cc: devicetree-discuss, qemu-devel, CE Linux Developers List,
	Paul Brook

Rob Landley wrote:
> For background of CELF project proposals, see:
>
>   http://elinux.org/CELF_Open_Project_Proposal_2010
>
> Summary:
>
> Integrate a flattened device tree parser into the emulator QEMU, so QEMU can 
> create board emulations on the fly (at runtime) from the same data files the 
> Linux kernel uses to attach drivers to hardware.
>   

See

http://thread.gmane.org/gmane.comp.emulators.qemu/44869

I'm not sure why Paul never pushed it but I think he was able to create 
the syborg board purely from a device tree.

Regards,

Anthony Liguori

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

* Re: [Celinux-dev] CELF Project Proposal - Device tree support for QEMU system emulation.
  2009-12-17  4:46 ` [Qemu-devel] " Rob Landley
@ 2009-12-17 23:14   ` Tim Bird
  -1 siblings, 0 replies; 11+ messages in thread
From: Tim Bird @ 2009-12-17 23:14 UTC (permalink / raw)
  To: Rob Landley
  Cc: devicetree-discuss@lists.ozlabs.org, qemu-devel@nongnu.org,
	CE Linux Developers List

Rob Landley wrote:
> For background of CELF project proposals, see:
> 
>   http://elinux.org/CELF_Open_Project_Proposal_2010
> 
> Summary:
> 
> Integrate a flattened device tree parser into the emulator QEMU, so QEMU can 
> create board emulations on the fly (at runtime) from the same data files the 
> Linux kernel uses to attach drivers to hardware.

I've created a page for this proposal at:
http://elinux.org/CELF_Project_Proposal/Add_Device_Tree_emulation_support_to_QEMU

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Corporation of America
=============================

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

* [Qemu-devel] Re: [Celinux-dev] CELF Project Proposal - Device tree support for QEMU system emulation.
@ 2009-12-17 23:14   ` Tim Bird
  0 siblings, 0 replies; 11+ messages in thread
From: Tim Bird @ 2009-12-17 23:14 UTC (permalink / raw)
  To: Rob Landley
  Cc: devicetree-discuss@lists.ozlabs.org, qemu-devel@nongnu.org,
	CE Linux Developers List

Rob Landley wrote:
> For background of CELF project proposals, see:
> 
>   http://elinux.org/CELF_Open_Project_Proposal_2010
> 
> Summary:
> 
> Integrate a flattened device tree parser into the emulator QEMU, so QEMU can 
> create board emulations on the fly (at runtime) from the same data files the 
> Linux kernel uses to attach drivers to hardware.

I've created a page for this proposal at:
http://elinux.org/CELF_Project_Proposal/Add_Device_Tree_emulation_support_to_QEMU

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Corporation of America
=============================

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

* Re: [Qemu-devel] CELF Project Proposal - Device tree support for QEMU system emulation.
  2009-12-17  4:46 ` [Qemu-devel] " Rob Landley
@ 2009-12-19 10:54     ` Blue Swirl
  -1 siblings, 0 replies; 11+ messages in thread
From: Blue Swirl @ 2009-12-19 10:54 UTC (permalink / raw)
  To: Rob Landley
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	qemu-devel-qX2TKyscuCcdnm+yROfE0A, CE Linux Developers List

On Thu, Dec 17, 2009 at 4:46 AM, Rob Landley <rob@landley.net> wrote:
> For background of CELF project proposals, see:
>
>  http://elinux.org/CELF_Open_Project_Proposal_2010
>
> Summary:
>
> Integrate a flattened device tree parser into the emulator QEMU, so QEMU can
> create board emulations on the fly (at runtime) from the same data files the
> Linux kernel uses to attach drivers to hardware.
>
> Proposer:
>
> Rob Landley
>
> Description:
>
> Currently, the QEMU is emulating system boards via hardwired .c files, which
> explicitly set up the resources for each emulation in a separate C function.
> In theory, QEMU could parse the same device tree data format the Linux kernel
> uses to set up its hardware resources,  and then pass hardware resources along
> to kernels it invokes through its built-in bootloader (I.E. with the -kernel
> option).  This could allow new boards to be added to qemu simply by supplying
> device tree files at runtime (assuming emulations for the appropriate
> peripherals had already been implemented in QEMU).

In addition to -kernel case, the device tree should be passed to
OpenBIOS, which would generate OF tree from DT. This would be useful
for OSes other than Linux.

Another interesting case is sun4v hypervisor, which uses a similar
device tree. Some DT transformation would be required in QEMU.
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [Qemu-devel] CELF Project Proposal - Device tree support for QEMU system emulation.
@ 2009-12-19 10:54     ` Blue Swirl
  0 siblings, 0 replies; 11+ messages in thread
From: Blue Swirl @ 2009-12-19 10:54 UTC (permalink / raw)
  To: Rob Landley; +Cc: devicetree-discuss, qemu-devel, CE Linux Developers List

On Thu, Dec 17, 2009 at 4:46 AM, Rob Landley <rob@landley.net> wrote:
> For background of CELF project proposals, see:
>
>  http://elinux.org/CELF_Open_Project_Proposal_2010
>
> Summary:
>
> Integrate a flattened device tree parser into the emulator QEMU, so QEMU can
> create board emulations on the fly (at runtime) from the same data files the
> Linux kernel uses to attach drivers to hardware.
>
> Proposer:
>
> Rob Landley
>
> Description:
>
> Currently, the QEMU is emulating system boards via hardwired .c files, which
> explicitly set up the resources for each emulation in a separate C function.
> In theory, QEMU could parse the same device tree data format the Linux kernel
> uses to set up its hardware resources,  and then pass hardware resources along
> to kernels it invokes through its built-in bootloader (I.E. with the -kernel
> option).  This could allow new boards to be added to qemu simply by supplying
> device tree files at runtime (assuming emulations for the appropriate
> peripherals had already been implemented in QEMU).

In addition to -kernel case, the device tree should be passed to
OpenBIOS, which would generate OF tree from DT. This would be useful
for OSes other than Linux.

Another interesting case is sun4v hypervisor, which uses a similar
device tree. Some DT transformation would be required in QEMU.

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

* Re: [Qemu-devel] CELF Project Proposal - Device tree support for QEMU system emulation.
  2009-12-17 20:29     ` Anthony Liguori
@ 2009-12-22 12:45         ` Paul Brook
  -1 siblings, 0 replies; 11+ messages in thread
From: Paul Brook @ 2009-12-22 12:45 UTC (permalink / raw)
  To: qemu-devel-qX2TKyscuCcdnm+yROfE0A
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Anthony Liguori,
	CE Linux Developers List

> http://thread.gmane.org/gmane.comp.emulators.qemu/44869
> 
> I'm not sure why Paul never pushed it but I think he was able to create
> the syborg board purely from a device tree.

The patches referenced above include purely device-tree based Syborg and 
Stellaris boards.

It works fairly nicely for some embedded boards, but gets fairly hairy when 
you start considering more complex topologies/machines. I particular the PCI 
OF/FDT bindings don't really fit what we need for qemu. Obviously full qdev 
conversion is a prerequisite for device tree based configuration, and at that 
time qdev was still in its infancy.

Part of the reason for posting that patch was to demonstrate the abstraction 
layers required for the internal device model. Previous patches tended to be 
based on the pre-existing PC commandline options, which IMO is a mistake. 
Likewise if (like my implementation) you focus on embedded machines you risk 
serious problems trying to extend to server class machines.

Paul

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

* Re: [Qemu-devel] CELF Project Proposal - Device tree support for QEMU system emulation.
@ 2009-12-22 12:45         ` Paul Brook
  0 siblings, 0 replies; 11+ messages in thread
From: Paul Brook @ 2009-12-22 12:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: devicetree-discuss, CE Linux Developers List

> http://thread.gmane.org/gmane.comp.emulators.qemu/44869
> 
> I'm not sure why Paul never pushed it but I think he was able to create
> the syborg board purely from a device tree.

The patches referenced above include purely device-tree based Syborg and 
Stellaris boards.

It works fairly nicely for some embedded boards, but gets fairly hairy when 
you start considering more complex topologies/machines. I particular the PCI 
OF/FDT bindings don't really fit what we need for qemu. Obviously full qdev 
conversion is a prerequisite for device tree based configuration, and at that 
time qdev was still in its infancy.

Part of the reason for posting that patch was to demonstrate the abstraction 
layers required for the internal device model. Previous patches tended to be 
based on the pre-existing PC commandline options, which IMO is a mistake. 
Likewise if (like my implementation) you focus on embedded machines you risk 
serious problems trying to extend to server class machines.

Paul

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

* Re: [Qemu-devel] CELF Project Proposal - Device tree support for QEMU system emulation.
       [not found]     ` <4B2A94BB.4020200-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
  2009-12-22 12:45         ` Paul Brook
@ 2009-12-22 18:54       ` Rob Landley
  1 sibling, 0 replies; 11+ messages in thread
From: Rob Landley @ 2009-12-22 18:54 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	qemu-devel-qX2TKyscuCcdnm+yROfE0A, CE Linux Developers List,
	Paul Brook

On Thursday 17 December 2009 14:29:47 Anthony Liguori wrote:
> Rob Landley wrote:
> > For background of CELF project proposals, see:
> >
> >   http://elinux.org/CELF_Open_Project_Proposal_2010
> >
> > Summary:
> >
> > Integrate a flattened device tree parser into the emulator QEMU, so QEMU
> > can create board emulations on the fly (at runtime) from the same data
> > files the Linux kernel uses to attach drivers to hardware.
>
> See
>
> http://thread.gmane.org/gmane.comp.emulators.qemu/44869
>
> I'm not sure why Paul never pushed it but I think he was able to create
> the syborg board purely from a device tree.

He'd be a great person to sponsor to get it finished/updated and checked 
in, then.  (Or his company, code sourcry, would.)  Me, I just want to use the 
result.

By the way, device trees were a topic at this year's kernel summit, and LWN 
did an excellent write-up, as usual: http://lwn.net/Articles/357487/

(If it does get done, somebody needs to write a HOWTO...)

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds

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

end of thread, other threads:[~2009-12-22 18:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-17  4:46 CELF Project Proposal - Device tree support for QEMU system emulation Rob Landley
2009-12-17  4:46 ` [Qemu-devel] " Rob Landley
     [not found] ` <200912162246.42366.rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org>
2009-12-17 20:29   ` Anthony Liguori
2009-12-17 20:29     ` Anthony Liguori
     [not found]     ` <4B2A94BB.4020200-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2009-12-22 12:45       ` Paul Brook
2009-12-22 12:45         ` Paul Brook
2009-12-22 18:54       ` Rob Landley
2009-12-19 10:54   ` Blue Swirl
2009-12-19 10:54     ` Blue Swirl
2009-12-17 23:14 ` [Celinux-dev] " Tim Bird
2009-12-17 23:14   ` [Qemu-devel] " Tim Bird

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.