Antonello Dettori (dev@dettori.io) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15956
-gerrit
commit d5e4a4d6ef9610e50580a3fb0cccb760f5bdc12a Author: Antonello Dettori dev@dettori.io Date: Fri Jul 29 12:03:43 2016 +0200
bayou: Adapt to the coreboot-v4 era
Adapt bayou to work in a coreboot-v4 environment: - Move from the original model (bundling every payload needed in a single file and linking it to bayou itself) to leaving the handling of the secondary payloads to the coreboot build system. - Use the newly introduced region_device api in libpayload. - Use the functions provided by modern libpayload instead of relying on local ones. - Update the SELF code to use struct cbfs_payload_segment.
The port it's still not complete: it can detect and boot most payloads but its currently missing the code to handle chains and configuration in general.
Change-Id: I034c92f52995ff6c69121d482d04dc8ab596b82c Signed-off-by: Antonello Dettori dev@dettori.io --- payloads/Makefile.inc | 7 +- payloads/bayou/Kconfig | 6 + payloads/bayou/Makefile | 89 ++++--- payloads/bayou/bayou.h | 11 +- payloads/bayou/bayou.ldscript | 87 ------- payloads/bayou/cbfs_walker.c | 90 +++++++ payloads/bayou/config.c | 105 ++++---- payloads/bayou/lzma.c | 43 ---- payloads/bayou/lzmadecode.c | 398 ------------------------------- payloads/bayou/lzmadecode.h | 67 ------ payloads/bayou/main.c | 33 ++- payloads/bayou/nrv2b.c | 86 ------- payloads/bayou/payload.c | 6 +- payloads/bayou/self.c | 121 ++++------ payloads/bayou/self.h | 40 ---- payloads/libpayload/configs/config.bayou | 11 + 16 files changed, 294 insertions(+), 906 deletions(-)
diff --git a/payloads/Makefile.inc b/payloads/Makefile.inc index 2d7edb6..7c4ce18 100644 --- a/payloads/Makefile.inc +++ b/payloads/Makefile.inc @@ -21,7 +21,9 @@ cbfs-files-$(CONFIG_NVRAMCUI_SECONDARY_PAYLOAD) += img/nvramcui img/nvramcui-file := payloads/nvramcui/nvramcui.elf img/nvramcui-type := payload
+ PAYLOADS_LIST=\ +payloads/bayou \ payloads/coreinfo \ payloads/nvramcui \ payloads/libpayload \ @@ -38,6 +40,9 @@ payloads/coreinfo/build/coreinfo.elf coreinfo: payloads/nvramcui/nvramcui.elf nvramcui: $(MAKE) -C payloads/nvramcui
+payloads/bayou/build/bayou.elf bayou: + $(MAKE) -C payloads/bayou + clean-payloads: $(foreach payload, $(PAYLOADS_LIST), $(MAKE) -C $(payload) clean; )
@@ -47,4 +52,4 @@ distclean-payloads: print-repo-info-payloads: -$(foreach payload, $(PAYLOADS_LIST), $(MAKE) -C $(payload) print-repo-info 2>/dev/null; )
-.PHONY: clean-payloads distclean-payloads print-repo-info-payloads nvramcui coreinfo +.PHONY: clean-payloads distclean-payloads print-repo-info-payloads nvramcui coreinfo bayou diff --git a/payloads/bayou/Kconfig b/payloads/bayou/Kconfig new file mode 100644 index 0000000..2e4f317 --- /dev/null +++ b/payloads/bayou/Kconfig @@ -0,0 +1,6 @@ +if PAYLOAD_BAYOU + +config PAYLOAD_FILE + default "payloads/bayou/build/bayou.elf" + +endif diff --git a/payloads/bayou/Makefile b/payloads/bayou/Makefile index 7a4b08b..24c9444 100644 --- a/payloads/bayou/Makefile +++ b/payloads/bayou/Makefile @@ -13,55 +13,72 @@ ## GNU General Public License for more details. ##
-CONFIG_LZMA=y -CONFIG_NRV2B=y -CONFIG_BUILTIN_LAR=y - -PBUILDER_CONFIG=bayou.xml -BUILTIN_LAR=builtin.lar - export src := $(CURDIR) export obj := $(src)/build +export V := $(V)
-LIBPAYLOAD_DIR := $(obj)/libpayload +# Make is silent per default, but 'make V=1' will show all compiler calls. +ifneq ($(V),1) +.SILENT: +endif
-CC?=gcc -STRIP?=strip -OBJCOPY?=objcopy +LIBPAYLOAD_PATH := $(realpath ../libpayload) +LIBPAYLOAD_OBJ := $(obj)/libpayload +HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_OBJ)/lib/libpayload.a) +LIBPAYLOAD_CONFIG ?= configs/config.bayou +OBJCOPY ?= objcopy
-FFLAGS-y= -FFLAGS-$(CONFIG_BUILTIN_LAR) += -DCONFIG_BUILTIN_LAR -FFLAGS-$(CONFIG_LZMA) += -DCONFIG_LZMA -FFLAGS-$(CONFIG_NRV2B) += -DCONFIG_NRV2B +OBJECTS-y = main.o menu.o payload.o config.o self.o cbfs_walker.o +OBJS = $(patsubst %,$(obj)/%,$(OBJECTS-y)) +TARGET = $(obj)/bayou.elf
-OBJECTS-y=main.o payload.o config.o menu.o self.o -OBJECTS-$(CONFIG_LZMA) += lzma.o -OBJECTS-$(CONFIG_NRV2B) += nrv2b.o -OBJECTS-$(CONFIG_BUILTIN_LAR) += builtin-lar.o +# in addition to the dependency below, create the file if it doesn't exist +# to silence warnings about a file that would be generated anyway. +$(if $(wildcard .xcompile),,$(eval $(shell ../../util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile))) +.xcompile: ../../util/xcompile/xcompile + $< $(XGCCPATH) > $@.tmp + \mv -f $@.tmp $@ 2> /dev/null || rm -f $@.tmp $@
-CFLAGS= -Wall -Werror -Os $(FFLAGS-y) -LDFLAGS=-Wl,-T,bayou.ldscript -static -LIBGCC=$(shell $(CC) -m32 -print-libgcc-file-name) +CONFIG_COMPILER_GCC := y +ARCH-y := x86_32 + +include .xcompile
-LPCC=$(LIBPAYLOAD_DIR)/bin/lpgcc +CC := $(CC_$(ARCH-y)) +STRIP := $(STRIP_$(ARCH-y)) +OBJCOPY := $(OBJCOPY_$(ARCH-y))
-bayou.elf: $(OBJECTS-y) - $(LPCC) $(LDFLAGS) -m32 -o $@ $(OBJECTS-y) - @$(STRIP) $@ +LPCC := CC="$(CC)" $(LIBPAYLOAD_OBJ)/bin/lpgcc
-builtin-lar.o: $(BUILTIN_LAR) - @$(OBJCOPY) -I binary -B i386 -O elf32-i386 $(BUILTIN_LAR) $@ +CFLAGS= -Wall -Werror -Og -fno-builtin $(CFLAGS_$(ARCH-y)) +LDFLAGS= -Wl,--build-id=none -static +LIBGCC=$(shell $(CC) -m32 -print-libgcc-file-name)
-builtin.lar: util/pbuilder/pbuilder - @rm -f $@ - util/pbuilder/pbuilder -c $(PBUILDER_CONFIG) create $@ +all: $(TARGET)
-util/pbuilder/pbuilder: - $(MAKE) -C util/pbuilder +$(TARGET): libpayload $(OBJS) + $(LPCC) -o $@ $(OBJS) + $(OBJCOPY) --only-keep-debug $@ $(TARGET).debug + $(OBJCOPY) --strip-debug $@ + $(OBJCOPY) --add-gnu-debuglink=$(TARGET).debug $@
-%.o: %.c +$(obj)/%.o: $(src)/%.c $(LPCC) $(CFLAGS) -c -o $@ $<
+ifneq ($(strip $(HAVE_LIBPAYLOAD)),) +libpayload: + printf "Found Libpayload $(LIBPAYLOAD_OBJ).\n" +else +LPOPTS=obj="$(CURDIR)/lpbuild" DOTCONFIG="$(CURDIR)/lp.config" +libpayload: + printf "Building libpayload @ $(LIBPAYLOAD_PATH).\n" + $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) distclean obj=$(obj)/libptmp + $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) defconfig KBUILD_DEFCONFIG=$(LIBPAYLOAD_CONFIG) + $(MAKE) -C $(LIBPAYLOAD_PATH) $(LPOPTS) install DESTDIR=$(obj) +endif + + clean: - rm -f *.o bayou.elf builtin.lar - $(MAKE) -C util/pbuilder clean + rm -rf build lpbuild + +.PHONY: $(PHONY) libpayload prepare clean distclean diff --git a/payloads/bayou/bayou.h b/payloads/bayou/bayou.h index 6bf10a5..4b262af 100644 --- a/payloads/bayou/bayou.h +++ b/payloads/bayou/bayou.h @@ -17,6 +17,7 @@ #define BAYOU_H_
#include <libpayload.h> +#include <cbfs.h>
#define BAYOU_MAX_ENTRIES 10
@@ -53,7 +54,7 @@ enum bayou_params {
struct payload { struct bpt_pentry pentry; - struct larstat stat; + struct cbfs_file stat; u8 *fptr; char *params[BAYOU_PARAMS_COUNT]; }; @@ -66,9 +67,12 @@ struct bayoucfg {
extern struct bayoucfg bayoucfg;
+extern char **cbfs_filenames; +extern int cbfs_filecount; + int verify_self(u8 *ptr); int self_get_params(u8 *fptr, u8 **params); -int self_load_and_run(struct payload *p, int *ret); +int self_load_and_run(struct payload *p);
void menu(void);
@@ -78,6 +82,7 @@ struct payload *payload_get_default(void); void run_payload_timeout(struct payload *p, int timeout); void payload_parse_params(struct payload *pload, u8 *params, int len);
-int get_configuration(struct LAR *lar); +int get_configuration(struct region_device *cbfs); +int init_payload_filenames(void);
#endif diff --git a/payloads/bayou/bayou.ldscript b/payloads/bayou/bayou.ldscript deleted file mode 100644 index 86baaec..0000000 --- a/payloads/bayou/bayou.ldscript +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file is part of the bayou project. - * - * Copyright (C) 2008 Advanced Micro Devices, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -BASE_ADDRESS = 0x19000; - -OUTPUT_FORMAT(elf32-i386) -OUTPUT_ARCH(i386) - -ENTRY(_entry) - -HEAP_SIZE = 16384; -STACK_SIZE = 16384; - -SECTIONS -{ - . = BASE_ADDRESS; - - . = ALIGN(16); - _start = .; - - .text : { - *(.text._entry) - *(.text) - *(.text.*) - } - - .rodata : { - *(.rodata) - *(.rodata.*) - } - - .data : { - *(.data) - *(.data.*) - } - - _edata = .; - - .bss : { - *(.bss) - *(.bss.*) - *(COMMON) - - /* Stack and heap */ - - . = ALIGN(16); - _heap = .; - . += HEAP_SIZE; - . = ALIGN(16); - _eheap = .; - - _estack = .; - . += STACK_SIZE; - . = ALIGN(16); - _stack = .; - } - - _end = .; - - /DISCARD/ : { *(.comment) *(.note) *(.note.*) } -} diff --git a/payloads/bayou/cbfs_walker.c b/payloads/bayou/cbfs_walker.c new file mode 100644 index 0000000..0a7d9f8 --- /dev/null +++ b/payloads/bayou/cbfs_walker.c @@ -0,0 +1,90 @@ +/* + * This file is part of the bayou project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + */ + +#include "bayou.h" + +char **cbfs_filenames; +int cbfs_filecount; + +/* Functions used to walk through the CBFS and read filenames. */ +static struct cbfs_file *getfile(const struct cbfs_header *header, + struct cbfs_file *f) +{ + while (1) { + if (f < (struct cbfs_file *)(0xffffffff - + ntohl(header->romsize))) + return NULL; + if (f->magic == 0) + return NULL; + /* 8 is the max size of cbfs_file->magic */ + if (strncmp(f->magic, CBFS_FILE_MAGIC, 8) == 0) + return f; + f = (void *)f + ntohl(header->align); + } +} + +static struct cbfs_file *firstfile(const struct cbfs_header *header) +{ + return getfile(header, (void *)(0 - ntohl(header->romsize) + + ntohl(header->offset))); +} + +static struct cbfs_file *nextfile(const struct cbfs_header *header, + struct cbfs_file *f) +{ + f = (void *)f + ALIGN(ntohl(f->len) + ntohl(f->offset), + ntohl(header->align)); + + return getfile(header, f); +} + +static int check_payload(struct cbfs_file *file) +{ + char *name = file->filename; + + if (!strncmp(name, "img/", 4)) + return 1; + + return 0; +} + +int init_payload_filenames(void) +{ + const struct cbfs_header *header; + struct cbfs_file *file; + int index = 0; + + cbfs_filecount = 0; + header = get_cbfs_header(); + + if (header == CBFS_HEADER_INVALID_ADDRESS) + return -1; + + if (header->magic != ntohl(CBFS_HEADER_MAGIC)) + return -1; + + for (file = firstfile(header); file; file = nextfile(header, file)) + if (check_payload(file)) + cbfs_filecount++; + + cbfs_filenames = malloc(cbfs_filecount * sizeof(char *)); + if (!cbfs_filenames) + return -1; + + for (file = firstfile(header); file; file = nextfile(header, file)) + if (check_payload(file)) + cbfs_filenames[index++] = + strdup((const char *)file->filename); + + return 0; +} diff --git a/payloads/bayou/config.c b/payloads/bayou/config.c index ad315c8..630bfe3 100644 --- a/payloads/bayou/config.c +++ b/payloads/bayou/config.c @@ -17,7 +17,8 @@
struct bayoucfg bayoucfg;
-static int add_payload(struct LAR *lar, struct larent *larent) +/* Add the given cbfs_file/payloads to the entries in bayoucfg */ +static int add_payload(struct cbfs_file *file) { struct payload *payload; int plen; @@ -29,19 +30,15 @@ static int add_payload(struct LAR *lar, struct larent *larent)
payload = &bayoucfg.entries[bayoucfg.n_entries];
- if (strncmp((char *)larent->name, "payload/", 8)) - return -1; - - if (larstat(lar, (const char *)larent->name, &payload->stat)) - return -1; - - /* Make sure the LAR entry is valid. */ - if (!lfverify(lar, (const char *)larent->name)) + if (strncmp((char *)file->filename, "img/", 4)) { + printf("Name comparison failed!\n"); return -1; + }
/* Get a pointer to the start of the file. */ - fptr = larfptr(lar, (const char *)larent->name); + fptr = cbfs_find_file((const char *)file->filename, CBFS_TYPE_PAYLOAD);
+ printf("%s\n", file->filename); if (fptr == NULL) return -1;
@@ -52,6 +49,8 @@ static int add_payload(struct LAR *lar, struct larent *larent) payload->pentry.parent = 0; payload->pentry.type = BPT_TYPE_CHOOSER; payload->pentry.flags = 0; + strncpy((char *) payload->pentry.title, file->filename, + sizeof(payload->pentry.title));
plen = self_get_params(fptr, ¶ms); payload_parse_params(payload, params, plen); @@ -63,17 +62,19 @@ static int add_payload(struct LAR *lar, struct larent *larent) return 0; }
-static int lar_walk_files(struct LAR *lar, - int (*cb) (struct LAR *, struct larent *)) +static int cbfs_walk_files(int (*cb) (struct cbfs_file *)) { - struct larent *larent; + struct cbfs_file *file; int ret = 0;
- rewindlar(lar); + for (int i = 0; i < cbfs_filecount; i++) { + file = cbfs_find(cbfs_filenames[i]);
- while ((larent = readlar(lar)) != NULL) { - if ((ret = cb(lar, larent))) - break; + if (file != NULL) { + ret = cb(file); + if (ret) + break; + } }
return ret; @@ -83,37 +84,42 @@ static int lar_walk_files(struct LAR *lar, * If reading the bayou_payload_table fails for some reason, then construct * a dummy table. All valid payloads in the lar are added as chooser items. */ -static void build_dummy_table(struct LAR *lar) +static void build_dummy_table(void) { bayoucfg.timeout = 0xFF; bayoucfg.n_entries = 0;
- lar_walk_files(lar, add_payload); + cbfs_walk_files(add_payload); }
-int get_configuration(struct LAR *lar) +int get_configuration(struct region_device *cbfs) { - struct larstat stat; + struct cbfs_file *bpt_file; struct bpt_config *bptcfg; - u8 *fptr, *ptr; - int i; + u8 *bpt_buffer, *pt_ptr;
/* * If bayou_payload_table doesn't exist, then dummy up - * a table from the LAR contents. + * a table from the CBFS contents. */ - if (larstat(lar, "bayou_payload_table", &stat) || - !lfverify(lar, "bayou_payload_table")) - build_dummy_table(lar); + bpt_file = cbfs_find("bayou_payload_table");
- /* Open up the BPT and get the creamy goodness within. */ + if (bpt_file == NULL) { + build_dummy_table(); + return -1; + }
- fptr = larfptr(lar, "bayou_payload_table"); + /* Read the BPT and get the creamy goodness within. */
- if (fptr == NULL) - build_dummy_table(lar); + bpt_buffer = cbfs_find_file("bayou_payload_table", bpt_file->type); + + if (bpt_buffer == NULL) { + build_dummy_table(); + return -1; + }
- bptcfg = (struct bpt_config *)fptr; + /* Store the Global configuration table. */ + bptcfg = (struct bpt_config *)bpt_buffer; bayoucfg.timeout = bptcfg->timeout;
bayoucfg.n_entries = bptcfg->entries; @@ -124,37 +130,40 @@ int get_configuration(struct LAR *lar) bayoucfg.n_entries = BAYOU_MAX_ENTRIES; }
- ptr = fptr + sizeof(struct bpt_config); + /* Start keeping track of the Payload tables. */ + pt_ptr = bpt_buffer + sizeof(struct bpt_config);
- for (i = 0; i < bayoucfg.n_entries; i++) { - struct bpt_pentry *entry = (struct bpt_pentry *)ptr; + for (int i = 0; i < bayoucfg.n_entries; i++) { + struct bpt_pentry *entry = (struct bpt_pentry *)pt_ptr; struct payload *p = &(bayoucfg.entries[i]); int plen; - u8 *params = NULL; + uint8_t *params = NULL;
memcpy(&p->pentry, entry, sizeof(struct bpt_pentry));
if (entry->type != BPT_TYPE_CHAIN) { - char *lname = (char *)ptr + sizeof(struct bpt_pentry); - - if (larstat(lar, (const char *)lname, &p->stat)) - build_dummy_table(lar); + char *lname = + (char *)pt_ptr + sizeof(struct bpt_pentry); + struct cbfs_handle *payload_handle = + cbfs_get_handle(cbfs, (const char *)lname); + uint8_t *payload_ptr;
- if (!lfverify(lar, (const char *)lname)) - build_dummy_table(lar); + if (!payload_handle) + build_dummy_table();
- fptr = larfptr(lar, (const char *)lname); + payload_ptr = cbfs_get_contents(payload_handle, + (size_t *)payload_handle->content_size, 0);
- if (verify_self(fptr)) - p->fptr = fptr; + if (verify_self(payload_ptr)) + p->fptr = payload_ptr; else - build_dummy_table(lar); + build_dummy_table();
- plen = self_get_params(fptr, ¶ms); + plen = self_get_params(payload_ptr, ¶ms); payload_parse_params(p, params, plen); }
- ptr += sizeof(struct bpt_pentry) + entry->nlen; + pt_ptr += sizeof(struct bpt_pentry) + entry->nlen; }
return 0; diff --git a/payloads/bayou/lzma.c b/payloads/bayou/lzma.c deleted file mode 100644 index a7a8717..0000000 --- a/payloads/bayou/lzma.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - -Coreboot interface to memory-saving variant of LZMA decoder - -(C)opyright 2006 Carl-Daniel Hailfinger -Released under the GNU GPL v2 or later - -Parts of this file are based on C/7zip/Compress/LZMA_C/LzmaTest.c from the LZMA -SDK 4.42, which is written and distributed to public domain by Igor Pavlov. - -*/ - -#include <libpayload.h> -#include "lzmadecode.c" - -unsigned long ulzma(u8 *src, u8 *dst) -{ - unsigned char properties[LZMA_PROPERTIES_SIZE]; - UInt32 outSize; - SizeT inProcessed; - SizeT outProcessed; - int res; - CLzmaDecoderState state; - SizeT mallocneeds; - unsigned char scratchpad[15980]; - - memcpy(properties, src, LZMA_PROPERTIES_SIZE); - outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE); - if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) { - printf("Incorrect stream properties\n"); - } - mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb)); - if (mallocneeds > 15980) { - printf("Decoder scratchpad too small!\n"); - } - state.Probs = (CProb *)scratchpad; - res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed, - dst, outSize, &outProcessed); - if (res != 0) { - printf("Decoding error = %d\n", res); - } - return outSize; -} diff --git a/payloads/bayou/lzmadecode.c b/payloads/bayou/lzmadecode.c deleted file mode 100644 index b03415f..0000000 --- a/payloads/bayou/lzmadecode.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - LzmaDecode.c - LZMA Decoder (optimized for Speed version) - - LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) - http://www.7-zip.org/ - - LZMA SDK is licensed under two licenses: - 1) GNU Lesser General Public License (GNU LGPL) - 2) Common Public License (CPL) - It means that you can select one of these two licenses and - follow rules of that license. - - SPECIAL EXCEPTION: - Igor Pavlov, as the author of this Code, expressly permits you to - statically or dynamically link your Code (or bind by name) to the - interfaces of this file without subjecting your linked Code to the - terms of the CPL or GNU LGPL. Any modifications or additions - to this file, however, are subject to the LGPL or CPL terms. -*/ - -#include "lzmadecode.h" - -#define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 - -#define RC_READ_BYTE (*Buffer++) - -#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \ - { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }} - - -#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; } - -#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2 - - -#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; } - -#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound) -#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits; -#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits; - -#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \ - { UpdateBit0(p); mi <<= 1; A0; } else \ - { UpdateBit1(p); mi = (mi + mi) + 1; A1; } - -#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;) - -#define RangeDecoderBitTreeDecode(probs, numLevels, res) \ - { int i = numLevels; res = 1; \ - do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \ - res -= (1 << numLevels); } - - -#define kNumPosBitsMax 4 -#define kNumPosStatesMax (1 << kNumPosBitsMax) - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumMidBits 3 -#define kLenNumMidSymbols (1 << kLenNumMidBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) - -#define LenChoice 0 -#define LenChoice2 (LenChoice + 1) -#define LenLow (LenChoice2 + 1) -#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) -#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) -#define kNumLenProbs (LenHigh + kLenNumHighSymbols) - - -#define kNumStates 12 -#define kNumLitStates 7 - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -#define kNumPosSlotBits 6 -#define kNumLenToPosStates 4 - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) - -#define kMatchMinLen 2 - -#define IsMatch 0 -#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) -#define IsRepG0 (IsRep + kNumStates) -#define IsRepG1 (IsRepG0 + kNumStates) -#define IsRepG2 (IsRepG1 + kNumStates) -#define IsRep0Long (IsRepG2 + kNumStates) -#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) -#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) -#define LenCoder (Align + kAlignTableSize) -#define RepLenCoder (LenCoder + kNumLenProbs) -#define Literal (RepLenCoder + kNumLenProbs) - -#if Literal != LZMA_BASE_SIZE -StopCompilingDueBUG -#endif - -int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size) -{ - unsigned char prop0; - if (size < LZMA_PROPERTIES_SIZE) - return LZMA_RESULT_DATA_ERROR; - prop0 = propsData[0]; - if (prop0 >= (9 * 5 * 5)) - return LZMA_RESULT_DATA_ERROR; - { - for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5)); - for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9); - propsRes->lc = prop0; - /* - unsigned char remainder = (unsigned char)(prop0 / 9); - propsRes->lc = prop0 % 9; - propsRes->pb = remainder / 5; - propsRes->lp = remainder % 5; - */ - } - - return LZMA_RESULT_OK; -} - -#define kLzmaStreamWasFinishedId (-1) - -int LzmaDecode(CLzmaDecoderState *vs, - const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, - unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed) -{ - CProb *p = vs->Probs; - SizeT nowPos = 0; - Byte previousByte = 0; - UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1; - UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1; - int lc = vs->Properties.lc; - - - int state = 0; - UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1; - int len = 0; - const Byte *Buffer; - const Byte *BufferLim; - UInt32 Range; - UInt32 Code; - - *inSizeProcessed = 0; - *outSizeProcessed = 0; - - { - UInt32 i; - UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp)); - for (i = 0; i < numProbs; i++) - p[i] = kBitModelTotal >> 1; - } - - RC_INIT(inStream, inSize); - - - while(nowPos < outSize) - { - CProb *prob; - UInt32 bound; - int posState = (int)( - (nowPos - ) - & posStateMask); - - prob = p + IsMatch + (state << kNumPosBitsMax) + posState; - IfBit0(prob) - { - int symbol = 1; - UpdateBit0(prob) - prob = p + Literal + (LZMA_LIT_SIZE * - ((( - (nowPos - ) - & literalPosMask) << lc) + (previousByte >> (8 - lc)))); - - if (state >= kNumLitStates) - { - int matchByte; - matchByte = outStream[nowPos - rep0]; - do - { - int bit; - CProb *probLit; - matchByte <<= 1; - bit = (matchByte & 0x100); - probLit = prob + 0x100 + bit + symbol; - RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break) - } - while (symbol < 0x100); - } - while (symbol < 0x100) - { - CProb *probLit = prob + symbol; - RC_GET_BIT(probLit, symbol) - } - previousByte = (Byte)symbol; - - outStream[nowPos++] = previousByte; - if (state < 4) state = 0; - else if (state < 10) state -= 3; - else state -= 6; - } - else - { - UpdateBit1(prob); - prob = p + IsRep + state; - IfBit0(prob) - { - UpdateBit0(prob); - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - state = state < kNumLitStates ? 0 : 3; - prob = p + LenCoder; - } - else - { - UpdateBit1(prob); - prob = p + IsRepG0 + state; - IfBit0(prob) - { - UpdateBit0(prob); - prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState; - IfBit0(prob) - { - UpdateBit0(prob); - - if (nowPos == 0) - return LZMA_RESULT_DATA_ERROR; - - state = state < kNumLitStates ? 9 : 11; - previousByte = outStream[nowPos - rep0]; - outStream[nowPos++] = previousByte; - - continue; - } - else - { - UpdateBit1(prob); - } - } - else - { - UInt32 distance; - UpdateBit1(prob); - prob = p + IsRepG1 + state; - IfBit0(prob) - { - UpdateBit0(prob); - distance = rep1; - } - else - { - UpdateBit1(prob); - prob = p + IsRepG2 + state; - IfBit0(prob) - { - UpdateBit0(prob); - distance = rep2; - } - else - { - UpdateBit1(prob); - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - state = state < kNumLitStates ? 8 : 11; - prob = p + RepLenCoder; - } - { - int numBits, offset; - CProb *probLen = prob + LenChoice; - IfBit0(probLen) - { - UpdateBit0(probLen); - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - numBits = kLenNumLowBits; - } - else - { - UpdateBit1(probLen); - probLen = prob + LenChoice2; - IfBit0(probLen) - { - UpdateBit0(probLen); - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - numBits = kLenNumMidBits; - } - else - { - UpdateBit1(probLen); - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - numBits = kLenNumHighBits; - } - } - RangeDecoderBitTreeDecode(probLen, numBits, len); - len += offset; - } - - if (state < 4) - { - int posSlot; - state += kNumLitStates; - prob = p + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << - kNumPosSlotBits); - RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot); - if (posSlot >= kStartPosModelIndex) - { - int numDirectBits = ((posSlot >> 1) - 1); - rep0 = (2 | ((UInt32)posSlot & 1)); - if (posSlot < kEndPosModelIndex) - { - rep0 <<= numDirectBits; - prob = p + SpecPos + rep0 - posSlot - 1; - } - else - { - numDirectBits -= kNumAlignBits; - do - { - RC_NORMALIZE - Range >>= 1; - rep0 <<= 1; - if (Code >= Range) - { - Code -= Range; - rep0 |= 1; - } - } - while (--numDirectBits != 0); - prob = p + Align; - rep0 <<= kNumAlignBits; - numDirectBits = kNumAlignBits; - } - { - int i = 1; - int mi = 1; - do - { - CProb *prob3 = prob + mi; - RC_GET_BIT2(prob3, mi, ; , rep0 |= i); - i <<= 1; - } - while(--numDirectBits != 0); - } - } - else - rep0 = posSlot; - if (++rep0 == (UInt32)(0)) - { - /* it's for stream version */ - len = kLzmaStreamWasFinishedId; - break; - } - } - - len += kMatchMinLen; - if (rep0 > nowPos) - return LZMA_RESULT_DATA_ERROR; - - - do - { - previousByte = outStream[nowPos - rep0]; - len--; - outStream[nowPos++] = previousByte; - } - while(len != 0 && nowPos < outSize); - } - } - RC_NORMALIZE; - - - *inSizeProcessed = (SizeT)(Buffer - inStream); - *outSizeProcessed = nowPos; - return LZMA_RESULT_OK; -} diff --git a/payloads/bayou/lzmadecode.h b/payloads/bayou/lzmadecode.h deleted file mode 100644 index 3771245..0000000 --- a/payloads/bayou/lzmadecode.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - LzmaDecode.h - LZMA Decoder interface - - LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) - http://www.7-zip.org/ - - LZMA SDK is licensed under two licenses: - 1) GNU Lesser General Public License (GNU LGPL) - 2) Common Public License (CPL) - It means that you can select one of these two licenses and - follow rules of that license. - - SPECIAL EXCEPTION: - Igor Pavlov, as the author of this code, expressly permits you to - statically or dynamically link your code (or bind by name) to the - interfaces of this file without subjecting your linked code to the - terms of the CPL or GNU LGPL. Any modifications or additions - to this file, however, are subject to the LGPL or CPL terms. -*/ - -#ifndef LZMADECODE_H -#define LZMADECODE_H - -typedef unsigned char Byte; -typedef unsigned short UInt16; -typedef unsigned int UInt32; -typedef UInt32 SizeT; - -#define CProb UInt16 - -#define LZMA_RESULT_OK 0 -#define LZMA_RESULT_DATA_ERROR 1 - - -#define LZMA_BASE_SIZE 1846 -#define LZMA_LIT_SIZE 768 - -#define LZMA_PROPERTIES_SIZE 5 - -typedef struct _CLzmaProperties -{ - int lc; - int lp; - int pb; -}CLzmaProperties; - -int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size); - -#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp))) - -#define kLzmaNeedInitId (-2) - -typedef struct _CLzmaDecoderState -{ - CLzmaProperties Properties; - CProb *Probs; - - -} CLzmaDecoderState; - - -int LzmaDecode(CLzmaDecoderState *vs, - const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, - unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed); - -#endif /* LZMADECODE_H */ diff --git a/payloads/bayou/main.c b/payloads/bayou/main.c index cdccea1..3a558e3 100644 --- a/payloads/bayou/main.c +++ b/payloads/bayou/main.c @@ -17,38 +17,36 @@
static void print_banner(void) { - printf("\e[H\e[JBayou Payload Chooser v0.3\n"); + printf("Bayou Payload Chooser v0.3\n"); }
int main(void) { - extern unsigned long _binary_builtin_lar_start; - struct LAR *lar; + struct region_device cbfs;
print_banner();
- lar = openlar((void *)&_binary_builtin_lar_start); + init_payload_filenames();
- if (lar == NULL) { - printf("[CHOOSER]: Unable to scan the attached LAR file\n"); - return -1; - } +// for (int i=0;i<cbfs_filecount;i++) +// printf("Filename n%d: %s\n", i, cbfs_filenames[i]);
- get_configuration(lar); + get_configuration(&cbfs);
if (bayoucfg.n_entries == 0) { - printf("[CHOOSER]: No payloads were found in the LAR\n"); + printf("[CHOOSER]: No payloads were found in the CBFS.\n"); + halt(); return -1; }
/* - * If timeout == 0xFF, then show the menu immediately. - * If timeout is zero, then find and run the default item immediately. - * If there is no default item, then show the menu. - * If timeout is anything else, then show a message and wait for a - * keystroke. If there is no keystroke in time then run the default. - * If there is no default then show the menu. - */ + * If timeout == 0xFF, then show the menu immediately. + * If timeout is zero, then find and run the default item immediately. + * If there is no default item, then show the menu. + * If timeout is anything else, then show a message and wait for a + * keystroke. If there is no keystroke in time then run the default. + * If there is no default then show the menu. + */ if (bayoucfg.timeout != 0xFF) { struct payload *d = payload_get_default();
@@ -62,5 +60,6 @@ int main(void)
menu();
+ halt(); return 0; } diff --git a/payloads/bayou/nrv2b.c b/payloads/bayou/nrv2b.c deleted file mode 100644 index 53f7988..0000000 --- a/payloads/bayou/nrv2b.c +++ /dev/null @@ -1,86 +0,0 @@ -#include <libpayload.h> - -// This GETBIT is supposed to work on little endian -// 32bit systems. The algorithm will definitely need -// some fixing on other systems, but it might not be -// a problem since the nrv2b binary behaves the same.. - -#ifndef ENDIAN -#define ENDIAN 0 -#endif -#ifndef BITSIZE -#define BITSIZE 32 -#endif - -#define GETBIT_8(bb, src, ilen) \ - (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) - -#define GETBIT_LE16(bb, src, ilen) \ - (bb*=2,bb&0xffff ? (bb>>16)&1 : (ilen+=2,((bb=(src[ilen-2]+src[ilen-1]*256u)*2+1)>>16)&1)) -#define GETBIT_LE32(bb, src, ilen) \ - (bc > 0 ? ((bb>>--bc)&1) : (bc=31,\ - bb=*(const u32 *)((src)+ilen),ilen+=4,(bb>>31)&1)) - -#if ENDIAN == 0 && BITSIZE == 8 -#define GETBIT(bb, src, ilen) GETBIT_8(bb, src, ilen) -#endif -#if ENDIAN == 0 && BITSIZE == 16 -#define GETBIT(bb, src, ilen) GETBIT_LE16(bb, src, ilen) -#endif -#if ENDIAN == 0 && BITSIZE == 32 -#define GETBIT(bb, src, ilen) GETBIT_LE32(bb, src, ilen) -#endif - -unsigned long unrv2b(u8 *src, u8 *dst, unsigned long *ilen_p) -{ - unsigned long ilen = 0, olen = 0, last_m_off = 1; - u32 bb = 0; - unsigned bc = 0; - const u8 *m_pos; - - // skip length - src += 4; - /* FIXME: check olen with the length stored in first 4 bytes */ - - for (;;) { - unsigned int m_off, m_len; - while (GETBIT(bb, src, ilen)) { - dst[olen++] = src[ilen++]; - } - - m_off = 1; - do { - m_off = m_off * 2 + GETBIT(bb, src, ilen); - } while (!GETBIT(bb, src, ilen)); - if (m_off == 2) { - m_off = last_m_off; - } else { - m_off = (m_off - 3) * 256 + src[ilen++]; - if (m_off == 0xffffffffU) - break; - last_m_off = ++m_off; - } - - m_len = GETBIT(bb, src, ilen); - m_len = m_len * 2 + GETBIT(bb, src, ilen); - if (m_len == 0) { - m_len++; - do { - m_len = m_len * 2 + GETBIT(bb, src, ilen); - } while (!GETBIT(bb, src, ilen)); - m_len += 2; - } - m_len += (m_off > 0xd00); - - m_pos = dst + olen - m_off; - dst[olen++] = *m_pos++; - do { - dst[olen++] = *m_pos++; - } while (--m_len > 0); - } - - *ilen_p = ilen; - - return olen; - -} diff --git a/payloads/bayou/payload.c b/payloads/bayou/payload.c index a76e49f..9261b11 100644 --- a/payloads/bayou/payload.c +++ b/payloads/bayou/payload.c @@ -20,11 +20,11 @@
void run_payload(struct payload *p) { - int ret, i; + int i;
/* For chooser entries, just run the payload. */ if (p->pentry.type == BPT_TYPE_CHOOSER) { - self_load_and_run(p, &ret); + self_load_and_run(p); return; }
@@ -33,7 +33,7 @@ void run_payload(struct payload *p) struct payload *s = &(bayoucfg.entries[i]);
if (s->pentry.parent == p->pentry.index) - self_load_and_run(s, &ret); + self_load_and_run(s); } }
diff --git a/payloads/bayou/self.c b/payloads/bayou/self.c index 88e495b..8f48969 100644 --- a/payloads/bayou/self.c +++ b/payloads/bayou/self.c @@ -14,48 +14,28 @@ */
#include "bayou.h" -#include "self.h"
-static int nop_decompress(void *dst, void *src, int len) +static void cbfs_decode_payload_segment(struct cbfs_payload_segment *segment, + const struct cbfs_payload_segment *src) { - memcpy(dst, src, len); - return len; -} - -#ifdef CONFIG_LZMA -extern int ulzma(u8 *, u8 *); - -static int lzma_decompress(void *dst, void *src, int len) -{ - return ulzma((u8 *) src, (u8 *) dst); -} -#endif - -#ifdef CONFIG_NRV2B -extern int unrv2b(u8 *, u8 *, unsigned long *); - -static int nrv2b_decompress(void *dst, void *src, int len) -{ - unsigned long l = (u32) len; - return unrv2b(src, dst, &l); -} -#endif - -static int zeros_decompress(void *dst, void *src, int len) -{ - memset(dst, 0, len); - return len; + /* TODO: Convert current segment macros into BE! */ + segment->type = src->type; + segment->compression = be32toh(src->compression); + segment->offset = be32toh(src->offset); + segment->load_addr = be64toh(src->load_addr); + segment->len = be32toh(src->len); + segment->mem_len = be32toh(src->mem_len); }
int self_get_params(u8 *fptr, u8 **params) { - struct self_segment *seg = (struct self_segment *)fptr; + struct cbfs_payload_segment *seg = (struct cbfs_payload_segment *)fptr;
- while (seg->type != SELF_TYPE_ENTRY) { + while (seg->type != PAYLOAD_SEGMENT_ENTRY) { if (seg->type == 0) return -1;
- if (seg->type == SELF_TYPE_PARAMS) { + if (seg->type == PAYLOAD_SEGMENT_PARAMS) { *params = (u8 *) (fptr + seg->offset); return seg->len; } @@ -70,73 +50,60 @@ int self_get_params(u8 *fptr, u8 **params)
int verify_self(u8 *ptr) { - struct self_segment *seg = (struct self_segment *)ptr; - - switch (seg->type) { - case SELF_TYPE_CODE: - case SELF_TYPE_DATA: - case SELF_TYPE_BSS: - case SELF_TYPE_PARAMS: - case SELF_TYPE_ENTRY: + struct cbfs_payload_segment seg; + + cbfs_decode_payload_segment(&seg, (struct cbfs_payload_segment *)ptr); + + switch (seg.type) { + case PAYLOAD_SEGMENT_CODE: + case PAYLOAD_SEGMENT_DATA: + case PAYLOAD_SEGMENT_BSS: + case PAYLOAD_SEGMENT_PARAMS: + case PAYLOAD_SEGMENT_ENTRY: return 1; }
return 0; }
-int self_load_and_run(struct payload *p, int *ret) +int self_load_and_run(struct payload *p) { - struct self_segment *seg = (struct self_segment *)p->fptr; - int (*dcmp) (void *, void *, int); + struct cbfs_payload_segment *orig_seg = + (struct cbfs_payload_segment *)p->fptr; + struct cbfs_payload_segment seg; int dlen;
- switch (p->stat.compression) { -#ifdef CONFIG_LZMA - case ALGO_LZMA: - dcmp = lzma_decompress; - break; -#endif -#ifdef CONFIG_NRV2B - case ALGO_NRV2B: - dcmp = nrv2b_decompress; - break; -#endif - case ALGO_ZEROES: - dcmp = zeros_decompress; - break; - case ALGO_NONE: - dcmp = nop_decompress; - default: - printf("E: Unsupported decompression type\n"); - return -1; - } - while (1) { - u32 laddr = (u32) (seg->load_addr & 0xFFFFFFFF); + cbfs_decode_payload_segment(&seg, orig_seg);
- switch (seg->type) { - case SELF_TYPE_CODE: - case SELF_TYPE_DATA: - dlen = dcmp((void *)laddr, - (void *)p->fptr + seg->offset, seg->len); + u32 laddr = (u32) (seg.load_addr & 0xFFFFFFFF);
- if (dlen < seg->mem_len) { + switch (seg.type) { + case PAYLOAD_SEGMENT_PARAMS: + continue; + case PAYLOAD_SEGMENT_CODE: + case PAYLOAD_SEGMENT_DATA: + dlen = cbfs_decompress(seg.compression, + (void *)p->fptr + seg.offset, (void *)laddr, + seg.len); + + if (dlen < seg.mem_len) { memset((void *)(laddr + dlen), 0, - seg->mem_len - dlen); + seg.mem_len - dlen); } break;
- case SELF_TYPE_BSS: - memset((void *)laddr, 0, seg->len); + case PAYLOAD_SEGMENT_BSS: + memset((void *)laddr, 0, seg.len); break; - case SELF_TYPE_ENTRY: - *ret = exec(laddr, 0, NULL); + case PAYLOAD_SEGMENT_ENTRY: + selfboot((void *)laddr); return 0; default: break; }
- seg++; + orig_seg++; }
return -1; diff --git a/payloads/bayou/self.h b/payloads/bayou/self.h deleted file mode 100644 index a341899..0000000 --- a/payloads/bayou/self.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the bayou project. - * - * Copyright (C) 2008 Advanced Micro Devices, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * 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. - */ - -#ifndef SELF_H_ -#define SELF_H_ - -#include <libpayload.h> - -struct self_segment { - u32 type; - u32 offset; - u64 load_addr; - u32 len; - u32 mem_len; -}; - -struct self { - struct larstat stat; - void *fptr; -}; - -#define SELF_TYPE_CODE 0x45444F43 -#define SELF_TYPE_DATA 0x41544144 -#define SELF_TYPE_BSS 0x20535342 -#define SELF_TYPE_PARAMS 0x41524150 -#define SELF_TYPE_ENTRY 0x52544E45 - -#endif diff --git a/payloads/libpayload/configs/config.bayou b/payloads/libpayload/configs/config.bayou new file mode 100644 index 0000000..80b8370 --- /dev/null +++ b/payloads/libpayload/configs/config.bayou @@ -0,0 +1,11 @@ +# CONFIG_LP_MULTIBOOT is not set +CONFIG_LP_TINYCURSES=y +CONFIG_LP_COREBOOT_VIDEO_CONSOLE=y +CONFIG_LP_USB=y +CONFIG_LP_USB_UHCI=y +CONFIG_LP_USB_OHCI=y +CONFIG_LP_USB_EHCI=y +CONFIG_LP_USB_XHCI=y +CONFIG_LP_BASE_ADDRESS=0x19000 +CONFIG_LP_HEAP_SIZE=16384 +CONFIG_LP_STACK_SIZE=16384