fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
at master 119 lines 3.8 kB view raw
1/***************************************************************************** 2 * pce * 3 *****************************************************************************/ 4 5/***************************************************************************** 6 * File name: src/devices/ata.h * 7 * Created: 2004-12-03 by Hampa Hug <hampa@hampa.ch> * 8 * Copyright: (C) 2004-2011 Hampa Hug <hampa@hampa.ch> * 9 *****************************************************************************/ 10 11/***************************************************************************** 12 * This program is free software. You can redistribute it and / or modify it * 13 * under the terms of the GNU General Public License version 2 as published * 14 * by the Free Software Foundation. * 15 * * 16 * This program is distributed in the hope that it will be useful, but * 17 * WITHOUT ANY WARRANTY, without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 19 * Public License for more details. * 20 *****************************************************************************/ 21 22 23#ifndef PCE_DEVICES_ATA_H 24#define PCE_DEVICES_ATA_H 1 25 26 27#include <devices/memory.h> 28 29#include <drivers/block/block.h> 30 31 32struct ata_dev_s; 33struct ata_chn_s; 34 35 36#define ATA_BUF_MAX 4096 37 38 39typedef struct ata_dev_s { 40 struct ata_chn_s *chn; 41 42 unsigned char reg_cmd; 43 unsigned char reg_status; 44 unsigned char reg_error; 45 unsigned char reg_features; 46 unsigned char reg_cyl_lo; 47 unsigned char reg_cyl_hi; 48 unsigned char reg_head; 49 unsigned char reg_sec; 50 unsigned char reg_sec_cnt; 51 unsigned char reg_dev_ctl; 52 53 uint16_t c; 54 uint16_t h; 55 uint16_t s; 56 57 uint16_t default_c; 58 uint16_t default_h; 59 uint16_t default_s; 60 61 unsigned multi_block_max; 62 unsigned multi_block_size; 63 64 unsigned buf_i; 65 unsigned buf_n; 66 unsigned buf_m; 67 unsigned buf_mode; 68 uint32_t buf_blk_i; 69 uint32_t buf_blk_n; 70 unsigned buf_mult_i; 71 unsigned buf_mult_n; 72 unsigned char buf[ATA_BUF_MAX]; 73 void (*callback) (struct ata_dev_s *dev); 74 75 char model[64]; 76 char firmware[16]; 77 char serial[32]; 78 79 disk_t *blk; 80} ata_dev_t; 81 82 83typedef struct ata_chn_s { 84 mem_blk_t reg_cmd; 85 mem_blk_t reg_ctl; 86 87 void *irq_ext; 88 unsigned char irq_val; 89 void (*irq) (void *ext, unsigned char val); 90 91 ata_dev_t dev[2]; 92 ata_dev_t *sel; 93} ata_chn_t; 94 95 96void ata_init (ata_chn_t *ata, unsigned long addr1, unsigned long addr2); 97void ata_free (ata_chn_t *ata); 98 99ata_chn_t *ata_new (unsigned long addr1, unsigned long addr2); 100void ata_del (ata_chn_t *ata); 101 102void ata_set_irq_f (ata_chn_t *ata, void *irq, void *ext); 103 104void ata_set_model (ata_chn_t *ata, unsigned devi, const char *name); 105 106void ata_set_multi_mode (ata_chn_t *ata, unsigned devi, unsigned max); 107 108void ata_set_block (ata_chn_t *ata, disk_t *blk, unsigned devi); 109 110unsigned char ata_cmd_get_uint8 (ata_chn_t *ata, unsigned long addr); 111unsigned short ata_cmd_get_uint16 (ata_chn_t *ata, unsigned long addr); 112unsigned long ata_cmd_get_uint32 (ata_chn_t *ata, unsigned long addr); 113 114void ata_cmd_set_uint8 (ata_chn_t *ata, unsigned long addr, unsigned char val); 115void ata_cmd_set_uint16 (ata_chn_t *ata, unsigned long addr, unsigned short val); 116void ata_cmd_set_uint32 (ata_chn_t *ata, unsigned long addr, unsigned long val); 117 118 119#endif