Uwe Hermann | 7eb845e | 2008-11-02 17:01:06 +0000 | [diff] [blame] | 1 | /* |
| 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. |
Uwe Hermann | 7eb845e | 2008-11-02 17:01:06 +0000 | [diff] [blame] | 21 | * --------------------------------------------------------------------------- |
| 22 | * Redistribution and use in source and binary forms, with or without |
| 23 | * modification, are permitted provided that the following conditions |
| 24 | * are met: |
| 25 | * 1. Redistributions of source code must retain the above copyright |
| 26 | * notice, this list of conditions and the following disclaimer. |
| 27 | * 2. Redistributions in binary form must reproduce the above copyright |
| 28 | * notice, this list of conditions and the following disclaimer in the |
| 29 | * documentation and/or other materials provided with the distribution. |
| 30 | * 3. The name of the author may not be used to endorse or promote products |
| 31 | * derived from this software without specific prior written permission. |
| 32 | * |
| 33 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 34 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 35 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 36 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 37 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 38 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 39 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 40 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 41 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 42 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 43 | * SUCH DAMAGE. |
| 44 | * --------------------------------------------------------------------------- |
| 45 | */ |
| 46 | |
| 47 | #include <stdio.h> |
| 48 | #include <stdint.h> |
| 49 | |
| 50 | #define MAGIC "LARCHIVE" |
| 51 | #define MAX_PATHLEN 1024 |
| 52 | #define BOOTBLOCK_SIZE 20480 |
| 53 | |
| 54 | #define BOOTBLOCK_NAME "bootblock" |
| 55 | #define BOOTBLOCK_NAME_LEN 16 |
| 56 | |
| 57 | typedef uint64_t u64; |
| 58 | typedef int64_t s64; |
| 59 | typedef uint32_t u32; |
| 60 | typedef int32_t s32; |
| 61 | typedef uint8_t u8; |
| 62 | |
| 63 | /* NOTE -- This and the coreboot lar.h may NOT be in sync. Be careful. */ |
| 64 | struct lar_header { |
| 65 | char magic[8]; |
| 66 | u32 len; |
| 67 | u32 reallen; |
| 68 | u32 checksum; |
| 69 | u32 compchecksum; |
| 70 | /* Filenames are limited to 2^31-1-sizeof(lar_header)-1 bytes. |
| 71 | * "Nobody will ever need more than 640k" */ |
| 72 | u32 offset; |
| 73 | /* Compression: |
| 74 | * 0 = no compression |
| 75 | * 1 = lzma |
| 76 | * 2 = nrv2b |
| 77 | * 3 = zeroes |
| 78 | */ |
| 79 | u32 compression; |
| 80 | u64 entry; |
| 81 | u64 loadaddress; |
| 82 | }; |
| 83 | |
| 84 | enum compalgo { |
| 85 | ALGO_NONE = 0, |
| 86 | ALGO_LZMA = 1, |
| 87 | ALGO_NRV2B = 2, |
| 88 | ALGO_ZEROES = 3, |
| 89 | /* invalid should always be the last entry. */ |
| 90 | ALGO_INVALID |
| 91 | }; |