blob: 801bdfc2d71c56fefd4321f432270b983e5b79d7 [file] [log] [blame]
Hung-Te Lind01d0362013-01-25 12:42:40 +08001/*
2 * This file is part of the libpayload project.
3 *
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 * Copyright (C) 2013 Google, Inc.
6 *
7 * This file is dual-licensed. You can choose between:
8 * - The GNU GPL, version 2, as published by the Free Software Foundation
9 * - The revised BSD license (without advertising clause)
10 *
11 * ---------------------------------------------------------------------------
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2 of the License.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
Hung-Te Lind01d0362013-01-25 12:42:40 +080020 * ---------------------------------------------------------------------------
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * 3. The name of the author may not be used to endorse or promote products
30 * derived from this software without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 * ---------------------------------------------------------------------------
44 */
Stefan Reinauer8af0d032012-12-14 13:05:21 -080045
Hung-Te Lind01d0362013-01-25 12:42:40 +080046#ifndef _CBFS_H_
47#define _CBFS_H_
48
49#include <cbfs_core.h>
50
51/* legacy APIs */
52const struct cbfs_header *get_cbfs_header(void);
53struct cbfs_file *cbfs_find(const char *name);
54void *cbfs_find_file(const char *name, int type);
55
56int cbfs_execute_stage(struct cbfs_media *media, const char *name);
57void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor,
Daisuke Nojirid66f1da2015-07-09 15:07:45 -070058 uint16_t device);
Hung-Te Lind01d0362013-01-25 12:42:40 +080059void *cbfs_load_payload(struct cbfs_media *media, const char *name);
60void *cbfs_load_stage(struct cbfs_media *media, const char *name);
61
62/* Simple buffer for streaming media. */
63struct cbfs_simple_buffer {
64 char *buffer;
65 size_t allocated;
66 size_t size;
67 size_t last_allocate;
68};
69
70void *cbfs_simple_buffer_map(struct cbfs_simple_buffer *buffer,
71 struct cbfs_media *media,
72 size_t offset, size_t count);
73
74void *cbfs_simple_buffer_unmap(struct cbfs_simple_buffer *buffer,
75 const void *address);
76
77// Utility functions
78int run_address(void *f);
79
Hung-Te Lind01d0362013-01-25 12:42:40 +080080/* Defined in individual arch / board implementation. */
81int init_default_cbfs_media(struct cbfs_media *media);
82
Stefan Reinauer8af0d032012-12-14 13:05:21 -080083#endif