/* process the command queue into a maple command block *terminatingcommandhasbit32offirstlongsetto0
*/ staticvoid maple_build_block(struct mapleq *mq)
{ int port, unit, from, to, len; unsignedlong *lsendbuf = mq->sendbuf;
port = mq->dev->port & 3;
unit = mq->dev->unit;
len = mq->length;
from = port << 6;
to = (port << 6) | (unit > 0 ? (1 << (unit - 1)) & 0x1f : 0x20);
list_for_each_entry_safe(mq, nmq, &maple_waitq, list) {
maple_build_block(mq);
list_del_init(&mq->list);
list_add_tail(&mq->list, &maple_sentq); if (maple_packets++ > MAPLE_MAXPACKETS) break;
}
mutex_unlock(&maple_wlist_lock); if (maple_packets > 0) { for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++)
__flush_purge_region(maple_sendbuf + i * PAGE_SIZE,
PAGE_SIZE);
}
finish:
maple_dma_reset();
}
/* check if there is a driver registered likely to match this device */ staticint maple_check_matching_driver(struct device_driver *driver, void *devptr)
{ struct maple_driver *maple_drv; struct maple_device *mdev;
/* process initial MAPLE_COMMAND_DEVINFO for each device or port */ staticvoid maple_attach_driver(struct maple_device *mdev)
{ char *p, *recvbuf; unsignedlong function; int matched, error;
recvbuf = mdev->mq->recvbuf->buf; /* copy the data as individual elements in
* case of memory optimisation */
memcpy(&mdev->devinfo.function, recvbuf + 4, 4);
memcpy(&mdev->devinfo.function_data[0], recvbuf + 8, 12);
memcpy(&mdev->devinfo.area_code, recvbuf + 20, 1);
memcpy(&mdev->devinfo.connector_direction, recvbuf + 21, 1);
memcpy(&mdev->devinfo.product_name[0], recvbuf + 22, 30);
memcpy(&mdev->devinfo.standby_power, recvbuf + 112, 2);
memcpy(&mdev->devinfo.max_power, recvbuf + 114, 2);
memcpy(mdev->product_name, mdev->devinfo.product_name, 30);
mdev->product_name[30] = '\0';
memcpy(mdev->product_licence, mdev->devinfo.product_licence, 60);
mdev->product_licence[60] = '\0';
for (p = mdev->product_name + 29; mdev->product_name <= p; p--) if (*p == ' ')
*p = '\0'; else break; for (p = mdev->product_licence + 59; mdev->product_licence <= p; p--) if (*p == ' ')
*p = '\0'; else break;
function = be32_to_cpu(mdev->devinfo.function);
dev_info(&mdev->dev, "detected %s: function 0x%lX: at (%d, %d)\n",
mdev->product_name, function, mdev->port, mdev->unit);
if (function > 0x200) { /* Do this silently - as not a real device */
function = 0;
mdev->driver = &maple_unsupported_device;
dev_set_name(&mdev->dev, "%d:0.port", mdev->port);
} else {
matched =
bus_for_each_drv(&maple_bus_type, NULL, mdev,
maple_check_matching_driver);
if (matched == 0) { /* Driver does not exist yet */
dev_info(&mdev->dev, "no driver found\n");
mdev->driver = &maple_unsupported_device;
}
dev_set_name(&mdev->dev, "%d:0%d.%lX", mdev->port,
mdev->unit, function);
}
case MAPLE_RESPONSE_DEVINFO:
maple_response_devinfo(mdev, recvbuf);
atomic_set(&mdev->busy, 0); break;
case MAPLE_RESPONSE_DATATRF: if (mdev->callback)
mdev->callback(mq);
atomic_set(&mdev->busy, 0);
wake_up(&mdev->maple_wait); break;
case MAPLE_RESPONSE_FILEERR:
maple_response_fileerr(mdev, recvbuf);
atomic_set(&mdev->busy, 0);
wake_up(&mdev->maple_wait); break;
case MAPLE_RESPONSE_AGAIN: case MAPLE_RESPONSE_BADCMD: case MAPLE_RESPONSE_BADFUNC:
dev_warn(&mdev->dev, "non-fatal error" " 0x%X at (%d, %d)\n", code,
mdev->port, mdev->unit);
atomic_set(&mdev->busy, 0); break;
case MAPLE_RESPONSE_ALLINFO:
dev_notice(&mdev->dev, "extended" " device information request for (%d, %d)" " but call is not supported\n", mdev->port,
mdev->unit);
atomic_set(&mdev->busy, 0); break;
case MAPLE_RESPONSE_OK:
atomic_set(&mdev->busy, 0);
wake_up(&mdev->maple_wait); break;
default: break;
}
} /* if scanning is 1 then we have subdevices to check */ if (scanning == 1) {
maple_send();
scanning = 2;
} else
scanning = 0; /*check if we have actually tested all ports yet */ if (!fullscan)
maple_port_rescan(); /* mark that we have been through the first scan */
started = 1;
}
maple_send();
}
static irqreturn_t maple_dma_interrupt(int irq, void *dev_id)
{ /* Load everything into the bottom half */
schedule_work(&maple_dma_process); return IRQ_HANDLED;
}
staticint __init maple_bus_init(void)
{ int retval, i; struct maple_device *mdev[MAPLE_PORTS];
__raw_writel(0, MAPLE_ENABLE);
retval = device_register(&maple_bus); if (retval) goto cleanup;
retval = bus_register(&maple_bus_type); if (retval) goto cleanup_device;
retval = driver_register(&maple_unsupported_device.drv); if (retval) goto cleanup_bus;
/* allocate memory for maple bus dma */
retval = maple_get_dma_buffer(); if (retval) {
dev_err(&maple_bus, "failed to allocate DMA buffers\n"); goto cleanup_basic;
}
/* set up DMA interrupt handler */
retval = maple_set_dma_interrupt_handler(); if (retval) {
dev_err(&maple_bus, "bus failed to grab maple " "DMA IRQ\n"); goto cleanup_dma;
}
/* set up VBLANK interrupt handler */
retval = maple_set_vblank_interrupt_handler(); if (retval) {
dev_err(&maple_bus, "bus failed to grab VBLANK IRQ\n"); goto cleanup_irq;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.