2014-02-24 21:56:34 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
2015-03-17 17:43:44 +01:00
|
|
|
* Copyright 2015 Google Inc.
|
2015-01-09 14:14:20 +01:00
|
|
|
* Copyright (C) 2014 Imagination Technologies
|
2014-02-24 21:56:34 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2015-03-17 17:43:44 +01:00
|
|
|
#ifndef PROGRAM_LOADING_H
|
|
|
|
#define PROGRAM_LOADING_H
|
2014-02-24 21:56:34 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2015-03-20 15:42:05 +01:00
|
|
|
enum {
|
|
|
|
/* Last segment of program. Can be used to take different actions for
|
|
|
|
* cache maintenance of a program load. */
|
|
|
|
SEG_FINAL = 1 << 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Called for each segment of a program loaded. The PROG_FLAG_FINAL will be
|
|
|
|
* set on the last segment loaded. */
|
|
|
|
void arch_segment_loaded(uintptr_t start, size_t size, int flags);
|
2015-01-09 14:14:20 +01:00
|
|
|
|
2015-03-17 19:17:06 +01:00
|
|
|
/************************
|
|
|
|
* ROMSTAGE LOADING *
|
|
|
|
************************/
|
|
|
|
|
|
|
|
/* Run romstage from bootblock. */
|
|
|
|
void run_romstage(void);
|
2015-03-17 17:43:44 +01:00
|
|
|
|
|
|
|
/************************
|
|
|
|
* RAMSTAGE LOADING *
|
|
|
|
************************/
|
|
|
|
|
2015-03-20 16:58:41 +01:00
|
|
|
struct romstage_handoff;
|
2015-03-17 17:43:44 +01:00
|
|
|
struct cbmem_entry;
|
|
|
|
|
2015-03-20 16:58:41 +01:00
|
|
|
#if defined(__PRE_RAM__)
|
|
|
|
#if CONFIG_RELOCATABLE_RAMSTAGE
|
|
|
|
/* The cache_loaded_ramstage() and load_cached_ramstage() functions are defined
|
|
|
|
* to be weak so that board and chipset code may override them. Their job is to
|
|
|
|
* cache and load the ramstage for quick S3 resume. By default a copy of the
|
|
|
|
* relocated ramstage is saved using the cbmem infrastructure. These
|
|
|
|
* functions are only valid during romstage. */
|
|
|
|
|
|
|
|
/* The implementer of cache_loaded_ramstage() may use the romstage_handoff
|
|
|
|
* structure to store information, but note that the handoff variable can be
|
|
|
|
* NULL. The ramstage cbmem_entry represents the region occupied by the loaded
|
|
|
|
* ramstage. */
|
|
|
|
void cache_loaded_ramstage(struct romstage_handoff *handoff,
|
|
|
|
const struct cbmem_entry *ramstage, void *entry_point);
|
|
|
|
/* Return NULL on error or entry point on success. The ramstage cbmem_entry is
|
|
|
|
* the region where to load the cached contents to. */
|
|
|
|
void * load_cached_ramstage(struct romstage_handoff *handoff,
|
|
|
|
const struct cbmem_entry *ramstage);
|
|
|
|
#else /* CONFIG_RELOCATABLE_RAMSTAGE */
|
|
|
|
|
|
|
|
static inline void cache_loaded_ramstage(struct romstage_handoff *handoff,
|
|
|
|
const struct cbmem_entry *ramstage, void *entry_point)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *
|
|
|
|
load_cached_ramstage(struct romstage_handoff *handoff,
|
|
|
|
const struct cbmem_entry *ramstage)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_RELOCATABLE_RAMSTAGE */
|
|
|
|
#endif /* defined(__PRE_RAM__) */
|
|
|
|
|
2015-03-17 17:43:44 +01:00
|
|
|
/* Run ramstage from romstage. */
|
|
|
|
void run_ramstage(void);
|
|
|
|
|
|
|
|
struct ramstage_loader_ops {
|
|
|
|
const char *name;
|
|
|
|
void *(*load)(uint32_t cbmem_id, const char *name,
|
|
|
|
const struct cbmem_entry **cbmem_entry);
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* PAYLOAD LOADING *
|
|
|
|
***********************/
|
|
|
|
|
2014-02-25 05:11:45 +01:00
|
|
|
struct buffer_area {
|
2014-02-24 21:56:34 +01:00
|
|
|
void *data;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct payload {
|
|
|
|
const char *name;
|
2014-02-25 05:11:45 +01:00
|
|
|
struct buffer_area backing_store;
|
|
|
|
/* Used when payload wants memory coreboot ramstage is running at. */
|
|
|
|
struct buffer_area bounce;
|
2014-02-24 21:56:34 +01:00
|
|
|
void *entry;
|
|
|
|
};
|
|
|
|
|
2015-03-20 16:20:15 +01:00
|
|
|
/* Load payload into memory in preparation to run. */
|
|
|
|
void payload_load(void);
|
2014-02-24 21:56:34 +01:00
|
|
|
|
|
|
|
/* Run the loaded payload. */
|
2015-03-20 16:20:15 +01:00
|
|
|
void payload_run(void);
|
2014-02-24 21:56:34 +01:00
|
|
|
|
2014-02-26 03:36:56 +01:00
|
|
|
/* Mirror the payload to be loaded. */
|
|
|
|
void mirror_payload(struct payload *payload);
|
|
|
|
|
2014-02-25 05:27:39 +01:00
|
|
|
/* architecture specific function to run payload. */
|
|
|
|
void arch_payload_run(const struct payload *payload);
|
|
|
|
|
2014-02-24 21:56:34 +01:00
|
|
|
/* Payload loading operations. */
|
|
|
|
struct payload_loader_ops {
|
|
|
|
const char *name;
|
|
|
|
/*
|
|
|
|
* Fill in payload_backing_store structure. Return 0 on success, < 0
|
|
|
|
* on failure.
|
|
|
|
*/
|
|
|
|
int (*locate)(struct payload *payload);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Defined in src/lib/selfboot.c */
|
2014-02-25 07:21:10 +01:00
|
|
|
void *selfload(struct payload *payload);
|
2014-02-24 21:56:34 +01:00
|
|
|
|
2015-03-17 17:43:44 +01:00
|
|
|
|
|
|
|
#endif /* PROGRAM_LOADING_H */
|