Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/uboot/lib/glue.c
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | api_search_sig(struct api_signature **sig) | ||||
unsigned char *sp, *spend; | unsigned char *sp, *spend; | ||||
if (sig == NULL) | if (sig == NULL) | ||||
return (0); | return (0); | ||||
if (uboot_address == 0) | if (uboot_address == 0) | ||||
uboot_address = 255 * 1024 * 1024; | uboot_address = 255 * 1024 * 1024; | ||||
#ifdef __mips__ | |||||
sp = (void *)(uboot_address & ~0x0000ffff); | |||||
spend = sp + 0x00010000 - API_SIG_MAGLEN; | |||||
#else | |||||
sp = (void *)(uboot_address & ~0x000fffff); | sp = (void *)(uboot_address & ~0x000fffff); | ||||
spend = sp + 0x00300000 - API_SIG_MAGLEN; | spend = sp + 0x00300000 - API_SIG_MAGLEN; | ||||
#endif | |||||
andrew: What are these numbers? | |||||
while (sp < spend) { | while (sp < spend) { | ||||
if (!bcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) { | if (!bcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) { | ||||
*sig = (struct api_signature *)sp; | *sig = (struct api_signature *)sp; | ||||
if (valid_sig(*sig)) | if (valid_sig(*sig)) | ||||
return (1); | return (1); | ||||
} | } | ||||
sp += API_SIG_MAGLEN; | sp += API_SIG_MAGLEN; | ||||
} | } | ||||
*sig = NULL; | *sig = NULL; | ||||
return (0); | return (0); | ||||
} | } | ||||
/**************************************** | /**************************************** | ||||
* | * | ||||
* console | * console | ||||
* | * | ||||
****************************************/ | ****************************************/ | ||||
int | int | ||||
ub_getc(void) | ub_getc(void) | ||||
{ | { | ||||
int c; | int c; | ||||
if (!syscall(API_GETC, NULL, (uint32_t)&c)) | if (!syscall(API_GETC, NULL, &c)) | ||||
return (-1); | return (-1); | ||||
return (c); | return (c); | ||||
} | } | ||||
int | int | ||||
ub_tstc(void) | ub_tstc(void) | ||||
{ | { | ||||
int t; | int t; | ||||
if (!syscall(API_TSTC, NULL, (uint32_t)&t)) | if (!syscall(API_TSTC, NULL, &t)) | ||||
return (-1); | return (-1); | ||||
return (t); | return (t); | ||||
} | } | ||||
void | void | ||||
ub_putc(char c) | ub_putc(const char c) | ||||
{ | { | ||||
syscall(API_PUTC, NULL, (uint32_t)&c); | syscall(API_PUTC, NULL, &c); | ||||
} | } | ||||
void | void | ||||
ub_puts(const char *s) | ub_puts(const char *s) | ||||
{ | { | ||||
syscall(API_PUTS, NULL, (uint32_t)s); | syscall(API_PUTS, NULL, s); | ||||
} | } | ||||
/**************************************** | /**************************************** | ||||
* | * | ||||
* system | * system | ||||
* | * | ||||
****************************************/ | ****************************************/ | ||||
Show All 12 Lines | |||||
{ | { | ||||
int err = 0; | int err = 0; | ||||
memset(&si, 0, sizeof(struct sys_info)); | memset(&si, 0, sizeof(struct sys_info)); | ||||
si.mr = mr; | si.mr = mr; | ||||
si.mr_no = UB_MAX_MR; | si.mr_no = UB_MAX_MR; | ||||
memset(&mr, 0, sizeof(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 (NULL); | ||||
return ((err) ? NULL : &si); | return ((err) ? NULL : &si); | ||||
} | } | ||||
/**************************************** | /**************************************** | ||||
* | * | ||||
* timing | * timing | ||||
▲ Show 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
ub_dump_di(int handle) | ub_dump_di(int handle) | ||||
{ | { | ||||
struct device_info *di = ub_dev_get(handle); | struct device_info *di = ub_dev_get(handle); | ||||
int i; | int i; | ||||
printf("device info (%d):\n", handle); | printf("device info (%d):\n", handle); | ||||
printf(" cookie\t= 0x%08x\n", (uint32_t)di->cookie); | printf(" cookie\t= 0x%08lx\n", (unsigned long)di->cookie); | ||||
andrewUnsubmitted Done Inline Actions%p andrew: `%p` | |||||
printf(" type\t\t= 0x%08x\n", di->type); | printf(" type\t\t= 0x%08x\n", di->type); | ||||
if (di->type == DEV_TYP_NET) { | if (di->type == DEV_TYP_NET) { | ||||
printf(" hwaddr\t= "); | printf(" hwaddr\t= "); | ||||
for (i = 0; i < 6; i++) | for (i = 0; i < 6; i++) | ||||
printf("%02x ", di->di_net.hwaddr[i]); | printf("%02x ", di->di_net.hwaddr[i]); | ||||
printf("\n"); | printf("\n"); | ||||
Show All 33 Lines | |||||
* | * | ||||
****************************************/ | ****************************************/ | ||||
char * | char * | ||||
ub_env_get(const char *name) | ub_env_get(const char *name) | ||||
{ | { | ||||
char *value; | 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 (NULL); | ||||
return (value); | return (value); | ||||
} | } | ||||
void | void | ||||
ub_env_set(const char *name, char *value) | 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]; | static char env_name[256]; | ||||
const char * | const char * | ||||
ub_env_enum(const char *last) | ub_env_enum(const char *last) | ||||
{ | { | ||||
const char *env, *str; | const char *env, *str; | ||||
int i; | int i; | ||||
/* | /* | ||||
* It's OK to pass only the name piece as last (and not the whole | * It's OK to pass only the name piece as last (and not the whole | ||||
* 'name=val' string), since the API_ENUM_ENV call uses envmatch() | * 'name=val' string), since the API_ENUM_ENV call uses envmatch() | ||||
* internally, which handles such case | * internally, which handles such case | ||||
*/ | */ | ||||
env = NULL; | env = NULL; | ||||
if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env)) | if (!syscall(API_ENV_ENUM, NULL, last, &env)) | ||||
return (NULL); | return (NULL); | ||||
if (env == NULL || last == env) | if (env == NULL || last == env) | ||||
/* no more env. variables to enumerate */ | /* no more env. variables to enumerate */ | ||||
return (NULL); | return (NULL); | ||||
/* next enumerated env var */ | /* next enumerated env var */ | ||||
memset(env_name, 0, 256); | memset(env_name, 0, 256); | ||||
for (i = 0, str = env; *str != '=' && *str != '\0';) | for (i = 0, str = env; *str != '=' && *str != '\0';) | ||||
env_name[i++] = *str++; | env_name[i++] = *str++; | ||||
env_name[i] = '\0'; | env_name[i] = '\0'; | ||||
return (env_name); | return (env_name); | ||||
} | } |
What are these numbers?