svn commit: r223508 - in projects/largeSMP: bin/rcp bin/sh contrib/binutils/gas/config contrib/top etc lib/libstand lib/libusb libexec/ftpd libexec/tftpd release/doc/en_US.ISO8859-1/readme release/...

Attilio Rao attilio at FreeBSD.org
Fri Jun 24 16:35:41 UTC 2011


Author: attilio
Date: Fri Jun 24 16:35:40 2011
New Revision: 223508
URL: http://svn.freebsd.org/changeset/base/223508

Log:
  MFC

Added:
  projects/largeSMP/lib/libusb/libusb01.c
     - copied unchanged from r223507, head/lib/libusb/libusb01.c
  projects/largeSMP/sys/dev/usb/template/usb_template_audio.c
     - copied unchanged from r223507, head/sys/dev/usb/template/usb_template_audio.c
  projects/largeSMP/sys/dev/usb/template/usb_template_kbd.c
     - copied unchanged from r223507, head/sys/dev/usb/template/usb_template_kbd.c
  projects/largeSMP/sys/dev/usb/template/usb_template_modem.c
     - copied unchanged from r223507, head/sys/dev/usb/template/usb_template_modem.c
  projects/largeSMP/sys/dev/usb/template/usb_template_mouse.c
     - copied unchanged from r223507, head/sys/dev/usb/template/usb_template_mouse.c
  projects/largeSMP/sys/x86/include/pci_cfgreg.h
     - copied unchanged from r223507, head/sys/x86/include/pci_cfgreg.h
  projects/largeSMP/sys/x86/pci/pci_bus.c
     - copied unchanged from r223507, head/sys/x86/pci/pci_bus.c
  projects/largeSMP/tools/tools/bus_autoconf/
     - copied from r223507, head/tools/tools/bus_autoconf/
Deleted:
  projects/largeSMP/lib/libusb/libusb20_compat01.c
  projects/largeSMP/sys/amd64/pci/pci_bus.c
  projects/largeSMP/sys/i386/pci/pci_bus.c
