Changeset 646849b3 in mainline
- Timestamp:
- 2024-05-17T12:25:26Z (4 months ago)
- Branches:
- master
- Children:
- 60744cb
- Parents:
- 59c0f478
- git-author:
- Jiri Svoboda <jiri@…> (2024-05-16 19:25:07)
- git-committer:
- Jiri Svoboda <jiri@…> (2024-05-17 12:25:26)
- Location:
- uspace
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sysinst/sysinst.c
r59c0f478 r646849b3 62 62 * in Grub notation). 63 63 */ 64 #define DEFAULT_DEV "devices/\\hw\\sys\\00:01.0\\ata -c1\\d0"64 #define DEFAULT_DEV "devices/\\hw\\sys\\00:01.0\\ata1\\c0d0" 65 65 //#define DEFAULT_DEV "devices/\\hw\\pci0\\00:01.2\\uhci_rh\\usb01_a1\\mass-storage0\\l0" 66 66 /** Volume label for the new file system */ -
uspace/drv/block/isa-ide/isa-ide.c
r59c0f478 r646849b3 55 55 #include "main.h" 56 56 57 static errno_t isa_ide_init_io(isa_ide_c trl_t *ctrl);58 static void isa_ide_fini_io(isa_ide_c trl_t *ctrl);59 static errno_t isa_ide_init_irq(isa_ide_c trl_t *ctrl);60 static void isa_ide_fini_irq(isa_ide_c trl_t *ctrl);61 static void isa_ide_irq_handler(ipc_call_t * call, ddf_dev_t *dev);57 static errno_t isa_ide_init_io(isa_ide_channel_t *); 58 static void isa_ide_fini_io(isa_ide_channel_t *); 59 static errno_t isa_ide_init_irq(isa_ide_channel_t *); 60 static void isa_ide_fini_irq(isa_ide_channel_t *); 61 static void isa_ide_irq_handler(ipc_call_t *, ddf_dev_t *); 62 62 63 63 static void isa_ide_write_data_16(void *, uint16_t *, size_t); … … 95 95 }; 96 96 97 /** Initialize ISA IDE controller. */ 98 errno_t isa_ide_ctrl_init(isa_ide_ctrl_t *ctrl, isa_ide_hwres_t *res) 97 /** Initialize ISA IDE channel. */ 98 errno_t isa_ide_channel_init(isa_ide_ctrl_t *ctrl, isa_ide_channel_t *chan, 99 unsigned chan_id, isa_ide_hwres_t *res) 99 100 { 100 101 errno_t rc; … … 104 105 ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init()"); 105 106 106 fibril_mutex_initialize(&ctrl->lock); 107 ctrl->cmd_physical = res->cmd; 108 ctrl->ctl_physical = res->ctl; 109 ctrl->irq = res->irq; 110 111 ddf_msg(LVL_NOTE, "I/O address %p/%p", (void *) ctrl->cmd_physical, 112 (void *) ctrl->ctl_physical); 107 chan->ctrl = ctrl; 108 chan->chan_id = chan_id; 109 fibril_mutex_initialize(&chan->lock); 110 if (chan_id == 0) { 111 chan->cmd_physical = res->cmd1; 112 chan->ctl_physical = res->ctl1; 113 chan->irq = res->irq1; 114 } else { 115 chan->cmd_physical = res->cmd2; 116 chan->ctl_physical = res->ctl2; 117 chan->irq = res->irq2; 118 } 119 120 ddf_msg(LVL_NOTE, "I/O address %p/%p", (void *) chan->cmd_physical, 121 (void *) chan->ctl_physical); 113 122 114 123 ddf_msg(LVL_DEBUG, "Init I/O"); 115 rc = isa_ide_init_io(c trl);124 rc = isa_ide_init_io(chan); 116 125 if (rc != EOK) 117 126 return rc; 118 127 119 128 ddf_msg(LVL_DEBUG, "Init IRQ"); 120 rc = isa_ide_init_irq(c trl);129 rc = isa_ide_init_irq(chan); 121 130 if (rc != EOK) { 122 131 ddf_msg(LVL_NOTE, "init IRQ failed"); … … 128 137 ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init(): Initialize IDE channel"); 129 138 130 params.arg = (void *)c trl;131 params.have_irq = (c trl->irq >= 0) ? true : false;139 params.arg = (void *)chan; 140 params.have_irq = (chan->irq >= 0) ? true : false; 132 141 params.write_data_16 = isa_ide_write_data_16; 133 142 params.read_data_16 = isa_ide_read_data_16; … … 145 154 params.msg_error = isa_ide_msg_error; 146 155 147 rc = ata_channel_create(¶ms, &c trl->channel);156 rc = ata_channel_create(¶ms, &chan->channel); 148 157 if (rc != EOK) 149 158 goto error; 150 159 151 rc = ata_channel_initialize(c trl->channel);160 rc = ata_channel_initialize(chan->channel); 152 161 if (rc != EOK) 153 162 goto error; … … 157 166 error: 158 167 if (irq_inited) 159 isa_ide_fini_irq(c trl);160 isa_ide_fini_io(c trl);168 isa_ide_fini_irq(chan); 169 isa_ide_fini_io(chan); 161 170 return rc; 162 171 } 163 172 164 /** Remove ISA IDE controller. */165 errno_t isa_ide_c trl_remove(isa_ide_ctrl_t *ctrl)173 /** Finalize ISA IDE channel. */ 174 errno_t isa_ide_channel_fini(isa_ide_channel_t *chan) 166 175 { 167 176 errno_t rc; … … 169 178 ddf_msg(LVL_DEBUG, ": isa_ide_ctrl_remove()"); 170 179 171 fibril_mutex_lock(&c trl->lock);172 173 rc = ata_channel_destroy(c trl->channel);174 if (rc != EOK) { 175 fibril_mutex_unlock(&c trl->lock);176 return rc; 177 } 178 179 isa_ide_fini_irq(c trl);180 isa_ide_fini_io(c trl);181 fibril_mutex_unlock(&c trl->lock);180 fibril_mutex_lock(&chan->lock); 181 182 rc = ata_channel_destroy(chan->channel); 183 if (rc != EOK) { 184 fibril_mutex_unlock(&chan->lock); 185 return rc; 186 } 187 188 isa_ide_fini_irq(chan); 189 isa_ide_fini_io(chan); 190 fibril_mutex_unlock(&chan->lock); 182 191 183 192 return EOK; 184 193 } 185 194 186 /** Surprise removal of ISA IDE controller. */ 187 errno_t isa_ide_ctrl_gone(isa_ide_ctrl_t *ctrl) 188 { 189 errno_t rc; 190 191 ddf_msg(LVL_DEBUG, "isa_ide_ctrl_gone()"); 192 193 fibril_mutex_lock(&ctrl->lock); 194 195 rc = ata_channel_destroy(ctrl->channel); 196 if (rc != EOK) { 197 fibril_mutex_unlock(&ctrl->lock); 198 return rc; 199 } 200 201 isa_ide_fini_io(ctrl); 202 fibril_mutex_unlock(&ctrl->lock); 203 195 /** Enable device I/O. */ 196 static errno_t isa_ide_init_io(isa_ide_channel_t *chan) 197 { 198 errno_t rc; 199 void *vaddr; 200 201 rc = pio_enable((void *) chan->cmd_physical, sizeof(ata_cmd_t), &vaddr); 202 if (rc != EOK) { 203 ddf_msg(LVL_ERROR, "Cannot initialize device I/O space."); 204 return rc; 205 } 206 207 chan->cmd = vaddr; 208 209 rc = pio_enable((void *) chan->ctl_physical, sizeof(ata_ctl_t), &vaddr); 210 if (rc != EOK) { 211 ddf_msg(LVL_ERROR, "Cannot initialize device I/O space."); 212 return rc; 213 } 214 215 chan->ctl = vaddr; 204 216 return EOK; 205 217 } 206 218 207 /** Enable device I/O. */208 static errno_t isa_ide_init_io(isa_ide_ctrl_t *ctrl)209 {210 errno_t rc;211 void *vaddr;212 213 rc = pio_enable((void *) ctrl->cmd_physical, sizeof(ata_cmd_t), &vaddr);214 if (rc != EOK) {215 ddf_msg(LVL_ERROR, "Cannot initialize device I/O space.");216 return rc;217 }218 219 ctrl->cmd = vaddr;220 221 rc = pio_enable((void *) ctrl->ctl_physical, sizeof(ata_ctl_t), &vaddr);222 if (rc != EOK) {223 ddf_msg(LVL_ERROR, "Cannot initialize device I/O space.");224 return rc;225 }226 227 ctrl->ctl = vaddr;228 return EOK;229 }230 231 219 /** Clean up device I/O. */ 232 static void isa_ide_fini_io(isa_ide_c trl_t *ctrl)233 { 234 (void) c trl;220 static void isa_ide_fini_io(isa_ide_channel_t *chan) 221 { 222 (void) chan; 235 223 /* XXX TODO */ 236 224 } 237 225 238 226 /** Initialize IRQ. */ 239 static errno_t isa_ide_init_irq(isa_ide_c trl_t *ctrl)227 static errno_t isa_ide_init_irq(isa_ide_channel_t *chan) 240 228 { 241 229 irq_code_t irq_code; … … 244 232 errno_t rc; 245 233 246 if (c trl->irq < 0)234 if (chan->irq < 0) 247 235 return EOK; 248 236 … … 258 246 259 247 memcpy(ranges, &isa_ide_irq_ranges, sizeof(isa_ide_irq_ranges)); 260 ranges[0].base = c trl->cmd_physical;248 ranges[0].base = chan->cmd_physical; 261 249 memcpy(cmds, &isa_ide_irq_cmds, sizeof(isa_ide_irq_cmds)); 262 cmds[0].addr = &c trl->cmd->status;250 cmds[0].addr = &chan->cmd->status; 263 251 264 252 irq_code.rangecount = sizeof(isa_ide_irq_ranges) / sizeof(irq_pio_range_t); … … 267 255 irq_code.cmds = cmds; 268 256 269 ddf_msg(LVL_NOTE, "IRQ %d", c trl->irq);270 rc = register_interrupt_handler (ctrl->dev, ctrl->irq, isa_ide_irq_handler,271 &irq_code, &ctrl->ihandle);257 ddf_msg(LVL_NOTE, "IRQ %d", chan->irq); 258 rc = register_interrupt_handler_arg(chan->ctrl->dev, chan->irq, 259 isa_ide_irq_handler, (void *)chan, &irq_code, &chan->ihandle); 272 260 if (rc != EOK) { 273 261 ddf_msg(LVL_ERROR, "Error registering IRQ."); … … 286 274 287 275 /** Clean up IRQ. */ 288 static void isa_ide_fini_irq(isa_ide_c trl_t *ctrl)276 static void isa_ide_fini_irq(isa_ide_channel_t *chan) 289 277 { 290 278 errno_t rc; 291 279 async_sess_t *parent_sess; 292 280 293 parent_sess = ddf_dev_parent_sess_get(c trl->dev);294 295 rc = hw_res_disable_interrupt(parent_sess, c trl->irq);281 parent_sess = ddf_dev_parent_sess_get(chan->ctrl->dev); 282 283 rc = hw_res_disable_interrupt(parent_sess, chan->irq); 296 284 if (rc != EOK) 297 285 ddf_msg(LVL_ERROR, "Error disabling IRQ."); 298 286 299 (void) unregister_interrupt_handler(c trl->dev, ctrl->ihandle);287 (void) unregister_interrupt_handler(chan->ctrl->dev, chan->ihandle); 300 288 } 301 289 … … 305 293 * @param dev Device that caused the interrupt 306 294 */ 307 static void isa_ide_irq_handler(ipc_call_t *call, ddf_dev_t * dev)308 { 309 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev);295 static void isa_ide_irq_handler(ipc_call_t *call, ddf_dev_t *xdev) 296 { 297 isa_ide_channel_t *chan = (isa_ide_channel_t *)(void *)xdev; // XXX 310 298 uint8_t status; 311 299 async_sess_t *parent_sess; 312 300 313 301 status = ipc_get_arg1(call); 314 ata_channel_irq(c trl->channel, status);315 316 parent_sess = ddf_dev_parent_sess_get( dev);317 hw_res_clear_interrupt(parent_sess, c trl->irq);302 ata_channel_irq(chan->channel, status); 303 304 parent_sess = ddf_dev_parent_sess_get(chan->ctrl->dev); 305 hw_res_clear_interrupt(parent_sess, chan->irq); 318 306 } 319 307 320 308 /** Write the data register callback handler. 321 309 * 322 * @param arg Argument (isa_ide_c trl_t *)310 * @param arg Argument (isa_ide_channel_t *) 323 311 * @param data Data 324 312 * @param nwords Number of words to write … … 326 314 static void isa_ide_write_data_16(void *arg, uint16_t *data, size_t nwords) 327 315 { 328 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;316 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 329 317 size_t i; 330 318 331 319 for (i = 0; i < nwords; i++) 332 pio_write_16(&c trl->cmd->data_port, data[i]);320 pio_write_16(&chan->cmd->data_port, data[i]); 333 321 } 334 322 335 323 /** Read the data register callback handler. 336 324 * 337 * @param arg Argument (isa_ide_c trl_t *)325 * @param arg Argument (isa_ide_channel_t *) 338 326 * @param buf Destination buffer 339 327 * @param nwords Number of words to read … … 341 329 static void isa_ide_read_data_16(void *arg, uint16_t *buf, size_t nwords) 342 330 { 343 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;331 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 344 332 size_t i; 345 333 346 334 for (i = 0; i < nwords; i++) 347 buf[i] = pio_read_16(&c trl->cmd->data_port);335 buf[i] = pio_read_16(&chan->cmd->data_port); 348 336 } 349 337 350 338 /** Write command register callback handler. 351 339 * 352 * @param arg Argument (isa_ide_c trl_t *)340 * @param arg Argument (isa_ide_channel_t *) 353 341 * @param off Register offset 354 342 * @param value Value to write to command register … … 356 344 static void isa_ide_write_cmd_8(void *arg, uint16_t off, uint8_t value) 357 345 { 358 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;359 360 pio_write_8(((ioport8_t *)c trl->cmd) + off, value);346 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 347 348 pio_write_8(((ioport8_t *)chan->cmd) + off, value); 361 349 } 362 350 363 351 /** Read command register callback handler. 364 352 * 365 * @param arg Argument (isa_ide_c trl_t *)353 * @param arg Argument (isa_ide_channel_t *) 366 354 * @param off Register offset 367 355 * @return value Value read from command register … … 369 357 static uint8_t isa_ide_read_cmd_8(void *arg, uint16_t off) 370 358 { 371 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;372 373 return pio_read_8(((ioport8_t *)c trl->cmd) + off);359 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 360 361 return pio_read_8(((ioport8_t *)chan->cmd) + off); 374 362 } 375 363 376 364 /** Write control register callback handler. 377 365 * 378 * @param arg Argument (isa_ide_c trl_t *)366 * @param arg Argument (isa_ide_channel_t *) 379 367 * @param off Register offset 380 368 * @param value Value to write to control register … … 382 370 static void isa_ide_write_ctl_8(void *arg, uint16_t off, uint8_t value) 383 371 { 384 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;385 386 pio_write_8(((ioport8_t *)c trl->ctl) + off, value);372 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 373 374 pio_write_8(((ioport8_t *)chan->ctl) + off, value); 387 375 } 388 376 389 377 /** Read control register callback handler. 390 378 * 391 * @param arg Argument (isa_ide_c trl_t *)379 * @param arg Argument (isa_ide_channel_t *) 392 380 * @param off Register offset 393 381 * @return value Value read from control register … … 395 383 static uint8_t isa_ide_read_ctl_8(void *arg, uint16_t off) 396 384 { 397 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;398 399 return pio_read_8(((ioport8_t *)c trl->ctl) + off);385 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 386 387 return pio_read_8(((ioport8_t *)chan->ctl) + off); 400 388 } 401 389 402 390 /** Enable IRQ callback handler 403 391 * 404 * @param arg Argument (isa_ide_c trl_t *)392 * @param arg Argument (isa_ide_channel_t *) 405 393 * @return EOK on success or an error code 406 394 */ 407 395 static errno_t isa_ide_irq_enable(void *arg) 408 396 { 409 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;397 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 410 398 async_sess_t *parent_sess; 411 399 errno_t rc; 412 400 413 ddf_msg(LVL_DEBUG, "Enable IRQ"); 414 415 parent_sess = ddf_dev_parent_sess_get(ctrl->dev); 416 417 rc = hw_res_enable_interrupt(parent_sess, ctrl->irq); 401 ddf_msg(LVL_DEBUG, "Enable IRQ %d for channel %u", 402 chan->irq, chan->chan_id); 403 404 parent_sess = ddf_dev_parent_sess_get(chan->ctrl->dev); 405 406 rc = hw_res_enable_interrupt(parent_sess, chan->irq); 418 407 if (rc != EOK) { 419 408 ddf_msg(LVL_ERROR, "Error enabling IRQ."); 420 (void) unregister_interrupt_handler(ctrl->dev,421 ctrl->ihandle);422 409 return rc; 423 410 } … … 428 415 /** Disable IRQ callback handler 429 416 * 430 * @param arg Argument (isa_ide_c trl_t *)417 * @param arg Argument (isa_ide_channel_t *) 431 418 * @return EOK on success or an error code 432 419 */ 433 420 static errno_t isa_ide_irq_disable(void *arg) 434 421 { 435 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;422 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 436 423 async_sess_t *parent_sess; 437 424 errno_t rc; … … 439 426 ddf_msg(LVL_DEBUG, "Disable IRQ"); 440 427 441 parent_sess = ddf_dev_parent_sess_get(ctrl->dev); 442 443 rc = hw_res_disable_interrupt(parent_sess, ctrl->irq); 444 if (rc != EOK) { 445 ddf_msg(LVL_ERROR, "Error enabling IRQ."); 446 (void) unregister_interrupt_handler(ctrl->dev, 447 ctrl->ihandle); 428 parent_sess = ddf_dev_parent_sess_get(chan->ctrl->dev); 429 430 rc = hw_res_disable_interrupt(parent_sess, chan->irq); 431 if (rc != EOK) { 432 ddf_msg(LVL_ERROR, "Error disabling IRQ."); 448 433 return rc; 449 434 } … … 454 439 /** Add ATA device callback handler. 455 440 * 456 * @param arg Argument (isa_ide_c trl_t *)441 * @param arg Argument (isa_ide_channel_t *) 457 442 * @param idx Device index 458 443 * $param charg Connection handler argument … … 461 446 static errno_t isa_ide_add_device(void *arg, unsigned idx, void *charg) 462 447 { 463 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;464 return isa_ide_fun_create(c trl, idx, charg);448 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 449 return isa_ide_fun_create(chan, idx, charg); 465 450 } 466 451 467 452 /** Remove ATA device callback handler. 468 453 * 469 * @param arg Argument (isa_ide_c trl_t *)454 * @param arg Argument (isa_ide_channel_t *) 470 455 * @param idx Device index 471 456 * @return EOK on success or an error code … … 473 458 static errno_t isa_ide_remove_device(void *arg, unsigned idx) 474 459 { 475 isa_ide_c trl_t *ctrl = (isa_ide_ctrl_t *)arg;476 return isa_ide_fun_remove(c trl, idx);460 isa_ide_channel_t *chan = (isa_ide_channel_t *)arg; 461 return isa_ide_fun_remove(chan, idx); 477 462 } 478 463 479 464 /** Debug message callback handler. 480 465 * 481 * @param arg Argument (isa_ide_c trl_t *)466 * @param arg Argument (isa_ide_channel_t *) 482 467 * @param msg Message 483 468 */ … … 490 475 /** Notice message callback handler. 491 476 * 492 * @param arg Argument (isa_ide_c trl_t *)477 * @param arg Argument (isa_ide_channel_t *) 493 478 * @param msg Message 494 479 */ … … 501 486 /** Warning message callback handler. 502 487 * 503 * @param arg Argument (isa_ide_c trl_t *)488 * @param arg Argument (isa_ide_channel_t *) 504 489 * @param msg Message 505 490 */ … … 512 497 /** Error message callback handler. 513 498 * 514 * @param arg Argument (isa_ide_c trl_t *)499 * @param arg Argument (isa_ide_channel_t *) 515 500 * @param msg Message 516 501 */ -
uspace/drv/block/isa-ide/isa-ide.h
r59c0f478 r646849b3 47 47 /** ISA IDE hardware resources */ 48 48 typedef struct { 49 uintptr_t cmd; /**< Command block base address. */ 50 uintptr_t ctl; /**< Control block base address. */ 51 int irq; /**< IRQ */ 49 uintptr_t cmd1; /**< Primary channel command block base address. */ 50 uintptr_t ctl1; /**< Primary channel control block base address. */ 51 uintptr_t cmd2; /**< Secondary channel command block base address. */ 52 uintptr_t ctl2; /**< Secondary channel control block base address. */ 53 int irq1; /**< Primary channel IRQ */ 54 int irq2; /**< Secondary channel IRQ */ 52 55 } isa_ide_hwres_t; 53 56 54 /** ISA IDE c ontroller*/55 typedef struct isa_ide_c trl {56 /** DDF device*/57 ddf_dev_t *dev;57 /** ISA IDE channel */ 58 typedef struct isa_ide_channel { 59 /** Parent controller */ 60 struct isa_ide_ctrl *ctrl; 58 61 /** I/O base address of the command registers */ 59 62 uintptr_t cmd_physical; … … 78 81 ata_channel_t *channel; 79 82 struct isa_ide_fun *fun[2]; 83 84 /** Channel ID */ 85 unsigned chan_id; 86 } isa_ide_channel_t; 87 88 /** ISA IDE controller */ 89 typedef struct isa_ide_ctrl { 90 /** DDF device */ 91 ddf_dev_t *dev; 92 93 /** Primary and secondary channel */ 94 isa_ide_channel_t channel[2]; 80 95 } isa_ide_ctrl_t; 81 96 97 /** ISA IDE function */ 82 98 typedef struct isa_ide_fun { 83 99 ddf_fun_t *fun; … … 85 101 } isa_ide_fun_t; 86 102 87 extern errno_t isa_ide_c trl_init(isa_ide_ctrl_t *, isa_ide_hwres_t *);88 extern errno_t isa_ide_ctrl_remove(isa_ide_ctrl_t *);89 extern errno_t isa_ide_c trl_gone(isa_ide_ctrl_t *);103 extern errno_t isa_ide_channel_init(isa_ide_ctrl_t *, isa_ide_channel_t *, 104 unsigned, isa_ide_hwres_t *); 105 extern errno_t isa_ide_channel_fini(isa_ide_channel_t *); 90 106 91 107 #endif -
uspace/drv/block/isa-ide/main.c
r59c0f478 r646849b3 81 81 return rc; 82 82 83 if (hw_res.io_ranges.count != 2) {83 if (hw_res.io_ranges.count != 4) { 84 84 rc = EINVAL; 85 85 goto error; … … 88 88 /* I/O ranges */ 89 89 90 addr_range_t *cmd_rng = &hw_res.io_ranges.ranges[0]; 91 addr_range_t *ctl_rng = &hw_res.io_ranges.ranges[1]; 92 ata_res->cmd = RNGABS(*cmd_rng); 93 ata_res->ctl = RNGABS(*ctl_rng); 94 95 if (RNGSZ(*ctl_rng) < sizeof(ata_ctl_t)) { 96 rc = EINVAL; 97 goto error; 98 } 99 100 if (RNGSZ(*cmd_rng) < sizeof(ata_cmd_t)) { 90 addr_range_t *cmd1_rng = &hw_res.io_ranges.ranges[0]; 91 addr_range_t *ctl1_rng = &hw_res.io_ranges.ranges[1]; 92 addr_range_t *cmd2_rng = &hw_res.io_ranges.ranges[2]; 93 addr_range_t *ctl2_rng = &hw_res.io_ranges.ranges[3]; 94 ata_res->cmd1 = RNGABS(*cmd1_rng); 95 ata_res->ctl1 = RNGABS(*ctl1_rng); 96 ata_res->cmd2 = RNGABS(*cmd2_rng); 97 ata_res->ctl2 = RNGABS(*ctl2_rng); 98 99 if (RNGSZ(*ctl1_rng) < sizeof(ata_ctl_t)) { 100 rc = EINVAL; 101 goto error; 102 } 103 104 if (RNGSZ(*cmd1_rng) < sizeof(ata_cmd_t)) { 105 rc = EINVAL; 106 goto error; 107 } 108 109 if (RNGSZ(*ctl2_rng) < sizeof(ata_ctl_t)) { 110 rc = EINVAL; 111 goto error; 112 } 113 114 if (RNGSZ(*cmd2_rng) < sizeof(ata_cmd_t)) { 101 115 rc = EINVAL; 102 116 goto error; … … 105 119 /* IRQ */ 106 120 if (hw_res.irqs.count > 0) { 107 ata_res->irq = hw_res.irqs.irqs[0];121 ata_res->irq1 = hw_res.irqs.irqs[0]; 108 122 } else { 109 ata_res->irq = -1; 123 ata_res->irq1 = -1; 124 } 125 126 if (hw_res.irqs.count > 1) { 127 ata_res->irq2 = hw_res.irqs.irqs[1]; 128 } else { 129 ata_res->irq2 = -1; 110 130 } 111 131 … … 142 162 ctrl->dev = dev; 143 163 144 rc = isa_ide_ctrl_init(ctrl, &res); 164 rc = isa_ide_channel_init(ctrl, &ctrl->channel[0], 0, &res); 165 if (rc == ENOENT) 166 goto error; 167 168 rc = isa_ide_channel_init(ctrl, &ctrl->channel[1], 1, &res); 145 169 if (rc == ENOENT) 146 170 goto error; … … 157 181 } 158 182 159 static char *isa_ide_fun_name( unsigned idx)183 static char *isa_ide_fun_name(isa_ide_channel_t *chan, unsigned idx) 160 184 { 161 185 char *fun_name; 162 186 163 if (asprintf(&fun_name, " d%u", idx) < 0)187 if (asprintf(&fun_name, "c%ud%u", chan->chan_id, idx) < 0) 164 188 return NULL; 165 189 … … 167 191 } 168 192 169 errno_t isa_ide_fun_create(isa_ide_c trl_t *ctrl, unsigned idx, void *charg)193 errno_t isa_ide_fun_create(isa_ide_channel_t *chan, unsigned idx, void *charg) 170 194 { 171 195 errno_t rc; … … 175 199 bool bound = false; 176 200 177 fun_name = isa_ide_fun_name( idx);201 fun_name = isa_ide_fun_name(chan, idx); 178 202 if (fun_name == NULL) { 179 203 ddf_msg(LVL_ERROR, "Out of memory."); … … 182 206 } 183 207 184 fun = ddf_fun_create(c trl->dev, fun_exposed, fun_name);208 fun = ddf_fun_create(chan->ctrl->dev, fun_exposed, fun_name); 185 209 if (fun == NULL) { 186 210 ddf_msg(LVL_ERROR, "Failed creating DDF function."); … … 232 256 } 233 257 234 errno_t isa_ide_fun_remove(isa_ide_c trl_t *ctrl, unsigned idx)258 errno_t isa_ide_fun_remove(isa_ide_channel_t *chan, unsigned idx) 235 259 { 236 260 errno_t rc; 237 261 char *fun_name; 238 isa_ide_fun_t *ifun = c trl->fun[idx];239 240 fun_name = isa_ide_fun_name( idx);262 isa_ide_fun_t *ifun = chan->fun[idx]; 263 264 fun_name = isa_ide_fun_name(chan, idx); 241 265 if (fun_name == NULL) { 242 266 ddf_msg(LVL_ERROR, "Out of memory."); … … 267 291 } 268 292 269 errno_t isa_ide_fun_unbind(isa_ide_c trl_t *ctrl, unsigned idx)293 errno_t isa_ide_fun_unbind(isa_ide_channel_t *chan, unsigned idx) 270 294 { 271 295 errno_t rc; 272 296 char *fun_name; 273 isa_ide_fun_t *ifun = c trl->fun[idx];274 275 fun_name = isa_ide_fun_name( idx);297 isa_ide_fun_t *ifun = chan->fun[idx]; 298 299 fun_name = isa_ide_fun_name(chan, idx); 276 300 if (fun_name == NULL) { 277 301 ddf_msg(LVL_ERROR, "Out of memory."); … … 299 323 { 300 324 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev); 325 errno_t rc; 301 326 302 327 ddf_msg(LVL_DEBUG, "isa_ide_dev_remove(%p)", dev); 303 328 304 return isa_ide_ctrl_remove(ctrl); 329 rc = isa_ide_channel_fini(&ctrl->channel[0]); 330 if (rc != EOK) 331 return rc; 332 333 rc = isa_ide_channel_fini(&ctrl->channel[1]); 334 if (rc != EOK) 335 return rc; 336 337 return EOK; 305 338 } 306 339 … … 308 341 { 309 342 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev); 343 errno_t rc; 310 344 311 345 ddf_msg(LVL_DEBUG, "isa_ide_dev_gone(%p)", dev); 312 346 313 return isa_ide_ctrl_gone(ctrl); 347 rc = isa_ide_channel_fini(&ctrl->channel[0]); 348 if (rc != EOK) 349 return rc; 350 351 rc = isa_ide_channel_fini(&ctrl->channel[1]); 352 if (rc != EOK) 353 return rc; 354 355 return EOK; 314 356 } 315 357 -
uspace/drv/block/isa-ide/main.h
r59c0f478 r646849b3 38 38 #include "isa-ide.h" 39 39 40 extern errno_t isa_ide_fun_create(isa_ide_c trl_t *, unsigned, void *);41 extern errno_t isa_ide_fun_remove(isa_ide_c trl_t *, unsigned);42 extern errno_t isa_ide_fun_unbind(isa_ide_c trl_t *, unsigned);40 extern errno_t isa_ide_fun_create(isa_ide_channel_t *, unsigned, void *); 41 extern errno_t isa_ide_fun_remove(isa_ide_channel_t *, unsigned); 42 extern errno_t isa_ide_fun_unbind(isa_ide_channel_t *, unsigned); 43 43 44 44 #endif -
uspace/drv/bus/isa/isa.c
r59c0f478 r646849b3 1 1 /* 2 * Copyright (c) 20 18Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2010 Lenka Trochtova 4 4 * Copyright (c) 2011 Jan Vesely … … 72 72 #define EBUS_CHILD_FUN_CONF_PATH "/drv/isa/ebus.dev" 73 73 74 #define ISA_MAX_HW_RES 574 #define ISA_MAX_HW_RES 6 75 75 76 76 typedef struct { -
uspace/drv/bus/isa/isa.dev
r59c0f478 r646849b3 51 51 io_range 70 2 52 52 53 ata-c1:53 ide1: 54 54 match 100 isa/ide 55 55 io_range 0x1f0 8 56 56 io_range 0x3f0 8 57 irq 1458 59 ata-c2:60 match 100 isa/ide61 57 io_range 0x170 8 62 58 io_range 0x370 8 59 irq 14 63 60 irq 15 -
uspace/lib/ata/src/ata.c
r59c0f478 r646849b3 446 446 static errno_t ata_bd_init_irq(ata_channel_t *chan) 447 447 { 448 if (!chan->params.have_irq) 449 return EOK; 450 448 451 return chan->params.irq_enable(chan->params.arg); 449 452 } … … 452 455 static void ata_bd_fini_irq(ata_channel_t *chan) 453 456 { 457 if (!chan->params.have_irq) 458 return; 459 454 460 (void)chan->params.irq_disable(chan->params.arg); 455 461 } -
uspace/lib/drv/generic/interrupt.c
r59c0f478 r646849b3 1 1 /* 2 * Copyright (c) 2024 Jiri Svoboda 2 3 * Copyright (c) 2010 Lenka Trochtova 3 4 * All rights reserved. … … 50 51 } 51 52 53 errno_t register_interrupt_handler_arg(ddf_dev_t *dev, int irq, 54 interrupt_handler_t *handler, void *arg, const irq_code_t *irq_code, 55 cap_irq_handle_t *handle) 56 { 57 (void)dev; 58 return async_irq_subscribe(irq, (async_notification_handler_t) handler, 59 arg, irq_code, handle); 60 } 61 52 62 errno_t unregister_interrupt_handler(ddf_dev_t *dev, cap_irq_handle_t handle) 53 63 { -
uspace/lib/drv/include/ddf/interrupt.h
r59c0f478 r646849b3 1 1 /* 2 * Copyright (c) 2024 Jiri Svoboda 2 3 * Copyright (c) 2010 Lenka Trochtova 3 4 * All rights reserved. … … 52 53 extern errno_t register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *, 53 54 const irq_code_t *, cap_irq_handle_t *); 55 extern errno_t register_interrupt_handler_arg(ddf_dev_t *, int, 56 interrupt_handler_t *, void *, const irq_code_t *, cap_irq_handle_t *); 54 57 extern errno_t unregister_interrupt_handler(ddf_dev_t *, cap_irq_handle_t); 55 58
Note:
See TracChangeset
for help on using the changeset viewer.