mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
Add execute in place to lar. Allows code to be run from the ROM.
Signed-off-by: Marc Jones <marc.jones@amd.com> Acked-by: Ronald G. Minnich <rminnich@gmail.com> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@458 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
396fdc33a7
commit
b48030fa84
2 changed files with 31 additions and 4 deletions
|
@ -76,5 +76,6 @@ struct mem_file {
|
||||||
int find_file(struct mem_file *archive, char *filename, struct mem_file *result);
|
int find_file(struct mem_file *archive, char *filename, struct mem_file *result);
|
||||||
int copy_file(struct mem_file *archive, char *filename, void *where);
|
int copy_file(struct mem_file *archive, char *filename, void *where);
|
||||||
int run_file(struct mem_file *archive, char *filename, void *where);
|
int run_file(struct mem_file *archive, char *filename, void *where);
|
||||||
|
int execute_in_place(struct mem_file *archive, char *filename);
|
||||||
|
|
||||||
#endif /* LAR_H */
|
#endif /* LAR_H */
|
||||||
|
|
34
lib/lar.c
34
lib/lar.c
|
@ -3,6 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2007 coresystems GmbH
|
* Copyright (C) 2006-2007 coresystems GmbH
|
||||||
* (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH)
|
* (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH)
|
||||||
|
* Copyright (C) 2007 Advanced Micro Devices, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -103,16 +104,41 @@ int copy_file(struct mem_file *archive, char *filename, void *where)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the file in the LAR header, copy it to the desired location,
|
||||||
|
* and execute it. A location of 0xFFFFFFFF means execute in place (XIP).
|
||||||
|
*/
|
||||||
int run_file(struct mem_file *archive, char *filename, void *where)
|
int run_file(struct mem_file *archive, char *filename, void *where)
|
||||||
{
|
{
|
||||||
int (*v) (void);
|
int (*v) (void);
|
||||||
|
struct mem_file result;
|
||||||
|
|
||||||
if (copy_file(archive, filename, where)) {
|
if ((u32) where != 0xFFFFFFFF) {
|
||||||
printk(BIOS_INFO, "LAR: Run file %s failed: No such file.\n",
|
if (copy_file(archive, filename, where)) {
|
||||||
filename);
|
printk(BIOS_INFO,
|
||||||
return 1;
|
"LAR: Run file %s failed: No such file.\n",
|
||||||
|
filename);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else { /* XIP */
|
||||||
|
if (find_file(archive, filename, &result)) {
|
||||||
|
printk(BIOS_INFO,
|
||||||
|
"LAR: Run file %s failed: No such file.\n",
|
||||||
|
filename);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
where = result.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
v = where;
|
v = where;
|
||||||
return v();
|
return v();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call run_file() to execute in place.
|
||||||
|
*/
|
||||||
|
int execute_in_place(struct mem_file *archive, char *filename)
|
||||||
|
{
|
||||||
|
return run_file(archive, filename, (void *) 0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue