blob: f9579a242dc2c9f2115ee0455cb994f82bebafca [file] [log] [blame]
Will Robertson590501c2007-09-21 15:51:53 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Linus Nielsen Feltzing
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Will Robertson590501c2007-09-21 15:51:53 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef ATA_TARGET_H
22#define ATA_TARGET_H
23
Michael Sevakis80278e42008-05-10 18:00:11 +000024#ifdef BOOTLOADER
25#define ATA_DRIVER_CLOSE
26#endif
27
Will Robertson590501c2007-09-21 15:51:53 +000028/* Plain C read & write loops */
29#define PREFER_C_READING
30#define PREFER_C_WRITING
Nicolas Pennequine2f5f212008-02-17 23:17:08 +000031#if 0
Will Robertson590501c2007-09-21 15:51:53 +000032#if !defined(BOOTLOADER)
Michael Sevakisbc057f92008-02-08 06:34:11 +000033#define ATA_OPTIMIZED_WRITING
34void copy_write_sectors(const unsigned char* buf, int wordcount);
Will Robertson590501c2007-09-21 15:51:53 +000035#endif
Nicolas Pennequine2f5f212008-02-17 23:17:08 +000036#endif
Will Robertson590501c2007-09-21 15:51:53 +000037
Michael Sevakisbc057f92008-02-08 06:34:11 +000038#define ATA_DATA ATA_DRIVE_DATA
39#define ATA_ERROR ATA_DRIVE_FEATURES
40#define ATA_NSECTOR ATA_DRIVE_SECTOR_COUNT
41#define ATA_SECTOR ATA_DRIVE_SECTOR_NUM
42#define ATA_LCYL ATA_DRIVE_CYL_LOW
43#define ATA_HCYL ATA_DRIVE_CYL_HIGH
44#define ATA_SELECT ATA_DRIVE_CYL_HEAD
45#define ATA_COMMAND ATA_DRIVE_COMMAND
46#define ATA_CONTROL ATA_DRIVE_CONTROL
Will Robertson590501c2007-09-21 15:51:53 +000047
48#define STATUS_BSY 0x80
49#define STATUS_RDY 0x40
50#define STATUS_DF 0x20
51#define STATUS_DRQ 0x08
52#define STATUS_ERR 0x01
53#define ERROR_ABRT 0x04
54
55#define WRITE_PATTERN1 0xa5
56#define WRITE_PATTERN2 0x5a
57#define WRITE_PATTERN3 0xaa
58#define WRITE_PATTERN4 0x55
59
60#define READ_PATTERN1 0xa5
61#define READ_PATTERN2 0x5a
62#define READ_PATTERN3 0xaa
63#define READ_PATTERN4 0x55
64
65#define READ_PATTERN1_MASK 0xff
66#define READ_PATTERN2_MASK 0xff
67#define READ_PATTERN3_MASK 0xff
68#define READ_PATTERN4_MASK 0xff
69
70#define SET_REG(reg,val) reg = (val)
71#define SET_16BITREG(reg,val) reg = (val)
72
73void ata_reset(void);
74void ata_device_init(void);
75bool ata_is_coldstart(void);
76
Michael Sevakis57cbd772008-05-05 13:00:08 +000077#define ATA_SET_DEVICE_FEATURES
78void ata_set_pio_timings(int mode);
Michael Sevakisbe0c7d02008-05-05 10:53:06 +000079
Michael Sevakis57cbd772008-05-05 13:00:08 +000080#endif /* ATA_TARGET_H */