Modified:
  projects/largeSMP/bin/rcp/rcp.c
  projects/largeSMP/bin/sh/mkinit.c
  projects/largeSMP/contrib/binutils/gas/config/tc-arm.c
  projects/largeSMP/etc/network.subr
  projects/largeSMP/etc/regdomain.xml
  projects/largeSMP/lib/libstand/tftp.c
  projects/largeSMP/lib/libusb/Makefile
  projects/largeSMP/lib/libusb/libusb20.3
  projects/largeSMP/lib/libusb/libusb20.c
  projects/largeSMP/lib/libusb/libusb20.h
  projects/largeSMP/lib/libusb/libusb20_int.h
  projects/largeSMP/lib/libusb/libusb20_ugen20.c
  projects/largeSMP/libexec/ftpd/ftpd.c
  projects/largeSMP/libexec/tftpd/tftp-file.c
  projects/largeSMP/libexec/tftpd/tftpd.8
  projects/largeSMP/release/doc/en_US.ISO8859-1/readme/article.sgml
  projects/largeSMP/release/doc/share/sgml/release.ent
  projects/largeSMP/sbin/ipfw/nat.c
  projects/largeSMP/sbin/savecore/savecore.c
  projects/largeSMP/share/man/man4/ng_ether.4
  projects/largeSMP/sys/amd64/include/pci_cfgreg.h
  projects/largeSMP/sys/boot/i386/zfsboot/zfsldr.S
  projects/largeSMP/sys/cam/ata/ata_xpt.c
  projects/largeSMP/sys/cam/scsi/scsi_xpt.c
  projects/largeSMP/sys/conf/files
  projects/largeSMP/sys/conf/files.amd64
  projects/largeSMP/sys/conf/files.i386
  projects/largeSMP/sys/conf/files.pc98
  projects/largeSMP/sys/dev/acpica/acpi.c
  projects/largeSMP/sys/dev/acpica/acpi_cpu.c
  projects/largeSMP/sys/dev/ath/ah_osdep.c
  projects/largeSMP/sys/dev/ath/ath_hal/ah.h
  projects/largeSMP/sys/dev/ath/ath_hal/ah_internal.h
  projects/largeSMP/sys/dev/ath/ath_hal/ah_regdomain.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5210/ar5210_beacon.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5211/ar5211_beacon.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5211/ar5211_xmit.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5212/ar5112.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5312/ar5312_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar2133.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar9001/ar9160_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c
  projects/largeSMP/sys/dev/ath/ath_hal/ar9002/ar9287_attach.c
  projects/largeSMP/sys/dev/ath/if_ath.c
  projects/largeSMP/sys/dev/ath/if_ath_sysctl.c
  projects/largeSMP/sys/dev/ath/if_ath_sysctl.h
  projects/largeSMP/sys/dev/e1000/if_igb.c
  projects/largeSMP/sys/dev/sound/usb/uaudio.c
  projects/largeSMP/sys/dev/usb/input/atp.c
  projects/largeSMP/sys/dev/usb/input/uhid.c
  projects/largeSMP/sys/dev/usb/net/if_aue.c
  projects/largeSMP/sys/dev/usb/net/if_axe.c
  projects/largeSMP/sys/dev/usb/net/if_cdce.c
  projects/largeSMP/sys/dev/usb/net/if_cue.c
  projects/largeSMP/sys/dev/usb/net/if_ipheth.c
  projects/largeSMP/sys/dev/usb/net/if_kue.c
  projects/largeSMP/sys/dev/usb/net/if_mos.c
  projects/largeSMP/sys/dev/usb/net/if_rue.c
  projects/largeSMP/sys/dev/usb/net/if_udav.c
  projects/largeSMP/sys/dev/usb/net/uhso.c
  projects/largeSMP/sys/dev/usb/serial/u3g.c
  projects/largeSMP/sys/dev/usb/serial/uark.c
  projects/largeSMP/sys/dev/usb/serial/ubsa.c
  projects/largeSMP/sys/dev/usb/serial/uchcom.c
  projects/largeSMP/sys/dev/usb/serial/ucycom.c
  projects/largeSMP/sys/dev/usb/serial/uftdi.c
  projects/largeSMP/sys/dev/usb/serial/ugensa.c
  projects/largeSMP/sys/dev/usb/serial/uipaq.c
  projects/largeSMP/sys/dev/usb/serial/ulpt.c
  projects/largeSMP/sys/dev/usb/serial/umcs.c
  projects/largeSMP/sys/dev/usb/serial/umct.c
  projects/largeSMP/sys/dev/usb/serial/umodem.c
  projects/largeSMP/sys/dev/usb/serial/umoscom.c
  projects/largeSMP/sys/dev/usb/serial/uplcom.c
  projects/largeSMP/sys/dev/usb/serial/uslcom.c
  projects/largeSMP/sys/dev/usb/serial/uvisor.c
  projects/largeSMP/sys/dev/usb/serial/uvscom.c
  projects/largeSMP/sys/dev/usb/storage/umass.c
  projects/largeSMP/sys/dev/usb/template/usb_template.c
  projects/largeSMP/sys/dev/usb/template/usb_template.h
  projects/largeSMP/sys/dev/usb/template/usb_template_cdce.c
  projects/largeSMP/sys/dev/usb/template/usb_template_msc.c
  projects/largeSMP/sys/dev/usb/template/usb_template_mtp.c
  projects/largeSMP/sys/dev/usb/usb_hub.c
  projects/largeSMP/sys/dev/usb/usb_ioctl.h
  projects/largeSMP/sys/dev/usb/usb_lookup.c
  projects/largeSMP/sys/dev/usb/usbdi.h
  projects/largeSMP/sys/dev/usb/wlan/if_rum.c
  projects/largeSMP/sys/dev/usb/wlan/if_run.c
  projects/largeSMP/sys/dev/usb/wlan/if_uath.c
  projects/largeSMP/sys/dev/usb/wlan/if_upgt.c
  projects/largeSMP/sys/dev/usb/wlan/if_ural.c
  projects/largeSMP/sys/dev/usb/wlan/if_urtw.c
  projects/largeSMP/sys/dev/usb/wlan/if_zyd.c
  projects/largeSMP/sys/fs/nfs/nfs_commonkrpc.c
  projects/largeSMP/sys/i386/include/param.h
  projects/largeSMP/sys/i386/include/pci_cfgreg.h
  projects/largeSMP/sys/ia64/ia64/machdep.c
  projects/largeSMP/sys/kern/vfs_subr.c
  projects/largeSMP/sys/modules/cxgbe/if_cxgbe/Makefile
  projects/largeSMP/sys/modules/nfscl/Makefile
  projects/largeSMP/sys/modules/nfscommon/Makefile
  projects/largeSMP/sys/modules/usb/template/Makefile
  projects/largeSMP/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
  projects/largeSMP/sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c
  projects/largeSMP/sys/netgraph/ng_ether.c
  projects/largeSMP/sys/netinet/libalias/alias_db.c
  projects/largeSMP/sys/netinet/libalias/alias_ftp.c
  projects/largeSMP/sys/netinet/libalias/alias_local.h
  projects/largeSMP/sys/netinet/libalias/libalias.3
  projects/largeSMP/sys/powerpc/aim/copyinout.c
  projects/largeSMP/sys/powerpc/aim/locore32.S
  projects/largeSMP/sys/powerpc/aim/locore64.S
  projects/largeSMP/sys/powerpc/aim/machdep.c
  projects/largeSMP/sys/powerpc/aim/mmu_oea64.c
  projects/largeSMP/sys/powerpc/aim/mp_cpudep.c
  projects/largeSMP/sys/powerpc/aim/swtch32.S
  projects/largeSMP/sys/powerpc/aim/swtch64.S
  projects/largeSMP/sys/powerpc/aim/trap.c
  projects/largeSMP/sys/powerpc/aim/trap_subr32.S
  projects/largeSMP/sys/powerpc/aim/trap_subr64.S
  projects/largeSMP/sys/powerpc/booke/copyinout.c
  projects/largeSMP/sys/powerpc/booke/interrupt.c
  projects/largeSMP/sys/powerpc/booke/trap.c
  projects/largeSMP/sys/powerpc/include/pcpu.h
  projects/largeSMP/sys/powerpc/ofw/ofwcall32.S
  projects/largeSMP/sys/powerpc/powerpc/db_trace.c
  projects/largeSMP/sys/powerpc/powerpc/mp_machdep.c
  projects/largeSMP/sys/powerpc/ps3/ps3-hvcall.h
  projects/largeSMP/sys/powerpc/ps3/ps3-hvcall.master
  projects/largeSMP/sys/powerpc/ps3/ps3bus.c
  projects/largeSMP/sys/powerpc/ps3/ps3disk.c
  projects/largeSMP/sys/powerpc/ps3/ps3pic.c
  projects/largeSMP/sys/vm/vm_fault.c
  projects/largeSMP/sys/vm/vm_page.c
  projects/largeSMP/usr.bin/ktrace/ktrace.c
  projects/largeSMP/usr.bin/ncplogin/ncplogin.c
  projects/largeSMP/usr.bin/systat/netstat.c
  projects/largeSMP/usr.bin/tftp/main.c
  projects/largeSMP/usr.bin/tftp/tftp.1
  projects/largeSMP/usr.bin/vmstat/vmstat.c
  projects/largeSMP/usr.sbin/ancontrol/ancontrol.c
  projects/largeSMP/usr.sbin/ifmcstat/ifmcstat.c
  projects/largeSMP/usr.sbin/nfsd/nfsd.c
  projects/largeSMP/usr.sbin/pmcstat/pmcpl_calltree.c
  projects/largeSMP/usr.sbin/ppp/nat_cmd.c
  projects/largeSMP/usr.sbin/rpc.yppasswdd/yppasswdd_main.c
  projects/largeSMP/usr.sbin/rpc.ypupdated/update.c
  projects/largeSMP/usr.sbin/rpc.ypupdated/ypupdated_main.c
  projects/largeSMP/usr.sbin/rpc.ypupdated/ypupdated_server.c
  projects/largeSMP/usr.sbin/sysinstall/modules.c
  projects/largeSMP/usr.sbin/wpa/ndis_events/ndis_events.c
  projects/largeSMP/usr.sbin/wpa/wpa_supplicant/Packet32.c
Directory Properties:
  projects/largeSMP/   (props changed)
  projects/largeSMP/cddl/contrib/opensolaris/   (props changed)
  projects/largeSMP/contrib/bind9/   (props changed)
  projects/largeSMP/contrib/binutils/   (props changed)
  projects/largeSMP/contrib/bzip2/   (props changed)
  projects/largeSMP/contrib/compiler-rt/   (props changed)
  projects/largeSMP/contrib/dialog/   (props changed)
  projects/largeSMP/contrib/ee/   (props changed)
  projects/largeSMP/contrib/expat/   (props changed)
  projects/largeSMP/contrib/file/   (props changed)
  projects/largeSMP/contrib/gcc/   (props changed)
  projects/largeSMP/contrib/gdb/   (props changed)
  projects/largeSMP/contrib/gdtoa/   (props changed)
  projects/largeSMP/contrib/gnu-sort/   (props changed)
  projects/largeSMP/contrib/groff/   (props changed)
  projects/largeSMP/contrib/less/   (props changed)
  projects/largeSMP/contrib/libpcap/   (props changed)
  projects/largeSMP/contrib/libstdc++/   (props changed)
  projects/largeSMP/contrib/llvm/   (props changed)
  projects/largeSMP/contrib/llvm/tools/clang/   (props changed)
  projects/largeSMP/contrib/ncurses/   (props changed)
  projects/largeSMP/contrib/netcat/   (props changed)
  projects/largeSMP/contrib/ntp/   (props changed)
  projects/largeSMP/contrib/one-true-awk/   (props changed)
  projects/largeSMP/contrib/openbsm/   (props changed)
  projects/largeSMP/contrib/openpam/   (props changed)
  projects/largeSMP/contrib/pf/   (props changed)
  projects/largeSMP/contrib/sendmail/   (props changed)
  projects/largeSMP/contrib/tcpdump/   (props changed)
  projects/largeSMP/contrib/tcsh/   (props changed)
  projects/largeSMP/contrib/tnftp/   (props changed)
  projects/largeSMP/contrib/top/   (props changed)
  projects/largeSMP/contrib/top/install-sh   (props changed)
  projects/largeSMP/contrib/tzcode/stdtime/   (props changed)
  projects/largeSMP/contrib/tzcode/zic/   (props changed)
  projects/largeSMP/contrib/tzdata/   (props changed)
  projects/largeSMP/contrib/wpa/   (props changed)
  projects/largeSMP/contrib/xz/   (props changed)
  projects/largeSMP/crypto/openssh/   (props changed)
  projects/largeSMP/crypto/openssl/   (props changed)
  projects/largeSMP/gnu/lib/   (props changed)
  projects/largeSMP/gnu/usr.bin/binutils/   (props changed)
  projects/largeSMP/gnu/usr.bin/cc/cc_tools/   (props changed)
  projects/largeSMP/gnu/usr.bin/gdb/   (props changed)
  projects/largeSMP/lib/libc/   (props changed)
  projects/largeSMP/lib/libc/stdtime/   (props changed)
  projects/largeSMP/lib/libutil/   (props changed)
  projects/largeSMP/lib/libz/   (props changed)
  projects/largeSMP/sbin/   (props changed)
  projects/largeSMP/sbin/ipfw/   (props changed)
  projects/largeSMP/share/mk/bsd.arch.inc.mk   (props changed)
  projects/largeSMP/share/zoneinfo/   (props changed)
  projects/largeSMP/sys/   (props changed)
  projects/largeSMP/sys/amd64/include/xen/   (props changed)
  projects/largeSMP/sys/boot/   (props changed)
  projects/largeSMP/sys/boot/i386/efi/   (props changed)
  projects/largeSMP/sys/boot/ia64/efi/   (props changed)
  projects/largeSMP/sys/boot/ia64/ski/   (props changed)
  projects/largeSMP/sys/boot/powerpc/boot1.chrp/   (props changed)
  projects/largeSMP/sys/boot/powerpc/ofw/   (props changed)
  projects/largeSMP/sys/cddl/contrib/opensolaris/   (props changed)
  projects/largeSMP/sys/conf/   (props changed)
  projects/largeSMP/sys/contrib/dev/acpica/   (props changed)
  projects/largeSMP/sys/contrib/octeon-sdk/   (props changed)
  projects/largeSMP/sys/contrib/pf/   (props changed)
  projects/largeSMP/sys/contrib/x86emu/   (props changed)
  projects/largeSMP/usr.bin/calendar/   (props changed)
  projects/largeSMP/usr.bin/csup/   (props changed)
  projects/largeSMP/usr.bin/procstat/   (props changed)
  projects/largeSMP/usr.sbin/ndiscvt/   (props changed)
  projects/largeSMP/usr.sbin/zic/   (props changed)

Modified: projects/largeSMP/bin/rcp/rcp.c
==============================================================================
--- projects/largeSMP/bin/rcp/rcp.c	Fri Jun 24 16:06:50 2011	(r223507)
+++ projects/largeSMP/bin/rcp/rcp.c	Fri Jun 24 16:35:40 2011	(r223508)
@@ -71,7 +71,6 @@ __FBSDID("$FreeBSD$");
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "extern.h"

Modified: projects/largeSMP/bin/sh/mkinit.c
==============================================================================
--- projects/largeSMP/bin/sh/mkinit.c	Fri Jun 24 16:06:50 2011	(r223507)
+++ projects/largeSMP/bin/sh/mkinit.c	Fri Jun 24 16:35:40 2011	(r223508)
@@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
  */
 
 
-#include <sys/cdefs.h>
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>

Modified: projects/largeSMP/contrib/binutils/gas/config/tc-arm.c
==============================================================================
--- projects/largeSMP/contrib/binutils/gas/config/tc-arm.c	Fri Jun 24 16:06:50 2011	(r223507)
+++ projects/largeSMP/contrib/binutils/gas/config/tc-arm.c	Fri Jun 24 16:35:40 2011	(r223508)
@@ -9974,6 +9974,13 @@ do_t_rbit (void)
 }
 
 static void
+do_t_rd_rm (void)
+{
+  inst.instruction |= inst.operands[0].reg << 8;
+  inst.instruction |= inst.operands[1].reg;
+}
+
+static void
 do_t_rev (void)
 {
   if (inst.operands[0].reg <= 7 && inst.operands[1].reg <= 7
@@ -14901,6 +14908,9 @@ static const struct asm_opcode insns[] =
  TCE(rsb,	0600000, ebc00000, 3, (RR, oRR, SH), arit, t_rsb),
  TC3(rsbs,	0700000, ebd00000, 3, (RR, oRR, SH), arit, t_rsb),
 
+ TCE(rrx,      1a00060, ea4f0030, 2, (RR, RR),      rd_rm, t_rd_rm),
+ TCE(rrxs,     1b00060, ea5f0030, 2, (RR, RR),      rd_rm, t_rd_rm),
+
 #undef THUMB_VARIANT
 #define THUMB_VARIANT &arm_ext_v6
  TCE(cpy,       1a00000, 4600,     2, (RR, RR),      rd_rm, t_cpy),

Modified: projects/largeSMP/etc/network.subr
==============================================================================
--- projects/largeSMP/etc/network.subr	Fri Jun 24 16:06:50 2011	(r223507)
+++ projects/largeSMP/etc/network.subr	Fri Jun 24 16:35:40 2011	(r223508)
@@ -94,7 +94,7 @@ ifconfig_up()
 	# ifconfig_IF
 	ifconfig_args=`ifconfig_getargs $1`
 	if [ -n "${ifconfig_args}" ]; then
-		ifconfig $1 ${ifconfig_args}
+		eval ifconfig $1 ${ifconfig_args}
 		_cfg=0
 	fi
 

Modified: projects/largeSMP/etc/regdomain.xml
==============================================================================
--- projects/largeSMP/etc/regdomain.xml	Fri Jun 24 16:06:50 2011	(r223507)
+++ projects/largeSMP/etc/regdomain.xml	Fri Jun 24 16:35:40 2011	(r223508)
@@ -83,7 +83,7 @@
       <flags>IEEE80211_CHAN_HT20</flags>
     </band>
     <band>
-      <freqband ref="F1_2412_2462"/>
+      <freqband ref="H4_2412_2462"/>
       <maxpower>30</maxpower>
       <flags>IEEE80211_CHAN_G</flags>
       <flags>IEEE80211_CHAN_HT40</flags>
@@ -96,7 +96,7 @@
       <flags>IEEE80211_CHAN_HT20</flags>
     </band>
     <band>
-      <freqband ref="F1_5180_5240"/>
+      <freqband ref="H4_5180_5240"/>
       <maxpower>17</maxpower>
       <flags>IEEE80211_CHAN_HT40</flags>
     </band>
@@ -106,7 +106,7 @@
       <flags>IEEE80211_CHAN_HT20</flags>
     </band>
     <band>
-      <freqband ref="F1_5745_5805"/>
+      <freqband ref="H4_5745_5805"/>
       <maxpower>23</maxpower>
       <flags>IEEE80211_CHAN_HT40</flags>
     </band>
@@ -138,6 +138,12 @@
       <maxpower>17</maxpower>
     </band>
     <band>
+      <freqband ref="F1_5260_5320"/>
+      <maxpower>20</maxpower>
+      <flags>IEEE80211_CHAN_PASSIVE</flags>
+      <flags>IEEE80211_CHAN_DFS</flags>
+    </band>
+    <band>
       <freqband ref="F1_5745_5805"/>
       <maxpower>23</maxpower>
       <flags>IEEE80211_CHAN_PASSIVE</flags>
@@ -176,6 +182,20 @@
       <flags>IEEE80211_CHAN_HT40</flags>
     </band>
     <band>
+      <freqband ref="F1_5260_5320"/>
+      <maxpower>20</maxpower>
+      <flags>IEEE80211_CHAN_HT20</flags>
+      <flags>IEEE80211_CHAN_PASSIVE</flags>
+      <flags>IEEE80211_CHAN_DFS</flags>
+    </band>
+    <band>
+      <freqband ref="H4_5260_5320"/>
+      <maxpower>20</maxpower>
+      <flags>IEEE80211_CHAN_HT40</flags>
+      <flags>IEEE80211_CHAN_PASSIVE</flags>
+      <flags>IEEE80211_CHAN_DFS</flags>
+    </band>
+    <band>
       <freqband ref="F1_5745_5805"/>
       <maxpower>23</maxpower>
       <flags>IEEE80211_CHAN_HT20</flags>
@@ -231,7 +251,7 @@
       <flags>IEEE80211_CHAN_HT20</flags>
     </band>
     <band>
-      <freqband ref="F1_2412_2462"/>
+      <freqband ref="H4_2412_2462"/>
       <maxpower>30</maxpower>
       <flags>IEEE80211_CHAN_G</flags>
       <flags>IEEE80211_CHAN_HT40</flags>

Modified: projects/largeSMP/lib/libstand/tftp.c
==============================================================================
--- projects/largeSMP/lib/libstand/tftp.c	Fri Jun 24 16:06:50 2011	(r223507)
+++ projects/largeSMP/lib/libstand/tftp.c	Fri Jun 24 16:35:40 2011	(r223508)
@@ -64,13 +64,13 @@ struct tftp_handle;
 
 static int	tftp_open(const char *path, struct open_file *f);
 static int	tftp_close(struct open_file *f);
-static void	tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len);
+static int	tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len);
 static int	tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid);
 static int	tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid);
 static off_t	tftp_seek(struct open_file *f, off_t offset, int where);
 static int	tftp_set_blksize(struct tftp_handle *h, const char *str);
 static int	tftp_stat(struct open_file *f, struct stat *sb);
