Changeset 3de67b4c in mainline
- Timestamp:
- 2013-06-27T20:43:29Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4339f09
- Parents:
- 9f391e9
- Location:
- uspace/drv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/ata_bd/ata_bd.c
r9f391e9 r3de67b4c 81 81 */ 82 82 static const size_t identify_data_size = 512; 83 84 /** I/O base addresses for legacy (ISA-compatible) controllers. */85 static ata_base_t legacy_base[LEGACY_CTLS] = {86 { 0x1f0, 0x3f0 },87 { 0x170, 0x370 },88 { 0x1e8, 0x3e8 },89 { 0x168, 0x368 }90 };91 83 92 84 static int ata_bd_init_io(ata_ctrl_t *ctrl); … … 145 137 146 138 /** Initialize ATA controller. */ 147 int ata_ctrl_init(ata_ctrl_t *ctrl )139 int ata_ctrl_init(ata_ctrl_t *ctrl, ata_base_t *res) 148 140 { 149 141 int i, rc; 150 142 int n_disks; 151 unsigned ctl_num;152 143 153 144 ddf_msg(LVL_DEBUG, "ata_ctrl_init()"); 154 145 155 ctl_num = 1;156 157 146 fibril_mutex_initialize(&ctrl->lock); 158 ctrl->cmd_physical = legacy_base[ctl_num - 1].cmd;159 ctrl->ctl_physical = legacy_base[ctl_num - 1].ctl;147 ctrl->cmd_physical = res->cmd; 148 ctrl->ctl_physical = res->ctl; 160 149 161 150 ddf_msg(LVL_NOTE, "I/O address %p/%p", (void *) ctrl->cmd_physical, -
uspace/drv/block/ata_bd/ata_bd.h
r9f391e9 r3de67b4c 152 152 } ata_fun_t; 153 153 154 extern int ata_ctrl_init(ata_ctrl_t * );154 extern int ata_ctrl_init(ata_ctrl_t *, ata_base_t *); 155 155 extern int ata_ctrl_remove(ata_ctrl_t *); 156 156 extern int ata_ctrl_gone(ata_ctrl_t *); -
uspace/drv/block/ata_bd/main.c
r9f391e9 r3de67b4c 36 36 #include <ddf/driver.h> 37 37 #include <ddf/log.h> 38 #include <device/hw_res_parsed.h> 38 39 39 40 #include "ata_bd.h" … … 61 62 }; 62 63 64 static int ata_get_res(ddf_dev_t *dev, ata_base_t *ata_res) 65 { 66 async_sess_t *parent_sess; 67 hw_res_list_parsed_t hw_res; 68 int rc; 69 70 parent_sess = ddf_dev_parent_sess_create(dev, 71 EXCHANGE_SERIALIZE); 72 if (parent_sess == NULL) 73 return ENOMEM; 74 75 hw_res_list_parsed_init(&hw_res); 76 rc = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 77 if (rc != EOK) 78 return rc; 79 80 if (hw_res.io_ranges.count != 2) { 81 rc = EINVAL; 82 goto error; 83 return EINVAL; 84 } 85 86 ata_res->cmd = hw_res.io_ranges.ranges[0].address; 87 ata_res->ctl = hw_res.io_ranges.ranges[1].address; 88 89 if (hw_res.io_ranges.ranges[0].size < sizeof(ata_ctl_t)) { 90 rc = EINVAL; 91 goto error; 92 } 93 94 if (hw_res.io_ranges.ranges[1].size < sizeof(ata_cmd_t)) { 95 rc = EINVAL; 96 goto error; 97 } 98 99 return EOK; 100 error: 101 hw_res_list_parsed_clean(&hw_res); 102 return rc; 103 } 63 104 64 105 /** Add new device … … 70 111 { 71 112 ata_ctrl_t *ctrl; 72 int rc; 113 ata_base_t res; 114 int rc; 115 116 rc = ata_get_res(dev, &res); 117 if (rc != EOK) { 118 ddf_msg(LVL_ERROR, "Invalid HW resource configuration."); 119 return EINVAL; 120 } 73 121 74 122 ctrl = ddf_dev_data_alloc(dev, sizeof(ata_ctrl_t)); … … 81 129 ctrl->dev = dev; 82 130 83 rc = ata_ctrl_init(ctrl );131 rc = ata_ctrl_init(ctrl, &res); 84 132 if (rc != EOK) { 85 133 ddf_msg(LVL_ERROR, "Failed initializing ATA controller."); -
uspace/drv/bus/isa/isa.dev
r9f391e9 r3de67b4c 32 32 io_range 70 2 33 33 34 ata _bd:34 ata-c1: 35 35 match 100 isa/ata_bd 36 io_range 0x1f0 8 37 io_range 0x3f0 8 38 39 ata-c2: 40 match 100 isa/ata_bd 41 io_range 0x170 8 42 io_range 0x370 8 43 44 ata-c3: 45 match 100 isa/ata_bd 46 io_range 0x1e8 8 47 io_range 0x3e8 8 48 49 ata-c4: 50 match 100 isa/ata_bd 51 io_range 0x168 8 52 io_range 0x368 8
Note:
See TracChangeset
for help on using the changeset viewer.