⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atapiapi.h

📁 2443 wince5.0 bsp, source code
💻 H
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*****************************************************************************
* Filename: SDAPI.H - Defines & structures for HDTK API
*                     
* SanDisk Host Developer's Toolkit
*
* Copyright (c) 1996-2000 SanDisk Corporation
* Copyright EBS Inc. 1996
* All rights reserved.
* This code may not be redistributed in source or linkable object form
* without the consent of its author.
*
* Description: 
*       Provide FILE SYSTEM API as well as INTERFACE API to different
*       SANDISK products such as ATA PC Cards, CF, SPI, MMC, so on....
*
*       The API provides the initial state, transaction state,
*       device status andclosing state for IDE or PCMCIA, SPI and 
*       MMC controllers.
*
*****************************************************************************/

#ifndef __SDAPI_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "defines.h"

/* HDTK Version */
#define HDTK_MAJOR      4
#define HDTK_MINOR      00


#define HDTK_VERSION    ((HDTK_MAJOR << 8) + HDTK_MINOR)


/* Type Definitions of HDTK */

/* Include development environment settings */

/* Include kernel specific definitions */


/* Error codes */

#define PCERR_FAT_FLUSH         0  /* Cant flush FAT */
#define PCERR_INITMEDI          1  /* Not a DOS disk */
#define PCERR_INITDRNO          2  /* Invalid driveno */
#define PCERR_INITCORE          3  /* Out of core */
#define PCERR_INITDEV           4  /* Can't initialize device */
#define PCERR_INITREAD          5  /* Can't read block 0 */
#define PCERR_INITWRITE         6  /* Can't write block 0 */
#define PCERR_BLOCKCLAIM        7  /* PANIC: Buffer Claim */
#define PCERR_BLOCKLOCK         8  /* Warning: freeing a locked buffer */
#define PCERR_REMINODE          9  /* Trying to remove inode with open > 1 */
#define PCERR_FATREAD           10  /* IO Error While Failed Reading FAT */
#define PCERR_DROBJALLOC        11 /* Memory Failure: Out of DROBJ Structures */
#define PCERR_FINODEALLOC       12 /* Memory Failure: Out of FINODE Structures */



/*********************** CRITICAL_ERROR_HANDLER ******************************/
/* Arguments to critical_error_handler() */
#define CRERR_BAD_FORMAT        301
#define CRERR_NO_CARD           302
#define CRERR_BAD_CARD          303
#define CRERR_CHANGED_CARD      304
#define CRERR_CARD_FAILURE      305
#define CRERR_ID_ERROR          306
#define CRERR_ECC_ERROR         307


/* Return code from critical_error_handler() */
#define CRITICAL_ERROR_ABORT    1
#define CRITICAL_ERROR_RETRY    2
#define CRITICAL_ERROR_FORMAT   3
#define CRITICAL_ERROR_CLEARECC 4



/* Drive geometry structure */
typedef struct drv_geometry_desc
{
    UINT32  totalLBA;       /* Total drive logical blocks */
    UINT16  dfltCyl;        /* Number of cylinders */
    UINT16  dfltHd;         /* Number of Heads */
    UINT16  dfltSct;        /* Sectors per track */
    UINT16  dfltBytesPerSect; /* Bytes per sector */
    UCHAR   serialNum[16];  /* Drive serial number in ASCII mode */
    UCHAR   modelNum[32];   /* Drive model number in ASCII mode */
} DRV_GEOMETRY_DESC, *PDRV_GEOMETRY_DESC;



#ifndef copybuff
void copybuff(void *vto, void *vfrom, INT16 size);
#endif

#ifndef compbuff
INT16 compbuff(void *vfrom, void *vto, INT16 size);
#endif

#ifndef pc_memfill
void pc_memfill(void *vto, INT16 size, UTINY c);
#endif

#ifndef pc_strcat
void pc_strcat(TEXT *to, TEXT *from);
#endif


#if (CHAR_16BIT)
void b_unpack(UTINY *to, UINT16 *from, UINT16 length, UINT16 offset);
#endif

/* Byte ordering conversion */
UINT16 to_WORD(UCHAR *buf);
ULONG to_DWORD(UCHAR *buf);
void fr_WORD ( UCHAR *to, UINT16 from );
void fr_DWORD ( UCHAR *to, UINT32 from );


UINT16 swap_hi_low_byte(UINT16 inword);


/****************************************************************************/
/************************** MEMORY or I/O ACCESS ****************************/
/****************************************************************************/

    #define SDREAD_DATA08(X) (inpbyte((UINT32) (X) ))
    #define SDWRITE_DATA08(X,Y) outpbyte((UINT32)(X), (UINT16(Y))


    #define SDREAD_DATA16(X) (inpword((UINT32) (X) ))
    #define SDWRITE_DATA16(X,Y) outpword((UINT32)(X), (UINT16)(Y))


