[Tinyos-beta-commits] CVS: tinyos-1.x/beta/AT45DB AT45Remap.nc, NONE, 1.1 HALAT45DBShare.nc, NONE, 1.1 Mount.nc, NONE, 1.1 StorageManagerC.nc, NONE, 1.1 StorageManagerM.nc, NONE, 1.1 issues, NONE, 1.1 BlockStorageC.nc, 1.1, 1.2 BlockStorageM.nc, 1.1, 1.2 HALAT45DB.nc, 1.1, 1.2 HALAT45DBC.nc, 1.1, 1.2 HALAT45DBM.nc, 1.1, 1.2 HPLAT45DB.nc, 1.1, 1.2 HPLAT45DBByte.nc, 1.1, 1.2

David Gay idgay at users.sourceforge.net
Wed Feb 2 14:56:45 PST 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/AT45DB
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29796

Modified Files:
	BlockStorageC.nc BlockStorageM.nc HALAT45DB.nc HALAT45DBC.nc 
	HALAT45DBM.nc HPLAT45DB.nc HPLAT45DBByte.nc 
Added Files:
	AT45Remap.nc HALAT45DBShare.nc Mount.nc StorageManagerC.nc 
	StorageManagerM.nc issues 
Log Message:
updates to HAL
add dummy storage manager
update block storage to use storage manager



--- NEW FILE: AT45Remap.nc ---
includes HALAT45DB;
interface AT45Remap {
  /* Returns AT45_MAX_PAGES for invalid request (out of volume) */
  command at45page_t remap(volume_t volume, at45page_t volumePage);
}

--- NEW FILE: HALAT45DBShare.nc ---
// $Id: HALAT45DBShare.nc,v 1.1 2005/02/02 22:56:40 idgay Exp $

/*									tab:4
 * "Copyright (c) 2000-2003 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 * Copyright (c) 2002-2003 Intel Corporation
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached INTEL-LICENSE     
 * file. If you do not find these files, copies can be found by writing to
 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
 * 94704.  Attention:  Intel License Inquiry.
 */
/**
 * Provide simple multi-client access to HALAT45DB volumes:
 * - does request-response matching (per-volume), i.e., you only get events
 *   for commands on the volume you're using (normally only one user per
 *   volume)
 * - does page remapping so you can use volume-relative page numbers
 */
module HALAT45DBShare {
  provides interface HALAT45DB[volume_t volume];
  uses interface HALAT45DB as ActualAT45;
  uses interface AT45Remap;
}
implementation {
  enum {
    NCLIENTS = uniqueCount(UQ_STORAGE_VOLUME)
  };
  volume_t lastClient;

  // Read & write the client id. We special case the 1-client case to
  // eliminate the overhead (still costs 1 byte of ram, though)
  int setClient(volume_t client) {
    if (NCLIENTS != 1)
      {
	if (lastClient)
	  return FALSE;
	lastClient = client + 1;
      }
    return TRUE;
  }

  volume_t getClient() {
    volume_t id = 0;

    if (NCLIENTS != 1)
      {
	id = lastClient - 1;
	lastClient = 0;
      }

    return id;
  }

  inline at45page_t remap(at45page_t page) {
    if (NCLIENTS != 1)
      return call AT45Remap(lastClient, page);
    else
      return call AT45Remap(0, page);
  }

  /* Clear client if request failed. */
  result_t check(result_t requestOk) {
    if (requestOk != FAIL)
      return requestOk;
    lastClient = 0;
    return FAIL;
  }

  // Simply use the setClient, getClient functions to match requests &
  // responses. The inline reduces the overhead of this layer.
  inline command result_t HALAT45DB.write[volume_t client](at45page_t page, at45pageoffset_t offset,
							   void *data, at45pageoffset_t n) {
    if (!setClient(client))
      return FAIL;
    return check(call ActualAT45.write(remap(page), offset, data, n));
  }

  inline event result_t ActualAT45.writeDone(result_t result) {
    return signal HALAT45DB.writeDone[getClient()](result);
  }

  inline command result_t HALAT45DB.erase[volume_t client](at45page_t page, uint8_t eraseKind) {
    if (!setClient(client))
      return FAIL;
    return check(call ActualAT45.erase(remap(page), eraseKind));
  }

  inline event result_t ActualAT45.eraseDone(result_t result) {
    return signal HALAT45DB.eraseDone[getClient()](result);
  }

  inline command result_t HALAT45DB.sync[volume_t client](at45page_t page) {
    if (!setClient(client))
      return FAIL;
    return check(call ActualAT45.sync(page));
  }

  inline command result_t HALAT45DB.syncAll[volume_t client]() {
    if (!setClient(client))
      return FAIL;
    return check(call ActualAT45.syncAll());
  }

  inline event result_t ActualAT45.syncDone(result_t result) {
    return signal HALAT45DB.syncDone[getClient()](result);
  }

  inline command result_t HALAT45DB.flush[volume_t client](at45page_t page) {
    if (!setClient(client))
      return FAIL;
    return check(call ActualAT45.flush(remap(page)));
  }

  inline command result_t HALAT45DB.flushAll[volume_t client]() {
    if (!setClient(client))
      return FAIL;
    return check(call ActualAT45.flushAll());
  }

  inline event result_t ActualAT45.flushDone(result_t result) {
    return signal HALAT45DB.flushDone[getClient()](result);
  }

  inline command result_t HALAT45DB.read[volume_t client](at45page_t page, at45pageoffset_t offset,
							  void *data, at45pageoffset_t n) {
    if (!setClient(client))
      return FAIL;
    return check(call ActualAT45.read(remap(page), offset, data, n));
  }

  inline event result_t ActualAT45.readDone(result_t result) {
    return signal HALAT45DB.readDone[getClient()](result);
  }

  inline command result_t HALAT45DB.computeCrc[volume_t client](at45page_t page, at45pageoffset_t offset,
								at45pageoffset_t n) {
    if (!setClient(client))
      return FAIL;
    return check(call ActualAT45.computeCrc(remap(page), offset, n));
  }

  inline event result_t ActualAT45.computeCrcDone(result_t result, uint16_t crc) {
    return signal HALAT45DB.computeCrcDone[getClient()](result, crc);
  }
  
  default event result_t HALAT45DB.writeDone[volume_t client](result_t result) {
    return FAIL;
  }

  default event result_t HALAT45DB.eraseDone[volume_t client](result_t result) {
    return FAIL;
  }

  default event result_t HALAT45DB.syncDone[volume_t client](result_t result) {
    return FAIL;
  }

  default event result_t HALAT45DB.flushDone[volume_t client](result_t result) {
    return FAIL;
  }

  default event result_t HALAT45DB.readDone[volume_t client](result_t result) {
    return FAIL;
  }

  default event result_t HALAT45DB.computeCrcDone[volume_t client](result_t result, uint16_t crc) {
    return FAIL;
  }
}

--- NEW FILE: Mount.nc ---
includes Storage;
interface Mount 
{
  command result_t mount(volume_id_t id);
  event void mountDone(storage_result_t result, volume_id_t id);
}

--- NEW FILE: StorageManagerC.nc ---
configuration StorageManagerC {
  provides {
    interface StdControl;
    interface Mount[volume_t volume];
    interface HALAT45DB[volume_t volume];
  }
}
implementation {
  components StorageManagerM, HALAT45DBC, HALAT45DBShare;

  StdControl = StorageManagerM;
  StdControl = HALAT45DBC;
  Mount = StorageManagerM;
  HALAT45DBC = HALAT45DBShare;

  HALAT45DBShare.ActualAT45 -> HALAT45DBC;
  HALAT45DBShare.AT45Remap -> StorageManagerM;
}

--- NEW FILE: StorageManagerM.nc ---
module StorageManagerM {
  provides {
    interface StdControl;
    interface Mount[volume_t volume];
    interface AT45Remap[volume_t volume];
  }
}
implementation {
  volume_t client;
  volume_id_t id;

  command result_t StdControl.init() {
    return SUCCESS;
  }

  command result_t StdControl.start() {
    return SUCCESS;
  }

  command result_t StdControl.stop() {
    return SUCCESS;
  }

  task void mounted() {
    signal Mount.mountDone[client](STORAGE_OK, id);
  }

  command result_t Mount.mount[volume_t v](volume_id_t i) {
    client = v;
    id = i;
    post mounted();
    return SUCCESS;
  }

  command at45page_t AT45Remap.remap[volume_t volume](volume_t volume, at45page_t volumePage) {
    if (volume == 0)
      return volumePage;
    else
      return volumePage + 1024;
  }
}

--- NEW FILE: issues ---
- unmount/remount

- block storage needs to track max addr written. should read check this
  (my answer no: it's a very partial check as you can still read lots of
  data that was never written)

- notes for block storage: if any write fails, the whole block must be
  considered invalid (do not commit, cannot retry. not enforced)
  reason: failure may corrupt data from earlier write

- 0 byte r/w/etc ops? allow or fail?


