Skip to content

Commit 6e4e886

Browse files
authored
Merge pull request #31 from iamGavinJ/odroidc2-v2015.01
Patchset merged from upstream
2 parents d6b6563 + 3d1cc8d commit 6e4e886

4 files changed

Lines changed: 71 additions & 39 deletions

File tree

api/api.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static int API_getc(va_list ap)
5252
{
5353
int *c;
5454

55-
if ((c = (int *)va_arg(ap, u_int32_t)) == NULL)
55+
if ((c = (int *)va_arg(ap, uintptr_t)) == NULL)
5656
return API_EINVAL;
5757

5858
*c = getc();
@@ -68,7 +68,7 @@ static int API_tstc(va_list ap)
6868
{
6969
int *t;
7070

71-
if ((t = (int *)va_arg(ap, u_int32_t)) == NULL)
71+
if ((t = (int *)va_arg(ap, uintptr_t)) == NULL)
7272
return API_EINVAL;
7373

7474
*t = tstc();
@@ -84,7 +84,7 @@ static int API_putc(va_list ap)
8484
{
8585
char *c;
8686

87-
if ((c = (char *)va_arg(ap, u_int32_t)) == NULL)
87+
if ((c = (char *)va_arg(ap, uintptr_t)) == NULL)
8888
return API_EINVAL;
8989

9090
putc(*c);
@@ -100,7 +100,7 @@ static int API_puts(va_list ap)
100100
{
101101
char *s;
102102

103-
if ((s = (char *)va_arg(ap, u_int32_t)) == NULL)
103+
if ((s = (char *)va_arg(ap, uintptr_t)) == NULL)
104104
return API_EINVAL;
105105

106106
puts(s);
@@ -132,7 +132,7 @@ static int API_get_sys_info(va_list ap)
132132
{
133133
struct sys_info *si;
134134

135-
si = (struct sys_info *)va_arg(ap, u_int32_t);
135+
si = (struct sys_info *)va_arg(ap, uintptr_t);
136136
if (si == NULL)
137137
return API_ENOMEM;
138138

@@ -148,7 +148,7 @@ static int API_udelay(va_list ap)
148148
{
149149
unsigned long *d;
150150

151-
if ((d = (unsigned long *)va_arg(ap, u_int32_t)) == NULL)
151+
if ((d = (unsigned long *)va_arg(ap, unsigned long)) == NULL)
152152
return API_EINVAL;
153153

154154
udelay(*d);
@@ -164,11 +164,11 @@ static int API_get_timer(va_list ap)
164164
{
165165
unsigned long *base, *cur;
166166

167-
cur = (unsigned long *)va_arg(ap, u_int32_t);
167+
cur = (unsigned long *)va_arg(ap, unsigned long);
168168
if (cur == NULL)
169169
return API_EINVAL;
170170

171-
base = (unsigned long *)va_arg(ap, u_int32_t);
171+
base = (unsigned long *)va_arg(ap, unsigned long);
172172
if (base == NULL)
173173
return API_EINVAL;
174174

@@ -199,7 +199,7 @@ static int API_dev_enum(va_list ap)
199199
struct device_info *di;
200200

201201
/* arg is ptr to the device_info struct we are going to fill out */
202-
di = (struct device_info *)va_arg(ap, u_int32_t);
202+
di = (struct device_info *)va_arg(ap, uintptr_t);
203203
if (di == NULL)
204204
return API_EINVAL;
205205

@@ -233,7 +233,7 @@ static int API_dev_open(va_list ap)
233233
int err = 0;
234234

235235
/* arg is ptr to the device_info struct */
236-
di = (struct device_info *)va_arg(ap, u_int32_t);
236+
di = (struct device_info *)va_arg(ap, uintptr_t);
237237
if (di == NULL)
238238
return API_EINVAL;
239239

@@ -265,7 +265,7 @@ static int API_dev_close(va_list ap)
265265
int err = 0;
266266

267267
/* arg is ptr to the device_info struct */
268-
di = (struct device_info *)va_arg(ap, u_int32_t);
268+
di = (struct device_info *)va_arg(ap, uintptr_t);
269269
if (di == NULL)
270270
return API_EINVAL;
271271

@@ -319,7 +319,7 @@ static int API_dev_write(va_list ap)
319319
int err = 0;
320320

321321
/* 1. arg is ptr to the device_info struct */
322-
di = (struct device_info *)va_arg(ap, u_int32_t);
322+
di = (struct device_info *)va_arg(ap, uintptr_t);
323323
if (di == NULL)
324324
return API_EINVAL;
325325

@@ -329,12 +329,12 @@ static int API_dev_write(va_list ap)
329329
return API_ENODEV;
330330

331331
/* 2. arg is ptr to buffer from where to get data to write */
332-
buf = (void *)va_arg(ap, u_int32_t);
332+
buf = (void *)va_arg(ap, uintptr_t);
333333
if (buf == NULL)
334334
return API_EINVAL;
335335

336336
/* 3. arg is length of buffer */
337-
len = (int *)va_arg(ap, u_int32_t);
337+
len = (int *)va_arg(ap, uintptr_t);
338338
if (len == NULL)
339339
return API_EINVAL;
340340
if (*len <= 0)
@@ -387,7 +387,7 @@ static int API_dev_read(va_list ap)
387387
int *len_net, *act_len_net;
388388

389389
/* 1. arg is ptr to the device_info struct */
390-
di = (struct device_info *)va_arg(ap, u_int32_t);
390+
di = (struct device_info *)va_arg(ap, uintptr_t);
391391
if (di == NULL)
392392
return API_EINVAL;
393393

@@ -397,23 +397,23 @@ static int API_dev_read(va_list ap)
397397
return API_ENODEV;
398398

399399
/* 2. arg is ptr to buffer from where to put the read data */
400-
buf = (void *)va_arg(ap, u_int32_t);
400+
buf = (void *)va_arg(ap, uintptr_t);
401401
if (buf == NULL)
402402
return API_EINVAL;
403403

404404
if (di->type & DEV_TYP_STOR) {
405405
/* 3. arg - ptr to var with # of blocks to read */
406-
len_stor = (lbasize_t *)va_arg(ap, u_int32_t);
406+
len_stor = (lbasize_t *)va_arg(ap, uintptr_t);
407407
if (!len_stor)
408408
return API_EINVAL;
409409
if (*len_stor <= 0)
410410
return API_EINVAL;
411411

412412
/* 4. arg - ptr to var with start block */
413-
start = (lbastart_t *)va_arg(ap, u_int32_t);
413+
start = (lbastart_t *)va_arg(ap, uintptr_t);
414414

415415
/* 5. arg - ptr to var where to put the len actually read */
416-
act_len_stor = (lbasize_t *)va_arg(ap, u_int32_t);
416+
act_len_stor = (lbasize_t *)va_arg(ap, uintptr_t);
417417
if (!act_len_stor)
418418
return API_EINVAL;
419419

@@ -422,14 +422,14 @@ static int API_dev_read(va_list ap)
422422
} else if (di->type & DEV_TYP_NET) {
423423

424424
/* 3. arg points to the var with length of packet to read */
425-
len_net = (int *)va_arg(ap, u_int32_t);
425+
len_net = (int *)va_arg(ap, uintptr_t);
426426
if (!len_net)
427427
return API_EINVAL;
428428
if (*len_net <= 0)
429429
return API_EINVAL;
430430

431431
/* 4. - ptr to var where to put the len actually read */
432-
act_len_net = (int *)va_arg(ap, u_int32_t);
432+
act_len_net = (int *)va_arg(ap, uintptr_t);
433433
if (!act_len_net)
434434
return API_EINVAL;
435435

@@ -453,9 +453,9 @@ static int API_env_get(va_list ap)
453453
{
454454
char *name, **value;
455455

456-
if ((name = (char *)va_arg(ap, u_int32_t)) == NULL)
456+
if ((name = (char *)va_arg(ap, uintptr_t)) == NULL)
457457
return API_EINVAL;
458-
if ((value = (char **)va_arg(ap, u_int32_t)) == NULL)
458+
if ((value = (char **)va_arg(ap, uintptr_t)) == NULL)
459459
return API_EINVAL;
460460

461461
*value = getenv(name);
@@ -476,9 +476,9 @@ static int API_env_set(va_list ap)
476476
{
477477
char *name, *value;
478478

479-
if ((name = (char *)va_arg(ap, u_int32_t)) == NULL)
479+
if ((name = (char *)va_arg(ap, uintptr_t)) == NULL)
480480
return API_EINVAL;
481-
if ((value = (char *)va_arg(ap, u_int32_t)) == NULL)
481+
if ((value = (char *)va_arg(ap, uintptr_t)) == NULL)
482482
return API_EINVAL;
483483

484484
setenv(name, value);
@@ -498,9 +498,9 @@ static int API_env_enum(va_list ap)
498498
int i, n;
499499
char *last, **next;
500500

501-
last = (char *)va_arg(ap, u_int32_t);
501+
last = (char *)va_arg(ap, unsigned long);
502502

503-
if ((next = (char **)va_arg(ap, u_int32_t)) == NULL)
503+
if ((next = (char **)va_arg(ap, uintptr_t)) == NULL)
504504
return API_EINVAL;
505505

506506
if (last == NULL)
@@ -661,14 +661,14 @@ void api_init(void)
661661
return;
662662
}
663663

664-
debugf("API sig @ 0x%08x\n", sig);
664+
debugf("API sig @ 0x%lX\n", (unsigned long)sig);
665665
memcpy(sig->magic, API_SIG_MAGIC, 8);
666666
sig->version = API_SIG_VERSION;
667667
sig->syscall = &syscall;
668668
sig->checksum = 0;
669669
sig->checksum = crc32(0, (unsigned char *)sig,
670670
sizeof(struct api_signature));
671-
debugf("syscall entry: 0x%08x\n", sig->syscall);
671+
debugf("syscall entry: 0x%lX\n", (unsigned long)sig->syscall);
672672
}
673673

674674
void platform_set_mr(struct sys_info *si, unsigned long start, unsigned long size,

examples/api/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ endif
1010
ifeq ($(ARCH),arm)
1111
LOAD_ADDR = 0x1000000
1212
endif
13+
ifeq ($(ARCH),mips)
14+
ifdef CONFIG_64BIT
15+
LOAD_ADDR = 0xffffffff80200000
16+
else
17+
LOAD_ADDR = 0x80200000
18+
endif
19+
endif
1320

1421
# Resulting ELF and binary exectuables will be named demo and demo.bin
1522
extra-y = demo

examples/api/crt0.S

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,38 @@ syscall:
4040
ldr ip, =syscall_ptr
4141
ldr pc, [ip]
4242

43+
#elif defined(CONFIG_MIPS)
44+
#include <asm/asm.h>
45+
.text
46+
.globl __start
47+
.ent __start
48+
__start:
49+
PTR_S $sp, search_hint
50+
b main
51+
.end __start
52+
53+
.globl syscall
54+
.ent syscall
55+
syscall:
56+
PTR_S $ra, return_addr
57+
PTR_L $t9, syscall_ptr
58+
jalr $t9
59+
nop
60+
PTR_L $ra, return_addr
61+
jr $ra
62+
nop
63+
.end syscall
64+
65+
return_addr:
66+
.align 8
67+
.long 0
4368
#else
4469
#error No support for this arch!
4570
#endif
4671

4772
.globl syscall_ptr
4873
syscall_ptr:
49-
.align 4
74+
.align 8
5075
.long 0
5176

5277
.globl search_hint

examples/api/glue.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int ub_getc(void)
7777
{
7878
int c;
7979

80-
if (!syscall(API_GETC, NULL, (uint32_t)&c))
80+
if (!syscall(API_GETC, NULL, &c))
8181
return -1;
8282

8383
return c;
@@ -87,20 +87,20 @@ int ub_tstc(void)
8787
{
8888
int t;
8989

90-
if (!syscall(API_TSTC, NULL, (uint32_t)&t))
90+
if (!syscall(API_TSTC, NULL, &t))
9191
return -1;
9292

9393
return t;
9494
}
9595

9696
void ub_putc(char c)
9797
{
98-
syscall(API_PUTC, NULL, (uint32_t)&c);
98+
syscall(API_PUTC, NULL, &c);
9999
}
100100

101101
void ub_puts(const char *s)
102102
{
103-
syscall(API_PUTS, NULL, (uint32_t)s);
103+
syscall(API_PUTS, NULL, s);
104104
}
105105

106106
/****************************************
@@ -126,7 +126,7 @@ struct sys_info * ub_get_sys_info(void)
126126
si.mr_no = UB_MAX_MR;
127127
memset(&mr, 0, sizeof(mr));
128128

129-
if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si))
129+
if (!syscall(API_GET_SYS_INFO, &err, &si))
130130
return NULL;
131131

132132
return ((err) ? NULL : &si);
@@ -344,15 +344,15 @@ char * ub_env_get(const char *name)
344344
{
345345
char *value;
346346

347-
if (!syscall(API_ENV_GET, NULL, (uint32_t)name, (uint32_t)&value))
347+
if (!syscall(API_ENV_GET, NULL, name, &value))
348348
return NULL;
349349

350350
return value;
351351
}
352352

353353
void ub_env_set(const char *name, char *value)
354354
{
355-
syscall(API_ENV_SET, NULL, (uint32_t)name, (uint32_t)value);
355+
syscall(API_ENV_SET, NULL, name, value);
356356
}
357357

358358
static char env_name[256];
@@ -369,7 +369,7 @@ const char * ub_env_enum(const char *last)
369369
* 'name=val' string), since the API_ENUM_ENV call uses envmatch()
370370
* internally, which handles such case
371371
*/
372-
if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env))
372+
if (!syscall(API_ENV_ENUM, NULL, last, &env))
373373
return NULL;
374374

375375
if (!env)
@@ -396,7 +396,7 @@ int ub_display_get_info(int type, struct display_info *di)
396396
{
397397
int err = 0;
398398

399-
if (!syscall(API_DISPLAY_GET_INFO, &err, (uint32_t)type, (uint32_t)di))
399+
if (!syscall(API_DISPLAY_GET_INFO, &err, type, di))
400400
return API_ESYSC;
401401

402402
return err;

0 commit comments

Comments
 (0)