Changeset 12956e57 in mainline for uspace/srv/bd/ata_bd/ata_bd.c


Ignore:
Timestamp:
2009-06-20T19:31:19Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2dfd9fa
Parents:
ac47b7c2
Message:

Use fibril synchronization in bd drivers. Use per-disk locks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/ata_bd/ata_bd.c

    rac47b7c2 r12956e57  
    3838 * Currently based on the (now obsolete) ANSI X3.221-1994 (ATA-1) standard.
    3939 * At this point only reading is possible, not writing.
     40 *
     41 * The driver services a single controller which can have up to two disks
     42 * attached.
    4043 */
    4144
     
    4750#include <async.h>
    4851#include <as.h>
    49 #include <futex.h>
     52#include <fibril_sync.h>
    5053#include <devmap.h>
    5154#include <sys/types.h>
     
    6568static ata_ctl_t *ctl;
    6669
    67 static dev_handle_t dev_handle[MAX_DISKS];
    68 
    69 static atomic_t dev_futex = FUTEX_INITIALIZER;
    70 
     70/** Per-disk state. */
    7171static disk_t disk[MAX_DISKS];
    7272
     
    9090        printf(NAME ": ATA disk driver\n");
    9191
    92         printf("cmd_physical = 0x%x\n", cmd_physical);
    93         printf("ctl_physical = 0x%x\n", ctl_physical);
     92        printf("I/O address 0x%x\n", cmd_physical);
    9493
    9594        if (ata_bd_init() != EOK)
     
    121120
    122121                snprintf(name, 16, "disk%d", i);
    123                 rc = devmap_device_register(name, &dev_handle[i]);
     122                rc = devmap_device_register(name, &disk[i].dev_handle);
    124123                if (rc != EOK) {
    125124                        devmap_hangup_phone(DEVMAP_DRIVER);
     
    182181        }
    183182
    184         printf("\n\nStatus = 0x%x\n", pio_read_8(&cmd->status));
    185 
    186183        d->blocks = d->cylinders * d->heads * d->sectors;
    187184
     
    190187
    191188        d->present = true;
     189        fibril_mutex_initialize(&d->lock);
    192190
    193191        return EOK;
     
    244242        disk_id = -1;
    245243        for (i = 0; i < MAX_DISKS; i++)
    246                 if (dev_handle[i] == dh)
     244                if (disk[i].dev_handle == dh)
    247245                        disk_id = i;
    248246
     
    356354            (h & 0x0f);
    357355
    358         futex_down(&dev_futex);
     356        fibril_mutex_lock(&d->lock);
    359357
    360358        /* Program a Read Sectors operation. */
     
    378376        }
    379377
    380         futex_up(&dev_futex);
     378        fibril_mutex_unlock(&d->lock);
    381379        return EOK;
    382380}
     
    410408            (h & 0x0f);
    411409
    412         futex_down(&dev_futex);
     410        fibril_mutex_lock(&d->lock);
    413411
    414412        /* Program a Read Sectors operation. */
     
    431429        }
    432430
    433         futex_up(&dev_futex);
     431        fibril_mutex_unlock(&d->lock);
    434432        return EOK;
    435433}
Note: See TracChangeset for help on using the changeset viewer.