Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys PUCCN improvements:
details: https://anonhg.NetBSD.org/src/rev/ccd83dc13800
branches: trunk
changeset: 326346:ccd83dc13800
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Sun Jan 26 10:54:24 2014 +0000
description:
PUCCN improvements:
- Fix a bug that the puc cn mechanism doesn't use the UART's frequency
in pucdata.c's table.
- Add a new option PUC_CNAUTO. If this option is set, consinit() in
x86/x86/consinit.c checks puc com device to use it as console.
Without this option, the behavior is the same as before.
- Add a new config parameter PUC_CNBUS. The old code scans bus #0 only.
If PUC_CNBUS is set, the specified number's bus will be scanned.
- Rename comcnprobe() to puc_cnprobe() to make it clear.
- Rename comcninit() to puc_cninit() to make it clear.
- Add code for a device that a device's com register is MMIO (#if0 ed).
diffstat:
sys/arch/x86/pci/pci_machdep.c | 16 +++++++++++---
sys/arch/x86/x86/consinit.c | 23 +++++++++++++++++----
sys/dev/pci/files.pci | 6 +++-
sys/dev/pci/puccn.c | 44 +++++++++++++++++++++++++++++------------
sys/dev/pci/puccn.h | 7 ++++-
5 files changed, 70 insertions(+), 26 deletions(-)
diffs (285 lines):
diff -r a3bbe343747e -r ccd83dc13800 sys/arch/x86/pci/pci_machdep.c
--- a/sys/arch/x86/pci/pci_machdep.c Sun Jan 26 10:20:20 2014 +0000
+++ b/sys/arch/x86/pci/pci_machdep.c Sun Jan 26 10:54:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.63 2013/12/25 17:24:39 jakllsch Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.64 2014/01/26 10:54:24 msaitoh Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.63 2013/12/25 17:24:39 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.64 2014/01/26 10:54:24 msaitoh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -110,6 +110,7 @@
#include "opt_acpi.h"
#include "opt_ddb.h"
#include "opt_mpbios.h"
+#include "opt_puc.h"
#include "opt_vga.h"
#include "pci.h"
#include "wsdisplay.h"
@@ -963,14 +964,21 @@
return NULL;
}
+#ifndef PUC_CNBUS
+#define PUC_CNBUS 0
+#endif
+
#if NCOM > 0
int
-cpu_comcnprobe(struct consdev *cn, struct pci_attach_args *pa)
+cpu_puc_cnprobe(struct consdev *cn, struct pci_attach_args *pa)
{
pci_mode_detect();
pa->pa_iot = x86_bus_space_io;
+ pa->pa_memt = x86_bus_space_mem;
pa->pa_pc = 0;
- pa->pa_tag = pci_make_tag(0, 0, pci_bus_maxdevs(NULL, 0) - 1, 0);
+ pa->pa_tag = pci_make_tag(0, PUC_CNBUS, pci_bus_maxdevs(NULL, 0) - 1,
+ 0);
+
return 0;
}
#endif
diff -r a3bbe343747e -r ccd83dc13800 sys/arch/x86/x86/consinit.c
--- a/sys/arch/x86/x86/consinit.c Sun Jan 26 10:20:20 2014 +0000
+++ b/sys/arch/x86/x86/consinit.c Sun Jan 26 10:54:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: consinit.c,v 1.24 2012/10/13 17:58:55 jdc Exp $ */
+/* $NetBSD: consinit.c,v 1.25 2014/01/26 10:54:24 msaitoh Exp $ */
/*
* Copyright (c) 1998
@@ -27,9 +27,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.24 2012/10/13 17:58:55 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.25 2014/01/26 10:54:24 msaitoh Exp $");
#include "opt_kgdb.h"
+#include "opt_puc.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -42,6 +43,7 @@
#include "vga.h"
#include "ega.h"
#include "pcdisplay.h"
+#include "com_puc.h"
#if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0)
#include <dev/ic/mc6845reg.h>
#include <dev/ic/pcdisplayvar.h>
@@ -76,6 +78,9 @@
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
#endif
+#if (NCOM_PUC > 0)
+#include <dev/pci/puccn.h>
+#endif
#include "ukbd.h"
#if (NUKBD > 0)
@@ -144,6 +149,7 @@
const struct btinfo_console *consinfo;
const struct btinfo_framebuffer *fbinfo;
static int initted;
+ int rv;
if (initted)
return;
@@ -204,15 +210,22 @@
int addr = consinfo->addr;
int speed = consinfo->speed;
+#if (NCOM_PUC > 0) && defined(PUC_CNAUTO)
+ puc_cnprobe(NULL);
+ rv = puc_cninit(NULL);
+ if (rv == 0)
+ return;
+#endif
+
if (addr == 0)
addr = CONADDR;
if (speed == 0)
speed = CONSPEED;
- if (comcnattach(x86_bus_space_io, addr, speed,
- COM_FREQ, COM_TYPE_NORMAL, comcnmode))
+ rv = comcnattach(x86_bus_space_io, addr, speed,
+ COM_FREQ, COM_TYPE_NORMAL, comcnmode);
+ if (rv != 0)
panic("can't init serial console @%x", consinfo->addr);
-
return;
}
#endif
diff -r a3bbe343747e -r ccd83dc13800 sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci Sun Jan 26 10:20:20 2014 +0000
+++ b/sys/dev/pci/files.pci Sun Jan 26 10:54:24 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.pci,v 1.368 2014/01/21 14:52:07 mlelstv Exp $
+# $NetBSD: files.pci,v 1.369 2014/01/26 10:54:24 msaitoh Exp $
#
# Config file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@@ -604,9 +604,11 @@
attach puc at pci
file dev/pci/puc.c puc
file dev/pci/pucdata.c puc
+defflag opt_puc.h PUC_CNAUTO
+defparam opt_puc.h PUC_CNBUS
attach com at puc with com_puc
-file dev/pci/com_puc.c com_puc
+file dev/pci/com_puc.c com_puc needs-flag
file dev/pci/cyber.c com_puc
file dev/pci/puccn.c com_puc
diff -r a3bbe343747e -r ccd83dc13800 sys/dev/pci/puccn.c
--- a/sys/dev/pci/puccn.c Sun Jan 26 10:20:20 2014 +0000
+++ b/sys/dev/pci/puccn.c Sun Jan 26 10:54:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puccn.c,v 1.12 2014/01/23 17:43:28 msaitoh Exp $ */
+/* $NetBSD: puccn.c,v 1.13 2014/01/26 10:54:24 msaitoh Exp $ */
/*
* Derived from pci.c
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.12 2014/01/23 17:43:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.13 2014/01/26 10:54:24 msaitoh Exp $");
#include "opt_kgdb.h"
@@ -75,6 +75,7 @@
static bus_addr_t puccnbase;
static bus_space_tag_t puctag;
+static int puccnflags;
#ifdef KGDB
static bus_addr_t pucgdbbase;
@@ -99,11 +100,10 @@
/* Fetch our tags */
#if defined(amd64) || defined(i386)
- if (cpu_comcnprobe(cn, &pa) != 0)
+ if (cpu_puc_cnprobe(cn, &pa) != 0)
#endif
return 0;
- puctag = pa.pa_iot;
pci_decompose_tag(pa.pa_pc, pa.pa_tag, &bus, &maxdev, NULL);
/* Scan through devices and find a communication class device. */
@@ -145,6 +145,8 @@
*/
if (!foundport)
return 0;
+
+ /* Clear foundport flag */
foundport = 0;
/* Check whether the device is in the puc device table or not */
@@ -166,12 +168,21 @@
{
if (desc->ports[i].type != PUC_PORT_TYPE_COM)
continue;
+ puccnflags = desc->ports[i].flags;
base = pci_conf_read(pa.pa_pc, pa.pa_tag, desc->ports[i].bar);
base += desc->ports[i].offset;
- if (PCI_MAPREG_TYPE(base) != PCI_MAPREG_TYPE_IO)
- continue;
- base = PCI_MAPREG_IO_ADDR(base);
+ if (PCI_MAPREG_TYPE(base) == PCI_MAPREG_TYPE_IO) {
+ puctag = pa.pa_iot;
+ base = PCI_MAPREG_IO_ADDR(base);
+ }
+#if 0 /* For MMIO device */
+ else {
+ puctag = pa.pa_memt;
+ base = PCI_MAPREG_MEM_ADDR(base);
+ }
+#endif
+
if (com_is_console(puctag, base, NULL))
continue;
foundport = 1;
@@ -183,8 +194,13 @@
goto resume_scan;
}
+#if 0
cn->cn_pri = CN_REMOTE;
- return PCI_MAPREG_IO_ADDR(base);
+#else
+ if (cn)
+ cn->cn_pri = CN_REMOTE;
+#endif
+ return base;
}
#ifdef KGDB
@@ -211,19 +227,21 @@
#endif
void
-comcnprobe(struct consdev *cn)
+puc_cnprobe(struct consdev *cn)
{
puccnbase = pucprobe_doit(cn);
}
-void
-comcninit(struct consdev *cn)
+int
+puc_cninit(struct consdev *cn)
{
+
if (puccnbase == 0)
- return;
+ return -1;
- comcnattach(puctag, puccnbase, CONSPEED, COM_FREQ, COM_TYPE_NORMAL,
+ return comcnattach(puctag, puccnbase, CONSPEED,
+ puccnflags & PUC_COM_CLOCKMASK, COM_TYPE_NORMAL,
CONMODE);
}
diff -r a3bbe343747e -r ccd83dc13800 sys/dev/pci/puccn.h
--- a/sys/dev/pci/puccn.h Sun Jan 26 10:20:20 2014 +0000
+++ b/sys/dev/pci/puccn.h Sun Jan 26 10:54:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puccn.h,v 1.5 2013/07/22 13:40:36 soren Exp $ */
+/* $NetBSD: puccn.h,v 1.6 2014/01/26 10:54:24 msaitoh Exp $ */
/*
* Derived from pci.c
@@ -35,6 +35,7 @@
*/
#include <dev/cons.h>
+#include <dev/pci/pcivar.h>
/*
* Machine independent support for PCI serial console support.
@@ -44,4 +45,6 @@
* used before the normal PCI bus initialization.
*/
-int cpu_comcnprobe(struct consdev *, struct pci_attach_args *);
+void puc_cnprobe(struct consdev *);
+int puc_cninit(struct consdev *);
+int cpu_puc_cnprobe(struct consdev *, struct pci_attach_args *);
Home |
Main Index |
Thread Index |
Old Index