blob: 21d2c1eaf23424de6cc71153a4ddec36cf7a8e18 [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.
Ionela Voinescu00903e52015-01-09 13:14:20 +00005 * Copyright (C) 2014 Imagination Technologies
Aaron Durbinbdf913a2014-02-24 14:56:34 -06006 *
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 Durbin04654a22015-03-17 11:43:44 -050020#ifndef PROGRAM_LOADING_H
21#define PROGRAM_LOADING_H
Aaron Durbinbdf913a2014-02-24 14:56:34 -060022
23#include <stdint.h>
24#include <stddef.h>
25
Ionela Voinescu00903e52015-01-09 13:14:20 +000026/* For each segment of a program loaded this function is called*/
27void arch_program_segment_loaded(uintptr_t start, size_t size);
28
29/* Upon completion of loading a program this function is called */
30void arch_program_loaded(void);
31
Aaron Durbind1b0e872015-03-17 13:17:06 -050032/************************
33 * ROMSTAGE LOADING *
34 ************************/
35
36/* Run romstage from bootblock. */
37void run_romstage(void);
Aaron Durbin04654a22015-03-17 11:43:44 -050038
39/************************
40 * RAMSTAGE LOADING *
41 ************************/
42
43struct cbmem_entry;
44
45/* Run ramstage from romstage. */
46void run_ramstage(void);
47
48struct 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 Durbine58a24b2014-02-24 22:11:45 -060058struct buffer_area {
Aaron Durbinbdf913a2014-02-24 14:56:34 -060059 void *data;
60 size_t size;
61};
62
63struct payload {
64 const char *name;
Aaron Durbine58a24b2014-02-24 22:11:45 -060065 struct buffer_area backing_store;
66 /* Used when payload wants memory coreboot ramstage is running at. */
67 struct buffer_area bounce;
Aaron Durbinbdf913a2014-02-24 14:56:34 -060068 void *entry;
69};
70
71/*
72 * Load payload into memory and return pointer to payload structure. Returns
73 * NULL on error.
74 */
75struct payload *payload_load(void);
76
77/* Run the loaded payload. */
78void payload_run(const struct payload *payload);
79
Aaron Durbinc34713d2014-02-25 20:36:56 -060080/* Mirror the payload to be loaded. */
81void mirror_payload(struct payload *payload);
82
Aaron Durbin7d1996c2014-02-24 22:27:39 -060083/* architecture specific function to run payload. */
84void arch_payload_run(const struct payload *payload);
85
Aaron Durbinbdf913a2014-02-24 14:56:34 -060086/* Payload loading operations. */
87struct 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 Durbinceebc052014-02-25 00:21:10 -060097void *selfload(struct payload *payload);
Aaron Durbinbdf913a2014-02-24 14:56:34 -060098
Aaron Durbin04654a22015-03-17 11:43:44 -050099
100#endif /* PROGRAM_LOADING_H */