blob: 4948afb6b8e33592470994b8fdda69c728dbfee2 [file] [log] [blame]
Aaron Durbinbdf913a2014-02-24 14:56:34 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
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 */
19#ifndef PAYLOAD_LOADER_H
20#define PAYLOAD_LOADER_H
21
22#include <stdint.h>
23#include <stddef.h>
24
Aaron Durbine58a24b2014-02-24 22:11:45 -060025struct buffer_area {
Aaron Durbinbdf913a2014-02-24 14:56:34 -060026 void *data;
27 size_t size;
28};
29
30struct payload {
31 const char *name;
Aaron Durbine58a24b2014-02-24 22:11:45 -060032 struct buffer_area backing_store;
33 /* Used when payload wants memory coreboot ramstage is running at. */
34 struct buffer_area bounce;
Aaron Durbinbdf913a2014-02-24 14:56:34 -060035 void *entry;
36};
37
38/*
39 * Load payload into memory and return pointer to payload structure. Returns
40 * NULL on error.
41 */
42struct payload *payload_load(void);
43
44/* Run the loaded payload. */
45void payload_run(const struct payload *payload);
46
Aaron Durbin7d1996c2014-02-24 22:27:39 -060047/* architecture specific function to run payload. */
48void arch_payload_run(const struct payload *payload);
49
Aaron Durbinbdf913a2014-02-24 14:56:34 -060050/* Payload loading operations. */
51struct payload_loader_ops {
52 const char *name;
53 /*
54 * Fill in payload_backing_store structure. Return 0 on success, < 0
55 * on failure.
56 */
57 int (*locate)(struct payload *payload);
58};
59
60/* Defined in src/lib/selfboot.c */
61struct lb_memory;
Aaron Durbin6086e632014-02-24 21:50:24 -060062void *selfload(struct lb_memory *mem, struct payload *payload);
Aaron Durbinbdf913a2014-02-24 14:56:34 -060063
64#endif /* PAYLOAD_LOADER_H */