blob: 9ef827d0e00273df09e72eb6b12778dbaa85858b [file] [log] [blame]
Uwe Hermann7eb845e2008-11-02 17:01:06 +00001/*
2 * lar - lightweight archiver
3 *
4 * Copyright (C) 2006 coresystems GmbH
5 * (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH)
6 * Copyright (C) 2007 Patrick Georgi <patrick@georgi-clan.de>
7 *
8 * This file is dual-licensed. You can choose between:
9 * - The GNU GPL, version 2, as published by the Free Software Foundation
10 * - The revised BSD license (without advertising clause)
11 *
12 * ---------------------------------------------------------------------------
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; version 2 of the License.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
25 * ---------------------------------------------------------------------------
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * 3. The name of the author may not be used to endorse or promote products
35 * derived from this software without specific prior written permission.
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
38 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 * ---------------------------------------------------------------------------
49 */
50
51#include <stdio.h>
52#include <stdint.h>
53
54#define MAGIC "LARCHIVE"
55#define MAX_PATHLEN 1024
56#define BOOTBLOCK_SIZE 20480
57
58#define BOOTBLOCK_NAME "bootblock"
59#define BOOTBLOCK_NAME_LEN 16
60
61typedef uint64_t u64;
62typedef int64_t s64;
63typedef uint32_t u32;
64typedef int32_t s32;
65typedef uint8_t u8;
66
67/* NOTE -- This and the coreboot lar.h may NOT be in sync. Be careful. */
68struct lar_header {
69 char magic[8];
70 u32 len;
71 u32 reallen;
72 u32 checksum;
73 u32 compchecksum;
74 /* Filenames are limited to 2^31-1-sizeof(lar_header)-1 bytes.
75 * "Nobody will ever need more than 640k" */
76 u32 offset;
77 /* Compression:
78 * 0 = no compression
79 * 1 = lzma
80 * 2 = nrv2b
81 * 3 = zeroes
82 */
83 u32 compression;
84 u64 entry;
85 u64 loadaddress;
86};
87
88enum compalgo {
89 ALGO_NONE = 0,
90 ALGO_LZMA = 1,
91 ALGO_NRV2B = 2,
92 ALGO_ZEROES = 3,
93 /* invalid should always be the last entry. */
94 ALGO_INVALID
95};