diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/README.menu | 119 | ||||
-rw-r--r-- | doc/README.pxe | 240 | ||||
-rw-r--r-- | doc/README.sandbox | 53 |
3 files changed, 412 insertions, 0 deletions
diff --git a/doc/README.menu b/doc/README.menu new file mode 100644 index 0000000..1259c6a --- /dev/null +++ b/doc/README.menu @@ -0,0 +1,119 @@ +/* + * Copyright 2010-2011 Calxeda, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ + +U-boot provides a set of interfaces for creating and using simple, text +based menus. Menus are displayed as lists of labeled entries on the +console, and an entry can be selected by entering its label. + +To use the menu code, enable CONFIG_MENU, and include "menu.h" where +the interfaces should be available. + +Menus are composed of items. Each item has a key used to identify it in +the menu, and an opaque pointer to data controlled by the consumer. + +Interfaces +---------- +#include "menu.h" + +/* + * Consumers of the menu interfaces will use a struct menu * as the + * handle for a menu. struct menu is only fully defined in menu.c, + * preventing consumers of the menu interfaces from accessing its + * contents directly. + */ +struct menu; + +/* + * NOTE: See comments in common/menu.c for more detailed documentation on + * these interfaces. + */ + +/* + * menu_create() - Creates a menu handle with default settings + */ +struct menu *menu_create(char *title, int timeout, int prompt, + void (*item_data_print)(void *)); + +/* + * menu_item_add() - Adds or replaces a menu item + */ +int menu_item_add(struct menu *m, char *item_key, void *item_data); + +/* + * menu_default_set() - Sets the default choice for the menu + */ +int menu_default_set(struct menu *m, char *item_key); + +/* + * menu_get_choice() - Returns the user's selected menu entry, or the + * default if the menu is set to not prompt or the timeout expires. + */ +int menu_get_choice(struct menu *m, void **choice); + +/* + * menu_destroy() - frees the memory used by a menu and its items. + */ +int menu_destroy(struct menu *m); + + +Example Code +------------ +This example creates a menu that always prompts, and allows the user +to pick from a list of tools. The item key and data are the same. + +#include "menu.h" + +char *tools[] = { + "Hammer", + "Screwdriver", + "Nail gun", + NULL +}; + +char *pick_a_tool(void) +{ + struct menu *m; + int i; + char *tool = NULL; + + m = menu_create("Tools", 0, 1, NULL); + + for(i = 0; tools[i]; i++) { + if (menu_item_add(m, tools[i], tools[i]) != 1) { + printf("failed to add item!"); + menu_destroy(m); + return NULL; + } + } + + if (menu_get_choice(m, (void **)&tool) != 1) + printf("Problem picking tool!\n"); + + menu_destroy(m); + + return tool; +} + +void caller(void) +{ + char *tool = pick_a_tool(); + + if (tool) { + printf("picked a tool: %s\n", tool); + use_tool(tool); + } +} diff --git a/doc/README.pxe b/doc/README.pxe new file mode 100644 index 0000000..9026d9c --- /dev/null +++ b/doc/README.pxe @@ -0,0 +1,240 @@ +/* + * Copyright 2010-2011 Calxeda, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ + +The 'pxe' commands provide a near subset of the functionality provided by +the PXELINUX boot loader. This allows U-boot based systems to be controlled +remotely using the same PXE based techniques that many non U-boot based servers +use. + +Commands +======== + +pxe get +------- + syntax: pxe get + + follows PXELINUX's rules for retrieving configuration files from a tftp + server, and supports a subset of PXELINUX's config file syntax. + + Environment + ----------- + 'pxe get' requires two environment variables to be set: + + pxefile_addr_r - should be set to a location in RAM large enough to hold + pxe files while they're being processed. Up to 16 config files may be + held in memory at once. The exact number and size of the files varies with + how the system is being used. A typical config file is a few hundred bytes + long. + + bootfile,serverip - these two are typically set in the DHCP response + handler, and correspond to fields in the DHCP response. + + 'pxe get' optionally supports these two environment variables being set: + + ethaddr - this is the standard MAC address for the ethernet adapter in use. + 'pxe get' uses it to look for a configuration file specific to a system's + MAC address. + + pxeuuid - this is a UUID in standard form using lower case hexadecimal + digits, for example, 550e8400-e29b-41d4-a716-446655440000. 'pxe get' uses + it to look for a configuration file based on the system's UUID. + + File Paths + ---------- + 'pxe get' repeatedly tries to download config files until it either + successfully downloads one or runs out of paths to try. The order and + contents of paths it tries mirrors exactly that of PXELINUX - you can + read in more detail about it at: + + http://syslinux.zytor.com/wiki/index.php/Doc/pxelinux + +pxe boot +-------- + syntax: pxe boot [pxefile_addr_r] + + Interprets a pxe file stored in memory. + + pxefile_addr_r is an optional argument giving the location of the pxe file. + The file must be terminated with a NUL byte. + + Environment + ----------- + There are some environment variables that may need to be set, depending + on conditions. + + pxefile_addr_r - if the optional argument pxefile_addr_r is not supplied, + an environment variable named pxefile_addr_r must be supplied. This is + typically the same value as is used for the 'pxe get' command. + + bootfile - typically set in the DHCP response handler based on the + same field in the DHCP respone, this path is used to generate the base + directory that all other paths to files retrieved by 'pxe boot' will use. + If no bootfile is specified, paths used in pxe files will be used as is. + + serverip - typically set in the DHCP response handler, this is the IP + address of the tftp server from which other files will be retrieved. + + kernel_addr_r, initrd_addr_r - locations in RAM at which 'pxe boot' will + store the kernel and initrd it retrieves from tftp. These locations will + be passed to the bootm command to boot the kernel. These environment + variables are required to be set. + + fdt_addr - the location of a fdt blob. If this is set, it will be passed + to bootm when booting a kernel. + +pxe file format +=============== +The pxe file format is nearly a subset of the PXELINUX file format; see +http://syslinux.zytor.com/wiki/index.php/PXELINUX. It's composed of one line +commands - global commands, and commands specific to labels. Lines begining +with # are treated as comments. White space between and at the beginning of +lines is ignored. + +The size of pxe files and the number of labels is only limited by the amount +of RAM available to U-boot. Memory for labels is dynamically allocated as +they're parsed, and memory for pxe files is statically allocated, and its +location is given by the pxefile_addr_r environment variable. The pxe code is +not aware of the size of the pxefile memory and will outgrow it if pxe files +are too large. + +Supported global commands +------------------------- +Unrecognized commands are ignored. + +default <label> - the label named here is treated as the default and is + the first label 'pxe boot' attempts to boot. + +menu title <string> - sets a title for the menu of labels being displayed. + +menu include <path> - use tftp to retrieve the pxe file at <path>, which + is then immediately parsed as if the start of its + contents were the next line in the current file. nesting + of include up to 16 files deep is supported. + +prompt <flag> - if 1, always prompt the user to enter a label to boot + from. if 0, only prompt the user if timeout expires. + +timeout <num> - wait for user input for <num>/10 seconds before + auto-booting a node. + +label <name> - begin a label definition. labels continue until + a command not recognized as a label command is seen, + or EOF is reached. + +Supported label commands +------------------------ +labels end when a command not recognized as a label command is reached, or EOF. + +menu default - set this label as the default label to boot; this is + the same behavior as the global default command but + specified in a different way + +kernel <path> - if this label is chosen, use tftp to retrieve the kernel + at <path>. it will be stored at the address indicated in + the kernel_addr_r environment variable, and that address + will be passed to bootm to boot this kernel. + +append <string> - use <string> as the kernel command line when booting this + label. + +initrd <path> - if this label is chosen, use tftp to retrieve the initrd + at <path>. it will be stored at the address indicated in + the initrd_addr_r environment variable, and that address + will be passed to bootm. + +localboot <flag> - Run the command defined by "localcmd" in the environment. + <flag> is ignored and is only here to match the syntax of + PXELINUX config files. + +Example +------- +Here's a couple of example files to show how this works. + +------------/tftpboot/pxelinux.cfg/menus/linux.list---------- +menu title Linux selections + +# This is the default label +label install + menu label Default Install Image + kernel kernels/install.bin + append console=ttyAMA0,38400 debug earlyprintk + initrd initrds/uzInitrdDebInstall + +# Just another label +label linux-2.6.38 + kernel kernels/linux-2.6.38.bin + append root=/dev/sdb1 + +# The locally installed kernel +label local + menu label Locally installed kernel + append root=/dev/sdb1 + localboot 1 +------------------------------------------------------------- + +------------/tftpboot/pxelinux.cfg/default------------------- +menu include pxelinux.cfg/menus/base.menu +timeout 500 + +default linux-2.6.38 +------------------------------------------------------------- + +When a pxe client retrieves and boots the default pxe file, +'pxe boot' will wait for user input for 5 seconds before booting +the linux-2.6.38 label, which will cause /tftpboot/kernels/linux-2.6.38.bin +to be downloaded, and boot with the command line "root=/dev/sdb1" + +Differences with PXELINUX +========================= +The biggest difference between U-boot's pxe and PXELINUX is that since +U-boot's pxe support is written entirely in C, it can run on any platform +with network support in U-boot. Here are some other differences between +PXELINUX and U-boot's pxe support. + +- U-boot's pxe does not support the PXELINUX DHCP option codes specified + in RFC 5071, but could be extended to do so. + +- when U-boot's pxe fails to boot, it will return control to U-boot, + allowing another command to run, other U-boot command, instead of resetting + the machine like PXELINUX. + +- U-boot's pxe doesn't rely on or provide an UNDI/PXE stack in memory, it + only uses U-boot. + +- U-boot's pxe doesn't provide the full menu implementation that PXELINUX + does, only a simple text based menu using the commands described in + this README. With PXELINUX, it's possible to have a graphical boot + menu, submenus, passwords, etc. U-boot's pxe could be extended to support + a more robust menuing system like that of PXELINUX's. + +- U-boot's pxe expects U-boot uimg's as kernels. Anything that would work + with the 'bootm' command in U-boot could work with the 'pxe boot' command. + +- U-boot's pxe doesn't recognize initrd options in the append command - you + must specify initrd files using the initrd command. + +- U-boot's pxe only recognizes a single file on the initrd command line. It + could be extended to support multiple. + +- in U-boot's pxe, the localboot command doesn't necessarily cause a local + disk boot - it will do whatever is defined in the 'localcmd' env + variable. And since it doesn't support a full UNDI/PXE stack, the + type field is ignored. + +- the interactive prompt in U-boot's pxe only allows you to choose a label + from the menu. If you want to boot something not listed, you can ctrl+c + out of 'pxe boot' and use existing U-boot commands to accomplish it. diff --git a/doc/README.sandbox b/doc/README.sandbox new file mode 100644 index 0000000..04692b3 --- /dev/null +++ b/doc/README.sandbox @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +Native Execution of U-Boot +========================== + +The 'sandbox' architecture is designed to allow U-Boot to run under Linux on +almost any hardware. To achieve this it builds U-Boot (so far as possible) +as a normal C application with a main() and normal C libraries. + +All of U-Boot's architecture-specific code therefore cannot be built as part +of the sandbox U-Boot. The purpose of running U-Boot under Linux is to test +all the generic code, not specific to any one architecture. The idea is to +create unit tests which we can run to test this upper level code. + +CONFIG_SANDBOX is defined when building a native board. + +The chosen vendor and board names are also 'sandbox', so there is a single +board in board/sandbox/sandbox. + +CONFIG_SANDBOX_BIG_ENDIAN should be defined when running on big-endian +machines. + +Note that standalone/API support is not available at present. + +The serial driver is a very simple implementation which reads and writes to +the console. It does not set the terminal into raw mode, so cursor keys and +history will not work yet. + + +Tests +----- + +So far we have no tests, but when we do these will be documented here. |