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
|
Remove address from GPLv2 headers
As per discussion with lawyers[tm], it's not a good idea to
shorten the license header too much - not for legal reasons
but because there are tools that look for them, and giving
them a standard pattern simplifies things.
However, we got confirmation that we don't have to update
every file ever added to coreboot whenever the FSF gets a
new lease, but can drop the address instead.
util/kconfig is excluded because that's imported code that
we may want to synchronize every now and then.
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *MA[, ]*02110-1301[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 59 Temple Place[-, ]*Suite 330, Boston, MA *02111-1307[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.:Foundation, Inc.:" {} +
$ find * -type f
-a \! -name \*.patch \
-a \! -name \*_shipped \
-a \! -name LICENSE_GPL \
-a \! -name LGPL.txt \
-a \! -name COPYING \
-a \! -name DISCLAIMER \
-exec sed -i "/Foundation, Inc./ N;s:Foundation, Inc.* USA\.* *:Foundation, Inc. :;s:Foundation, Inc. $:Foundation, Inc.:" {} +
Change-Id: Icc968a5a5f3a5df8d32b940f9cdb35350654bef9
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/9233
Tested-by: build bot (Jenkins)
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-03-26 15:17:45 +01:00
|
|
|
* Foundation, Inc.
|
2014-02-24 21:56:34 +01:00
|
|
|
*/
|
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-05-20 19:08:55 +02:00
|
|
|
#include <assets.h>
|
2014-02-24 21:56:34 +01:00
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2015-03-20 19:00:20 +01:00
|
|
|
/* Called for each segment of a program loaded. The SEG_FINAL flag will be
|
2015-03-20 15:42:05 +01:00
|
|
|
* 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-20 19:00:20 +01:00
|
|
|
/* Representation of a program. */
|
|
|
|
struct prog {
|
2015-05-20 19:08:55 +02:00
|
|
|
/* The region_device within the asset is the source of program content
|
|
|
|
* to load. After loading program it represents the memory region of
|
|
|
|
* the stages and payload. For architectures that use a bounce buffer
|
|
|
|
* then it would represent the bounce buffer. */
|
|
|
|
struct asset asset;
|
2015-03-20 19:00:20 +01:00
|
|
|
/* Entry to program with optional argument. It's up to the architecture
|
|
|
|
* to decide if argument is passed. */
|
|
|
|
void (*entry)(void *);
|
|
|
|
void *arg;
|
|
|
|
};
|
|
|
|
|
2015-05-20 19:08:55 +02:00
|
|
|
#define PROG_INIT(type_, name_) \
|
|
|
|
{ \
|
|
|
|
.asset = ASSET_INIT(type_, name_), \
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const char *prog_name(const struct prog *prog)
|
|
|
|
{
|
|
|
|
return asset_name(&prog->asset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline enum asset_type prog_type(const struct prog *prog)
|
|
|
|
{
|
|
|
|
return asset_type(&prog->asset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct region_device *prog_rdev(struct prog *prog)
|
|
|
|
{
|
|
|
|
return asset_rdev(&prog->asset);
|
|
|
|
}
|
|
|
|
|
2015-05-19 23:25:20 +02:00
|
|
|
/* Only valid for loaded programs. */
|
2015-03-20 19:00:20 +01:00
|
|
|
static inline size_t prog_size(const struct prog *prog)
|
|
|
|
{
|
2015-05-20 19:08:55 +02:00
|
|
|
return asset_size(&prog->asset);
|
2015-03-20 19:00:20 +01:00
|
|
|
}
|
|
|
|
|
2015-05-19 23:25:20 +02:00
|
|
|
/* Only valid for loaded programs. */
|
2015-03-20 19:00:20 +01:00
|
|
|
static inline void *prog_start(const struct prog *prog)
|
|
|
|
{
|
2015-05-20 19:08:55 +02:00
|
|
|
return asset_mmap(&prog->asset);
|
2015-03-20 19:00:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *prog_entry(const struct prog *prog)
|
|
|
|
{
|
|
|
|
return prog->entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *prog_entry_arg(const struct prog *prog)
|
|
|
|
{
|
|
|
|
return prog->arg;
|
|
|
|
}
|
|
|
|
|
2015-05-19 23:25:20 +02:00
|
|
|
/* region_device representing the 32-bit flat address space. */
|
|
|
|
extern const struct mem_region_device addrspace_32bit;
|
|
|
|
|
|
|
|
static inline void prog_memory_init(struct prog *prog, uintptr_t ptr,
|
|
|
|
size_t size)
|
|
|
|
{
|
2015-05-20 19:08:55 +02:00
|
|
|
rdev_chain(&prog->asset.rdev, &addrspace_32bit.rdev, ptr, size);
|
2015-05-19 23:25:20 +02:00
|
|
|
}
|
|
|
|
|
2015-03-20 19:00:20 +01:00
|
|
|
static inline void prog_set_area(struct prog *prog, void *start, size_t size)
|
|
|
|
{
|
2015-05-19 23:25:20 +02:00
|
|
|
prog_memory_init(prog, (uintptr_t)start, size);
|
2015-03-20 19:00:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void prog_set_entry(struct prog *prog, void *e, void *arg)
|
|
|
|
{
|
|
|
|
prog->entry = e;
|
|
|
|
prog->arg = arg;
|
|
|
|
}
|
|
|
|
|
2015-05-16 06:39:23 +02:00
|
|
|
/* Locate the identified program to run. Return 0 on success. < 0 on error. */
|
2015-05-20 19:08:55 +02:00
|
|
|
static inline int prog_locate(struct prog *prog)
|
|
|
|
{
|
|
|
|
return asset_locate(&prog->asset);
|
|
|
|
}
|
|
|
|
|
2015-03-20 21:55:08 +01:00
|
|
|
/* Run the program described by prog. */
|
|
|
|
void prog_run(struct prog *prog);
|
|
|
|
/* Per architecture implementation running a program. */
|
|
|
|
void arch_prog_run(struct prog *prog);
|
|
|
|
/* Platform (SoC/chipset) specific overrides for running a program. This is
|
|
|
|
* called prior to calling the arch_prog_run. Thus, if there is anything
|
|
|
|
* special that needs to be done by the platform similar to the architecture
|
|
|
|
* code it needs to that as well. */
|
|
|
|
void platform_prog_run(struct prog *prog);
|
|
|
|
|
2015-03-20 22:37:12 +01:00
|
|
|
struct prog_loader_ops {
|
|
|
|
const char *name;
|
2015-04-28 22:59:12 +02:00
|
|
|
/* Determine if the loader is the active one. If so returns 1 else 0
|
|
|
|
* or < 0 on error. */
|
|
|
|
int (*is_loader_active)(struct prog *prog);
|
2015-05-16 06:39:23 +02:00
|
|
|
/* Returns < 0 on error or 0 on success. This function locates
|
|
|
|
* the rdev representing the file data associated with the passed in
|
|
|
|
* prog. */
|
|
|
|
int (*locate)(struct prog *prog);
|
2015-03-20 22:37:12 +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 22:37:12 +01:00
|
|
|
/* Run ramstage from romstage. */
|
|
|
|
void run_ramstage(void);
|
|
|
|
|
2015-03-07 06:17:33 +01:00
|
|
|
/* Called when the stage cache couldn't load ramstage on resume. */
|
|
|
|
void ramstage_cache_invalid(void);
|
2015-03-20 16:58:41 +01:00
|
|
|
|
2015-03-17 17:43:44 +01:00
|
|
|
/***********************
|
|
|
|
* PAYLOAD LOADING *
|
|
|
|
***********************/
|
|
|
|
|
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. */
|
2015-03-20 22:37:12 +01:00
|
|
|
void mirror_payload(struct prog *payload);
|
2014-02-24 21:56:34 +01:00
|
|
|
|
|
|
|
/* Defined in src/lib/selfboot.c */
|
2015-03-20 22:37:12 +01:00
|
|
|
void *selfload(struct prog *payload);
|
2015-03-17 17:43:44 +01:00
|
|
|
|
|
|
|
#endif /* PROGRAM_LOADING_H */
|