U-Boot + TFFS(Sandisk MDOC H3) Part II

Added: private/ems/u-boot/common/cmd_tffs.c
===================================================================
--- private/ems/u-boot/common/cmd_tffs.c	                        (rev 0)
+++ private/ems/u-boot/common/cmd_tffs.c	2007-10-23 18:48:53 UTC (rev 1156)
@@ -0,0 +1,53 @@
+#include 
+#include 
+
+int stat;
+
+extern int hxMemcopy (int partitionNum, int numOfSectors, volatile unsigned long* dest);
+
+static int tffs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+    unsigned long addr, size, sectors;
+    unsigned part;
+    
+    if( argc < 4 )
+        size = 0L;
+    else
+	size = simple_strtoul(argv[3], NULL, 16);
+
+    if( argc < 3 )
+	addr = 0x80000000L;
+    else	    
+	addr = simple_strtoul(argv[2], NULL, 16);
+
+    if( argc < 2 )
+	part = 1;
+    else
+	part = (unsigned)simple_strtoul(argv[1], NULL, 16);
+
+
+   // transform bytes to sectors => 
+   sectors =(size/512)+1;
+
+
+    //printf("## Loading Image 0x%08lX bytes from %d to 0x%08lX ...n", 
+   //        size, part, addr);
+    printf("## Loading Image 0x%08lX sectors from %d to 0x%08lX ...n", 
+           sectors, part, addr);
+    
+
+
+    //stat = tffsLoadImage( part, addr, size );
+    stat =  hxMemcopy( part, sectors, addr );
+    if( stat )
+	printf("FAILED(%d)n",stat);
+    else
+	printf("OKn");
+    return( stat );
+}
+
+U_BOOT_CMD(
+	tffs_load,4,1,tffs_load,
+	"tffs_loadt- load image from H3n",
+	"tffs_load part addr sizen"
+);

Modified: private/ems/u-boot/include/configs/vpm.h
===================================================================
--- private/ems/u-boot/include/configs/vpm.h	2007-10-20 21:45:38 UTC (rev 1155)
+++ private/ems/u-boot/include/configs/vpm.h	2007-10-23 18:48:53 UTC (rev 1156)
@@ -7,10 +7,7 @@
 
 #define CONFIG_VPM
 
-/* Since we are not PPC, we need to fake it */
-# define EIEIO          /* nothing */
 
-
 #define CFG_LONGHELP		1
 #define CONFIG_CMDLINE_EDITING	1
 #define CONFIG_BAUDRATE		115200
@@ -191,16 +188,16 @@
 #endif
 
 /* DiskOnChip related stuff */
-#define ADD_DOC_CMD             CFG_CMD_DOC
+/*#define ADD_DOC_CMD             CFG_CMD_DOC
 #define CFG_NAND_LEGACY
 #define CFG_DOC_SHORT_TIMEOUT
-#define CFG_MAX_DOC_DEVICE      1       /* Max number of DOC devices    */
+#define CFG_MAX_DOC_DEVICE      1       
 
 #define CFG_DOC_SUPPORT_2000
 #define CFG_DOC_SUPPORT_MILLENNIUM
 #define CFG_DOC_BASE            0x20000000
 #define CFG_DOC_SIZE            0x10000000
-
+*/
 #if ((BFIN_BOOT_MODE == BF537_BYPASS_BOOT) || (BFIN_BOOT_MODE == BF537_UART_BOOT))
 #define CONFIG_COMMANDS			(CONFIG_BFIN_CMD| 
 					 CFG_CMD_ELF	| 
@@ -223,12 +220,11 @@
 					 CFG_CMD_DHCP   | 
 					 ADD_IDE_CMD	| 
 					 CFG_CMD_POST_DIAG | 
-					 CFG_CMD_DOC | 
 					 CFG_CMD_DATE)
 #endif
 
 #define CONFIG_BOOTARGS "root=/dev/mtdblock0 rw console=ttyBF0,115200"	
