Will Robertson | 590501c | 2007-09-21 15:51:53 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2006 by Linus Nielsen Feltzing |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 12 | * 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 Robertson | 590501c | 2007-09-21 15:51:53 +0000 | [diff] [blame] | 16 | * |
| 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 Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 24 | #ifdef BOOTLOADER |
| 25 | #define ATA_DRIVER_CLOSE |
| 26 | #endif |
| 27 | |
Will Robertson | 590501c | 2007-09-21 15:51:53 +0000 | [diff] [blame] | 28 | /* Plain C read & write loops */ |
| 29 | #define PREFER_C_READING |
| 30 | #define PREFER_C_WRITING |
Nicolas Pennequin | e2f5f21 | 2008-02-17 23:17:08 +0000 | [diff] [blame] | 31 | #if 0 |
Will Robertson | 590501c | 2007-09-21 15:51:53 +0000 | [diff] [blame] | 32 | #if !defined(BOOTLOADER) |
Michael Sevakis | bc057f9 | 2008-02-08 06:34:11 +0000 | [diff] [blame] | 33 | #define ATA_OPTIMIZED_WRITING |
| 34 | void copy_write_sectors(const unsigned char* buf, int wordcount); |
Will Robertson | 590501c | 2007-09-21 15:51:53 +0000 | [diff] [blame] | 35 | #endif |
Nicolas Pennequin | e2f5f21 | 2008-02-17 23:17:08 +0000 | [diff] [blame] | 36 | #endif |
Will Robertson | 590501c | 2007-09-21 15:51:53 +0000 | [diff] [blame] | 37 | |
Michael Sevakis | bc057f9 | 2008-02-08 06:34:11 +0000 | [diff] [blame] | 38 | #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 Robertson | 590501c | 2007-09-21 15:51:53 +0000 | [diff] [blame] | 47 | |
| 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 | |
| 73 | void ata_reset(void); |
| 74 | void ata_device_init(void); |
| 75 | bool ata_is_coldstart(void); |
| 76 | |
Michael Sevakis | 57cbd77 | 2008-05-05 13:00:08 +0000 | [diff] [blame] | 77 | #define ATA_SET_DEVICE_FEATURES |
| 78 | void ata_set_pio_timings(int mode); |
Michael Sevakis | be0c7d0 | 2008-05-05 10:53:06 +0000 | [diff] [blame] | 79 | |
Michael Sevakis | 57cbd77 | 2008-05-05 13:00:08 +0000 | [diff] [blame] | 80 | #endif /* ATA_TARGET_H */ |