Permalink
Browse files

Done some major pieces while working on TCK compliance:

o Redid usbw to use __func__ to make the debugging more consistent.
o Caching all descriptors when loading the device.
o Fixed 64 bit compatability.
o Removed the usb_services_context struct. It wasn't used and there should only be.
o Adding the libusb error code when throwing platform exceptions, makes the toString() result better.
o Removed the code that went into the Java objects to fetch the libusb data. All data is now passed as arguments to the function that require it which all in all became much cleaner.
p Made both libusb_context and libusb_device fields into longs. Added a check_jvm_platform tools to assert that a jlong can handle a C pointer.
  • Loading branch information...
1 parent ecdf425 commit ed808f2f7fd3a1d23f49550ac78e70c86181966d @trygvis committed Jul 31, 2010
View
@@ -42,6 +42,12 @@ This is the command used to create and synchronize the upstream CVS repositories
> git cvsimport -d :pserver:anonymous@javax-usb.cvs.sourceforge.net:/cvsroot/javax-usb javax-usb
+### Building 64-Bit Versions
+
+To build a 64-bit version of the libraries and tools add BITS=64 to the make command:
+
+> make -C javalibusb1 clean all BITS=64^
+
### The Firmware
The original firmware images are not used as it's not clear which
View
@@ -12,16 +12,16 @@
</path>
<path id="test">
+ <pathelement location="tck/src/test/resources"/>
+ <pathelement location="${tck.path}/target/classes"/>
+ <pathelement location="${tck.path}/target/test-classes"/>
+
<pathelement location="javax.usb/target/classes"/>
<pathelement location="javax.usb/target/test-classes"/>
<pathelement location="javalibusb1/target/classes"/>
<pathelement location="javalibusb1/target/test-classes"/>
- <pathelement location="${tck.path}/resources"/>
- <pathelement location="${tck.path}/target/classes"/>
- <pathelement location="${tck.path}/target/test-classes"/>
-
<pathelement location="${maven.repo.local}/junit/junit/3.8.1/junit-3.8.1.jar"/>
<pathelement location="${maven.repo.local}/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar"/>
<pathelement location="${maven.repo.local}/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
@@ -87,29 +87,61 @@
<target name="prepare-tck" depends="compile">
</target>
- <target name="tck-1" depends="prepare-tck">
- <echo>Running TCK Test CONFIG1_TOPOLOGY_B6_IMAGE</echo>
- <echo>See tck.log for output.</echo>
+ <!--
+
+ javax.usb.tck.CONFIG3_ISODCP_B6_IMAGE
+ javax.usb.tck.CONFIG3_TOPOLOGY_B6_IMAGE
+ javax.usb.tck.OPT_CONFIG3_ISODCP_ISOCHRONOUS
+ javax.usb.tck.OPT_CONFIG3_TOPOLOGY_SET_CONFIG
+ javax.usb.tck.OPT_CONFIG3_TOPOLOGY_SET_INTERFACE
+ javax.usb.tck.SIGNATURE
+ -->
+
+ <target name="CONFIG1_TOPOLOGY_B6_IMAGE" depends="prepare-tck">
+ <echo>Running TCK Test javax.usb.tck.CONFIG1_TOPOLOGY_B6_IMAGE</echo>
+ <echo>See target/javax.usb.tck.CONFIG1_TOPOLOGY_B6_IMAGE.log for output.</echo>
+ <mkdir dir="target"/>
<!-- This uses the local javax.usb + TCK classes -->
- <java fork="true" failonerror="true" output="tck.log" classpathref="test"
+ <java fork="true" failonerror="true" output="target/javax.usb.tck.CONFIG1_TOPOLOGY_B6_IMAGE.log" classpathref="test"
classname="javax.usb.tck.CONFIG1_TOPOLOGY_B6_IMAGE">
<sysproperty key="javaxusbtck_home" value="${tck.path}"/>
<sysproperty key="java.library.path" value="javalibusb1/.libs"/>
<env key="LD_LIBRARY_PATH" value="${libusb.lib.path}"/>
<!-- For Darwin/OS X -->
<env key="DYLD_LIBRARY_PATH" value="${libusb.lib.path}"/>
</java>
+ </target>
- <!--
- javax.usb.tck.CONFIG2_TOPOLOGY_B6_IMAGE
- javax.usb.tck.CONFIG3_BULKINT_B6_IMAGE
- javax.usb.tck.CONFIG3_ISODCP_B6_IMAGE
- javax.usb.tck.CONFIG3_TOPOLOGY_B6_IMAGE
- javax.usb.tck.OPT_CONFIG3_ISODCP_ISOCHRONOUS
- javax.usb.tck.OPT_CONFIG3_TOPOLOGY_SET_CONFIG
- javax.usb.tck.OPT_CONFIG3_TOPOLOGY_SET_INTERFACE
- javax.usb.tck.SIGNATURE
- -->
+ <target name="CONFIG2_TOPOLOGY_B6_IMAGE" depends="prepare-tck">
+ <echo>Running TCK Test javax.usb.tck.CONFIG2_TOPOLOGY_B6_IMAGE</echo>
+ <echo>See target/tck-CONFIG2_TOPOLOGY_B6_IMAGE.log for output.</echo>
+ <mkdir dir="target"/>
+
+ <!-- This uses the local javax.usb + TCK classes -->
+ <java fork="true" failonerror="true" output="target/tck-CONFIG2_TOPOLOGY_B6_IMAGE.log" classpathref="test"
+ classname="javax.usb.tck.CONFIG2_TOPOLOGY_B6_IMAGE">
+ <sysproperty key="javaxusbtck_home" value="${tck.path}"/>
+ <sysproperty key="java.library.path" value="javalibusb1/.libs"/>
+ <env key="LD_LIBRARY_PATH" value="${libusb.lib.path}"/>
+ <!-- For Darwin/OS X -->
+ <env key="DYLD_LIBRARY_PATH" value="${libusb.lib.path}"/>
+ </java>
+ </target>
+
+ <target name="CONFIG3_BULKINT_B6_IMAGE" depends="prepare-tck">
+ <echo>Running TCK Test javax.usb.tck.CONFIG3_BULKINT_B6_IMAGE</echo>
+ <echo>See target/javax.usb.tck.CONFIG3_BULKINT_B6_IMAGE for output.</echo>
+ <mkdir dir="target"/>
+
+ <!-- This uses the local javax.usb + TCK classes -->
+ <java fork="true" failonerror="true" output="target/javax.usb.tck.CONFIG3_BULKINT_B6_IMAGE" classpathref="test"
+ classname="javax.usb.tck.CONFIG3_BULKINT_B6_IMAGE">
+ <sysproperty key="javaxusbtck_home" value="${tck.path}"/>
+ <sysproperty key="java.library.path" value="javalibusb1/.libs"/>
+ <env key="LD_LIBRARY_PATH" value="${libusb.lib.path}"/>
+ <!-- For Darwin/OS X -->
+ <env key="DYLD_LIBRARY_PATH" value="${libusb.lib.path}"/>
+ </java>
</target>
</project>
View
@@ -8,8 +8,17 @@ CC ?= gcc
CCFLAGS += -I$(JDK_HOME)/include
CCFLAGS += -Wall
CCFLAGS += -Werror
+# CCFLAGS += -m64 # Add this for 64-bit version
-all: usb_reset libjavalibusb1.$(SHREXT)
+all: check tools lib
+
+check: check_jvm_platform
+ @./check_jvm_platform
+
+TOOLS=usb_open_twice usb_get_config_descriptor usb_reset
+tools: $(TOOLS)
+
+lib: libjavalibusb1.$(SHREXT)
libjavalibusb1.$(SHREXT): javalibusb.lo usbw.lo
$(LIBTOOL) --mode=link --tag=CC cc -module -shared -shrext .$(SHREXT) -o libjavalibusb1.la $^ $(LDFLAGS) -rpath /usr/lib
@@ -42,7 +51,8 @@ clean-java:
rm -rf target/classes target/test-classes
clean-native:
- rm -rf *.lo *.la *.so $(wildcard core) $(wildcard hs_err_pid*)
+ @rm -rf *.lo *.la *.so $(wildcard core) $(wildcard hs_err_pid*) $(wildcard *.o)
+ @rm -f $(TOOLS)
test: libjavalibusb1.$(SHREXT)
$(JAVA_HOME)/bin/java -classpath $(CLASSPATH) -Xcheck:jni -Djava.library.path=.:.libs $(JVM_ARGS) javalibusb1.test.JUsbTest
@@ -53,8 +63,15 @@ lsusb: libjavalibusb1.$(SHREXT)
ReadSerial: libjavalibusb1.$(SHREXT)
$(JAVA_HOME)/bin/java -classpath $(CLASSPATH) -Xcheck:jni -Djava.library.path=.:.libs $(JVM_ARGS) javalibusb1.test.ReadSerial
-usb_reset.o: usb_reset.c
- $(CC) $(CCFLAGS) -c -o $@ $<
+usb_get_config_descriptor: usb_get_config_descriptor.o usbw.o
+usb_open_twice: usb_open_twice.o usbw.o
+usb_reset: usb_reset.o usbw.o
+check_jvm_platform: check_jvm_platform.o
+
+%.o: %.c
+ @echo CC $<
+ @$(CC) $(CCFLAGS) -c -g -o $@ $^
-usb_reset: usb_reset.o
- $(CC) $(LDFLAGS) -o $@ $<
+%: %.o
+ @echo LD $@
+ @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $^
@@ -1,3 +1,13 @@
-CCFLAGS += -L/Users/trygvis/opt/libusb-git/lib
-#CCFLAGS += -R/Users/trygvis/opt/libusb-git/lib
-CCFLAGS += -I/Users/trygvis/opt/libusb-git/include/libusb-1.0
+BITS ?= 32
+
+ifeq ($(BITS),64)
+CCFLAGS += -g
+CCFLAGS += -m64
+LDFLAGS += -m64
+BITDIR = -64
+endif
+
+CCFLAGS += -I/Users/trygvis/opt/libusb-git$(BITDIR)/include/libusb-1.0
+LDFLAGS += -L/Users/trygvis/opt/libusb-git$(BITDIR)/lib
+
+LDFLAGS += -lusb-1.0
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <libusb.h>
+
+int main() {
+
+ if(sizeof(struct libusb_device *) <= sizeof(jlong)) {
+ return EXIT_SUCCESS;
+ }
+
+ printf("Your platform's pointers are too long.\n");
+ printf("A jlong has to be able to hold a struct libusb_device*:\n");
+ printf("sizeof(jlong): %lu\n", sizeof(jlong));
+ printf("sizeof(struct libusb_device *): %lu\n", sizeof(struct libusb_device *));
+
+ return EXIT_FAILURE;
+}
Oops, something went wrong.

0 comments on commit ed808f2

Please sign in to comment.