- separate 'STATIC' (non-dyamic-allocation) from 'FIRMWARE' (no host drivers)
authorHarald Welte <laforge@gnumonks.org>
Sat, 14 Oct 2006 15:04:10 +0000 (15:04 +0000)
committerHarald Welte <laforge@gnumonks.org>
Sat, 14 Oct 2006 15:04:10 +0000 (15:04 +0000)
- enhance openpcd in-firmware driver stubs
- fix 15693 segfaults with cm5121 and openpcd (15693 is not working yet!)

git-svn-id: https://svn.gnumonks.org/trunk/librfid@1904 e0336214-984f-0b4b-a45f-81c69e1f0ede

include/librfid/rfid_system.h
src/ccid/ccid-driver.c
src/ccid/rfid_reader_cm5121_ccid_direct.c
src/rfid.c
src/rfid_layer2_iso15693.c
src/rfid_reader_cm5121.c
src/rfid_reader_openpcd.c

index 56441bb..9b07cf7 100644 (file)
@@ -1,10 +1,14 @@
 /* system / environment specific defines */
 
+/* build for openpcd firmware */
 //#define LIBRFID_FIRMWARE
 
+/* build without dynamic allocations */
+#define LIBRFID_STATIC
+
 #ifdef __LIBRFID__
 
-#ifndef LIBRFID_FIRMWARE
+#ifndef LIBRFID_STATIC
 /* If we're not doing a firmware compile, then we just use the regular
  * malloc()/free() functions as expected */
 
@@ -48,6 +52,6 @@ extern struct rfid_reader_handle rfid_rh;
 #define malloc_reader_handle(x)        &rfid_rh
 #define free_reader_handle(x)  EMPTY_STATEMENT
 
-#endif /* LIBRFID_FIRMWARE */
+#endif /* LIBRFID_STATIC */
 
 #endif /* __LIBRFID__ */
index edca5ca..e440167 100644 (file)
    level exchange and does fully automatic initialization.
 */
 
+#include <librfid/rfid.h>
+
+#ifndef LIBRFID_FIRMWARE
+
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
@@ -2446,3 +2450,5 @@ main (int argc, char **argv)
  */
 #endif /*TEST*/
 #endif /*HAVE_LIBUSB*/
+
+#endif /* LIBRFID_FIRMWARE */
index c6b2d15..3327a08 100644 (file)
@@ -3,6 +3,10 @@
 #include <unistd.h>
 #include <stdio.h>
 
+#include <librfid/rfid.h>
+
+#ifndef LIBRFID_FIRMWARE
+
 #include <librfid/rfid_asic.h>
 
 #include "ccid-driver.h"
@@ -34,3 +38,5 @@ int cm5121_source_init(struct rfid_asic_transport_handle *rath)
         }
        return 0;
 }
+
+#endif /* LIBRFID_FIRMWARE */
index ec0ce1f..10abb99 100644 (file)
@@ -23,7 +23,7 @@
 #include <librfid/rfid_protocol_mifare_ul.h>
 #include <librfid/rfid_protocol_mifare_classic.h>
 
-#ifdef LIBRFID_FIRMWARE
+#ifdef LIBRFID_STATIC
 struct rfid_asic_handle rfid_ah;
 struct rfid_layer2_handle rfid_l2h;
 struct rfid_protocol_handle rfid_ph;
index 8ab0b1e..a9767b7 100644 (file)
@@ -259,6 +259,13 @@ iso14443a_hlta(struct rfid_layer2_handle *handle)
 }
 #endif
 
