diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2002-02-08 20:43:17 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2002-02-08 20:43:17 +0000 |
commit | 28095814e7a406c63a14bced7b2e507d0410a923 (patch) | |
tree | 2714adc5d01cb4290f85f44bb5e29aef9f93ff74 | |
parent | cf9b9a9febd547d6696d6962ab054211afe1e49a (diff) |
Teach some magic to the kernel so that it can decode serial console settings.
mickey@ said "commitski".
-rw-r--r-- | sys/arch/hppa/dev/pdc.c | 27 | ||||
-rw-r--r-- | sys/arch/hppa/include/pdc.h | 10 |
2 files changed, 33 insertions, 4 deletions
diff --git a/sys/arch/hppa/dev/pdc.c b/sys/arch/hppa/dev/pdc.c index 346f462a511..afe67285aaa 100644 --- a/sys/arch/hppa/dev/pdc.c +++ b/sys/arch/hppa/dev/pdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pdc.c,v 1.20 2002/02/05 03:46:23 mickey Exp $ */ +/* $OpenBSD: pdc.c,v 1.21 2002/02/08 20:43:14 miod Exp $ */ /* * Copyright (c) 1998-2002 Michael Shalayeff @@ -75,6 +75,21 @@ void pdctimeout __P((void *v)); int pdcparam __P((struct tty *tp, struct termios *)); int pdccnlookc __P((dev_t dev, int *cp)); +/* serial console speed table */ +static int pdc_speeds[] = { + B50, + B75, + B110, + B150, + B300, + B600, + B1200, + B2400, + B4800, + B7200, + B9600, +}; + void pdc_init() { @@ -122,8 +137,14 @@ pdc_init() #endif conaddr = (u_long)pzd->pz_hpa + IOMOD_DEVOFFSET; conunit = 0; - /* TODO detect the baud rate from layer[0] */ - comdefaultrate = B9600; + + /* compute correct baud rate */ + if (PZL_SPEED(pzd->pz_layers[0]) < + sizeof(pdc_speeds) / sizeof(int)) + comdefaultrate = + pdc_speeds[PZL_SPEED(pzd->pz_layers[0])]; + else + comdefaultrate = B9600; /* XXX */ } #endif } diff --git a/sys/arch/hppa/include/pdc.h b/sys/arch/hppa/include/pdc.h index 88481b0e452..deb604c4637 100644 --- a/sys/arch/hppa/include/pdc.h +++ b/sys/arch/hppa/include/pdc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pdc.h,v 1.16 2002/01/25 21:26:41 mickey Exp $ */ +/* $OpenBSD: pdc.h,v 1.17 2002/02/08 20:43:16 miod Exp $ */ /* * Copyright (c) 1990 mt Xinu, Inc. All rights reserved. @@ -523,6 +523,14 @@ struct device_path { #define PZF_TIMER 0x0f /* power of 2 # secs "boot timer" (0 == dflt) */ #define PZF_BITS "\020\010autoboot\07autosearch" +/* macros to decode serial parameters out of dp_layers */ +#define PZL_BITS(l) (((l) & 0x03) + 5) +#define PZL_PARITY(l) (((l) & 0x18) >> 3) +#define PZL_SPEED(l) (((l) & 0x3c0) >> 6) +#define PZL_ENCODE(bits, parity, speed) \ + (((bits) - 5) & 0x03) | (((parity) & 0x3) << 3) | \ + (((speed) & 0x10) << 6) + /* * A processors Stable Storage is accessed through the PDC. There are * at least 96 bytes of stable storage (the device path information may |