*************************************************************************
*                                                                      	*
*  DiskOnChip(R) TrueFFS(R) driver for Windows NT 4.0			*
*                                                                      	*
*  Version 5.1.4, released on Dec 15, 2002				*
*  Based on TrueFFS version 5.1.4 from Nov 25, 2002			*
*                                                                      	*
*  Copyright M-Systems (c) 2002						*
*                                                                      	*
*  Release notes							*
*                                                                      	*
*************************************************************************

This document describes the installation of the DiskOnChip(R) TrueFFS driver
on Windows NT4.
This software should be used for DiskOnChip devices only.

Note for DiskOnChip Plus customers who upgrade from TrueFFS 5.1.x
-----------------------------------------------------------------
In TrueFFS 5.1.x versions (5.1.1, 5.1.2 and 5.1.3) there is a bug with
all DiskOnChip Plus devices in reading the bad block table in few specific
cases.
Therefore, customers who upgrade from TrueFFS 5.1.x, DiskOnChip Plus devices
formatted by 5.1.x have to be formatted again using 5.1.4.
Reasons for this:
1. If the media header is written already on a bad block because of the bug,
   in binary partitions it might be found using 5.1.4. 
2. There might be data loss:  Information that was written on bad blocks by
   5.1.x, will be ignored by 5.1.4, because the bad blocks will be ignored. 

Device Support
--------------
DiskOnChip TrueFFS driver for Windows CE version 5.1.4 supports all M-Systems 
DiskOnChip family of products, including:

- Mobile DiskOnChip Plus (16Mbytes-64MBytes)
- DiskOnChip Millennium Plus (16Mbytes-32MBytes) 
- DiskOnChip Millennium 8MB, Both DIP and TSOP packages.
- DiskOnChip DIMM2000
- DiskOnChip 2000 DIP (up to 1Gbytes) - including support in devices with 
    128MB Samsung Flash in capacities:
       low profile: 258MB, 384MB    - New!
       high profile: 768MB, 1GB     - New!


Contents
-----------
1. Installing the DiskOnChip(R) Product Family on Windows NT4
2. IOCTL Functionality of DiskOnChip Driver in version 5.1
3. Registry - Customize TrueFFS Driver Functionality
4. Known limitations of TrueFFS 5.1.4
5. How to contact us


1. Installing TrueFFS for DiskOnChip in Windows NT4
----------------------------------------------------
To work with the DiskOnChip on Windows NT 4.0, TrueFFS for
Windows NT must be installed. The following will guide you in this
process.

1.1 Installing DiskOnChip as additional drive in your system:

1.1.1 Insert the disk with TrueFFS installation files into a drive.
1.1.2 From the Windows NT display, open "My Computer" on your
      desktop or open the Windows NT Explorer.
1.1.3. Open the disk with TrueFFS installation files.
1.1.4. Click with the right mouse button on the file TrueFFS.inf.
       You will see a menu.
1.1.5. In the menu choose "Install" and click on it.
1.1.6. After Windows NT finishes copying the driver you will be
       asked to reboot your computer. After rebooting, the
       DiskOnChip will appear as another drive in your system.

NOTE:
	In Many cases, after reboot that DiskOnChip will be assigned 
	as the main drive (usually C: drive).
	As you know in Window NT4, the system page file is located on drive C:,
	this will cause a problem to format the DiskOnChip drive.
	therefore it is must to change the location of the system page file.

	in order to change the location of the page file do the following:
	1. Right-Click "My Computer" and select "Properties"
	2. Select the "Performance" Tab
	3. Select the Change button under the Virtual-Memory Section.
	4. Select C Drive (if not automatically selected)
	   and set the min and max size to 0 MB.
	5. if you want paging enabled, select other driver and set
	   his paging size to the required size.
	6. Apply, and after restart you will be able to format C drive.

1.2 Format DiskOnChip with NTFS, compress it and make it bootable on 
    Windows NT 4.0

 Assuming you already have DiskOnChip working in your system as additional 
 drive:

