blob: b8bfc0dd2116e805712fc752ff4a431e67495d57 [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
25struct payload_backing_store {
26 void *data;
27 size_t size;
28};
29
30struct payload {
31 const char *name;
32 struct payload_backing_store backing_store;
33 void *entry;
34};
35
36/*
37 * Load payload into memory and return pointer to payload structure. Returns
38 * NULL on error.
39 */
40struct payload *payload_load(void);
41
42/* Run the loaded payload. */
43void payload_run(const struct payload *payload);
44
45/* Payload loading operations. */
46struct payload_loader_ops {
47 const char *name;
48 /*
49 * Fill in payload_backing_store structure. Return 0 on success, < 0
50 * on failure.
51 */
52 int (*locate)(struct payload *payload);
53};
54
55/* Defined in src/lib/selfboot.c */
56struct lb_memory;
57struct cbfs_payload;
58void *selfload(struct lb_memory *mem, struct cbfs_payload *payload);
59void selfboot(void *entry);
60
61#endif /* PAYLOAD_LOADER_H */