AirPrime CDMA PC5220, FreeBSD 7.1

Решение проблем связванных с работой железа. Проблемы программно-аппаратной совместимости.
Правила форума
Убедительная просьба юзать теги [code] при оформлении листингов.
Сообщения не оформленные должным образом имеют все шансы быть незамеченными.
dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 19:13:01

dmesg -a

Код: Выделить всё

Copyright (c) 1992-2009 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 is a registered trademark of The FreeBSD Foundation.
FreeBSD 7.1-RELEASE-p1 #0: Sun Jan 11 15:29:37 UTC 2009
    root@alf.xtalk.com.ua:/usr/obj/usr/src/sys/GENERIC
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Celeron(R) CPU          550  @ 2.00GHz (1995.01-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x10661  Stepping = 1
  Features=0xafebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,PBE>
  Features2=0xe31d<SSE3,DTES64,MON,DS_CPL,TM2,SSSE3,CX16,xTPR,PDCM>
  AMD Features=0x20100000<NX,LM>
  AMD Features2=0x1<LAHF>
real memory  = 2138701824 (2039 MB)
avail memory = 2083213312 (1986 MB)
ACPI APIC Table: <A_M_I_ OEMAPIC >
ioapic0 <Version 2.0> irqs 0-23 on motherboard
kbd1 at kbdmux0
ath_hal: 0.9.20.3 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, RF5413)
acpi0: <A_M_I_ OEMXSDT> on motherboard
acpi0: [ITHREAD]
acpi_ec0: <Embedded Controller: GPE 0x1c, ECDT> port 0x62,0x66 on acpi0
acpi0: Power Button (fixed)
unknown: I/O range not supported
unknown: I/O range not supported
acpi0: reservation of 0, a0000 (3) failed
acpi0: reservation of 100000, 7f700000 (3) failed
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x808-0x80b on acpi0
acpi_hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
Timecounter "HPET" frequency 14318180 Hz quality 900
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
vgapci0: <VGA-compatible display> port 0xec00-0xec07 mem 0xfeb00000-0xfebfffff,0xd0000000-0xdfffffff irq 16 at device 2.0 on pci0
agp0: <Intel GM965 SVGA controller> on vgapci0
agp0: detected 7676k stolen memory
agp0: aperture size is 256M
vgapci1: <VGA-compatible display> mem 0xfe900000-0xfe9fffff at device 2.1 on pci0
uhci0: <Intel 82801H (ICH8) USB controller USB-D> port 0xd800-0xd81f irq 16 at device 26.0 on pci0
uhci0: [GIANT-LOCKED]
uhci0: [ITHREAD]
usb0: <Intel 82801H (ICH8) USB controller USB-D> on uhci0
usb0: USB revision 1.0
uhub0: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0
uhub0: 2 ports with 2 removable, self powered
uhci1: <Intel 82801H (ICH8) USB controller USB-E> port 0xd480-0xd49f irq 21 at device 26.1 on pci0
uhci1: [GIANT-LOCKED]
uhci1: [ITHREAD]
usb1: <Intel 82801H (ICH8) USB controller USB-E> on uhci1
usb1: USB revision 1.0
uhub1: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb1
uhub1: 2 ports with 2 removable, self powered
ehci0: <Intel 82801H (ICH8) USB 2.0 controller USB2-B> mem 0xfeaff000-0xfeaff3ff irq 18 at device 26.7 on pci0
ehci0: [GIANT-LOCKED]
ehci0: [ITHREAD]
usb2: waiting for BIOS to give up control
usb2: EHCI version 1.0
usb2: companion controllers, 2 ports each: usb0 usb1
usb2: <Intel 82801H (ICH8) USB 2.0 controller USB2-B> on ehci0
usb2: USB revision 2.0
uhub2: <Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb2
uhub2: 4 ports with 4 removable, self powered
pci0: <multimedia> at device 27.0 (no driver attached)
pcib1: <ACPI PCI-PCI bridge> irq 16 at device 28.0 on pci0
pci3: <ACPI PCI bus> on pcib1
pcib2: <ACPI PCI-PCI bridge> irq 17 at device 28.1 on pci0
pci4: <ACPI PCI bus> on pcib2
ath0: <Atheros 5424/2424> mem 0xfdef0000-0xfdefffff irq 17 at device 0.0 on pci4
ath0: [ITHREAD]
ath0: unable to attach hardware; HAL status 13
device_attach: ath0 attach returned 6
pcib3: <ACPI PCI-PCI bridge> irq 18 at device 28.2 on pci0
pci5: <ACPI PCI bus> on pcib3
pcib4: <ACPI PCI-PCI bridge> irq 19 at device 28.3 on pci0
pci7: <ACPI PCI bus> on pcib4
uhci2: <Intel 82801H (ICH8) USB controller USB-A> port 0xe000-0xe01f irq 23 at device 29.0 on pci0
uhci2: [GIANT-LOCKED]
uhci2: [ITHREAD]
usb3: <Intel 82801H (ICH8) USB controller USB-A> on uhci2
usb3: USB revision 1.0
uhub3: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb3
uhub3: 2 ports with 2 removable, self powered
uhci3: <Intel 82801H (ICH8) USB controller USB-B> port 0xdc00-0xdc1f irq 19 at device 29.1 on pci0
uhci3: [GIANT-LOCKED]
uhci3: [ITHREAD]
usb4: <Intel 82801H (ICH8) USB controller USB-B> on uhci3
usb4: USB revision 1.0
uhub4: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb4
uhub4: 2 ports with 2 removable, self powered
uhci4: <Intel 82801H (ICH8) USB controller USB-C> port 0xd880-0xd89f irq 18 at device 29.2 on pci0
uhci4: [GIANT-LOCKED]
uhci4: [ITHREAD]
usb5: <Intel 82801H (ICH8) USB controller USB-C> on uhci4
usb5: USB revision 1.0
uhub5: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb5
uhub5: 2 ports with 2 removable, self powered
ehci1: <Intel 82801H (ICH8) USB 2.0 controller USB2-A> mem 0xfeaff400-0xfeaff7ff irq 23 at device 29.7 on pci0
ehci1: [GIANT-LOCKED]
ehci1: [ITHREAD]
usb6: EHCI version 1.0
usb6: companion controllers, 2 ports each: usb3 usb4 usb5
usb6: <Intel 82801H (ICH8) USB 2.0 controller USB2-A> on ehci1
usb6: USB revision 2.0
uhub6: <Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb6
uhub6: 6 ports with 6 removable, self powered
pcib5: <ACPI PCI-PCI bridge> at device 30.0 on pci0
pci1: <ACPI PCI bus> on pcib5
cbb0: <RF5C476 PCI-CardBus Bridge> irq 17 at device 1.0 on pci1
cardbus0: <CardBus bus> on cbb0
pccard0: <16-bit PCCard bus> on cbb0
cbb0: [ITHREAD]
pci1: <base peripheral> at device 1.1 (no driver attached)
pci1: <base peripheral> at device 1.2 (no driver attached)
pci1: <base peripheral> at device 1.3 (no driver attached)
rl0: <RealTek 8139 10/100BaseTX> port 0xb800-0xb8ff mem 0xfddffc00-0xfddffcff irq 16 at device 7.0 on pci1
miibus0: <MII bus> on rl0
rlphy0: <RealTek internal media interface> PHY 0 on miibus0
rlphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
rl0: Ethernet address: 00:1f:c6:5c:b0:e1
rl0: [ITHREAD]
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel ICH8M UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xffa0-0xffaf at device 31.1 on pci0
ata0: <ATA channel 0> on atapci0
ata0: [ITHREAD]
ata1: <ATA channel 1> on atapci0
ata1: [ITHREAD]
atapci1: <Intel AHCI controller> port 0xe880-0xe887,0xe800-0xe803,0xe480-0xe487,0xe400-0xe403,0xe080-0xe09f mem 0xfeaff800-0xfeafffff irq 20 at device 31.2 on pci0
atapci1: [ITHREAD]
atapci1: AHCI Version 01.10 controller with 3 ports detected
ata2: <ATA channel 0> on atapci1
ata2: [ITHREAD]
ata3: <ATA channel 1> on atapci1
ata3: [ITHREAD]
ata4: <ATA channel 2> on atapci1
ata4: [ITHREAD]
acpi_button0: <Sleep Button> on acpi0
acpi_lid0: <Control Method Lid Switch> on acpi0
acpi_tz0: <Thermal Zone> on acpi0
acpi_acad0: <AC Adapter> on acpi0
battery0: <ACPI Control Method Battery> on acpi0
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
atkbd0: [ITHREAD]
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: [ITHREAD]
psm0: model IntelliMouse, device ID 3
cpu0: <ACPI CPU> on acpi0
p4tcc0: <CPU Frequency Thermal Control> on cpu0
pmtimer0 on isa0
orm0: <ISA Option ROM> at iomem 0xcf000-0xcffff pnpid ORM0000 on isa0
ppc0: parallel port not found.
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
sio0: configured irq 4 not in bitmap of probed irqs 0
sio0: port may not be enabled
sio0: configured irq 4 not in bitmap of probed irqs 0
sio0: port may not be enabled
sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 8250 or not responding
sio0: [FILTER]
sio1: configured irq 3 not in bitmap of probed irqs 0
sio1: port may not be enabled
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
ums0: <Genius Navigator 600, class 0/0, rev 1.10/1.00, addr 2> on uhub3
ums0: 3 buttons and Z dir.
Timecounter "TSC" frequency 1995010320 Hz quality 800
Timecounters tick every 1.000 msec
acd0: DVDR <HL-DT-ST DVDRAM GSA-T20N/WR02> at ata0-master UDMA33
ad4: 152627MB <Hitachi HTS542516K9SA00 BBCOC31P> at ata2-master SATA150
Trying to mount root from ufs:/dev/ad4s2a
rl0: link state changed to UP
$
Вставляю карту:

Код: Выделить всё

ohci0: <OHCI (generic) USB controller> mem 0xfd501000-0xfd501fff irq 17 at device 0.0 on cardbus0
ohci0: [GIANT-LOCKED]
ohci0: [ITHREAD]
usb7: OHCI version 1.0, legacy support
usb7: <OHCI (generic) USB controller> on ohci0
usb7: USB revision 1.0
uhub7: <(0x11c1) OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb7
uhub7: 2 ports with 2 removable, self powered
ugen0: <AirPrime, Incorporated AirPrime CDMA Wireless PC Card, class 0/0, rev 1.10/0.01, addr 2> on uhub7
$
$ uname -a

Код: Выделить всё

FreeBSD alf.xtalk.com.ua 7.1-RELEASE-p1 FreeBSD 7.1-RELEASE-p1 #0: Sun Jan 11 15:29:37 UTC 2009     root@alf.xtalk.com.ua:/usr/obj/usr/src/sys/GENERIC  i386

Хостинговая компания Host-Food.ru
Хостинг HostFood.ru
 

Услуги хостинговой компании Host-Food.ru

Хостинг HostFood.ru

Тарифы на хостинг в России, от 12 рублей: https://www.host-food.ru/tariffs/hosting/
Тарифы на виртуальные сервера (VPS/VDS/KVM) в РФ, от 189 руб.: https://www.host-food.ru/tariffs/virtualny-server-vps/
Выделенные сервера, Россия, Москва, от 2000 рублей (HP Proliant G5, Intel Xeon E5430 (2.66GHz, Quad-Core, 12Mb), 8Gb RAM, 2x300Gb SAS HDD, P400i, 512Mb, BBU):
https://www.host-food.ru/tariffs/vydelennyi-server-ds/
Недорогие домены в популярных зонах: https://www.host-food.ru/domains/

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 19:15:40

Код: Выделить всё

alf# usbdevs -v
Controller /dev/usb0:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
 port 1 powered
 port 2 powered
Controller /dev/usb1:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
 port 1 powered
 port 2 powered
Controller /dev/usb2:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), Intel(0x0000), rev 1.00
 port 1 powered
 port 2 powered
 port 3 powered
 port 4 powered
Controller /dev/usb3:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
 port 1 addr 2: low speed, power 50 mA, config 1, Navigator 600(0x008c), Genius(0x0458), rev 1.00
 port 2 powered
Controller /dev/usb4:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
 port 1 powered
 port 2 powered
Controller /dev/usb5:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
 port 1 powered
 port 2 powered
Controller /dev/usb6:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), Intel(0x0000), rev 1.00
 port 1 powered
 port 2 powered
 port 3 powered
 port 4 powered
 port 5 powered
 port 6 powered
Controller /dev/usb7:
addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), (0x11c1)(0x0000), rev 1.00
 port 1 addr 2: full speed, power 100 mA, config 1, AirPrime CDMA Wireless PC Card(0x0112), AirPrime, Incorporated(0x0f3d), rev 0.01
 port 2 powered

paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение paradox » 2009-01-11 19:17:24

а ну теперь понятно хоть как работает
а то я думал совсем чего то незнаю

pcmcia это как pci устройство
а в смамой карте pcimcia стоит usb контроллер а дальше уже ваш модем


правильно фикси те printf что я тебе говорил

что бы ничего не падало
и был нормальный лог

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 20:03:19

Код: Выделить всё

/*	$NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $	*/


#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sys/dev/usb/umodem.c,v 1.71.6.1 2008/11/25 02:59:29 kensmith Exp $");
/*-
 * Copyright (c) 2003, M. Warner Losh <imp@freebsd.org>.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*-
 * Copyright (c) 1998 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Lennart Augustsson (lennart@augustsson.net) at
 * Carlstedt Research & Technology.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by the NetBSD
 *        Foundation, Inc. and its contributors.
 * 4. Neither the name of The NetBSD Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * Comm Class spec:  http://www.usb.org/developers/devclass_docs/usbccs10.pdf
 *                   http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
 *                   http://www.usb.org/developers/devclass_docs/cdc_wmc10.zip
 */