1.2.1 Create a Windows NT 4.0 installation to be copied to the
      DiskOnChip. You may use Microsoft Embedded NT 4.0 Target Designer
      or VenturCom Component Integrator to create a small footprint 
      installation (see below more details).
 1.2.2 Open Explorer, go to DiskOnChip drive and press right button on
       the mouse, then choose "Format" from the menu.
 1.2.3 Choose NTFS in "File System", Do NOT enable compression, and press
       "Start". Press "Close" when formatting is finished.
 1.2.4 Go to the drive and create new folder with the name "Winnt".
       Right-click on this folder and choose "Properties" from the menu.
 1.2.5 Check "Compress" and press "Ok". You will be given another
       screen with exclamation point warning that this action compresses
       all files but does not compress subfolders. Check "Also compress
       subfolders" and click "Ok".
 1.2.6 Copy all the files from your Windows NT 4.0 installation to
       the drive. You should copy all files from \Winnt directory to 
       the just created \Winnt directory on the DiskOnChip drive. Copy
       all files that should be in the root to the root of the DiskOnChip
       drive. Do NOT compress files in the root directory! The following
       files must reside in the root directory for Windows NT to boot:
       NTLDR, NTDETECT.COM and BOOT.INI.
 1.2.7 DiskOnChip is ready to boot Windows NT. If you want to boot it
       in the system you just used, you may disable your hard disk drive
       in the BIOS Setup or disconnect it thus letting the DiskOnChip
       be a boot device instead of your hard disk. Another option is to 
       rewrite a firmware on the DiskOnChip using switch /FIRST. This will
       make DiskOnChip a first "hard disk" in the system while your
       original hard disk will became a second disk.


1.3 Using the embedded Windows NT4.0 Target Designer to prepare
    small footprint embedded Windows NT 4.0

1.3.1 To use DiskOnChip as a bootable system disk, select the DiskOnChip As Disk 
      component under System\Devices\Storage\Fixed Disk. 
    
1.3.2 After creation of embedded NT 4.0 image you need to copy new TrueFFS
      driver into \WINNT\SYSTEM32\DRIVERS\Trueffs.sys file.


2. Activating TrueFFS and DiskOnChip Extended Functionality Using IOCTL Calls                                          
-----------------------------------------------------------------------------
The basic function of TrueFFS is to provide disk emulation of the
DiskOnChip. To do this, TrueFFS provides a standard block-device interface,
consisting in essence of the capability for reading sectors and writing sectors.
This capability is enough to enable file-systems and operating systems to manage 
the DiskOnChip as a storage device.

In addition to the standard storage device functionality, the DiskOnChip driver,
based on TrueFFS version. 5.1, provides extended functionality. This functionality
goes beyond simple data storage capability and support:

- Obtain information on DiskOnChip
- Hardware and software read/write protection
- Initiate garbage collection in the background
- Access the DiskOnChip binary partition
- Format DiskOnChip under Windows CE
- Read/write to/from the DiskOnChip OTP area
- Read the DiskOnChip unique device ID (UID)
- Activate Deep Power-Down mode (low power consumption mode)

For more details please refer to M-Systems
'Extended Functions of the DiskOnChip driver - Developer Guide'. 

These extended features are accessible through standard Windows IOCTL calls to 
the TrueFFS driver, using the API provided in the flioctl.h file. For more 
information on these IOCTL calls, refer to 
'Extended Functions of the DiskOnChip driver - Developer Guide'.


Implementation example of IOCTL Functionality (IOCTL_TFFS_GET_INFO )
--------------------------------------------------------------------
int  main(int argc, char *argv[])
{
  HANDLE drvDev;
  CHAR drvName[TFFS_DRV_NAME];
  int  i;

  // Get Device Handle
  drvDev = CreateFile(	(LPCTSTR)drvName, GENERIC_READ | GENERIC_WRITE,
                        FILE_SHARE_READ | FILE_SHARE_WRITE,
						NULL, OPEN_EXISTING, 0, NULL );
  // Choose Device by argument
  if( isalpha(*argv[ARG_START]) && (*(argv[ARG_START]+1) == ':') )
	sprintf(drvName,"\\\\.\\%c:",*argv[ARG_START]);
  else if( isdigit(*argv[ARG_START]) )
    sprintf(drvName,"\\\\.\\PHYSICALDRIVE%c",*argv[ARG_START]);
  else 
   return( 1 );
  

  if( drvDev == INVALID_HANDLE_VALUE ) {
	printf("Device %s Handle - Fail, Error = %ld\n",drvName,GetLastError());
	return( 2 );
  }
  else printf("Device %s Handle - Ok\n",drvName);

  printf("GetInfo..");
  ioctlCall(drvDev,IOCTL_TFFS_GET_INFO,NULL);

  CloseHandle(drvDev);
  drvDev = NULL;
  return( 0 );
}



void ioctlCall(HANDLE Dev, DWORD ioCtlCode, ... )
{
  va_list param;
  PCHAR paramPtr;
  BOOL status;
  DWORD inBufferSize, outBufferSize;
  DWORD retLength; // returned amount of data
  LPVOID lpInBuffer = NULL, lpOutBuffer = NULL;
  va_start(param,ioCtlCode);			// init parameter variable

  //IOCTL_TFFS_GET_INFO
  inBufferSize = 0;
  outBufferSize = sizeof(flDiskInfoOutput);
  lpOutBuffer = (LPVOID)malloc(outBufferSize);
  va_end(param);				// end parameter variable

  // ioctl call
  status = DeviceIoControl(Dev, ioCtlCode, lpInBuffer, inBufferSize,
			   lpOutBuffer, outBufferSize, &retLength, NULL);

	
  if( status == 0 ) {
    printf("Fail\n");
    if( lpInBuffer != NULL )
      free(lpInBuffer);
    if( lpOutBuffer != NULL )
      free(lpOutBuffer);
		return;
  }
  printf("Ok\n");

  // show returned data
	
      printf("Logical Sectors:    %x\n", 
        ((flDiskInfoOutput *)lpOutBuffer)->info.logicalSectors);
      printf("Boot Area Size:     %x Kbytes\n", 
          ((flDiskInfoOutput *)lpOutBuffer)->info.bootAreaSize / KBYTE);
      printf("Base Address:       %lx\n",
          ((flDiskInfoOutput *)lpOutBuffer)->info.baseAddress);
      printf("Flash Type:         %x\n",
          ((flDiskInfoOutput *)lpOutBuffer)->info.flashType);
      printf("Physical Size:      %x Mbytes\n",
          ((flDiskInfoOutput *)lpOutBuffer)->info.physicalSize / MBYTE);
      printf("Physical Unit Size: %d Kbytes\n",
          ((flDiskInfoOutput *)lpOutBuffer)->info.physicalUnitSize / KBYTE);
      printf("DOC Type:           %d\n", 
          ((flDiskInfoOutput *)lpOutBuffer)->info.DOCType);
      printf("Life Time (1-10):   %d\n", 
          ((flDiskInfoOutput *)lpOutBuffer)->info.lifeTime);
      printf("Driver version:     %s\n", 
          ((flDiskInfoOutput *)lpOutBuffer)->info.driverVer);
      printf("OSAK version:       %s\n", 
          ((flDiskInfoOutput *)lpOutBuffer)->info.OSAKVer);
      printf("Cyl/Head/Sec = %x/%x/%x\n",
              ((flDiskInfoOutput *)lpOutBuffer)->info.cylinders,
		      ((flDiskInfoOutput *)lpOutBuffer)->info.heads,
			  ((flDiskInfoOutput *)lpOutBuffer)->info.sectors);
 
  if( lpInBuffer != NULL )
    free(lpInBuffer);
  if( lpOutBuffer != NULL )
    free(lpOutBuffer);
}


3. Customize TrueFFS Driver Functionality through the Windows Registry                                         
----------------------------------------------------------------------
Starting from version (5.1.0), DiskOnChip driver can now be
customize through the Windows NT registry.

3.1 Registry Setup
    When installing the driver on the first time, the following Key directory
    is created:
	
	\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\trueffs
 
    This directory holds Trueffs customizable environment variables 

3.2 Registry Values
    the customized values can be located under the "Parameters" directory
    under the Key Directory mentioned in the last section.
   
  * FL_TL_CACHE_ENABLED	
    
    - Options: 0 / 1
    - Default Value: 1 (TRUE)      

    Enabling this option improves performance, but requires additional RAM 
    resources. The NAND Flash Translation Layer (NFTL and INFTL) uses a small 
    part of each flash unit and sector for control information that allows 
    accessing the data stored on DiskOnChip as a virtual block device. Setting 
    this option to 1 enables caching this information in order to improve 
    performance.

  * FL_VERIFY_WRITE_BDTLn	n=[1|2|3|4]
    
    - Options: 0 (verify write mode), 1 (optimized mode), 2 (standard mode)
    - Default Value: 2	(FL_UPS)
    
    Verify write mode - Sets TrueFFS to Read Before and After Write mode. 
    In this mode, each write operation is preceded by a read operation 
    verifying the flash area is indeed erased, and followed by a read operation 
    verifying the data was written properly. Only after both conditions are met 
    is the sector considered to be written properly. Selecting this option 
    results in lower write performance, but insures absolute data protection 
    against power failures or any other event (such as errors caused from noisy 
    buses, faulty flash, or flash close to its end of life).
    
    Optimized mode - Sets TrueFFS to Optimized Verify Write mode. 
    In this mode, a sector is assumed to remain valid after it has been 
    verified as long as no sudden power down event occurs, therefore, no 
    additional read operations (verifications) are performed. When recovering 
    from a power failure, TrueFFS gradually verifies the validity of 
    additional sectors as data is written to the disk partition. 
    All the sectors on the disk are eventually verified, at which point no 
    further verification is done and peak performance is achieved.

    Standard mode - Sets TrueFFS to Standard mode. In this mode, a sector is 
    considered written successfully when the flash media reports that the write 
    operation ended successfully. Additional verification (using a read 
    operation) is not performed, so TrueFFS works at peak performance 
    regardless of past power failure events. This is the default mode for 
    devices supported by NFTL, as these devices do not require additional 
    verification for most applications.
   

3.3 Restore Registry Default Values.
    In order to restore the default values of the DiskOnChip driver,
    please install again the inf file that comes with this version of the driver.
    (right click on the inf file, and confirm the install operation)

3.4 For More Details and other Registry Issues, please contact M-systems.



4. Known limitations of TrueFFS 5.1.4
-------------------------------------
4.1 The IOCTL  for activating Deep Power-Down mode is not supported.
4.2 When formatting an 8MB disk (BDTL) partition, use the native file systems 
    high level format and not the TrueFFS built in FAT formatter.
4.3 Protected partitions must not use the key (password) "00000000" (ASCII 0)
4.4 If a wrong key or no key were used when writing to a protected disk partition
    a dismount must be performed prior to any other access to that partition.


5. HOW TO CONTACT US
--------------------

  Please visit our website for the latest driver versions and updated 
  information.  

  Internet:      http://www.m-sys.com
  
  E-mail:	 info@m-sys.com
  
  USA:           M-Systems Inc. 
                 8371 Central Ave, Suite A 
                 Newark CA 94560 USA
  		 Phone: +1-510-494-2090
  		 Fax:   +1-510-494-5545
  
  Taiwan:        M-System Asia Ltd. 
                 Room B, 13F, No. 133, Sec. 3
  		 Min Sheng East Road
                 Taipei, Taiwan
                 R.O.C.
                 Phone: +886-2-8770-6226
  		 Fax:   +886-2-8770-6295

  Japan:         M-Systems Japan Inc. 
                 Asahi Seimei Gotanda Bldg., 3F
                 5-25-16 Higashi-Gotanda
                 Shinagawa-ku Tokyo, 141-0022
                 Phone: +81-3-5423-8101
                 Fax:   +81-3-5423-8102
  
  China:         M-Systems China Ltd.
                 25A International Business Commercial Bldg.
                 Nanhu Rd., Lou Hu District
                 Shenzhen, China 518001
                 Phone: +86-755-2519-4732
                 Fax:   +86-755-2519-4729

  Europe/Israel: M-Systems Ltd. 
                 Central Park 2000 
                 7 Atir Yeda St. 
                 Kfar Saba 44425, Israel
  		 Tel: 972-9-764-5000
  		 Fax: 972-3-548-8666
  
  
   2002 M-Systems Flash Disk Pioneers, Ltd. All rights reserved.
  This document is for information use only and is subject to 
  change without prior notice. M-Systems Flash Disk Pioneers Ltd. 
  assumes no responsibility for any errors that may appear in this
  document. No part of this document may be reproduced, transmitted,
  transcribed, stored in a retrievable manner or translated into
  any language or computer language, in any form or by any means, 
  electronic, mechanical, magnetic, optical, chemical, manual or 
  otherwise, without prior written consent of M-Systems.

  M-Systems products are not warranted to operate without failure. 
  Accordingly, in any use of the Product in life support systems or
  other applications where failure could cause injury or loss of
  life, the Product should only be incorporated in systems designed
  with appropriate and sufficient redundancy or backup features.
  Contact your local M-Systems sales office or distributor, or visit
  our website at www.m-sys.com to obtain the latest specifications 
  before placing your order.

  DiskOnChip, DiskOnChip Millennium, DiskOnKey and TrueFFS are 
  registered trademarks of M-Systems. FFD and SuperMAP are trademarks
  of M-Systems. Other product names mentioned in this document may be
  trademarks or registered trademarks of their respective owners and 
  are hereby acknowledged.
