Hung-Te Lin | d01d036 | 2013-01-25 12:42:40 +0800 | [diff] [blame] | 1 | /* |
| 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. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 23 | * Foundation, Inc. |
Hung-Te Lin | d01d036 | 2013-01-25 12:42:40 +0800 | [diff] [blame] | 24 | * --------------------------------------------------------------------------- |
| 25 | * Redistribution and use in source and binary forms, with or without |
| 26 | * modification, are permitted provided that the following conditions |
| 27 | * are met: |
| 28 | * 1. Redistributions of source code must retain the above copyright |
| 29 | * notice, this list of conditions and the following disclaimer. |
| 30 | * 2. Redistributions in binary form must reproduce the above copyright |
| 31 | * notice, this list of conditions and the following disclaimer in the |
| 32 | * documentation and/or other materials provided with the distribution. |
| 33 | * 3. The name of the author may not be used to endorse or promote products |
| 34 | * derived from this software without specific prior written permission. |
| 35 | * |
| 36 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 37 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 39 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 40 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 41 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 42 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 44 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 45 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 46 | * SUCH DAMAGE. |
| 47 | * --------------------------------------------------------------------------- |
| 48 | */ |
Stefan Reinauer | 8af0d03 | 2012-12-14 13:05:21 -0800 | [diff] [blame] | 49 | |
Hung-Te Lin | d01d036 | 2013-01-25 12:42:40 +0800 | [diff] [blame] | 50 | #ifndef _CBFS_H_ |
| 51 | #define _CBFS_H_ |
| 52 | |
| 53 | #include <cbfs_core.h> |
| 54 | |
| 55 | /* legacy APIs */ |
| 56 | const struct cbfs_header *get_cbfs_header(void); |
| 57 | struct cbfs_file *cbfs_find(const char *name); |
| 58 | void *cbfs_find_file(const char *name, int type); |
| 59 | |
| 60 | int cbfs_execute_stage(struct cbfs_media *media, const char *name); |
| 61 | void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor, |
Daisuke Nojiri | d66f1da | 2015-07-09 15:07:45 -0700 | [diff] [blame^] | 62 | uint16_t device); |
Hung-Te Lin | d01d036 | 2013-01-25 12:42:40 +0800 | [diff] [blame] | 63 | void *cbfs_load_payload(struct cbfs_media *media, const char *name); |
| 64 | void *cbfs_load_stage(struct cbfs_media *media, const char *name); |
| 65 | |
| 66 | /* Simple buffer for streaming media. */ |
| 67 | struct cbfs_simple_buffer { |
| 68 | char *buffer; |
| 69 | size_t allocated; |
| 70 | size_t size; |
| 71 | size_t last_allocate; |
| 72 | }; |
| 73 | |
| 74 | void *cbfs_simple_buffer_map(struct cbfs_simple_buffer *buffer, |
| 75 | struct cbfs_media *media, |
| 76 | size_t offset, size_t count); |
| 77 | |
| 78 | void *cbfs_simple_buffer_unmap(struct cbfs_simple_buffer *buffer, |
| 79 | const void *address); |
| 80 | |
| 81 | // Utility functions |
| 82 | int run_address(void *f); |
| 83 | |
Hung-Te Lin | d01d036 | 2013-01-25 12:42:40 +0800 | [diff] [blame] | 84 | /* Defined in individual arch / board implementation. */ |
| 85 | int init_default_cbfs_media(struct cbfs_media *media); |
| 86 | |
Stefan Reinauer | 8af0d03 | 2012-12-14 13:05:21 -0800 | [diff] [blame] | 87 | #endif |