[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <p73zmeoz2l4.fsf@verdi.suse.de>
Date: 01 Aug 2006 21:19:03 +0200
From: Andi Kleen <ak@...e.de>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: <linux-kernel@...r.kernel.org>, Horms <horms@...ge.net.au>,
Jan Kratochvil <lace@...kratochvil.net>,
"H. Peter Anvin" <hpa@...or.com>,
Magnus Damm <magnus.damm@...il.com>,
Vivek Goyal <vgoyal@...ibm.com>, Linda Wang <lwang@...hat.com>
Subject: Re: [PATCH 9/33] i386 boot: Add serial output support to the decompressor
"Eric W. Biederman" <ebiederm@...ssion.com> writes:
> }
> @@ -200,6 +224,178 @@ static void putstr(const char *s)
> outb_p(0xff & (pos >> 1), vidport+1);
> }
>
> +static void vid_console_init(void)
Please just use early_printk instead of reimplementing this.
I think it should work in this context too.
> +static inline int tolower(int ch)
> +{
> + return ch | 0x20;
> +}
> +
> +static inline int isdigit(int ch)
> +{
> + return (ch >= '0') && (ch <= '9');
> +}
> +
> +static inline int isxdigit(int ch)
> +{
> + ch = tolower(ch);
> + return isdigit(ch) || ((ch >= 'a') && (ch <= 'f'));
> +}
And please reuse the Linux code here.
Actually the best way to reuse would be to first do 64bit uncompressor
and linker directly, but short of that #includes would be fine too.
> +
> +
> +static inline int digval(int ch)
> +{
> + return isdigit(ch)? (ch - '0') : tolower(ch) - 'a' + 10;
> +}
> +
> +/**
> + * simple_strtou - convert a string to an unsigned
> + * @cp: The start of the string
> + * @endp: A pointer to the end of the parsed string will be placed here
> + * @base: The number base to use
> + */
> +static unsigned simple_strtou(const char *cp, char **endp, unsigned base)
> +{
> + unsigned result = 0,value;
> +
> + if (!base) {
> + base = 10;
> + if (*cp == '0') {
> + base = 8;
> + cp++;
> + if ((tolower(*cp) == 'x') && isxdigit(cp[1])) {
> + cp++;
> + base = 16;
> + }
> + }
> + } else if (base == 16) {
> + if (cp[0] == '0' && tolower(cp[1]) == 'x')
> + cp += 2;
> + }
> + while (isxdigit(*cp) && ((value = digval(*cp)) < base)) {
> + result = result*base + value;
> + cp++;
> + }
> + if (endp)
> + *endp = (char *)cp;
> + return result;
> +}
Can you please somehow reuse the Linux one?
> +
> static void* memset(void* s, int c, unsigned n)
> {
> int i;
> @@ -218,6 +414,29 @@ static void* memcpy(void* dest, const vo
> return dest;
> }
>
> +static int memcmp(const void *s1, const void *s2, unsigned n)
> +{
> + const unsigned char *str1 = s1, *str2 = s2;
> + size_t i;
> + int result = 0;
> + for(i = 0; (result == 0) && (i < n); i++) {
> + result = *str1++ - *str2++;
> + }
> + return result;
> +}
> +
> +char *strstr(const char *haystack, const char *needle)
> +{
> + size_t len;
> + len = strlen(needle);
> + while(*haystack) {
> + if (memcmp(haystack, needle, len) == 0)
> + return (char *)haystack;
> + haystack++;
> + }
> + return NULL;
Would be better to just pull in lib/string.c
-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists