From: Harald Welte Date: Sun, 11 Sep 2005 19:59:58 +0000 (+0000) Subject: use 64bit timeout values throughout the code, since some timeouts exceeds 4.8 billion... X-Git-Url: http://git.rot13.org/?p=librfid;a=commitdiff_plain;h=2320c479767e58be144767a3c531d7a17e8e3a75;ds=sidebyside use 64bit timeout values throughout the code, since some timeouts exceeds 4.8 billion microseconds (seconds). git-svn-id: https://svn.gnumonks.org/trunk/librfid@1426 e0336214-984f-0b4b-a45f-81c69e1f0ede --- diff --git a/include/rfid/rfid_asic_rc632.h b/include/rfid/rfid_asic_rc632.h index 94345eb..13279a8 100644 --- a/include/rfid/rfid_asic_rc632.h +++ b/include/rfid/rfid_asic_rc632.h @@ -37,7 +37,7 @@ struct rfid_asic_rc632 { unsigned int tx_len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, + u_int64_t timeout, unsigned int flags); struct { int (*init)(struct rfid_asic_handle *h); @@ -109,13 +109,13 @@ rc632_power_down(struct rfid_asic_handle *handle); int -rc632_wait_idle(struct rfid_asic_handle *handle, unsigned int time); +rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time); int rc632_transmit(struct rfid_asic_handle *handle, const unsigned char *buf, unsigned char len, - unsigned int timeout); + u_int64_t timeout); int rc632_transcieve(struct rfid_asic_handle *handle, diff --git a/include/rfid/rfid_layer2.h b/include/rfid/rfid_layer2.h index 975022a..fb296a2 100644 --- a/include/rfid/rfid_layer2.h +++ b/include/rfid/rfid_layer2.h @@ -19,7 +19,7 @@ struct rfid_layer2 { int (*transcieve)(struct rfid_layer2_handle *h, const unsigned char *tx_buf, unsigned int tx_len, unsigned char *rx_buf, - unsigned int *rx_len, unsigned int timeout, + unsigned int *rx_len, u_int64_t timeout, unsigned int flags); int (*close)(struct rfid_layer2_handle *h); int (*fini)(struct rfid_layer2_handle *h); @@ -50,7 +50,7 @@ int rfid_layer2_open(struct rfid_layer2_handle *l2h); int rfid_layer2_transcieve(struct rfid_layer2_handle *l2h, const unsigned char *tx_buf, unsigned int tx_len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags); + u_int64_t timeout, unsigned int flags); int rfid_layer2_close(struct rfid_layer2_handle *l2h); int rfid_layer2_fini(struct rfid_layer2_handle *l2h); diff --git a/include/rfid/rfid_reader.h b/include/rfid/rfid_reader.h index 5f6c314..98c03a1 100644 --- a/include/rfid/rfid_reader.h +++ b/include/rfid/rfid_reader.h @@ -12,9 +12,9 @@ struct rfid_reader { int (*transcieve)(struct rfid_reader_handle *h, const unsigned char *tx_buf, unsigned int tx_len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags); + u_int64_t timeout, unsigned int flags); struct rfid_reader_handle * (*open)(void *data); - int (*close)(void *data); + void (*close)(struct rfid_reader_handle *h); struct rfid_14443a_reader { int (*init)(struct rfid_reader_handle *h); diff --git a/rfid_asic_rc632.c b/rfid_asic_rc632.c index 764b7b7..77e4c47 100644 --- a/rfid_asic_rc632.c +++ b/rfid_asic_rc632.c @@ -148,7 +148,7 @@ rc632_power_down(struct rfid_asic_handle *handle) /* Stupid RC623 implementations don't evaluate interrupts but poll the * command register for "status idle" */ int -rc632_wait_idle(struct rfid_asic_handle *handle, unsigned int time) +rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t timeout) { unsigned char cmd = 0xff; int ret; @@ -182,7 +182,7 @@ int rc632_transmit(struct rfid_asic_handle *handle, const unsigned char *buf, unsigned char len, - unsigned int timeout) + u_int64_t timeout) { int ret; @@ -617,7 +617,7 @@ static int rc632_iso14443a_transcieve(struct rfid_asic_handle *handle, const unsigned char *tx_buf, unsigned int tx_len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags) + u_int64_t timeout, unsigned int flags) { int ret; unsigned char rxl = *rx_len & 0xff; diff --git a/rfid_layer2.c b/rfid_layer2.c index aa3b767..ef59bad 100644 --- a/rfid_layer2.c +++ b/rfid_layer2.c @@ -48,7 +48,7 @@ int rfid_layer2_transcieve(struct rfid_layer2_handle *ph, const unsigned char *tx_buf, unsigned int len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags) + u_int64_t timeout, unsigned int flags) { return ph->l2->fn.transcieve(ph, tx_buf, len, rx_buf, rx_len, timeout, flags); diff --git a/rfid_layer2_iso14443a.c b/rfid_layer2_iso14443a.c index b3e5958..0605a89 100644 --- a/rfid_layer2_iso14443a.c +++ b/rfid_layer2_iso14443a.c @@ -57,7 +57,7 @@ static int iso14443a_transcieve(struct rfid_layer2_handle *handle, const unsigned char *tx_buf, unsigned int tx_len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags) + u_int64_t timeout, unsigned int flags) { return handle->rh->reader->transcieve(handle->rh, tx_buf, tx_len, rx_buf, rx_len, timeout, flags); diff --git a/rfid_layer2_iso14443b.c b/rfid_layer2_iso14443b.c index d36b5da..1988827 100644 --- a/rfid_layer2_iso14443b.c +++ b/rfid_layer2_iso14443b.c @@ -36,7 +36,7 @@ static inline int fwi_to_fwt(struct rfid_layer2_handle *h, unsigned int *fwt, unsigned int fwi) { - unsigned int multiplier; + unsigned int multiplier, tmp; /* 15 is RFU */ if (fwi > 14) @@ -52,7 +52,9 @@ fwi_to_fwt(struct rfid_layer2_handle *h, unsigned int *fwt, unsigned int fwi) multiplier = 1 << fwi; /* 2 to the power of fwi */ - return (1000000 * 256 * 16 / h->rh->ah->asic->fc) * multiplier + tmp = (unsigned int) 1000000 * 256 * 16; + + return (tmp / h->rh->ah->asic->fc) * multiplier; } static int @@ -124,7 +126,7 @@ send_reqb(struct rfid_layer2_handle *h, unsigned char afi, /* FIXME: send N-1 slot marker frames */ if (atqb_len != sizeof(atqb)) { - DEBUGP("error: atqb_len = %u instead of %u\n", + DEBUGP("error: atqb_len = %u instead of %Zu\n", atqb_len, sizeof(atqb)); continue; } @@ -263,7 +265,7 @@ iso14443b_anticol(struct rfid_layer2_handle *handle) { unsigned char afi = 0; /* FIXME */ int ret; - char buf[255]; + unsigned char buf[255]; unsigned int buf_len = sizeof(buf); ret = send_reqb(handle, afi, 0, 0); @@ -317,7 +319,7 @@ static int iso14443b_transcieve(struct rfid_layer2_handle *handle, const unsigned char *tx_buf, unsigned int tx_len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags) + u_int64_t timeout, unsigned int flags) { return handle->rh->reader->transcieve(handle->rh, tx_buf, tx_len, rx_buf, rx_len, timeout, flags); diff --git a/rfid_layer2_iso15693.c b/rfid_layer2_iso15693.c index 2c9eb3b..15ff18a 100644 --- a/rfid_layer2_iso15693.c +++ b/rfid_layer2_iso15693.c @@ -56,7 +56,7 @@ static int iso14443a_transcieve(struct rfid_layer2_handle *handle, const unsigned char *tx_buf, unsigned int tx_len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags) + u_int64_t, unsigned int flags) { return handle->rh->reader->transcieve(handle->rh, tx_buf, tx_len, rx_buf, rx_len, timeout, flags); diff --git a/rfid_proto_tcl.c b/rfid_proto_tcl.c index b8586f5..e60af55 100644 --- a/rfid_proto_tcl.c +++ b/rfid_proto_tcl.c @@ -41,6 +41,7 @@ static unsigned int sfgi_to_sfgt(struct rfid_protocol_handle *h, unsigned char sfgi) { unsigned int multiplier; + unsigned int tmp; if (sfgi > 14) sfgi = 14; @@ -49,14 +50,15 @@ static unsigned int sfgi_to_sfgt(struct rfid_protocol_handle *h, /* ISO 14443-4:2000(E) Section 5.2.5: * (256 * 16 / h->l2h->rh->ah->fc) * (2 ^ sfgi) */ + tmp = (unsigned int) 1000000 * 256 * 16; - return (1000000 * 256*16 / h->l2h->rh->ah->fc) * multiplier; + return (tmp / h->l2h->rh->ah->fc) * multiplier; } static unsigned int fwi_to_fwt(struct rfid_protocol_handle *h, unsigned char fwi) { - unsigned int multiplier; + unsigned int multiplier, tmp; if (fwi > 14) fwi = 14; @@ -66,10 +68,13 @@ static unsigned int fwi_to_fwt(struct rfid_protocol_handle *h, /* ISO 14443-4:2000(E) Section 7.2.: * (256*16 / h->l2h->rh->ah->fc) * (2 ^ fwi) */ - return (1000000 * 256*16 / h->l2h->rh->ah->fc) * multiplier; + tmp = (unsigned int) 1000000 * 256 * 16; + + return (tmp / h->l2h->rh->ah->fc) * multiplier; } -#define activation_fwt(x) (65536 / x->l2h->rh->ah->fc) +/* 4.9seconds as microseconds (4.9 billion seconds) exceeds 2^32 */ +#define activation_fwt(x) (((u_int64_t)1000000 * 65536 / x->l2h->rh->ah->fc)) #define deactivation_fwt(x) activation_fwt(x) static int diff --git a/rfid_reader.c b/rfid_reader.c index b39e0f8..61081bc 100644 --- a/rfid_reader.c +++ b/rfid_reader.c @@ -42,7 +42,7 @@ int rfid_reader_transcieve(struct rfid_reader_handle *rh, const unsigned char *tx_buf, unsigned int len, unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags) + u_int64_t timeout, unsigned int flags) { return rh->reader->transcieve(rh, tx_buf, len, rx_buf, rx_len, timeout, flags); diff --git a/rfid_reader_cm5121.c b/rfid_reader_cm5121.c index c8f13c5..7edadaf 100644 --- a/rfid_reader_cm5121.c +++ b/rfid_reader_cm5121.c @@ -174,7 +174,7 @@ static int TestFIFO(struct rc632_handle *handle) static int cm5121_transcieve(struct rfid_reader_handle *rh, const unsigned char *tx_data, unsigned int tx_len, unsigned char *rx_data, unsigned int *rx_len, - unsigned int timeout, unsigned int flags) + u_int64_t timeout, unsigned int flags) { return rh->ah->asic->priv.rc632.fn.transcieve(rh->ah, tx_data, tx_len, rx_data, @@ -299,6 +299,8 @@ struct rfid_reader rfid_reader_cm5121 = { .init = &cm5121_14443a_init, .transcieve_sf = &cm5121_transcieve_sf, .transcieve_acf = &cm5121_transcieve_acf, + .speed = RFID_READER_SPEED_106K | RFID_READER_SPEED_212K | + RFID_READER_SPEED_424K | RFID_READER_SPEED_848K, }, .iso14443b = { .init = &cm5121_14443b_init,