示例#1
0
static void
ide_local_device_init (IdeLocalDevice *self)
{
  IdeLocalDevicePrivate *priv = ide_local_device_get_instance_private (self);

  priv->system_type = get_system_type ();
  priv->config = g_key_file_new ();

  g_key_file_set_string (priv->config, "autoconf", "--host", priv->system_type);

  ide_device_set_display_name (IDE_DEVICE (self), g_get_host_name ());
  ide_device_set_id (IDE_DEVICE (self), "local");
}
示例#2
0
文件: qdev.c 项目: Pating/qemu
static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
{
    IDEDevice *d = IDE_DEVICE(obj);
    int32_t boot_index;
    Error *local_err = NULL;

    visit_type_int32(v, name, &boot_index, &local_err);
    if (local_err) {
        goto out;
    }
    /* check whether bootindex is present in fw_boot_order list  */
    check_boot_index(boot_index, &local_err);
    if (local_err) {
        goto out;
    }
    /* change bootindex to a new one */
    d->conf.bootindex = boot_index;

    if (d->unit != -1) {
        add_boot_device_path(d->conf.bootindex, &d->qdev,
                             d->unit ? "/disk@1" : "/disk@0");
    }
out:
    error_propagate(errp, local_err);
}
示例#3
0
文件: qdev.c 项目: Pating/qemu
static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
{
    IDEDevice *d = IDE_DEVICE(obj);

    visit_type_int32(v, name, &d->conf.bootindex, errp);
}
示例#4
0
static void ide_detect_devices(UWORD ifnum)
{
    volatile struct IDE *interface = ide_interface + ifnum;
    struct IFINFO *info = ifinfo + ifnum;
    UBYTE status;
    UWORD signature;
    int i;

    MAYBE_UNUSED(interface);

    IDE_WRITE_CONTROL(IDE_CONTROL_nIEN);    /* no interrupts please */

    /* initial check for devices */
    for (i = 0; i < 2; i++) {
        IDE_WRITE_HEAD(IDE_DEVICE(i));
        DELAY_400NS;
        IDE_WRITE_SECTOR_NUMBER_SECTOR_COUNT(0xaa,0x55);
        IDE_WRITE_SECTOR_NUMBER_SECTOR_COUNT(0x55,0xaa);
        IDE_WRITE_SECTOR_NUMBER_SECTOR_COUNT(0xaa,0x55);
        if (IDE_READ_SECTOR_NUMBER_SECTOR_COUNT() == 0xaa55) {
            info->dev[i].type = DEVTYPE_UNKNOWN;
            KDEBUG(("IDE i/f %d device %d detected\n",ifnum,i));
        } else
            info->dev[i].type = DEVTYPE_NONE;
        info->dev[i].options = 0;
        info->dev[i].spi = 0;   /* changed if using READ/WRITE MULTIPLE */
    }

    /* recheck after soft reset, also detect ata/atapi */
    IDE_WRITE_HEAD(IDE_DEVICE(0));
    DELAY_400NS;
    ide_reset(ifnum);

    for (i = 0; i < 2; i++) {
        IDE_WRITE_HEAD(IDE_DEVICE(i));
        DELAY_400NS;
        if (IDE_READ_SECTOR_NUMBER_SECTOR_COUNT() == 0x0101) {
            status = IDE_READ_STATUS();
            signature = IDE_READ_CYLINDER_HIGH_CYLINDER_LOW();
            info->dev[i].type = ide_decode_type(status,signature);
        }
    }

    for (i = 0; i < 2; i++)
        KDEBUG(("IDE i/f %d device %d is type %d\n",ifnum,i,info->dev[i].type));
}
示例#5
0
/*
 * set a special value in the sector number/count registers of
 * device 0 in the specified interface
 */
static void set_interface_magic(WORD ifnum)
{
    volatile struct IDE *interface = ide_interface + ifnum;
    UBYTE secnum = SECNUM_MAGIC + ifnum;
    UBYTE seccnt = SECCNT_MAGIC + ifnum;

    IDE_WRITE_CONTROL(IDE_CONTROL_nIEN);/* no interrupts please */
    IDE_WRITE_HEAD(IDE_DEVICE(0));
    DELAY_400NS;
    IDE_WRITE_SECTOR_NUMBER_SECTOR_COUNT(secnum,seccnt);
}
示例#6
0
/*
 * select device in IDE registers
 */
static int ide_select_device(volatile struct IDE *interface,UWORD dev)
{
    KDEBUG(("ide_select_device(0x%08lx, %u)\n", (ULONG)interface, dev));

    if (wait_for_not_BSY_not_DRQ(interface,SHORT_TIMEOUT))
        return ERR;

    IDE_WRITE_HEAD(IDE_DEVICE(dev));

    if (wait_for_not_BSY_not_DRQ(interface,SHORT_TIMEOUT))
        return ERR;

    return E_OK;
}
示例#7
0
文件: qdev.c 项目: Pating/qemu
static int ide_qdev_init(DeviceState *qdev)
{
    IDEDevice *dev = IDE_DEVICE(qdev);
    IDEDeviceClass *dc = IDE_DEVICE_GET_CLASS(dev);
    IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus);

    if (!dev->conf.blk) {
        error_report("No drive specified");
        goto err;
    }
    if (dev->unit == -1) {
        dev->unit = bus->master ? 1 : 0;
    }

    if (dev->unit >= bus->max_units) {
        error_report("Can't create IDE unit %d, bus supports only %d units",
                     dev->unit, bus->max_units);
        goto err;
    }

    switch (dev->unit) {
    case 0:
        if (bus->master) {
            error_report("IDE unit %d is in use", dev->unit);
            goto err;
        }
        bus->master = dev;
        break;
    case 1:
        if (bus->slave) {
            error_report("IDE unit %d is in use", dev->unit);
            goto err;
        }
        bus->slave = dev;
        break;
    default:
        error_report("Invalid IDE unit %d", dev->unit);
        goto err;
    }
    return dc->init(dev);

err:
    return -1;
}