]> oss.titaniummirror.com Git - tinyos-2.x.git/blob - BlockStorageC.nc
ff42bcca2eeff6e448aede55d0247075937f057f
[tinyos-2.x.git] / BlockStorageC.nc
1 /*
2 * Copyright (c) 2005-2006 Arch Rock Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * - Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the
13 * distribution.
14 * - Neither the name of the Arch Rock Corporation nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 * OF THE POSSIBILITY OF SUCH DAMAGE
30 */
31
32 /**
33 * Implementation of the block storage abstraction from TEP103 for the
34 * ST M25P serial code flash.
35 *
36 * @author Jonathan Hui <jhui@archrock.com>
37 * @version $Revision$ $Date$
38 */
39
40 #include "Stm25p.h"
41
42 generic configuration BlockStorageC( volume_id_t volume_id ) {
43
44 provides interface BlockRead;
45 provides interface BlockWrite;
46 provides interface StorageMap;
47
48 }
49
50 implementation {
51
52 enum {
53 BLOCK_ID = unique( "Stm25p.Block" ),
54 VOLUME_ID = unique( "Stm25p.Volume" ),
55 };
56
57 components Stm25pBlockP as BlockP;
58 BlockRead = BlockP.Read[ BLOCK_ID ];
59 BlockWrite = BlockP.Write[ BLOCK_ID ];
60 StorageMap = BlockP.StorageMap[ BLOCK_ID ];
61
62 components Stm25pSectorC as SectorC;
63 BlockP.ClientResource[ BLOCK_ID ] -> SectorC.ClientResource[ VOLUME_ID ];
64 BlockP.Sector[ BLOCK_ID ] -> SectorC.Sector[ VOLUME_ID ];
65
66 components new Stm25pBinderP( volume_id ) as BinderP;
67 BinderP.Volume -> SectorC.Volume[ VOLUME_ID ];
68
69 }