📄 ata.h
字号:
/*
* Copyright 2005 by Spectrum Digital Incorporated.
* All rights reserved. Property of Spectrum Digital Incorporated.
*
* Not for distribution.
*/
/*
* ATA HDD Test
*/
#include "davincievm.h"
#include "davincievm_gpio_exp.h"
#include "davincievm_msp430.h"
/*
* Note: The variables: ata_prd_table
* must be located in a memory space accessible by the ATA DMA.
* If the memory location is not in a accessible location, the ATA DMA
* cannot function correctly, and does not send or receive data.
*
* The DDR2 and AEMIF are both accessible to the ATA DMA. More locations
* can be found in the DaVinci System's Guide under the Memory map section.
* There it is detailed what memory locations can be viewed by all periphearls.
*
*/
/* ------------------------------------------------------------------------ *
* ATA DMA PRD variable *
* ------------------------------------------------------------------------ */
extern Uint32* ata_prd_word0; // Physical Region Descriptor ( PRD ) Table
extern Uint32* ata_prd_word1; // PRD - EOT & Byte Count
#define ATA_PRD_TABLE ( ( Uint32 )ata_prd_word0 )
/* ------------------------------------------------------------------------ *
* ATA Command Codes *
* ------------------------------------------------------------------------ */
#define ATA_READ_SECTOR 0x20
#define ATA_WRITE_SECTOR 0x30
#define ATA_READ_DMA 0xC8
#define ATA_WRITE_DMA 0xCA
#define ATA_IDENTIFY_DEVICE 0xEC
#define ATA_SET_FEATURE 0xEF
/* ------------------------------------------------------------------------ *
* ATA Command Codes *
* ------------------------------------------------------------------------ */
#define PIO_MODE_DEFAULT 0x00
#define PIO_MODE_NO_IORDY 0x01
#define PIO_MODE 0x08
#define PIO_MODE_0 0x00
#define PIO_MODE_1 ( PIO_MODE + 1 )
#define PIO_MODE_2 ( PIO_MODE + 2 )
#define PIO_MODE_3 ( PIO_MODE + 3 )
#define PIO_MODE_4 ( PIO_MODE + 4 )
#define MULTIWORD_DMA_MODE 0x20
#define MULTIWORD_DMA_MODE_0 ( MULTIWORD_DMA_MODE + 0 )
#define MULTIWORD_DMA_MODE_1 ( MULTIWORD_DMA_MODE + 1 )
#define MULTIWORD_DMA_MODE_2 ( MULTIWORD_DMA_MODE + 2 )
#define ULTRA_DMA_MODE 0x40
#define ULTRA_DMA_MODE_0 ( ULTRA_DMA_MODE + 0 )
#define ULTRA_DMA_MODE_1 ( ULTRA_DMA_MODE + 1 )
#define ULTRA_DMA_MODE_2 ( ULTRA_DMA_MODE + 2 )
#define ULTRA_DMA_MODE_3 ( ULTRA_DMA_MODE + 3 )
#define ULTRA_DMA_MODE_4 ( ULTRA_DMA_MODE + 4 )
#define ULTRA_DMA_MODE_5 ( ULTRA_DMA_MODE + 5 )
#define ULTRA_DMA_MODE_6 ( ULTRA_DMA_MODE + 6 )
/* ------------------------------------------------------------------------ *
* Prototypes *
* ------------------------------------------------------------------------ */
Int16 ATA_init( );
Int16 ATA_changeMode( Uint8 ata_mode );
Int16 ATA_issueCommand( Uint8 command, Uint32 sector );
Int16 ATA_setfeature( Uint8 command, Uint8 options );
Int16 ATA_readId( Uint32 dst );
Int16 ATA_identify( Uint8* buffer );
Int16 ATA_readSector( Uint32 src, Uint32 dst, Uint32 count );
Int16 ATA_readSectorDma( Uint32 src, Uint32 dst, Uint32 count, Uint32 timeout );
Int16 ATA_writeSector( Uint32 src, Uint32 dst, Uint32 count );
Int16 ATA_writeSectorDma( Uint32 src, Uint32 dst, Uint32 count, Uint32 timeout );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -