Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jan 2002 18:34:23 +0200
From:      Stoian Mishinev <mishinev@digsys.bg>
To:        stable@freebsd.org
Subject:   Moxa C168H/PCI
Message-ID:  <200201101634.SAA20381@ws5-plovdiv.digsys.bg>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hi List,

I'm trying to compile sio.c patched with cronyx's OMEGA drivers (www.cronyx.ru) as recommended from "Moxa Technologies Co Ltd". 
After some made by hand patches (the driver was written for 4.4-RELEASE) I've get this error:

siopci0: <Moxa Technologies C168H/PCI> port 0x2c20-0x2c2f,0x2880-0x28bf,0x2800-0x287f irq 5 at device 13.0 on pci0
sio4: couldn't map ports/memory
device_probe_and_attach: siopci0 attach returned 6

Any ideas are welcomed.

Follow 
1. dmesg
2. sio.c compiled patch
3. pciconf -lv output
4. kernel config file is GENERIC with no changes.


[-- Attachment #2 --]
chip0@pci0:0:0:	class=0x060000 card=0x00000000 chip=0x71a08086 rev=0x00 hdr=0x00
    vendor   = 'Intel Corporation'
    device   = '82443GX 440GX CPU to PCI Bridge (AGP Implemented)'
    class    = bridge
    subclass = HOST-PCI
pcib2@pci0:1:0:	class=0x060400 card=0x00000000 chip=0x71a18086 rev=0x00 hdr=0x01
    vendor   = 'Intel Corporation'
    device   = '82443GX PCI-to-PCI Bridge (AGP)'
    class    = bridge
    subclass = PCI-PCI
ahc0@pci0:12:0:	class=0x010000 card=0x00539004 chip=0x005f9005 rev=0x00 hdr=0x00
    vendor   = 'Adaptec'
    device   = 'AIC-7896/7 Ultra2 SCSI Controller'
    class    = mass storage
    subclass = SCSI
ahc1@pci0:12:1:	class=0x010000 card=0x00539004 chip=0x005f9005 rev=0x00 hdr=0x00
    vendor   = 'Adaptec'
    device   = 'AIC-7896/7 Ultra2 SCSI Controller'
    class    = mass storage
    subclass = SCSI
none0@pci0:13:0:	class=0x070080 card=0x00000000 chip=0x16801393 rev=0x02 hdr=0x00
    vendor   = 'Moxa Technologies Co Ltd'
    device   = 'C168H'
    class    = simple comms
    subclass = UART
fxp0@pci0:14:0:	class=0x020000 card=0x30008086 chip=0x12298086 rev=0x08 hdr=0x00
    vendor   = 'Intel Corporation'
    device   = '82557/8/9 EtherExpress PRO/100(B) Ethernet Adapter'
    class    = network
    subclass = ethernet
isab0@pci0:18:0:	class=0x060100 card=0x00000000 chip=0x71108086 rev=0x02 hdr=0x00
    vendor   = 'Intel Corporation'
    device   = '82371AB/EB/MB PIIX4 ISA Bridge'
    class    = bridge
    subclass = PCI-ISA
atapci0@pci0:18:1:	class=0x010180 card=0x00000000 chip=0x71118086 rev=0x01 hdr=0x00
    vendor   = 'Intel Corporation'
    device   = '82371AB/EB/MB PIIX4 EIDE Controller'
    class    = mass storage
    subclass = ATA
uhci0@pci0:18:2:	class=0x0c0300 card=0x00000000 chip=0x71128086 rev=0x01 hdr=0x00
    vendor   = 'Intel Corporation'
    device   = '82371AB/EB/MB PIIX4 USB Controller'
    class    = serial bus
    subclass = USB
chip1@pci0:18:3:	class=0x068000 card=0x00000000 chip=0x71138086 rev=0x02 hdr=0x00
    vendor   = 'Intel Corporation'
    device   = '82371AB/EB/MB PIIX4 Power Management Controller'
    class    = bridge
    subclass = PCI-unknown
none1@pci0:20:0:	class=0x030000 card=0x00bc1013 chip=0x00bc1013 rev=0x23 hdr=0x00
    vendor   = 'Cirrus Logic'
    device   = 'CL-GD5480 64-bit SGRAM GUI accelerator'
    class    = display
    subclass = VGA
pcib3@pci1:15:0:	class=0x060400 card=0x000000dc chip=0x00231011 rev=0x06 hdr=0x01
    vendor   = 'Digital Equipment Corporation'
    device   = 'DC21150 PCI to PCI Bridge'
    class    = bridge
    subclass = PCI-PCI

[-- Attachment #3 --]
*** /sys/isa/sio.c	Thu Jan 10 17:23:45 2002
--- /sys/isa/sio.c-GENERIC	Thu Jan 10 15:48:11 2002
***************
*** 138,143 ****
--- 138,148 ----
  
  #define	com_scr		7	/* scratch register for 16450-16550 (R/W) */
  
+ #define	sio_getreg(com, off) \
+ 	(bus_space_read_1((com)->bst, (com)->bsh, (off)))
+ #define	sio_setreg(com, off, value) \
+ 	(bus_space_write_1((com)->bst, (com)->bsh, (off), (value)))
+ 
  /*
   * com state bits.
   * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher
***************
*** 213,219 ****
  	int	unit;		/* unit	number */
  	int	dtr_wait;	/* time to hold DTR down on close (* 1/hz) */
  	u_int	tx_fifo_size;
- 	u_int	oscillator;
  	u_int	wopeners;	/* # processes waiting for DCD in open() */
  
  	/*
--- 218,223 ----
***************
*** 283,314 ****
  	u_char	obuf2[256];
  };
  
- #define MAXCHAN		8		/* up to 8 channels per multiport */
- 
- struct multicom {
- 	int		nchan;		/* channels per adapter */
- 	struct resource	*res;
- 	struct resource	*irq;
- 	void		*intrhand;
- 	struct com_s	com [MAXCHAN];
- };
- 
  #ifdef COM_ESP
  static	int	espattach	__P((struct com_s *com, Port_t esp_port));
  #endif
  static	int	sioattach	__P((device_t dev, int rid));
  static	int	sio_isa_attach	__P((device_t dev));
- static	int	sio_attach_unit	__P((struct com_s *com, int unit, Port_t iobase,
- 				    u_int flags, bool_t no_irq,
- 				    bus_space_tag_t t, bus_space_handle_t h));
- static	int	sio_find_freq	__P((struct com_s *com));
  
  static	timeout_t siobusycheck;
  static	timeout_t siodtrwakeup;
  static	void	comhardclose	__P((struct com_s *com));
  static	void	sioinput	__P((struct com_s *com));
  static	void	siointr1	__P((struct com_s *com));
- static	void	sio_pci_intr	__P((void *arg));
  static	void	siointr		__P((void *arg));
  static	int	commctl		__P((struct com_s *com, int bits, int how));
  static	int	comparam	__P((struct tty *tp, struct termios *t));
--- 287,303 ----
***************
*** 331,336 ****
--- 320,326 ----
  
  #if NPCI > 0
  static	int	sio_pci_attach __P((device_t dev));
+ static	void	sio_pci_kludge_unit __P((device_t dev));
  static	int	sio_pci_probe __P((device_t dev));
  #endif /* NPCI > 0 */
  
***************
*** 338,348 ****
  
  /* table and macro for fast conversion from a unit number to its com struct */
  static	devclass_t	sio_devclass;
! static	devclass_t	sio_pccard_devclass;
! static	devclass_t	sio_pci_devclass;
! #define SIO_MAXUNITS	64		/* up to 64 ports */
! #define	com_addr(unit)	(p_com_addr[unit])
! static	struct com_s	*p_com_addr[SIO_MAXUNITS];
  
  static device_method_t sio_isa_methods[] = {
  	/* Device interface */
--- 328,335 ----
  
  /* table and macro for fast conversion from a unit number to its com struct */
  static	devclass_t	sio_devclass;
! #define	com_addr(unit)	((struct com_s *) \
! 			 devclass_get_softc(sio_devclass, unit))
  
  static device_method_t sio_isa_methods[] = {
  	/* Device interface */
***************
*** 385,393 ****
  };
  
  static driver_t sio_pci_driver = {
! 	"siopci",
  	sio_pci_methods,
! 	sizeof(struct multicom),
  };
  #endif /* NPCI > 0 */
  
--- 372,380 ----
  };
  
  static driver_t sio_pci_driver = {
! 	driver_name,
  	sio_pci_methods,
! 	sizeof(struct com_s),
  };
  #endif /* NPCI > 0 */
  
***************
*** 432,440 ****
  static	struct	callout_handle sio_timeout_handle
      = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle);
  static	int	sio_numunits;
- static  int     sio_pci_numunits = NSIO;
  
! #define COMDIVISOR(osc,x)       (((osc) / (x) + 8) / 16)
  
  #ifdef COM_ESP
  /* XXX configure this properly. */
--- 419,447 ----
  static	struct	callout_handle sio_timeout_handle
      = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle);
  static	int	sio_numunits;
  
! static	struct speedtab comspeedtab[] = {
! 	{ 0,		0 },
! 	{ 50,		COMBRD(50) },
! 	{ 75,		COMBRD(75) },
! 	{ 110,		COMBRD(110) },
! 	{ 134,		COMBRD(134) },
! 	{ 150,		COMBRD(150) },
! 	{ 200,		COMBRD(200) },
! 	{ 300,		COMBRD(300) },
! 	{ 600,		COMBRD(600) },
! 	{ 1200,		COMBRD(1200) },
! 	{ 1800,		COMBRD(1800) },
! 	{ 2400,		COMBRD(2400) },
! 	{ 4800,		COMBRD(4800) },
! 	{ 9600,		COMBRD(9600) },
! 	{ 19200,	COMBRD(19200) },
! 	{ 28800,	COMBRD(28800) },
! 	{ 38400,	COMBRD(38400) },
! 	{ 57600,	COMBRD(57600) },
! 	{ 115200,	COMBRD(115200) },
! 	{ -1,		-1 }
! };
  
  #ifdef COM_ESP
  /* XXX configure this properly. */
***************
*** 443,504 ****
  #endif
  
  /*
-  * Redefine inb/outb to handle memory-based adapters.
-  * It is essential that Port_t contains 32-bit value.
-  */
- static	u_char	sio_inb __P((Port_t port));
- static	void	sio_outb __P((Port_t port, u_char byte));
- static	u_char	sio_getreg __P((struct com_s *com, bus_size_t off));
- static	void	sio_setreg __P((struct com_s *com, bus_size_t off, u_char val));
- 
- static __inline u_char 
- sio_inb (port)
- 	Port_t		port;
- {
- 	if (port & ~0xffff)
- 		return *(volatile u_char*) port;
- 	return inb (port);
- }
- 
- static __inline void 
- sio_outb (port, byte)
- 	Port_t		port;
- 	u_char		byte;
- {
- 	if (port & ~0xffff)
- 		*(volatile u_char*) port = byte;
- 	else
- 		outb (port, byte);
- }
- 
- #undef inb
- #undef outb
- #define inb(port)	sio_inb (port)
- #define outb(port,val)	sio_outb (port, val)
- 
- static __inline u_char 
- sio_getreg (com, off)
- 	struct com_s	*com;
- 	bus_size_t	off;
- {
- 	if ((unsigned) com->bsh & ~0xffff)
- 		return *(volatile u_char*) (com->bsh + off);
- 	return bus_space_read_1 (com->bst, com->bsh, off);
- }
- 
- static __inline void 
- sio_setreg (com, off, val)
- 	struct com_s	*com;
- 	bus_size_t	off;
- 	u_char		val;
- {
- 	if ((unsigned) com->bsh & ~0xffff)
- 		*(volatile u_char*) (com->bsh + off) = val;
- 	else
- 		bus_space_write_1 (com->bst, com->bsh, off, val);
- }
- 
- /*
   * handle sysctl read/write requests for console speed
   * 
   * In addition to setting comdefaultrate for I/O through /dev/console,
--- 450,455 ----
***************
*** 627,636 ****
  	u_int32_t	type;
  	const char	*desc;
  	int		rid;
- 	int		nchan;		/* channels per adapter */
- 	int		iostep;		/* addresses per channel */
- 	int		fifo_size;	/* fifo size in bytes */
- 	int		hw_rts_cts;	/* hardware rts/cts support */
  };
  
  static struct pci_ids pci_ids[] = {
--- 578,583 ----
***************
*** 639,719 ****
  	{ 0x0000151f, "SmartLink 5634PCV SurfRider", 0x10 },
  	{ 0x01101407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
  	{ 0x01111407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
- 	{ 0xc00110b5, "Cronyx Omega-PCI Serial Adapter", 0x18, 8, 8, 64, 1 },
- 	{ 0x015813a8, "Cronyx Omega2-PCI Serial Adapter", -0x10, 8, 0x200, 64 },
- 	{ 0x16801393, "Moxa Technologies C168H/PCI", 0x02 },
  	{ 0x00000000, NULL, 0 }
  };
  
- /*
-  * Find the oscillator frequency of the UART.
-  */
- static int 
- sio_find_freq(com)
- 	struct com_s	*com;
- {
- 	int t0, n;
- 	u_char lsr;
- 
- 	/* Set the loopback mode, 57600 baud. */
- 	outb(com->intr_ctl_port, 0);
- 	sio_setreg(com, com_cfcr, CFCR_DLAB);
- 	sio_setreg(com, com_dlbh, 0);
- 	sio_setreg(com, com_dlbl, 2);
- 	sio_setreg(com, com_cfcr, CFCR_8BITS);
- 	sio_setreg(com, com_fifo, 0);
- 	outb(com->modem_ctl_port, MCR_LOOPBACK);
- 	(void) inb (com->line_status_port);
- 
- 	/* Catch the tick. */
- 	t0 = ticks;
- 	while (ticks == t0)
- 		continue;
- 
- 	/* Run until the next tick, transmitting data. */
- 	n = 0;
- 	t0 = ticks;
- 	while (ticks == t0) {
- 		lsr = inb (com->line_status_port);
- 		if (lsr & LSR_TXRDY)
- 			sio_setreg(com, com_data, 0x5A);
- 
- 		if (lsr & LSR_RXRDY) {
- 			(void) inb (com->data_port);
- 			++n;
- 		}
- 	}
- 	outb(com->modem_ctl_port, com->mcr_image);
- 	sio_setreg(com, com_cfcr, com->cfcr_image);
- 	sio_setreg(com, com_fifo, FIFO_RCV_RST | FIFO_XMT_RST | 
- 		com->fifo_image);
- 	if (COM_IIR_TXRDYBUG(com->flags)) {
- 		outb(com->intr_ctl_port, IER_ERXRDY | IER_ERLS
- 					| IER_EMSC);
- 	} else {
- 		outb(com->intr_ctl_port, IER_ERXRDY | IER_ETXRDY
- 					| IER_ERLS | IER_EMSC);
- 	}
- 
- 	n = (n * hz + 5760/2) / 5760;
- 	if (n > 4) return 8 * 1843200;
- 	if (n > 2) return 4 * 1843200;
- 	if (n > 1) return 2 * 1843200;
- 	return 1843200;
- }
- 
  static int
  sio_pci_attach(dev)
  	device_t	dev;
  {
  	u_int32_t	type;
  	struct pci_ids	*id;
- 	struct multicom	*d = device_get_softc(dev);
- 	struct com_s	*com;
- 	Port_t		iobase;
- 	bus_space_tag_t	bst;
- 	bus_space_handle_t bsh, bsh_port;
- 	int		rid, offset, s, flags, err = 0;
  
  	type = pci_get_devid(dev);
  	id = pci_ids;
--- 586,600 ----
***************
*** 721,796 ****
  		id++;
  	if (id->desc == NULL)
  		return (ENXIO);
  
! 	bzero((char*)d, sizeof(*d));
! 	s = splimp();
! 	d->nchan = id->nchan > 1 ? id->nchan : 1;
! 
! 	/* Allocate i/o region. */
! 	rid = id->rid > 0 ? id->rid : - id->rid;
! 	d->res = bus_alloc_resource(dev, id->rid > 0 ?
! 		SYS_RES_IOPORT : SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE);
! 	if (! d->res) {
! 		printf("sio%d: couldn't map ports/memory\n", sio_pci_numunits);
! 		err = ENXIO;
! 		goto fail;
! 	}
  
! 	/* Allocate interrupt. */
! 	rid = 0;
! 	d->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
! 		RF_SHAREABLE | RF_ACTIVE);
! 	if (! d->irq) {
! 		printf("sio%d: couldn't map interrupt\n", sio_pci_numunits);
! 		err = ENXIO;
! 		goto fail;
! 	}
! 
! 	/* Register the interrupt handler. */
! 	err = bus_setup_intr(dev, d->irq, INTR_TYPE_TTY | INTR_TYPE_FAST,
! 		sio_pci_intr, d, &d->intrhand);
! 	if (err) {
! 		printf("sio%d: couldn't set up irq\n", sio_pci_numunits);
! fail:		if (d->res)
! 			bus_release_resource(dev, id->rid > 0 ? SYS_RES_IOPORT :
! 				SYS_RES_MEMORY, id->rid, d->res);
! 		if (d->irq)
! 			bus_release_resource(dev, SYS_RES_IRQ, 0, d->irq);
! 		goto done;
! 	}
! 
! 	/* Attach sio ports. */
! 	bst = rman_get_bustag(d->res);
! 	bsh = rman_get_bushandle(d->res);
! 	iobase = id->rid > 0 ? rman_get_start(d->res) :
! 		(Port_t) rman_get_virtual(d->res);
! 	flags = id->fifo_size << 24;
! 	if (id->hw_rts_cts)
! 		flags |= 0x20000;
! 	offset = 0;
! 	for (com=d->com; com<d->com+d->nchan; ++com, offset+=id->iostep) {
! 		/* Get a handle for a subregion of an already-mapped 
! 		 * area of bus space. */
! #if waiting_for_somebody_to_implement_bus_space_subregion
! 		if (bus_space_subregion (bst, bsh, offset, 8, &bsh_port) != 0) {
! 			printf("sio%d: cannot get bus subregion\n", 
! 				sio_pci_numunits);
! 			continue;
  	}
- #else
- 		bsh_port = bsh + offset;
- #endif
- 		/* Interrupt enable, do it _before_ sio_attach_unit. */
- 		outb (iobase + offset + com_mcr, 
- 			d->nchan > 1 ? MCR_IENABLE : 0);
- 
- 		if (sio_attach_unit(com, sio_pci_numunits++, iobase + offset,
- 		    flags, 0, bst, bsh_port) != 0)
- 			printf("sio%d: cannot attach\n", sio_pci_numunits);
- 	}
- done:
- 	splx (s);
- 	return err;
  }
  
  static int
--- 602,638 ----
  		id++;
  	if (id->desc == NULL)
  		return (ENXIO);
+ 	sio_pci_kludge_unit(dev);
+ 	return (sioattach(dev, id->rid));
+ }
  
! /*
!  * Don't cut and paste this to other drivers.  It is a horrible kludge
!  * which will fail to work and also be unnecessary in future versions.
!  */
! static void
! sio_pci_kludge_unit(dev)
! 	device_t dev;
! {
! 	devclass_t	dc;
! 	int		err;
! 	int		start;
! 	int		unit;
  
! 	unit = 0;
! 	start = 0;
! 	while (resource_int_value("sio", unit, "port", &start) == 0 && 
! 	    start > 0)
! 		unit++;
! 	if (device_get_unit(dev) < unit) {
! 		dc = device_get_devclass(dev);
! 		while (devclass_get_device(dc, unit))
! 			unit++;
! 		device_printf(dev, "moving to sio%d\n", unit);
! 		err = device_set_unit(dev, unit);	/* EVIL DO NOT COPY */
! 		if (err)
! 			device_printf(dev, "error moving device %d\n", err);
  	}
  }
  
  static int
***************
*** 807,813 ****
  	if (id->desc == NULL)
  		return (ENXIO);
  	device_set_desc(dev, id->desc);
! 	return (0);
  }
  #endif /* NPCI > 0 */
  
--- 649,655 ----
  	if (id->desc == NULL)
  		return (ENXIO);
  	device_set_desc(dev, id->desc);
! 	return (sioprobe(dev, id->rid));
  }
  #endif /* NPCI > 0 */
  
***************
*** 1271,1283 ****
  	int		xrid;
  {
  	struct com_s	*com;
  	Port_t		iobase;
  	int		unit;
  	u_int		flags;
  	int		rid;
  	struct resource *port;
  	int		ret;
- 	int		no_irq;
  
  	rid = xrid;
  	port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
--- 1113,1127 ----
  	int		xrid;
  {
  	struct com_s	*com;
+ #ifdef COM_ESP
+ 	Port_t		*espp;
+ #endif
  	Port_t		iobase;
  	int		unit;
  	u_int		flags;
  	int		rid;
  	struct resource *port;
  	int		ret;
  
  	rid = xrid;
  	port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
***************
*** 1290,1355 ****
  	com = device_get_softc(dev);
  	flags = device_get_flags(dev);
  
- #ifdef COM_MULTIPORT
- 	if (COM_ISMULTIPORT(flags)) {
- 		device_t masterdev;
- 
- 		masterdev = devclass_get_device(sio_devclass,
- 		    COM_MPMASTER(flags));
- 		no_irq = (masterdev == NULL || bus_get_resource(masterdev,
- 		    SYS_RES_IRQ, 0, NULL, NULL) != 0);
- 	 } else
- #endif /* COM_MULTIPORT */
- 	no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL) != 0;
- 
- 	ret = sio_attach_unit(com, unit, iobase, flags, no_irq,
- 		rman_get_bustag(port), rman_get_bushandle(port));
- 		
- 	if (ret != 0) {
- 		/* Leave i/o resources allocated if this is a `cn'-level
- 		 * console, so that other devices can't snarf them. */
- 		if (iobase != siocniobase)
- 			bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- 		return ret;
- 	}
- 
- 	rid = 0;
- 	com->irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1,
- 	    RF_ACTIVE);
- 	if (com->irqres) {
- 		ret = BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres,
- 				     INTR_TYPE_TTY | INTR_TYPE_FAST,
- 				     siointr, com, &com->cookie);
- 		if (ret) {
- 			ret = BUS_SETUP_INTR(device_get_parent(dev), dev,
- 					     com->irqres, INTR_TYPE_TTY,
- 					     siointr, com, &com->cookie);
- 			if (ret == 0)
- 				device_printf(dev, "unable to activate interrupt in fast mode - using normal mode");
- 		}
- 		if (ret)
- 			device_printf(dev, "could not activate interrupt\n");
- 	}
- 	com->ioportres = port;
- 	return 0;
- }
- 
- int
- sio_attach_unit(com, unit, iobase, flags, no_irq, bst, bsh)
-  	struct com_s	*com;
- 	int		unit;
- 	Port_t		iobase;
- 	u_int		flags;
- 	bool_t		no_irq;
- 	bus_space_tag_t	bst;
- 	bus_space_handle_t bsh;
- {
- #ifdef COM_ESP
- 	Port_t		*espp;
- #endif
- 
- 	if (unit >= SIO_MAXUNITS)
- 		return ENXIO;
  	if (unit >= sio_numunits)
  		sio_numunits = unit + 1;
  	/*
--- 1134,1139 ----
***************
*** 1366,1377 ****
  	 */
  	bzero(com, sizeof *com);
  	com->unit = unit;
! 	com->bst = bst;
! 	com->bsh = bsh;
  	com->cfcr_image = CFCR_8BITS;
  	com->dtr_wait = 3 * hz;
  	com->loses_outints = COM_LOSESOUTINTS(flags) != 0;
! 	com->no_irq = no_irq;
  	com->tx_fifo_size = 1;
  	com->obufs[0].l_head = com->obuf1;
  	com->obufs[1].l_head = com->obuf2;
--- 1150,1162 ----
  	 */
  	bzero(com, sizeof *com);
  	com->unit = unit;
! 	com->ioportres = port;
! 	com->bst = rman_get_bustag(port);
! 	com->bsh = rman_get_bushandle(port);
  	com->cfcr_image = CFCR_8BITS;
  	com->dtr_wait = 3 * hz;
  	com->loses_outints = COM_LOSESOUTINTS(flags) != 0;
! 	com->no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL) != 0;
  	com->tx_fifo_size = 1;
  	com->obufs[0].l_head = com->obuf1;
  	com->obufs[1].l_head = com->obuf2;
***************
*** 1407,1412 ****
--- 1192,1203 ----
  		com->it_in.c_ispeed = com->it_in.c_ospeed = TTYDEF_SPEED;
  	if (siosetwater(com, com->it_in.c_ispeed) != 0) {
  		enable_intr();
+ 		/*
+ 		 * Leave i/o resources allocated if this is a `cn'-level
+ 		 * console, so that other devices can't snarf them.
+ 		 */
+ 		if (iobase != siocniobase)
+ 			bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
  		return (ENOMEM);
  	}
  	enable_intr();
***************
*** 1456,1468 ****
  			printf(" 16550A fifo disabled");
  		} else {
  			com->hasfifo = TRUE;
- 			com->tx_fifo_size = COM_FIFOSIZE(flags);
  			if (COM_ST16650A(flags)) {
  				com->st16650a = 1;
- 				if (! com->tx_fifo_size)
  				com->tx_fifo_size = 32;
  				printf(" ST16650A");
  			} else {
  				printf(" 16550A");
  			}
  		}
--- 1247,1258 ----
  			printf(" 16550A fifo disabled");
  		} else {
  			com->hasfifo = TRUE;
  			if (COM_ST16650A(flags)) {
  				com->st16650a = 1;
  				com->tx_fifo_size = 32;
  				printf(" ST16650A");
  			} else {
+ 				com->tx_fifo_size = COM_FIFOSIZE(flags);
  				printf(" 16550A");
  			}
  		}
***************
*** 1473,1483 ****
  				break;
  			}
  #endif
! 		if (com->hasfifo) {
  			if (!com->tx_fifo_size)
  				com->tx_fifo_size = 16;
  			else
! 				printf(" with %d bytes FIFO",
  				    com->tx_fifo_size);
  		}
  
--- 1263,1273 ----
  				break;
  			}
  #endif
! 		if (!com->st16650a) {
  			if (!com->tx_fifo_size)
  				com->tx_fifo_size = 16;
  			else
! 				printf(" lookalike with %d bytes FIFO",
  				    com->tx_fifo_size);
  		}
  
***************
*** 1514,1524 ****
--- 1304,1320 ----
  
  #ifdef COM_MULTIPORT
  	if (COM_ISMULTIPORT(flags)) {
+ 		device_t masterdev;
+ 
  		com->multiport = TRUE;
  		printf(" (multiport");
  		if (unit == COM_MPMASTER(flags))
  			printf(" master");
  		printf(")");
+ 		masterdev = devclass_get_device(sio_devclass,
+ 		    COM_MPMASTER(flags));
+ 		com->no_irq = (masterdev == NULL || bus_get_resource(masterdev,
+ 		    SYS_RES_IRQ, 0, NULL, NULL) != 0);
  	 }
  #endif /* COM_MULTIPORT */
  	if (unit == comconsole)
***************
*** 1527,1534 ****
  		printf(" with a bogus IIR_TXRDY register");
  	printf("\n");
  
- 	com_addr(unit) = com;
- 
  	if (!sio_registered) {
  		register_swi(SWI_TTY, siopoll);
  		sio_registered = TRUE;
--- 1323,1328 ----
***************
*** 1549,1554 ****
--- 1343,1376 ----
  	com->pps.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;
  	pps_init(&com->pps);
  
+ 	rid = 0;
+ 	com->irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1,
+ 	    RF_ACTIVE);
+ 	if (com->irqres) {
+ 		ret = BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres,
+ 				     INTR_TYPE_TTY | INTR_TYPE_FAST,
+ 				     siointr, com, &com->cookie);
+ 		if (ret) {
+ 			ret = BUS_SETUP_INTR(device_get_parent(dev), dev,
+ 					     com->irqres, INTR_TYPE_TTY,
+ 					     siointr, com, &com->cookie);
+ 			if (ret == 0)
+ 				device_printf(dev, "unable to activate interrupt in fast mode - using normal mode\n");
+ 		}
+ 		if (ret)
+ 			device_printf(dev, "could not activate interrupt\n");
+ #if defined(DDB) && (defined(BREAK_TO_DEBUGGER) || \
+     defined(ALT_BREAK_TO_DEBUGGER))
+ 		/*
+ 		 * Enable interrupts for early break-to-debugger support
+ 		 * on the console.
+ 		 */
+ 		if (ret == 0 && unit == comconsole)
+ 			outb(siocniobase + com_ier, IER_ERXRDY | IER_ERLS |
+ 			    IER_EMSC);
+ #endif
+ 	}
+ 
  	return (0);
  }
  
***************
*** 2048,2074 ****
  }
  
  static void
- sio_pci_intr(arg)
- 	void		*arg;
- {
- 	struct multicom	*d = arg;
- 	struct com_s	*com;
- 	bool_t		possibly_more_intrs;
- 
- 	disable_intr();
- 	do {
- 		possibly_more_intrs = FALSE;
- 		for (com=d->com; com<d->com+d->nchan; ++com) {
- 			if ((inb(com->int_id_port) & IIR_IMASK) != IIR_NOPEND) {
- 				siointr1(com);
- 				possibly_more_intrs = TRUE;
- 			}
- 		}
- 	} while (possibly_more_intrs);
- 	enable_intr();
- }
- 
- static void
  siointr1(com)
  	struct com_s	*com;
  {
--- 1870,1875 ----
***************
*** 2533,2559 ****
  	if (t->c_ispeed == 0)
  		t->c_ispeed = t->c_ospeed;
  
! 	/* convert parameters to the com struct and the device */
  	unit = DEV_TO_UNIT(tp->t_dev);
  	com = com_addr(unit);
  	if (com == NULL)
  		return (ENODEV);
- 
- 	/* check requested parameters */
- 	if (! com->oscillator)
- 		com->oscillator = sio_find_freq (com);
- 	if (t->c_ospeed == 0)
- 		divisor = 0;
- 	else {
- 		divisor = COMDIVISOR (com->oscillator, t->c_ospeed);
- 		if (divisor == 0)
- 			divisor = 1;
- 		t->c_ospeed = COMDIVISOR (com->oscillator, divisor);
- 		t->c_ispeed = t->c_ospeed;
- 	}
- 	if (divisor > 0 && t->c_ispeed != t->c_ospeed)
- 		return (EINVAL);
- 
  	s = spltty();
  	if (divisor == 0)
  		(void)commctl(com, TIOCM_DTR, DMBIC);	/* hang up line */
--- 2334,2349 ----
  	if (t->c_ispeed == 0)
  		t->c_ispeed = t->c_ospeed;
  
! 	/* check requested parameters */
! 	divisor = ttspeedtab(t->c_ospeed, comspeedtab);
! 	if (divisor < 0 || (divisor > 0 && t->c_ispeed != t->c_ospeed))
! 		return (EINVAL);
! 
! 	/* parameters are OK, convert them to the com struct and the device */
  	unit = DEV_TO_UNIT(tp->t_dev);
  	com = com_addr(unit);
  	if (com == NULL)
  		return (ENODEV);
  	s = spltty();
  	if (divisor == 0)
  		(void)commctl(com, TIOCM_DTR, DMBIC);	/* hang up line */
***************
*** 3084,3090 ****
  	u_char	mcr;
  };
  
! static speed_t siocngetspeed __P((Port_t));
  static void siocnclose	__P((struct siocnstate *sp, Port_t iobase));
  static void siocnopen	__P((struct siocnstate *sp, Port_t iobase, int speed));
  static void siocntxwait	__P((Port_t iobase));
--- 2874,2880 ----
  	u_char	mcr;
  };
  
! static speed_t siocngetspeed __P((Port_t, struct speedtab *));
  static void siocnclose	__P((struct siocnstate *sp, Port_t iobase));
  static void siocnopen	__P((struct siocnstate *sp, Port_t iobase, int speed));
  static void siocntxwait	__P((Port_t iobase));
***************
*** 3132,3139 ****
   */
  
  static speed_t
! siocngetspeed(iobase)
  	Port_t iobase;
  {
  	int	code;
  	u_char	dlbh;
--- 2922,2930 ----
   */
  
  static speed_t
! siocngetspeed(iobase, table)
  	Port_t iobase;
+ 	struct speedtab *table;
  {
  	int	code;
  	u_char	dlbh;
***************
*** 3150,3156 ****
  
  	code = dlbh << 8 | dlbl;
  
! 	return COMDIVISOR (1843200, code);
  }
  
  static void
--- 2941,2951 ----
  
  	code = dlbh << 8 | dlbl;
  
! 	for (; table->sp_speed != -1; table++)
! 		if (table->sp_code == code)
! 			return (table->sp_speed);
! 
! 	return (0);	/* didn't match anything sane */
  }
  
  static void
***************
*** 3181,3187 ****
  	 * data input register.  This also reduces the effects of the
  	 * UMC8669F bug.
  	 */
! 	divisor = COMDIVISOR (1843200, speed);
  	dlbl = divisor & 0xFF;
  	if (sp->dlbl != dlbl)
  		outb(iobase + com_dlbl, dlbl);
--- 2976,2982 ----
  	 * data input register.  This also reduces the effects of the
  	 * UMC8669F bug.
  	 */
! 	divisor = ttspeedtab(speed, comspeedtab);
  	dlbl = divisor & 0xFF;
  	if (sp->dlbl != dlbl)
  		outb(iobase + com_dlbl, dlbl);
***************
*** 3263,3269 ****
  			iobase = port;
  			s = spltty();
  			if (boothowto & RB_SERIAL) {
! 				boot_speed = siocngetspeed(iobase);
  				if (boot_speed)
  					comdefaultrate = boot_speed;
  			}
--- 3058,3064 ----
  			iobase = port;
  			s = spltty();
  			if (boothowto & RB_SERIAL) {
! 				boot_speed = siocngetspeed(iobase, comspeedtab);
  				if (boot_speed)
  					comdefaultrate = boot_speed;
  			}
***************
*** 3527,3534 ****
  
  DRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);
  #if NCARD > 0
! DRIVER_MODULE(sio, pccard, sio_pccard_driver, sio_pccard_devclass, 0, 0);
  #endif
  #if NPCI > 0
! DRIVER_MODULE(sio, pci, sio_pci_driver, sio_pci_devclass, 0, 0);
  #endif
--- 3322,3329 ----
  
  DRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);
  #if NCARD > 0
! DRIVER_MODULE(sio, pccard, sio_pccard_driver, sio_devclass, 0, 0);
  #endif
  #if NPCI > 0
! DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0);
  #endif

[-- Attachment #4 --]
Copyright (c) 1992-2001 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD 4.4-01-12-2001-STABLE #0: Thu Jan 10 17:32:28 EET 2002
    root@freebsd.kcm.bg:/usr/src/sys/compile/GENERIC
Timecounter "i8254"  frequency 1193182 Hz
CPU: Pentium III/Pentium III Xeon/Celeron (746.76-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x683  Stepping = 3
  Features=0x387fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,PN,MMX,FXSR,SSE>
real memory  = 268369920 (262080K bytes)
avail memory = 256667648 (250652K bytes)
Preloaded elf kernel "kernel" at 0xc0489000.
Pentium Pro MTRR support enabled
md0: Malloc disk
Using $PIR table, 12 entries at 0xc00fdf00
npx0: <math processor> on motherboard
npx0: INT 16 interface
pcib0: <Intel 82443GX host to PCI bridge> on motherboard
pci0: <PCI bus> on pcib0
pcib2: <Intel 82443GX (440 GX) PCI-PCI (AGP) bridge> at device 1.0 on pci0
pci1: <PCI bus> on pcib2
pcib3: <PCI to PCI bridge (vendor=1011 device=0023)> at device 15.0 on pci1
pci2: <PCI bus> on pcib3
ahc0: <Adaptec aic7896/97 Ultra2 SCSI adapter> port 0x2000-0x20ff mem 0xf4100000-0xf4100fff irq 11 at device 12.0 on pci0
aic7896/97: Ultra2 Wide Channel A, SCSI Id=7, 32/255 SCBs
ahc1: <Adaptec aic7896/97 Ultra2 SCSI adapter> port 0x2400-0x24ff mem 0xf4101000-0xf4101fff irq 11 at device 12.1 on pci0
aic7896/97: Ultra2 Wide Channel B, SCSI Id=7, 32/255 SCBs
siopci0: <Moxa Technologies C168H/PCI> port 0x2c20-0x2c2f,0x2880-0x28bf,0x2800-0x287f irq 5 at device 13.0 on pci0
sio4: couldn't map ports/memory
device_probe_and_attach: siopci0 attach returned 6
fxp0: <Intel Pro 10/100B/100+ Ethernet> port 0x28c0-0x28ff mem 0xf4000000-0xf40fffff,0xf4102000-0xf4102fff irq 10 at device 14.0 on pci0
fxp0: Ethernet address 00:d0:b7:a9:6d:91
inphy0: <i82555 10/100 media interface> on miibus0
inphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
isab0: <Intel 82371AB PCI to ISA bridge> at device 18.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel PIIX4 ATA33 controller> port 0x2c30-0x2c3f at device 18.1 on pci0
ata0: at 0x1f0 irq 14 on atapci0
ata1: at 0x170 irq 15 on atapci0
uhci0: <Intel 82371AB/EB (PIIX4) USB controller> port 0x2c00-0x2c1f irq 10 at device 18.2 on pci0
usb0: <Intel 82371AB/EB (PIIX4) USB controller> on uhci0
usb0: USB revision 1.0
uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
chip1: <Intel 82371AB Power management controller> port 0x1040-0x104f at device 18.3 on pci0
pci0: <Cirrus Logic GD5480 SVGA controller> at 20.0
pcib1: <Intel 82443GX host to AGP bridge> on motherboard
pci3: <PCI bus> on pcib1
orm0: <Option ROMs> at iomem 0xc0000-0xc7fff,0xc8000-0xcd7ff,0xcd800-0xce7ff on isa0
fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: model Generic PS/2 mouse, device ID 0
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 16550A
sio1 at port 0x2f8-0x2ff irq 3 on isa0
sio1: type 16550A
ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0
ppc0: Generic chipset (ECP/PS2/NIBBLE) in COMPATIBLE mode
ppc0: FIFO with 16/16/8 bytes threshold
plip0: <PLIP network interface> on ppbus0
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port
ppi0: <Parallel I/O> on ppbus0
ad0: 6149MB <QUANTUM FIREBALL CX6.4A> [13328/15/63] at ata0-master UDMA33
acd0: CDROM <SONY CD-ROM CDU4821> at ata1-master using PIO4
Waiting 15 seconds for SCSI devices to settle
Mounting root from ufs:/dev/ad0s1a
da0 at ahc0 bus 0 target 1 lun 0
da0: <IBM DDYS-T18350N S93E> Fixed Direct Access SCSI-3 device 
da0: 80.000MB/s transfers (40.000MHz, offset 63, 16bit), Tagged Queueing Enabled
da0: 17501MB (35843670 512 byte sectors: 255H 63S/T 2231C)
da1 at ahc0 bus 0 target 2 lun 0
da1: <IBM DDYS-T18350N S93E> Fixed Direct Access SCSI-3 device 
da1: 80.000MB/s transfers (40.000MHz, offset 63, 16bit), Tagged Queueing Enabled
da1: 17501MB (35843670 512 byte sectors: 255H 63S/T 2231C)
cd0 at ahc1 bus 0 target 3 lun 0
cd0: <HP CD-Writer+ 9200 1.0c> Removable CD-ROM SCSI-4 device 
cd0: 10.000MB/s transfers (10.000MHz, offset 15)
cd0: Attempt to query device size failed: NOT READY, Medium not present

[-- Attachment #5 --]

Stoian Mishinev             Telephone:  (359) 32 621250
Digital Systems Ltd.        Mobile:     (359) 87 425785
8 Bulair Str.               Fax:        (359) 32 630119
Plovdiv 4000

Email:    mishinev@digsys.bg
Website:  http://www.digsys.bg

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200201101634.SAA20381>