fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/devices/hdc.h *
7 * Created: 2011-09-11 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2011-2012 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_HDC_H
24#define PCE_DEVICES_HDC_H 1
25
26
27#include <devices/device.h>
28#include <devices/memory.h>
29
30#include <drivers/block/block.h>
31
32
33typedef struct {
34 unsigned drive;
35
36 unsigned char sense[4];
37
38 unsigned short max_c;
39 unsigned short max_h;
40 unsigned short max_s;
41} hdc_drive_t;
42
43
44typedef struct hdc_t {
45 mem_blk_t blk;
46
47 unsigned char status;
48 unsigned char config;
49 unsigned char mask;
50
51 unsigned char result;
52
53 unsigned short cmd_idx;
54 unsigned short cmd_cnt;
55 unsigned char cmd[6];
56
57 unsigned short buf_idx;
58 unsigned short buf_cnt;
59 unsigned char buf[516];
60
61 unsigned char config_params[64];
62
63 unsigned sectors;
64
65 hdc_drive_t drv[2];
66
67 struct {
68 unsigned short d;
69 unsigned short c;
70 unsigned short h;
71 unsigned short s;
72 unsigned short n;
73 } id;
74
75 disks_t *dsks;
76
77 unsigned long delay;
78
79 void (*cont) (struct hdc_t *hdc);
80
81 unsigned char irq_val;
82 void *irq_ext;
83 void (*irq) (void *ext, unsigned char val);
84
85 unsigned char dreq_val;
86 void *dreq_ext;
87 void (*dreq) (void *ext, unsigned char val);
88} hdc_t;
89
90
91unsigned char hdc_read_data (hdc_t *hdc);
92void hdc_write_data (hdc_t *hdc, unsigned char val);
93void hdc_set_tc (hdc_t *hdc, unsigned char val);
94
95hdc_t *hdc_new (unsigned long addr);
96void hdc_del (hdc_t *hdc);
97
98void hdc_mem_add_io (hdc_t *hdc, memory_t *io);
99void hdc_mem_rmv_io (hdc_t *hdc, memory_t *io);
100
101void hdc_set_irq_fct (hdc_t *hdc, void *ext, void *fct);
102void hdc_set_dreq_fct (hdc_t *hdc, void *ext, void *fct);
103
104void hdc_set_config (hdc_t *hdc, unsigned val);
105
106void hdc_set_sectors (hdc_t *hdc, unsigned val);
107
108void hdc_set_disks (hdc_t *hdc, disks_t *dsks);
109
110void hdc_set_drive (hdc_t *hdc, unsigned hdcdrv, unsigned drive);
111
112unsigned hdc_get_drive (hdc_t *hdc, unsigned hdcdrv);
113
114/*!***************************************************************************
115 * @short Set the configuration parameters ID
116 * @param id An array of 8 bytes that will be returned as the first 8 bytes
117 * by the get configuration parameters command.
118 * @param cnt The number of bytes in id. If cnt < 8 then the remaining bytes
119 * will be set to 0.
120 *****************************************************************************/
121void hdc_set_config_id (hdc_t *hdc, const unsigned char *id, unsigned cnt);
122
123void hdc_reset (hdc_t *hdc);
124
125void hdc_clock (hdc_t *hdc, unsigned long cnt);
126
127
128#endif