-#define CONFIG_LOADADDR	0x1000000
+#define CONFIG_LOADADDR	0x2000000
 
 #if ((BFIN_BOOT_MODE == BF537_BYPASS_BOOT) || (BFIN_BOOT_MODE == BF537_UART_BOOT))
 #if (BFIN_CPU != ADSP_BF534)

Added: private/ems/u-boot/tffs/Makefile
===================================================================
--- private/ems/u-boot/tffs/Makefile	                        (rev 0)
+++ private/ems/u-boot/tffs/Makefile	2007-10-23 18:48:53 UTC (rev 1156)
@@ -0,0 +1,21 @@
+include $(TOPDIR)/config.mk
+
+LIB = tffs.a
+
+OBJS =hxMemcopy.o 
+#OBJS += flbase.o docbdk.o docsoc.o g4_mtd.o g4_lgc.o bch_hm.o saftl.o matchalg.o
+
+all:    $(LIB)
+
+$(LIB): $(START) $(OBJS)
+	$(AR) crv $@ $(OBJS)
+
+#########################################################################
+
+.depend:    Makefile $(OBJS:.o=.c)
+	$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+
+include $(SRCTREE)/rules.mk
+sinclude ($obj).depend
+
+#########################################################################

Added: private/ems/u-boot/tffs/hxMemcopy.c
===================================================================
--- private/ems/u-boot/tffs/hxMemcopy.c	                        (rev 0)
+++ private/ems/u-boot/tffs/hxMemcopy.c	2007-10-23 18:48:53 UTC (rev 1156)
@@ -0,0 +1,283 @@
+
+#include "hxMemcopy.h"
+
+
+/* 
+*	Function prototypes - for function pointers
+*/
+
+FLSNative doch_sleep_nor ( FLSNative    socketNo,FLDword millisec);
+FLSNative hal_blk_read_nor ( volatile FLByte * base,FLSNative reg,FLByte * buf,FLSNative bytes );
+void flWrite8bitUsing16bitsSingleShift(volatile  FLByte * win, FLWord offset,Reg8bitType val);
+Reg8bitType  flRead8bitUsing16bitsSingleShift(volatile  FLByte * win,FLWord offset);
+/*
+*	Function prototypes 
+*/
+
+DOCH_Error ready ( FLByte *BaseAddress,DOCH_Reg reg,FLByte mask,FLByte	on_bits,FLDword	millisec );
+
+
+/****************************************
+*
+*	Define Here the following
+*
+****************************************/
+
+#define HDOC_START_ADDRESS				0x20000000
+#define GetPointerFromPhysAddress(A)	(A)
+
+/****************************************************************************** 
+ *                                                                            * 
+ *                             ipl_start									  * 
+ *                                                                            * 
+ *  Read sectors from DOCH device.                                            * 
+ *                                                                            * 
+ *  Parameters :                                                              *
+ *                                                                            * 
+ *  Returns :                                                                 * 
+ *      DOCH_OK in success, otherwise respective error code.                  *
+ *                                                                            * 
+ ******************************************************************************/
+int hxMemcopy (int partitionNum, int numOfSectors, volatile unsigned long* dest)
+{    
+	
+	FLNative	secPerformed;
+	FLNative	offset = 0;
+	DOCH_Error  	rc = 0;
+	//FLWord		regVal = 0;
+	//FLWord		regVal2 = 0;
+	FLWord		total_num_of_sectors = numOfSectors;
+	FLNative    	sectors_to_read = 0, sectors_already_read = 0;
+	FLByte		*BaseAddress =  (FLByte*)GetPointerFromPhysAddress (HDOC_START_ADDRESS+HIB_CORE_ADDRESS);
+
+  	/*********************************
+	*	Taken from SDK init sequence
+	*	Set Operation Mode Register:
+	*	- Address shifting
+	*	- NON-PIPE Access
+	*********************************/
+	
+	*(FLByte*)(BaseAddress + HIB_OPERATION_MODE_REG) = (HIB_ADDR_SHIFT | HIB_NON_PIPE_ACCESS);
+	
+	BaseAddress += DOCH_CONT_REG_AREA;
+
+	/*****************************************************************
+	*	total_num_of_sectors  stands for the total number of sectors
+	* 	that contain the full SPL image.
+	*	Each blk read can be performed upto 256 sectors each time
+	*	Therefore nested loop untill no more sectors to read
+	******************************************************************/
+	while(sectors_already_read < total_num_of_sectors)
+	{
+		FLDword start_sector;
+		sectors_to_read = total_num_of_sectors - sectors_already_read;
+
+		if (sectors_to_read > DOCH_MAX_SECTORS)
+			sectors_to_read = DOCH_MAX_SECTORS;
+
+		/*
+ 		 * Wait for BUSY bit to clear
+ 		 */
+		if ((rc = ready( BaseAddress, DOCH_ALT_STATUS_REG, DOCH_BUSY, 0, DOCH_LONG_WAIT)) != DOCH_OK)
+		{
+			printf("rnio_input(): ATA not Ready (before command) rn");
+			printf("rc = 0x%x rn",rc);
+			return rc;
+		}
+
+		/* Current itteration starting sector to read */
+		start_sector = sectors_already_read;
+		if (rc == DOCH_OK)
+		{
+			/* Write ATA registers */
+			flWrite8bitUsing16bitsSingleShift(BaseAddress,
+					(FLWord)DOCH_SECTOR_CNT_REG, (Reg8bitType)sectors_to_read);
+			flWrite8bitUsing16bitsSingleShift(BaseAddress,
+					(FLWord)DOCH_SECTOR_NO_REG, (Reg8bitType)start_sector);
+			flWrite8bitUsing16bitsSingleShift(BaseAddress,
+					(FLWord)DOCH_CYLINDER_LOW_REG,
+					(Reg8bitType)(FLByte)(start_sector>>8));
+			flWrite8bitUsing16bitsSingleShift(BaseAddress,
+					(FLWord)DOCH_CYLINDER_HIGH_REG,
+					(Reg8bitType)(FLByte)(start_sector>>16));
+			/* The following is Partition number */
+			flWrite8bitUsing16bitsSingleShift(BaseAddress,
+					(FLWord)DOCH_FEATURES_REG, (Reg8bitType)partitionNum);
+			flWrite8bitUsing16bitsSingleShift(BaseAddress,
+					(FLWord)DOCH_DRIVE_HEAD_REG,
+					(Reg8bitType)(FLByte) (((start_sector >> 24) & 0x0f) | DOCH_LBA ));
+			flWrite8bitUsing16bitsSingleShift(BaseAddress,
+					(FLWord)DOCH_COMMAND_REG, (Reg8bitType)DOCH_VSCMD_READ_PARTITION);
+			/**************************************************		 
+			 *	Perform per-sector
+			 *	1. Wait until device is ready to receive data
+			 *	2. Xfer 1 sector
+			 **************************************************/
+			for(secPerformed=0; secPerformed 0)
+    {
+		status = (Reg8bitType)FLREAD_IO_WORD(( ((volatile FLWord *)BaseAddress)+((FLWord)reg) ));
+        if ((status & mask) == on_bits)
+        { 
+            /* read status once again, just to be sure .. */
+            /*if ((hal_get_reg8(pdev->device[devNum].bRegBase, reg) & mask) == on_bits)*/
+                return DOCH_OK;
+        }
+		/*If an error was detected - return the error code*/
+		/***********************************************	
+		*	We might want to know the error code....
+		************************************************/
+		else if((status & DOCH_ERROR) == DOCH_ERROR)
+		
+		{
+				
+#ifdef REDUCED_SIZE
+			error = (Reg8bitType)FLREAD_IO_WORD(( ((volatile FLWord *)BaseAddress) +((FLWord)(DOCH_ERROR_REG)) ));
+			DBG_PRINT_ERR(FLZONE_ATA, "ready(): ATA Error: ");
+			DBG_PRINT_ERR_PRM(FLZONE_ATA, (FLTXT("0x%x "), error));
+			DBG_PRINT_ERR(FLZONE_ATA, "rn");
+			return error;
+#else
+			return DOCH_ERROR;
+#endif
+		
+		}
+    }
+
+	DBG_PRINT_ERR(FLZONE_ATA, "rnready(): Timed Outrn");
+    return DOCH_TimedOut;
+}
+
+/****************************************************************************** 
+ *                                                                            * 
+ *                  d o c h _ s y s _ b l k _ r e a d                         * 
+ *                                                                            * 
+ *  Read 'bytes' bytes from DOCH (usually 512 bytes).                         * 
+ *                                                                            * 
+ *  Parameters :                                                              *
+ *      base                 : pointer to the base of DOCH register set       *
+ *      reg                  : register's offset (in bytes) from 'base'       *
+ *      buf                  : buffer to read to                              *
+ *      bytes                : number of bytes to read (must be even)         *
+ *                                                                            * 
+ *  Returns :                                                                 * 
+ *      always zero (success)                                                 *
+ *                                                                            * 
+ ******************************************************************************/
+
+FLSNative hal_blk_read_nor ( volatile FLByte * base, 
+							 FLSNative         reg, 
+							 FLByte          * buf, 
+							 FLSNative         bytes )
+{
+  volatile FLWord * reg16 ;
+  register FLSNative  max;
+  FLWord temp;
+ 
+ 
+  reg16 = (volatile FLWord *)((FLSNative)base + reg);
+
+//patch - to solve access problem	
+  max   = (FLSNative)buf + bytes;
+  for (; (FLSNative)buf < max; buf+=2)
+  {
+	temp = *reg16;
+    buf[0]  = (FLByte)temp;
+	buf[1]  = temp >>0x8;
+  }
+
+  return 0;
+}
+
+
+/*----------------------------------------------------------------------
+   f l W r i t e 8 b i t U s i n g 16 b i t s S i n g l e S h i f t
+
+   Note : Data is written only to 8-LSB.
+
+   Write 8-bits Using 16-bits operands with Single address shifted.
+------------------------------------------------------------------------*/
+
+void flWrite8bitUsing16bitsSingleShift(volatile  FLByte * win, FLWord offset,Reg8bitType val)
+{
+   FLWRITE_IO_WORD((FLWord)val,(((volatile FLWord *)win)+offset));
+}
+
+/*----------------------------------------------------------------------
+   f l R e a d 8 b i t U s i n g 16 b i t s S i n g l e S h i f t
+
+   Note : Assume data is found in 8-LSB of DiskOnChip
+
+   Read 8-bits Using 16-bits operands with Single address shifted.
+------------------------------------------------------------------------*/
+
+Reg8bitType  flRead8bitUsing16bitsSingleShift(volatile  FLByte * win,FLWord offset)
+{
+   return( (Reg8bitType)FLREAD_IO_WORD((((volatile FLWord *)win)+offset)) );
+}
+

Added: private/ems/u-boot/tffs/hxMemcopy.h
===================================================================
--- private/ems/u-boot/tffs/hxMemcopy.h	                        (rev 0)
+++ private/ems/u-boot/tffs/hxMemcopy.h	2007-10-23 18:48:53 UTC (rev 1156)
@@ -0,0 +1,291 @@
+
+/******************************************************************************
+ *                                                                            *
+ * Project: DOC Driver for Linux 2.6 Block device driver for mDOC H3  family  *
+ * of devices under Linux kernel 2.6.                                         *
+ *                                                                            *
+ *   Version: 1.0                                                             *
+ *   Email questions to: oemsupport at sandisk.com                               *
+ *   Copyright (C) SanDisk IL Ltd. 1995 - 2007                                *
+ *   SanDisk IL Ltd., 7 Atir Yeda Street, Kfar Saba 44425, Israel             *
+ *                                                                            *
+ ******************************************************************************
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or modify it    *
+ * under the terms of the GNU General Public License as published by the Free *
+ * Software Foundation; either version 2 of the License, or any later version.*
+ * This program is distributed in the hope that it will be useful, but WITHOUT*
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      *
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for  *
+ * more details, which is set forth in the readme.txt file.                   *
+ * You should have received a copy of the GNU General Public License along    *
+ * with this program; if not, write to the Free Software Foundation, Inc., 51 *
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA                    *
+ *                                                                            *
+ * This License does not grant you any right to use the trademarks, service   *
+ * marks or logos of SanDisk IL Ltd. or SanDisk Corporation.                  *
+ * Subject to the foregoing, SanDisk IL Ltd., for itself and on behalf of its *
+ * licensors, hereby reserves all intellectual property rights in the program,*
+ * except for the rights expressly granted in this License.                   *
+ *                                                                            *
+ ******************************************************************************/
+ 
+/*
+ * $Log$
+ */
+
+
+
+/**************************************************************************/
+/* General types definitions                                              */
+/*   TrueFFS interface of all packages uses the following types as the    */
+/*   variable definision.                                                 */
+/**************************************************************************/
+
+typedef int            FLBoolean;
+typedef unsigned char  FLByte;           /* 8  bit unsigned variable */
+typedef unsigned short FLWord;           /* 16 bit unsigned variable */
+typedef unsigned long  FLDword;          /* 32 bit unsigned variable */
+typedef unsigned int   FLNative;         /* Native variable at least 16 bits */
+typedef signed char    FLSByte;          /* 8  bit signed variable */
+typedef signed short   FLSWord;          /* 16 bit signed variable */
+typedef signed long    FLSDword;         /* 32 bit signed variable */
+typedef int            FLSNative;        /* Signed native variable at least 16 bits */
+typedef FLSWord        FLWchar;          /* Unicode type variable */
+
+#define DOCH_USING_8K_WIN
+
+#ifdef DOCH_USING_8K_WIN
+//	#define HIB_CORE_ADDRESS			0x20000000
+	#define HIB_CORE_ADDRESS			0x0000
+	#define DOCH_CONT_REG_AREA			HIB_CORE_ADDRESS + 0x0800
+	#define	DOCH_DATA_PORT_AREA			HIB_CORE_ADDRESS + 0x1000
+	#define	DOCH_CONFIG_REG_AREA		HIB_CORE_ADDRESS + 0x1400
+	
+	#define DOCH_MEM_WIN_SIZE			0x2000	/*8KB*/
+
+#else /* DOCH_USING_8K_WIN */
+
+#ifdef DOCH_PCI_ACCESS
+	#define HIB_CORE_ADDRESS			0x0000
+	#define DOCH_MEM_WIN_SIZE			0x8000	/*32KB*/
+	#define	HIB_PCI_CONTROL_REGISTER	0x7FFF	/*Constant, No offset*/
+#else /*DOCH_PCI_ACCESS*/
+	#define HIB_CORE_ADDRESS 0x8000
+	#define DOCH_MEM_WIN_SIZE			0x20000	/*128KB*/
+#endif /*DOCH_PCI_ACCESS*/
+
+	#define DOCH_CONT_REG_AREA			0x0
+	#define	DOCH_DATA_PORT_AREA			0x0800
+	#define	DOCH_CONFIG_REG_AREA		0x1400
+	#define	DOCH_PRIMARY_SECONDARY_AREA	0x1800
+
+
+#endif /* DOCH_USING_8K_WIN */
+
+#define	HIB_OPERATION_MODE_REG			DOCH_CONFIG_REG_AREA + 0x14
+#define	HIB_NO_ADDR_SHIFT	0x00
+#define	HIB_ADDR_SHIFT		0x02
+/*Operation Mode Register*/
+#define	HIB_NON_PIPE_ACCESS	0x00
+#define	HIB_PIPE_ACCESS		0x01
+
+/* bits for DOCH_DRIVE_HEAD_REG register */
+#define DOCH_DEVICE     0x10
+#define DOCH_LBA        0x40
+#define DOCH_DRIVE_HEAD 0xA0
+
+/* size of DOCH data block in FLBytes */
+#define DOCH_SECTOR_SIZE  512
+#define	DOCH_SECTOR_SIZE_BITS 9
+
+
+/* bits in DOCH_STATUS_REG and DOCH_ALT_STATUS_REG registers */
+#define DOCH_ERROR      0x01
+#define DOCH_DRQ        0x08
+#define DOCH_DSC        0x10
+#define DOCH_READY      0x40
+#define DOCH_BUSY       0x80
+
+#define DOCH_MAX_SECTORS  256
+
+
+/* all DOCH error codes */
+#define DOCH_ATA_ERROR_BASE	0x0
+#define DOCH_SDK_ERROR_BASE	0x100
+#define DOCH_FS_ERROR_BASE  0x200
+
+#ifdef DOCH_FPGA_SIM
+	/* 'long'  DOCH operations can take up to DOCH_LONG_WAIT milliseconds  */
+	#define DOCH_LONG_WAIT   5000
+	/* 'short' DOCH operations can take up to DOCH_SHORT_WAIT milliseconds */
+	#define DOCH_SHORT_WAIT  5000
+#else /*DOCH_FPGA_SIM*/
+	/* 'long'  DOCH operations can take up to DOCH_LONG_WAIT milliseconds  */
+	#define DOCH_LONG_WAIT   500
+	/* 'short' DOCH operations can take up to DOCH_SHORT_WAIT milliseconds */
+	#define DOCH_SHORT_WAIT  5
+#endif /*DOCH_FPGA_SIM*/
+
+
+typedef enum { DOCH_OK                  = 0,
+
+			   /*ATA Error codes*/
+			   DOCH_AtaDeviceNotFound   = DOCH_ATA_ERROR_BASE	+ 6,
+			   DOCH_UnknownATACmd		= DOCH_ATA_ERROR_BASE	+ 7,
+               DOCH_NoSpaceInVolume     = DOCH_ATA_ERROR_BASE	+ 10,
+               DOCH_NoSpaceInDevice     = DOCH_ATA_ERROR_BASE	+ 11,
+               DOCH_PartitionNotProtected = DOCH_ATA_ERROR_BASE + 20,
+               DOCH_NoWriteAccess       = DOCH_ATA_ERROR_BASE	+ 21,
+               DOCH_NoReadAccess        = DOCH_ATA_ERROR_BASE	+ 22,
+               DOCH_PartitionProtected  = DOCH_ATA_ERROR_BASE	+ 23,
+               DOCH_WrongPasskey		= DOCH_ATA_ERROR_BASE	+ 24,
+               DOCH_PartitionOTPEnabled = DOCH_ATA_ERROR_BASE	+ 25,
+               DOCH_TimedOut            = DOCH_ATA_ERROR_BASE	+ 30,
+               DOCH_PartitionNotFormatted = DOCH_ATA_ERROR_BASE + 35,
+               DOCH_SectorExceedsVolume	= DOCH_ATA_ERROR_BASE	+ 40,
+               DOCH_AtaVerifyFault      = DOCH_ATA_ERROR_BASE	+ 41,
+
+               /*SDK Error Codes*/
+			   DOCH_GeneralFailure      = DOCH_SDK_ERROR_BASE + 5,
+               DOCH_AdapterNotFound     = DOCH_SDK_ERROR_BASE + 6,
+               DOCH_BadFunction         = DOCH_SDK_ERROR_BASE + 10,
+               DOCH_BadParameter        = DOCH_SDK_ERROR_BASE + 15,
+               DOCH_DriveNotAvailable   = DOCH_SDK_ERROR_BASE + 20,
+               DOCH_DriveNotReady       = DOCH_SDK_ERROR_BASE + 25,
+               DOCH_FormattingError     = DOCH_SDK_ERROR_BASE + 30,
+               DOCH_NotEnoughMemory     = DOCH_SDK_ERROR_BASE + 35,
+               DOCH_ReadFault           = DOCH_SDK_ERROR_BASE + 40,
+               DOCH_WriteFault          = DOCH_SDK_ERROR_BASE + 41,
+               DOCH_VerifyFault         = DOCH_SDK_ERROR_BASE + 42,
+               DOCH_UnknownCmd          = DOCH_SDK_ERROR_BASE + 45,
+               DOCH_UnknownMedia        = DOCH_SDK_ERROR_BASE + 50,
+               DOCH_DiskNotFound        = DOCH_SDK_ERROR_BASE + 55,
+               DOCH_PartitionNotFound	= DOCH_SDK_ERROR_BASE + 60,
+               DOCH_FeatureNotSupported	= DOCH_SDK_ERROR_BASE + 65,
+			   DOCH_ATABusyNotCleared	= DOCH_SDK_ERROR_BASE + 70,
+			   DOCH_ATANotReady			= DOCH_SDK_ERROR_BASE + 71,
+			   DOCH_ATAErrorDetected	= DOCH_SDK_ERROR_BASE + 72
+
+} DOCH_Error;
+
+/* Ata registers structure */
+typedef struct {  FLByte bFeaturesError;/* DOCH_FEATURES_REG or DOCH_ERROR_REG	*/
+				  FLByte bSectorCount;	/* DOCH_SECTOR_CNT_REG	*/
+				  FLByte bSectorNumber;	/* DOCH_SECTOR_NO_REG	*/
+				  FLByte bCylLow;		/* DOCH_CYLINDER_LOW_REG	*/
+				  FLByte bCylHigh;		/* DOCH_CYLINDER_HIGH_REG	*/
+				  FLByte bDriveHead;	/* DOCH_DRIVE_HEAD_REG	*/
+				  FLByte bCommandStatus;/* DOCH_COMMAND_REG	or DOCH_STATUS_REG*/
+} DOCH_Registers;
+
+typedef enum { 
+			   DOCH_DATA_REG          = DOCH_CONT_REG_AREA,
+			   DOCH_ERROR_REG         = 0x01,
+               DOCH_FEATURES_REG      = 0x01,
+               DOCH_SECTOR_CNT_REG    = 0x02,
+               DOCH_SECTOR_NO_REG     = 0x03,
+               DOCH_CYLINDER_LOW_REG  = 0x04,
+               DOCH_CYLINDER_HIGH_REG = 0x05,
+               DOCH_DRIVE_HEAD_REG    = 0x06,
+               DOCH_STATUS_REG        = 0x07,
+               DOCH_COMMAND_REG       = 0x07,
+               DOCH_ALT_STATUS_REG    = 0x0E,
+               DOCH_CONTROL_REG		  = 0x0E
+} DOCH_Reg;
+
+/* set of DOCH Vendor-Specific ATA Commands */
+typedef enum { 
+			   /*I/O*/
+			   DOCH_VSCMD_READ_PARTITION		= 0x82,
+               DOCH_VSCMD_WRITE_PARTITION		= 0x83,
+			   DOCH_VSCMD_WRITE_FLEXI			= 0x84,
+			   DOCH_VSCMD_VERIFY				= 0x85,
+
+			   /*Sectors Operations*/
+			   DOCH_VSCMD_OPTIMIZE_SECTORS		= 0x86,
+			   DOCH_VSCMD_ERASE_SECTORS			= 0x88,
+
+			   /*Hash*/
+			   DOCH_VSCMD_READ_CALCULATED_HASH	= 0x8A,
+			   DOCH_VSCMD_WRITE_CALCULATED_HASH	= 0x8B,
+			   DOCH_VSCMD_READ_ORIGINAL_HASH	= 0x8C,
+			   DOCH_VSCMD_WRITE_GIVEN_HASH		= 0x8D,
+
+			   /*Sub-commanded commands*/
+			   DOCH_VSCMD_PARTITION_MANAGEMENT	= 0xFA,
+			   DOCH_VSCMD_ACCESS_CONTROL		= 0xFB,
+               DOCH_VSCMD_EXT_DEVICE_CTRL		= 0xFC,
+               DOCH_VSCMD_EXT_SECURITY_CTRL		= 0xFD,
+
+			   /*Supported standard ATA commands*/
+			   DOCH_CMD_IDENTIFY_DEV            = 0xEC,
+			   DOCH_DOWNLOAD_MICROCODE			= 0x92
+
+} DOCH_Command;
+
+typedef FLByte Reg8bitType;
+typedef FLWord Reg16bitType;
+
+
+/*Max number of devices per ATA socket (defined by ATA standard)*/
+#define ATA_MAX_NUM_OF_DEVICES	2
+
+/* size of DOCH data block in FLBytes */
+#define DOCH_SECTOR_SIZE  512
+#define	DOCH_SECTOR_SIZE_BITS 9
+
+/* 
+ * Length of DOCH register 'read' cycle in nanoseconds (default value should
+ * do for most systems).
+ */
+
+#define DOCH_ACCESS_NANOSEC  15
+
+
+
+
+#ifndef FAR0
+#define FAR0 
+#endif /* FAR0 */
+
+#ifndef FAR1
+#define FAR1
+#endif /* FAR1 */
+
+
+#ifndef FLREAD_IO_WORD
+#define FLREAD_IO_WORD(address)           (*((volatile FLWord FAR0*)(address)))
+#endif
+
+#ifndef FLWRITE_IO_WORD
+#define FLWRITE_IO_WORD(val,address)      *((volatile FLWord FAR0*)(address))=(FLWord)(val)
+#endif
+
+
+
+#ifndef DBG_PRINT_FLOW
+#define DBG_PRINT_FLOW(zone,str)    /* if (zone & (ACTIVE_DEBUG_ZONE)) printf (str) */
+#endif
+#ifndef DBG_PRINT_ERR
+#define DBG_PRINT_ERR(zone,str)     /* if (zone & (ACTIVE_DEBUG_ZONE)) printf (str) */
+#endif
+#ifndef DBG_PRINT_WRN
+#define DBG_PRINT_WRN(zone,str)     /* if (zone & (ACTIVE_DEBUG_ZONE)) printf (str) */
+#endif
+#ifndef DBG_PRINT_FLOW_PRM
+#define DBG_PRINT_FLOW_PRM(zone,str) /* if (zone & (ACTIVE_DEBUG_ZONE)) printf str */
+#endif
+#ifndef DBG_PRINT_ERR_PRM
+#define DBG_PRINT_ERR_PRM(zone,str)  /* if (zone & (ACTIVE_DEBUG_ZONE)) printf str */
+#endif
+#ifndef DBG_PRINT_WRN_PRM
+#define DBG_PRINT_WRN_PRM(zone,str)  /* if (zone & (ACTIVE_DEBUG_ZONE)) printf str */
+#endif
+
+#ifndef DFORMAT_PRINT 
+#define DFORMAT_PRINT(a)             DBG_PRINT_WRN_PRM(FLZONE_FORMAT,a)
+#endif 
+#ifndef DEBUG_PRINT
+#define DEBUG_PRINT(a)               DBG_PRINT_WRN(FLZONE_FULL,a)
+#endif 
廣告

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s

%d 位部落客按了讚: