blob: 32f80e1f34a980a58c70bdf007bc515fd497b2c4 [file] [log] [blame]
Aaron Durbinbdf913a2014-02-24 14:56:34 -06001/*
2 * This file is part of the coreboot project.
3 *
Aaron Durbin04654a22015-03-17 11:43:44 -05004 * Copyright 2015 Google Inc.
Aaron Durbinbdf913a2014-02-24 14:56:34 -06005 *
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 Durbin04654a22015-03-17 11:43:44 -050019#ifndef PROGRAM_LOADING_H
20#define PROGRAM_LOADING_H
Aaron Durbinbdf913a2014-02-24 14:56:34 -060021
22#include <stdint.h>
23#include <stddef.h>
24
Aaron Durbind1b0e872015-03-17 13:17:06 -050025/************************
26 * ROMSTAGE LOADING *
27 ************************/
28
29/* Run romstage from bootblock. */
30void run_romstage(void);
Aaron Durbin04654a22015-03-17 11:43:44 -050031
32/************************
33 * RAMSTAGE LOADING *
34 ************************/
35
36struct cbmem_entry;
37
38/* Run ramstage from romstage. */
39void run_ramstage(void);
40
41struct 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 Durbine58a24b2014-02-24 22:11:45 -060051struct buffer_area {
Aaron Durbinbdf913a2014-02-24 14:56:34 -060052 void *data;
53 size_t size;
54};
55
56struct payload {
57 const char *name;
Aaron Durbine58a24b2014-02-24 22:11:45 -060058 struct buffer_area backing_store;
59 /* Used when payload wants memory coreboot ramstage is running at. */
60 struct buffer_area bounce;
Aaron Durbinbdf913a2014-02-24 14:56:34 -060061 void *entry;
62};
63
64/*
65 * Load payload into memory and return pointer to payload structure. Returns
66 * NULL on error.
67 */
68struct payload *payload_load(void);
69
70/* Run the loaded payload. */
71void payload_run(const struct payload *payload);
72
Aaron Durbinc34713d2014-02-25 20:36:56 -060073/* Mirror the payload to be loaded. */
74void mirror_payload(struct payload *payload);
75
Aaron Durbin7d1996c2014-02-24 22:27:39 -060076/* architecture specific function to run payload. */
77void arch_payload_run(const struct payload *payload);
78
Aaron Durbinbdf913a2014-02-24 14:56:34 -060079/* Payload loading operations. */
80struct 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 Durbinceebc052014-02-25 00:21:10 -060090void *selfload(struct payload *payload);
Aaron Durbinbdf913a2014-02-24 14:56:34 -060091
Aaron Durbin04654a22015-03-17 11:43:44 -050092
93#endif /* PROGRAM_LOADING_H */