x86: Early-boot serial I/O support
PATCH v3 1/1 x86: Early-boot serial I/O support
This patch adds serial I/O support to very early boot printf(). It's useful for debugging boot code when running Linux under KVM, for example. The actual code was lifted from early printk.
---
v2 -> v3:
- Remove 'memory' from cpu_relax as suggested by hpa
arch/x86/boot/boot.h | 16 +++++++ arch/x86/boot/main.c | 3 + arch/x86/boot/string.c | 41 ++++++++++++++++++ arch/x86/boot/tty.c | 111 +++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 165 insertions(+), 6 deletions(-)
arch/x86/boot/boot.h +16 -0
@@ -37,6 +37,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) {
@@ -203,6 +205,17 @@ 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' ); +} +/* Heap -- available for dynamic lists. */ extern char _end[];extern char *HEAP ;
@@ -329,10 +342,13 @@ 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 console_init (void );void puts (const char *);void putchar (int );int getchar (void );
arch/x86/boot/main.c +3 -0
@@ -130,6 +130,9 @@ void main(void)/* First, copy the boot header into the "zeropage" */ copy_boot_params (); +/* Initialize the early-boot console */ +console_init (); +/* End of heap check */ init_heap ();
arch/x86/boot/string.c +41 -0
50 lines not on this page · raw message
arch/x86/boot/tty.c +105 -6
137 lines not on this page · raw message
Signature · 1 line
1.6.3.3
[tip:x86/setup] x86, setup: Early-boot serial I/O support
Commit-ID: fa97bdf92709adaaf8b9a5164a895e262a4fcf60 Gitweb: http://git.kernel.org/tip/fa97bdf92709adaaf8b9a5164a895e262a4fcf60 Author: Pekka Enberg <[email protected]> AuthorDate: Sun, 11 Jul 2010 11:06:57 +0300 Committer: H. Peter Anvin <[email protected]> CommitDate: Mon, 12 Jul 2010 14:46:00 -0700
x86, setup: Early-boot serial I/O support
This patch adds serial I/O support to the real-mode setup (very early boot) printf(). It's useful for debugging boot code when running Linux under KVM, for example. The actual code was lifted from early printk.
LKML-Reference: <[email protected]>
--- arch/x86/boot/boot.h | 16 +++++++ arch/x86/boot/main.c | 3 + arch/x86/boot/string.c | 41 ++++++++++++++++++ arch/x86/boot/tty.c | 111 +++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 165 insertions(+), 6 deletions(-)
arch/x86/boot/boot.h +16 -0
@@ -37,6 +37,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) {
@@ -203,6 +205,17 @@ 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' ); +} +/* Heap -- available for dynamic lists. */ extern char _end[];extern char *HEAP ;
@@ -329,10 +342,13 @@ 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 console_init (void );void puts (const char *);void putchar (int );int getchar (void );
arch/x86/boot/main.c +3 -0
@@ -130,6 +130,9 @@ void main(void)/* First, copy the boot header into the "zeropage" */ copy_boot_params (); +/* Initialize the early-boot console */ +console_init (); +/* End of heap check */ init_heap ();
arch/x86/boot/string.c +41 -0
50 lines not on this page · raw message
arch/x86/boot/tty.c +105 -6
137 lines not on this page · raw message