x86/setup for 2.6.36
Hi Linus,
The following changes since commit cdd854bc42b5e6c79bbbc40c6600d995ffe6e747:
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc (2010-08-05 09:03:46 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-setup-for-linus
H. Peter Anvin (2):
x86, setup: Allow global variables and functions in the decompressor x86, setup: move isdigit.h to ctype.h, header files on top.
Pekka Enberg (1):
x86, setup: Early-boot serial I/O support
Yinghai Lu (4):
x86, setup: Make the setup code also accept console=uart8250 x86, setup: Only set early_serial_base after port is initialized x86, setup: reorganize the early console setup
x86, setup: enable early console output from the decompressor
arch/x86/boot/Makefile | 8 +- arch/x86/boot/boot.h | 28 ++++- arch/x86/boot/cmdline.c | 6 +- arch/x86/boot/compressed/Makefile | 4 +- arch/x86/boot/compressed/cmdline.c | 21 ++++ arch/x86/boot/compressed/early_serial_console.c | 5 + arch/x86/boot/compressed/head_32.S | 13 ++ arch/x86/boot/compressed/head_64.S | 13 ++ arch/x86/boot/compressed/misc.c | 56 ++++++---- arch/x86/boot/compressed/misc.h | 39 +++++++ arch/x86/boot/compressed/string.c | 2 + arch/x86/boot/compressed/vmlinux.lds.S | 6 + arch/x86/boot/ctype.h | 21 ++++ arch/x86/boot/early_serial_console.c | 139 +++++++++++++++++++++++ arch/x86/boot/main.c | 9 +- arch/x86/boot/printf.c | 4 +- arch/x86/boot/string.c | 63 ++++++++++ arch/x86/boot/tty.c | 37 +++++- 18 files changed, 422 insertions(+), 52 deletions(-) create mode 100644 arch/x86/boot/compressed/cmdline.c create mode 100644 arch/x86/boot/compressed/early_serial_console.c create mode 100644 arch/x86/boot/compressed/misc.h create mode 100644 arch/x86/boot/compressed/string.c create mode 100644 arch/x86/boot/ctype.h create mode 100644 arch/x86/boot/early_serial_console.c
arch/x86/boot/Makefile +4 -4
@@ -26,10 +26,10 @@ targets := vmlinux.bin setup.bin setup.elf bzImage targets += fdimage fdimage144 fdimage288 image.iso mtools.conf subdir- := compressed -setup-y += a20.o bioscall.o cmdline.o copy.o cpu.o cpucheck.o edd.o -setup-y += header.o main.o mca.o memory.o pm.o pmjump.o -setup-y += printf.o regs.o string.o tty.o video.o video-mode.o -setup-y += version.o +setup-y += a20.o bioscall.o cmdline.o copy.o cpu.o cpucheck.o +setup-y += early_serial_console.o edd.o header.o main.o mca.o memory.o +setup-y += pm.o pmjump.o printf.o regs.o string.o tty.o video.o +setup-y += video-mode.o version.o setup-$(CONFIG_X86_APM_BOOT) += apm.o # The link order of the video-*.o modules can matter. In particular,
arch/x86/boot/boot.h +21 -7
@@ -28,6 +28,7 @@#include "bitops.h" #include <asm/cpufeature.h> #include <asm/processor-flags.h> +#include "ctype.h" /* Useful macros */ #define BUILD_BUG_ON (condition) ((void)sizeof(char[1 - 2*!!(condition)]))
@@ -37,6 +38,8 @@extern struct setup_header hdr;extern struct boot_params boot_params; +#define cpu_relax () asm volatile("rep; nop") +/* Basic port I/O */ static inline void outb (u8 v,u16 port) {
@@ -198,11 +201,6 @@ 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. */ extern char _end[];extern char *HEAP ;
@@ -287,8 +285,18 @@ struct biosregs {void intcall (u8 int_no,const struct biosregs *ireg,struct biosregs *oreg);/* cmdline.c */ -int cmdline_find_option (const char *option,char *buffer,int bufsize); -int cmdline_find_option_bool (const char *option); +int __cmdline_find_option (u32 cmdline_ptr,const char *option,char *buffer,int bufsize); +int __cmdline_find_option_bool (u32 cmdline_ptr,const char *option); +static inline int cmdline_find_option (const char *option,char *buffer,int bufsize) +{ +return __cmdline_find_option (boot_params.hdr.cmd_line_ptr, option, buffer, bufsize); +} + +static inline int cmdline_find_option_bool (const char *option) +{ +return __cmdline_find_option_bool (boot_params.hdr.cmd_line_ptr, option); +} +/* cpu.c, cpucheck.c */ struct cpu_features {
@@ -300,6 +308,10 @@ extern struct cpu_features cpu;int check_cpu (int *cpu_level_ptr,int *req_level_ptr,u32 **err_flags_ptr);int validate_cpu (void ); +/* early_serial_console.c */ +extern int early_serial_base; +void console_init (void ); +/* edd.c */ void query_edd (void );
@@ -329,8 +341,10 @@ void initregs(struct biosregs *regs);/* string.c */ int strcmp (const char *str1,const char *str2); +int strncmp (const char *cs,const char *ct,size_t count);size_t strnlen (const char *s,size_t maxlen);unsigned int atou (const char *s); +unsigned long long simple_strtoull (const char *cp,char **endp,unsigned int base);/* tty.c */ void puts (const char *);
arch/x86/boot/cmdline.c +2 -4
@@ -27,9 +27,8 @@ static inline int myisspace(u8 c)* Returns the length of the argument (regardless of if it was * truncated to fit in the buffer), or -1 on not found. */ -int cmdline_find_option (const char *option,char *buffer,int bufsize) +int __cmdline_find_option (u32 cmdline_ptr,const char *option,char *buffer,int bufsize) { -u32 cmdline_ptr = boot_params.hdr.cmd_line_ptr;addr_t cptr;char c;int len =-1 ;
@@ -100,9 +99,8 @@ int cmdline_find_option(const char *option, char *buffer, int bufsize)* Returns the position of that option (starts counting with 1) * or 0 on not found */ -int cmdline_find_option_bool (const char *option) +int __cmdline_find_option_bool (u32 cmdline_ptr,const char *option) { -u32 cmdline_ptr = boot_params.hdr.cmd_line_ptr;addr_t cptr;char c;int pos =0 , wstart =0 ;
arch/x86/boot/compressed/Makefile +2 -2
@@ -4,7 +4,7 @@ # create a compressed vmlinux image from the original vmlinux # -targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.lzo head_$(BITS).o misc.o piggy.o +targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.lzo head_$(BITS).o misc.o string.o cmdline.o early_serial_console.o piggy.o KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
@@ -23,7 +23,7 @@ LDFLAGS_vmlinux := -T hostprogs-y := mkpiggy -$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/piggy.o FORCE +$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o $(obj)/piggy.o FORCE $(call if_changed,ld) @:
arch/x86/boot/compressed/cmdline.c new file +21 -0
@@ -0,0 +1,21 @@ +#include "misc.h" + +static unsigned long fs; +static inline void set_fs (unsigned long seg) +{ + fs = seg <<4 ;/* shift it back */ +} +typedef unsigned long addr_t ; +static inline char rdfs8 (addr_t addr) +{ +return *((char *)(fs + addr)); +} +#include "../cmdline.c" +int cmdline_find_option (const char *option,char *buffer,int bufsize) +{ +return __cmdline_find_option (real_mode->hdr.cmd_line_ptr, option, buffer, bufsize); +} +int cmdline_find_option_bool (const char *option) +{ +return __cmdline_find_option_bool (real_mode->hdr.cmd_line_ptr, option); +}
arch/x86/boot/compressed/early_serial_console.c new file +5 -0
@@ -0,0 +1,5 @@ +#include "misc.h" + +int early_serial_base; + +#include "../early_serial_console.c"
arch/x86/boot/compressed/head_32.S +13 -0
@@ -124,6 +124,19 @@ relocated: rep stosl /* + * Adjust our own GOT + */ + leal _got(%ebx), %edx + leal _egot(%ebx), %ecx +1: + cmpl %ecx, %edx + jae 2f + addl %ebx, (%edx) + addl $4, %edx + jmp 1b +2: + +/* * Do the decompression, and jump to the new kernel.. */ leal z_extract_offset_negative(%ebx), %ebp
arch/x86/boot/compressed/head_64.S +13 -0
@@ -280,6 +280,19 @@ relocated: rep stosq /* + * Adjust our own GOT + */ + leaq _got(%rip), %rdx + leaq _egot(%rip), %rcx +1: + cmpq %rcx, %rdx + jae 2f + addq %rbx, (%rdx) + addq $8, %rdx + jmp 1b +2: + +/* * Do the decompression, and jump to the new kernel.. */ pushq %rsi /* Save the real mode argument */
arch/x86/boot/compressed/misc.c +33 -23
98 lines not on this page · raw message
arch/x86/boot/compressed/misc.h new file +39 -0
@@ -0,0 +1,39 @@ +#ifndef BOOT_COMPRESSED_MISC_H +#define BOOT_COMPRESSED_MISC_H + +/* +* we have to be careful, because no indirections are allowed here, and +* paravirt_ops is a kind of one. As it will only run in baremetal anyway, +* we just keep it from happening +*/ +#undef CONFIG_PARAVIRT +#ifdef CONFIG_X86_32 +#define _ASM_X86_DESC_H 1 +#endif + +#include <linux/linkage.h> +#include <linux/screen_info.h> +#include <linux/elf.h> +#include <linux/io.h> +#include <asm/page.h> +#include <asm/boot.h> +#include <asm/bootparam.h> + +#define BOOT_BOOT_H +#include "../ctype.h" + +/* misc.c */ +extern struct boot_params *real_mode;/* Pointer to real-mode data */ +void __putstr (int error,const char *s); +#define putstr (__x) __putstr(0, __x) +#define puts (__x) __putstr(0, __x) + +/* cmdline.c */ +int cmdline_find_option (const char *option,char *buffer,int bufsize); +int cmdline_find_option_bool (const char *option); + +/* early_serial_console.c */ +extern int early_serial_base; +void console_init (void ); + +#endif
arch/x86/boot/compressed/string.c new file +2 -0
@@ -0,0 +1,2 @@ +#include "misc.h" +#include "../string.c"
arch/x86/boot/compressed/vmlinux.lds.S +6 -0
@@ -41,6 +41,12 @@ SECTIONS *(.rodata.*) _erodata = . ; } + .got : { + _got = .; + KEEP(*(.got.plt)) + KEEP(*(.got)) + _egot = .; + } .data : { _data = . ; *(.data)
arch/x86/boot/ctype.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef BOOT_ISDIGIT_H + +#define BOOT_ISDIGIT_H + +static inline int isdigit (int ch) +{ +return (ch >='0' ) && (ch <='9' ); +} + +static inline int isxdigit (int ch) +{ +if (isdigit (ch)) +return true; + +if ((ch >='a' ) && (ch <='f' )) +return true; + +return (ch >='A' ) && (ch <='F' ); +} + +#endif
arch/x86/boot/early_serial_console.c new file +139 -0
139 lines not on this page · raw message
arch/x86/boot/main.c +5 -4
@@ -130,6 +130,11 @@ void main(void)/* First, copy the boot header into the "zeropage" */ copy_boot_params (); +/* Initialize the early-boot console */ +console_init (); +if (cmdline_find_option_bool ("debug" )) +puts ("early console in setup code\n" ); +/* End of heap check */ init_heap ();
@@ -168,10 +173,6 @@ void main(void)/* Set the video mode */ set_video (); -/* Parse command line for 'quiet' and pass it to decompressor. */ -if (cmdline_find_option_bool ("quiet" )) - boot_params.hdr.loadflags |=QUIET_FLAG ; -/* Do the last things and invoke protected mode */ go_to_protected_mode (); }
arch/x86/boot/printf.c +2 -2
@@ -34,7 +34,7 @@ static int skip_atoi(const char **s)#define SMALL 32/* Must be 32 == 0x20 */ #define SPECIAL 64/* 0x */ -#define do_div (n,base) ({ \ +#define __do_div (n, base) ({ \ int __res; \ __res = ((unsigned long) n) % (unsigned) base; \ n = ((unsigned long) n) / (unsigned) base; \
@@ -83,7 +83,7 @@ static char *number(char *str, long num, int base, int size, int precision, tmp[i++] ='0' ; else while (num != 0) - tmp[i++] = (digits[do_div (num, base)] | locase); + tmp[i++] = (digits[__do_div (num, base)] | locase);if (i > precision) precision = i; size -= precision;
arch/x86/boot/string.c +63 -0
72 lines not on this page · raw message
arch/x86/boot/tty.c +31 -6
@@ -10,23 +10,36 @@* ----------------------------------------------------------------------- */ /* -* Very simple screen I/O -* XXX: Probably should add very simple serial I/O? +* Very simple screen and serial I/O */ #include "boot.h" +int early_serial_base; + +#define XMTRDY 0x20 + +#define TXR 0/* Transmit register (WRITE) */ +#define LSR 5/* Line Status */ +/* * These functions are in .inittext so they can be used to signal * error during initialization. */ -void __attribute__((section (".inittext" )))putchar (int ch) +static void __attribute__((section (".inittext" )))serial_putchar (int ch) { -struct biosregs ireg; +unsigned timeout =0xffff ; -if (ch =='\n' ) -putchar ('\r' );/* \n -> \r\n */ +while ((inb (early_serial_base +LSR ) &XMTRDY ) ==0 && --timeout) +cpu_relax (); + +outb (ch, early_serial_base +TXR ); +} + +static void __attribute__((section (".inittext" )))bios_putchar (int ch) +{ +struct biosregs ireg;initregs (&ireg); ireg.bx =0x0007 ;
@@ -36,6 +49,17 @@ void __attribute__((section(".inittext"))) putchar(int ch)intcall (0x10 , &ireg,NULL ); } +void __attribute__((section (".inittext" )))putchar (int ch) +{ +if (ch =='\n' ) +putchar ('\r' );/* \n -> \r\n */ + +bios_putchar (ch); + +if (early_serial_base !=0 ) +serial_putchar (ch); +} +void __attribute__((section (".inittext" )))puts (const char *str) {while (*str)
@@ -112,3 +136,4 @@ int getchar_timeout(void)return 0 ;/* Timeout! */ } +
H. Peter Anvin
reviewerScript fail, sorry for the repeated messages.
-hpa