[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/stm25p LogStorageC.nc,
1.1.2.2, 1.1.2.3 Stm25pLogConfigP.nc, NONE,
1.1.2.1 Stm25pLogP.nc, NONE, 1.1.2.1 BlockStorageC.nc, 1.1.2.8,
1.1.2.9 Stm25pBinderP.nc, 1.1.2.4, 1.1.2.5 Stm25pBlockP.nc,
1.1.2.7, 1.1.2.8 Stm25pSector.nc, 1.1.2.4,
1.1.2.5 Stm25pSectorC.nc, 1.1.2.7, 1.1.2.8 Stm25pSectorP.nc,
1.1.2.9, 1.1.2.10 Stm25pSpi.nc, 1.1.2.4, 1.1.2.5 Stm25pSpiC.nc,
1.1.2.5, 1.1.2.6 Stm25pSpiP.nc, 1.1.2.9,
1.1.2.10 Stm25pVolume.nc, 1.1.2.4, 1.1.2.5 StorageMap.nc,
1.1.2.3, 1.1.2.4 Storage_chip.h, 1.1.2.6, 1.1.2.7
Jonathan Hui
jwhui at users.sourceforge.net
Tue Jun 6 10:57:21 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30600
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
BlockStorageC.nc Stm25pBinderP.nc Stm25pBlockP.nc
Stm25pSector.nc Stm25pSectorC.nc Stm25pSectorP.nc Stm25pSpi.nc
Stm25pSpiC.nc Stm25pSpiP.nc Stm25pVolume.nc StorageMap.nc
Storage_chip.h
Added Files:
Tag: tinyos-2_0_devel-BRANCH
LogStorageC.nc Stm25pLogConfigP.nc Stm25pLogP.nc
Log Message:
Updates to stm25p storage stack.
Add LogStorage to implementation.
--- NEW FILE: Stm25pLogConfigP.nc ---
/**
* Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
* - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE
*/
/**
* @author Jonathan Hui <jhui at archrock.com>
* @version $Revision: 1.1.2.1 $ $Date: 2006/06/06 17:57:18 $
*/
generic module Stm25pLogConfigP( bool IS_CIRCULAR ) {
provides interface Get<bool> as Circular;
}
implementation {
command bool Circular.get() {
return IS_CIRCULAR;
}
}
--- NEW FILE: Stm25pLogP.nc ---
/**
* Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
* - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE
*/
/**
* @author Jonathan Hui <jhui at archrock.com>
* @version $Revision: 1.1.2.1 $ $Date: 2006/06/06 17:57:18 $
*/
#include <Stm25p.h>
module Stm25pLogP {
provides interface Init;
provides interface LogRead as Read[ uint8_t id ];
provides interface LogWrite as Write[ uint8_t id ];
uses interface Stm25pSector as Sector[ uint8_t id ];
uses interface Resource as ClientResource[ uint8_t id ];
uses interface Get<bool> as Circular[ uint8_t id ];
uses interface Leds;
}
implementation {
enum {
NUM_LOGS = uniqueCount( "Stm25p.Log" ),
BLOCK_SIZE = 4096,
BLOCK_SIZE_LOG2 = 12,
BLOCK_MASK = BLOCK_SIZE - 1,
BLOCKS_PER_SECTOR = STM25P_SECTOR_SIZE / BLOCK_SIZE,
MAX_RECORD_SIZE = 254,
INVALID_HEADER = 0xff,
};
typedef enum {
S_IDLE,
S_READ,
S_SEEK,
S_ERASE,
S_APPEND,
S_SYNC,
} stm25p_log_req_t;
typedef struct stm25p_log_state_t {
storage_cookie_t cookie;
void* buf;
uint8_t len;
stm25p_log_req_t req;
} stm25p_log_state_t;
typedef struct stm25p_log_info_t {
stm25p_addr_t read_addr;
stm25p_addr_t remaining;
stm25p_addr_t write_addr;
} stm25p_log_info_t;
stm25p_log_state_t m_log_state[ NUM_LOGS ];
stm25p_log_state_t m_req;
stm25p_log_info_t m_log_info[ NUM_LOGS ];
stm25p_addr_t m_addr;
uint8_t m_header;
uint8_t m_remaining;
uint8_t m_len;
typedef enum {
S_SEARCH_BLOCKS,
S_SEARCH_RECORDS,
S_SEARCH_SEEK,
S_HEADER,
S_DATA,
} stm25p_log_rw_state_t;
stm25p_log_rw_state_t m_rw_state;
error_t newRequest( uint8_t client );
void continueReadOp( uint8_t client );
void continueAppendOp( uint8_t client );
void signalDone( uint8_t id, error_t error );
command error_t Init.init() {
int i;
for ( i = 0; i < NUM_LOGS; i++ ) {
m_log_info[ i ].read_addr = STM25P_INVALID_ADDRESS;
m_log_info[ i ].write_addr = 0;
}
return SUCCESS;
}
command error_t Read.read[ uint8_t id ]( void* buf, storage_len_t len ) {
m_req.req = S_READ;
m_req.buf = buf;
m_req.len = len;
m_len = len;
return newRequest( id );
}
command error_t Read.seek[ uint8_t id ]( storage_addr_t cookie ) {
if ( cookie > m_log_info[ id ].write_addr )
return FAIL;
m_req.req = S_SEEK;
m_req.cookie = cookie;
return newRequest( id );
}
command storage_cookie_t Read.currentOffset[ uint8_t id ]() {
return m_log_info[ id ].read_addr;
}
command storage_cookie_t Read.getSize[ uint8_t id ]() {
return ( (storage_len_t)call Sector.getNumSectors[ id ]()
<< STM25P_SECTOR_SIZE_LOG2 );
}
command storage_cookie_t Write.currentOffset[ uint8_t id ]() {
return m_log_info[ id ].write_addr;
}
command error_t Write.erase[ uint8_t id ]() {
m_req.req = S_ERASE;
return newRequest( id );
}
command error_t Write.append[ uint8_t id ]( void* buf, storage_len_t len ) {
uint16_t bytes_left = (uint16_t)m_log_info[ id ].write_addr % BLOCK_SIZE;
bytes_left = BLOCK_SIZE - bytes_left;
// don't allow appends larger than maximum record size
if ( len > MAX_RECORD_SIZE )
return ESIZE;
// move to next block if current block doesn't have enough space
if ( sizeof( m_header ) + len > bytes_left )
m_log_info[ id ].write_addr += bytes_left;
// if log is not circular, make sure it doesn't grow too large
if ( !call Circular.get[ id ]() &&
( (uint8_t)(m_log_info[ id ].write_addr >> STM25P_SECTOR_SIZE_LOG2) >=
call Sector.getNumSectors[ id ]() ) )
return ESIZE;
m_req.req = S_APPEND;
m_req.buf = buf;
m_req.len = len;
return newRequest( id );
}
command error_t Write.sync[ uint8_t id ]() {
m_req.req = S_SYNC;
return newRequest( id );
}
error_t newRequest( uint8_t client ) {
if ( m_log_state[ client ].req != S_IDLE )
return FAIL;
call ClientResource.request[ client ]();
m_log_state[ client ] = m_req;
return SUCCESS;
}
event void ClientResource.granted[ uint8_t id ]() {
// log never used, need to find start and end of log
if ( m_log_info[ id ].read_addr == STM25P_INVALID_ADDRESS &&
m_log_state[ id ].req != S_ERASE ) {
m_rw_state = S_SEARCH_BLOCKS;
call Sector.read[ id ]( 0, (uint8_t*)&m_addr, sizeof( m_addr ) );
}
// start and end of log known, do the requested operation
else {
switch( m_log_state[ id ].req ) {
case S_READ:
m_rw_state = (m_log_info[ id ].remaining) ? S_DATA : S_HEADER;
continueReadOp( id );
break;
case S_SEEK:
{
// make sure the cookie is still within the range of valid data
uint8_t numSectors = call Sector.getNumSectors[ id ]();
uint8_t readSector =
(m_log_state[ id ].cookie >> STM25P_SECTOR_SIZE_LOG2);
uint8_t writeSector =
((m_log_info[ id ].write_addr-1)>>STM25P_SECTOR_SIZE_LOG2)+1;
// if cookie is overwritten, advance to beginning of log
if ( (writeSector - readSector) > numSectors ) {
m_log_state[ id ].cookie =
(storage_cookie_t)(writeSector-numSectors)
<<STM25P_SECTOR_SIZE_LOG2;
}
m_log_info[ id ].read_addr = m_log_state[ id ].cookie & BLOCK_MASK;
m_log_info[ id ].remaining = 0;
m_rw_state = S_SEARCH_SEEK;
if ( m_log_info[ id ].read_addr != m_log_state[ id ].cookie )
call Sector.read[ id ]( m_log_info[ id ].read_addr, &m_header,
sizeof( m_header ) );
else
signalDone( id, SUCCESS );
}
break;
case S_ERASE:
call Sector.erase[ id ]( 0, call Sector.getNumSectors[ id ]() );
break;
case S_APPEND:
m_rw_state = S_HEADER;
continueAppendOp( id );
break;
case S_SYNC:
signalDone( id, SUCCESS );
break;
case S_IDLE:
break;
}
}
}
uint8_t calcSector( uint8_t client, stm25p_addr_t addr ) {
uint8_t sector = call Sector.getNumSectors[ client ]();
return (uint8_t)( addr >> STM25P_SECTOR_SIZE_LOG2 ) % sector;
}
stm25p_addr_t calcAddr( uint8_t client, stm25p_addr_t addr ) {
stm25p_addr_t result = calcSector( client, addr );
result <<= STM25P_SECTOR_SIZE_LOG2;
result |= addr & STM25P_SECTOR_MASK;
return result;
}
void continueReadOp( uint8_t client ) {
stm25p_addr_t read_addr = m_log_info[ client ].read_addr;
uint8_t* buf;
uint8_t len;
// check if all done
if ( m_len == 0 || read_addr >= m_log_info[ client ].write_addr ) {
signalDone( client, SUCCESS );
return;
}
buf = &m_header;
len = sizeof( len );
if ( m_rw_state == S_DATA ) {
// if header is invalid, move to next block
if ( m_header == INVALID_HEADER ) {
m_rw_state = S_HEADER;
read_addr += BLOCK_SIZE;
read_addr &= ~BLOCK_MASK;
}
else {
buf = m_log_state[ client ].buf;
// truncate if record is shorter than requested length
if ( m_remaining < m_len )
m_log_state[ client ].len = m_remaining;
len = m_len;
}
}
// if on block boundary
if ( !((uint16_t)read_addr & BLOCK_MASK ) )
read_addr += sizeof( storage_addr_t );
m_log_info[ client ].read_addr = read_addr;
call Sector.read[ client ]( calcAddr( client, read_addr ), buf, len );
}
event void Sector.readDone[ uint8_t id ]( stm25p_addr_t addr, uint8_t* buf,
stm25p_len_t len, error_t error ) {
stm25p_log_info_t* log_info = &m_log_info[ id ];
// searching for the first and last log blocks
switch( m_rw_state ) {
case S_SEARCH_BLOCKS:
{
uint8_t block = addr >> BLOCK_SIZE_LOG2;
// record potential starting and ending addresses
if ( m_addr != STM25P_INVALID_ADDRESS ) {
if ( m_addr < log_info->read_addr )
log_info->read_addr = m_addr;
if ( m_addr > log_info->write_addr )
log_info->write_addr = m_addr;
}
// move on to next log block
if ( (uint16_t)m_addr == 0 &&
++block < (call Sector.getNumSectors[ id ]()*BLOCKS_PER_SECTOR)) {
addr += BLOCK_SIZE;
call Sector.read[ id ]( addr, (uint8_t*)&m_addr, sizeof( m_addr ) );
}
// if log is empty, continue operation
else if ( log_info->read_addr == STM25P_INVALID_ADDRESS ) {
log_info->read_addr = 0;
log_info->write_addr = 0;
signal ClientResource.granted[ id ]();
}
// search for last record
else {
log_info->write_addr += sizeof( m_addr );
m_rw_state = S_SEARCH_RECORDS;
call Sector.read[ id ]( log_info->write_addr, &m_header,
sizeof( m_header ) );
}
}
break;
case S_SEARCH_RECORDS:
{
// searching for the last log record to write
uint16_t cur_block = log_info->write_addr >> BLOCK_SIZE_LOG2;
uint16_t new_block = ( log_info->write_addr + sizeof( m_header ) +
m_header ) >> BLOCK_SIZE_LOG2;
// if header is valid and is on same block, move to next record
if ( m_header != INVALID_HEADER && cur_block == new_block ) {
log_info->write_addr += sizeof( m_header ) + m_header;
call Sector.read[ id ]( log_info->write_addr, &m_header,
sizeof( m_header ) );
}
// found last record
else {
signal ClientResource.granted[ id ]();
}
}
break;
case S_SEARCH_SEEK:
{
// searching for last log record to read
log_info->read_addr += sizeof( m_header ) + m_header;
// if not yet at cookie, keep searching
if ( log_info->read_addr < m_log_state->cookie ) {
call Sector.read[ id ]( log_info->read_addr, &m_header,
sizeof( m_header ) );
}
// at or passed cookie, stop
else {
log_info->remaining = log_info->read_addr - m_log_state[ id ].cookie;
log_info->read_addr = m_log_state[ id ].cookie;
signalDone( id, error );
}
}
break;
case S_HEADER:
{
// if header is invalid, move to next block
if ( m_header == INVALID_HEADER ) {
log_info->read_addr += BLOCK_SIZE;
log_info->read_addr &= ~BLOCK_MASK;
}
else {
log_info->read_addr += sizeof( m_header );
log_info->remaining = m_header;
m_rw_state = S_DATA;
}
continueReadOp( id );
}
break;
case S_DATA:
{
log_info->read_addr += len;
log_info->remaining -= len;
m_len -= len;
m_rw_state = S_HEADER;
continueReadOp( id );
break;
}
}
}
void continueAppendOp( uint8_t client ) {
stm25p_addr_t write_addr = m_log_info[ client ].write_addr;
uint8_t* buf;
uint8_t len;
if ( !(uint16_t)write_addr ) {
call Sector.erase[ client ]( calcSector( client, write_addr ), 1 );
}
else {
if ( m_rw_state == S_HEADER ) {
buf = &m_log_state[ client ].len;
len = sizeof( m_log_state[ client ].len );
}
else {
buf = m_log_state[ client ].buf;
len = m_log_state[ client ].len;
}
call Sector.write[ client ]( calcAddr( client, write_addr ), buf, len );
}
}
event void Sector.eraseDone[ uint8_t id ]( uint8_t sector,
uint8_t num_sectors,
error_t error ) {
if ( m_log_state[ id ].req == S_ERASE ) {
m_log_info[ id ].read_addr = 0;
m_log_info[ id ].write_addr = 0;
signalDone( id, error );
}
else {
// advance read pointer if write pointer has gone too far ahead
// (the log could have cycled around)
stm25p_addr_t volume_size =
STM25P_SECTOR_SIZE * ( call Sector.getNumSectors[ id ]() - 1 );
if ( m_log_info[ id ].write_addr >= volume_size ) {
stm25p_addr_t read_addr = m_log_info[ id ].write_addr - volume_size;
if ( m_log_info[ id ].read_addr < read_addr )
m_log_info[ id ].read_addr = read_addr;
}
m_addr = m_log_info[ id ].write_addr;
call Sector.write[ id ]( calcAddr( id, m_addr ), (uint8_t*)&m_addr,
sizeof( m_addr ) );
}
}
event void Sector.writeDone[ uint8_t id ]( storage_addr_t addr,
uint8_t* buf,
storage_len_t len,
error_t error ) {
m_log_info[ id ].write_addr += len;
if ( m_rw_state == S_HEADER ) {
if ( len == sizeof( m_header ) )
m_rw_state = S_DATA;
continueAppendOp( id );
}
else {
signalDone( id, error );
}
}
void signalDone( uint8_t id, error_t error ) {
stm25p_log_req_t req = m_log_state[ id ].req;
void* buf = m_log_state[ id ].buf;
storage_len_t len = m_log_state[ id ].len;
call ClientResource.release[ id ]();
m_log_state[ id ].req = S_IDLE;
switch( req ) {
case S_IDLE:
break;
case S_READ:
signal Read.readDone[ id ]( buf, len - m_len, error );
break;
case S_SEEK:
signal Read.seekDone[ id ]( error );
break;
case S_ERASE:
signal Write.eraseDone[ id ]( error );
break;
case S_APPEND:
signal Write.appendDone[ id ]( buf, len, error );
break;
case S_SYNC:
signal Write.syncDone[ id ]( error );
break;
}
}
event void Sector.computeCrcDone[ uint8_t id ]( stm25p_addr_t addr, stm25p_len_t len, uint16_t crc, error_t error ) {}
default event void Read.readDone[ uint8_t id ]( void* data, storage_len_t len, error_t error ) {}
default event void Read.seekDone[ uint8_t id ]( error_t error ) {}
default event void Write.eraseDone[ uint8_t id ]( error_t error ) {}
default event void Write.appendDone[ uint8_t id ]( void* data, storage_len_t len, error_t error ) {}
default event void Write.syncDone[ uint8_t id ]( error_t error ) {}
default command storage_addr_t Sector.getPhysicalAddress[ uint8_t id ]( storage_addr_t addr ) { return 0xffffffff; }
default command uint8_t Sector.getNumSectors[ uint8_t id ]() { return 0; }
default command error_t Sector.read[ uint8_t id ]( storage_addr_t addr, uint8_t* buf, storage_len_t len ) { return FAIL; }
default command error_t Sector.write[ uint8_t id ]( storage_addr_t addr, uint8_t* buf, storage_len_t len ) { return FAIL; }
default command error_t Sector.erase[ uint8_t id ]( uint8_t sector, uint8_t num_sectors ) { return FAIL; }
default command error_t Sector.computeCrc[ uint8_t id ]( uint16_t crc, storage_addr_t addr, storage_len_t len ) { return FAIL; }
default async command error_t ClientResource.request[ uint8_t id ]() { return FAIL; }
default async command void ClientResource.release[ uint8_t id ]() {}
default command bool Circular.get[ uint8_t id ]() { return FALSE; }
}
Index: BlockStorageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/BlockStorageC.nc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** BlockStorageC.nc 14 Feb 2006 17:01:43 -0000 1.1.2.8
--- BlockStorageC.nc 6 Jun 2006 17:57:18 -0000 1.1.2.9
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 34,38 ****
* ST M25P serial code flash.
*
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 34,38 ----
* ST M25P serial code flash.
*
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
Index: Stm25pBinderP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pBinderP.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** Stm25pBinderP.nc 28 Jan 2006 01:39:30 -0000 1.1.2.4
--- Stm25pBinderP.nc 6 Jun 2006 17:57:18 -0000 1.1.2.5
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 31,35 ****
/**
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 31,35 ----
/**
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
Index: Stm25pBlockP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pBlockP.nc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** Stm25pBlockP.nc 2 Jun 2006 15:43:30 -0000 1.1.2.7
--- Stm25pBlockP.nc 6 Jun 2006 17:57:18 -0000 1.1.2.8
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 31,35 ****
/**
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 31,35 ----
/**
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
***************
*** 37,46 ****
module Stm25pBlockP {
! provides interface BlockRead as Read[ storage_block_t block ];
! provides interface BlockWrite as Write[ storage_block_t block ];
! provides interface StorageMap[ storage_block_t block ];
! uses interface Stm25pSector as Sector[ storage_block_t block ];
! uses interface Resource as ClientResource[ storage_block_t block ];
uses interface Leds;
--- 37,46 ----
module Stm25pBlockP {
! provides interface BlockRead as Read[ uint8_t id ];
! provides interface BlockWrite as Write[ uint8_t id ];
! provides interface StorageMap[ uint8_t id ];
! uses interface Stm25pSector as Sector[ uint8_t id ];
! uses interface Resource as ClientResource[ uint8_t id ];
uses interface Leds;
***************
*** 74,135 ****
error_t newRequest( uint8_t client );
! void signalDone( storage_block_t b, uint16_t crc, error_t error );
!
! command storage_addr_t StorageMap.getPhysicalAddress[ storage_block_t b ]( storage_addr_t addr ) {
! return call Sector.getPhysicalAddress[ b ]( addr );
}
! command storage_len_t Read.getSize[ storage_block_t b ]() {
! return ( (storage_len_t)call Sector.getNumSectors[ b ]()
<< STM25P_SECTOR_SIZE_LOG2 );
}
! command error_t Read.read[ storage_block_t b ]( storage_addr_t addr,
! void* buf,
! storage_len_t len ) {
m_req.req = S_READ;
m_req.addr = addr;
m_req.buf = buf;
m_req.len = len;
! return newRequest( b );
}
! command error_t Read.verify[ storage_block_t b ]() {
m_req.req = S_VERIFY;
! return newRequest( b );
}
! command error_t Read.computeCrc[ storage_block_t b ]( storage_addr_t addr,
! storage_len_t len,
! uint16_t crc ) {
m_req.req = S_CRC;
m_req.addr = addr;
m_req.buf = (void*)crc;
m_req.len = len;
! return newRequest( b );
}
! command error_t Write.write[ storage_block_t b ]( storage_addr_t addr,
! void* buf,
! storage_len_t len ) {
m_req.req = S_WRITE;
m_req.addr = addr;
m_req.buf = buf;
m_req.len = len;
! return newRequest( b );
}
! command error_t Write.commit[ storage_block_t b ]() {
m_req.req = S_COMMIT;
! return newRequest( b );
}
! command error_t Write.erase[ storage_block_t b ]() {
m_req.req = S_ERASE;
! return newRequest( b );
}
! error_t newRequest( storage_block_t client ) {
!
if ( m_block_state[ client ].req != S_IDLE )
return FAIL;
--- 74,133 ----
error_t newRequest( uint8_t client );
! void signalDone( uint8_t id, uint16_t crc, error_t error );
!
! command storage_addr_t StorageMap.getPhysicalAddress[ uint8_t id ]( storage_addr_t addr ) {
! return call Sector.getPhysicalAddress[ id ]( addr );
}
! command storage_len_t Read.getSize[ uint8_t id ]() {
! return ( (storage_len_t)call Sector.getNumSectors[ id ]()
<< STM25P_SECTOR_SIZE_LOG2 );
}
! command error_t Read.read[ uint8_t id ]( storage_addr_t addr, void* buf,
! storage_len_t len ) {
m_req.req = S_READ;
m_req.addr = addr;
m_req.buf = buf;
m_req.len = len;
! return newRequest( id );
}
! command error_t Read.verify[ uint8_t id ]() {
m_req.req = S_VERIFY;
! return newRequest( id );
}
! command error_t Read.computeCrc[ uint8_t id ]( storage_addr_t addr,
! storage_len_t len,
! uint16_t crc ) {
m_req.req = S_CRC;
m_req.addr = addr;
m_req.buf = (void*)crc;
m_req.len = len;
! return newRequest( id );
}
! command error_t Write.write[ uint8_t id ]( storage_addr_t addr, void* buf,
! storage_len_t len ) {
m_req.req = S_WRITE;
m_req.addr = addr;
m_req.buf = buf;
m_req.len = len;
! return newRequest( id );
}
! command error_t Write.commit[ uint8_t id ]() {
m_req.req = S_COMMIT;
! return newRequest( id );
}
! command error_t Write.erase[ uint8_t id ]() {
m_req.req = S_ERASE;
! return newRequest( id );
}
! error_t newRequest( uint8_t client ) {
!
if ( m_block_state[ client ].req != S_IDLE )
return FAIL;
***************
*** 137,252 ****
call ClientResource.request[ client ]();
m_block_state[ client ] = m_req;
!
return SUCCESS;
!
}
!
! event void ClientResource.granted[ storage_block_t b ]() {
!
! switch( m_block_state[ b ].req ) {
case S_READ:
! call Sector.read[ b ]( m_block_state[ b ].addr, m_block_state[ b ].buf,
! m_block_state[ b ].len );
break;
case S_CRC:
! call Sector.computeCrc[ b ]( (uint16_t)m_block_state[ b ].buf,
! m_block_state[ b ].addr,
! m_block_state[ b ].len );
break;
case S_WRITE:
! call Sector.write[ b ]( m_block_state[ b ].addr, m_block_state[ b ].buf,
! m_block_state[ b ].len );
break;
case S_ERASE:
! call Sector.erase[ b ]( 0, call Sector.getNumSectors[ b ]() );
break;
case S_COMMIT: case S_VERIFY:
! signalDone( b, 0, SUCCESS );
break;
case S_IDLE:
break;
}
!
}
! event void Sector.readDone[ storage_block_t b ]( stm25p_addr_t addr,
! uint8_t* buf,
! stm25p_len_t len,
! error_t error ) {
! signalDone( b, 0, error );
}
! event void Sector.writeDone[ storage_block_t b ]( stm25p_addr_t addr,
! uint8_t* buf,
! stm25p_len_t len,
! error_t error ) {
! signalDone( b, 0, error );
}
! event void Sector.eraseDone[ storage_block_t b ]( uint8_t sector,
! uint8_t num_sectors,
! error_t error ) {
! signalDone( b, 0, error );
}
! event void Sector.computeCrcDone[ storage_block_t b ]( stm25p_addr_t addr,
! stm25p_len_t len,
! uint16_t crc,
! error_t error ) {
! signalDone( b, crc, error );
}
!
! void signalDone( storage_block_t b, uint16_t crc, error_t error ) {
!
! stm25p_block_req_t req = m_block_state[ b ].req;
!
! call ClientResource.release[ b ]();
! m_block_state[ b ].req = S_IDLE;
switch( req ) {
case S_READ:
! signal Read.readDone[ b ]( m_block_state[ b ].addr,
! m_block_state[ b ].buf,
! m_block_state[ b ].len, error );
break;
case S_VERIFY:
! signal Read.verifyDone[ b ]( error );
break;
case S_CRC:
! signal Read.computeCrcDone[ b ]( m_block_state[ b ].addr,
! m_block_state[ b ].len, crc, error );
break;
case S_WRITE:
! signal Write.writeDone[ b ]( m_block_state[ b ].addr,
! m_block_state[ b ].buf,
! m_block_state[ b ].len, error );
break;
case S_COMMIT:
! signal Write.commitDone[ b ]( error );
break;
case S_ERASE:
! signal Write.eraseDone[ b ]( error );
break;
case S_IDLE:
break;
}
!
}
!
! default event void Read.readDone[ storage_block_t b ]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {}
! default event void Read.computeCrcDone[ storage_block_t b ]( storage_addr_t addr, storage_len_t len, uint16_t crc, error_t error ) {}
! default event void Read.verifyDone[ storage_block_t b ]( error_t error ) {}
! default event void Write.writeDone[ storage_block_t b ]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {}
! default event void Write.eraseDone[ storage_block_t b ]( error_t error ) {}
! default event void Write.commitDone[ storage_block_t b ]( error_t error ) {}
!
! default command storage_addr_t Sector.getPhysicalAddress[ storage_block_t b ]( storage_addr_t addr ) { return 0xffffffff; }
! default command uint8_t Sector.getNumSectors[ storage_block_t b ]() { return 0; }
! default command error_t Sector.read[ storage_block_t b ]( stm25p_addr_t addr, uint8_t* buf, stm25p_len_t len ) { return FAIL; }
! default command error_t Sector.write[ storage_block_t b ]( stm25p_addr_t addr, uint8_t* buf, stm25p_len_t len ) { return FAIL; }
! default command error_t Sector.erase[ storage_block_t b ]( uint8_t sector, uint8_t num_sectors ) { return FAIL; }
! default command error_t Sector.computeCrc[ storage_block_t b ]( uint16_t crc, storage_addr_t addr, storage_len_t len ) { return FAIL; }
! default async command error_t ClientResource.request[ storage_block_t b ]() { return FAIL; }
! default async command void ClientResource.release[ storage_block_t b ]() {}
!
}
--- 135,248 ----
call ClientResource.request[ client ]();
m_block_state[ client ] = m_req;
!
return SUCCESS;
!
}
!
! event void ClientResource.granted[ uint8_t id ]() {
!
! switch( m_block_state[ id ].req ) {
case S_READ:
! call Sector.read[ id ]( m_block_state[ id ].addr,
! m_block_state[ id ].buf,
! m_block_state[ id ].len );
break;
case S_CRC:
! call Sector.computeCrc[ id ]( (uint16_t)m_block_state[ id ].buf,
! m_block_state[ id ].addr,
! m_block_state[ id ].len );
break;
case S_WRITE:
! call Sector.write[ id ]( m_block_state[ id ].addr,
! m_block_state[ id ].buf,
! m_block_state[ id ].len );
break;
case S_ERASE:
! call Sector.erase[ id ]( 0, call Sector.getNumSectors[ id ]() );
break;
case S_COMMIT: case S_VERIFY:
! signalDone( id, 0, SUCCESS );
break;
case S_IDLE:
break;
}
!
}
! event void Sector.readDone[ uint8_t id ]( stm25p_addr_t addr, uint8_t* buf,
! stm25p_len_t len, error_t error ) {
! signalDone( id, 0, error );
}
! event void Sector.writeDone[ uint8_t id ]( stm25p_addr_t addr, uint8_t* buf,
! stm25p_len_t len, error_t error ){
! signalDone( id, 0, error );
}
! event void Sector.eraseDone[ uint8_t id ]( uint8_t sector,
! uint8_t num_sectors,
! error_t error ) {
! signalDone( id, 0, error );
}
! event void Sector.computeCrcDone[ uint8_t id ]( stm25p_addr_t addr,
! stm25p_len_t len,
! uint16_t crc,
! error_t error ) {
! signalDone( id, crc, error );
}
!
! void signalDone( uint8_t id, uint16_t crc, error_t error ) {
!
! stm25p_block_req_t req = m_block_state[ id ].req;
!
! call ClientResource.release[ id ]();
! m_block_state[ id ].req = S_IDLE;
switch( req ) {
case S_READ:
! signal Read.readDone[ id ]( m_block_state[ id ].addr,
! m_block_state[ id ].buf,
! m_block_state[ id ].len, error );
break;
case S_VERIFY:
! signal Read.verifyDone[ id ]( error );
break;
case S_CRC:
! signal Read.computeCrcDone[ id ]( m_block_state[ id ].addr,
! m_block_state[ id ].len, crc, error );
break;
case S_WRITE:
! signal Write.writeDone[ id ]( m_block_state[ id ].addr,
! m_block_state[ id ].buf,
! m_block_state[ id ].len, error );
break;
case S_COMMIT:
! signal Write.commitDone[ id ]( error );
break;
case S_ERASE:
! signal Write.eraseDone[ id ]( error );
break;
case S_IDLE:
break;
}
!
}
!
! default event void Read.readDone[ uint8_t id ]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {}
! default event void Read.computeCrcDone[ uint8_t id ]( storage_addr_t addr, storage_len_t len, uint16_t crc, error_t error ) {}
! default event void Read.verifyDone[ uint8_t id ]( error_t error ) {}
! default event void Write.writeDone[ uint8_t id ]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {}
! default event void Write.eraseDone[ uint8_t id ]( error_t error ) {}
! default event void Write.commitDone[ uint8_t id ]( error_t error ) {}
!
! default command storage_addr_t Sector.getPhysicalAddress[ uint8_t id ]( storage_addr_t addr ) { return 0xffffffff; }
! default command uint8_t Sector.getNumSectors[ uint8_t id ]() { return 0; }
! default command error_t Sector.read[ uint8_t id ]( stm25p_addr_t addr, uint8_t* buf, stm25p_len_t len ) { return FAIL; }
! default command error_t Sector.write[ uint8_t id ]( stm25p_addr_t addr, uint8_t* buf, stm25p_len_t len ) { return FAIL; }
! default command error_t Sector.erase[ uint8_t id ]( uint8_t sector, uint8_t num_sectors ) { return FAIL; }
! default command error_t Sector.computeCrc[ uint8_t id ]( uint16_t crc, storage_addr_t addr, storage_len_t len ) { return FAIL; }
! default async command error_t ClientResource.request[ uint8_t id ]() { return FAIL; }
! default async command void ClientResource.release[ uint8_t id ]() {}
!
}
Index: Stm25pSector.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pSector.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** Stm25pSector.nc 14 Feb 2006 17:01:43 -0000 1.1.2.4
--- Stm25pSector.nc 6 Jun 2006 17:57:18 -0000 1.1.2.5
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 36,40 ****
* committed to non-volatile storage.
*
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 36,40 ----
* committed to non-volatile storage.
*
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
Index: Stm25pSectorC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pSectorC.nc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** Stm25pSectorC.nc 2 Jun 2006 17:23:49 -0000 1.1.2.7
--- Stm25pSectorC.nc 6 Jun 2006 17:57:18 -0000 1.1.2.8
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 34,38 ****
* serial code flash.
*
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 34,38 ----
* serial code flash.
*
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
***************
*** 40,46 ****
configuration Stm25pSectorC {
! provides interface Resource as ClientResource[ storage_volume_t volume ];
! provides interface Stm25pSector as Sector[ storage_volume_t volume ];
! provides interface Stm25pVolume as Volume[ storage_volume_t volume ];
}
--- 40,46 ----
configuration Stm25pSectorC {
! provides interface Resource as ClientResource[ uint8_t id ];
! provides interface Stm25pSector as Sector[ uint8_t id ];
! provides interface Stm25pVolume as Volume[ uint8_t id ];
}
Index: Stm25pSectorP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pSectorP.nc,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** Stm25pSectorP.nc 2 Jun 2006 17:23:49 -0000 1.1.2.9
--- Stm25pSectorP.nc 6 Jun 2006 17:57:18 -0000 1.1.2.10
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 31,35 ****
/**
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 31,35 ----
/**
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
***************
*** 41,49 ****
provides interface SplitControl;
! provides interface Resource as ClientResource[ storage_volume_t volume ];
! provides interface Stm25pSector as Sector[ storage_volume_t volume ];
! provides interface Stm25pVolume as Volume[ storage_volume_t volume ];
! uses interface Resource as Stm25pResource[ storage_volume_t volume ];
uses interface Resource as SpiResource;
uses interface Stm25pSpi as Spi;
--- 41,49 ----
provides interface SplitControl;
! provides interface Resource as ClientResource[ uint8_t id ];
! provides interface Stm25pSector as Sector[ uint8_t id ];
! provides interface Stm25pVolume as Volume[ uint8_t id ];
! uses interface Resource as Stm25pResource[ uint8_t id ];
uses interface Resource as SpiResource;
uses interface Stm25pSpi as Spi;
***************
*** 74,78 ****
norace stm25p_power_state_t m_power_state;
! norace storage_volume_t m_client;
norace stm25p_addr_t m_addr;
norace stm25p_len_t m_len;
--- 74,78 ----
norace stm25p_power_state_t m_power_state;
! norace uint8_t m_client;
norace stm25p_addr_t m_addr;
norace stm25p_len_t m_len;
***************
*** 100,122 ****
}
! async command error_t ClientResource.request[ storage_volume_t v ]() {
! return call Stm25pResource.request[ v ]();
}
! async command error_t ClientResource.immediateRequest[ storage_volume_t v ]() {
return FAIL;
}
! async command void ClientResource.release[ storage_volume_t v ]() {
! if ( m_client == v ) {
m_state = S_IDLE;
m_client = NO_CLIENT;
call SpiResource.release();
! call Stm25pResource.release[ v ]();
}
}
!
! event void Stm25pResource.granted[ storage_volume_t v ]() {
! m_client = v;
call SpiResource.request();
}
--- 100,122 ----
}
! async command error_t ClientResource.request[ uint8_t id ]() {
! return call Stm25pResource.request[ id ]();
}
! async command error_t ClientResource.immediateRequest[ uint8_t id ]() {
return FAIL;
}
! async command void ClientResource.release[ uint8_t id ]() {
! if ( m_client == id ) {
m_state = S_IDLE;
m_client = NO_CLIENT;
call SpiResource.release();
! call Stm25pResource.release[ id ]();
}
}
!
! event void Stm25pResource.granted[ uint8_t id ]() {
! m_client = id;
call SpiResource.request();
}
***************
*** 125,129 ****
return signal Volume.getVolumeId[ client ]();
}
!
event void SpiResource.granted() {
error_t error;
--- 125,129 ----
return signal Volume.getVolumeId[ client ]();
}
!
event void SpiResource.granted() {
error_t error;
***************
*** 144,173 ****
signal ClientResource.granted[ m_client ]();
}
!
! async command uint8_t ClientResource.isOwner[ storage_volume_t v ]() {
! return call Stm25pResource.isOwner[v]();
}
!
! stm25p_addr_t physicalAddr( storage_volume_t v, stm25p_addr_t addr ) {
! return addr + ( (stm25p_addr_t)STM25P_VMAP[ getVolumeId( v ) ].base
<< STM25P_SECTOR_SIZE_LOG2 );
}
!
stm25p_len_t calcWriteLen( stm25p_addr_t addr ) {
stm25p_len_t len = STM25P_PAGE_SIZE - ( addr & STM25P_PAGE_MASK );
return ( m_cur_len < len ) ? m_cur_len : len;
}
!
! command stm25p_addr_t Sector.getPhysicalAddress[ storage_volume_t v ]( stm25p_addr_t addr ) {
! return physicalAddr( v, addr );
}
! command uint8_t Sector.getNumSectors[ storage_volume_t v ]() {
! return STM25P_VMAP[ getVolumeId( v ) ].size;
}
!
! command error_t Sector.read[ storage_volume_t v ]( stm25p_addr_t addr,
! uint8_t* buf,
! stm25p_len_t len ) {
m_state = S_READ;
--- 144,172 ----
signal ClientResource.granted[ m_client ]();
}
!
! async command uint8_t ClientResource.isOwner[ uint8_t id ]() {
! return call Stm25pResource.isOwner[id]();
}
!
! stm25p_addr_t physicalAddr( uint8_t id, stm25p_addr_t addr ) {
! return addr + ( (stm25p_addr_t)STM25P_VMAP[ getVolumeId( id ) ].base
<< STM25P_SECTOR_SIZE_LOG2 );
}
!
stm25p_len_t calcWriteLen( stm25p_addr_t addr ) {
stm25p_len_t len = STM25P_PAGE_SIZE - ( addr & STM25P_PAGE_MASK );
return ( m_cur_len < len ) ? m_cur_len : len;
}
!
! command stm25p_addr_t Sector.getPhysicalAddress[ uint8_t id ]( stm25p_addr_t addr ) {
! return physicalAddr( id, addr );
}
! command uint8_t Sector.getNumSectors[ uint8_t id ]() {
! return STM25P_VMAP[ getVolumeId( id ) ].size;
}
!
! command error_t Sector.read[ uint8_t id ]( stm25p_addr_t addr, uint8_t* buf,
! stm25p_len_t len ) {
m_state = S_READ;
***************
*** 175,191 ****
m_buf = buf;
m_len = len;
!
! return call Spi.read( physicalAddr( v, addr ), buf, len );
!
}
!
async event void Spi.readDone( stm25p_addr_t addr, uint8_t* buf,
stm25p_len_t len, error_t error ) {
signalDone( error );
}
!
! command error_t Sector.write[ storage_volume_t v ]( stm25p_addr_t addr,
! uint8_t* buf,
! stm25p_len_t len ) {
m_state = S_WRITE;
--- 174,190 ----
m_buf = buf;
m_len = len;
!
! return call Spi.read( physicalAddr( id, addr ), buf, len );
!
}
!
async event void Spi.readDone( stm25p_addr_t addr, uint8_t* buf,
stm25p_len_t len, error_t error ) {
signalDone( error );
}
!
! command error_t Sector.write[ uint8_t id ]( stm25p_addr_t addr,
! uint8_t* buf,
! stm25p_len_t len ) {
m_state = S_WRITE;
***************
*** 193,200 ****
m_buf = buf;
m_len = m_cur_len = len;
!
! return call Spi.pageProgram( physicalAddr( v, addr ), buf,
calcWriteLen( addr ) );
!
}
--- 192,199 ----
m_buf = buf;
m_len = m_cur_len = len;
!
! return call Spi.pageProgram( physicalAddr( id, addr ), buf,
calcWriteLen( addr ) );
!
}
***************
*** 209,215 ****
call Spi.pageProgram( addr, buf, calcWriteLen( addr ) );
}
!
! command error_t Sector.erase[ storage_volume_t v ]( uint8_t sector,
! uint8_t num_sectors ) {
m_state = S_ERASE;
--- 208,214 ----
call Spi.pageProgram( addr, buf, calcWriteLen( addr ) );
}
!
! command error_t Sector.erase[ uint8_t id ]( uint8_t sector,
! uint8_t num_sectors ) {
m_state = S_ERASE;
***************
*** 218,222 ****
m_cur_len = 0;
! return call Spi.sectorErase( STM25P_VMAP[ getVolumeId(v) ].base + m_addr +
m_cur_len );
--- 217,221 ----
m_cur_len = 0;
! return call Spi.sectorErase( STM25P_VMAP[ getVolumeId(id) ].base + m_addr +
m_cur_len );
***************
*** 231,242 ****
}
! command error_t Sector.computeCrc[ storage_volume_t v ]( uint16_t crc,
! stm25p_addr_t addr,
! stm25p_len_t len ) {
m_state = S_CRC;
m_addr = addr;
m_len = len;
!
return call Spi.computeCrc( crc, m_addr, m_len );
--- 230,241 ----
}
! command error_t Sector.computeCrc[ uint8_t id ]( uint16_t crc,
! stm25p_addr_t addr,
! stm25p_len_t len ) {
m_state = S_CRC;
m_addr = addr;
m_len = len;
!
return call Spi.computeCrc( crc, m_addr, m_len );
***************
*** 280,291 ****
}
}
!
! default event void ClientResource.granted[ storage_volume_t v ]() {}
! default event void Sector.readDone[ storage_volume_t v ]( stm25p_addr_t addr, uint8_t* buf, stm25p_len_t len, error_t error ) {}
! default event void Sector.writeDone[ storage_volume_t v ]( stm25p_addr_t addr, uint8_t* buf, stm25p_len_t len, error_t error ) {}
! default event void Sector.eraseDone[ storage_volume_t v ]( uint8_t sector, uint8_t num_sectors, error_t error ) {}
! default event void Sector.computeCrcDone[ storage_volume_t v ]( stm25p_addr_t addr, stm25p_len_t len, uint16_t crc, error_t error ) {}
! default async event volume_id_t Volume.getVolumeId[ storage_volume_t v ]() { return 0xff; }
!
}
--- 279,290 ----
}
}
!
! default event void ClientResource.granted[ uint8_t id ]() {}
! default event void Sector.readDone[ uint8_t id ]( stm25p_addr_t addr, uint8_t* buf, stm25p_len_t len, error_t error ) {}
! default event void Sector.writeDone[ uint8_t id ]( stm25p_addr_t addr, uint8_t* buf, stm25p_len_t len, error_t error ) {}
! default event void Sector.eraseDone[ uint8_t id ]( uint8_t sector, uint8_t num_sectors, error_t error ) {}
! default event void Sector.computeCrcDone[ uint8_t id ]( stm25p_addr_t addr, stm25p_len_t len, uint16_t crc, error_t error ) {}
! default async event volume_id_t Volume.getVolumeId[ uint8_t id ]() { return 0xff; }
!
}
Index: Stm25pSpi.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pSpi.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** Stm25pSpi.nc 15 Mar 2006 16:49:55 -0000 1.1.2.4
--- Stm25pSpi.nc 6 Jun 2006 17:57:18 -0000 1.1.2.5
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 33,37 ****
* SPI abstraction for the ST M25P family of serial code flash chips.
*
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 33,37 ----
* SPI abstraction for the ST M25P family of serial code flash chips.
*
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
Index: Stm25pSpiC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pSpiC.nc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** Stm25pSpiC.nc 7 Feb 2006 19:43:02 -0000 1.1.2.5
--- Stm25pSpiC.nc 6 Jun 2006 17:57:18 -0000 1.1.2.6
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 34,38 ****
* code flash.
*
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 34,38 ----
* code flash.
*
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
Index: Stm25pSpiP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pSpiP.nc,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** Stm25pSpiP.nc 2 Jun 2006 17:23:49 -0000 1.1.2.9
--- Stm25pSpiP.nc 6 Jun 2006 17:57:18 -0000 1.1.2.10
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 31,35 ****
/**
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 31,35 ----
/**
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
Index: Stm25pVolume.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Stm25pVolume.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** Stm25pVolume.nc 14 Feb 2006 17:01:43 -0000 1.1.2.4
--- Stm25pVolume.nc 6 Jun 2006 17:57:18 -0000 1.1.2.5
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 33,37 ****
* Abstraction to provide the id of a volume.
*
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 33,37 ----
* Abstraction to provide the id of a volume.
*
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
Index: StorageMap.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/StorageMap.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** StorageMap.nc 28 Jan 2006 01:39:30 -0000 1.1.2.3
--- StorageMap.nc 6 Jun 2006 17:57:18 -0000 1.1.2.4
***************
*** 1,4 ****
/**
! * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
--- 1,4 ----
/**
! * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
***************
*** 12,16 ****
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
--- 12,16 ----
* documentation and/or other materials provided with the
* distribution.
! * - Neither the name of the Arch Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
***************
*** 33,37 ****
* An abstraction to map volume addresses to physical addresses.
*
! * @author Jonathan Hui <jhui at archedrock.com>
* @version $Revision$ $Date$
*/
--- 33,37 ----
* An abstraction to map volume addresses to physical addresses.
*
! * @author Jonathan Hui <jhui at archrock.com>
* @version $Revision$ $Date$
*/
Index: Storage_chip.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/stm25p/Attic/Storage_chip.h,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** Storage_chip.h 2 Jun 2006 17:23:49 -0000 1.1.2.6
--- Storage_chip.h 6 Jun 2006 17:57:18 -0000 1.1.2.7
***************
*** 36,42 ****
#define __STORAGE_CHIP_H__
- typedef uint8_t storage_volume_t;
- typedef uint8_t storage_block_t;
- typedef uint8_t storage_log_t;
-
#endif
--- 36,38 ----
More information about the Tinyos-2-commits
mailing list