From 9ce76f09417c31a8fc904b67624c0f3b397c21c0 Mon Sep 17 00:00:00 2001 From: laforge Date: Sat, 14 Oct 2006 15:04:10 +0000 Subject: [PATCH] - separate 'STATIC' (non-dyamic-allocation) from 'FIRMWARE' (no host drivers) - 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 | 8 ++++++-- src/ccid/ccid-driver.c | 6 ++++++ src/ccid/rfid_reader_cm5121_ccid_direct.c | 6 ++++++ src/rfid.c | 2 +- src/rfid_layer2_iso15693.c | 10 ++++++++-- src/rfid_reader_cm5121.c | 9 ++++++--- src/rfid_reader_openpcd.c | 11 +++++++++++ 7 files changed, 44 insertions(+), 8 deletions(-) diff --git a/include/librfid/rfid_system.h b/include/librfid/rfid_system.h index 56441bb..9b07cf7 100644 --- a/include/librfid/rfid_system.h +++ b/include/librfid/rfid_system.h @@ -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__ */ diff --git a/src/ccid/ccid-driver.c b/src/ccid/ccid-driver.c index edca5ca..e440167 100644 --- a/src/ccid/ccid-driver.c +++ b/src/ccid/ccid-driver.c @@ -71,6 +71,10 @@ level exchange and does fully automatic initialization. */ +#include + +#ifndef LIBRFID_FIRMWARE + #ifdef HAVE_CONFIG_H # include #endif @@ -2446,3 +2450,5 @@ main (int argc, char **argv) */ #endif /*TEST*/ #endif /*HAVE_LIBUSB*/ + +#endif /* LIBRFID_FIRMWARE */ diff --git a/src/ccid/rfid_reader_cm5121_ccid_direct.c b/src/ccid/rfid_reader_cm5121_ccid_direct.c index c6b2d15..3327a08 100644 --- a/src/ccid/rfid_reader_cm5121_ccid_direct.c +++ b/src/ccid/rfid_reader_cm5121_ccid_direct.c @@ -3,6 +3,10 @@ #include #include +#include + +#ifndef LIBRFID_FIRMWARE + #include #include "ccid-driver.h" @@ -34,3 +38,5 @@ int cm5121_source_init(struct rfid_asic_transport_handle *rath) } return 0; } + +#endif /* LIBRFID_FIRMWARE */ diff --git a/src/rfid.c b/src/rfid.c index ec0ce1f..10abb99 100644 --- a/src/rfid.c +++ b/src/rfid.c @@ -23,7 +23,7 @@ #include #include -#ifdef LIBRFID_FIRMWARE +#ifdef LIBRFID_STATIC struct rfid_asic_handle rfid_ah; struct rfid_layer2_handle rfid_l2h; struct rfid_protocol_handle rfid_ph; diff --git a/src/rfid_layer2_iso15693.c b/src/rfid_layer2_iso15693.c index 8ab0b1e..a9767b7 100644 --- a/src/rfid_layer2_iso15693.c +++ b/src/rfid_layer2_iso15693.c @@ -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, diff --git a/src/rfid_reader_cm5121.c b/src/rfid_reader_cm5121.c index dd15fd6..a62cc4c 100644 --- a/src/rfid_reader_cm5121.c +++ b/src/rfid_reader_cm5121.c @@ -26,15 +26,15 @@ * 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 #include #include #include #include + +#ifndef LIBRFID_FIRMWARE + #include #include #include @@ -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, diff --git a/src/rfid_reader_openpcd.c b/src/rfid_reader_openpcd.c index 15486b6..dc9db10 100644 --- a/src/rfid_reader_openpcd.c +++ b/src/rfid_reader_openpcd.c @@ -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, -- 2.20.1