All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: torvalds@linux-foundation.org, andi@firstfloor.org,
	linux-kernel@vger.kernel.org
Subject: Re: x86 setup code rewrite in C - revised
Date: Wed, 11 Jul 2007 13:29:44 -0700	[thread overview]
Message-ID: <46953DB8.6080008@zytor.com> (raw)
In-Reply-To: <469538A9.4010202@garzik.org>

[-- Attachment #1: Type: text/plain, Size: 740 bytes --]

Jeff Garzik wrote:
> 
> I'm sure you know what's changed since the last revision, but nobody
> everybody does :)  It would be nice to know what's different from the
> last posting.
> 

- Added -fno-toplevel-reorder/-fno-unit-at-a-time to the Makefile; this
  is necessary for .code16gcc to be safe on all current versions of gcc.
  Added comment to that effect to code16gcc.h.
- Moved strnlen, atou and isdigit out of printf.c.
- Corrected title of cpu.c and cpucheck.c.
- Fixed "paragraps" typo in pm.c.
- Removed bogus <linux/edd.h> in string.c.
- Removed #include <linux/mmzone.h> from asm-x86/e820.h; according to
  Andi it isn't needed even for non-_SETUP, and my compile testing seems
  to confirm that.

Full diff attached.

	-hpa



[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 5256 bytes --]

diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
index e9f46fd..08678a0 100644
--- a/arch/i386/boot/Makefile
+++ b/arch/i386/boot/Makefile
@@ -57,6 +57,8 @@ CFLAGS		:= $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
 		   -include $(srctree)/$(src)/code16gcc.h \
 		   -fno-strict-aliasing -fomit-frame-pointer \
 		   $(call cc-option, -ffreestanding) \
+		   $(call cc-option, -fno-toplevel-reorder,\
+			$(call cc-option, -fno-unit-at-a-time)) \
 		   $(call cc-option, -fno-stack-protector) \
 		   $(call cc-option, -mpreferred-stack-boundary=2)
 AFLAGS		:= $(CFLAGS) -D__ASSEMBLY__
diff --git a/arch/i386/boot/boot.h b/arch/i386/boot/boot.h
index 7251ef6..0329c4f 100644
--- a/arch/i386/boot/boot.h
+++ b/arch/i386/boot/boot.h
@@ -192,6 +192,11 @@ static inline int memcmp_gs(const void *s1, addr_t s2, size_t len)
 	return diff;
 }
 
+static inline int isdigit(int ch)
+{
+	return (ch >= '0') && (ch <= '9');
+}
+
 /* Heap -- available for dynamic lists. */
 #define STACK_SIZE	512	/* Minimum number of bytes for stack */
 
@@ -261,13 +266,14 @@ void __attribute__((noreturn))
 	protected_mode_jump(u32 entrypoint, u32 bootparams);
 
 /* printf.c */
-unsigned int atou(const char *s);
 int sprintf(char *buf, const char *fmt, ...);
 int vsprintf(char *buf, const char *fmt, va_list args);
 int printf(const char *fmt, ...);
 
 /* string.c */
 int strcmp(const char *str1, const char *str2);
+size_t strnlen(const char *s, size_t maxlen);
+unsigned int atou(const char *s);
 
 /* tty.c */
 void puts(const char *);
diff --git a/arch/i386/boot/code16gcc.h b/arch/i386/boot/code16gcc.h
index dbc6414..3bd8480 100644
--- a/arch/i386/boot/code16gcc.h
+++ b/arch/i386/boot/code16gcc.h
@@ -2,6 +2,12 @@
  * code16gcc.h
  *
  * This file is -include'd when compiling 16-bit C code.
+ * Note: this asm() needs to be emitted before gcc omits any code.
+ * Depending on gcc version, this requires -fno-unit-at-a-time or
+ * -fno-toplevel-reorder.
+ *
+ * Hopefully gcc will eventually have a real -m16 option so we can
+ * drop this hack long term.
  */
 
 #ifndef __ASSEMBLY__