/*****************************************************************************
* Name: pc_get_error
*
* Description
*       Get error code
*
* Entries:
*    if (USE_FILE_SYSTEM)
*       INT16  taskno     task number
*    else #(!USE_FILE_SYSTEM)
*       INT16  driveno    drive number
* Returns:
*    if (USE_FILE_SYSTEM)
*    {
*          0  No Error
*       otherwise, one of the following error code:
*           PEBADF          9    Invalid file descriptor
*           PENOENT         2    File not found or path to file not found
*           PEMFILE         24   No file descriptors available (too many files open)
*           PEEXIST         17   Exclusive access requested but file already exists.
*           PEACCES         13   Attempt to open a read only file or a special (directory)
*           PEINVAL         22   Seek to negative file pointer attempted.
*           PENOSPC         28   Write failed. Presumably because of no space
*           PESHARE         30   Open failed do to sharing
*           PEDEVICE        31   No Valid Disk Present
*    }
*    else #(!USE_FILE_SYSTEM)
*    {
*
*           0  No Error
*       otherwise, one of the following error code in controller_s:
*           BUS_ERC_DIAG     1   Drive diagnostic failed in initialize
*           BUS_ERC_ARGS     2   User supplied invalid arguments
*           BUS_ERC_DRQ      3   DRQ should be asserted but it isn't
*                                  or driver and controller are out of phase
*           BUS_ERC_TIMEOUT  4   Timeout during some operation 
*           BUS_ERC_STATUS   5   Controller reported an error
*                                  look in the error register
*    }
*
******************************************************************************/
INT16 pc_get_error (INT16 driveno_or_taskno);


INT16 pc_get_extended_error (INT16 driveno);



/*****************************************************************************
* Name: mmc_init
*
* Processing:
*       Initialize data structure for MMC controller.
*
* Entries:
*       INT16   driveno         Driver number
*
* Returns:
*       TRUE if successful
*       FALSE if failure
*       
*****************************************************************************/
int mmc_init(void);


/*****************************************************************************
* Name: mmc_drive_open
*
* Processing:
*       Set up internal data structure and configure the system.
*
* Entries:
*       INT16   driveno         Driver number
*
* Returns:
*       TRUE if successful
*       FALSE if failure
*       
*****************************************************************************/
int mmc_drive_open(INT16 driveno);



/*****************************************************************************
* Name: mmc_drive_close
*
* Processing:
*       Release internal data structure and restore memory configuration
*
* Entries:
*       INT16   driveno         Driver number
*
* Returns:
*       TRUE if successful
*       FALSE if failure
*       
*****************************************************************************/
int mmc_drive_close(INT16 driveno);



/*****************************************************************************
* Name: mmc_read_serial
*
* Processing:
*       Get the drive geometry information.
*
* Entries:
*       INT16   driveno         Driver number
*       PDRV_GEOMETRY_DESC idDrvPtr Device geometry buffer
*
* Returns:
*       TRUE if successful
*       FALSE if failure
*       
*****************************************************************************/
int mmc_read_serial(INT16 driveno, PDRV_GEOMETRY_DESC idDrvPtr);



/*****************************************************************************
* Name: mmc_read
*
* Processing:
*       Get data from the drive at the requested logical block addresses.
*
* Entries:
*       INT16   driveno         Driver number
*       ULONG   sector          Starting logical block address
*       UCHAR   *buffer         Data buffer
*       UCOUNT  count           Number of sector to transfer
*
* Returns:
*       TRUE if successful
*       FALSE if failure
*       
*****************************************************************************/
int mmc_read(INT16 driveno, ULONG sector, UCHAR *buffer, UCOUNT count);



/*****************************************************************************
* Name: mmc_write
*
* Processing:
*       Send information to the specific location on the drive.
*
* Entries:
*       INT16   driveno         Driver number
*       ULONG   sector          Starting logical block address
*       UCHAR   *buffer         Data buffer
*       UCOUNT  count           Number of sector to transfer
*
* Returns:
*       TRUE if successful
*       FALSE if failure
*       
*****************************************************************************/
int mmc_write(INT16 driveno, ULONG sector, UCHAR *buffer, UCOUNT count);



/*****************************************************************************
* Name: mmc_erase
*
* Processing:
*       Clear the LBA to make it ready for the next write access. This
*       will improve the write data access.
*
* Entries:
*       INT16   driveno         Driver number
*       ULONG   sector          Starting logical block address
*       UCOUNT  count           Number of sectors
*
* Returns:
*       TRUE if successful
*       FALSE if failure
*       
*****************************************************************************/
int mmc_erase(INT16 driveno, ULONG sector, UCOUNT count);

/* Configure the block size */
int setBlockSize( INT16 driveno, UINT16 blockSize );
int IsCardBusy(INT16 driveno);



#ifdef __cplusplus
}
#endif

#define __SDAPI_H__

#endif  /* __SDAPI_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -