#include <librfid/rfid_asic.h>
#include <librfid/rfid_asic_rc632.h>
#include <librfid/rfid_reader_openpcd.h>
+#include <librfid/rfid_layer2.h>
+#include <librfid/rfid_protocol.h>
/* FIXME */
#include "rc632.h"
-
#define SENDBUF_LEN (256+4+10) /* 256bytes max FSD/FSC, plus 4 bytes header,
plus 10 bytes reserve */
#define RECVBUF_LEN SENDBUF_LEN
static struct openpcd_hdr *rcv_hdr;
+#ifndef LIBRFID_FIRMWARE
+
static struct usb_device *dev;
static struct usb_dev_handle *hdl;
struct usb_device *dev;
for (dev = bus->devices; dev; dev = dev->next) {
int i;
- printf("usb: %4x:%4x\n", dev->descriptor.idVendor,
- dev->descriptor.idProduct);
for (i = 0; i < ARRAY_SIZE(opcd_usb_ids); i++) {
const struct usb_id *id = &opcd_usb_ids[i];
- printf("%x:%x\n", id->vid, id->pid);
if (dev->descriptor.idVendor == id->vid &&
dev->descriptor.idProduct == id->pid)
return dev;
return NULL;
}
+/* RC632 access primitives for librfid inside reader firmware */
+
static int openpcd_reg_write(struct rfid_asic_transport_handle *rath,
unsigned char reg, unsigned char value)
{
return ret;
}
+const struct rfid_asic_transport openpcd_rat = {
+ .name = "OpenPCD Dumb USB Protocol",
+ .priv.rc632 = {
+ .fn = {
+ .reg_write = &openpcd_reg_write,
+ .reg_read = &openpcd_reg_read,
+ .fifo_write = &openpcd_fifo_write,
+ .fifo_read = &openpcd_fifo_read,
+ },
+ },
+};
+
+#else
+/* RC632 access primitives for librfid inside reader firmware */
+
+static int openpcd_reg_write(struct rfid_asic_transport_handle *rath,
+ unsigned char reg, unsigned char value)
+{
+}
+
+static int openpcd_reg_read(struct rfid_asic_transport_handle *rath,
+ unsigned char reg,
+ unsigned char *value)
+{
+}
+
+
+static int openpcd_fifo_read(struct rfid_asic_transport_handle *rath,
+ unsigned char num_bytes,
+ unsigned char *buf)
+{
+}
+
+static int openpcd_fifo_write(struct rfid_asic_transport_handle *rath,
+ unsigned char len,
+ const unsigned char *bytes,
+ unsigned char flags)
+{
+}
+
+const struct rfid_asic_transport openpcd_rat = {
+ .name = "OpenPCD Firmware RC632 Access",
+ .priv.rc632 = {
+ .fn = {
+ .reg_write = &openpcd_reg_write,
+ .reg_read = &openpcd_reg_read,
+ .fifo_write = &openpcd_fifo_write,
+ .fifo_read = &openpcd_fifo_read,
+ },
+ },
+};
+
+#endif /* LIBRFID_FIRMWARE */
+
static int openpcd_transceive(struct rfid_reader_handle *rh,
enum rfid_frametype frametype,
const unsigned char *tx_data, unsigned int tx_len,
cmd, serno, block);
}
-struct rfid_asic_transport openpcd_ccid = {
- .name = "OpenPCD Dumb USB Protocol",
- .priv.rc632 = {
- .fn = {
- .reg_write = &openpcd_reg_write,
- .reg_read = &openpcd_reg_read,
- .fifo_write = &openpcd_fifo_write,
- .fifo_read = &openpcd_fifo_read,
- },
- },
-};
-
static struct rfid_reader_handle *
openpcd_open(void *data)
{
return NULL;
}
- rh = malloc(sizeof(*rh));
+ rh = malloc_reader_handle(sizeof(*rh));
if (!rh)
return NULL;
memset(rh, 0, sizeof(*rh));
- rath = malloc(sizeof(*rath));
+ rath = malloc_rat_handle(sizeof(*rath));
if (!rath)
goto out_rh;
memset(rath, 0, sizeof(*rath));
- rath->rat = &openpcd_ccid;
+ rath->rat = &openpcd_rat;
rh->reader = &rfid_reader_openpcd;
rh->ah = rc632_open(rath);
return rh;
out_rath:
- free(rath);
+ free_rat_handle(rath);
out_rh:
- free(rh);
+ free_reader_handle(rh);
return NULL;
}
struct rfid_asic_transport_handle *rath = rh->ah->rath;
rc632_close(rh->ah);
- free(rath);
- free(rh);
+ free_rat_handle(rath);
+ free_reader_handle(rh);
usb_close(hdl);
}
-struct rfid_reader rfid_reader_openpcd = {
+const struct rfid_reader rfid_reader_openpcd = {
.name = "OpenPCD RFID Reader",
.id = RFID_READER_OPENPCD,
.open = &openpcd_open,
.close = &openpcd_close,
.transceive = &openpcd_transceive,
+ .l2_supported = (1 << RFID_LAYER2_ISO14443A) |
+ (1 << RFID_LAYER2_ISO14443B) |
+ (1 << RFID_LAYER2_ISO15693),
+ .proto_supported = (1 << RFID_PROTOCOL_TCL) |
+ (1 << RFID_PROTOCOL_MIFARE_UL) |
+ (1 << RFID_PROTOCOL_MIFARE_CLASSIC),
.iso14443a = {
.init = &openpcd_14443a_init,
.transceive_sf = &openpcd_transceive_sf,