Re: [PATCH 9/33] i386 boot: Add serial output support to the decompressor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Eric W. Biederman" <[email protected]> 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux