Lines Matching defs:ac
143 static int amr_enquiry_mapcmd(struct amr_command *ac, uint32_t data_size);
144 static void amr_enquiry_unmapcmd(struct amr_command *ac);
145 static int amr_mapcmd(struct amr_command *ac, int (*callback)(), caddr_t arg);
146 static void amr_unmapcmd(struct amr_command *ac);
156 static int amr_poll_command(struct amr_command *ac);
716 register struct amr_command *ac;
738 sc = %p, pkt = %p, index = %d, ac = %p",
744 ac = softs->busycmd[i];
745 ac->ac_next = NULL;
756 pkt = ac->pkt;
929 struct amr_command ac;
934 bzero(&ac, sizeof (struct amr_command));
935 ac.ac_softs = softs;
938 ac.ac_flags |= AMR_CMD_DATAOUT;
941 ac.mailbox.mb_command = cmd;
942 ac.mailbox.mb_cmdsub = cmdsub;
943 ac.mailbox.mb_cmdqual = cmdqual;
945 if (amr_enquiry_mapcmd(&ac, bufsize) != DDI_SUCCESS)
948 if (amr_poll_command(&ac) || ac.ac_status != 0) {
950 amr_enquiry_unmapcmd(&ac);
957 bcopy(ac.ac_data, result, bufsize);
959 amr_enquiry_unmapcmd(&ac);
969 struct amr_command ac;
972 bzero(&ac, sizeof (struct amr_command));
973 ac.ac_softs = softs;
975 ac.ac_flags |= AMR_CMD_DATAOUT;
978 ac.mailbox.mb_command = AMR_CMD_FLUSH;
981 if (error = amr_poll_command(&ac)) {
994 amr_poll_command(struct amr_command *ac)
996 struct amr_softs *softs = ac->ac_softs;
1000 (void *)&ac->mailbox,
1013 if ((ac->mailbox.mb_command == AMR_CMD_LREAD) ||
1014 (ac->mailbox.mb_command == AMR_CMD_LWRITE)) {
1015 bcopy(ac->sgtable,
1023 ac->mailbox.mb_physaddr =
1027 bcopy(&ac->mailbox, (void *)softs->mailbox, AMR_MBOX_CMDSIZE);
1052 ac->ac_status = softs->mailbox->mb_status;
1073 return (ac->ac_status != AMR_STATUS_SUCCESS);
1172 * Map/unmap (ac)'s data in the controller's addressable space as required.
1177 amr_setup_dmamap(struct amr_command *ac, ddi_dma_cookie_t *buffer_dma_cookiep,
1183 sg = ac->sgtable;
1187 ac->mailbox.mb_nsgelem = (uint8_t)nsegments;
1198 if ((ac->current_cookie + i + 1) != ac->num_of_cookie)
1199 ddi_dma_nextcookie(ac->buffer_dma_handle,
1203 ac->transfer_size = size;
1204 ac->data_transfered += size;
1212 amr_enquiry_mapcmd(struct amr_command *ac, uint32_t data_size)
1214 struct amr_softs *softs = ac->ac_softs;
1218 AMRDB_PRINT((CE_NOTE, "Amr_enquiry_mapcmd called, ac=%p, flags=%x",
1219 (void *)ac, ac->ac_flags));
1221 if (ac->ac_flags & AMR_CMD_DATAOUT) {
1232 &ac->buffer_dma_handle) !=
1240 if (ddi_dma_mem_alloc(ac->buffer_dma_handle,
1246 (caddr_t *)&ac->ac_data,
1248 &ac->buffer_acc_handle) !=
1257 ac->buffer_dma_handle,
1258 NULL, ac->ac_data, len, dma_flags,
1259 DDI_DMA_SLEEP, NULL, &ac->buffer_dma_cookie,
1260 &ac->num_of_cookie)) != DDI_DMA_MAPPED) {
1267 ac->ac_dataphys = (&ac->buffer_dma_cookie)->dmac_address;
1269 ((struct amr_mailbox *)&(ac->mailbox))->mb_param = 0;
1270 ac->mailbox.mb_nsgelem = 0;
1271 ac->mailbox.mb_physaddr = ac->ac_dataphys;
1273 ac->ac_flags |= AMR_CMD_MAPPED;
1278 if (ac->num_of_cookie)
1279 (void) ddi_dma_unbind_handle(ac->buffer_dma_handle);
1280 if (ac->buffer_acc_handle) {
1281 ddi_dma_mem_free(&ac->buffer_acc_handle);
1282 ac->buffer_acc_handle = NULL;
1284 if (ac->buffer_dma_handle) {
1285 (void) ddi_dma_free_handle(&ac->buffer_dma_handle);
1286 ac->buffer_dma_handle = NULL;
1296 amr_enquiry_unmapcmd(struct amr_command *ac)
1298 AMRDB_PRINT((CE_NOTE, "Amr_enquiry_unmapcmd called, ac=%p",
1299 (void *)ac));
1302 if ((ac->ac_flags & AMR_CMD_MAPPED) && ac->ac_data) {
1303 if (ac->buffer_dma_handle)
1305 ac->buffer_dma_handle);
1306 if (ac->buffer_acc_handle) {
1307 ddi_dma_mem_free(&ac->buffer_acc_handle);
1308 ac->buffer_acc_handle = NULL;
1310 if (ac->buffer_dma_handle) {
1312 &ac->buffer_dma_handle);
1313 ac->buffer_dma_handle = NULL;
1317 ac->ac_flags &= ~AMR_CMD_MAPPED;
1324 amr_mapcmd(struct amr_command *ac, int (*callback)(), caddr_t arg)
1332 AMRDB_PRINT((CE_NOTE, "Amr_mapcmd called, ac=%p, flags=%x",
1333 (void *)ac, ac->ac_flags));
1335 if (ac->ac_flags & AMR_CMD_DATAOUT) {
1341 if (ac->ac_flags & AMR_CMD_PKT_CONSISTENT) {
1344 if (ac->ac_flags & AMR_CMD_PKT_DMA_PARTIAL) {
1348 if ((!(ac->ac_flags & AMR_CMD_MAPPED)) && (ac->ac_buf == NULL)) {
1349 ac->ac_flags |= AMR_CMD_MAPPED;
1356 if (!(ac->ac_flags & AMR_CMD_MAPPED)) {
1358 error = ddi_dma_buf_bind_handle(ac->buffer_dma_handle,
1359 ac->ac_buf,
1363 &ac->buffer_dma_cookie,
1364 &ac->num_of_cookie);
1367 if (ddi_dma_numwin(ac->buffer_dma_handle,
1368 &ac->num_of_win) == DDI_FAILURE) {
1373 ac->buffer_dma_handle);
1375 &ac->buffer_dma_handle);
1376 ac->buffer_dma_handle = NULL;
1379 ac->current_win = 0;
1383 ac->num_of_win = 1;
1384 ac->current_win = 0;
1392 &ac->buffer_dma_handle);
1393 ac->buffer_dma_handle = NULL;
1397 ac->current_cookie = 0;
1399 ac->ac_flags |= AMR_CMD_MAPPED;
1400 } else if (ac->current_cookie == AMR_LAST_COOKIE_TAG) {
1402 ac->current_win++;
1403 (void) ddi_dma_getwin(ac->buffer_dma_handle,
1404 ac->current_win, &off, &len,
1405 &ac->buffer_dma_cookie,
1406 &ac->num_of_cookie);
1407 ac->current_cookie = 0;
1410 if ((ac->num_of_cookie - ac->current_cookie) > AMR_NSEG) {
1411 amr_setup_dmamap(ac, &ac->buffer_dma_cookie, AMR_NSEG);
1412 ac->current_cookie += AMR_NSEG;
1414 amr_setup_dmamap(ac, &ac->buffer_dma_cookie,
1415 ac->num_of_cookie - ac->current_cookie);
1416 ac->current_cookie = AMR_LAST_COOKIE_TAG;
1426 amr_unmapcmd(struct amr_command *ac)
1428 AMRDB_PRINT((CE_NOTE, "Amr_unmapcmd called, ac=%p",
1429 (void *)ac));
1432 if ((ac->ac_flags & AMR_CMD_MAPPED) &&
1433 ac->ac_buf && ac->buffer_dma_handle)
1434 (void) ddi_dma_unbind_handle(ac->buffer_dma_handle);
1436 ac->ac_flags &= ~AMR_CMD_MAPPED;
1501 struct amr_command *ac;
1515 ac = (struct amr_command *)pkt->pkt_ha_private;
1516 bp = ac->ac_buf;
1530 (void) amr_poll_command(ac);
1541 ac->ac_prev = NULL;
1542 ac->ac_next = NULL;
1543 softs->waiting_q_head = ac;
1544 softs->waiting_q_tail = ac;
1546 ac->ac_next = NULL;
1547 ac->ac_prev = softs->waiting_q_tail;
1548 softs->waiting_q_tail->ac_next = ac;
1549 softs->waiting_q_tail = ac;
1587 amr_unmapcmd(ac);
1614 amr_unmapcmd(ac);
1633 amr_unmapcmd(ac);
1655 amr_unmapcmd(ac);
1674 amr_unmapcmd(ac);
1726 * problem and continue get ac
1847 struct amr_command *ac;
1876 ac = (struct amr_command *)pkt->pkt_ha_private;
1877 ac->ac_buf = bp;
1878 ac->cmdlen = cmdlen;
1879 ac->ac_softs = softs;
1880 ac->pkt = pkt;
1881 ac->ac_flags &= ~AMR_CMD_GOT_SLOT;
1882 ac->ac_flags &= ~AMR_CMD_BUSY;
1890 &ac->buffer_dma_handle) != DDI_SUCCESS) {
1903 ac = (struct amr_command *)pkt->pkt_ha_private;
1906 ASSERT(ac != NULL);
1909 ac->ac_flags |= AMR_CMD_DATAOUT;
1911 ac->ac_flags |= AMR_CMD_DATAIN;
1915 ac->ac_flags |= AMR_CMD_PKT_CONSISTENT;
1919 ac->ac_flags |= AMR_CMD_PKT_DMA_PARTIAL;
1922 if (amr_mapcmd(ac, callback, arg) != DDI_SUCCESS) {
1927 pkt->pkt_resid = bp->b_bcount - ac->data_transfered;
1932 ac->data_transfered));
1942 struct amr_command *ac = (struct amr_command *)pkt->pkt_ha_private;
1944 amr_unmapcmd(ac);
1946 if (ac->buffer_dma_handle) {
1947 (void) ddi_dma_free_handle(&ac->buffer_dma_handle);
1948 ac->buffer_dma_handle = NULL;
1959 struct amr_command *ac = (struct amr_command *)pkt->pkt_ha_private;
1961 if (ac->buffer_dma_handle) {
1962 (void) ddi_dma_sync(ac->buffer_dma_handle, 0, 0,
1963 (ac->ac_flags & AMR_CMD_DATAIN) ?
1972 struct amr_command *ac = (struct amr_command *)pkt->pkt_ha_private;
1974 if (ac->ac_flags & AMR_CMD_MAPPED) {
1975 (void) ddi_dma_unbind_handle(ac->buffer_dma_handle);
1976 (void) ddi_dma_free_handle(&ac->buffer_dma_handle);
1977 ac->buffer_dma_handle = NULL;
1978 ac->ac_flags &= ~AMR_CMD_MAPPED;
1987 struct amr_command *ac = (struct amr_command *)pkt->pkt_ha_private;
1991 if (ac->ac_flags & AMR_CMD_DATAOUT) {
1997 ac->mailbox.mb_command = cmd;
1998 ac->mailbox.mb_blkcount =
1999 (ac->transfer_size + AMR_BLKSIZE - 1)/AMR_BLKSIZE;
2000 ac->mailbox.mb_lba = (ac->cmdlen == 10) ?
2002 ac->mailbox.mb_drive = (uint8_t)target;
2079 struct amr_command *ac;
2087 while ((ac = softs->waiting_q_head) != NULL) {
2104 ac->ac_timestamp = ddi_get_time();
2106 if (!(ac->ac_flags & AMR_CMD_GOT_SLOT)) {
2108 softs->busycmd[slot] = ac;
2109 ac->ac_slot = slot;
2112 bcopy(ac->sgtable,
2121 ac->mailbox.mb_physaddr =
2126 softs->waiting_q_head = ac->ac_next;
2128 ac->mailbox.mb_ident = ac->ac_slot + 1;
2129 ac->mailbox.mb_busy = 1;
2130 ac->ac_next = NULL;
2131 ac->ac_prev = NULL;
2132 ac->ac_flags |= AMR_CMD_GOT_SLOT;
2143 * problem and continue get ac
2150 bcopy(&ac->mailbox, (void *)softs->mailbox,
2152 ac->ac_flags |= AMR_CMD_BUSY;
2161 * current ac is submitted
2162 * so quit 'for-loop' to get next ac
2185 struct amr_command *ac, *head, *tail;
2224 ac = softs->busycmd[idx];
2226 if (ac != NULL) {
2234 ac->ac_flags &= ~AMR_CMD_BUSY;
2235 ac->ac_flags &= ~AMR_CMD_GOT_SLOT;
2236 ac->ac_status = mbox->mb_status;
2240 tail->ac_next = ac;
2241 tail = ac;
2244 tail = head = ac;
2245 ac->ac_next = NULL;
2249 "ac in mailbox is NULL!"));
2273 register struct amr_command *ac, *localhead;
2278 ac = localhead;
2279 localhead = ac->ac_next;
2280 ac->ac_next = NULL;
2282 pkt = ac->pkt;
2285 if (ac->ac_status == AMR_STATUS_SUCCESS) {