symbian-qemu-0.9.1-12/model-libraries/nvmemmory/nvmemmory.h
author Gareth Stockwell <gareth.stockwell@accenture.com>
Wed, 22 Sep 2010 17:06:27 +0100
branchgraphics-phase-3
changeset 112 b6c206049d8a
permissions -rw-r--r--
Copied NVM model library code from default branch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
112
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     1
/*
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     3
* All rights reserved.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     8
*
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     9
* Initial Contributors:
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    11
*
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    12
* Contributors:
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    13
*
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    14
* Description: 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    15
*
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    16
* Simple non volatile memory device. nvmemmory.h
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    17
*
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    18
*/
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    19
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    20
#ifndef _NVMEMORY_H
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    21
#define _NVMEMORY_H
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    22
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    23
#pragma once
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    24
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    25
/*! \brief 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    26
NVMEMORY.DLL 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    27
- A simple non volatile sector addressed memory device
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    28
- An example of a portable high abstraction model architecture. 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    29
  This DLL is created to serve in multiple different modeling 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    30
  environments and tools. Model portability should be taken into 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    31
  account when further developing and maintaining this device.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    32
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    33
USAGE       
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    34
nvmemory.dll Example usage provided by syborg_nvmemorydevice.py.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    35
1 - Create an instance of SyborgNVMemory class. 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    36
    This can be performed either by instantiating the C++ class directly 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    37
    by calling the constructor "new SyborgNVMemory( a_sectorsize );".
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    38
    Or by using the C API to create an instance "nvmem_create( sector_size )".
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    39
    As you can see you need to set the sector size for your device when you create it.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    40
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    41
    In fact each of the API functions are provided in form of both C and C++ API functions.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    42
    From this on only the C API is explained.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    43
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    44
2 - Reset the device by calling "nvmem_reset( self.obj )". 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    45
    This function clears any information stored by the device instance except the sector size.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    46
    Note that for the C API you always need to specify the object which you wish to command.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    47
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    48
3 - Create handle to your image file by calling "nvmem_open( self.obj, imagepath )".
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    49
    Image is opened in binary mode. Store the handle.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    50
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    51
    Note that you need to have an image stored to a path on your PC before you can call this function. 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    52
    You must provide the image name and path when calling.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    53
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    54
    Note also that there is a service provided by this DLL which can create an image for you.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    55
    NVMEMORY_API int32_t nvmem_create_image( SyborgNVMemory* a_syborg_nvmemory, char* a_memoryarrayname, uint32_t a_sectorcount, uint32_t a_sectorsize = NVMEM_DEFAULT_SECTORSIZE_IN_BYTES );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    56
    nvmem_create_image function probably needs further development. You may also create image in your wrapper as done in example usage file.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    57
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    58
    You may get your memory device size by calling nvmem_get_sector_count( self.obj, nvmemhandle ).
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    59
    nvmemhandle is the handle you got when calling nvmem_open.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    60
    nvmem_get_sector_count is handy in cases where you have provided a readymade image for the device.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    61
    In this case you don't need to go and hardcode the image size each time in your wrapper.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    62
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    63
4 - Initialize callback. Provide a callback function for the device by calling "nvmem_set_callback( self.obj, nvmem_callback )".
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    64
    Where the callback is a function pointer of a type "int (*i_NVMemCallBack)(int);".
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    65
    Callback is called by DLL when read and write operations are finished. Parameter is the amount of sectors succesfully read or written.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    66
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    67
5 - Start using your device.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    68
    nvmem_read(  self.obj, nvmemory_sharedmemory_host_address, nvmemhandle, transaction_offset, transaction_size )
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    69
    nvmem_write(  self.obj, nvmemory_sharedmemory_host_address, nvmemhandle, transaction_offset, transaction_size )
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    70
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    71
    See syborg_nvmemorydevice.py to learn more about device usage. 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    72
*/
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    73
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    74
#include "platformtypes.h"
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    75
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    76
#ifdef WIN32
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    77
#ifdef NVMEMORY_EXPORTS
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    78
#define NVMEMORY_API __declspec(dllexport)
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    79
#else
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    80
#define NVMEMORY_API __declspec(dllimport)
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    81
#endif
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    82
#else
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    83
#define NVMEMORY_API
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    84
#endif
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    85
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    86
class NVMEMORY_API SyborgNVMemory;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    87
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    88
extern "C"
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    89
    {
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    90
    const int32_t NVMEM_DEFAULT_SECTORSIZE_IN_BYTES = 512;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    91
    const int32_t NVMEM_MAX_STREAMHANDLES = 16;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    92
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    93
    /*Nvmemory error codes*/
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    94
    const int32_t NVMEM_OK =                                 0;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    95
    const int32_t NVMEM_ERROR_OUT_OF_FREE_STREAMHANDLES =   -1;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    96
    const int32_t NVMEM_ERROR_FOPEN =                       -2;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    97
    const int32_t NVMEM_ERROR_FCLOSE =                      -3;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    98
    const int32_t NVMEM_ERROR_FFLUSH =                      -4;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    99
    const int32_t NVMEM_ERROR_FSEEK =                       -5;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   100
    const int32_t NVMEM_ERROR_FREAD =                       -6;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   101
    const int32_t NVMEM_ERROR_FWRITE =                      -7;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   102
    const int32_t NVMEM_ERROR_SETVBUF =                     -8;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   103
    const int32_t NVMEM_ERROR_CREATE =                      -9;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   104
    const int32_t NVMEM_ERROR_FPRINTF =                     -10;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   105
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   106
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   107
    * Reset the device
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   108
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   109
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   110
    * @return TODO an error if fails
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   111
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   112
    NVMEMORY_API int32_t nvmem_reset( SyborgNVMemory* a_syborg_nvmemory );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   113
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   114
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   115
    * Create a non volatile memory array object.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   116
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   117
    * @param a_sectorsize Size for the sector.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   118
    * @return An object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   119
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   120
    NVMEMORY_API SyborgNVMemory * nvmem_create( uint32_t a_sectorsize = NVMEM_DEFAULT_SECTORSIZE_IN_BYTES);
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   121
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   122
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   123
    * Create a non volatile memory array. A raw image will be created to host filesystem which will 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   124
    * act as a non volatile memory device in client point of view.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   125
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   126
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   127
    * @param a_memoryarrayname Name for the image to be created.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   128
    * @param a_sectorcount Image size in sectors.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   129
    * @param a_sectorsize size for the sector.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   130
    * @return An error code.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   131
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   132
    NVMEMORY_API int32_t nvmem_create_image( SyborgNVMemory* a_syborg_nvmemory, char* a_memoryarrayname, uint32_t a_sectorcount, uint32_t a_sectorsize = NVMEM_DEFAULT_SECTORSIZE_IN_BYTES );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   133
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   134
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   135
    * Create handle to an image
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   136
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   137
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   138
    * @param a_memoryarrayname Name and path for the image to be opened.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   139
    * @return Handle to a non volatile memory array.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   140
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   141
    NVMEMORY_API int32_t nvmem_open( SyborgNVMemory* a_syborg_nvmemory, char* a_memoryarrayname );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   142
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   143
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   144
    * Close handle to a non volatile memory array
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   145
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   146
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   147
    * @param a_memoryarrayhandle Handle to be closed.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   148
    * @return Error code.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   149
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   150
    NVMEMORY_API int32_t nvmem_close( SyborgNVMemory* a_syborg_nvmemory, int32_t a_memoryarrayhandle );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   151
    
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   152
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   153
    * Flush possible cached content of a non volatile memory array
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   154
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   155
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   156
    * @param a_memoryarrayhandle Handle pointing to stream which is flushed to a file.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   157
    * @return Error code.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   158
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   159
    NVMEMORY_API int32_t nvmem_flush( SyborgNVMemory* a_syborg_nvmemory, int32_t a_memoryarrayhandle );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   160
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   161
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   162
    * Read from a non volatile memory array to a guest os application memory space
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   163
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   164
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   165
    * @param a_client_targetmemoryaddr Host OS address pointing to a place to where the data read should be returned.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   166
    * @param a_memoryarrayhandle Handle to the device image.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   167
    * @param a_memoryarrayoffset Sector offset to a position from where the data is to be read.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   168
    * @param a_sectorcount Amount of sectors to be read.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   169
    * @return Error code.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   170
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   171
    NVMEMORY_API void nvmem_read( SyborgNVMemory* a_syborg_nvmemory, uint32_t *a_client_targetmemoryaddr, int32_t a_memoryarrayhandle, uint32_t a_memoryarrayoffset, uint32_t a_sectorcount );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   172
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   173
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   174
    * Write to a non volatile memory array from a guest os application memory space
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   175
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   176
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   177
    * @param a_client_sourcememoryaddr Host OS address pointing to a place to where to get the data for write operation.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   178
    * @param a_memoryarrayhandle Handle to the device image.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   179
    * @param a_memoryarrayoffset Sector offset to a position to where the data is to be written.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   180
    * @param a_sectorcount Amount of sectors to be written.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   181
    * @return Error code.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   182
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   183
    NVMEMORY_API void nvmem_write( SyborgNVMemory* a_syborg_nvmemory, uint32_t *a_client_sourcememoryaddr, int32_t a_memoryarrayhandle, uint32_t a_memoryarrayoffset, uint32_t a_sectorcount );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   184
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   185
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   186
    * Get the size of a non volatile memory array
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   187
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   188
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   189
    * @param a_memoryarrayhandle Handle to the device image.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   190
    * @return Total amount of sectors of the device.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   191
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   192
    NVMEMORY_API uint32_t nvmem_get_sector_count( SyborgNVMemory* a_syborg_nvmemory, int32_t a_memoryarrayhandle );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   193
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   194
    /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   195
    * Store callback
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   196
    *
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   197
    * @param a_syborg_nvmemory an object of class SyborgNVMemory.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   198
    * @param aGraphicsCallBack pointer to a callback function.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   199
    * @return TODO an error if fails.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   200
    */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   201
    NVMEMORY_API int32_t nvmem_set_callback( SyborgNVMemory* a_syborg_nvmemory, int (*aGraphicsCallBack) (int) );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   202
    }
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   203
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   204
class NVMEMORY_API SyborgNVMemory
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   205
    {
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   206
    public:
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   207
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   208
        SyborgNVMemory( uint32_t a_sectorsize = NVMEM_DEFAULT_SECTORSIZE_IN_BYTES );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   209
        ~SyborgNVMemory( );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   210
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   211
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   212
        * Reset the device
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   213
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   214
        int32_t NVMemReset( );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   215
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   216
        * Create a non volatile memory array. A raw image will be created to host filesystem which will 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   217
        * act as a non volatile memory device in client point of view.
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   218
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   219
        int32_t NVMemCreateImage( char* a_memoryarrayname, uint32_t a_sectorcount, uint32_t a_sectorsize = NVMEM_DEFAULT_SECTORSIZE_IN_BYTES );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   220
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   221
        * Return handle to a non volatile memory array
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   222
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   223
        int32_t NVMemOpen( char* a_memoryarrayname );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   224
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   225
        * Close handle to a non volatile memory array
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   226
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   227
        int32_t NVMemClose( int32_t a_memoryarrayhandle );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   228
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   229
        * Flush possible cached content of a non volatile memory array
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   230
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   231
        int32_t NVMemFlush( int32_t a_memoryarrayhandle );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   232
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   233
        * Read from a non volatile memory array to a guest os application memory space
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   234
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   235
        void NVMemRead( uint32_t *a_client_targetmemoryaddr, int32_t a_memoryarrayhandle, uint32_t a_memoryarrayoffset, uint32_t a_sectorcount );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   236
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   237
        * Write to a non volatile memory array from a guest os application memory space
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   238
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   239
        void NVMemWrite( uint32_t *a_client_sourcememoryaddr, int32_t a_memoryarrayhandle, uint32_t a_memoryarrayoffset, uint32_t a_sectorcount );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   240
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   241
        * Get the size of a non volatile memory array
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   242
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   243
        uint32_t NVMemGetSectorCount( int32_t a_memoryarrayhandle );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   244
        /**
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   245
        * Store callback
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   246
        */
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   247
        int32_t NVMemSetCallback( int (*aNVMemCallBack) (int) );
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   248
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   249
    private:
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   250
        FILE *i_filestream[NVMEM_MAX_STREAMHANDLES];
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   251
        uint32_t iNVMemSectorSizeInBytes;
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   252
        int (*i_NVMemCallBack)(int); 
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   253
    };
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   254
b6c206049d8a Copied NVM model library code from default branch
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
   255
#endif // _NVMEMORY_H