fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/lib/iniata.c *
7 * Created: 2006-12-16 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2006-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#include <stdlib.h>
24
25#include <lib/iniata.h>
26#include <lib/log.h>
27
28#include <devices/ata.h>
29#include <devices/pci-ata.h>
30
31#include <drivers/block/block.h>
32
33
34int ini_get_ata_chn (ata_chn_t *ata, disks_t *dsks, ini_sct_t *ini, unsigned idx)
35{
36 unsigned dev, drv;
37 unsigned multi;
38 const char *model;
39 disk_t *dsk;
40 ini_sct_t *sct;
41
42 sct = NULL;
43
44 while ((sct = ini_next_sct (ini, sct, "device")) != NULL) {
45 ini_get_uint16 (sct, "device", &dev, 0);
46 ini_get_uint16 (sct, "disk", &drv, 0);
47 ini_get_uint16 (sct, "multi_count_max", &multi, 0);
48 ini_get_string (sct, "model", &model, "PCEDISK");
49
50 dsk = dsks_get_disk (dsks, drv);
51
52 if (dsk != NULL) {
53 pce_log_tag (MSG_INF,
54 "ATA:",
55 "channel=%u device=%u multi=%u model=%s drive=%u\n",
56 idx, dev, multi, model, drv
57 );
58
59 ata_set_multi_mode (ata, dev, multi);
60 ata_set_model (ata, dev, model);
61
62 ata_set_block (ata, dsk, dev);
63 }
64 }
65
66 return (0);
67}
68
69int ini_get_pci_ata (pci_ata_t *pciata, disks_t *dsks, ini_sct_t *ini)
70{
71 unsigned idx;
72 ini_sct_t *sct;
73 ata_chn_t *chn;
74
75 idx = 0;
76 sct = NULL;
77
78 while ((sct = ini_next_sct (ini, sct, "channel")) != NULL) {
79 ini_get_uint16 (sct, "channel", &idx, idx);
80
81 chn = pci_ata_get_chn (pciata, idx);
82
83 if (chn == NULL) {
84 pce_log (MSG_ERR, "*** no such channel (%u)\n", idx);
85 }
86 else {
87 ini_get_ata_chn (chn, dsks, sct, idx);
88 }
89 }
90
91 return (0);
92}