mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
Fix FreeBSD loader API so that it works on both 32-bit and 64-bit targets.
Specifically tested on MIPS under QEMU (works with all combination of bit-ness and endian-ness) Signed-off-by: Stanislav Galabov <sgalabov@gmail.com>
This commit is contained in:
committed by
Daniel Schwierzeck
parent
713a9e15bb
commit
78757d52c8
@@ -11,8 +11,12 @@ ifeq ($(ARCH),arm)
|
||||
LOAD_ADDR = 0x1000000
|
||||
endif
|
||||
ifeq ($(ARCH),mips)
|
||||
ifdef CONFIG_64BIT
|
||||
LOAD_ADDR = 0xffffffff80200000
|
||||
else
|
||||
LOAD_ADDR = 0x80200000
|
||||
endif
|
||||
endif
|
||||
|
||||
# Resulting ELF and binary exectuables will be named demo and demo.bin
|
||||
extra-y = demo
|
||||
|
@@ -41,28 +41,29 @@ syscall:
|
||||
ldr pc, [ip]
|
||||
|
||||
#elif defined(CONFIG_MIPS)
|
||||
#include <asm/asm.h>
|
||||
.text
|
||||
.globl __start
|
||||
.ent __start
|
||||
__start:
|
||||
sw $sp, search_hint
|
||||
PTR_S $sp, search_hint
|
||||
b main
|
||||
.end __start
|
||||
|
||||
.globl syscall
|
||||
.ent syscall
|
||||
syscall:
|
||||
sw $ra, return_addr
|
||||
lw $t9, syscall_ptr
|
||||
PTR_S $ra, return_addr
|
||||
PTR_L $t9, syscall_ptr
|
||||
jalr $t9
|
||||
nop
|
||||
lw $ra, return_addr
|
||||
PTR_L $ra, return_addr
|
||||
jr $ra
|
||||
nop
|
||||
.end syscall
|
||||
|
||||
return_addr:
|
||||
.align 4
|
||||
.align 8
|
||||
.long 0
|
||||
#else
|
||||
#error No support for this arch!
|
||||
@@ -70,7 +71,7 @@ return_addr:
|
||||
|
||||
.globl syscall_ptr
|
||||
syscall_ptr:
|
||||
.align 4
|
||||
.align 8
|
||||
.long 0
|
||||
|
||||
.globl search_hint
|
||||
|
@@ -77,7 +77,7 @@ int ub_getc(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
if (!syscall(API_GETC, NULL, (uint32_t)&c))
|
||||
if (!syscall(API_GETC, NULL, &c))
|
||||
return -1;
|
||||
|
||||
return c;
|
||||
@@ -87,7 +87,7 @@ int ub_tstc(void)
|
||||
{
|
||||
int t;
|
||||
|
||||
if (!syscall(API_TSTC, NULL, (uint32_t)&t))
|
||||
if (!syscall(API_TSTC, NULL, &t))
|
||||
return -1;
|
||||
|
||||
return t;
|
||||
@@ -95,12 +95,12 @@ int ub_tstc(void)
|
||||
|
||||
void ub_putc(char c)
|
||||
{
|
||||
syscall(API_PUTC, NULL, (uint32_t)&c);
|
||||
syscall(API_PUTC, NULL, &c);
|
||||
}
|
||||
|
||||
void ub_puts(const char *s)
|
||||
{
|
||||
syscall(API_PUTS, NULL, (uint32_t)s);
|
||||
syscall(API_PUTS, NULL, s);
|
||||
}
|
||||
|
||||
/****************************************
|
||||
@@ -126,7 +126,7 @@ struct sys_info * ub_get_sys_info(void)
|
||||
si.mr_no = UB_MAX_MR;
|
||||
memset(&mr, 0, sizeof(mr));
|
||||
|
||||
if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si))
|
||||
if (!syscall(API_GET_SYS_INFO, &err, &si))
|
||||
return NULL;
|
||||
|
||||
return ((err) ? NULL : &si);
|
||||
@@ -344,7 +344,7 @@ char * ub_env_get(const char *name)
|
||||
{
|
||||
char *value;
|
||||
|
||||
if (!syscall(API_ENV_GET, NULL, (uint32_t)name, (uint32_t)&value))
|
||||
if (!syscall(API_ENV_GET, NULL, name, &value))
|
||||
return NULL;
|
||||
|
||||
return value;
|
||||
@@ -352,7 +352,7 @@ char * ub_env_get(const char *name)
|
||||
|
||||
void ub_env_set(const char *name, char *value)
|
||||
{
|
||||
syscall(API_ENV_SET, NULL, (uint32_t)name, (uint32_t)value);
|
||||
syscall(API_ENV_SET, NULL, name, value);
|
||||
}
|
||||
|
||||
static char env_name[256];
|
||||
@@ -369,7 +369,7 @@ const char * ub_env_enum(const char *last)
|
||||
* 'name=val' string), since the API_ENUM_ENV call uses envmatch()
|
||||
* internally, which handles such case
|
||||
*/
|
||||
if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env))
|
||||
if (!syscall(API_ENV_ENUM, NULL, last, &env))
|
||||
return NULL;
|
||||
|
||||
if (!env)
|
||||
@@ -396,7 +396,7 @@ int ub_display_get_info(int type, struct display_info *di)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (!syscall(API_DISPLAY_GET_INFO, &err, (uint32_t)type, (uint32_t)di))
|
||||
if (!syscall(API_DISPLAY_GET_INFO, &err, type, di))
|
||||
return API_ESYSC;
|
||||
|
||||
return err;
|
||||
|
Reference in New Issue
Block a user