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