Skip to content

Commit

Permalink
Merge branch 'x86-setup-for-linus' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/tip/linux-2.6-tip

* 'x86-setup-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86, setup: move isdigit.h to ctype.h, header files on top.
  x86, setup: enable early console output from the decompressor
  x86, setup: reorganize the early console setup
  x86, setup: Allow global variables and functions in the decompressor
  x86, setup: Only set early_serial_base after port is initialized
  x86, setup: Make the setup code also accept console=uart8250
  x86, setup: Early-boot serial I/O support
  • Loading branch information
Linus Torvalds committed Aug 6, 2010
2 parents 9faa1e5 + 6238b47 commit a417fb9
Show file tree
Hide file tree
Showing 18 changed files with 422 additions and 52 deletions.
8 changes: 4 additions & 4 deletions arch/x86/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 21 additions & 7 deletions arch/x86/boot/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)]))
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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);

Expand Down Expand Up @@ -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 *);
Expand Down
6 changes: 2 additions & 4 deletions arch/x86/boot/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
@:

Expand Down
21 changes: 21 additions & 0 deletions arch/x86/boot/compressed/cmdline.c
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 5 additions & 0 deletions arch/x86/boot/compressed/early_serial_console.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "misc.h"

int early_serial_base;

#include "../early_serial_console.c"
13 changes: 13 additions & 0 deletions arch/x86/boot/compressed/head_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ relocated:
shrl $2, %ecx
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..
*/
Expand Down
13 changes: 13 additions & 0 deletions arch/x86/boot/compressed/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,19 @@ relocated:
shrq $3, %rcx
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..
*/
Expand Down
56 changes: 33 additions & 23 deletions arch/x86/boot/compressed/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,7 @@
* High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
*/

/*
* 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>
#include "misc.h"

/* WARNING!!
* This code is compiled with -fPIC and it is relocated dynamically
Expand Down Expand Up @@ -123,15 +107,13 @@ static void error(char *m);
/*
* This is set up by the setup-routine at boot-time
*/
static struct boot_params *real_mode; /* Pointer to real-mode data */
struct boot_params *real_mode; /* Pointer to real-mode data */
static int quiet;
static int debug;

void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);

static void __putstr(int, const char *);
#define putstr(__x) __putstr(0, __x)

#ifdef CONFIG_X86_64
#define memptr long
#else
Expand Down Expand Up @@ -170,7 +152,21 @@ static void scroll(void)
vidmem[i] = ' ';
}

static void __putstr(int error, const char *s)
#define XMTRDY 0x20

#define TXR 0 /* Transmit register (WRITE) */
#define LSR 5 /* Line Status */
static void serial_putchar(int ch)
{
unsigned timeout = 0xffff;

while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
cpu_relax();

outb(ch, early_serial_base + TXR);
}

void __putstr(int error, const char *s)
{
int x, y, pos;
char c;
Expand All @@ -179,6 +175,14 @@ static void __putstr(int error, const char *s)
if (!error)
return;
#endif
if (early_serial_base) {
const char *str = s;
while (*str) {
if (*str == '\n')
serial_putchar('\r');
serial_putchar(*str++);
}
}

if (real_mode->screen_info.orig_video_mode == 0 &&
lines == 0 && cols == 0)
Expand Down Expand Up @@ -305,8 +309,10 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
{
real_mode = rmode;

if (real_mode->hdr.loadflags & QUIET_FLAG)
if (cmdline_find_option_bool("quiet"))
quiet = 1;
if (cmdline_find_option_bool("debug"))
debug = 1;

if (real_mode->screen_info.orig_video_mode == 7) {
vidmem = (char *) 0xb0000;
Expand All @@ -319,6 +325,10 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
lines = real_mode->screen_info.orig_video_lines;
cols = real_mode->screen_info.orig_video_cols;

console_init();
if (debug)
putstr("early console in decompress_kernel\n");

free_mem_ptr = heap; /* Heap */
free_mem_end_ptr = heap + BOOT_HEAP_SIZE;

Expand Down
39 changes: 39 additions & 0 deletions arch/x86/boot/compressed/misc.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions arch/x86/boot/compressed/string.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "misc.h"
#include "../string.c"
6 changes: 6 additions & 0 deletions arch/x86/boot/compressed/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ SECTIONS
*(.rodata.*)
_erodata = . ;
}
.got : {
_got = .;
KEEP(*(.got.plt))
KEEP(*(.got))
_egot = .;
}
.data : {
_data = . ;
*(.data)
Expand Down
21 changes: 21 additions & 0 deletions arch/x86/boot/ctype.h
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit a417fb9

Please sign in to comment.