Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

transaction.h File Reference

Transaction declarations. More...

#include <types.h>

Go to the source code of this file.

Defines

#define TRANSAC_STATE_CLEAN   0x00
#define TRANSAC_STATE_DATA   0xA5
 Transaction buffer contains data. More...


Functions

bool ta_setdata (iu8 *data, iu8 len, iu16 dst)
 Begins a transaction and sets the data. More...

bool ta_commit (void)
 Commits the data in the transaction buffer. More...

bool ta_rollback (void)
 Do a rollback and discard the data in the transaction buffer. More...


Detailed Description

Transaction declarations.

Note:
Is the current transaction implementation secure against tearing? IMO it should be nearly be. Let's consider following scenarios:
1) Card is removed while writing the data for the transaction: This is no problem, because the state is still TRANSAC_STATE_CLEAN.

2) Card is removed while writing the status byte: This is most likely no problem. If the state is anything other than TRANSAC_STATE_DATA, it is regarded as clean, which it is. The only problem is, when it accidently is TRANSAC_STATE_DATA, which is IMO very unlikely, because the erased state is totally different. But on the other side, if the card tearing occured shortly after the state update, the state really is TRANSAC_STATE_DATA.

3) Card is removed while doing a commit and writing the data therein: This is no problem, because after the next reset the commit is tried again.

4) Card is removed after a commit, while reseting the status byte: This is no problem, because most likely the new state is interpreted as TRANSAC_STATE_CLEAN, which it is, and if the new state is really TRANSAC_STATE_DATA, it is just a second time written.

5) Card is removed while writing status byte in a rollback: This might be a problem, because the rollback might file, when the unlikely event occures, that the state is TRANSAC_STATE_DATA. But this can also happen, if the card is removed before the rollback, because the state is there already TRANSAC_STATE_DATA.

Id:
transaction.h,v 1.9 2002/12/22 15:42:56 m Exp


Define Documentation

#define TRANSAC_STATE_CLEAN   0x00
 

Transaction buffer is clean. (Also all other values not being 0xA5 are interpreted as clean.

#define TRANSAC_STATE_DATA   0xA5
 

Transaction buffer contains data.


Function Documentation

bool ta_commit void   
 

Commits the data in the transaction buffer.

Data is written to the destination specified in ta_setdata(). The state is then set to clean.

This function must be called after each reset to commit pending transactions.

Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool ta_rollback void   
 

Do a rollback and discard the data in the transaction buffer.

The state is set to clean.

Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool ta_setdata iu8   data,
iu8    len,
iu16    dst
 

Begins a transaction and sets the data.

data/len bytes are written to the transaction buffer. The destination address is also stored there. Then the state is set to TRANSAC_STATE_DATA.

Parameters:
data  Pointer to the data to write into the transaction buffer.
len  Length of the data. (Max.: TRANSAC_DATA_LEN)
dst  Destination of the data in EEPROM.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.


Copyright 2002 by Matthias Bruestle. This is licensed under the GNU General Public License.