/*
 * TODO:
 * - Add error recovery in various places; the big problem is what
 *   to do in a callback if there is an error.
 * - Implement a Call Device for modems without multiplexed commands.
 *
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/ioccom.h>
#include <sys/conf.h>
#include <sys/serial.h>
#include <sys/tty.h>
#include <sys/file.h>
#include <sys/select.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/bus.h>
#include <sys/poll.h>
#include <sys/uio.h>
#include <sys/taskqueue.h>

#include <dev/usb/usb.h>
#include <dev/usb/usbcdc.h>

#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_quirks.h>

#include <dev/usb/ucomvar.h>

#include "usbdevs.h"

#ifdef USB_DEBUG
int	umodemdebug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, umodem, CTLFLAG_RW, 0, "USB umodem");
SYSCTL_INT(_hw_usb_umodem, OID_AUTO, debug, CTLFLAG_RW,
	   &umodemdebug, 0, "umodem debug level");
#define DPRINTFN(n, x)	if (umodemdebug > (n)) printf x
#else
#define DPRINTFN(n, x)
#endif
#define DPRINTF(x) DPRINTFN(0, x)

static const struct umodem_product {
	u_int16_t	vendor;
	u_int16_t	product;
	u_int8_t	interface;
} umodem_products[] = {
	/* Kyocera AH-K3001V*/
	{ USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_AHK3001V, 0 },
	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720, 0 },
	{ USB_VENDOR_CURITEL, USB_PRODUCT_CURITEL_PC5740, 0 },
      { 0x0f3d, 0x0112, 1 },
	{ 0, 0, 0 },
};

/*
 * These are the maximum number of bytes transferred per frame.
 * As speeds for umodem deivces increase, these numbers will need to
 * be increased.  They should be good for G3 speeds and below.
 */
#define UMODEMIBUFSIZE 1024
#define UMODEMOBUFSIZE 1024

#define UMODEM_MODVER			1	/* module version */

struct umodem_softc {
	struct ucom_softc	sc_ucom;

	device_t		sc_dev;		/* base device */

	usbd_device_handle	sc_udev;	/* USB device */

	int			sc_ctl_iface_no;
	usbd_interface_handle	sc_ctl_iface;	/* control interface */
	int			sc_data_iface_no;
	usbd_interface_handle	sc_data_iface;	/* data interface */

	int			sc_cm_cap;	/* CM capabilities */
	int			sc_acm_cap;	/* ACM capabilities */

	int			sc_cm_over_data;

	usb_cdc_line_state_t	sc_line_state;	/* current line state */
	u_char			sc_dtr;		/* current DTR state */
	u_char			sc_rts;		/* current RTS state */

	u_char			sc_opening;	/* lock during open */

	int			sc_ctl_notify;	/* Notification endpoint */
	usbd_pipe_handle	sc_notify_pipe; /* Notification pipe */
	usb_cdc_notification_t	sc_notify_buf;	/* Notification structure */
	u_char			sc_lsr;		/* Local status register */
	u_char			sc_msr;		/* Modem status register */

	struct task		sc_task;
};

static void	*umodem_get_desc(usbd_device_handle dev, int type, int subtype);
static usbd_status umodem_set_comm_feature(struct umodem_softc *sc,
					   int feature, int state);
static usbd_status umodem_set_line_coding(struct umodem_softc *sc,
					  usb_cdc_line_state_t *state);

static void	umodem_get_caps(usbd_device_handle, int *, int *);
static usb_cdc_union_descriptor_t *
umodem_get_union(usbd_device_handle dev, int iface_no);
static void	umodem_get_status(void *, int portno, u_char *lsr, u_char *msr);
static void	umodem_set(void *, int, int, int);
static void	umodem_dtr(struct umodem_softc *, int);
static void	umodem_rts(struct umodem_softc *, int);
static void	umodem_break(struct umodem_softc *, int);
static void	umodem_set_line_state(struct umodem_softc *);
static int	umodem_param(void *, int, struct termios *);
static int	umodem_ioctl(void *, int, u_long, caddr_t, int, struct thread *);
static int	umodem_open(void *, int portno);
static void	umodem_close(void *, int portno);
static void	umodem_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
static void	umodem_notify(void *, int);

static struct ucom_callback umodem_callback = {
	umodem_get_status,
	umodem_set,
	umodem_param,
	umodem_ioctl,
	umodem_open,
	umodem_close,
	NULL,
	NULL,
};

static device_probe_t umodem_match;
static device_attach_t umodem_attach;
static device_detach_t umodem_detach;

static device_method_t umodem_methods[] = {
	/* Device interface */
	DEVMETHOD(device_probe, umodem_match),
	DEVMETHOD(device_attach, umodem_attach),
	DEVMETHOD(device_detach, umodem_detach),
	{ 0, 0 }
};

static driver_t umodem_driver = {
	"ucom",
	umodem_methods,
	sizeof (struct umodem_softc)
};

DRIVER_MODULE(umodem, uhub, umodem_driver, ucom_devclass, usbd_driver_load, 0);
MODULE_DEPEND(umodem, usb, 1, 1, 1);
MODULE_DEPEND(umodem, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
MODULE_VERSION(umodem, UMODEM_MODVER);

static int
umodem_match(device_t self)
{
	struct usb_attach_arg *uaa = device_get_ivars(self);
	usb_interface_descriptor_t *id;
	usb_device_descriptor_t *dd;
	int cm, acm, i, ret;

	if (uaa->iface == NULL)
		return (UMATCH_NONE);

	id = usbd_get_interface_descriptor(uaa->iface);
	dd = usbd_get_device_descriptor(uaa->device);
	if (id == NULL || dd == NULL)
		return (UMATCH_NONE);

	ret = UMATCH_NONE;
	for (i = 0; umodem_products[i].vendor != 0; i++) {
		if (umodem_products[i].vendor == UGETW(dd->idVendor) &&
		    umodem_products[i].product == UGETW(dd->idProduct) &&
		    umodem_products[i].interface == id->bInterfaceNumber) {
			ret = UMATCH_VENDOR_PRODUCT;
			break;
		}
	}

	if (ret == UMATCH_NONE &&
	    id->bInterfaceClass == UICLASS_CDC &&
	    id->bInterfaceSubClass == UISUBCLASS_ABSTRACT_CONTROL_MODEL &&
	    id->bInterfaceProtocol == UIPROTO_CDC_AT)
		ret = UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;

	if (ret == UMATCH_NONE)
		return (ret);

	umodem_get_caps(uaa->device, &cm, &acm);
	if (!(cm & USB_CDC_CM_DOES_CM) ||
	    !(cm & USB_CDC_CM_OVER_DATA) ||
	    !(acm & USB_CDC_ACM_HAS_LINE))
		return (UMATCH_NONE);

	return ret;
}

static int
umodem_attach(device_t self)
{
	struct umodem_softc *sc = device_get_softc(self);
	struct usb_attach_arg *uaa = device_get_ivars(self);
	usbd_device_handle dev = uaa->device;
	usb_interface_descriptor_t *id;
	usb_endpoint_descriptor_t *ed;
	usb_cdc_cm_descriptor_t *cmd;
      usb_cdc_union_descriptor_t *cud;
	int data_ifcno;
	int i;
	struct ucom_softc *ucom;

	ucom = &sc->sc_ucom;
	ucom->sc_dev = self;
	sc->sc_dev = self;
	ucom->sc_udev = dev;
	ucom->sc_iface = uaa->iface;

	sc->sc_udev = dev;
	sc->sc_ctl_iface = uaa->iface;
	id = usbd_get_interface_descriptor(sc->sc_ctl_iface);
	sc->sc_ctl_iface_no = id->bInterfaceNumber;
	device_printf(self, "iclass %d/%d\n", id->bInterfaceClass,
	  id->bInterfaceSubClass);

	umodem_get_caps(dev, &sc->sc_cm_cap, &sc->sc_acm_cap);

	/* Get the data interface no. */
	cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
	if (cmd == NULL) {
               cud = umodem_get_union(dev, sc->sc_ctl_iface_no);
               if (cud ==NULL) {
                       device_printf(sc->sc_dev, "no CM and Union descriptors\n");
		goto bad;
                       }else data_ifcno = cud->bSlaveInterface[0];
       }else data_ifcno = cmd->bDataInterface;
       sc->sc_data_iface_no = data_ifcno;
	device_printf(sc->sc_dev,
	    "data interface %d, has %sCM over data, has %sbreak\n",
	    data_ifcno, sc->sc_cm_cap & USB_CDC_CM_OVER_DATA ? "" : "no ",
	    sc->sc_acm_cap & USB_CDC_ACM_HAS_BREAK ? "" : "no ");

	/* Get the data interface too. */
	for (i = 0; i < uaa->nifaces; i++) {
		if (uaa->ifaces[i] != NULL) {
			id = usbd_get_interface_descriptor(uaa->ifaces[i]);
			if (id != NULL && id->bInterfaceNumber == data_ifcno) {
				sc->sc_data_iface = uaa->ifaces[i];
				uaa->ifaces[i] = NULL;
			}
		}
	}
	if (sc->sc_data_iface == NULL) {
		device_printf(sc->sc_dev, "no data interface\n");
		goto bad;
	}
	ucom->sc_iface = sc->sc_data_iface;

	/*
	 * Find the bulk endpoints.
	 * Iterate over all endpoints in the data interface and take note.
	 */
	ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1;

	id = usbd_get_interface_descriptor(sc->sc_data_iface);
	for (i = 0; i < id->bNumEndpoints; i++) {
		ed = usbd_interface2endpoint_descriptor(sc->sc_data_iface, i);
		if (ed == NULL) {
			device_printf(sc->sc_dev,
			    "no endpoint descriptor for %d\n", i);
			goto bad;
		}
		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
			ucom->sc_bulkin_no = ed->bEndpointAddress;
                } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
			ucom->sc_bulkout_no = ed->bEndpointAddress;
                }
        }

	if (ucom->sc_bulkin_no == -1) {
		device_printf(sc->sc_dev, "Could not find data bulk in\n");
		goto bad;
	}
	if (ucom->sc_bulkout_no == -1) {
		device_printf(sc->sc_dev, "Could not find data bulk out\n");
		goto bad;
	}

	if (sc->sc_cm_cap & USB_CDC_CM_OVER_DATA) {
		if (sc->sc_acm_cap & USB_CDC_ACM_HAS_FEATURE)
			umodem_set_comm_feature(sc, UCDC_ABSTRACT_STATE,
			    UCDC_DATA_MULTIPLEXED);
		sc->sc_cm_over_data = 1;
	}

	/*
	 * The standard allows for notification messages (to indicate things
	 * like a modem hangup) to come in via an interrupt endpoint
	 * off of the control interface.  Iterate over the endpoints on
	 * the control interface and see if there are any interrupt
	 * endpoints; if there are, then register it.
	 */

	sc->sc_ctl_notify = -1;
	sc->sc_notify_pipe = NULL;

	for (i = 0; i < id->bNumEndpoints; i++) {
		ed = usbd_interface2endpoint_descriptor(sc->sc_ctl_iface, i);
		if (ed == NULL)
			continue;

		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
		    (ed->bmAttributes & UE_XFERTYPE) == UE_INTERRUPT) {
			device_printf(sc->sc_dev, 
			    "status change notification available\n");
			sc->sc_ctl_notify = ed->bEndpointAddress;
		}
	}

	sc->sc_dtr = -1;

	ucom->sc_parent = sc;
	ucom->sc_portno = UCOM_UNK_PORTNO;
	/* bulkin, bulkout set above */
	ucom->sc_ibufsize = UMODEMIBUFSIZE;
	ucom->sc_obufsize = UMODEMOBUFSIZE;
	ucom->sc_ibufsizepad = UMODEMIBUFSIZE;
	ucom->sc_opkthdrlen = 0;
	ucom->sc_callback = &umodem_callback;

	TASK_INIT(&sc->sc_task, 0, umodem_notify, sc);
	ucom_attach(&sc->sc_ucom);
	return 0;

 bad:
	ucom->sc_dying = 1;
	return ENXIO;
}

static int
umodem_open(void *addr, int portno)
{
	struct umodem_softc *sc = addr;
	int err;

	DPRINTF(("umodem_open: sc=%p\n", sc));

	if (sc->sc_ctl_notify != -1 && sc->sc_notify_pipe == NULL) {
		err = usbd_open_pipe_intr(sc->sc_ctl_iface, sc->sc_ctl_notify,
		    USBD_SHORT_XFER_OK, &sc->sc_notify_pipe, sc,
		    &sc->sc_notify_buf, sizeof(sc->sc_notify_buf),
		    umodem_intr, USBD_DEFAULT_INTERVAL);

		if (err) {
			DPRINTF(("Failed to establish notify pipe: %s\n",
				usbd_errstr(err)));
			return EIO;
		}
	}

	return 0;
}

static void
umodem_close(void *addr, int portno)
{
	struct umodem_softc *sc = addr;
	int err;

	DPRINTF(("umodem_close: sc=%p\n", sc));

	if (sc->sc_notify_pipe != NULL) {
		err = usbd_abort_pipe(sc->sc_notify_pipe);
		if (err)
			device_printf(sc->sc_dev, 
			    "abort notify pipe failed: %s\n",
			    usbd_errstr(err));
		err = usbd_close_pipe(sc->sc_notify_pipe);
		if (err)
			device_printf(sc->sc_dev,
			    "close notify pipe failed: %s\n",
			    usbd_errstr(err));
		sc->sc_notify_pipe = NULL;
	}
}