diff --git a/arch/i386/boot/cpu.c b/arch/i386/boot/cpu.c
index 042d894..2a5c32d 100644
--- a/arch/i386/boot/cpu.c
+++ b/arch/i386/boot/cpu.c
@@ -9,7 +9,7 @@
  * ----------------------------------------------------------------------- */
 
 /*
- * arch/i386/boot/cpucheck.c
+ * arch/i386/boot/cpu.c
  *
  * Check for obligatory CPU features and abort if the features are not
  * present.
diff --git a/arch/i386/boot/cpucheck.c b/arch/i386/boot/cpucheck.c
index 431bef8..8b0f447 100644
--- a/arch/i386/boot/cpucheck.c
+++ b/arch/i386/boot/cpucheck.c
@@ -9,7 +9,7 @@
  * ----------------------------------------------------------------------- */
 
 /*
- * arch/i386/boot/cpu.c
+ * arch/i386/boot/cpucheck.c
  *
  * Check for obligatory CPU features and abort if the features are not
  * present.  This code should be compilable as 16-, 32- or 64-bit
diff --git a/arch/i386/boot/pm.c b/arch/i386/boot/pm.c
index 4deb298..3fa53e1 100644
--- a/arch/i386/boot/pm.c
+++ b/arch/i386/boot/pm.c
@@ -49,7 +49,7 @@ static void move_kernel_around(void)
 
 	dst_seg =  0x1000 >> 4;
 	src_seg = 0x10000 >> 4;
-	syssize = boot_params.hdr.syssize; /* Size in 16-byte paragraps */
+	syssize = boot_params.hdr.syssize; /* Size in 16-byte paragraphs */
 
 	while (syssize) {
 		int paras  = (syssize >= 0x1000) ? 0x1000 : syssize;
diff --git a/arch/i386/boot/printf.c b/arch/i386/boot/printf.c
index ee3d9fc..1a09f93 100644
--- a/arch/i386/boot/printf.c
+++ b/arch/i386/boot/printf.c
@@ -19,11 +19,6 @@
 
 #include "boot.h"
 
-static inline int isdigit(int ch)
-{
-	return (ch >= '0') && (ch <= '9');
-}
-
 static int skip_atoi(const char **s)
 {
 	int i = 0;
@@ -33,25 +28,6 @@ static int skip_atoi(const char **s)
 	return i;
 }
 
-unsigned int atou(const char *s)
-{
-	unsigned int i = 0;
-	while (isdigit(*s))
-		i = i * 10 + (*s++ - '0');
-	return i;
-}
-
-static int strnlen(const char *s, int maxlen)
-{
-	const char *es = s;
-	while (*es && maxlen) {
-		es++;
-		maxlen--;
-	}
-
-	return (es - s);
-}
-
 #define ZEROPAD	1		/* pad with zero */
 #define SIGN	2		/* unsigned/signed long */
 #define PLUS	4		/* show plus */
diff --git a/arch/i386/boot/string.c b/arch/i386/boot/string.c
index 0808197..481a220 100644
--- a/arch/i386/boot/string.c
+++ b/arch/i386/boot/string.c
@@ -15,7 +15,6 @@
  */
 
 #include "boot.h"
-#include <linux/edd.h>
 
 int strcmp(const char *str1, const char *str2)
 {
@@ -32,3 +31,22 @@ int strcmp(const char *str1, const char *str2)
 	}
 	return 0;
 }
+
+size_t strnlen(const char *s, size_t maxlen)
+{
+	const char *es = s;
+	while (*es && maxlen) {
+		es++;
+		maxlen--;
+	}
+
+	return (es - s);
+}
+
+unsigned int atou(const char *s)
+{
+	unsigned int i = 0;
+	while (isdigit(*s))
+		i = i * 10 + (*s++ - '0');
+	return i;
+}
diff --git a/include/asm-x86_64/e820.h b/include/asm-x86_64/e820.h
index 15eb8e2..3486e70 100644
--- a/include/asm-x86_64/e820.h
+++ b/include/asm-x86_64/e820.h
@@ -11,10 +11,6 @@
 #ifndef __E820_HEADER
 #define __E820_HEADER
 
-#ifndef _SETUP
-# include <linux/mmzone.h>
-#endif
-
 #define E820MAP	0x2d0		/* our map */
 #define E820MAX	128		/* number of entries in E820MAP */
 #define E820NR	0x1e8		/* # entries in E820MAP */

  reply	other threads:[~2007-07-11 20:30 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-11 19:18 x86 setup code rewrite in C - revised H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 01/33] x86 setup: MAINTAINERS: formally take responsibility for the i386 boot code H. Peter Anvin
2007-07-11 19:18   ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 02/33] hd.c: remove BIOS/CMOS queries H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 03/33] include/asm-i386/boot.h: This is <asm/boot.h>, not <linux/boot.h> H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 04/33] Unify the CPU features vectors between i386 and x86-64 H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 05/33] Change CONFIG_X86_MINIMUM_CPU_MODEL to CONFIG_X86_MINIMUM_CPU_FAMILY H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 06/33] Clean up struct screen_info (<linux/screen_info.h>) H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 07/33] Use a new CPU feature word to cover all Intel features that are spread around H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 08/33] Define zero-page offset 0x1e4 as a scratch field, and use it H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 09/33] Make definitions for struct e820entry and struct e820map consistent H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 10/33] Make struct boot_params a real structure, and remove obsolete fields H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 11/33] x86-64: add CONFIG_PHYSICAL_ALIGN for consistency with i386 H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 12/33] x86-64: add symbolic constants for the boot segment selectors H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 13/33] Header file to produce 16-bit code with gcc H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 14/33] Top header file for new x86 setup code H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 15/33] Simple bitops for the " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 16/33] String-handling functions " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 17/33] A20 handling code H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 18/33] APM probing code H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 19/33] Command-line parsing code for the new x86 setup code H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 20/33] Console-writing " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 21/33] Version string " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 22/33] CPU features verification " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 23/33] EDD probing code " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 24/33] MCA support for " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 25/33] Memory probing support for the " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 26/33] Voyager " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 27/33] Video mode probing " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-16 10:59     ` Martin Mares
2007-07-11 19:18   ` [x86 setup 28/33] Code for actual protected-mode entry H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 29/33] Assembly header and main routine for new x86 setup code H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 30/33] Linker script for the " H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 31/33] Use the new x86 setup code for i386 H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-13  9:27       ` Tilman Schmidt
2007-07-11 19:18   ` [x86 setup 32/33] Use the new x86 setup code for x86-64; unify with i386 H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 33/33] Remove old i386 setup code H. Peter Anvin
2007-07-11 19:18     ` H. Peter Anvin
2007-07-11 20:08 ` x86 setup code rewrite in C - revised Jeff Garzik
2007-07-11 20:29   ` H. Peter Anvin [this message]
2007-07-12 17:24 ` Linus Torvalds
2007-07-12 17:30   ` Andrew Morton
2007-07-12 17:49     ` Linus Torvalds
2007-07-12 19:38   ` Andi Kleen
  -- strict thread matches above, loose matches on Subject: below --
2007-07-12 13:18 Etienne Lorrain
2007-07-13 14:25 Etienne Lorrain
2007-07-13 16:35 ` Chuck Ebbert
2007-07-13 16:51   ` H. Peter Anvin
2007-07-13 22:23   ` H. Peter Anvin
2007-07-16 13:31     ` Etienne Lorrain
2007-07-16 17:35       ` H. Peter Anvin
2007-07-13 14:42 Etienne Lorrain
2007-07-16  9:15 RE : Re: RE : " H. Peter Anvin
2007-07-16 10:21 ` Etienne Lorrain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46953DB8.6080008@zytor.com \
    --to=hpa@zytor.com \
    --cc=andi@firstfloor.org \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.