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. |
Ionela Voinescu | 00903e5 | 2015-01-09 13:14:20 +0000 | [diff] [blame] | 5 | * Copyright (C) 2014 Imagination Technologies |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 20 | #ifndef PROGRAM_LOADING_H |
| 21 | #define PROGRAM_LOADING_H |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 22 | |
| 23 | #include <stdint.h> |
| 24 | #include <stddef.h> |
| 25 | |
Ionela Voinescu | 00903e5 | 2015-01-09 13:14:20 +0000 | [diff] [blame] | 26 | /* For each segment of a program loaded this function is called*/ |
| 27 | void arch_program_segment_loaded(uintptr_t start, size_t size); |
| 28 | |
| 29 | /* Upon completion of loading a program this function is called */ |
| 30 | void arch_program_loaded(void); |
| 31 | |
Aaron Durbin | d1b0e87 | 2015-03-17 13:17:06 -0500 | [diff] [blame] | 32 | /************************ |
| 33 | * ROMSTAGE LOADING * |
| 34 | ************************/ |
| 35 | |
| 36 | /* Run romstage from bootblock. */ |
| 37 | void run_romstage(void); |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 38 | |
| 39 | /************************ |
| 40 | * RAMSTAGE LOADING * |
| 41 | ************************/ |
| 42 | |
| 43 | struct cbmem_entry; |
| 44 | |
| 45 | /* Run ramstage from romstage. */ |
| 46 | void run_ramstage(void); |
| 47 | |
| 48 | struct ramstage_loader_ops { |
| 49 | const char *name; |
| 50 | void *(*load)(uint32_t cbmem_id, const char *name, |
| 51 | const struct cbmem_entry **cbmem_entry); |
| 52 | }; |
| 53 | |
| 54 | /*********************** |
| 55 | * PAYLOAD LOADING * |
| 56 | ***********************/ |
| 57 | |
Aaron Durbin | e58a24b | 2014-02-24 22:11:45 -0600 | [diff] [blame] | 58 | struct buffer_area { |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 59 | void *data; |
| 60 | size_t size; |
| 61 | }; |
| 62 | |
| 63 | struct payload { |
| 64 | const char *name; |
Aaron Durbin | e58a24b | 2014-02-24 22:11:45 -0600 | [diff] [blame] | 65 | struct buffer_area backing_store; |
| 66 | /* Used when payload wants memory coreboot ramstage is running at. */ |
| 67 | struct buffer_area bounce; |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 68 | void *entry; |
| 69 | }; |
| 70 | |
| 71 | /* |
| 72 | * Load payload into memory and return pointer to payload structure. Returns |
| 73 | * NULL on error. |
| 74 | */ |
| 75 | struct payload *payload_load(void); |
| 76 | |
| 77 | /* Run the loaded payload. */ |
| 78 | void payload_run(const struct payload *payload); |
| 79 | |
Aaron Durbin | c34713d | 2014-02-25 20:36:56 -0600 | [diff] [blame] | 80 | /* Mirror the payload to be loaded. */ |
| 81 | void mirror_payload(struct payload *payload); |
| 82 | |
Aaron Durbin | 7d1996c | 2014-02-24 22:27:39 -0600 | [diff] [blame] | 83 | /* architecture specific function to run payload. */ |
| 84 | void arch_payload_run(const struct payload *payload); |
| 85 | |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 86 | /* Payload loading operations. */ |
| 87 | struct payload_loader_ops { |
| 88 | const char *name; |
| 89 | /* |
| 90 | * Fill in payload_backing_store structure. Return 0 on success, < 0 |
| 91 | * on failure. |
| 92 | */ |
| 93 | int (*locate)(struct payload *payload); |
| 94 | }; |
| 95 | |
| 96 | /* Defined in src/lib/selfboot.c */ |
Aaron Durbin | ceebc05 | 2014-02-25 00:21:10 -0600 | [diff] [blame] | 97 | void *selfload(struct payload *payload); |
Aaron Durbin | bdf913a | 2014-02-24 14:56:34 -0600 | [diff] [blame] | 98 | |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 99 | |
| 100 | #endif /* PROGRAM_LOADING_H */ |