static void
umodem_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
{
	struct umodem_softc *sc = priv;
	u_char mstatus;

	if (sc->sc_ucom.sc_dying)
		return;

	if (status != USBD_NORMAL_COMPLETION) {
		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
			return;
		device_printf(sc->sc_dev, "abnormal status: %s\n",
		    usbd_errstr(status));
		return;
	}

	if (sc->sc_notify_buf.bmRequestType != UCDC_NOTIFICATION) {
		DPRINTF(("%s: unknown message type (%02x) on notify pipe\n",
			 device_get_nameunit(sc->sc_dev),
			 sc->sc_notify_buf.bmRequestType));
		return;
	}

	switch (sc->sc_notify_buf.bNotification) {
	case UCDC_N_SERIAL_STATE:
		/*
		 * Set the serial state in ucom driver based on
		 * the bits from the notify message
		 */
		if (UGETW(sc->sc_notify_buf.wLength) != 2) {
			device_printf(sc->sc_dev,
			    "Invalid notification length! (%d)\n",
			    UGETW(sc->sc_notify_buf.wLength));
			break;
		}
		DPRINTF(("%s: notify bytes = %02x%02x\n",
			 device_get_nameunit(sc->sc_dev),
			 sc->sc_notify_buf.data[0],
			 sc->sc_notify_buf.data[1]));
		/* Currently, lsr is always zero. */
		sc->sc_lsr = sc->sc_msr = 0;
		mstatus = sc->sc_notify_buf.data[0];

		if (ISSET(mstatus, UCDC_N_SERIAL_RI))
			sc->sc_msr |= SER_RI;
		if (ISSET(mstatus, UCDC_N_SERIAL_DSR))
			sc->sc_msr |= SER_DSR;
		if (ISSET(mstatus, UCDC_N_SERIAL_DCD))
			sc->sc_msr |= SER_DCD;
		/* Deferred notifying to the ucom layer */
		taskqueue_enqueue(taskqueue_swi_giant, &sc->sc_task);
		break;
	default:
		DPRINTF(("%s: unknown notify message: %02x\n",
			 device_get_nameunit(sc->sc_dev),
			 sc->sc_notify_buf.bNotification));
		break;
	}
}

static void
umodem_notify(void *arg, int count)
{
	struct umodem_softc *sc;

	sc = (struct umodem_softc *)arg;
	if (sc->sc_ucom.sc_dying)
		return;
	ucom_status_change(&sc->sc_ucom);
}

void
umodem_get_caps(usbd_device_handle dev, int *cm, int *acm)
{
	usb_cdc_cm_descriptor_t *cmd;
	usb_cdc_acm_descriptor_t *cad;

	*cm = *acm = 0;

	cad = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_ACM);
	if (cad == NULL) {
		DPRINTF(("umodem_get_desc: no ACM desc\n"));
		return;
	}
	*acm = cad->bmCapabilities;

       cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
       if (cmd == NULL) {
               DPRINTF(("umodem_get_desc: no CM desc\n"));
               *cm = USB_CDC_CM_DOES_CM | USB_CDC_CM_OVER_DATA;
       }else *cm = cmd->bmCapabilities;
}

usb_cdc_union_descriptor_t  *
umodem_get_union(usbd_device_handle dev, int iface_no)
{
    usb_cdc_union_descriptor_t *desc;
    usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
    uByte *p = (uByte *)cd;
    uByte *end = p + UGETW(cd->wTotalLength);
    while (p < end) {
        desc = (usb_cdc_union_descriptor_t *)p;
        if (desc->bDescriptorType ==  UDESC_CS_INTERFACE &&
                desc->bDescriptorSubtype == UDESCSUB_CDC_UNION &&
                desc->bMasterInterface == iface_no)
            return (desc);
        p += desc->bLength;
    }
    return (0);
}

void
umodem_get_status(void *addr, int portno, u_char *lsr, u_char *msr)
{
	struct umodem_softc *sc = addr;

	DPRINTF(("umodem_get_status:\n"));

	if (lsr != NULL)
		*lsr = sc->sc_lsr;
	if (msr != NULL)
		*msr = sc->sc_msr;
}

int
umodem_param(void *addr, int portno, struct termios *t)
{
	struct umodem_softc *sc = addr;
	usbd_status err;
	usb_cdc_line_state_t ls;

	DPRINTF(("umodem_param: sc=%p\n", sc));

	USETDW(ls.dwDTERate, t->c_ospeed);
	if (ISSET(t->c_cflag, CSTOPB))
		ls.bCharFormat = UCDC_STOP_BIT_2;
	else
		ls.bCharFormat = UCDC_STOP_BIT_1;
	if (ISSET(t->c_cflag, PARENB)) {
		if (ISSET(t->c_cflag, PARODD))
			ls.bParityType = UCDC_PARITY_ODD;
		else
			ls.bParityType = UCDC_PARITY_EVEN;
	} else
		ls.bParityType = UCDC_PARITY_NONE;
	switch (ISSET(t->c_cflag, CSIZE)) {
	case CS5:
		ls.bDataBits = 5;
		break;
	case CS6:
		ls.bDataBits = 6;
		break;
	case CS7:
		ls.bDataBits = 7;
		break;
	case CS8:
		ls.bDataBits = 8;
		break;
	}

	err = umodem_set_line_coding(sc, &ls);
	if (err) {
		DPRINTF(("umodem_param: err=%s\n", usbd_errstr(err)));
		return (ENOTTY);
	}
	return (0);
}

int
umodem_ioctl(void *addr, int portno, u_long cmd, caddr_t data, int flag,
	     struct thread *p)
{
	struct umodem_softc *sc = addr;
	int error = 0;

	if (sc->sc_ucom.sc_dying)
		return (EIO);

	DPRINTF(("umodemioctl: cmd=0x%08lx\n", cmd));

	switch (cmd) {
	case USB_GET_CM_OVER_DATA:
		*(int *)data = sc->sc_cm_over_data;
		break;

	case USB_SET_CM_OVER_DATA:
		if (*(int *)data != sc->sc_cm_over_data) {
			/* XXX change it */
		}
		break;

	default:
		DPRINTF(("umodemioctl: unknown\n"));
		error = ENOTTY;
		break;
	}

	return (error);
}

void
umodem_dtr(struct umodem_softc *sc, int onoff)
{
	DPRINTF(("umodem_modem: onoff=%d\n", onoff));

	if (sc->sc_dtr == onoff)
		return;
	sc->sc_dtr = onoff;

	umodem_set_line_state(sc);
}

void
umodem_rts(struct umodem_softc *sc, int onoff)
{
	DPRINTF(("umodem_modem: onoff=%d\n", onoff));

	if (sc->sc_rts == onoff)
		return;
	sc->sc_rts = onoff;

	umodem_set_line_state(sc);
}

void
umodem_set_line_state(struct umodem_softc *sc)
{
	usb_device_request_t req;
	int ls;

	ls = (sc->sc_dtr ? UCDC_LINE_DTR : 0) |
	     (sc->sc_rts ? UCDC_LINE_RTS : 0);
	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
	req.bRequest = UCDC_SET_CONTROL_LINE_STATE;
	USETW(req.wValue, ls);
	USETW(req.wIndex, sc->sc_ctl_iface_no);
	USETW(req.wLength, 0);

	(void)usbd_do_request(sc->sc_udev, &req, 0);

}

void
umodem_break(struct umodem_softc *sc, int onoff)
{
	usb_device_request_t req;

	DPRINTF(("umodem_break: onoff=%d\n", onoff));

	if (!(sc->sc_acm_cap & USB_CDC_ACM_HAS_BREAK))
		return;

	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
	req.bRequest = UCDC_SEND_BREAK;
	USETW(req.wValue, onoff ? UCDC_BREAK_ON : UCDC_BREAK_OFF);
	USETW(req.wIndex, sc->sc_ctl_iface_no);
	USETW(req.wLength, 0);

	(void)usbd_do_request(sc->sc_udev, &req, 0);
}

void
umodem_set(void *addr, int portno, int reg, int onoff)
{
	struct umodem_softc *sc = addr;

	switch (reg) {
	case UCOM_SET_DTR:
		umodem_dtr(sc, onoff);
		break;
	case UCOM_SET_RTS:
		umodem_rts(sc, onoff);
		break;
	case UCOM_SET_BREAK:
		umodem_break(sc, onoff);
		break;
	default:
		break;
	}
}

usbd_status
umodem_set_line_coding(struct umodem_softc *sc, usb_cdc_line_state_t *state)
{
	usb_device_request_t req;
	usbd_status err;

	DPRINTF(("umodem_set_line_coding: rate=%d fmt=%d parity=%d bits=%d\n",
		 UGETDW(state->dwDTERate), state->bCharFormat,
		 state->bParityType, state->bDataBits));

	if (memcmp(state, &sc->sc_line_state, UCDC_LINE_STATE_LENGTH) == 0) {
		DPRINTF(("umodem_set_line_coding: already set\n"));
		return (USBD_NORMAL_COMPLETION);
	}

	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
	req.bRequest = UCDC_SET_LINE_CODING;
	USETW(req.wValue, 0);
	USETW(req.wIndex, sc->sc_ctl_iface_no);
	USETW(req.wLength, UCDC_LINE_STATE_LENGTH);

	err = usbd_do_request(sc->sc_udev, &req, state);
	if (err) {
		DPRINTF(("umodem_set_line_coding: failed, err=%s\n",
			 usbd_errstr(err)));
		return (err);
	}

	sc->sc_line_state = *state;

	return (USBD_NORMAL_COMPLETION);
}

void *
umodem_get_desc(usbd_device_handle dev, int type, int subtype)
{
	usb_descriptor_t *desc;
	usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
        uByte *p = (uByte *)cd;
        uByte *end = p + UGETW(cd->wTotalLength);

	while (p < end) {
		desc = (usb_descriptor_t *)p;
		if (desc->bDescriptorType == type &&
		    desc->bDescriptorSubtype == subtype)
			return (desc);
		p += desc->bLength;
	}

	return (0);
}

usbd_status
umodem_set_comm_feature(struct umodem_softc *sc, int feature, int state)
{
	usb_device_request_t req;
	usbd_status err;
	usb_cdc_abstract_state_t ast;

	DPRINTF(("umodem_set_comm_feature: feature=%d state=%d\n", feature,
		 state));

	req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
	req.bRequest = UCDC_SET_COMM_FEATURE;
	USETW(req.wValue, feature);
	USETW(req.wIndex, sc->sc_ctl_iface_no);
	USETW(req.wLength, UCDC_ABSTRACT_STATE_LENGTH);
	USETW(ast.wState, state);

	err = usbd_do_request(sc->sc_udev, &req, &ast);
	if (err) {
		DPRINTF(("umodem_set_comm_feature: feature=%d, err=%s\n",
			 feature, usbd_errstr(err)));
		return (err);
	}

	return (USBD_NORMAL_COMPLETION);
}

static int
umodem_detach(device_t self)
{
	struct umodem_softc *sc = device_get_softc(self);
	int rv = 0;

	DPRINTF(("umodem_detach: sc=%p\n", sc));

	if (sc->sc_notify_pipe != NULL) {
		usbd_abort_pipe(sc->sc_notify_pipe);
		usbd_close_pipe(sc->sc_notify_pipe);
		sc->sc_notify_pipe = NULL;
	}

	sc->sc_ucom.sc_dying = 1;
	rv = ucom_detach(&sc->sc_ucom);

	return (rv);
}

../modules/umodem
make clean
make
make install

shutdown -r now

kldload umodem.ko

Вставляю модем

Код: Выделить всё

ohci0: <OHCI (generic) USB controller> mem 0xfd501000-0xfd501fff irq 17 at device 0.0 on cardbus0
ohci0: [GIANT-LOCKED]
ohci0: [ITHREAD]
usb7: OHCI version 1.0, legacy support
usb7: <OHCI (generic) USB controller> on ohci0
usb7: USB revision 1.0
uhub7: <(0x11c1) OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb7
uhub7: 2 ports with 2 removable, self powered
ugen0: <AirPrime, Incorporated AirPrime CDMA Wireless PC Card, class 0/0, rev 1.10/0.01, addr 2> on uhub7
достаю модем
Fatal trap 12: и т.д.


:st:

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 20:05:43

Я указаную тему скоро рапечатаю и буду курить до просветления((
там версии и для 6 и для 7 фри, тыкните пальцем куда вставить принтфы, или через строчку

paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение paradox » 2009-01-11 20:10:33

ты тему то что я дал почитай
там в ней указано что и как пропатчить
и где расставить printf )))


а падать оно будет в любом случае
наверное и на женерике
нерасчитала фря что у нее не стого не сего прорадет контроллер усб))) точнее что его вытянуть с системы :ROFL:

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 20:28:18

Код: Выделить всё

ohci0: <OHCI (generic) USB controller> mem 0xfd50100
ohci0: [GIANT-LOCKED]
ohci0: [ITHREAD]
usb7: OHCI version 1.0, legacy support
usb7: <OHCI (generic) USB controller> on ohci0
usb7: USB revision 1.0
uhub7: <(0x11c1) OHCI root hub, class 9/0, rev 1.00/
uhub7: 2 ports with 2 removable, self powered
1
Unknown USB device: vendor 0x0f3d product 0x0112 bus u
3
sho?
none:  cm 0, acm 0
1
ugen0: <AirPrime, Incorporated AirPrime CDMA Wireles

Код: Выделить всё

static int
umodem_match(device_t self)
{
	struct usb_attach_arg *uaa = device_get_ivars(self);
	usb_interface_descriptor_t *id;
	usb_device_descriptor_t *dd;
	int cm, acm, i, ret;

	if (uaa->iface == NULL)
	   {
                printf("1\n");
                return (UMATCH_NONE);
                printf("1\n");
         }

	id = usbd_get_interface_descriptor(uaa->iface);
	dd = usbd_get_device_descriptor(uaa->device);
	if (id == NULL || dd == NULL)
         {
                printf("2\n");
        printf("idvendor %x, idproduct %x, ifnum %d\n", UGETW(dd->idVendor), UGETW(dd->idProduct), id->bInterfaceNumber);
                return (UMATCH_NONE);
                printf("2\n");
         }
	ret = UMATCH_NONE;
	for (i = 0; umodem_products[i].vendor != 0; i++) {
		if (umodem_products[i].vendor == UGETW(dd->idVendor) &&
		    umodem_products[i].product == UGETW(dd->idProduct) &&
		    umodem_products[i].interface == id->bInterfaceNumber) {
			ret = UMATCH_VENDOR_PRODUCT;
			break;
		}
	}

	if (ret == UMATCH_NONE &&
	    id->bInterfaceClass == UICLASS_CDC &&
	    id->bInterfaceSubClass == UISUBCLASS_ABSTRACT_CONTROL_MODEL &&
	    id->bInterfaceProtocol == UIPROTO_CDC_AT)
		ret = UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;

	if (ret == UMATCH_NONE)
         {
                printf("3\n");
                return (ret);
                printf("3\n");
         }
	umodem_get_caps(uaa->device, &cm, &acm);
	if (!(cm & USB_CDC_CM_DOES_CM) ||
	    !(cm & USB_CDC_CM_OVER_DATA) ||
	    !(acm & USB_CDC_ACM_HAS_LINE))
                {
                printf("sho?\n");
		printf("none:  cm %x, acm %x\n", cm, acm)
                return (UMATCH_NONE);
                printf("sho?\n");
                }

        {
        printf("4\n");
        return ret;
        printf("4\n");
        }
}
static int
umodem_attach(device_t self)
Последний раз редактировалось dr_alf 2009-01-11 20:44:02, всего редактировалось 1 раз.

paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение paradox » 2009-01-11 20:43:37

{ 0x0f3d, 0x0112, 1 },
поменяй так
и покажешь дебаг
{ 0x0f3d, 0x0112, 0 },

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 20:50:29

Код: Выделить всё

Jan 11 19:47:53 alf kernel: ohci0: <OHCI (generic) USB controller> mem 0xfd50100
Jan 11 19:47:53 alf kernel: ohci0: [GIANT-LOCKED]
Jan 11 19:47:53 alf kernel: ohci0: [ITHREAD]
Jan 11 19:47:53 alf kernel: usb7: OHCI version 1.0, legacy support
Jan 11 19:47:53 alf kernel: usb7: <OHCI (generic) USB controller> on ohci0
Jan 11 19:47:53 alf kernel: usb7: USB revision 1.0
Jan 11 19:47:53 alf kernel: uhub7: <(0x11c1) OHCI root hub, class 9/0, rev 1.00/
Jan 11 19:47:53 alf kernel: uhub7: 2 ports with 2 removable, self powered
Jan 11 19:47:58 alf kernel: 1
Jan 11 19:47:58 alf root: Unknown USB device: vendor 0x0f3d product 0x0112 bus u
Jan 11 19:47:58 alf kernel: sho?
Jan 11 19:47:58 alf kernel: none:  cm 0, acm 0
Jan 11 19:47:59 alf kernel: 3
Jan 11 19:47:59 alf kernel: 1
Jan 11 19:47:59 alf kernel: ugen0: <AirPrime, Incorporated AirPrime CDMA Wireles
Jan 11 19:49:27 alf su: freeman to root on /dev/ttyp1

paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение paradox » 2009-01-11 20:54:18

нужны дополнительные измения в этом файле

полный патч в той же ветке форума

и незабудь свои дев вендор айди добавить если будет с самого нуля патчить

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 20:55:40

при двойке

1
Unknown USB device: vendor 0x0f3d product 0x0112 bus u
3
3
1
ugen0: <AirPrime, Incorporated AirPrime CDMA Wireles

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 20:57:15

paradox писал(а):нужны дополнительные измения в этом файле

полный патч в той же ветке форума

и незабудь свои дев вендор айди добавить если будет с самого нуля патчить
:( umodem.diff - этот?


dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 21:14:18

Код: Выделить всё

alf# make
Warning: Object directory not changed from original /usr/src/sys/modules/umodem
cc -O2 -fno-strict-aliasing -pipe  -D_KERNEL -DKLD_MODULE -std=c99 -nostdinc   -I. -I@ -I@/contrib/altq -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common  -mno-align-long-strings -mpreferred-stack-boundary=2  -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -ffreestanding -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -c /usr/src/sys/modules/umodem/../../dev/usb/umodem.c
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:184: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'usb_cdc_union_descriptor_t'
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c: In function 'umodem_attach':
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:311: warning: implicit declaration of function 'umodem_get_union'
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:311: warning: nested extern declaration of 'umodem_get_union'
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:311: warning: assignment makes pointer from integer without a cast
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:313: error: 'devname' undeclared (first use in this function)
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:313: error: (Each undeclared identifier is reported only once
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:313: error: for each function it appears in.)
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c: At top level:
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:566: warning: no previous prototype for 'umodem_get_union'
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:566: error: conflicting types for 'umodem_get_union'
/usr/src/sys/modules/umodem/../../dev/usb/umodem.c:311: error: previous implicit declaration of 'umodem_get_union' was here
*** Error code 1

Stop in /usr/src/sys/modules/umodem.
alf#

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 21:19:57

я на 7-ку ложу патч для 6 версии


dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 21:43:01

сначала,

Код: Выделить всё

src/sys/dev/usb/umodem.c
--- umodem.c.orig        Tue Feb  8 15:44:09 2005
+++ umodem.c     Mon Jan  9 06:50:07 2006
@@ -69,6 +69,7 @@
 /*
  * Comm Class spec:  http://www.usb.org/developers/devclass_docs/usbccs10.pdf
  *                   http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
+ *                   http://www.usb.org/developers/devclass_docs/cdc_wmc10.zip
  */
 /*
@@ -176,6 +177,8 @@
                                           usb_cdc_line_state_t *state);
 Static void     umodem_get_caps(usbd_device_handle, int *, int *);
+Static usb_cdc_union_descriptor_t  *
+    umodem_get_union(usbd_device_handle dev, int iface_no);
 Static void     umodem_get_status(void *, int portno, u_char *lsr, u_char *msr);
 Static void     umodem_set(void *, int, int, int);
@@ -274,6 +277,7 @@
         usb_interface_descriptor_t *id;
         usb_endpoint_descriptor_t *ed;
         usb_cdc_cm_descriptor_t *cmd;
+        usb_cdc_union_descriptor_t *cud;
         char *devinfo = NULL;
         const char *devname;
         usbd_status err;
@@ -306,10 +310,13 @@
         /* Get the data interface no. */
         cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
         if (cmd == NULL) {
-                printf("%s: no CM descriptor\n", devname);
+                cud = umodem_get_union(dev, sc->sc_ctl_iface_no);
+                if (cud == NULL) {
+                    printf("%s: no CM and Union descriptors\n", devname);
                 goto bad;
-        }
-        sc->sc_data_iface_no = data_ifcno = cmd->bDataInterface;
+                }else data_ifcno = cud->bSlaveInterface[0];
+        }else data_ifcno = cmd->bDataInterface;
+        sc->sc_data_iface_no = data_ifcno;
         printf("%s: data interface %d, has %sCM over data, has %sbreak\n",
                devname, data_ifcno,
@@ -555,19 +562,36 @@
         *cm = *acm = 0;
-        cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
-        if (cmd == NULL) {
-                DPRINTF(("umodem_get_desc: no CM desc\n"));
-                return;
-        }
-        *cm = cmd->bmCapabilities;
-
         cad = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_ACM);
         if (cad == NULL) {
                 DPRINTF(("umodem_get_desc: no ACM desc\n"));
                 return;
         }
         *acm = cad->bmCapabilities;
