Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / romfs / tools / cfgparse.h
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12 #ifndef CFGPARSE_H
13 #define CFGPARSE_H
14
15 #include <byteswap.h>
16 #include <endian.h>
17
18 #if __BYTE_ORDER == __BIG_ENDIAN
19 #define cpu_to_be64(x)  (x)
20 #else
21 #define cpu_to_be64(x)  bswap_64(x)
22 #endif
23
24 struct ffs_chain_t {
25         int count;
26         unsigned int romfs_size;
27         struct ffs_header_t *first;
28 };
29
30 #define FLAG_LLFW 1             /* low level firmware at fix offs in romfs */
31
32 #define needs_fix_offset(hdr) ((hdr)->flags & FLAG_LLFW)
33
34 struct ffs_header_t {
35         unsigned long long flags;
36         unsigned long long romaddr;
37         char *token;
38         char *imagefile;
39         int imagefile_length;
40         struct ffs_header_t *linked_to;
41         struct ffs_header_t *next;
42         unsigned long long save_data;
43         unsigned long long save_data_len;
44         int save_data_valid;
45
46         unsigned long long addr;        /* tmp */
47         int hdrsize;            /* tmp */
48         int tokensize;          /* tmp */
49         int ffsize;             /* tmp */
50 };
51
52 void dump_fs_contents(struct ffs_chain_t *chain);
53 void find_duplicates(struct ffs_chain_t *chain);
54 void free_chain_memory(struct ffs_chain_t *chain);
55
56 int read_config(int conf_file, struct ffs_chain_t *ffs_chain);
57 int reorder_ffs_chain(struct ffs_chain_t *fs);
58 int build_ffs(struct ffs_chain_t *fs, const char *outfile, int notime);
59 #endif