Subject: port-i386/18426: setting serial speed in bootloader during installation
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wgstuken@nagler-company.com>
List: netbsd-bugs
Date: 09/26/2002 12:49:40
>Number:         18426
>Category:       port-i386
>Synopsis:       setting serial speed in bootloader during installation
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-i386-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 26 03:42:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.6
>Organization:
Dr. Nagler & Company GmbH
>Environment:
System: NetBSD test-s0 1.6 NetBSD 1.6 (GENERIC) #0: Thu Sep 19 09:24:41 CEST 2002 wgstuken@test-s0:/export/netbsd-1.6-release/usr/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
	Up to now it is not possible to set the speed of a serial console during installation.
	Recompilation is required.
	This problem-report contains a fix, that makes it possible to set the speed during installation of the
	bootloader by /usr/mdec/installboot.
	Affected files: /usr/src/sys/arch/i386/stand/installboot/installboot.c
	                /usr/src/sys/arch/i386/stand/lib/pcio.c
	                /usr/src/sys/arch/i386/stand/lib/comio_direct.c

	A new option "-s <speed>" has been added to installboot, that will set the new variable "conspeed"
	in the bootloader image during installation.

	A new variable "conspeed" has been added in the bootloader and all initialisation will be done
	from this new variable now.

	The output of diff -c for the three files is added in the Fix section below.


>How-To-Repeat:
	not relevant
>Fix:


------- installboot.c -------
*** /tmp/sccs.cUayqe	Thu Sep 26 12:11:59 2002
--- installboot.c	Thu Sep 26 12:11:05 2002
***************
*** 84,97 ****
--- 84,100 ----
  #define X_fraglist	0
  #define X_boottimeout	1
  #define X_bootpasswd	2
+ #define X_conspeed	3
  #ifdef __ELF__
  	{{"fraglist"}},
  	{{"boottimeout"}},
  	{{"bootpasswd"}},
+ 	{{"conspeed"}},
  #else
  	{{"_fraglist"}},
  	{{"_boottimeout"}},
  	{{"_bootpasswd"}},
+ 	{{"_conspeed"}},
  #endif
  	{{NULL}}
  };
***************
*** 442,451 ****
  	int nowrite = 0;
  	int allok = 0;
  	int timeout = -1;
  	char *bootpasswd = 0;
  	ino_t (*save_func) __P((char *, char *, char *, unsigned int));
  
! 	while ((c = getopt(argc, argv, "b:vnft:p:")) != -1) {
  		switch (c) {
  		case 'b':
  			/* generic override, supply starting block # */
--- 445,455 ----
  	int nowrite = 0;
  	int allok = 0;
  	int timeout = -1;
+ 	int conspeed = -1;
  	char *bootpasswd = 0;
  	ino_t (*save_func) __P((char *, char *, char *, unsigned int));
  
! 	while ((c = getopt(argc, argv, "b:vnft:p:s:")) != -1) {
  		switch (c) {
  		case 'b':
  			/* generic override, supply starting block # */
***************
*** 452,457 ****
--- 456,465 ----
  			conblockmode = 1;
  			conblockstart = atoi(optarg);
  			break;
+ 		case 's':
+ 			/* console speed */
+ 			conspeed = atoi(optarg);
+ 			break;
  		case 't':
  			/* boot timeout */
  			timeout = atoi(optarg);
***************
*** 492,497 ****
--- 500,514 ----
  			warnx("no timeout support in bootblock");
  			goto out;
  		}
+ 	}
+ 
+ 	if (conspeed >= 0) {
+ 		if (nl[X_conspeed].n_value != 0)
+ 			*((int *)(bp + nl[X_conspeed].n_value)) = conspeed;
+ 		else {
+ 			warnx("no console-speed support in bootblock");
+ 			goto out;
+ 		}
  	}
  
  	if (bootpasswd) {
------- END OF OUTPUR FOR installboot.c -------



------- pcio.c -------
*** /tmp/sccs.oIaase	Thu Sep 26 12:12:35 2002
--- pcio.c	Thu Sep 26 12:10:02 2002
***************
*** 52,57 ****
--- 52,64 ----
  #ifdef SUPPORT_SERIAL
  static int iodev;
  
+ #ifdef CONSPEED
+ int conspeed = CONSPEED; 
+ #else 
+ int conspeed = 9600;
+ #endif  
+ 
+ 
  #ifdef DIRECT_SERIAL
  #include "comio_direct.h"
  
***************
*** 193,202 ****
  	conputc('\015');
  	conputc('\n');
  	strncpy(btinfo_console.devname, iodev == CONSDEV_PC ? "pc" : "com", 16);
! #if defined(DIRECT_SERIAL) && defined(CONSPEED)
! 	btinfo_console.speed = CONSPEED;
! #else
! 	btinfo_console.speed = 9600;
  #endif
  #else /* !SUPPORT_SERIAL */
  	strncpy(btinfo_console.devname, "pc", 16);
--- 200,207 ----
  	conputc('\015');
  	conputc('\n');
  	strncpy(btinfo_console.devname, iodev == CONSDEV_PC ? "pc" : "com", 16);
! #if defined(DIRECT_SERIAL)
! 	btinfo_console.speed = conspeed;
  #endif
  #else /* !SUPPORT_SERIAL */
  	strncpy(btinfo_console.devname, "pc", 16);
------- END OF OUTPUR FOR pcio.c -------



------- comio_direct.c -------
*** /tmp/sccs.LCaaue	Thu Sep 26 12:13:24 2002
--- comio_direct.c	Thu Sep 26 12:10:02 2002
***************
*** 85,90 ****
--- 85,92 ----
  static int serbuf_write = 0;
  static int stopped = 0;
  
+ extern int conspeed;
+ 
  #define	ISSET(t,f)	((t) & (f))
  
  /*
***************
*** 203,213 ****
  	serbuf_write = 0;
  
  	outb(combase + com_cfcr, LCR_DLAB);
! #ifdef CONSPEED
! 	rate = comspeed(CONSPEED);
! #else
! 	rate = comspeed(9600);
! #endif
  	outb(combase + com_dlbl, rate);
  	outb(combase + com_dlbh, rate >> 8);
  	outb(combase + com_cfcr, LCR_8BITS);
--- 205,211 ----
  	serbuf_write = 0;
  
  	outb(combase + com_cfcr, LCR_DLAB);
! 	rate = comspeed(conspeed);
  	outb(combase + com_dlbl, rate);
  	outb(combase + com_dlbh, rate >> 8);
  	outb(combase + com_cfcr, LCR_8BITS);
------- END OF OUTPUR FOR comio_direct.c -------
>Release-Note:
>Audit-Trail:
>Unformatted: