2 * This file is part of the coreboot project.
4 * Copyright 2015 Google Inc.
5 * Copyright (C) 2014 Imagination Technologies
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.
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.
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
20 #ifndef PROGRAM_LOADING_H
21 #define PROGRAM_LOADING_H
26 /* For each segment of a program loaded this function is called*/
27 void arch_program_segment_loaded(uintptr_t start
, size_t size
);
29 /* Upon completion of loading a program this function is called */
30 void arch_program_loaded(void);
32 /************************
34 ************************/
36 /* Run romstage from bootblock. */
37 void run_romstage(void);
39 /************************
41 ************************/
43 struct romstage_handoff
;
46 #if defined(__PRE_RAM__)
47 #if CONFIG_RELOCATABLE_RAMSTAGE
48 /* The cache_loaded_ramstage() and load_cached_ramstage() functions are defined
49 * to be weak so that board and chipset code may override them. Their job is to
50 * cache and load the ramstage for quick S3 resume. By default a copy of the
51 * relocated ramstage is saved using the cbmem infrastructure. These
52 * functions are only valid during romstage. */
54 /* The implementer of cache_loaded_ramstage() may use the romstage_handoff
55 * structure to store information, but note that the handoff variable can be
56 * NULL. The ramstage cbmem_entry represents the region occupied by the loaded
58 void cache_loaded_ramstage(struct romstage_handoff
*handoff
,
59 const struct cbmem_entry
*ramstage
, void *entry_point
);
60 /* Return NULL on error or entry point on success. The ramstage cbmem_entry is
61 * the region where to load the cached contents to. */
62 void * load_cached_ramstage(struct romstage_handoff
*handoff
,
63 const struct cbmem_entry
*ramstage
);
64 #else /* CONFIG_RELOCATABLE_RAMSTAGE */
66 static inline void cache_loaded_ramstage(struct romstage_handoff
*handoff
,
67 const struct cbmem_entry
*ramstage
, void *entry_point
)
72 load_cached_ramstage(struct romstage_handoff
*handoff
,
73 const struct cbmem_entry
*ramstage
)
78 #endif /* CONFIG_RELOCATABLE_RAMSTAGE */
79 #endif /* defined(__PRE_RAM__) */
81 /* Run ramstage from romstage. */
82 void run_ramstage(void);
84 struct ramstage_loader_ops
{
86 void *(*load
)(uint32_t cbmem_id
, const char *name
,
87 const struct cbmem_entry
**cbmem_entry
);
90 /***********************
92 ***********************/
101 struct buffer_area backing_store
;
102 /* Used when payload wants memory coreboot ramstage is running at. */
103 struct buffer_area bounce
;
108 * Load payload into memory and return pointer to payload structure. Returns
111 struct payload
*payload_load(void);
113 /* Run the loaded payload. */
114 void payload_run(const struct payload
*payload
);
116 /* Mirror the payload to be loaded. */
117 void mirror_payload(struct payload
*payload
);
119 /* architecture specific function to run payload. */
120 void arch_payload_run(const struct payload
*payload
);
122 /* Payload loading operations. */
123 struct payload_loader_ops
{
126 * Fill in payload_backing_store structure. Return 0 on success, < 0
129 int (*locate
)(struct payload
*payload
);
132 /* Defined in src/lib/selfboot.c */
133 void *selfload(struct payload
*payload
);
136 #endif /* PROGRAM_LOADING_H */