Changeset 59c0f478 in mainline
- Timestamp:
- 2024-05-16T18:20:35Z (4 months ago)
- Branches:
- master
- Children:
- 646849b3
- Parents:
- 2791fbb7
- Files:
-
- 2 added
- 2 deleted
- 6 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
meson/arch/amd64/meson.build
r2791fbb7 r59c0f478 62 62 'drv/intctl/i8259', 63 63 'drv/platform/pc', 64 'drv/block/ ata_bd',64 'drv/block/isa-ide', 65 65 'drv/bus/pci/pciintel', 66 66 'drv/bus/isa', … … 76 76 'drv/audio/sb16', 77 77 'drv/block/ahci', 78 'drv/block/ ata_bd',78 'drv/block/isa-ide', 79 79 'drv/block/usbmast', 80 80 'drv/block/virtio-blk', -
meson/arch/ia32/meson.build
r2791fbb7 r59c0f478 68 68 'drv/intctl/i8259', 69 69 'drv/platform/pc', 70 'drv/block/ ata_bd',70 'drv/block/isa-ide', 71 71 'drv/bus/pci/pciintel', 72 72 'drv/bus/isa', … … 82 82 'drv/audio/sb16', 83 83 'drv/block/ahci', 84 'drv/block/ ata_bd',84 'drv/block/isa-ide', 85 85 'drv/block/usbmast', 86 86 'drv/block/virtio-blk', -
meson/arch/mips32/meson.build
r2791fbb7 r59c0f478 67 67 'drv/platform/malta', 68 68 'drv/intctl/i8259', 69 'drv/block/ ata_bd',69 'drv/block/isa-ide', 70 70 'drv/bus/pci/pciintel', 71 71 'drv/bus/isa', -
uspace/drv/block/isa-ide/isa-ide.c
r2791fbb7 r59c0f478 27 27 */ 28 28 29 /** @addtogroup ata_bd29 /** @addtogroup isa-ide 30 30 * @{ 31 31 */ … … 33 33 /** 34 34 * @file 35 * @brief ISA ATAdriver35 * @brief ISA IDE driver 36 36 * 37 37 * The driver services a single IDE channel. … … 52 52 #include <errno.h> 53 53 54 #include " ata_bd.h"54 #include "isa-ide.h" 55 55 #include "main.h" 56 56 57 #define NAME "ata_bd" 58 59 static errno_t ata_bd_init_io(ata_ctrl_t *ctrl); 60 static void ata_bd_fini_io(ata_ctrl_t *ctrl); 61 static errno_t ata_bd_init_irq(ata_ctrl_t *ctrl); 62 static void ata_bd_fini_irq(ata_ctrl_t *ctrl); 63 static void ata_irq_handler(ipc_call_t *call, ddf_dev_t *dev); 64 65 static void ata_write_data_16(void *, uint16_t *, size_t); 66 static void ata_read_data_16(void *, uint16_t *, size_t); 67 static void ata_write_cmd_8(void *, uint16_t, uint8_t); 68 static uint8_t ata_read_cmd_8(void *, uint16_t); 69 static void ata_write_ctl_8(void *, uint16_t, uint8_t); 70 static uint8_t ata_read_ctl_8(void *, uint16_t); 71 static errno_t ata_irq_enable(void *); 72 static errno_t ata_irq_disable(void *); 73 static errno_t ata_add_device(void *, unsigned, void *); 74 static errno_t ata_remove_device(void *, unsigned); 75 static void ata_msg_debug(void *, char *); 76 static void ata_msg_note(void *, char *); 77 static void ata_msg_warn(void *, char *); 78 static void ata_msg_error(void *, char *); 79 80 static const irq_pio_range_t ata_irq_ranges[] = { 57 static errno_t isa_ide_init_io(isa_ide_ctrl_t *ctrl); 58 static void isa_ide_fini_io(isa_ide_ctrl_t *ctrl); 59 static errno_t isa_ide_init_irq(isa_ide_ctrl_t *ctrl); 60 static void isa_ide_fini_irq(isa_ide_ctrl_t *ctrl); 61 static void isa_ide_irq_handler(ipc_call_t *call, ddf_dev_t *dev); 62 63 static void isa_ide_write_data_16(void *, uint16_t *, size_t); 64 static void isa_ide_read_data_16(void *, uint16_t *, size_t); 65 static void isa_ide_write_cmd_8(void *, uint16_t, uint8_t); 66 static uint8_t isa_ide_read_cmd_8(void *, uint16_t); 67 static void isa_ide_write_ctl_8(void *, uint16_t, uint8_t); 68 static uint8_t isa_ide_read_ctl_8(void *, uint16_t); 69 static errno_t isa_ide_irq_enable(void *); 70 static errno_t isa_ide_irq_disable(void *); 71 static errno_t isa_ide_add_device(void *, unsigned, void *); 72 static errno_t isa_ide_remove_device(void *, unsigned); 73 static void isa_ide_msg_debug(void *, char *); 74 static void isa_ide_msg_note(void *, char *); 75 static void isa_ide_msg_warn(void *, char *); 76 static void isa_ide_msg_error(void *, char *); 77 78 static const irq_pio_range_t isa_ide_irq_ranges[] = { 81 79 { 82 80 .base = 0, … … 85 83 }; 86 84 87 /** ATAinterrupt pseudo code. */88 static const irq_cmd_t ata_irq_cmds[] = {85 /** IDE interrupt pseudo code. */ 86 static const irq_cmd_t isa_ide_irq_cmds[] = { 89 87 { 90 88 .cmd = CMD_PIO_READ_8, … … 97 95 }; 98 96 99 /** Initialize ATAcontroller. */100 errno_t ata_ctrl_init(ata_ctrl_t *ctrl, ata_hwres_t *res)97 /** Initialize ISA IDE controller. */ 98 errno_t isa_ide_ctrl_init(isa_ide_ctrl_t *ctrl, isa_ide_hwres_t *res) 101 99 { 102 100 errno_t rc; … … 104 102 ata_params_t params; 105 103 106 ddf_msg(LVL_DEBUG, " ata_ctrl_init()");104 ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init()"); 107 105 108 106 fibril_mutex_initialize(&ctrl->lock); … … 115 113 116 114 ddf_msg(LVL_DEBUG, "Init I/O"); 117 rc = ata_bd_init_io(ctrl);115 rc = isa_ide_init_io(ctrl); 118 116 if (rc != EOK) 119 117 return rc; 120 118 121 119 ddf_msg(LVL_DEBUG, "Init IRQ"); 122 rc = ata_bd_init_irq(ctrl);120 rc = isa_ide_init_irq(ctrl); 123 121 if (rc != EOK) { 124 122 ddf_msg(LVL_NOTE, "init IRQ failed"); … … 128 126 irq_inited = true; 129 127 130 ddf_msg(LVL_DEBUG, " ata_ctrl_init(): Initialize ATAchannel");128 ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init(): Initialize IDE channel"); 131 129 132 130 params.arg = (void *)ctrl; 133 131 params.have_irq = (ctrl->irq >= 0) ? true : false; 134 params.write_data_16 = ata_write_data_16;135 params.read_data_16 = ata_read_data_16;136 params.write_cmd_8 = ata_write_cmd_8;137 params.read_cmd_8 = ata_read_cmd_8;138 params.write_ctl_8 = ata_write_ctl_8;139 params.read_ctl_8 = ata_read_ctl_8;140 params.irq_enable = ata_irq_enable;141 params.irq_disable = ata_irq_disable;142 params.add_device = ata_add_device;143 params.remove_device = ata_remove_device;144 params.msg_debug = ata_msg_debug;145 params.msg_note = ata_msg_note;146 params.msg_warn = ata_msg_warn;147 params.msg_error = ata_msg_error;132 params.write_data_16 = isa_ide_write_data_16; 133 params.read_data_16 = isa_ide_read_data_16; 134 params.write_cmd_8 = isa_ide_write_cmd_8; 135 params.read_cmd_8 = isa_ide_read_cmd_8; 136 params.write_ctl_8 = isa_ide_write_ctl_8; 137 params.read_ctl_8 = isa_ide_read_ctl_8; 138 params.irq_enable = isa_ide_irq_enable; 139 params.irq_disable = isa_ide_irq_disable; 140 params.add_device = isa_ide_add_device; 141 params.remove_device = isa_ide_remove_device; 142 params.msg_debug = isa_ide_msg_debug; 143 params.msg_note = isa_ide_msg_note; 144 params.msg_warn = isa_ide_msg_warn; 145 params.msg_error = isa_ide_msg_error; 148 146 149 147 rc = ata_channel_create(¶ms, &ctrl->channel); … … 155 153 goto error; 156 154 157 ddf_msg(LVL_DEBUG, " ata_ctrl_init: DONE");155 ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init: DONE"); 158 156 return EOK; 159 157 error: 160 158 if (irq_inited) 161 ata_bd_fini_irq(ctrl);162 ata_bd_fini_io(ctrl);159 isa_ide_fini_irq(ctrl); 160 isa_ide_fini_io(ctrl); 163 161 return rc; 164 162 } 165 163 166 /** Remove ATAcontroller. */167 errno_t ata_ctrl_remove(ata_ctrl_t *ctrl)168 { 169 errno_t rc; 170 171 ddf_msg(LVL_DEBUG, ": ata_ctrl_remove()");164 /** Remove ISA IDE controller. */ 165 errno_t isa_ide_ctrl_remove(isa_ide_ctrl_t *ctrl) 166 { 167 errno_t rc; 168 169 ddf_msg(LVL_DEBUG, ": isa_ide_ctrl_remove()"); 172 170 173 171 fibril_mutex_lock(&ctrl->lock); … … 179 177 } 180 178 181 ata_bd_fini_irq(ctrl);182 ata_bd_fini_io(ctrl);179 isa_ide_fini_irq(ctrl); 180 isa_ide_fini_io(ctrl); 183 181 fibril_mutex_unlock(&ctrl->lock); 184 182 … … 186 184 } 187 185 188 /** Surprise removal of ATAcontroller. */189 errno_t ata_ctrl_gone(ata_ctrl_t *ctrl)190 { 191 errno_t rc; 192 193 ddf_msg(LVL_DEBUG, " ata_ctrl_gone()");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()"); 194 192 195 193 fibril_mutex_lock(&ctrl->lock); … … 201 199 } 202 200 203 ata_bd_fini_io(ctrl);201 isa_ide_fini_io(ctrl); 204 202 fibril_mutex_unlock(&ctrl->lock); 205 203 … … 208 206 209 207 /** Enable device I/O. */ 210 static errno_t ata_bd_init_io(ata_ctrl_t *ctrl)208 static errno_t isa_ide_init_io(isa_ide_ctrl_t *ctrl) 211 209 { 212 210 errno_t rc; … … 232 230 233 231 /** Clean up device I/O. */ 234 static void ata_bd_fini_io(ata_ctrl_t *ctrl)232 static void isa_ide_fini_io(isa_ide_ctrl_t *ctrl) 235 233 { 236 234 (void) ctrl; … … 239 237 240 238 /** Initialize IRQ. */ 241 static errno_t ata_bd_init_irq(ata_ctrl_t *ctrl)239 static errno_t isa_ide_init_irq(isa_ide_ctrl_t *ctrl) 242 240 { 243 241 irq_code_t irq_code; … … 249 247 return EOK; 250 248 251 ranges = malloc(sizeof( ata_irq_ranges));249 ranges = malloc(sizeof(isa_ide_irq_ranges)); 252 250 if (ranges == NULL) 253 251 return ENOMEM; 254 252 255 cmds = malloc(sizeof( ata_irq_cmds));253 cmds = malloc(sizeof(isa_ide_irq_cmds)); 256 254 if (cmds == NULL) { 257 255 free(cmds); … … 259 257 } 260 258 261 memcpy(ranges, & ata_irq_ranges, sizeof(ata_irq_ranges));259 memcpy(ranges, &isa_ide_irq_ranges, sizeof(isa_ide_irq_ranges)); 262 260 ranges[0].base = ctrl->cmd_physical; 263 memcpy(cmds, & ata_irq_cmds, sizeof(ata_irq_cmds));261 memcpy(cmds, &isa_ide_irq_cmds, sizeof(isa_ide_irq_cmds)); 264 262 cmds[0].addr = &ctrl->cmd->status; 265 263 266 irq_code.rangecount = sizeof( ata_irq_ranges) / sizeof(irq_pio_range_t);264 irq_code.rangecount = sizeof(isa_ide_irq_ranges) / sizeof(irq_pio_range_t); 267 265 irq_code.ranges = ranges; 268 irq_code.cmdcount = sizeof( ata_irq_cmds) / sizeof(irq_cmd_t);266 irq_code.cmdcount = sizeof(isa_ide_irq_cmds) / sizeof(irq_cmd_t); 269 267 irq_code.cmds = cmds; 270 268 271 269 ddf_msg(LVL_NOTE, "IRQ %d", ctrl->irq); 272 rc = register_interrupt_handler(ctrl->dev, ctrl->irq, ata_irq_handler,270 rc = register_interrupt_handler(ctrl->dev, ctrl->irq, isa_ide_irq_handler, 273 271 &irq_code, &ctrl->ihandle); 274 272 if (rc != EOK) { … … 288 286 289 287 /** Clean up IRQ. */ 290 static void ata_bd_fini_irq(ata_ctrl_t *ctrl)288 static void isa_ide_fini_irq(isa_ide_ctrl_t *ctrl) 291 289 { 292 290 errno_t rc; … … 307 305 * @param dev Device that caused the interrupt 308 306 */ 309 static void ata_irq_handler(ipc_call_t *call, ddf_dev_t *dev)310 { 311 ata_ctrl_t *ctrl = (ata_ctrl_t *)ddf_dev_data_get(dev);307 static void isa_ide_irq_handler(ipc_call_t *call, ddf_dev_t *dev) 308 { 309 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev); 312 310 uint8_t status; 313 311 async_sess_t *parent_sess; … … 322 320 /** Write the data register callback handler. 323 321 * 324 * @param arg Argument ( ata_ctrl_t *)322 * @param arg Argument (isa_ide_ctrl_t *) 325 323 * @param data Data 326 324 * @param nwords Number of words to write 327 325 */ 328 static void ata_write_data_16(void *arg, uint16_t *data, size_t nwords)329 { 330 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;326 static void isa_ide_write_data_16(void *arg, uint16_t *data, size_t nwords) 327 { 328 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 331 329 size_t i; 332 330 … … 337 335 /** Read the data register callback handler. 338 336 * 339 * @param arg Argument ( ata_ctrl_t *)337 * @param arg Argument (isa_ide_ctrl_t *) 340 338 * @param buf Destination buffer 341 339 * @param nwords Number of words to read 342 340 */ 343 static void ata_read_data_16(void *arg, uint16_t *buf, size_t nwords)344 { 345 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;341 static void isa_ide_read_data_16(void *arg, uint16_t *buf, size_t nwords) 342 { 343 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 346 344 size_t i; 347 345 … … 352 350 /** Write command register callback handler. 353 351 * 354 * @param arg Argument ( ata_ctrl_t *)352 * @param arg Argument (isa_ide_ctrl_t *) 355 353 * @param off Register offset 356 354 * @param value Value to write to command register 357 355 */ 358 static void ata_write_cmd_8(void *arg, uint16_t off, uint8_t value)359 { 360 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;356 static void isa_ide_write_cmd_8(void *arg, uint16_t off, uint8_t value) 357 { 358 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 361 359 362 360 pio_write_8(((ioport8_t *)ctrl->cmd) + off, value); … … 365 363 /** Read command register callback handler. 366 364 * 367 * @param arg Argument ( ata_ctrl_t *)365 * @param arg Argument (isa_ide_ctrl_t *) 368 366 * @param off Register offset 369 367 * @return value Value read from command register 370 368 */ 371 static uint8_t ata_read_cmd_8(void *arg, uint16_t off)372 { 373 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;369 static uint8_t isa_ide_read_cmd_8(void *arg, uint16_t off) 370 { 371 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 374 372 375 373 return pio_read_8(((ioport8_t *)ctrl->cmd) + off); … … 378 376 /** Write control register callback handler. 379 377 * 380 * @param arg Argument ( ata_ctrl_t *)378 * @param arg Argument (isa_ide_ctrl_t *) 381 379 * @param off Register offset 382 380 * @param value Value to write to control register 383 381 */ 384 static void ata_write_ctl_8(void *arg, uint16_t off, uint8_t value)385 { 386 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;382 static void isa_ide_write_ctl_8(void *arg, uint16_t off, uint8_t value) 383 { 384 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 387 385 388 386 pio_write_8(((ioport8_t *)ctrl->ctl) + off, value); … … 391 389 /** Read control register callback handler. 392 390 * 393 * @param arg Argument ( ata_ctrl_t *)391 * @param arg Argument (isa_ide_ctrl_t *) 394 392 * @param off Register offset 395 393 * @return value Value read from control register 396 394 */ 397 static uint8_t ata_read_ctl_8(void *arg, uint16_t off)398 { 399 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;395 static uint8_t isa_ide_read_ctl_8(void *arg, uint16_t off) 396 { 397 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 400 398 401 399 return pio_read_8(((ioport8_t *)ctrl->ctl) + off); … … 404 402 /** Enable IRQ callback handler 405 403 * 406 * @param arg Argument ( ata_ctrl_t *)404 * @param arg Argument (isa_ide_ctrl_t *) 407 405 * @return EOK on success or an error code 408 406 */ 409 static errno_t ata_irq_enable(void *arg)410 { 411 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;407 static errno_t isa_ide_irq_enable(void *arg) 408 { 409 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 412 410 async_sess_t *parent_sess; 413 411 errno_t rc; … … 430 428 /** Disable IRQ callback handler 431 429 * 432 * @param arg Argument ( ata_ctrl_t *)430 * @param arg Argument (isa_ide_ctrl_t *) 433 431 * @return EOK on success or an error code 434 432 */ 435 static errno_t ata_irq_disable(void *arg)436 { 437 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;433 static errno_t isa_ide_irq_disable(void *arg) 434 { 435 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 438 436 async_sess_t *parent_sess; 439 437 errno_t rc; … … 456 454 /** Add ATA device callback handler. 457 455 * 458 * @param arg Argument ( ata_ctrl_t *)456 * @param arg Argument (isa_ide_ctrl_t *) 459 457 * @param idx Device index 460 458 * $param charg Connection handler argument 461 459 * @return EOK on success or an error code 462 460 */ 463 static errno_t ata_add_device(void *arg, unsigned idx, void *charg)464 { 465 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;466 return ata_fun_create(ctrl, idx, charg);461 static errno_t isa_ide_add_device(void *arg, unsigned idx, void *charg) 462 { 463 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 464 return isa_ide_fun_create(ctrl, idx, charg); 467 465 } 468 466 469 467 /** Remove ATA device callback handler. 470 468 * 471 * @param arg Argument ( ata_ctrl_t *)469 * @param arg Argument (isa_ide_ctrl_t *) 472 470 * @param idx Device index 473 471 * @return EOK on success or an error code 474 472 */ 475 static errno_t ata_remove_device(void *arg, unsigned idx)476 { 477 ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;478 return ata_fun_remove(ctrl, idx);473 static errno_t isa_ide_remove_device(void *arg, unsigned idx) 474 { 475 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg; 476 return isa_ide_fun_remove(ctrl, idx); 479 477 } 480 478 481 479 /** Debug message callback handler. 482 480 * 483 * @param arg Argument ( ata_ctrl_t *)481 * @param arg Argument (isa_ide_ctrl_t *) 484 482 * @param msg Message 485 483 */ 486 static void ata_msg_debug(void *arg, char *msg)484 static void isa_ide_msg_debug(void *arg, char *msg) 487 485 { 488 486 (void)arg; … … 492 490 /** Notice message callback handler. 493 491 * 494 * @param arg Argument ( ata_ctrl_t *)492 * @param arg Argument (isa_ide_ctrl_t *) 495 493 * @param msg Message 496 494 */ 497 static void ata_msg_note(void *arg, char *msg)495 static void isa_ide_msg_note(void *arg, char *msg) 498 496 { 499 497 (void)arg; … … 503 501 /** Warning message callback handler. 504 502 * 505 * @param arg Argument ( ata_ctrl_t *)503 * @param arg Argument (isa_ide_ctrl_t *) 506 504 * @param msg Message 507 505 */ 508 static void ata_msg_warn(void *arg, char *msg)506 static void isa_ide_msg_warn(void *arg, char *msg) 509 507 { 510 508 (void)arg; … … 514 512 /** Error message callback handler. 515 513 * 516 * @param arg Argument ( ata_ctrl_t *)514 * @param arg Argument (isa_ide_ctrl_t *) 517 515 * @param msg Message 518 516 */ 519 static void ata_msg_error(void *arg, char *msg)517 static void isa_ide_msg_error(void *arg, char *msg) 520 518 { 521 519 (void)arg; -
uspace/drv/block/isa-ide/isa-ide.h
r2791fbb7 r59c0f478 27 27 */ 28 28 29 /** @addtogroup ata_bd29 /** @addtogroup isa-ide 30 30 * @{ 31 31 */ 32 /** @file ATAdriver definitions.32 /** @file ISA IDE driver definitions. 33 33 */ 34 34 35 #ifndef __ATA_BD_H__36 #define __ATA_BD_H__35 #ifndef ISA_IDE_H 36 #define ISA_IDE_H 37 37 38 38 #include <ata/ata.h> … … 43 43 #include <stdint.h> 44 44 45 #define NAME " ata_bd"45 #define NAME "isa-ide" 46 46 47 /** ATAhardware resources */47 /** ISA IDE hardware resources */ 48 48 typedef struct { 49 49 uintptr_t cmd; /**< Command block base address. */ 50 50 uintptr_t ctl; /**< Control block base address. */ 51 51 int irq; /**< IRQ */ 52 } ata_hwres_t;52 } isa_ide_hwres_t; 53 53 54 /** ATAcontroller */55 typedef struct ata_ctrl {54 /** ISA IDE controller */ 55 typedef struct isa_ide_ctrl { 56 56 /** DDF device */ 57 57 ddf_dev_t *dev; … … 77 77 /** Libata ATA channel */ 78 78 ata_channel_t *channel; 79 struct ata_fun *fun[2];80 } ata_ctrl_t;79 struct isa_ide_fun *fun[2]; 80 } isa_ide_ctrl_t; 81 81 82 typedef struct ata_fun {82 typedef struct isa_ide_fun { 83 83 ddf_fun_t *fun; 84 84 void *charg; 85 } ata_fun_t;85 } isa_ide_fun_t; 86 86 87 extern errno_t ata_ctrl_init(ata_ctrl_t *, ata_hwres_t *);88 extern errno_t ata_ctrl_remove(ata_ctrl_t *);89 extern errno_t ata_ctrl_gone(ata_ctrl_t *);87 extern errno_t isa_ide_ctrl_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_ctrl_gone(isa_ide_ctrl_t *); 90 90 91 91 #endif -
uspace/drv/block/isa-ide/main.c
r2791fbb7 r59c0f478 27 27 */ 28 28 29 /** @addtogroup ata_bd29 /** @addtogroup isa-ide 30 30 * @{ 31 31 */ … … 42 42 #include <device/hw_res_parsed.h> 43 43 44 #include " ata_bd.h"44 #include "isa-ide.h" 45 45 #include "main.h" 46 46 47 static errno_t ata_dev_add(ddf_dev_t *dev);48 static errno_t ata_dev_remove(ddf_dev_t *dev);49 static errno_t ata_dev_gone(ddf_dev_t *dev);50 static errno_t ata_fun_online(ddf_fun_t *fun);51 static errno_t ata_fun_offline(ddf_fun_t *fun);52 53 static void ata_bd_connection(ipc_call_t *, void *);47 static errno_t isa_ide_dev_add(ddf_dev_t *dev); 48 static errno_t isa_ide_dev_remove(ddf_dev_t *dev); 49 static errno_t isa_ide_dev_gone(ddf_dev_t *dev); 50 static errno_t isa_ide_fun_online(ddf_fun_t *fun); 51 static errno_t isa_ide_fun_offline(ddf_fun_t *fun); 52 53 static void isa_ide_connection(ipc_call_t *, void *); 54 54 55 55 static driver_ops_t driver_ops = { 56 .dev_add = & ata_dev_add,57 .dev_remove = & ata_dev_remove,58 .dev_gone = & ata_dev_gone,59 .fun_online = & ata_fun_online,60 .fun_offline = & ata_fun_offline56 .dev_add = &isa_ide_dev_add, 57 .dev_remove = &isa_ide_dev_remove, 58 .dev_gone = &isa_ide_dev_gone, 59 .fun_online = &isa_ide_fun_online, 60 .fun_offline = &isa_ide_fun_offline 61 61 }; 62 62 63 static driver_t ata_driver = {63 static driver_t isa_ide_driver = { 64 64 .name = NAME, 65 65 .driver_ops = &driver_ops 66 66 }; 67 67 68 static errno_t ata_get_res(ddf_dev_t *dev, ata_hwres_t *ata_res)68 static errno_t ata_get_res(ddf_dev_t *dev, isa_ide_hwres_t *ata_res) 69 69 { 70 70 async_sess_t *parent_sess; … … 121 121 * @return EOK on success or an error code. 122 122 */ 123 static errno_t ata_dev_add(ddf_dev_t *dev)124 { 125 ata_ctrl_t *ctrl;126 ata_hwres_t res;123 static errno_t isa_ide_dev_add(ddf_dev_t *dev) 124 { 125 isa_ide_ctrl_t *ctrl; 126 isa_ide_hwres_t res; 127 127 errno_t rc; 128 128 … … 133 133 } 134 134 135 ctrl = ddf_dev_data_alloc(dev, sizeof( ata_ctrl_t));135 ctrl = ddf_dev_data_alloc(dev, sizeof(isa_ide_ctrl_t)); 136 136 if (ctrl == NULL) { 137 137 ddf_msg(LVL_ERROR, "Failed allocating soft state."); … … 142 142 ctrl->dev = dev; 143 143 144 rc = ata_ctrl_init(ctrl, &res);144 rc = isa_ide_ctrl_init(ctrl, &res); 145 145 if (rc == ENOENT) 146 146 goto error; … … 157 157 } 158 158 159 static char * ata_fun_name(unsigned idx)159 static char *isa_ide_fun_name(unsigned idx) 160 160 { 161 161 char *fun_name; … … 167 167 } 168 168 169 errno_t ata_fun_create(ata_ctrl_t *ctrl, unsigned idx, void *charg)169 errno_t isa_ide_fun_create(isa_ide_ctrl_t *ctrl, unsigned idx, void *charg) 170 170 { 171 171 errno_t rc; 172 172 char *fun_name = NULL; 173 173 ddf_fun_t *fun = NULL; 174 ata_fun_t *afun = NULL;174 isa_ide_fun_t *ifun = NULL; 175 175 bool bound = false; 176 176 177 fun_name = ata_fun_name(idx);177 fun_name = isa_ide_fun_name(idx); 178 178 if (fun_name == NULL) { 179 179 ddf_msg(LVL_ERROR, "Out of memory."); … … 190 190 191 191 /* Allocate soft state */ 192 afun = ddf_fun_data_alloc(fun, sizeof(ata_fun_t));193 if ( afun == NULL) {192 ifun = ddf_fun_data_alloc(fun, sizeof(isa_ide_fun_t)); 193 if (ifun == NULL) { 194 194 ddf_msg(LVL_ERROR, "Failed allocating softstate."); 195 195 rc = ENOMEM; … … 197 197 } 198 198 199 afun->fun = fun;200 afun->charg = charg;199 ifun->fun = fun; 200 ifun->charg = charg; 201 201 202 202 /* Set up a connection handler. */ 203 ddf_fun_set_conn_handler(fun, ata_bd_connection);203 ddf_fun_set_conn_handler(fun, isa_ide_connection); 204 204 205 205 rc = ddf_fun_bind(fun); … … 232 232 } 233 233 234 errno_t ata_fun_remove(ata_ctrl_t *ctrl, unsigned idx)234 errno_t isa_ide_fun_remove(isa_ide_ctrl_t *ctrl, unsigned idx) 235 235 { 236 236 errno_t rc; 237 237 char *fun_name; 238 ata_fun_t *afun = ctrl->fun[idx];239 240 fun_name = ata_fun_name(idx);238 isa_ide_fun_t *ifun = ctrl->fun[idx]; 239 240 fun_name = isa_ide_fun_name(idx); 241 241 if (fun_name == NULL) { 242 242 ddf_msg(LVL_ERROR, "Out of memory."); … … 245 245 } 246 246 247 ddf_msg(LVL_DEBUG, " ata_fun_remove(%p, '%s')", afun, fun_name);248 rc = ddf_fun_offline( afun->fun);247 ddf_msg(LVL_DEBUG, "isa_ide_fun_remove(%p, '%s')", ifun, fun_name); 248 rc = ddf_fun_offline(ifun->fun); 249 249 if (rc != EOK) { 250 250 ddf_msg(LVL_ERROR, "Error offlining function '%s'.", fun_name); … … 252 252 } 253 253 254 rc = ddf_fun_unbind( afun->fun);254 rc = ddf_fun_unbind(ifun->fun); 255 255 if (rc != EOK) { 256 256 ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", fun_name); … … 258 258 } 259 259 260 ddf_fun_destroy( afun->fun);260 ddf_fun_destroy(ifun->fun); 261 261 free(fun_name); 262 262 return EOK; … … 267 267 } 268 268 269 errno_t ata_fun_unbind(ata_ctrl_t *ctrl, unsigned idx)269 errno_t isa_ide_fun_unbind(isa_ide_ctrl_t *ctrl, unsigned idx) 270 270 { 271 271 errno_t rc; 272 272 char *fun_name; 273 ata_fun_t *afun = ctrl->fun[idx];274 275 fun_name = ata_fun_name(idx);273 isa_ide_fun_t *ifun = ctrl->fun[idx]; 274 275 fun_name = isa_ide_fun_name(idx); 276 276 if (fun_name == NULL) { 277 277 ddf_msg(LVL_ERROR, "Out of memory."); … … 280 280 } 281 281 282 ddf_msg(LVL_DEBUG, " ata_fun_unbind(%p, '%s')", afun, fun_name);283 rc = ddf_fun_unbind( afun->fun);282 ddf_msg(LVL_DEBUG, "isa_ide_fun_unbind(%p, '%s')", ifun, fun_name); 283 rc = ddf_fun_unbind(ifun->fun); 284 284 if (rc != EOK) { 285 285 ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", fun_name); … … 287 287 } 288 288 289 ddf_fun_destroy( afun->fun);289 ddf_fun_destroy(ifun->fun); 290 290 free(fun_name); 291 291 return EOK; … … 296 296 } 297 297 298 static errno_t ata_dev_remove(ddf_dev_t *dev)299 { 300 ata_ctrl_t *ctrl = (ata_ctrl_t *)ddf_dev_data_get(dev);301 302 ddf_msg(LVL_DEBUG, " ata_dev_remove(%p)", dev);303 304 return ata_ctrl_remove(ctrl);305 } 306 307 static errno_t ata_dev_gone(ddf_dev_t *dev)308 { 309 ata_ctrl_t *ctrl = (ata_ctrl_t *)ddf_dev_data_get(dev);310 311 ddf_msg(LVL_DEBUG, " ata_dev_gone(%p)", dev);312 313 return ata_ctrl_gone(ctrl);314 } 315 316 static errno_t ata_fun_online(ddf_fun_t *fun)317 { 318 ddf_msg(LVL_DEBUG, " ata_fun_online()");298 static errno_t isa_ide_dev_remove(ddf_dev_t *dev) 299 { 300 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev); 301 302 ddf_msg(LVL_DEBUG, "isa_ide_dev_remove(%p)", dev); 303 304 return isa_ide_ctrl_remove(ctrl); 305 } 306 307 static errno_t isa_ide_dev_gone(ddf_dev_t *dev) 308 { 309 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev); 310 311 ddf_msg(LVL_DEBUG, "isa_ide_dev_gone(%p)", dev); 312 313 return isa_ide_ctrl_gone(ctrl); 314 } 315 316 static errno_t isa_ide_fun_online(ddf_fun_t *fun) 317 { 318 ddf_msg(LVL_DEBUG, "isa_ide_fun_online()"); 319 319 return ddf_fun_online(fun); 320 320 } 321 321 322 static errno_t ata_fun_offline(ddf_fun_t *fun)323 { 324 ddf_msg(LVL_DEBUG, " ata_fun_offline()");322 static errno_t isa_ide_fun_offline(ddf_fun_t *fun) 323 { 324 ddf_msg(LVL_DEBUG, "isa_ide_fun_offline()"); 325 325 return ddf_fun_offline(fun); 326 326 } 327 327 328 static void ata_bd_connection(ipc_call_t *icall, void *arg)329 { 330 ata_fun_t *afun;331 332 afun = (ata_fun_t *) ddf_fun_data_get((ddf_fun_t *)arg);333 ata_connection(icall, afun->charg);328 static void isa_ide_connection(ipc_call_t *icall, void *arg) 329 { 330 isa_ide_fun_t *ifun; 331 332 ifun = (isa_ide_fun_t *) ddf_fun_data_get((ddf_fun_t *)arg); 333 ata_connection(icall, ifun->charg); 334 334 } 335 335 336 336 int main(int argc, char *argv[]) 337 337 { 338 printf(NAME ": HelenOS ATA(PI)device driver\n");338 printf(NAME ": HelenOS ISA IDE device driver\n"); 339 339 ddf_log_init(NAME); 340 return ddf_driver_main(& ata_driver);340 return ddf_driver_main(&isa_ide_driver); 341 341 } 342 342 -
uspace/drv/block/isa-ide/main.h
r2791fbb7 r59c0f478 27 27 */ 28 28 29 /** @addtogroup ata_bd29 /** @addtogroup isa-ide 30 30 * @{ 31 31 */ 32 /** @file ATAdriver main module32 /** @file ISA IDE driver main module 33 33 */ 34 34 35 #ifndef __ATA_MAIN_H__36 #define __ATA_MAIN_H__35 #ifndef MAIN_H 36 #define MAIN_H 37 37 38 #include " ata_bd.h"38 #include "isa-ide.h" 39 39 40 extern errno_t ata_fun_create(ata_ctrl_t *, unsigned, void *);41 extern errno_t ata_fun_remove(ata_ctrl_t *, unsigned);42 extern errno_t ata_fun_unbind(ata_ctrl_t *, unsigned);40 extern errno_t isa_ide_fun_create(isa_ide_ctrl_t *, unsigned, void *); 41 extern errno_t isa_ide_fun_remove(isa_ide_ctrl_t *, unsigned); 42 extern errno_t isa_ide_fun_unbind(isa_ide_ctrl_t *, unsigned); 43 43 44 44 #endif -
uspace/drv/block/isa-ide/meson.build
r2791fbb7 r59c0f478 1 1 # 2 # Copyright (c) 20 13Jiri Svoboda2 # Copyright (c) 2024 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 28 28 29 29 deps = [ 'ata', 'scsi' ] 30 src = files(' ata_bd.c', 'main.c')30 src = files('isa-ide.c', 'main.c') -
uspace/drv/bus/isa/isa.dev
r2791fbb7 r59c0f478 52 52 53 53 ata-c1: 54 match 100 isa/ ata_bd54 match 100 isa/ide 55 55 io_range 0x1f0 8 56 56 io_range 0x3f0 8 … … 58 58 59 59 ata-c2: 60 match 100 isa/ ata_bd60 match 100 isa/ide 61 61 io_range 0x170 8 62 62 io_range 0x370 8 -
uspace/drv/meson.build
r2791fbb7 r59c0f478 33 33 'root/virt', 34 34 'block/ahci', 35 'block/ata_bd',36 35 'block/ddisk', 36 'block/isa-ide', 37 37 'block/usbmast', 38 38 'block/virtio-blk', -
uspace/lib/ata/include/ata/ata.h
r2791fbb7 r59c0f478 44 44 #include <stddef.h> 45 45 #include "ata_hw.h" 46 47 #define NAME "ata_bd"48 46 49 47 struct ata_device;
Note:
See TracChangeset
for help on using the changeset viewer.