- config storage:
  - when does a "transaction" start? first write, presumably.
    do we want an explict start op?
  - what does a read after some writes but before a commit do?
    o return the new data (but no guarantee of validity?)
    o return the old data
  - behaviour on corrupt data found? (assume "empty"?)

  - is the common model an update to part of the config data, or a complete
    rewrite? or both? (if the latter, maybe a start w/ a "new" vs "copy"
    argument would be useful?)



Index: BlockStorageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/AT45DB/BlockStorageC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BlockStorageC.nc	22 Jan 2005 00:26:30 -0000	1.1
--- BlockStorageC.nc	2 Feb 2005 22:56:39 -0000	1.2
***************
*** 1,57 ****
  // $Id$
! 
! /*									tab:4
!  * "Copyright (c) 2000-2004 The Regents of the University  of California.  
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  * 
!  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
!  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  * 
!  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
!  */
! 
! /*
!  * @author: Jonathan Hui <jwhui at cs.berkeley.edu>
!  */
! 
! includes BlockStorage;
! includes STM25P;
! 
! configuration BlockStorageC {
    provides {
!     interface StdControl;
!     interface BlockWrite[uint8_t id];
!     interface BlockRead[uint8_t id];
    }
  }
- 
  implementation {
  
!   components
!     BlockStorageM,
!     FlashVolumeC,
!     PageEEPROMC,
!     LedsC as Leds;
! 
!   StdControl = BlockStorageM;
!   StdControl = FlashVolumeC;
!   StdControl = PageEEPROMC;
!   BlockWrite = BlockStorageM;
!   BlockRead = BlockStorageM;
! 
!   BlockStorageM.ActualFV -> FlashVolumeC.FlashVolume;
!   BlockStorageM.Leds -> Leds;
!   BlockStorageM.PageEEPROM -> PageEEPROMC;
  
  }
--- 1,23 ----
  // $Id$
! generic configuration BlockStorageC() {
    provides {
!     interface Mount;
!     interface BlockWrite;
!     interface BlockRead;
    }
  }
  implementation {
+   enum {
+     BLOCK_ID = unique(UQ_BLOCK_STORAGE),
+     VOLUME_ID = unique(UQ_STORAGE_VOLUME)
+   };
+     
+   components BlockStorageM, StorageManagerC;
  
!   Mount = BlockStorageM.Mount[BLOCK_ID];
!   BlockWrite = BlockStorageM.BlockWrite[BLOCK_ID];
!   BlockRead = BlockStorageM.BlockRead[BLOCK_ID];
  
+   BlockStorageM.HALAT45DB[BLOCK_ID] -> StorageManagerC.HALAT45DB[VOLUME_ID];
+   BlockStorageM.ActualMount[BLOCK_ID] -> StorageManagerC.Mount[VOLUME_ID];
  }

Index: BlockStorageM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/AT45DB/BlockStorageM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BlockStorageM.nc	22 Jan 2005 00:26:30 -0000	1.1
--- BlockStorageM.nc	2 Feb 2005 22:56:39 -0000	1.2
***************
*** 29,40 ****
  module BlockStorageM {
    provides {
!     interface StdControl;
!     interface BlockWrite[uint8_t id];
!     interface BlockRead[uint8_t id];
    }
    uses {
!     interface FlashVolume as ActualFV[uint8_t id];
!     interface Leds;
!     interface PageEEPROM as HALAT45DB;
    }
  }
--- 29,39 ----
  module BlockStorageM {
    provides {
!     interface Mount[blockstorage_t blockId];
!     interface BlockWrite[blockstorage_t blockId];
!     interface BlockRead[blockstorage_t blockId];
    }
    uses {
!     interface HALAT45DB[blockstorage_t blockId];
!     interface Mount as ActualMount[blockstorage_t blockId];
    }
  }
***************
*** 45,49 ****
      S_WRITE,
      S_ERASE,
!     S_COMMIT,
      S_READ,
      S_VERIFY,
--- 44,48 ----
      S_WRITE,
      S_ERASE,
!     S_COMMIT, S_COMMIT2, S_COMMIT3,
      S_READ,
      S_VERIFY,
***************
*** 51,55 ****
    };
  
!   uint8_t state;
    uint8_t client;
  
--- 50,54 ----
    };
  
!   uint8_t state = S_IDLE;
    uint8_t client;
  
***************
*** 58,74 ****
    block_addr_t bytesRemaining;
    uint16_t crc;
  
!   command result_t StdControl.init() {
!     state = S_IDLE;
!     return SUCCESS;
!   }
! 
!   command result_t StdControl.start() {
!     return SUCCESS;
!   }
! 
!   command result_t StdControl.stop() {
!     return SUCCESS;
!   }
  
    result_t actualSignal(result_t result) {
--- 57,64 ----
    block_addr_t bytesRemaining;
    uint16_t crc;
+   block_addr_t maxAddr[uniqueCount(UQ_BLOCK_STORAGE)];
  
!   void commitSignature();
!   void commitSync();
  
    result_t actualSignal(result_t result) {
***************
*** 82,85 ****
--- 72,77 ----
        case S_ERASE: return signal BlockWrite.eraseDone[client](result);
        case S_CRC: return signal BlockRead.computeCrcDone[client](result, crc);
+       case S_COMMIT: case S_COMMIT2: case S_COMMIT3:
+ 	return signal BlockWrite.commitDone[client](result);
        }
  
***************
*** 93,101 ****
    void signalDone(result_t result) {
      if (result == SUCCESS)
!       post signalSuccess();
      else
        post signalFail();
    }
  
    bool admitRequest(uint8_t newState, uint8_t id) {
      if (state != S_IDLE)
--- 85,103 ----
    void signalDone(result_t result) {
      if (result == SUCCESS)
!       switch (state)
! 	{
! 	case S_COMMIT: commitSignature(); break;
! 	case S_COMMIT2: commitSync(); break;
! 	default: post signalSuccess(); break;
! 	}
      else
        post signalFail();
    }
  
+   void check(result_t ok) {
+     if (!ok)
+       post signalFail();
+   }
+ 
    bool admitRequest(uint8_t newState, uint8_t id) {
      if (state != S_IDLE)
***************
*** 108,115 ****
    void calcRequest(block_addr_t addr, at45page_t *page,
  		   at45pageoffset_t *offset, at45pageoffset_t *count) {
!     storage_addr_t physicalAddr = call ActualFV.physicalAddr[client](addr);
! 
!     *page = physicalAddr >> AT45_PAGE_SIZE_LOG2;
!     *offset = physicalAddr & ((1 << AT45_PAGE_SIZE_LOG2) - 1);
      if (bytesRemaining < (1 << AT45_PAGE_SIZE_LOG2) - *offset)
        *count = bytesRemaining;
--- 110,115 ----
    void calcRequest(block_addr_t addr, at45page_t *page,
  		   at45pageoffset_t *offset, at45pageoffset_t *count) {
!     *page = addr >> AT45_PAGE_SIZE_LOG2;
!     *offset = addr & ((1 << AT45_PAGE_SIZE_LOG2) - 1);
      if (bytesRemaining < (1 << AT45_PAGE_SIZE_LOG2) - *offset)
        *count = bytesRemaining;
***************
*** 131,144 ****
        {
        case S_WRITE:
! 	if (!call HALAT45DB.write(page, offset, buf, count))
! 	  post signalFail();
  	break;
        case S_READ:
! 	if (!call HALAT45DB.read(page, offset, buf, count))
! 	  post signalFail();
  	break;
!       case S_CRC:
! 	if (!call HALAT45DB.computeCrc(page, offset, count, crc))
! 	  post signalFail();
  	break;
        }
--- 131,141 ----
        {
        case S_WRITE:
! 	check(call HALAT45DB.write(page, offset, buf, count));
  	break;
        case S_READ:
! 	check(call HALAT45DB.read(page, offset, buf, count));
  	break;
!       case S_CRC: case S_COMMIT:
! 	check(call HALAT45DB.computeCrc(page, offset, count, crc));
  	break;
        }
***************
*** 153,156 ****
--- 150,154 ----
      bufPtr = buf;
      bytesRemaining = len;
+     crc = 0;
  
      continueRequest();
***************
*** 160,176 ****
  
    command result_t BlockWrite.write[uint8_t id](block_addr_t addr, uint8_t* buf, block_addr_t len) {
!     return newRequest(S_WRITE, addr, buf, len);
    }
  
    command result_t BlockWrite.erase[uint8_t id]() {
-     storage_addr_t physicalAddr;
- 
      if (admitRequest(S_ERASE, id) == FAIL)
        return FAIL;
  
!     physicalAddr = call ActualFV.physicalAddr[client](0);
! 
!     if (!call HALAT45DB.erase(physicalAddr >> AT45_PAGE_SIZE_LOG2, AT45_ERASE))
!       post signalFail();
  
      return SUCCESS;
--- 158,174 ----
  
    command result_t BlockWrite.write[uint8_t id](block_addr_t addr, uint8_t* buf, block_addr_t len) {
!     result_t ok = newRequest(S_WRITE, addr, buf, len);
! 
!     if (ok && addr + len > maxAddr[id])
!       maxAddr[id] = addr+len;
! 
!     return ok;
    }
  
    command result_t BlockWrite.erase[uint8_t id]() {
      if (admitRequest(S_ERASE, id) == FAIL)
        return FAIL;
  
!     check(call HALAT45DB.erase(0, AT45_ERASE));
  
      return SUCCESS;
***************
*** 178,188 ****
  
    command result_t BlockWrite.commit[uint8_t id]() {
!     if (admitRequest(S_COMMIT, id) == FAIL)
!       return FAIL;
  
!     if (!call HALAT45DB.syncAll())
!       post signalFail();
  
!     return SUCCESS;
    }
  
--- 176,200 ----
  
    command result_t BlockWrite.commit[uint8_t id]() {
!     return newRequest(S_COMMIT, 0, NULL, maxAddr[id]);
!   }
  
!   /* Called once crc computed. Write crc + signature in block 0. */
!   void commitSignature() {
!     static uint8_t sig[4];
  
!     sig[0] = crc;
!     sig[1] = crc >> 8;
!     sig[2] = 0xb1; /* block sig: b10c */
!     sig[3] = 0x0c;
!     state = S_COMMIT2;
!     /* Note: bytesRemaining is 0, so multipageDone will got straight to
!        signalDone */
!     check(call HALAT45DB.write(0, 1 << AT45_PAGE_SIZE_LOG2, sig, 4));
!   }
! 
!   /* Called once signature written. Ensure writes complete. */
!   void commitSunc() {
!     state = S_COMMIT3;
!     check(call HALAT45DB.syncAll());
    }
  
***************
*** 196,201 ****
  
    command result_t BlockRead.computeCrc[uint8_t id](block_addr_t addr, block_addr_t len) {
-     if (state == S_IDLE)
-       crc = 0;
      return newRequest(S_CRC, addr, NULL, len);
    }
--- 208,211 ----
***************
*** 241,243 ****
--- 251,262 ----
    default event result_t BlockRead.verifyDone[uint8_t id](result_t result) { return SUCCESS; }
    default event result_t BlockRead.computeCrcDone[uint8_t id](result_t result, uint16_t crcResult) { return SUCCESS; }
+ 
+   command result_t Mount.mount[blockstorage_t blockId](volume_id_t id) {
+     maxAddr[id] = 0;
+     return call ActualMount.mount[blockId](id);
+   }
+ 
+   event void ActualMount.mountDone[blockstorage_t blockId](storage_result_t result, volume_id_t id) {
+     return signal Mount.mountDone[blockId](result, id);
+   }
  }

Index: HALAT45DB.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/AT45DB/HALAT45DB.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HALAT45DB.nc	22 Jan 2005 00:26:31 -0000	1.1
--- HALAT45DB.nc	2 Feb 2005 22:56:39 -0000	1.2
***************
*** 51,55 ****
  
    command result_t computeCrc(at45page_t page, at45pageoffset_t offset,
! 			      at45pageoffset_t n);
    event result_t computeCrcDone(result_t result, uint16_t crc);
  }
--- 51,55 ----
  
    command result_t computeCrc(at45page_t page, at45pageoffset_t offset,
! 			      at45pageoffset_t n, uint16_t baseCrc);
    event result_t computeCrcDone(result_t result, uint16_t crc);
  }

Index: HALAT45DBC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/AT45DB/HALAT45DBC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HALAT45DBC.nc	22 Jan 2005 00:26:31 -0000	1.1
--- HALAT45DBC.nc	2 Feb 2005 22:56:40 -0000	1.2
***************
*** 1,25 ****
! // $Id$
! 
  /*									tab:4
!  * "Copyright (c) 2000-2003 The Regents of the University  of California.  
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  * 
!  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
!  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  * 
!  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
!  *
!  * Copyright (c) 2002-2003 Intel Corporation
   * All rights reserved.
   *
--- 1,5 ----
! // $Id: HALAT45DBC.nc,v 1.1 2005/01/22 00:26:31 idgay Exp 
  /*									tab:4
!  * Copyright (c) 2005 Intel Corporation
   * All rights reserved.
   *
***************
*** 29,68 ****
   * 94704.  Attention:  Intel License Inquiry.
   */
- /*
-  *
-  * Authors:		Jason Hill, David Gay, Philip Levis
-  * Date last modified:  6/25/02
-  *
-  */
- 
  /**
-  * @author Jason Hill
   * @author David Gay
-  * @author Philip Levis
   */
  
! 
! configuration PageEEPROMC
  {
    provides {
      interface StdControl;
!     interface PageEEPROM[uint8_t client];
    }
  }
  implementation
  {
!   components PageEEPROMM, PageEEPROMShare, HPLFlash, NoLeds as Leds;
! 
!   StdControl = PageEEPROMM;
!   PageEEPROM = PageEEPROMShare;
! 
!   PageEEPROMShare.ActualEEPROM -> PageEEPROMM;
  
!   PageEEPROMM.FlashSPI -> HPLFlash;
!   PageEEPROMM.FlashControl -> HPLFlash;
!   PageEEPROMM.FlashIdle -> HPLFlash;
!   PageEEPROMM.getCompareStatus -> HPLFlash;
!   PageEEPROMM.FlashSelect -> HPLFlash;
  
!   PageEEPROMM.Leds -> Leds;
  }
--- 9,31 ----
   * 94704.  Attention:  Intel License Inquiry.
   */
  /**
   * @author David Gay
   */
  
! configuration HALAT45DBC
  {
    provides {
      interface StdControl;
!     interface HALAT45DB;
    }
  }
  implementation
  {
!   components HALAT45DBM, HPLAT45DBC;
  
!   StdControl = HALAT45DBM;
!   StdControl = HPLAT45DBC;
!   HALAT45DBM = HALAT45DBM;
  
!   HALAT45DBM.HPLAT45DB -> HPLAT45DBC;
  }

Index: HALAT45DBM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/AT45DB/HALAT45DBM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HALAT45DBM.nc	22 Jan 2005 00:26:31 -0000	1.1
--- HALAT45DBM.nc	2 Feb 2005 22:56:40 -0000	1.2
***************
*** 34,38 ****
    provides {
      interface StdControl;
!     interface PageEEPROM as HALAT45DB;
    }
    uses {
--- 34,38 ----
    provides {
      interface StdControl;
!     interface HALAT45DB;
    }
    uses {
***************
*** 66,70 ****
      R_SYNCALL,
      R_FLUSH,
!     R_FLUSHALL
    };
    uint8_t request;
--- 66,71 ----
      R_SYNCALL,
      R_FLUSH,
!     R_FLUSHALL,
!     BROKEN // Write failed. Fail all subsequent requests.
    };
    uint8_t request;
***************
*** 73,78 ****
    at45page_t reqPage;
  
-   bool broken; // Write failed. Fail all subsequent requests.
- 
    enum {
      P_READ,
--- 74,77 ----
***************
*** 131,138 ****
  
    task void taskSuccess() {
!     requestDone(SUCCESS, 0);
    }
    task void taskFail() {
!     requestDone(FAIL, 0);
    }
  
--- 130,137 ----
  
    task void taskSuccess() {
!     requestDone(SUCCESS, 0, IDLE);
    }
    task void taskFail() {
!     requestDone(FAIL, 0, IDLE);
    }
  
***************
*** 171,176 ****
      else
        {
! 	broken = TRUE; // write failed. refuse all further reqs
! 	requestDone(FAIL, 0);
  	return SUCCESS;
        }
--- 170,174 ----
      else
        {
! 	requestDone(FAIL, 0, BROKEN);
  	return SUCCESS;
        }
***************
*** 180,184 ****
  
    event result_t HPLAT45DB.readDone() {
!     requestDone(SUCCESS, 0);
      return SUCCESS;
    }
--- 178,182 ----
  
    event result_t HPLAT45DB.readDone() {
!     requestDone(SUCCESS, 0, IDLE);
      return SUCCESS;
    }
***************
*** 187,196 ****
      buffer[selected].clean = FALSE;
      buffer[selected].unchecked = 0;
!     requestDone(SUCCESS, 0);
      return SUCCESS;
    }
  
    event result_t HPLAT45DB.crcDone(uint16_t crc) {
!     requestDone(SUCCESS, crc);
      return SUCCESS;
    }
--- 185,194 ----
      buffer[selected].clean = FALSE;
      buffer[selected].unchecked = 0;
!     requestDone(SUCCESS, 0, IDLE);
      return SUCCESS;
    }
  
    event result_t HPLAT45DB.crcDone(uint16_t crc) {
!     requestDone(SUCCESS, crc, IDLE);
      return SUCCESS;
    }
***************
*** 234,238 ****
      buffer[selected].clean = TRUE;
      buffer[selected].erased = TRUE;
!     requestDone(SUCCESS, 0);
      return SUCCESS;
    }
--- 232,236 ----
      buffer[selected].clean = TRUE;
      buffer[selected].erased = TRUE;
!     requestDone(SUCCESS, 0, IDLE);
      return SUCCESS;
    }
***************
*** 262,266 ****
  	      // subsequent write)
  	      buffer[selected].clean = TRUE;
! 	      requestDone(SUCCESS, 0);
  	      break;
  	    }
--- 260,264 ----
  	      // subsequent write)
  	      buffer[selected].clean = TRUE;
! 	      requestDone(SUCCESS, 0, IDLE);
  	      break;
  	    }
***************
*** 301,305 ****
  	    call HPLAT45DB.waitIdle();
  	  else
! 	    call HPLAT45DB.crc(OP(AT45_C_READ_BUFFER), 0, reqOffset, reqBytes);
  	  break;
  
--- 299,305 ----
  	    call HPLAT45DB.waitIdle();
  	  else
! 	    /* Hack: baseCrc was stored in reqBuf */
! 	    call HPLAT45DB.crc(OP(AT45_C_READ_BUFFER), 0, reqOffset, reqBytes,
! 			       (uint16_t)reqBuf);
  	  break;
  
***************
*** 331,338 ****
    }
  
!   void requestDone(result_t result, uint16_t computedCrc) {
      uint8_t orequest = request;
  
!     request = IDLE;
      switch (orequest)
        {
--- 331,338 ----
    }
  
!   void requestDone(result_t result, uint16_t computedCrc, uint8_t newState) {
      uint8_t orequest = request;
  
!     request = newState;
      switch (orequest)
        {
***************
*** 350,354 ****
  		      void *reqdata, at45pageoffset_t n) {
  #ifdef CHECKARGS
!     if (page >= AT45_MAX_PAGES || offset >= AT45_PAGE_SIZE ||
  	n > AT45_PAGE_SIZE || offset + n > AT45_PAGE_SIZE)
        return FAIL;
--- 350,354 ----
  		      void *reqdata, at45pageoffset_t n) {
  #ifdef CHECKARGS
!     if (page >= AT45_MAX_PAGES || offset >= AT45_PAGE_SIZE || n == 0 ||
  	n > AT45_PAGE_SIZE || offset + n > AT45_PAGE_SIZE)
        return FAIL;
***************
*** 359,368 ****
      request = req;
  
-     if (broken)
-       {
- 	post taskFail();
- 	return SUCCESS;
-       }
- 
      reqBuf = reqdata;
      reqBytes = n;
--- 359,362 ----
***************
*** 388,401 ****
  
    command result_t HALAT45DB.computeCrc(at45page_t page,
! 					 at45pageoffset_t offset,
! 					 at45pageoffset_t n) {
!     if (n == 0)
!       {
! 	request = R_READCRC;
! 	post taskSuccess();
! 	return SUCCESS;
!       }
!     else
!       return newRequest(R_READCRC, page, offset, NULL, n);
    }
  
--- 382,392 ----
  
    command result_t HALAT45DB.computeCrc(at45page_t page,
! 					at45pageoffset_t offset,
! 					at45pageoffset_t n,
! 					uint16_t baseCrc) {
!     /* This is a hack (store crc in reqBuf), but it saves 2 bytes of RAM */
!     if (request == IDLE)
!       reqBuf = (uint8_t *)baseCrc;
!     return newRequest(R_READCRC, page, offset, NULL, n);
    }
  
***************
*** 415,424 ****
      request = newReq;
  
!     if (broken)
!       {
! 	post taskFail();
! 	return SUCCESS;
!       }
!     else if (buffer[0].page == page)
        selected = 0;
      else if (buffer[1].page == page)
--- 406,410 ----
      request = newReq;
  
!     if (buffer[0].page == page)
        selected = 0;
      else if (buffer[1].page == page)
***************
*** 449,458 ****
      request = newReq;
  
!     if (broken)
!       {
! 	post taskFail();
! 	return SUCCESS;
!       }
!     else if (!buffer[0].clean)
        selected = 0;
      else if (!buffer[1].clean)
--- 435,439 ----
      request = newReq;
  
!     if (!buffer[0].clean)
        selected = 0;
      else if (!buffer[1].clean)

Index: HPLAT45DB.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/AT45DB/HPLAT45DB.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HPLAT45DB.nc	22 Jan 2005 00:26:31 -0000	1.1
--- HPLAT45DB.nc	2 Feb 2005 22:56:40 -0000	1.2
***************
*** 24,28 ****
  
    command result_t crc(uint8_t cmd, at45page_t page, at45pageoffset_t offset,
! 		       at45pageoffset_t count);
    event result_t crcDone(uint16_t computedCrc);
  
--- 24,28 ----
  
    command result_t crc(uint8_t cmd, at45page_t page, at45pageoffset_t offset,
! 		       at45pageoffset_t count, uint16_t baseCrc);
    event result_t crcDone(uint16_t computedCrc);
  

Index: HPLAT45DBByte.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/AT45DB/HPLAT45DBByte.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HPLAT45DBByte.nc	22 Jan 2005 00:26:31 -0000	1.1
--- HPLAT45DBByte.nc	2 Feb 2005 22:56:40 -0000	1.2
***************
*** 97,106 ****
    void execCommand(uint8_t op, uint8_t reqCmd, uint8_t dontCare,
  		   at45page_t page, at45pageoffset_t offset,
! 		   uint8_t *data, at45pageoffset_t dataCount) {
      uint8_t cmd[4];
      uint8_t in = 0, out = 0;
      uint8_t *ptr;
      at45pageoffset_t count;
-     uint16_t crc = 0;
      uint8_t lphase = P_SEND_CMD;
  
--- 97,105 ----
    void execCommand(uint8_t op, uint8_t reqCmd, uint8_t dontCare,
  		   at45page_t page, at45pageoffset_t offset,
! 		   uint8_t *data, at45pageoffset_t dataCount, uint16_t crc) {
      uint8_t cmd[4];
      uint8_t in = 0, out = 0;
      uint8_t *ptr;
      at45pageoffset_t count;
      uint8_t lphase = P_SEND_CMD;
  
***************
*** 172,191 ****
  
    command result_t HPLAT45DB.fill(uint8_t cmd, at45page_t page) {
!     execCommand(P_FILL, cmd, 0, page, 0, NULL, 0);
      return SUCCESS;
    }
  
    command result_t HPLAT45DB.flush(uint8_t cmd, at45page_t page) {
!     execCommand(P_FLUSH, cmd, 0, page, 0, NULL, 0);
      return SUCCESS;
    }
  
    command result_t HPLAT45DB.compare(uint8_t cmd, at45page_t page) {
!     execCommand(P_COMPARE, cmd, 0, page, 0, NULL, 0);
      return SUCCESS;
    }
  
    command result_t HPLAT45DB.erase(uint8_t cmd, at45page_t page) {
!     execCommand(P_ERASE, cmd, 0, page, 0, NULL, 0);
      return SUCCESS;
    }
--- 171,190 ----
  
    command result_t HPLAT45DB.fill(uint8_t cmd, at45page_t page) {
!     execCommand(P_FILL, cmd, 0, page, 0, NULL, 0, 0);
      return SUCCESS;
    }
  
    command result_t HPLAT45DB.flush(uint8_t cmd, at45page_t page) {
!     execCommand(P_FLUSH, cmd, 0, page, 0, NULL, 0, 0);
      return SUCCESS;
    }
  
    command result_t HPLAT45DB.compare(uint8_t cmd, at45page_t page) {
!     execCommand(P_COMPARE, cmd, 0, page, 0, NULL, 0, 0);
      return SUCCESS;
    }
  
    command result_t HPLAT45DB.erase(uint8_t cmd, at45page_t page) {
!     execCommand(P_ERASE, cmd, 0, page, 0, NULL, 0, 0);
      return SUCCESS;
    }
***************
*** 194,198 ****
  				  at45page_t page, at45pageoffset_t offset,
  				  uint8_t *data, at45pageoffset_t count) {
!     execCommand(P_READ, cmd, 2, page, offset, data, count);
      return SUCCESS;
    }
--- 193,197 ----
  				  at45page_t page, at45pageoffset_t offset,
  				  uint8_t *data, at45pageoffset_t count) {
!     execCommand(P_READ, cmd, 2, page, offset, data, count, 0);
      return SUCCESS;
    }
***************
*** 200,205 ****
    command result_t HPLAT45DB.crc(uint8_t cmd,
  				 at45page_t page, at45pageoffset_t offset,
! 				 at45pageoffset_t count) {
!     execCommand(P_READ_CRC, cmd, 2, page, offset, NULL, count);
      return SUCCESS;
    }
--- 199,205 ----
    command result_t HPLAT45DB.crc(uint8_t cmd,
  				 at45page_t page, at45pageoffset_t offset,
! 				 at45pageoffset_t count,
! 				 uint16_t baseCrc) {
!     execCommand(P_READ_CRC, cmd, 2, page, offset, NULL, count, baseCrc);
      return SUCCESS;
    }
***************
*** 208,212 ****
  				   at45page_t page, at45pageoffset_t offset,
  				   uint8_t *data, at45pageoffset_t count) {
!     execCommand(P_WRITE, cmd, 0, page, offset, data, count);
      return SUCCESS;
    }
--- 208,212 ----
  				   at45page_t page, at45pageoffset_t offset,
  				   uint8_t *data, at45pageoffset_t count) {
!     execCommand(P_WRITE, cmd, 0, page, offset, data, count, 0);
      return SUCCESS;
    }



More information about the Tinyos-beta-commits mailing list