Interface: moteiv.tos.lib.Flash.BlockWrite

interface BlockWrite

Write interface for the block storage abstraction described in TEP103.

Author:
Jonathan Hui <jwhui@cs.berkeley.edu>

Commands
command result_t commit() Initiate a commit operation and finialize any additional writes to the volume.
command result_t erase() Initiate an erase operation.
command result_t write(block_addr_t addr, void *buf, block_addr_t len) Initiate a write operation within a given volume.

Events
event void commitDone(storage_result_t result) Signals the completion of a commit operation.
event void eraseDone(storage_result_t result) Signals the completion of an erase operation.
event void writeDone(storage_result_t result, block_addr_t addr, void *buf, block_addr_t len) Signals the completion of a read operation.

Commands - Details

commit

command result_t commit()

Initiate a commit operation and finialize any additional writes to the volume. A verify operation from BlockRead can be done to check if the data has been modified since. A commit operation must be issued to ensure that data is stored in non-volatile storage. On SUCCESS, the commitDone event will signal completion of the operation.

Returns:
SUCCESS if the request was accepted, FAIL otherwise.

erase

command result_t erase()

Initiate an erase operation. On SUCCESS, the eraseDone event will signal completion of the operation.

Returns:
SUCCESS if the request was accepted, FAIL otherwise.

write

command result_t write(block_addr_t addr, void *buf, block_addr_t len)

Initiate a write operation within a given volume. On SUCCESS, the writeDone event will signal completion of the operation.

Parameters:
addr - starting address to begin write.
buf - buffer to write data from.
len - number of bytes to write.
Returns:
SUCCESS if the request was accepted, FAIL otherwise.

Events - Details

commitDone

event void commitDone(storage_result_t result)

Signals the completion of a commit operation. All written data is flushed to non-volatile storage after this event.

Parameters:
result - notification of how the operation went.

eraseDone

event void eraseDone(storage_result_t result)

Signals the completion of an erase operation.

Parameters:
result - notification of how the operation went.

writeDone

event void writeDone(storage_result_t result, block_addr_t addr, void *buf, block_addr_t len)

Signals the completion of a read operation. However, data is not guaranteed to survive a power-cycle unless a commit operation has been completed.

Parameters:
addr - starting address of write.
buf - buffer that written data was read from.
len - number of bytes rwrite.
result - notification of how the operation went.