Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | #ifndef PAYLOAD_LOADER_H |
| 20 | #define PAYLOAD_LOADER_H |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | #include <stddef.h> |
| 24 | |
Aaron Durbin | e58a24b | 2014-02-24 22:11:45 -0600 | [diff] [blame] | 25 | struct buffer_area { |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 26 | void *data; |
| 27 | size_t size; |
| 28 | }; |
| 29 | |
| 30 | struct payload { |
| 31 | const char *name; |
Aaron Durbin | e58a24b | 2014-02-24 22:11:45 -0600 | [diff] [blame] | 32 | struct buffer_area backing_store; |
| 33 | /* Used when payload wants memory coreboot ramstage is running at. */ |
| 34 | struct buffer_area bounce; |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 35 | void *entry; |
| 36 | }; |
| 37 | |
| 38 | /* |
| 39 | * Load payload into memory and return pointer to payload structure. Returns |
| 40 | * NULL on error. |
| 41 | */ |
| 42 | struct payload *payload_load(void); |
| 43 | |
| 44 | /* Run the loaded payload. */ |
| 45 | void payload_run(const struct payload *payload); |
| 46 | |
Aaron Durbin | 7d1996c | 2014-02-24 22:27:39 -0600 | [diff] [blame] | 47 | /* architecture specific function to run payload. */ |
| 48 | void arch_payload_run(const struct payload *payload); |
| 49 | |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 50 | /* Payload loading operations. */ |
| 51 | struct payload_loader_ops { |
| 52 | const char *name; |
| 53 | /* |
| 54 | * Fill in payload_backing_store structure. Return 0 on success, < 0 |
| 55 | * on failure. |
| 56 | */ |
| 57 | int (*locate)(struct payload *payload); |
| 58 | }; |
| 59 | |
| 60 | /* Defined in src/lib/selfboot.c */ |
Aaron Durbin | ceebc05 | 2014-02-25 00:21:10 -0600 | [diff] [blame^] | 61 | void *selfload(struct payload *payload); |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 62 | |
| 63 | #endif /* PAYLOAD_LOADER_H */ |