Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 4 | * Copyright 2015 Google Inc. |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 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 | */ |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 19 | #ifndef PROGRAM_LOADING_H |
| 20 | #define PROGRAM_LOADING_H |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 21 | |
| 22 | #include <stdint.h> |
| 23 | #include <stddef.h> |
| 24 | |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 25 | |
| 26 | /************************ |
| 27 | * RAMSTAGE LOADING * |
| 28 | ************************/ |
| 29 | |
| 30 | struct cbmem_entry; |
| 31 | |
| 32 | /* Run ramstage from romstage. */ |
| 33 | void run_ramstage(void); |
| 34 | |
| 35 | struct ramstage_loader_ops { |
| 36 | const char *name; |
| 37 | void *(*load)(uint32_t cbmem_id, const char *name, |
| 38 | const struct cbmem_entry **cbmem_entry); |
| 39 | }; |
| 40 | |
| 41 | /*********************** |
| 42 | * PAYLOAD LOADING * |
| 43 | ***********************/ |
| 44 | |
Aaron Durbin | e58a24b | 2014-02-24 22:11:45 -0600 | [diff] [blame] | 45 | struct buffer_area { |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 46 | void *data; |
| 47 | size_t size; |
| 48 | }; |
| 49 | |
| 50 | struct payload { |
| 51 | const char *name; |
Aaron Durbin | e58a24b | 2014-02-24 22:11:45 -0600 | [diff] [blame] | 52 | struct buffer_area backing_store; |
| 53 | /* Used when payload wants memory coreboot ramstage is running at. */ |
| 54 | struct buffer_area bounce; |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 55 | void *entry; |
| 56 | }; |
| 57 | |
| 58 | /* |
| 59 | * Load payload into memory and return pointer to payload structure. Returns |
| 60 | * NULL on error. |
| 61 | */ |
| 62 | struct payload *payload_load(void); |
| 63 | |
| 64 | /* Run the loaded payload. */ |
| 65 | void payload_run(const struct payload *payload); |
| 66 | |
Aaron Durbin | c34713d | 2014-02-25 20:36:56 -0600 | [diff] [blame] | 67 | /* Mirror the payload to be loaded. */ |
| 68 | void mirror_payload(struct payload *payload); |
| 69 | |
Aaron Durbin | 7d1996c | 2014-02-24 22:27:39 -0600 | [diff] [blame] | 70 | /* architecture specific function to run payload. */ |
| 71 | void arch_payload_run(const struct payload *payload); |
| 72 | |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 73 | /* Payload loading operations. */ |
| 74 | struct payload_loader_ops { |
| 75 | const char *name; |
| 76 | /* |
| 77 | * Fill in payload_backing_store structure. Return 0 on success, < 0 |
| 78 | * on failure. |
| 79 | */ |
| 80 | int (*locate)(struct payload *payload); |
| 81 | }; |
| 82 | |
| 83 | /* Defined in src/lib/selfboot.c */ |
Aaron Durbin | ceebc05 | 2014-02-25 00:21:10 -0600 | [diff] [blame] | 84 | void *selfload(struct payload *payload); |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 85 | |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 86 | |
| 87 | #endif /* PROGRAM_LOADING_H */ |