[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/umass/tos/types PageNAND.h, NONE, 1.1 SingleStream.h, NONE, 1.1 app_header.h, NONE, 1.1 chunk_header.h, NONE, 1.1 common_header.h, NONE, 1.1

Gaurav gmathur at users.sourceforge.net
Sat Dec 9 13:05:53 PST 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/umass/tos/types
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17795/tos/types

Added Files:
	PageNAND.h SingleStream.h app_header.h chunk_header.h 
	common_header.h 
Log Message:
Added contrib/umass containing Capsule -- a storage system for sensors

--- NEW FILE: PageNAND.h ---
/*
 * file:        PageNAND.h
 * description:
 */

#ifndef TOS_PAGENAND_H
#define TOS_PAGENAND_H

enum {
    TOS_NAND_PAGE_SIZE = 512,
    TOS_NAND_EXTRA_SIZE = 16,
    TOS_NAND_ERASE_SIZE = 32 /* number of pages in an erase block */
};

typedef uint32_t nandpage_t;
typedef uint16_t nandoffset_t;

#endif

--- NEW FILE: SingleStream.h ---

#ifndef SINGLE_STREAM_H
#define SINGLE_STREAM_H


// stream_t
typedef struct stream_t
{
	flashptr_t tail;
	bool doEcc;
	flashptr_t traverse;
} stream_t;


#endif

--- NEW FILE: app_header.h ---
/*
 * file:        app_header.h
 * description: Application level headers used by Capsule
 */

/*
 * Application level headers used by the different storage objects
 */

#ifndef APP_HEADER_H
#define APP_HEADER_H

#include "common_header.h"

// Stack header
struct stack_header
{
    flashptr_t prev_ptr;
};
typedef struct stack_header stack_header;


// Queue header
struct queue_header
{
    flashptr_t prev_ptr;
};
typedef struct queue_header queue_header;


// Stream header
struct stream_header
{
    flashptr_t prev_ptr;
};
typedef struct stream_header stream_header;


// Array header
//
struct array_header
{
    flashptr_t ptr[ARRAY_ELEMENTS_PER_CHUNK];
};
typedef struct array_header array_header;


// Index header
//
struct index_header
{
    flashptr_t ptr[INDEX_ELEMENTS_PER_CHUNK];
};
typedef struct index_header index_header;


// Transaction data header
// - Stores memory state for various storage objects
//
struct checkpoint_header
{
    uint8_t state_buffer[MAX_STATE];
};
typedef struct checkpoint_header checkpoint_header;


// File
//
struct file_header
{
    bool invalid;
    char name[MAX_FILENAME];
    uint16_t length;
    flashptr_t start_ptr;
    uint8_t last_index;
};
typedef struct file_header file_header;


// Filesystem data header
//
struct filesystem
{
    file_header data[MAX_FILES];
};
typedef struct filesystem filesystem;


// Root data header
// - This data is stored in the root area of the flash
//
struct root_header
{
    uint8_t crc;
    uint16_t timestamp;
    flashptr_t root[NUM_CHECKPOINTS];
};
typedef struct root_header root_header;


bool cmpflashptr(flashptr_t *ptr1, flashptr_t *ptr2)
{
    if ( (ptr1->page == ptr2->page) && (ptr1->offset == ptr2->offset))
        return (TRUE);
    else
        return (FALSE);
}

#endif

--- NEW FILE: chunk_header.h ---
/*
 * file:        chunk_header.h
 * description: Chunk header stamped on every chunk written by FAL
 */

/*
 * Header present for every chunk on the flash
 */

#ifndef CHUNK_HEADER_H
#define CHUNK_HEADER_H

#include "common_header.h"

/*
 * The structure of one write buffer looks like:
 * -------------------------------------------------
 * | chunk 1 | chunk 2 | ... |
 * -------------------------------------------------
 */

struct chunk_header
{
    datalen_t data_len;
    uint8_t ecc;
};
typedef struct chunk_header chunk_header;

#endif

--- NEW FILE: common_header.h ---
/*
 * file:        common_header.h
 * description: common headers
 */

/*
 * Common declarations
 */

#ifndef COMMON_HEADER_H
#define COMMON_HEADER_H

#include "platform.h"

struct flashptr_t
{
	pageptr_t page;
	offsetptr_t offset;
};

typedef struct flashptr_t flashptr_t;

typedef uint8_t fileptr_t;

/*
 * The following is just a temp buffer that is used to read the headers
 * - it should be >= size of the chunk header + the max {app_headers}
 */
#define MAX_HEADERS_LEN 10

/*
 * The following is just a temp buffer used to hold the memory state of 
 * each storage object for checkpointing / restore purposes. Needs to be
 * set manually unfortunately because we dont know how much state each
 * storage object needs.
 */
#define MAX_STATE 200

/*
 * The following defines the max number of files that can be supported
 * by Capsule
 */
#define MAX_FILES 8

/*
 * The following defines the max size of the filename (in bytes)
 */
#define MAX_FILENAME 16


/*
 * The following defines the number of instances of each of these storage 
 * objects being used in the application.
 * The values for these are set automatically by the compiler
 */
#define NUM_ARRAYS uniqueCount("Array")

#define NUM_QUEUES uniqueCount("Queue")

#define NUM_INDEXES uniqueCount("Index")

#define NUM_STACKS uniqueCount("Stack")

#define NUM_STREAMS uniqueCount("Stream")

#define NUM_CHECKPOINTS uniqueCount("Checkpoint")

#define NUM_STREAM_INDEXES uniqueCount("StreamIndex")

#endif



More information about the Tinyos-contrib-commits mailing list