Lines Matching refs:mailboxp

218 static int		mboxsc_add_mailbox(mboxsc_mbox_t *mailboxp);
219 static void mboxsc_close_mailbox(mboxsc_mbox_t *mailboxp);
220 static void mboxsc_hashinsert_mailbox(mboxsc_mbox_t *mailboxp);
238 static void mboxsc_reference_mailbox(mboxsc_mbox_t *mailboxp);
239 static void mboxsc_dereference_mailbox(mboxsc_mbox_t *mailboxp);
337 mboxsc_mbox_t *mailboxp;
353 mailboxp = mboxsc_hash_table[i];
354 mboxsc_close_mailbox(mailboxp);
394 mboxsc_mbox_t *mailboxp;
416 mailboxp = (mboxsc_mbox_t *)kmem_zalloc(sizeof (mboxsc_mbox_t),
419 sizeof (mboxsc_mbox_t), (void *)mailboxp);
420 mailboxp->mbox_key = key;
421 mailboxp->mbox_direction = direction;
422 mailboxp->mbox_callback = event_handler;
429 error = mboxsc_add_mailbox(mailboxp);
434 (void *)mailboxp, sizeof (mboxsc_mbox_t));
435 kmem_free(mailboxp, sizeof (mboxsc_mbox_t));
451 mboxsc_mbox_t *mailboxp;
460 mailboxp = mboxsc_hashfind_mailbox_by_key(key);
461 if (mailboxp == NULL) {
464 while (mailboxp->mbox_refcount != 0) {
467 mboxsc_close_mailbox(mailboxp);
495 mboxsc_mbox_t *mailboxp;
553 mailboxp = mboxsc_hashfind_mailbox_by_key(key);
555 if (mailboxp == NULL) {
557 } else if ((mailboxp->mbox_direction != MBOXSC_MBOX_OUT) ||
558 (length + MBOXSC_PROTOCOL_SIZE > mailboxp->mbox_length) ||
559 ((header.msg_transid == mailboxp->mbox_header.msg_transid) &&
560 ((type & mailboxp->mbox_header.msg_type) != MBOXSC_MSG_REPLY) &&
580 mboxsc_generate_transid(mailboxp->mbox_header.msg_transid);
594 mboxsc_reference_mailbox(mailboxp);
596 while ((mailboxp->mbox_state & STATE_WRITING) &&
598 remainder = cv_timedwait_sig(&(mailboxp->mbox_wait),
614 mboxsc_dereference_mailbox(mailboxp);
626 bcopy(&header, &(mailboxp->mbox_header), MBOXSC_MSGHDR_SIZE);
631 mailboxp->mbox_state |= STATE_WRITING;
699 mailboxp->mbox_state &= ~STATE_WRITING;
700 cv_broadcast(&(mailboxp->mbox_wait));
701 mboxsc_dereference_mailbox(mailboxp);
774 mailboxp->mbox_state &= ~STATE_WRITING;
775 cv_broadcast(&(mailboxp->mbox_wait));
776 mboxsc_dereference_mailbox(mailboxp);
807 mboxsc_mbox_t *mailboxp;
860 mailboxp = mboxsc_hashfind_mailbox_by_key(key);
861 if (mailboxp == NULL) {
863 } else if (mailboxp->mbox_direction != MBOXSC_MBOX_IN) {
878 mboxsc_reference_mailbox(mailboxp);
900 while (!(mailboxp->mbox_state & STATE_HDRVALID) ||
901 (mailboxp->mbox_state & STATE_READING) ||
902 !MSG_TYPE_MATCHES(*typep, &(mailboxp->mbox_header)) ||
903 !MSG_CMD_MATCHES(*cmdp, &(mailboxp->mbox_header)) ||
904 !MSG_TRANSID_MATCHES(*transidp, &(mailboxp->mbox_header))) {
905 remainder = cv_timedwait_sig(&(mailboxp->mbox_wait),
914 mboxsc_dereference_mailbox(mailboxp);
927 if (mailboxp->mbox_header.msg_version > MBOXSC_PROTOCOL_VERSION) {
930 mailboxp->mbox_header.msg_version);
931 mailboxp->mbox_state &= ~STATE_HDRVALID;
952 mailboxp->mbox_state &= ~STATE_HDRVALID;
966 datalen = mailboxp->mbox_header.msg_length - MBOXSC_MSGHDR_SIZE;
977 cv_broadcast(&(mailboxp->mbox_wait));
978 mboxsc_dereference_mailbox(mailboxp);
990 bcopy(&(mailboxp->mbox_header), &header, MBOXSC_MSGHDR_SIZE);
991 mailboxp->mbox_state |= STATE_READING;
1010 mailboxp->mbox_state &= ~STATE_READING;
1011 if (mailboxp->mbox_state & STATE_HDRVALID) {
1012 cv_broadcast(&(mailboxp->mbox_wait));
1014 mboxsc_dereference_mailbox(mailboxp);
1037 if (!(mailboxp->mbox_state & STATE_HDRVALID)) {
1043 mailboxp->mbox_state &= ~STATE_HDRVALID;
1051 mailboxp->mbox_state &= ~STATE_READING;
1098 mailboxp->mbox_state &= ~STATE_READING;
1099 if (mailboxp->mbox_state & STATE_HDRVALID) {
1100 cv_broadcast(&(mailboxp->mbox_wait));
1102 mboxsc_dereference_mailbox(mailboxp);
1123 mailboxp->mbox_state &= ~STATE_READING;
1125 (mailboxp->mbox_header.msg_transid != read_transid)) {
1126 mailboxp->mbox_state &= ~STATE_HDRVALID;
1127 } else if (mailboxp->mbox_state & STATE_HDRVALID) {
1128 cv_broadcast(&(mailboxp->mbox_wait));
1161 mboxsc_dereference_mailbox(mailboxp);
1162 mailboxp->mbox_state &= ~STATE_READING;
1163 if (mailboxp->mbox_state & STATE_HDRVALID) {
1164 cv_broadcast(&(mailboxp->mbox_wait));
1177 if (bcmp(&(mailboxp->mbox_header), &header, MBOXSC_MSGHDR_SIZE) == 0) {
1178 mailboxp->mbox_state &= ~STATE_HDRVALID;
1179 } else if (mailboxp->mbox_state & STATE_HDRVALID) {
1180 cv_broadcast(&(mailboxp->mbox_wait));
1183 mboxsc_dereference_mailbox(mailboxp);
1184 mailboxp->mbox_state &= ~STATE_READING;
1210 mboxsc_mbox_t *mailboxp;
1218 mailboxp = mboxsc_hashfind_mailbox_by_key(key);
1219 if (mailboxp == NULL) {
1263 *(uint32_t *)arg = mailboxp->mbox_length -
1339 mboxsc_mbox_t *mailboxp;
1345 mailboxp = mboxsc_hashfind_mailbox_by_key(key);
1351 ASSERT(mailboxp != NULL);
1352 ASSERT(mailboxp->mbox_direction == MBOXSC_MBOX_IN);
1359 mailboxp->mbox_state &= ~STATE_HDRVALID;
1361 (caddr_t)&(mailboxp->mbox_header));
1368 if (mailboxp->mbox_header.msg_version > MBOXSC_PROTOCOL_VERSION) {
1372 mailboxp->mbox_header.msg_version);
1406 mailboxp->mbox_state |= STATE_HDRVALID;
1407 if (IS_UNSOLICITED_TYPE(mailboxp->mbox_header.msg_type) &&
1408 (mailboxp->mbox_callback != NULL)) {
1409 mboxsc_reference_mailbox(mailboxp);
1411 (*(mailboxp->mbox_callback))();
1413 mboxsc_dereference_mailbox(mailboxp);
1415 cv_broadcast(&(mailboxp->mbox_wait));
1461 mboxsc_add_mailbox(mboxsc_mbox_t *mailboxp)
1464 uint32_t key = mailboxp->mbox_key;
1467 DPRINTF1(DBG_ARGS, DBGACT_DEFAULT, "mailboxp = %p\n", (void *)mailboxp);
1489 error = iosram_ctrl(key, IOSRAM_CMD_CHUNKLEN, &(mailboxp->mbox_length));
1491 if ((error == 0) && (mailboxp->mbox_length < MBOXSC_PROTOCOL_SIZE)) {
1495 if ((error == 0) && (mailboxp->mbox_direction == MBOXSC_MBOX_IN)) {
1513 mailboxp->mbox_state = STATE_IDLE;
1514 mailboxp->mbox_refcount = 0;
1515 cv_init(&(mailboxp->mbox_wait), NULL, CV_DRIVER, NULL);
1516 mboxsc_hashinsert_mailbox(mailboxp);
1531 mboxsc_close_mailbox(mboxsc_mbox_t *mailboxp)
1534 uint32_t key = mailboxp->mbox_key;
1537 DPRINTF1(DBG_ARGS, DBGACT_DEFAULT, "mailboxp = %p\n", (void *)mailboxp);
1547 if (mailboxp->mbox_direction == MBOXSC_MBOX_IN) {
1560 cv_destroy(&(mailboxp->mbox_wait));
1562 (void *)mailboxp, sizeof (mboxsc_mbox_t));
1563 kmem_free(mailboxp, sizeof (mboxsc_mbox_t));
1577 mboxsc_hashinsert_mailbox(mboxsc_mbox_t *mailboxp)
1583 DPRINTF1(DBG_ARGS, DBGACT_DEFAULT, "mailboxp = %p\n", (void *)mailboxp);
1590 hash = HASH_KEY(mailboxp->mbox_key);
1591 mailboxp->mbox_hash_next = mboxsc_hash_table[hash];
1592 mboxsc_hash_table[hash] = mailboxp;
1609 mboxsc_mbox_t *mailboxp;
1621 mailboxp = mboxsc_hash_table[hash];
1622 while (mailboxp != NULL) {
1623 if (mailboxp->mbox_key == key) {
1626 mailboxp = mailboxp->mbox_hash_next;
1630 "mboxsc_hashfind_mailbox_by_key ret: %p\n", (void *)mailboxp);
1631 return (mailboxp);
1646 mboxsc_mbox_t *mailboxp;
1659 mailboxp = mboxsc_hash_table[hash];
1661 while (mailboxp != NULL) {
1662 if (mailboxp->mbox_key == key) {
1665 last = mailboxp;
1666 mailboxp = mailboxp->mbox_hash_next;
1672 if (mailboxp != NULL) {
1674 mboxsc_hash_table[hash] = mailboxp->mbox_hash_next;
1676 last->mbox_hash_next = mailboxp->mbox_hash_next;
1679 mailboxp->mbox_hash_next = NULL;
1683 "mboxsc_hashremove_mailbox_by_key ret: %p\n", (void *)mailboxp);
1684 return (mailboxp);
2240 mboxsc_reference_mailbox(mboxsc_mbox_t *mailboxp)
2243 DPRINTF1(DBG_ARGS, DBGACT_DEFAULT, "mailboxp = 0x%p\n",
2244 (void *)mailboxp);
2248 mailboxp->mbox_refcount++;
2261 mboxsc_dereference_mailbox(mboxsc_mbox_t *mailboxp)
2265 DPRINTF1(DBG_ARGS, DBGACT_DEFAULT, "mailboxp = 0x%p\n",
2266 (void *)mailboxp);
2270 mailboxp->mbox_refcount--;
2271 if (mailboxp->mbox_refcount == 0) {
2292 static void print_mailbox(mboxsc_mbox_t *mailboxp);
2376 mboxsc_mbox_t *mailboxp;
2385 for (mailboxp = mboxsc_hash_table[i]; mailboxp != NULL;
2386 mailboxp = mailboxp->mbox_hash_next) {
2388 " key: 0x%08x, dir: %d\n", mailboxp->mbox_key,
2389 mailboxp->mbox_direction);
2402 mboxsc_mbox_t *mailboxp;
2409 mailboxp = mboxsc_hashfind_mailbox_by_key(key);
2410 if (mailboxp != NULL) {
2411 print_mailbox(mailboxp);
2428 print_mailbox(mboxsc_mbox_t *mailboxp)
2431 DPRINTF1(DBG_ARGS, DBGACT_DEFAULT, "mailboxp = %p\n",
2432 (void *)mailboxp);
2433 if (mailboxp->mbox_direction == MBOXSC_MBOX_IN) {
2436 mailboxp->mbox_key, mailboxp->mbox_direction,
2437 (void *)mailboxp->mbox_callback);
2440 (int)mailboxp->mbox_key, mailboxp->mbox_direction);
2444 mailboxp->mbox_length, mailboxp->mbox_refcount,
2445 mailboxp->mbox_state);
2448 (void *)&mailboxp->mbox_wait, (void *)mailboxp->mbox_hash_next);
2449 if (mailboxp->mbox_direction == MBOXSC_MBOX_IN) {
2452 mailboxp->mbox_header.msg_type,
2453 mailboxp->mbox_header.msg_cmd,
2454 mailboxp->mbox_header.msg_length);
2456 mailboxp->mbox_header.msg_transid);