+
+static int
+iso15693_anticol(struct rfid_layer2_handle *handle)
+{
+       return -1;
+}
+
 static struct rfid_layer2_handle *
 iso15693_init(struct rfid_reader_handle *rh)
 {
@@ -270,7 +277,6 @@ iso15693_init(struct rfid_reader_handle *rh)
        h->l2 = &rfid_layer2_iso15693;
        h->rh = rh;
        h->priv.iso15693.state = ISO15693_STATE_NONE;
-
        ret = h->rh->reader->iso15693.init(h->rh);
        if (ret < 0) {
                free_layer2_handle(h);
@@ -293,7 +299,7 @@ const struct rfid_layer2 rfid_layer2_iso15693 = {
        .name   = "ISO 15693",
        .fn     = {
                .init           = &iso15693_init,
-               //.open                 = &iso15693_anticol,
+               .open           = &iso15693_anticol,
                //.transceive   = &iso15693_transceive,
                //.close                = &iso14443a_hlta,
                .fini           = &iso15693_fini,
index dd15fd6..a62cc4c 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
-#ifndef LIBRFID_FIRMWARE
-
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
 
 #include <librfid/rfid.h>
+
+#ifndef LIBRFID_FIRMWARE
+
 #include <librfid/rfid_reader.h>
 #include <librfid/rfid_asic.h>
 #include <librfid/rfid_asic_rc632.h>
@@ -381,6 +381,9 @@ const struct rfid_reader rfid_reader_cm5121 = {
        .iso14443b = {
                .init = &cm5121_14443b_init,
        },
+       .iso15693 = {
+               .init = &cm5121_15693_init,
+       },
        .mifare_classic = {
                .setkey = &cm5121_mifare_setkey,
                .auth = &cm5121_mifare_auth,
index 15486b6..dc9db10 100644 (file)
@@ -226,12 +226,14 @@ const struct rfid_asic_transport openpcd_rat = {
 static int openpcd_reg_write(struct rfid_asic_transport_handle *rath,
                             unsigned char reg, unsigned char value)
 {
+       return rc632_reg_write(rath, reg, value);
 }
 
 static int openpcd_reg_read(struct rfid_asic_transport_handle *rath,
                            unsigned char reg,
                            unsigned char *value)
 {
+       return rc632_reg_write(rath, reg, value);
 }
 
 
@@ -239,6 +241,7 @@ static int openpcd_fifo_read(struct rfid_asic_transport_handle *rath,
                             unsigned char num_bytes,
                             unsigned char *buf)
 {
+       return rc632_reg_write(rath, num_bytes, buf);
 }
 
 static int openpcd_fifo_write(struct rfid_asic_transport_handle *rath,
@@ -246,6 +249,7 @@ static int openpcd_fifo_write(struct rfid_asic_transport_handle *rath,
                             const unsigned char *bytes,
                             unsigned char flags)
 {
+       return rc632_fifo_write(rath, len, bytes, flags);
 }
 
 const struct rfid_asic_transport openpcd_rat = {
@@ -365,6 +369,7 @@ openpcd_open(void *data)
        snd_hdr = (struct openpcd_hdr *)snd_buf;
        rcv_hdr = (struct openpcd_hdr *)rcv_buf;
 
+#ifndef LIBRFID_FIRMWARE
        usb_init();
        if (usb_find_busses() < 0)
                return NULL;
@@ -388,6 +393,7 @@ openpcd_open(void *data)
                usb_close(hdl);
                return NULL;
        }
+#endif
 
        rh = malloc_reader_handle(sizeof(*rh));
        if (!rh)
@@ -426,7 +432,9 @@ openpcd_close(struct rfid_reader_handle *rh)
        free_rat_handle(rath);
        free_reader_handle(rh);
 
+#ifndef LIBRFID_FIRMWARE
        usb_close(hdl);
+#endif
 }
 
 const struct rfid_reader rfid_reader_openpcd = {
@@ -452,6 +460,9 @@ const struct rfid_reader rfid_reader_openpcd = {
        .iso14443b = {
                .init = &openpcd_14443b_init,
        },
+       .iso15693 = {
+               .init = &openpcd_15693_init,
+       },
        .mifare_classic = {
                .setkey = &openpcd_mifare_setkey,
                .auth = &openpcd_mifare_auth,