Difference between revisions of "Bayou"

From coreboot
Jump to: navigation, search
(Add behavior and cleanups)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''Bayou''' is the working name for a coreboot payload that can chose, load and run other payloads from a LAR archive on the ROM.
+
[[Image:Bayou-screenshot-menu.jpg|thumb|right|The chooser menu with two options.]]
 +
[[Image:Bayou-screenshot-info.jpg|thumb|right|The same chooser menu showing the PAYLOAD_PARAM data passed by coreinfo.]]
 +
[[Image:Bayou-screenshot-serial.jpg|thumb|right|The same chooser menu over serial.]]
 +
[[Image:Bayou-screenshot-timeout.jpg|thumb|right|The timeout message. If the key isn't pressed, then the menu is displayed.]]
 +
 
 +
'''Bayou''' is the working name for a coreboot [[Payloads|payload]] that can choose, load and run other payloads from a LAR archive on the ROM.
 +
 
 +
== Building ==
 +
 
 +
First, get and build [[libpayload]]:
 +
 
 +
$ '''git clone http://review.coreboot.org/p/coreboot'''
 +
$ '''cd payloads/libpayload'''
 +
$ '''make menuconfig'''
 +
$ '''make'''
 +
 
 +
Then, get and build Bayou itself:
 +
 
 +
$ '''cd ../bayou'''
 +
$ '''mkdir build'''
 +
$ '''cd build'''
 +
$ '''ln -s ../../libpayload/ ./'''
 +
$ '''cd ../'''
 +
 
 +
Now, you'll need to create a '''bayou.xml''' file containing the menu entries you like. Start by copying and then editing the sample file '''bayou.xml.example''' (and copying all required payloads in the current directory).
 +
 
 +
$ '''cp bayou.xml.example bayou.xml'''
 +
 
 +
Then actually build Bayou:
 +
 
 +
$ '''make'''
 +
 
 +
The file '''bayou.elf''' is your finale Bayou payload file, which you can use for coreboot.
  
 
== Why "Bayou"? ==
 
== Why "Bayou"? ==
  
We need a little bit of originality in the names of our payloads, as Peter discusses [http://www.coreboot.org/pipermail/coreboot/2008-April/033219.html here].  In the grand tradition of [http://en.wikipedia.org/wiki/El_Torito_%28CD-ROM_standard%29 El Torito], we decided to name the project after the restaurant where we ate lunch and debated the payload chooser during the coreboot summit in Denver: [http://denver.citysearch.com/profile/1823003/denver_co/bayou_bob_s_seafood_southern_cookin.html Bayou Bob's]. The word ''bayou'' is French in origin, but it famously describes slow or stagnant streams and swamps in the southern United States (see also [http://en.wikipedia.org/wiki/Bayou Bayou at wikipedia].  The name in no way describes the project itself, which should neither be slow nor swampy.
+
We need a little bit of originality in the names of our payloads, as Peter discusses [http://www.coreboot.org/pipermail/coreboot/2008-April/033219.html here].  In the grand tradition of [http://en.wikipedia.org/wiki/El_Torito_%28CD-ROM_standard%29 El Torito], we decided to name the project after the restaurant where we ate lunch and debated the payload chooser during the coreboot summit 2008 in Denver: [http://denver.citysearch.com/profile/1823003/denver_co/bayou_bob_s_seafood_southern_cookin.html Bayou Bob's]. The word ''bayou'' is French in origin, but it famously describes slow or stagnant streams and swamps in the southern United States (see also [http://en.wikipedia.org/wiki/Bayou Bayou at wikipedia].  The name in no way describes the project itself, which should neither be slow nor swampy.
  
 
== Usage Models ==
 
== Usage Models ==
Line 10: Line 42:
  
 
=== Graphical chooser ===
 
=== Graphical chooser ===
This usage model presents a menu to the user containing the descriptive names of all the payloads in the LAR.  The user selects an item from the list, and bayou loads and runs the payload.  If the payload is responsible enough to be able to exit cleanly (as all libpayload payloads should be able to do) and return control to bayou, then the user can select a different payload.
+
 
 +
This usage model presents a menu to the user containing the descriptive names of all the payloads in the LAR.  The user selects an item from the list, and Bayou loads and runs the payload.  If the payload is responsible enough to be able to exit cleanly (as all libpayload payloads should be able to do) and return control to Bayou, then the user can select a different payload.
  
 
=== Chaining ===
 
=== Chaining ===
Chaining is a non-interactive usage model wherein Bayou will load and execute a series of payloads in order.  The payloads must be able to return control to bayou cleanly (except the "final" payload which isn't expected to return).  This will loosely imitate a traditional BIOS in that one could define a "BIOS setup screen" payload that ran before FILO or other kernel bootloader.
+
 
 +
Chaining is a non-interactive usage model wherein Bayou will load and execute a series of payloads in order.  The payloads must be able to return control to Bayou cleanly (except the "final" payload which isn't expected to return).  This will loosely imitate a traditional BIOS in that one could define a "BIOS setup screen" payload that ran before FILO or other kernel bootloader.
  
 
== Architecture ==
 
== Architecture ==
  
The architecture of bayou is rather simple.  It is a [[libpayload]] based application with code for reading and loading payloads from a LAR and an front end user interface.  The
+
The architecture of Bayou is rather simple.  It is a [[libpayload]] based application with code for reading and loading payloads from a LAR and a front end user interface.  The Bayou code itself lives below 640k so that it can stay resident when loading payloads that would typically locate themselves at 1Mb or higher.  Payloads that want to work cleanly with Bayou should not write to memory below 640k unless it is a "final" payload (i.e. something that will not return to Bayou, such as the Linux kernel).  Bayou will read, load and execute payloads encoded in the [[SELF|Simple Executable Loader Format]], decompressing them if needed (with lzma).
bayou code itself lives below 640k so that it can stay resident when loading payloads that would typically locate themselves at 1Mb or higher.  Payloads that want to work cleanly with bayou
+
should not write to memory below 640k unless it is a "final" payload (i.e. something that will not return to bayou, such as the Linux kernel).  Bayou will read, load and execute payloads encoded in
+
the [[SELF|Simple Executable Loader Format]], decompressing them if needed (with lzma).
+
  
 
== Behavior ==
 
== Behavior ==
  
When Bayou starts, it will find and read the Bayou Payload Table (see below).  There are three different paths that can be followed, depending on the value of the 'timeout' field:
+
When Bayou starts, it will find and read the '''Bayou Payload Table (BPT)''' (see below).  There are three different paths that can be followed, depending on the value of the '''timeout''' field:
  
* If the timeout field is greater then 0 but not 0xFFFF, then Bayou will display a countdown message on the screen. If the user presses F1, then the chooser menu will be displayed.  If the user does not press a key in the alloted time then bayou will automatically start the item in the payload table that is marked as 'default'.
+
* If the timeout field is greater then 0 but not 0xFF, then Bayou will display a countdown message on the screen. If the user presses F1, then the chooser menu will be displayed.  If the user does not press a key in the alloted time then Bayou will automatically start the item in the payload table that is marked as 'default'.
 
  Please press F1 for the menu.  Timeout in (3) seconds...
 
  Please press F1 for the menu.  Timeout in (3) seconds...
 
* If the timeout field is zero, then the default item will be chosen immediately without a timeout.
 
* If the timeout field is zero, then the default item will be chosen immediately without a timeout.
* If the timeout field is 0xFFFF. then the chooser menu will be shown immediately without a timeout.
+
* If the timeout field is 0xFF. then the chooser menu will be shown immediately without a timeout.
  
When the menu is displayed, it will list all top level items in the BPT, both chooser and chain items. When a chain item is selected from the menu (or as the 'default' item), then each
+
When the menu is displayed, it will list all top level items in the Bayou Payload Table, both chooser and chain items. When a chain item is selected from the menu (or as the 'default' item), then each of the sub-items listed in the payload table will be executed in order.  Each sub-payload item is expected to return control to Bayou, except the last one.  If a payload fails to return control, then the rest of the chain will not be executed.
of the sub-items listed in the payload table will be executed in order.  Each sub-payload item is expected to return control to bayou, except the last one.  If a payload fails to return
+
control, then the rest of the chain will not be executed.
+
  
 
== Configuration ==
 
== Configuration ==
  
The ROM image with LAR + coreboot-v3 is very dynamic in nature.  New blobs of data can be added at any time during the build process or during runtime.  This means that the Bayou configuration
+
The ROM image with LAR + coreboot v3 is very dynamic in nature.  New blobs of data can be added at any time during the build process or during runtime.  This means that the Bayou configuration cannot be static - it must be able to grow and change with the LAR.
cannot be static - it must be able to grow and change with the LAR.
+
  
 
=== Bayou Payload Table ===
 
=== Bayou Payload Table ===
  
The payload table describes which payloads to manage, both in chooser and in chained mode.  The table is stored as a LAR file with the name ''bayou_payload_table''.  The table is organized like
+
The payload table describes which payloads to manage, both in chooser and in chained mode.  The table is stored as a LAR file with the name '''bayou_payload_table'''.  The table is organized like follows:
follows:
+
  
 
{| border="1"
 
{| border="1"
Line 63: Line 90:
 
| ID || 4 bytes || An identifier that indicates the file is a Bayou Payload Table. the value will be 'BPT0' or in hex: 0x305405042 (in little endian)
 
| ID || 4 bytes || An identifier that indicates the file is a Bayou Payload Table. the value will be 'BPT0' or in hex: 0x305405042 (in little endian)
 
|-
 
|-
| Timeout || 2 bytes || if the value of this field is 0, then the default item in the payload list will be executed immediately.  If this value is 65535 (0xFFFF), then the chooser menu will be displayed immediately.  Any value between 1 and 65534 indicates the amount of time (in milliseconds) that the system should wait.   
+
| Timeout || 1 bytes || if the value of this field is 0, then the default item in the payload list will be executed immediately.  If this value is 254 (0xFF), then the chooser menu will be displayed immediately.  Any value between 1 and 254 indicates the amount of time (in seconds) that the system should wait.   
 
|-
 
|-
| Padding || 10 bytes || Unused space padding out to 16 byte alignment.  This may be used in the future  
+
| Padding || 11 bytes || Unused space padding out to 16 byte alignment.  This may be used in the future  
 
|}  
 
|}  
 
   
 
   
 
Following the configuration header is the list of payloads.  There are three types of possible items in the list:  
 
Following the configuration header is the list of payloads.  There are three types of possible items in the list:  
 
* A chooser item is displayed in a list of other items on a menu.  Each chooser item is associated with a single payload.
 
* A chooser item is displayed in a list of other items on a menu.  Each chooser item is associated with a single payload.
* A master chain item describes a chain of items that are to be executed one after another.  Master chain items specify a title and may be displayed on the chooser menu
+
* A master chain item describes a chain of items that are to be executed one after another.  Master chain items specify a title and may be displayed on the chooser menu.
* A number of sub chain items are tied to a master chain item and point to the specific payloads to be executed in the chain
+
* A number of sub chain items are tied to a master chain item and point to the specific payloads to be executed in the chain.
  
 
{| border="1"
 
{| border="1"
Line 96: Line 123:
 
== Payload Parameters ==
 
== Payload Parameters ==
  
There are several parameters that the payload can set to control the behavior of bayou.  These are passed in through the PARAMS section in the SELF:
+
There are several parameters that the payload can set to control the behavior of Bayou.  These are passed in through the PARAMS section in the SELF:
  
 
{| border="1"
 
{| border="1"
Line 117: Line 144:
  
 
== Changes to coreboot ==
 
== Changes to coreboot ==
In order to support bayou, some drastic changes need to be made to coreboot and associated projects.  The following is a short synopsis of these changes.
+
 
 +
In order to support Bayou, some drastic changes need to be made to coreboot and associated projects.  The following is a short synopsis of these changes.
  
 
=== Coreboot ===
 
=== Coreboot ===
* Coreboot needs to be modified to understand and load the [[SELF]] format
+
 
* The LAR design needs to be modified so that coreboot can identify and boot the "default" payload. Captain Obvious says: call it payload/default (or normal, or whatever). No evil bit in LAR required to find it.
+
* Coreboot needs to be modified to understand and load the [[SELF]] format.
 +
* The LAR design needs to be modified so that coreboot can identify and boot the "default" payload. Captain Obvious says: call it '''payload/default''' (or normal, or whatever). No evil bit in LAR required to find it.
  
 
=== LAR ===
 
=== LAR ===
* The LAR utility must be modified to build LAR images with SELF payloads
 
* The LAR utility needs to be modified to allow the user to specify a long descriptive name to be included in the NAME segment
 
* A rewrite of the frontend of the LAR utility may be needed to fully support all the features
 
  
Instead of modifying LAR and putting even more features into it, how about creating an elf2self (and back) tool, and just add those files into lar?
+
* The LAR utility must be modified to build LAR images with SELF payloads.
Sure, it's another build step, but it's "one tool for one job", allows for interesting development, adoption of self beyond coreboot, ... - and we really already have enough build steps that this additional one won't hurt either.
+
* The LAR utility needs to be modified to allow the user to specify a long descriptive name to be included in the NAME segment.
 +
* A rewrite of the frontend of the LAR utility may be needed to fully support all the features.
 +
 
 +
Instead of modifying LAR and putting even more features into it, how about creating an '''elf2self''' (and back) tool, and just add those files into lar?
 +
Sure, it's another build step, but it's "one tool for one job", allows for interesting development, adoption of SELF beyond coreboot, ... - and we really already have enough build steps that this additional one won't hurt either.
  
 
=== Buildrom ===
 
=== Buildrom ===
* Buildrom must be adapted to build multiple payloads during the same run
+
 
 +
* Buildrom must be adapted to build multiple payloads during the same run.
  
 
=== Libpayload ===
 
=== Libpayload ===
* Add generic LAR walking code '''Done'''
+
 
* Ensure that libpayload based payloads can cleanly return control to the master payload
+
* Add generic LAR walking code ('''done''').
* Modify the build system to allow the configuration system to modify the payload entry point
+
* Ensure that libpayload based payloads can cleanly return control to the master payload.
 +
* Modify the build system to allow the configuration system to modify the payload entry point.

Latest revision as of 17:23, 16 February 2013

The chooser menu with two options.
The same chooser menu showing the PAYLOAD_PARAM data passed by coreinfo.
The same chooser menu over serial.
The timeout message. If the key isn't pressed, then the menu is displayed.

Bayou is the working name for a coreboot payload that can choose, load and run other payloads from a LAR archive on the ROM.

Building

First, get and build libpayload:

$ git clone http://review.coreboot.org/p/coreboot
$ cd payloads/libpayload
$ make menuconfig
$ make

Then, get and build Bayou itself:

$ cd ../bayou
$ mkdir build
$ cd build
$ ln -s ../../libpayload/ ./
$ cd ../

Now, you'll need to create a bayou.xml file containing the menu entries you like. Start by copying and then editing the sample file bayou.xml.example (and copying all required payloads in the current directory).

$ cp bayou.xml.example bayou.xml

Then actually build Bayou:

$ make

The file bayou.elf is your finale Bayou payload file, which you can use for coreboot.

Why "Bayou"?

We need a little bit of originality in the names of our payloads, as Peter discusses here. In the grand tradition of El Torito, we decided to name the project after the restaurant where we ate lunch and debated the payload chooser during the coreboot summit 2008 in Denver: Bayou Bob's. The word bayou is French in origin, but it famously describes slow or stagnant streams and swamps in the southern United States (see also Bayou at wikipedia. The name in no way describes the project itself, which should neither be slow nor swampy.

Usage Models

The following are the two usage models for the payload:

Graphical chooser

This usage model presents a menu to the user containing the descriptive names of all the payloads in the LAR. The user selects an item from the list, and Bayou loads and runs the payload. If the payload is responsible enough to be able to exit cleanly (as all libpayload payloads should be able to do) and return control to Bayou, then the user can select a different payload.

Chaining

Chaining is a non-interactive usage model wherein Bayou will load and execute a series of payloads in order. The payloads must be able to return control to Bayou cleanly (except the "final" payload which isn't expected to return). This will loosely imitate a traditional BIOS in that one could define a "BIOS setup screen" payload that ran before FILO or other kernel bootloader.

Architecture

The architecture of Bayou is rather simple. It is a libpayload based application with code for reading and loading payloads from a LAR and a front end user interface. The Bayou code itself lives below 640k so that it can stay resident when loading payloads that would typically locate themselves at 1Mb or higher. Payloads that want to work cleanly with Bayou should not write to memory below 640k unless it is a "final" payload (i.e. something that will not return to Bayou, such as the Linux kernel). Bayou will read, load and execute payloads encoded in the Simple Executable Loader Format, decompressing them if needed (with lzma).

Behavior

When Bayou starts, it will find and read the Bayou Payload Table (BPT) (see below). There are three different paths that can be followed, depending on the value of the timeout field:

  • If the timeout field is greater then 0 but not 0xFF, then Bayou will display a countdown message on the screen. If the user presses F1, then the chooser menu will be displayed. If the user does not press a key in the alloted time then Bayou will automatically start the item in the payload table that is marked as 'default'.
Please press F1 for the menu.  Timeout in (3) seconds...
  • If the timeout field is zero, then the default item will be chosen immediately without a timeout.
  • If the timeout field is 0xFF. then the chooser menu will be shown immediately without a timeout.

When the menu is displayed, it will list all top level items in the Bayou Payload Table, both chooser and chain items. When a chain item is selected from the menu (or as the 'default' item), then each of the sub-items listed in the payload table will be executed in order. Each sub-payload item is expected to return control to Bayou, except the last one. If a payload fails to return control, then the rest of the chain will not be executed.

Configuration

The ROM image with LAR + coreboot v3 is very dynamic in nature. New blobs of data can be added at any time during the build process or during runtime. This means that the Bayou configuration cannot be static - it must be able to grow and change with the LAR.

Bayou Payload Table

The payload table describes which payloads to manage, both in chooser and in chained mode. The table is stored as a LAR file with the name bayou_payload_table. The table is organized like follows:

Global configuration
Payload tables

The global configuration header controls general Bayou behavior:

Field Size Description
ID 4 bytes An identifier that indicates the file is a Bayou Payload Table. the value will be 'BPT0' or in hex: 0x305405042 (in little endian)
Timeout 1 bytes if the value of this field is 0, then the default item in the payload list will be executed immediately. If this value is 254 (0xFF), then the chooser menu will be displayed immediately. Any value between 1 and 254 indicates the amount of time (in seconds) that the system should wait.
Padding 11 bytes Unused space padding out to 16 byte alignment. This may be used in the future

Following the configuration header is the list of payloads. There are three types of possible items in the list:

  • A chooser item is displayed in a list of other items on a menu. Each chooser item is associated with a single payload.
  • A master chain item describes a chain of items that are to be executed one after another. Master chain items specify a title and may be displayed on the chooser menu.
  • A number of sub chain items are tied to a master chain item and point to the specific payloads to be executed in the chain.
Field Size Description
index 1 byte An index number for the entry - sub items will use this as the value of its 'parent' field
parent 1 byte For sub chain items this lists the index of the master chain item that the payload is attached to. Chooser and master chain items are always at the toplevel and should have a parent of '0'
type 1 byte Specifies the type of the entry. Possible values are 0x01 - chooser item, 0x02 - master chain item, 0x03 sub-chain item
flags 1 byte This bit field describes various flags that modify the item. Possible values are bit 0 - default item (executed after timeout), bit 1 - do not show in chooser menu
title 64 bytes This is a name displayed by the chooser for the item. It is required for master chain items, but not for chooser items. If not NULL, this will replace any names specified by the payload. This should be null for sub chain items
nlen 4 bytes Length of the payload name, in bytes. This should be 0 for master chain items.
name 'nlen' bytes Specifies the name of the LAR file for the payload associated with this entry. Only valid for sub-chain items and chooser items.

Payload Parameters

There are several parameters that the payload can set to control the behavior of Bayou. These are passed in through the PARAMS section in the SELF:

Parameter Description
name This is the short name of the payload, which is displayed in the log and in the chooser menu if 'listname' is not defined
listname This is the name shown in the chooser menu
desc This is a verbose description of the application that will be displayed in the "help" section in the chooser menu

The following is an example of macros a typical payload would use to set the above values:

PAYLOAD_PARAM(name,"coreinfo");
PAYLOAD_PARAM(listname,"System Information");
PAYLOAD_PARAM(desc,"Display information about the system");

Changes to coreboot

In order to support Bayou, some drastic changes need to be made to coreboot and associated projects. The following is a short synopsis of these changes.

Coreboot

  • Coreboot needs to be modified to understand and load the SELF format.
  • The LAR design needs to be modified so that coreboot can identify and boot the "default" payload. Captain Obvious says: call it payload/default (or normal, or whatever). No evil bit in LAR required to find it.

LAR

  • The LAR utility must be modified to build LAR images with SELF payloads.
  • The LAR utility needs to be modified to allow the user to specify a long descriptive name to be included in the NAME segment.
  • A rewrite of the frontend of the LAR utility may be needed to fully support all the features.

Instead of modifying LAR and putting even more features into it, how about creating an elf2self (and back) tool, and just add those files into lar? Sure, it's another build step, but it's "one tool for one job", allows for interesting development, adoption of SELF beyond coreboot, ... - and we really already have enough build steps that this additional one won't hurt either.

Buildrom

  • Buildrom must be adapted to build multiple payloads during the same run.

Libpayload

  • Add generic LAR walking code (done).
  • Ensure that libpayload based payloads can cleanly return control to the master payload.
  • Modify the build system to allow the configuration system to modify the payload entry point.