-static ssize_t sendrecv_tftp(struct tftp_handle *h, 
+static ssize_t sendrecv_tftp(struct tftp_handle *h,
     ssize_t (*sproc)(struct iodesc *, void *, size_t),
     void *sbuf, size_t ssize,
     ssize_t (*rproc)(struct tftp_handle *h, void *, ssize_t, time_t, unsigned short *),
@@ -93,7 +93,7 @@ static int      tftpport = 2000;
 static int	is_open = 0;
 
 /*
- * The legacy TFTP_BLKSIZE value was 512.
+ * The legacy TFTP_BLKSIZE value was SEGSIZE(512).
  * TFTP_REQUESTED_BLKSIZE of 1428 is (Ethernet MTU, less the TFTP, UDP and
  * IP header lengths).
  */
@@ -102,7 +102,7 @@ static int	is_open = 0;
 /*
  * Choose a blksize big enough so we can test with Ethernet
  * Jumbo frames in the future.
- */ 
+ */
 #define TFTP_MAX_BLKSIZE 9008
 
 struct tftp_handle {
@@ -113,7 +113,7 @@ struct tftp_handle {
 	int             off;
 	char           *path;	/* saved for re-requests */
 	unsigned int	tftp_blksize;
-	unsigned long	tftp_tsize; 
+	unsigned long	tftp_tsize;
 	struct {
 		u_char header[HEADER_SIZE];
 		struct tftphdr t;
@@ -121,7 +121,8 @@ struct tftp_handle {
 	} __packed __aligned(4) lastdata;
 };
 
-static const int tftperrors[8] = {
+#define	TFTP_MAX_ERRCODE EOPTNEG
+static const int tftperrors[TFTP_MAX_ERRCODE + 1] = {
 	0,			/* ??? */
 	ENOENT,
 	EPERM,
@@ -129,10 +130,57 @@ static const int tftperrors[8] = {
 	EINVAL,			/* ??? */
 	EINVAL,			/* ??? */
 	EEXIST,
-	EINVAL			/* ??? */
+	EINVAL,			/* ??? */
+	EINVAL,			/* Option negotiation failed. */
 };
 
-static ssize_t 
+static int  tftp_getnextblock(struct tftp_handle *h);
+
+/* send error message back. */
+static void
+tftp_senderr(struct tftp_handle *h, u_short errcode, const char *msg)
+{
+	struct {
+		u_char header[HEADER_SIZE];
+		struct tftphdr  t;
+		u_char space[63]; /* +1 from t */
+	} __packed __aligned(4) wbuf;
+	char           *wtail;
+	int             len;
+
+	len = strlen(msg);
+	if (len > sizeof(wbuf.space))
+		len = sizeof(wbuf.space);
+
+	wbuf.t.th_opcode = htons((u_short) ERROR);
+	wbuf.t.th_code   = htons(errcode);
+
+	wtail = wbuf.t.th_msg;
+	bcopy(msg, wtail, len);
+	wtail[len] = '\0';
+	wtail += len + 1;
+
+	sendudp(h->iodesc, &wbuf.t, wtail - (char *) &wbuf.t);
+}
+
+static void
+tftp_sendack(struct tftp_handle *h)
+{
+	struct {
+		u_char header[HEADER_SIZE];
+		struct tftphdr  t;
+	} __packed __aligned(4) wbuf;
+	char           *wtail;
+
+	wbuf.t.th_opcode = htons((u_short) ACK);
+	wtail = (char *) &wbuf.t.th_block;
+	wbuf.t.th_block = htons((u_short) h->currblock);
+	wtail += 2;
+
+	sendudp(h->iodesc, &wbuf.t, wtail - (char *) &wbuf.t);
+}
+
+static ssize_t
 recvtftp(struct tftp_handle *h, void *pkt, ssize_t len, time_t tleft,
     unsigned short *rtype)
 {
@@ -170,7 +218,7 @@ recvtftp(struct tftp_handle *h, void *pk
 		return got;
 	}
 	case ERROR:
-		if ((unsigned) ntohs(t->th_code) >= 8) {
+		if ((unsigned) ntohs(t->th_code) > TFTP_MAX_ERRCODE) {
 			printf("illegal tftp error %d\n", ntohs(t->th_code));
 			errno = EIO;
 		} else {
@@ -182,14 +230,30 @@ recvtftp(struct tftp_handle *h, void *pk
 		return (-1);
 	case OACK: {
 		struct udphdr *uh;
-		int tftp_oack_len = len - sizeof(t->th_opcode); 
-		tftp_parse_oack(h, t->th_u.tu_stuff, tftp_oack_len);
+		int tftp_oack_len;
+
+		/* 
+		 * Unexpected OACK. TFTP transfer already in progress. 
+		 * Drop the pkt.
+		 */
+		if (d->xid != 1) {
+			return (-1);
+		}
+
 		/*
-		 * Remember which port this OACK came from,
-		 * because we need to send the ACK back to it.
+		 * Remember which port this OACK came from, because we need
+		 * to send the ACK or errors back to it.
 		 */
 		uh = (struct udphdr *) pkt - 1;
 		d->destport = uh->uh_sport;
+		
+		/* Parse options ACK-ed by the server. */
+		tftp_oack_len = len - sizeof(t->th_opcode);
+		if (tftp_parse_oack(h, t->th_u.tu_stuff, tftp_oack_len) != 0) {
+			tftp_senderr(h, EOPTNEG, "Malformed OACK");
+			errno = EIO;
+			return (-1);
+		}
 		return (0);
 	}
 	default:
@@ -201,7 +265,7 @@ recvtftp(struct tftp_handle *h, void *pk
 }
 
 /* send request, expect first block (or error) */
-static int 
+static int
 tftp_makereq(struct tftp_handle *h)
 {
 	struct {
@@ -250,26 +314,28 @@ tftp_makereq(struct tftp_handle *h)
 	h->iodesc->destport = htons(IPPORT_TFTP);
 	h->iodesc->xid = 1;	/* expected block */
 
+	h->currblock = 0;
+	h->islastblock = 0;
+	h->validsize = 0;
+
 	res = sendrecv_tftp(h, &sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
 		       &recvtftp, t, sizeof(*t) + h->tftp_blksize, &rtype);
 
-	if (rtype == OACK) {
-		wbuf.t.th_opcode = htons((u_short)ACK);
-		wtail = (char *) &wbuf.t.th_block;
-		wbuf.t.th_block = htons(0);
-		wtail += 2;
-		rtype = 0;
-		res = sendrecv_tftp(h, &sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
-			       &recvtftp, t, sizeof(*t) + h->tftp_blksize, &rtype);
-	}
+	if (rtype == OACK)
+		return (tftp_getnextblock(h));
+
+	/* Server ignored our blksize request, revert to TFTP default. */
+	h->tftp_blksize = SEGSIZE;
 
 	switch (rtype) {
 		case DATA: {
 			h->currblock = 1;
 			h->validsize = res;
 			h->islastblock = 0;
-			if (res < h->tftp_blksize)
+			if (res < h->tftp_blksize) {
 				h->islastblock = 1;	/* very short file */
+				tftp_sendack(h);
+			}
 			return (0);
 		}
 		case ERROR:
@@ -320,7 +386,7 @@ tftp_getnextblock(struct tftp_handle *h)
 	return (0);
 }
 
-static int 
+static int
 tftp_open(const char *path, struct open_file *f)
 {
 	struct tftp_handle *tftpfile;
@@ -365,7 +431,7 @@ tftp_open(const char *path, struct open_
 	return (0);
 }
 
-static int 
+static int
 tftp_read(struct open_file *f, void *addr, size_t size,
     size_t *resid /* out */)
 {
@@ -381,9 +447,11 @@ tftp_read(struct open_file *f, void *add
 
 		needblock = tftpfile->off / tftpfile->tftp_blksize + 1;
 
-		if (tftpfile->currblock > needblock)	/* seek backwards */
+		if (tftpfile->currblock > needblock) {	/* seek backwards */
+			tftp_senderr(tftpfile, 0, "No error: read aborted");
 			tftp_makereq(tftpfile);	/* no error check, it worked
 						 * for open */
+		}
 
 		while (tftpfile->currblock < needblock) {
 			int res;
@@ -452,7 +520,7 @@ tftp_close(struct open_file *f)
 	return (0);
 }
 
-static int 
+static int
 tftp_write(struct open_file *f __unused, void *start __unused, size_t size __unused,
     size_t *resid __unused /* out */)
 {
@@ -473,7 +541,7 @@ tftp_stat(struct open_file *f, struct st
 	return (0);
 }
 
-static off_t 
+static off_t
 tftp_seek(struct open_file *f, off_t offset, int where)
 {
 	struct tftp_handle *tftpfile;
@@ -494,7 +562,7 @@ tftp_seek(struct open_file *f, off_t off
 }
 
 static ssize_t
-sendrecv_tftp(struct tftp_handle *h, 
+sendrecv_tftp(struct tftp_handle *h,
     ssize_t (*sproc)(struct iodesc *, void *, size_t),
     void *sbuf, size_t ssize,
     ssize_t (*rproc)(struct tftp_handle *, void *, ssize_t, time_t, unsigned short *),
@@ -562,9 +630,9 @@ tftp_set_blksize(struct tftp_handle *h, 
 
 	/*
 	 * Only accept blksize value if it is numeric.
-	 * RFC2348 specifies that acceptable valuesare 8-65464
-	 * 8-65464 .  Let's choose a limit less than MAXRSPACE
-	*/
+	 * RFC2348 specifies that acceptable values are 8-65464.
+	 * Let's choose a limit less than MAXRSPACE.
+	 */
 	if (*endptr == '\0' && new_blksize >= 8
 	    && new_blksize <= TFTP_MAX_BLKSIZE) {
 		h->tftp_blksize = new_blksize;
@@ -597,13 +665,12 @@ tftp_set_blksize(struct tftp_handle *h, 
  *    optN, valueN
  *       The final option/value acknowledgment pair.
  */
-static void 
+static int 
 tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len)
 {
 	/* 
 	 *  We parse the OACK strings into an array
 	 *  of name-value pairs.
-	 *  
 	 */
 	char *tftp_options[128] = { 0 };
 	char *val = buf;
@@ -612,18 +679,22 @@ tftp_parse_oack(struct tftp_handle *h, c
 	int blksize_is_set = 0;
 	int tsize = 0;
 	
- 
-	while ( option_idx < 128 && i < len ) {
-		 if (buf[i] == '\0') {
-		    if (&buf[i] > val) {
-		       tftp_options[option_idx] = val;
-		       val = &buf[i] + 1;
-		       ++option_idx;
-		    }
-		 }
-		 ++i;
+	unsigned int orig_blksize;
+
+	while (option_idx < 128 && i < len) {
+		if (buf[i] == '\0') {
+			if (&buf[i] > val) {
+				tftp_options[option_idx] = val;
+				val = &buf[i] + 1;
+				++option_idx;
+			}
+		}
+		++i;
 	}
 
+	/* Save the block size we requested for sanity check later. */
+	orig_blksize = h->tftp_blksize;
+
 	/* 
 	 * Parse individual TFTP options.
 	 *    * "blksize" is specified in RFC2348.
@@ -631,27 +702,37 @@ tftp_parse_oack(struct tftp_handle *h, c
 	 */ 
 	for (i = 0; i < option_idx; i += 2) {
 	    if (strcasecmp(tftp_options[i], "blksize") == 0) {
-		if (i + 1 < option_idx) {
+		if (i + 1 < option_idx)
 			blksize_is_set =
 			    tftp_set_blksize(h, tftp_options[i + 1]);
-		}
 	    } else if (strcasecmp(tftp_options[i], "tsize") == 0) {
-		if (i + 1 < option_idx) {
+		if (i + 1 < option_idx)
 			tsize = strtol(tftp_options[i + 1], (char **)NULL, 10);
-		}
+	    } else {
+		/* Do not allow any options we did not expect to be ACKed. */
+		printf("unexpected tftp option '%s'\n", tftp_options[i]);
+		return (-1);
 	    }
 	}
 
 	if (!blksize_is_set) {
 		/*
 		 * If TFTP blksize was not set, try defaulting
-		 * to the legacy TFTP blksize of 512
+		 * to the legacy TFTP blksize of SEGSIZE(512)
 		 */
-		h->tftp_blksize = 512;
+		h->tftp_blksize = SEGSIZE;
+	} else if (h->tftp_blksize > orig_blksize) {
+		/*
+		 * Server should not be proposing block sizes that
+		 * exceed what we said we can handle.
+		 */
+		printf("unexpected blksize %u\n", h->tftp_blksize);
+		return (-1);
 	}
 
 #ifdef TFTP_DEBUG
 	printf("tftp_blksize: %u\n", h->tftp_blksize);
 	printf("tftp_tsize: %lu\n", h->tftp_tsize);
 #endif
+	return 0;
 }

Modified: projects/largeSMP/lib/libusb/Makefile
==============================================================================
--- projects/largeSMP/lib/libusb/Makefile	Fri Jun 24 16:06:50 2011	(r223507)
+++ projects/largeSMP/lib/libusb/Makefile	Fri Jun 24 16:35:40 2011	(r223508)
@@ -22,7 +22,7 @@ MLINKS+=	libusb.3 usb.3
 
 # libusb 0.1 compat
 INCS+=		usb.h
-SRCS+=		libusb20_compat01.c
+SRCS+=		libusb01.c
 
 # libusb 1.0 compat
 INCS+=		libusb.h
@@ -184,6 +184,8 @@ MLINKS += libusb20.3 libusb20_dev_get_de
 MLINKS += libusb20.3 libusb20_dev_alloc_config.3
 MLINKS += libusb20.3 libusb20_dev_alloc.3
 MLINKS += libusb20.3 libusb20_dev_get_address.3
+MLINKS += libusb20.3 libusb20_dev_get_parent_address.3
+MLINKS += libusb20.3 libusb20_dev_get_parent_port.3
 MLINKS += libusb20.3 libusb20_dev_get_bus_number.3
 MLINKS += libusb20.3 libusb20_dev_get_mode.3
 MLINKS += libusb20.3 libusb20_dev_get_speed.3

Copied: projects/largeSMP/lib/libusb/libusb01.c (from r223507, head/lib/libusb/libusb01.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/largeSMP/lib/libusb/libusb01.c	Fri Jun 24 16:35:40 2011	(r223508, copy of r223507, head/lib/libusb/libusb01.c)
@@ -0,0 +1,945 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2008 Hans Petter Selasky. 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.
+ */
+
+/*
+ * This file contains the emulation layer for LibUSB v0.1 from sourceforge.
+ */
+
+#include <sys/queue.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "libusb20.h"
+#include "libusb20_desc.h"
+#include "libusb20_int.h"
+#include "usb.h"
+
+/*
+ * The two following macros were taken from the original LibUSB v0.1
+ * for sake of compatibility:
+ */
+#define	LIST_ADD(begin, ent)	   \
+  do {				   \
+    if (begin) {		   \
+      ent->next = begin;	   \
+      ent->next->prev = ent;	   \
+    } else {			   \
+      ent->next = NULL;		   \
+    }				   \
+    ent->prev = NULL;		   \
+    begin = ent;		   \
+  } while(0)
+
+#define	LIST_DEL(begin, ent)		 \
+  do {					 \
+    if (ent->prev) {			 \
+      ent->prev->next = ent->next;	 \
+    } else {				 \
+      begin = ent->next;		 \
+    }					 \
+    if (ent->next) {			 \
+      ent->next->prev = ent->prev;	 \
+    }					 \
+    ent->prev = NULL;			 \
+    ent->next = NULL;			 \
+  } while (0)
+
+struct usb_bus *usb_busses = NULL;
+
+static struct usb_bus usb_global_bus = {
+	.dirname = {"/dev/usb"},
+	.root_dev = NULL,
+	.devices = NULL,
+};
+
+static struct libusb20_backend *usb_backend = NULL;
+
+struct usb_parse_state {
+
+	struct {
+		struct libusb20_endpoint *currep;
+		struct libusb20_interface *currifc;
+		struct libusb20_config *currcfg;
+		struct libusb20_me_struct *currextra;
+	}	a;
+
+	struct {
+		struct usb_config_descriptor *currcfg;
+		struct usb_interface_descriptor *currifc;
+		struct usb_endpoint_descriptor *currep;
+		struct usb_interface *currifcw;
+		uint8_t *currextra;
+	}	b;
+
+	uint8_t	preparse;
+};
+
+static struct libusb20_transfer *
+usb_get_transfer_by_ep_no(usb_dev_handle * dev, uint8_t ep_no)
+{
+	struct libusb20_device *pdev = (void *)dev;
+	struct libusb20_transfer *xfer;
+	int err;
+	uint32_t bufsize;
+	uint8_t x;
+	uint8_t speed;
+
+	x = (ep_no & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 2;
+
+	if (ep_no & LIBUSB20_ENDPOINT_DIR_MASK) {
+		/* this is an IN endpoint */
+		x |= 1;
+	}
+	speed = libusb20_dev_get_speed(pdev);
+
+	/* select a sensible buffer size */
+	if (speed == LIBUSB20_SPEED_LOW) {
+		bufsize = 256;
+	} else if (speed == LIBUSB20_SPEED_FULL) {
+		bufsize = 4096;
+	} else {
+		bufsize = 16384;
+	}
+
+	xfer = libusb20_tr_get_pointer(pdev, x);
+
+	if (xfer == NULL)
+		return (xfer);
+
+	err = libusb20_tr_open(xfer, bufsize, 1, ep_no);
+	if (err == LIBUSB20_ERROR_BUSY) {
+		/* already opened */
+		return (xfer);
+	} else if (err) {
+		return (NULL);
+	}
+	/* success */
+	return (xfer);
+}
+
+usb_dev_handle *
+usb_open(struct usb_device *dev)
+{
+	int err;
+
+	err = libusb20_dev_open(dev->dev, 16 * 2);
+	if (err == LIBUSB20_ERROR_BUSY) {
+		/*
+		 * Workaround buggy USB applications which open the USB
+		 * device multiple times:
+		 */
+		return (dev->dev);
+	}
+	if (err)
+		return (NULL);
+
+	/*
+	 * Dequeue USB device from backend queue so that it does not get
+	 * freed when the backend is re-scanned:
+	 */
+	libusb20_be_dequeue_device(usb_backend, dev->dev);
+
+	return (dev->dev);
+}
+
+int
+usb_close(usb_dev_handle * udev)
+{
+	struct usb_device *dev;
+	int err;
+
+	err = libusb20_dev_close((void *)udev);
+
+	if (err)
+		return (-1);
+
+	if (usb_backend != NULL) {
+		/*
+		 * Enqueue USB device to backend queue so that it gets freed
+		 * when the backend is re-scanned:
+		 */
+		libusb20_be_enqueue_device(usb_backend, (void *)udev);
+	} else {
+		/*
+		 * The backend is gone. Free device data so that we
+		 * don't start leaking memory!
+		 */
+		dev = usb_device(udev);
+		libusb20_dev_free((void *)udev);
+		LIST_DEL(usb_global_bus.devices, dev);
+		free(dev);
+	}
+	return (0);
+}
+
+int
+usb_get_string(usb_dev_handle * dev, int strindex,
+    int langid, char *buf, size_t buflen)
+{
+	int err;
+
+	err = libusb20_dev_req_string_sync((void *)dev,
+	    strindex, langid, buf, buflen);
+
+	if (err)
+		return (-1);
+
+	return (0);
+}
+
+int
+usb_get_string_simple(usb_dev_handle * dev, int strindex,
+    char *buf, size_t buflen)
+{
+	int err;
+
+	err = libusb20_dev_req_string_simple_sync((void *)dev,
+	    strindex, buf, buflen);
+
+	if (err)
+		return (-1);
+
+	return (strlen(buf));
+}
+
+int
+usb_get_descriptor_by_endpoint(usb_dev_handle * udev, int ep, uint8_t type,
+    uint8_t ep_index, void *buf, int size)
+{
+	memset(buf, 0, size);
+
+	return (usb_control_msg(udev, ep | USB_ENDPOINT_IN,
+	    USB_REQ_GET_DESCRIPTOR, (type << 8) + ep_index, 0,
+	    buf, size, 1000));
+}
+
+int
+usb_get_descriptor(usb_dev_handle * udev, uint8_t type, uint8_t desc_index,
+    void *buf, int size)
+{
+	memset(buf, 0, size);
+
+	return (usb_control_msg(udev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR,
+	    (type << 8) + desc_index, 0, buf, size, 1000));
+}
+
+int
+usb_parse_descriptor(uint8_t *source, char *description, void *dest)
+{
+	uint8_t *sp = source;
+	uint8_t *dp = dest;
+	uint16_t w;
+	uint32_t d;
+	char *cp;
+
+	for (cp = description; *cp; cp++) {
+		switch (*cp) {
+		case 'b':		/* 8-bit byte */
+			*dp++ = *sp++;
+			break;
+			/*
+			 * 16-bit word, convert from little endian to CPU
+			 */
+		case 'w':
+			w = (sp[1] << 8) | sp[0];
+			sp += 2;
+			/* Align to word boundary */
+			dp += ((dp - (uint8_t *)0) & 1);
+			*((uint16_t *)dp) = w;
+			dp += 2;
+			break;
+			/*
+			 * 32-bit dword, convert from little endian to CPU
+			 */
+		case 'd':
+			d = (sp[3] << 24) | (sp[2] << 16) |
+			    (sp[1] << 8) | sp[0];
+			sp += 4;
+			/* Align to word boundary */
+			dp += ((dp - (uint8_t *)0) & 1);
+			/* Align to double word boundary */
+			dp += ((dp - (uint8_t *)0) & 2);
+			*((uint32_t *)dp) = d;
+			dp += 4;
+			break;
+		}
+	}
+	return (sp - source);
+}
+
+static void
+usb_parse_extra(struct usb_parse_state *ps, uint8_t **pptr, int *plen)
+{
+	void *ptr;
+	uint16_t len;
+
+	ptr = ps->a.currextra->ptr;
+	len = ps->a.currextra->len;
+
+	if (ps->preparse == 0) {
+		memcpy(ps->b.currextra, ptr, len);
+		*pptr = ps->b.currextra;
+		*plen = len;
+	}
+	ps->b.currextra += len;
+	return;
+}
+
+static void
+usb_parse_endpoint(struct usb_parse_state *ps)
+{
+	struct usb_endpoint_descriptor *bep;
+	struct libusb20_endpoint *aep;
+
+	aep = ps->a.currep;
+	bep = ps->b.currep++;
+
+	if (ps->preparse == 0) {
+		/* copy descriptor fields */
+		bep->bLength = aep->desc.bLength;
+		bep->bDescriptorType = aep->desc.bDescriptorType;
+		bep->bEndpointAddress = aep->desc.bEndpointAddress;
+		bep->bmAttributes = aep->desc.bmAttributes;
+		bep->wMaxPacketSize = aep->desc.wMaxPacketSize;
+		bep->bInterval = aep->desc.bInterval;
+		bep->bRefresh = aep->desc.bRefresh;
+		bep->bSynchAddress = aep->desc.bSynchAddress;
+	}
+	ps->a.currextra = &aep->extra;
+	usb_parse_extra(ps, &bep->extra, &bep->extralen);
+	return;
+}
+
+static void
+usb_parse_iface_sub(struct usb_parse_state *ps)
+{
+	struct libusb20_interface *aifc;
+	struct usb_interface_descriptor *bifc;
+	uint8_t x;
+
+	aifc = ps->a.currifc;
+	bifc = ps->b.currifc++;
+
+	if (ps->preparse == 0) {
+		/* copy descriptor fields */
+		bifc->bLength = aifc->desc.bLength;
+		bifc->bDescriptorType = aifc->desc.bDescriptorType;
+		bifc->bInterfaceNumber = aifc->desc.bInterfaceNumber;
+		bifc->bAlternateSetting = aifc->desc.bAlternateSetting;
+		bifc->bNumEndpoints = aifc->num_endpoints;
+		bifc->bInterfaceClass = aifc->desc.bInterfaceClass;
+		bifc->bInterfaceSubClass = aifc->desc.bInterfaceSubClass;
+		bifc->bInterfaceProtocol = aifc->desc.bInterfaceProtocol;
+		bifc->iInterface = aifc->desc.iInterface;
+		bifc->endpoint = ps->b.currep;
+	}
+	for (x = 0; x != aifc->num_endpoints; x++) {
+		ps->a.currep = aifc->endpoints + x;
+		usb_parse_endpoint(ps);
+	}
+
+	ps->a.currextra = &aifc->extra;
+	usb_parse_extra(ps, &bifc->extra, &bifc->extralen);
+	return;
+}
+
+static void
+usb_parse_iface(struct usb_parse_state *ps)
+{
+	struct libusb20_interface *aifc;
+	struct usb_interface *bifc;
+	uint8_t x;
+
+	aifc = ps->a.currifc;
+	bifc = ps->b.currifcw++;
+
+	if (ps->preparse == 0) {
+		/* initialise interface wrapper */
+		bifc->altsetting = ps->b.currifc;
+		bifc->num_altsetting = aifc->num_altsetting + 1;
+	}
+	usb_parse_iface_sub(ps);
+
+	for (x = 0; x != aifc->num_altsetting; x++) {
+		ps->a.currifc = aifc->altsetting + x;
+		usb_parse_iface_sub(ps);
+	}
+	return;
+}
+
+static void
+usb_parse_config(struct usb_parse_state *ps)
+{
+	struct libusb20_config *acfg;
+	struct usb_config_descriptor *bcfg;
+	uint8_t x;
+
+	acfg = ps->a.currcfg;
+	bcfg = ps->b.currcfg;
+
+	if (ps->preparse == 0) {
+		/* initialise config wrapper */
+		bcfg->bLength = acfg->desc.bLength;
+		bcfg->bDescriptorType = acfg->desc.bDescriptorType;
+		bcfg->wTotalLength = acfg->desc.wTotalLength;
+		bcfg->bNumInterfaces = acfg->num_interface;
+		bcfg->bConfigurationValue = acfg->desc.bConfigurationValue;
+		bcfg->iConfiguration = acfg->desc.iConfiguration;
+		bcfg->bmAttributes = acfg->desc.bmAttributes;
+		bcfg->MaxPower = acfg->desc.bMaxPower;
+		bcfg->interface = ps->b.currifcw;
+	}
+	for (x = 0; x != acfg->num_interface; x++) {
+		ps->a.currifc = acfg->interface + x;
+		usb_parse_iface(ps);
+	}
+
+	ps->a.currextra = &acfg->extra;
+	usb_parse_extra(ps, &bcfg->extra, &bcfg->extralen);
+	return;
+}
+
+int
+usb_parse_configuration(struct usb_config_descriptor *config,
+    uint8_t *buffer)
+{
+	struct usb_parse_state ps;
+	uint8_t *ptr;
+	uint32_t a;
+	uint32_t b;
+	uint32_t c;
+	uint32_t d;
+
+	if ((buffer == NULL) || (config == NULL)) {
+		return (-1);
+	}
+	memset(&ps, 0, sizeof(ps));
+
+	ps.a.currcfg = libusb20_parse_config_desc(buffer);
+	ps.b.currcfg = config;
+	if (ps.a.currcfg == NULL) {
+		/* could not parse config or out of memory */
+		return (-1);
+	}
+	/* do the pre-parse */
+	ps.preparse = 1;
+	usb_parse_config(&ps);
+
+	a = ((uint8_t *)(ps.b.currifcw) - ((uint8_t *)0));
+	b = ((uint8_t *)(ps.b.currifc) - ((uint8_t *)0));
+	c = ((uint8_t *)(ps.b.currep) - ((uint8_t *)0));
+	d = ((uint8_t *)(ps.b.currextra) - ((uint8_t *)0));
+
+	/* allocate memory for our configuration */
+	ptr = malloc(a + b + c + d);
+	if (ptr == NULL) {
+		/* free config structure */
+		free(ps.a.currcfg);
+		return (-1);
+	}
+
+	/* "currifcw" must be first, hence this pointer is freed */
+	ps.b.currifcw = (void *)(ptr);
+	ps.b.currifc = (void *)(ptr + a);
+	ps.b.currep = (void *)(ptr + a + b);
+	ps.b.currextra = (void *)(ptr + a + b + c);
+
+	/* generate a libusb v0.1 compatible structure */
+	ps.preparse = 0;
+	usb_parse_config(&ps);
+
+	/* free config structure */
+	free(ps.a.currcfg);
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list