mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
Make the load address and entry 64 bits.
Remove a broken proto from a c file. Fix protos etc. per uwe's request for const where it made sense. Signed-off-by: Ronald G. Minnich <rminnich@gmail.com> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@485 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
be93a3b4e5
commit
ca1953808e
4 changed files with 60 additions and 19 deletions
|
@ -36,7 +36,6 @@
|
||||||
/* these prototypes should go into headers */
|
/* these prototypes should go into headers */
|
||||||
void uart_init(void);
|
void uart_init(void);
|
||||||
void die(const char *msg);
|
void die(const char *msg);
|
||||||
int find_file(struct mem_file *archive, char *filename, struct mem_file *result);
|
|
||||||
void hardware_stage1(void);
|
void hardware_stage1(void);
|
||||||
void disable_car(void);
|
void disable_car(void);
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,8 @@ struct lar_header {
|
||||||
* 2 = nrv2b
|
* 2 = nrv2b
|
||||||
*/
|
*/
|
||||||
u32 compression;
|
u32 compression;
|
||||||
u32 entry; /* we might need to make this u64 */
|
u64 entry;
|
||||||
u32 loadaddress; /* ditto */
|
u64 loadaddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mem_file {
|
struct mem_file {
|
||||||
|
@ -83,10 +83,10 @@ struct mem_file {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Prototypes. */
|
/* Prototypes. */
|
||||||
int find_file(struct mem_file *archive, char *filename, struct mem_file *result);
|
int find_file(struct mem_file *archive, const char *filename, struct mem_file *result);
|
||||||
int copy_file(struct mem_file *archive, char *filename, void *where);
|
int copy_file(struct mem_file *archive, const char *filename, void *where);
|
||||||
int run_file(struct mem_file *archive, char *filename, void *where);
|
int run_file(struct mem_file *archive, const char *filename, void *where);
|
||||||
int execute_in_place(struct mem_file *archive, char *filename);
|
int execute_in_place(struct mem_file *archive, const char *filename);
|
||||||
int run_address(void *f);
|
int run_address(void *f);
|
||||||
void *load_file(struct mem_file *archive, char *filename);
|
void *load_file(struct mem_file *archive, const char *filename);
|
||||||
#endif /* LAR_H */
|
#endif /* LAR_H */
|
||||||
|
|
59
lib/lar.c
59
lib/lar.c
|
@ -31,6 +31,13 @@
|
||||||
#define ntohl(x) (x)
|
#define ntohl(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run_address is passed the address of a function taking no parameters and
|
||||||
|
* jumps to it, returning the result.
|
||||||
|
* @param v the address to call as a function.
|
||||||
|
* returns value returned by the function.
|
||||||
|
*/
|
||||||
|
|
||||||
int run_address(void *f)
|
int run_address(void *f)
|
||||||
{
|
{
|
||||||
int (*v) (void);
|
int (*v) (void);
|
||||||
|
@ -38,7 +45,18 @@ int run_address(void *f)
|
||||||
return v();
|
return v();
|
||||||
}
|
}
|
||||||
|
|
||||||
int find_file(struct mem_file *archive, char *filename, struct mem_file *result)
|
/**
|
||||||
|
* Given a file name in the LAR , search for it, and fill out a return struct with the
|
||||||
|
* result.
|
||||||
|
* @param archive A descriptor for current archive. This is actually a mem_file type,
|
||||||
|
* which is a machine-dependent representation of hte actual archive. In particular,
|
||||||
|
* things like u32 are void * in the mem_file struct.
|
||||||
|
* @param filename filename to find
|
||||||
|
* @param result pointer to mem_file struct which is filled in if the file is found
|
||||||
|
* returns 0 on success, -1 otherwise
|
||||||
|
*/
|
||||||
|
|
||||||
|
int find_file(struct mem_file *archive, const char *filename, struct mem_file *result)
|
||||||
{
|
{
|
||||||
char *walk, *fullname;
|
char *walk, *fullname;
|
||||||
struct lar_header *header;
|
struct lar_header *header;
|
||||||
|
@ -105,8 +123,15 @@ int find_file(struct mem_file *archive, char *filename, struct mem_file *result)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a file name in the LAR , search for it, and load it into memory, using
|
||||||
|
* the loadaddress pointer in the mem_file struct.
|
||||||
|
* @param archive A descriptor for current archive.
|
||||||
|
* @param filename filename to find
|
||||||
|
* returns 0 on success, -1 otherwise
|
||||||
|
*/
|
||||||
|
|
||||||
void *load_file(struct mem_file *archive, char *filename)
|
void *load_file(struct mem_file *archive, const char *filename)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct mem_file result;
|
struct mem_file result;
|
||||||
|
@ -149,7 +174,15 @@ void *load_file(struct mem_file *archive, char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME -- most of copy_file should be replaced by load_file */
|
/* FIXME -- most of copy_file should be replaced by load_file */
|
||||||
int copy_file(struct mem_file *archive, char *filename, void *where)
|
/**
|
||||||
|
* Given a file name in the LAR , search for it, and load it into memory,
|
||||||
|
* using the passed-in pointer as the address
|
||||||
|
* @param archive A descriptor for current archive.
|
||||||
|
* @param filename filename to find
|
||||||
|
* @param where pointer to where to load the data
|
||||||
|
* returns 0 on success, -1 otherwise
|
||||||
|
*/
|
||||||
|
int copy_file(struct mem_file *archive, const char *filename, void *where)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct mem_file result;
|
struct mem_file result;
|
||||||
|
@ -190,10 +223,15 @@ int copy_file(struct mem_file *archive, char *filename, void *where)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the file in the LAR header, copy it to the desired location,
|
* Given a file name in the LAR , search for it, and load it into memory,
|
||||||
* and execute it. A location of 0xFFFFFFFF means execute in place (XIP).
|
* using the passed-in pointer as the address; jump to the file.
|
||||||
|
* If the passed-in pointer is (void *)-1, then execute the file in place.
|
||||||
|
* @param archive A descriptor for current archive.
|
||||||
|
* @param filename filename to find
|
||||||
|
* @param where pointer to where to load the data
|
||||||
|
* returns 0 on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
int run_file(struct mem_file *archive, char *filename, void *where)
|
int run_file(struct mem_file *archive, const char *filename, void *where)
|
||||||
{
|
{
|
||||||
int (*v) (void);
|
int (*v) (void);
|
||||||
struct mem_file result;
|
struct mem_file result;
|
||||||
|
@ -217,15 +255,18 @@ int run_file(struct mem_file *archive, char *filename, void *where)
|
||||||
}
|
}
|
||||||
printk(BIOS_SPEW, "where is %p\n", where);
|
printk(BIOS_SPEW, "where is %p\n", where);
|
||||||
v = where;
|
v = where;
|
||||||
ret = v();
|
ret = v();
|
||||||
printk(BIOS_SPEW, "run_file returns with %d\n", ret);
|
printk(BIOS_SPEW, "run_file returns with %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call run_file() to execute in place.
|
* Given a file name in the LAR , search for it, and execute it in place.
|
||||||
|
* @param archive A descriptor for current archive.
|
||||||
|
* @param filename filename to find
|
||||||
|
* returns 0 on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
int execute_in_place(struct mem_file *archive, char *filename)
|
int execute_in_place(struct mem_file *archive, const char *filename)
|
||||||
{
|
{
|
||||||
return run_file(archive, filename, (void *) 0xFFFFFFFF);
|
return run_file(archive, filename, (void *) 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#define BOOTBLOCK_NAME "bootblock"
|
#define BOOTBLOCK_NAME "bootblock"
|
||||||
#define BOOTBLOCK_NAME_LEN 16
|
#define BOOTBLOCK_NAME_LEN 16
|
||||||
|
|
||||||
|
typedef uint64_t u64;
|
||||||
typedef uint32_t u32;
|
typedef uint32_t u32;
|
||||||
typedef uint8_t u8;
|
typedef uint8_t u8;
|
||||||
|
|
||||||
|
@ -74,8 +75,8 @@ struct lar_header {
|
||||||
* 2 = nrv2b
|
* 2 = nrv2b
|
||||||
*/
|
*/
|
||||||
u32 compression;
|
u32 compression;
|
||||||
u32 entry; /* we might need to make this u64 */
|
u64 entry;
|
||||||
u32 loadaddress; /* ditto */
|
u64 loadaddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**\struct
|
/**\struct
|
||||||
|
|
Loading…
Add table
Reference in a new issue