+
+        cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
+        if (cmd == NULL) {
+                DPRINTF(("umodem_get_desc: no CM desc\n"));
+                *cm = USB_CDC_CM_DOES_CM | USB_CDC_CM_OVER_DATA;
+        }else *cm = cmd->bmCapabilities;
+}
+
+usb_cdc_union_descriptor_t  *
+umodem_get_union(usbd_device_handle dev, int iface_no)
+{
+    usb_cdc_union_descriptor_t *desc;
+    usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
+    uByte *p = (uByte *)cd;
+    uByte *end = p + UGETW(cd->wTotalLength);
+    while (p < end) {
+        desc = (usb_cdc_union_descriptor_t *)p;
+        if (desc->bDescriptorType ==  UDESC_CS_INTERFACE &&
+                desc->bDescriptorSubtype == UDESCSUB_CDC_UNION &&
+                desc->bMasterInterface == iface_no)
+            return (desc);
+        p += desc->bLength;
+    }
+    return (0);
 }
 void
не прошло, отписал постом выше


сейчас

Код: Выделить всё

--- umodem.c    2007-07-30 00:16:43.000000000 +0600
+++ /backup/jail/ftp/var/ftp/pub/FreeBSD/patches/SE_K550i/umodem.c      2008-11-25 02:20:41.000000000 +0500
@@ -127,6 +127,7 @@
        { USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_AHK3001V, 0 },
        { USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720, 0 },
        { USB_VENDOR_CURITEL, USB_PRODUCT_CURITEL_PC5740, 0 },
+       { 0x0fce, 0xd069, 1 },
        { 0, 0, 0 },
};

@@ -180,6 +181,8 @@

static void    umodem_get_caps(usbd_device_handle, int *, int *);

+static usb_cdc_union_descriptor_t  *
+umodem_get_union(usbd_device_handle dev, int iface_no);
static void    umodem_get_status(void *, int portno, u_char *lsr, u_char *msr);
static void    umodem_set(void *, int, int, int);
static void    umodem_dtr(struct umodem_softc *, int);

@@ -280,6 +291,7 @@
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
        usb_cdc_cm_descriptor_t *cmd;
+       usb_cdc_union_descriptor_t *cud;
        int data_ifcno;
        int i;
        struct ucom_softc *ucom;
@@ -302,11 +314,13 @@
        /* Get the data interface no. */
        cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
        if (cmd == NULL) {
-               device_printf(sc->sc_dev, "no CM descriptor\n");
+               cud = umodem_get_union(dev, sc->sc_ctl_iface_no);
+               if (cud ==NULL) {
+                       device_printf(sc->sc_dev, "no CM and Union descriptors\n");
                goto bad;
-       }
-       sc->sc_data_iface_no = data_ifcno = cmd->bDataInterface;
-
+                       }else data_ifcno = cud->bSlaveInterface[0];
+       }else data_ifcno = cmd->bDataInterface;
+       sc->sc_data_iface_no = data_ifcno;
        device_printf(sc->sc_dev,
            "data interface %d, has %sCM over data, has %sbreak\n",
            data_ifcno, sc->sc_cm_cap & USB_CDC_CM_OVER_DATA ? "" : "no ",
@@ -538,19 +552,36 @@

        *cm = *acm = 0;

-       cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
-       if (cmd == NULL) {
-               DPRINTF(("umodem_get_desc: no CM desc\n"));
-               return;
-       }
-       *cm = cmd->bmCapabilities;
-
        cad = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_ACM);
        if (cad == NULL) {
                DPRINTF(("umodem_get_desc: no ACM desc\n"));
                return;
        }
        *acm = cad->bmCapabilities;
+
+       cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
+       if (cmd == NULL) {
+               DPRINTF(("umodem_get_desc: no CM desc\n"));
+               *cm = USB_CDC_CM_DOES_CM | USB_CDC_CM_OVER_DATA;
+       }else *cm = cmd->bmCapabilities;
+}
+
+usb_cdc_union_descriptor_t  *
+umodem_get_union(usbd_device_handle dev, int iface_no)
+{
+    usb_cdc_union_descriptor_t *desc;
+    usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
+    uByte *p = (uByte *)cd;
+    uByte *end = p + UGETW(cd->wTotalLength);
+    while (p < end) {
+        desc = (usb_cdc_union_descriptor_t *)p;
+        if (desc->bDescriptorType ==  UDESC_CS_INTERFACE &&
+                desc->bDescriptorSubtype == UDESCSUB_CDC_UNION &&
+                desc->bMasterInterface == iface_no)
+            return (desc);
+        p += desc->bLength;
+    }
+    return (0);
}

umodem.c собрался, подгрузил его, втыкаю модем, ничего( ugen0: и все


Вложил свой юмодем.с
Вложения
UMODEM.C
(23.72 КБ) 20 скачиваний

paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение paradox » 2009-01-11 22:02:46

paradox.lissyara.su/umodem.c
давай лог


paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение paradox » 2009-01-11 22:08:48

а что непонятного я сказал?

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 22:10:03

http://paradox.lissyara.su/umodem.c
Невозможно найти страницу

ищу на фтп....

paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение paradox » 2009-01-11 22:15:08

какой файл дали такой и правил

UMODEM.C

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 22:23:53

:smile: да я понял, я найти файл не могу, по указанной ссылке не находит страницу...

гугл хром HTTP 404 – Файл не найден

paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение paradox » 2009-01-11 22:29:12

paradox писал(а):какой файл дали такой и правил

UMODEM.C

линка верная
в капсе наберите имя файла

dr_alf
рядовой
Сообщения: 43
Зарегистрирован: 2009-01-09 12:42:41

Re: AirPrime CDMA PC5220, FreeBSD 7.1

Непрочитанное сообщение dr_alf » 2009-01-11 22:31:21

:smile: есть, пробую поставить...