blob: 8ceebc12d45658c2e808608259cc0c2d72c2dce0 [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 Durbin04654a22015-03-17 11:43:44 -050025
26/************************
27 * RAMSTAGE LOADING *
28 ************************/
29
30struct cbmem_entry;
31
32/* Run ramstage from romstage. */
33void run_ramstage(void);
34
35struct 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 Durbine58a24b2014-02-24 22:11:45 -060045struct buffer_area {
Aaron Durbinbdf913a2014-02-24 14:56:34 -060046 void *data;
47 size_t size;
48};
49
50struct payload {
51 const char *name;
Aaron Durbine58a24b2014-02-24 22:11:45 -060052 struct buffer_area backing_store;
53 /* Used when payload wants memory coreboot ramstage is running at. */
54 struct buffer_area bounce;
Aaron Durbinbdf913a2014-02-24 14:56:34 -060055 void *entry;
56};
57
58/*
59 * Load payload into memory and return pointer to payload structure. Returns
60 * NULL on error.
61 */
62struct payload *payload_load(void);
63
64/* Run the loaded payload. */
65void payload_run(const struct payload *payload);
66
Aaron Durbinc34713d2014-02-25 20:36:56 -060067/* Mirror the payload to be loaded. */
68void mirror_payload(struct payload *payload);
69
Aaron Durbin7d1996c2014-02-24 22:27:39 -060070/* architecture specific function to run payload. */
71void arch_payload_run(const struct payload *payload);
72
Aaron Durbinbdf913a2014-02-24 14:56:34 -060073/* Payload loading operations. */
74struct 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 Durbinceebc052014-02-25 00:21:10 -060084void *selfload(struct payload *payload);
Aaron Durbinbdf913a2014-02-24 14:56:34 -060085
Aaron Durbin04654a22015-03-17 11:43:44 -050086
87#endif /* PROGRAM_LOADING_H */