mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
The system will default to old behaviour. See Kconfig in the root. I still wish to kill ELF mode very soon, however. LAR is a very capable format. With two simple extensions, we can use LAR to replace all that we are using ELF for now. This change can really make life better: 1. we can use streaming decompress instead of the current "uncompress elf to memory and then copy segments" approach. So we can get rid of THIS hardcode: #define UNCOMPRESS_AREA (0x400000) 2. A simple lar l can show ALL segments, including payload segments 3. It's really easy to see where things will go in memory, and catch problems 4. We can figure out an ELF input file is bogus BEFORE we flash, not AFTER we flash and try to boot it 5. did I mention streaming decompress? 6. We no longer have to worry about where we decompress the elf in memory (this problem was causing trouble when the payload was a linux kernel -- it was so big) 7. Since we have a load address, we can create this lar entry: normal/cmdline and specify that it be loaded at a place where linux will find it as the cmdline. 8. The decision on whether to XIP can be made in the LAR entry, not in hardcode. For example, if initram needs to be XIP, set the load address to 0xffffffff. Done. The change is simple. Add a load address and entry point to the lar header. Extend the lar tool to parse the elf file and create multiple lar segments. It looks like this: normal/payload0 (33192 bytes, lzma compressed to 18088 bytes @0x38 load @0x100000, entry 0x105258) normal/payload1 (72 bytes, lzma compressed to 47 bytes @0x4718 load @0x1225a0, entry 0x105258) normal/option_table (932 bytes @0x4798 load @0, entry 0) normal/stage2 (33308 bytes, lzma compressed to 15474 bytes @0x4b78 load @0, entry 0) normal/initram (4208 bytes @0x8828 load @0, entry 0) linuxbios.bootblock (16384 bytes @0xfc000 load @0, entry 0) note that the payload is now payload/segment0, payload/segment1, etc. I've extended linuxbios to look for these. Note that you can now see all the things that get loaded ;they're no longer hidden in an ELF header somewhere. Elf failures are gone! Note that I've left legacy elf support in, for now, but recommend we get rid of it as soon as possible. patch attached. This is a first pass. lar.c needs some refactoring but I want to get the cmdline going. You can now have a linux payload and it will uncompress with no problems. This has been tested with filo and BOCHS. This patch includes ONLY the lar changes, the other changes are next. Signed-off-by: Ronald G. Minnich <rminnich@gmail.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@481 f3766cd6-281f-0410-b1cd-43a5c92072e9
90 lines
2.7 KiB
C
90 lines
2.7 KiB
C
/*
|
|
* lar - LinuxBIOS archiver
|
|
*
|
|
* Copyright (C) 2006-2007 coresystems GmbH
|
|
* (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH)
|
|
*
|
|
* 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; version 2 of the License.
|
|
*
|
|
* 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef __LAR_LIB_H
|
|
#define __LAR_LIB_H
|
|
|
|
/* data types */
|
|
|
|
struct file {
|
|
char *name;
|
|
struct file *next;
|
|
};
|
|
|
|
enum {
|
|
NONE,
|
|
ADD,
|
|
CREATE,
|
|
LIST,
|
|
EXTRACT
|
|
} larmodes;
|
|
|
|
/* prototypes for lar.c functions */
|
|
int verbose(void);
|
|
int elfparse(void);
|
|
long get_larsize(void);
|
|
char *get_bootblock(void);
|
|
|
|
/* prototypes for lib.c functions */
|
|
int mkdirp_below(const char *parent, const char *dirpath, mode_t mode);
|
|
|
|
int add_files(const char *name);
|
|
int add_file_or_directory(const char *name);
|
|
|
|
struct file *get_files(void);
|
|
void free_files(void);
|
|
|
|
/* Prototypes for ELF functions */
|
|
int iself(char *filebuf);
|
|
|
|
/* Prototypes for in-memory LAR operations */
|
|
int lar_process_name(char *name, char **pfilename, char **ppathname,
|
|
enum compalgo *thisalgo);
|
|
u32 lar_compress(char *ptr, ssize_t size, char *temp, enum compalgo *thisalgo);
|
|
int lar_add_entry(struct lar *lar, char *pathname, void *data,
|
|
u32 complen, u32 reallen, u32 loadaddress, u32 entry,
|
|
enum compalgo thisalgo);
|
|
/* Prototypes for the LAR I/O functions */
|
|
char *mapfile(char *filename, u32 *size);
|
|
struct lar * lar_new_archive(const char *archive, unsigned int size);
|
|
struct lar * lar_open_archive(const char *archive);
|
|
void lar_close_archive(struct lar *lar);
|
|
|
|
void lar_list_files(struct lar *lar, struct file *files);
|
|
int lar_add_file(struct lar *lar, char *name);
|
|
int lar_add_bootblock(struct lar *lar, const char *bootblock);
|
|
int lar_extract_files(struct lar *lar, struct file *files);
|
|
|
|
/* prototypes for extract.c functions */
|
|
int extract_lar(const char *archivename, struct file *files);
|
|
|
|
/* prototypes for list.c functions */
|
|
int list_lar(const char *archivename, struct file *files);
|
|
|
|
/* prototypes for create.c functions */
|
|
int create_lar(const char *archivename, struct file *files);
|
|
|
|
/* prototypes for bootblock.c functions */
|
|
extern char *bootblock_code;
|
|
extern int bootblock_len;
|
|
|
|
int load_bootblock(const char *bootblock);
|
|
int fixup_bootblock(void);
|
|
#endif
|