projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
s3c24x0: move serial driver to drivers/serial
[oweals/u-boot.git]
/
api_examples
/
glue.c
diff --git
a/api_examples/glue.c
b/api_examples/glue.c
index 75983691fde4332d748f45c375472114a1577657..eff6a7e62f515806036efb3f6f9b7ea5a73b5054 100644
(file)
--- a/
api_examples/glue.c
+++ b/
api_examples/glue.c
@@
-1,7
+1,5
@@
/*
/*
- * (C) Copyright 2007 Semihalf
- *
- * Written by: Rafal Jaworowski <raj@semihalf.com>
+ * (C) Copyright 2007-2008 Semihalf, Rafal Jaworowski <raj@semihalf.com>
*
* See file CREDITS for list of people who contributed to this
* project.
*
* See file CREDITS for list of people who contributed to this
* project.
@@
-57,16
+55,23
@@
static int valid_sig(struct api_signature *sig)
*
* returns 1/0 depending on found/not found result
*/
*
* returns 1/0 depending on found/not found result
*/
-int api_search_sig(struct api_signature **sig)
{
-
+int api_search_sig(struct api_signature **sig)
+{
unsigned char *sp;
unsigned char *sp;
+ uint32_t search_start = 0;
+ uint32_t search_end = 0;
if (sig == NULL)
return 0;
if (sig == NULL)
return 0;
- sp = (unsigned char *)API_SEARCH_START;
+ if (search_hint == 0)
+ search_hint = 255 * 1024 * 1024;
+
+ search_start = search_hint & ~0x000fffff;
+ search_end = search_start + API_SEARCH_LEN - API_SIG_MAGLEN;
- while ((sp + (int)API_SIG_MAGLEN) < (unsigned char *)API_SEARCH_END) {
+ sp = (unsigned char *)search_start;
+ while ((sp + API_SIG_MAGLEN) < (unsigned char *)search_end) {
if (!memcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) {
*sig = (struct api_signature *)sp;
if (valid_sig(*sig))
if (!memcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) {
*sig = (struct api_signature *)sp;
if (valid_sig(*sig))
@@
-126,8
+131,7
@@
void ub_reset(void)
syscall(API_RESET, NULL);
}
syscall(API_RESET, NULL);
}
-#define MR_MAX 5
-static struct mem_region mr[MR_MAX];
+static struct mem_region mr[UB_MAX_MR];
static struct sys_info si;
struct sys_info * ub_get_sys_info(void)
static struct sys_info si;
struct sys_info * ub_get_sys_info(void)
@@
-136,7
+140,7
@@
struct sys_info * ub_get_sys_info(void)
memset(&si, 0, sizeof(struct sys_info));
si.mr = mr;
memset(&si, 0, sizeof(struct sys_info));
si.mr = mr;
- si.mr_no =
MR_MAX
;
+ si.mr_no =
UB_MAX_MR
;
memset(&mr, 0, sizeof(mr));
if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si))
memset(&mr, 0, sizeof(mr));
if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si))
@@
-150,7
+154,7
@@
struct sys_info * ub_get_sys_info(void)
* timing
*
****************************************/
* timing
*
****************************************/
-
+
void ub_udelay(unsigned long usec)
{
syscall(API_UDELAY, NULL, &usec);
void ub_udelay(unsigned long usec)
{
syscall(API_UDELAY, NULL, &usec);
@@
-171,17
+175,15
@@
unsigned long ub_get_timer(unsigned long base)
*
* devices
*
*
* devices
*
- * Devices are identified by handles: numbers 0, 1, 2, ...,
MAX_DEVS
-1
+ * Devices are identified by handles: numbers 0, 1, 2, ...,
UB_MAX_DEV
-1
*
***************************************************************************/
*
***************************************************************************/
-#define MAX_DEVS 6
-
-static struct device_info devices[MAX_DEVS];
+static struct device_info devices[UB_MAX_DEV];
struct device_info * ub_dev_get(int i)
{
struct device_info * ub_dev_get(int i)
{
- return ((i < 0 || i >=
MAX_DEVS
) ? NULL : &devices[i]);
+ return ((i < 0 || i >=
UB_MAX_DEV
) ? NULL : &devices[i]);
}
/*
}
/*
@@
-195,7
+197,7
@@
int ub_dev_enum(void)
struct device_info *di;
int n = 0;
struct device_info *di;
int n = 0;
- memset(&devices, 0, sizeof(struct device_info) *
MAX_DEVS
);
+ memset(&devices, 0, sizeof(struct device_info) *
UB_MAX_DEV
);
di = &devices[0];
if (!syscall(API_DEV_ENUM, NULL, di))
di = &devices[0];
if (!syscall(API_DEV_ENUM, NULL, di))
@@
-203,7
+205,7
@@
int ub_dev_enum(void)
while (di->cookie != NULL) {
while (di->cookie != NULL) {
- if (++n >=
MAX_DEVS
)
+ if (++n >=
UB_MAX_DEV
)
break;
/* take another device_info */
break;
/* take another device_info */
@@
-229,7
+231,7
@@
int ub_dev_open(int handle)
struct device_info *di;
int err = 0;
struct device_info *di;
int err = 0;
- if (handle < 0 || handle >=
MAX_DEVS
)
+ if (handle < 0 || handle >=
UB_MAX_DEV
)
return API_EINVAL;
di = &devices[handle];
return API_EINVAL;
di = &devices[handle];
@@
-244,7
+246,7
@@
int ub_dev_close(int handle)
{
struct device_info *di;
{
struct device_info *di;
- if (handle < 0 || handle >=
MAX_DEVS
)
+ if (handle < 0 || handle >=
UB_MAX_DEV
)
return API_EINVAL;
di = &devices[handle];
return API_EINVAL;
di = &devices[handle];
@@
-265,7
+267,7
@@
int ub_dev_close(int handle)
*/
static int dev_valid(int handle)
{
*/
static int dev_valid(int handle)
{
- if (handle < 0 || handle >=
MAX_DEVS
)
+ if (handle < 0 || handle >=
UB_MAX_DEV
)
return 0;
if (devices[handle].state != DEV_STA_OPEN)
return 0;
if (devices[handle].state != DEV_STA_OPEN)
@@
-285,7
+287,8
@@
static int dev_stor_valid(int handle)
return 1;
}
return 1;
}
-int ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start)
+int ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start,
+ lbasize_t *rlen)
{
struct device_info *di;
lbasize_t act_len;
{
struct device_info *di;
lbasize_t act_len;
@@
-296,15
+299,12
@@
int ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start)
di = &devices[handle];
if (!syscall(API_DEV_READ, &err, di, buf, &len, &start, &act_len))
di = &devices[handle];
if (!syscall(API_DEV_READ, &err, di, buf, &len, &start, &act_len))
- return
-1
;
+ return
API_ESYSC
;
- if (
err)
-
return err
;
+ if (
!err && rlen)
+
*rlen = act_len
;
- if (act_len != len)
- return API_EIO;
-
- return 0;
+ return err;
}
static int dev_net_valid(int handle)
}
static int dev_net_valid(int handle)
@@
-318,7
+318,7
@@
static int dev_net_valid(int handle)
return 1;
}
return 1;
}
-int ub_dev_recv(int handle, void *buf, int len)
+int ub_dev_recv(int handle, void *buf, int len
, int *rlen
)
{
struct device_info *di;
int err = 0, act_len;
{
struct device_info *di;
int err = 0, act_len;
@@
-328,12
+328,12
@@
int ub_dev_recv(int handle, void *buf, int len)
di = &devices[handle];
if (!syscall(API_DEV_READ, &err, di, buf, &len, &act_len))
di = &devices[handle];
if (!syscall(API_DEV_READ, &err, di, buf, &len, &act_len))
- return
-1
;
+ return
API_ESYSC
;
- if (
err
)
-
return -1
;
+ if (
!err && rlen
)
+
*rlen = act_len
;
-
return act_len
;
+
return (err)
;
}
int ub_dev_send(int handle, void *buf, int len)
}
int ub_dev_send(int handle, void *buf, int len)
@@
-346,7
+346,7
@@
int ub_dev_send(int handle, void *buf, int len)
di = &devices[handle];
if (!syscall(API_DEV_WRITE, &err, di, buf, &len))
di = &devices[handle];
if (!syscall(API_DEV_WRITE, &err, di, buf, &len))
- return
-1
;
+ return
API_ESYSC
;
return err;
}
return err;
}
@@
-372,7
+372,6
@@
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, (uint32_t)name, (uint32_t)value);
}
-
static char env_name[256];
const char * ub_env_enum(const char *last)
static char env_name[256];
const char * ub_env_enum(const char *last)