Marcin Bukat | 28d54c6 | 2010-04-26 21:40:16 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Marcin Bukat | 082c7d3 | 2010-10-22 12:28:43 +0000 | [diff] [blame^] | 8 | * $Id$ |
Marcin Bukat | 28d54c6 | 2010-04-26 21:40:16 +0000 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 2010 Marcin Bukat |
| 11 | * |
| 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. |
| 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 | |
Marcin Bukat | 68da06f | 2010-05-11 11:35:58 +0000 | [diff] [blame] | 24 | #define ATA_OPTIMIZED_READING |
Marcin Bukat | fc33011 | 2010-05-10 13:24:44 +0000 | [diff] [blame] | 25 | #define ATA_OPTIMIZED_WRITING |
Marcin Bukat | 28d54c6 | 2010-04-26 21:40:16 +0000 | [diff] [blame] | 26 | |
Marcin Bukat | 28d54c6 | 2010-04-26 21:40:16 +0000 | [diff] [blame] | 27 | #define ATA_IOBASE 0x20000000 |
| 28 | #define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE + 0x20))) |
| 29 | #define ATA_CONTROL (*((volatile unsigned short*)(ATA_IOBASE + 0x1c))) |
| 30 | |
| 31 | #define ATA_ERROR (*((volatile unsigned short*)(ATA_IOBASE + 0x22))) |
| 32 | #define ATA_NSECTOR (*((volatile unsigned short*)(ATA_IOBASE + 0x24))) |
| 33 | #define ATA_SECTOR (*((volatile unsigned short*)(ATA_IOBASE + 0x26))) |
| 34 | #define ATA_LCYL (*((volatile unsigned short*)(ATA_IOBASE + 0x28))) |
| 35 | #define ATA_HCYL (*((volatile unsigned short*)(ATA_IOBASE + 0x2a))) |
| 36 | #define ATA_SELECT (*((volatile unsigned short*)(ATA_IOBASE + 0x2c))) |
| 37 | #define ATA_COMMAND (*((volatile unsigned short*)(ATA_IOBASE + 0x2e))) |
| 38 | |
| 39 | |
| 40 | #define STATUS_BSY 0x80 |
| 41 | #define STATUS_RDY 0x40 |
| 42 | #define STATUS_DF 0x20 |
| 43 | #define STATUS_DRQ 0x08 |
| 44 | #define STATUS_ERR 0x01 |
| 45 | |
| 46 | #define ERROR_ABRT 0x04 |
| 47 | #define ERROR_IDNF 0x10 |
| 48 | |
| 49 | #define WRITE_PATTERN1 0xa5 |
| 50 | #define WRITE_PATTERN2 0x5a |
| 51 | #define WRITE_PATTERN3 0xaa |
| 52 | #define WRITE_PATTERN4 0x55 |
| 53 | |
| 54 | #define READ_PATTERN1 0xa5 |
| 55 | #define READ_PATTERN2 0x5a |
| 56 | #define READ_PATTERN3 0xaa |
| 57 | #define READ_PATTERN4 0x55 |
| 58 | |
| 59 | #define READ_PATTERN1_MASK 0xff |
| 60 | #define READ_PATTERN2_MASK 0xff |
| 61 | #define READ_PATTERN3_MASK 0xff |
| 62 | #define READ_PATTERN4_MASK 0xff |
| 63 | |
| 64 | #define SET_REG(reg,val) reg = (val) |
| 65 | #define SET_16BITREG(reg,val) reg = (val) |
| 66 | |
| 67 | void ata_reset(void); |
| 68 | void ata_enable(bool on); |
| 69 | void ata_device_init(void); |
| 70 | bool ata_is_coldstart(void); |
| 71 | |
Marcin Bukat | 68da06f | 2010-05-11 11:35:58 +0000 | [diff] [blame] | 72 | void copy_read_sectors(unsigned char* buf, int wordcount); |
Marcin Bukat | fc33011 | 2010-05-10 13:24:44 +0000 | [diff] [blame] | 73 | void copy_write_sectors(const unsigned char* buf, int wordcount); |
Marcin Bukat | 28d54c6 | 2010-04-26 21:40:16 +0000 | [diff] [blame] | 74 | #endif |