auto serial port configuration
PATCH 1/1 auto serial port configuration
This patch allows runtime autoconfiguration of the serial console.
Right now on PowerPC, we're configuring the serial port by appending "com1=..." to cmdline, which is inflexible and inefficient.
Also, we're using a couple systems whose firmware use different baud rates for the serial console (115200 and 19200). It is annoying or impossible to set environment variables in these firmwares right now, which makes autoconfiguration important.
This patch does a few things:
- It allows us to automatically enable the serial console ("console=com1").
- It gives the ns16550 parameters reasonable defaults (8n1).
- If baud is unspecified, do not reconfigure the ns16550 baud rate (use whatever firmware was using).
- It allows us to automatically configure ns16550 parameters ("com1=baud,..."). All parameters are optional (so you can selectively override the defaults).
I've included the PowerPC code so you could see an example of a user. (Side
note: Open Firmware systems provide the system's hardware configuration in a data structure called the "device tree". In particular, the ISA IO base, used to emulate ISA IO on systems that only have MMIO, is at an arbitrary physical address; we only know where that is at runtime, when the device tree tells us.)
If there are no objections, please apply.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
xen/drivers/char/console.c +16 -0
@@ -441,6 +441,22 @@strcpy (printk_prefix, prefix); } +void use_serial_console (unsigned int index,char flag) +{ +if (index >1 ) { +printk ("ERROR: bad serial-interface index %d\n" , index); +return ; + } + sercon_handle = index; + +if (flag =='H' ) + sercon_handle |=SERHND_HI ; +else if (flag =='L' ) + sercon_handle |=SERHND_LO ; + + sercon_handle |=SERHND_COOKED ; +} +void init_console (void ) {char *p;
xen/drivers/char/ns16550.c +75 -13
118 lines not on this page · raw message
xen/include/xen/console.h +1 -0
@@ -16,6 +16,7 @@long read_console_ring (char **,u32 *,int );void init_console (void ); +void use_serial_console (unsigned int index,char flag);void console_endboot (int disable_vga);void console_force_unlock (void );
xen/include/xen/serial.h +4 -0
@@ -114,6 +114,10 @@* Initialisers for individual uart drivers. */ void ns16550_init (void ); +void ns16550_port_register (unsigned int index); +void ns16550_port_config (unsigned int index,int baud,int data_bits, +char parity,int stop_bits,int irq, +ulong io_base);#endif /* __XEN_SERIAL_H__ */
xen/arch/ppc/boot_of.c +10 -5
@@ -22,8 +22,11 @@#include <xen/lib.h> #include <xen/multiboot.h> #include <xen/compile.h> +#include <xen/console.h> +#include <xen/serial.h> #include <public/of-devtree.h> #include <asm/page.h> +#include <asm/io.h> static ulong of_vec;static ulong of_msr;
@@ -346,8 +349,6 @@if (rc <=0 ) {strcpy (cmdline,"xen console=com1" ); } -/* Should really fidn this in OF tree add ",irq" when ready */ -strcat (cmdline," com1=115200,8n1,0xf40003f8" ); mbi->flags |=MBI_CMDLINE ; mbi->cmdline = (u32 )cmdline;
@@ -655,9 +656,13 @@int __init boot_of_serial (void ) { -/* right now we are punting and using mambo writes which is the -* hardcoded setup */ - +/* XXX get base from ISA node in device tree */ + isa_io_base =0xf4000000 ; + +/* XXX get values from serial node in device tree */ +ns16550_port_config (0 ,0 ,0 ,0 ,0 ,10 ,0 );/* override irq */ +ns16550_port_register (0 ); +use_serial_console (0 ,0 );return 1 ; }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Hollis Blanchard
- It allows us to automatically enable the serial console ("console=com1").
That's what OPT_CONSOLE_STR is for.
Quoted 3 lines
- It gives the ns16550 parameters reasonable defaults (8n1).
- If baud is unspecified, do not reconfigure the ns16550 baud rate (use whatever firmware was using).
Okay.
Quoted 3 lines
- It allows us to automatically configure ns16550 parameters ("com1=baud,..."). All parameters are optional (so you can selectively override the defaults).
I'll give you a run-time method to specify override strings for opt_com1 and opt_com2.
-- Keir
Quoted 6 lines · Keir Fraser
Quoted 4 lines
- It allows us to automatically configure ns16550 parameters ("com1=baud,..."). All parameters are optional (so you can selectively override the defaults).
I'll give you a run-time method to specify override strings for
opt_com1andopt_com2.
Thanks Keir, this working perfectly.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center