bare-io.c 1.31 KB
Newer Older
1
/*
2
 * Alessandro Rubini for CERN, 2011 -- GPL 2 or later (it includes u-boot code)
3
 */
4
#include <pptp/pptp.h>
5 6 7 8 9 10 11 12 13 14
#include "bare-linux.h"

void pp_puts(const char *s)
{
	sys_write(0, s, pp_strnlen(s, 300));
}

int pp_strnlen(const char *s, int maxlen)
{
	int len = 0;
15 16
	while (*(s++))
		len++;
17 18 19
	return len;
}

20
void *pp_memcpy(void *dest, const void *src, int count)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
{
	/* from u-boot-1.1.2 */
	char *tmp = (char *) dest, *s = (char *) src;

	while (count--)
		*tmp++ = *s++;

	return dest;
}

void pp_get_stamp(uint32_t *sptr)
{
	*sptr = htonl(sys_time(0));
}

36
int pp_memcmp(const void *cs, const void *ct, int count)
37 38
{
	/* from u-boot-1.1.2 */
39 40
	const unsigned char *su1, *su2;
	int res = 0;
41

42 43 44 45
	for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
		if ((res = *su1 - *su2) != 0)
			break;
	return res;
46 47
}

48
void *pp_memset(void *s, int c, int count)
49 50 51 52 53 54 55 56 57 58
{
	/* from u-boot-1.1.2 */
	char *xs = (char *) s;

	while (count--)
		*xs++ = c;

	return s;
}

59 60
/* What follows has no prefix because it's only used by arch code */
char *strcpy(char *dest, const char *src)
61 62
{
	/* from u-boot-1.1.2 */
63
	char *tmp = dest;
64

65 66 67
	while ((*dest++ = *src++) != '\0')
		/* nothing */;
	return tmp;
68
}
69 70 71 72 73 74

void *memset(void *s, int c, int count)
	__attribute__((alias("pp_memset")));

void *memcpy(void *dest, const void *src, int count)
	__attribute__((alias("pp_memcpy")));