Lines Matching refs:tpm

125 static int itpm_command(tpm_state_t *tpm, uint8_t *buf, size_t bufsiz);
126 static int tpm_get_timeouts(tpm_state_t *tpm);
127 static int tpm_get_duration(tpm_state_t *tpm);
128 static int tpm_get_version(tpm_state_t *tpm);
129 static int tpm_continue_selftest(tpm_state_t *tpm);
302 #define TPM_EXCLUSIVE_LOCK(tpm) { \ argument
303 mutex_enter(&tpm->pm_mutex); \
304 while (tpm->suspended) \
305 cv_wait(&tpm->suspend_cv, &tpm->pm_mutex); \
306 mutex_exit(&tpm->pm_mutex); }
320 tpm_get8(tpm_state_t *tpm, unsigned long offset) in tpm_get8() argument
324 ASSERT(tpm != NULL); in tpm_get8()
325 (void) hcall_tpm_get(tpm->locality, offset, sizeof (uint8_t), &value); in tpm_get8()
330 tpm_get32(tpm_state_t *tpm, unsigned long offset) in tpm_get32() argument
334 ASSERT(tpm != NULL); in tpm_get32()
335 (void) hcall_tpm_get(tpm->locality, offset, sizeof (uint32_t), &value); in tpm_get32()
340 tpm_put8(tpm_state_t *tpm, unsigned long offset, uint8_t value) in tpm_put8() argument
342 ASSERT(tpm != NULL); in tpm_put8()
343 (void) hcall_tpm_put(tpm->locality, offset, sizeof (uint8_t), value); in tpm_put8()
349 tpm_get8(tpm_state_t *tpm, unsigned long offset) in tpm_get8() argument
351 ASSERT(tpm != NULL); in tpm_get8()
353 return (ddi_get8(tpm->handle, in tpm_get8()
354 (uint8_t *)(TPM_LOCALITY_OFFSET(tpm->locality) | in tpm_get8()
355 (uintptr_t)tpm->addr + offset))); in tpm_get8()
359 tpm_get32(tpm_state_t *tpm, unsigned long offset) in tpm_get32() argument
361 ASSERT(tpm != NULL); in tpm_get32()
362 return (ddi_get32(tpm->handle, in tpm_get32()
363 (uint32_t *)(TPM_LOCALITY_OFFSET(tpm->locality) | in tpm_get32()
364 (uintptr_t)tpm->addr + offset))); in tpm_get32()
368 tpm_put8(tpm_state_t *tpm, unsigned long offset, uint8_t value) in tpm_put8() argument
370 ASSERT(tpm != NULL); in tpm_put8()
371 ddi_put8(tpm->handle, in tpm_put8()
372 (uint8_t *)(TPM_LOCALITY_OFFSET(tpm->locality) | in tpm_put8()
373 (uintptr_t)tpm->addr + offset), value); in tpm_put8()
403 tpm_get_timeouts(tpm_state_t *tpm) in tpm_get_timeouts() argument
420 ASSERT(tpm != NULL); in tpm_get_timeouts()
422 ret = itpm_command(tpm, buf, sizeof (buf)); in tpm_get_timeouts()
454 tpm->timeout_a = drv_usectohz(timeout); in tpm_get_timeouts()
463 tpm->timeout_b = drv_usectohz(timeout); in tpm_get_timeouts()
472 tpm->timeout_c = drv_usectohz(timeout); in tpm_get_timeouts()
481 tpm->timeout_d = drv_usectohz(timeout); in tpm_get_timeouts()
492 tpm_get_duration(tpm_state_t *tpm) { in tpm_get_duration() argument
506 ASSERT(tpm != NULL); in tpm_get_duration()
508 ret = itpm_command(tpm, buf, sizeof (buf)); in tpm_get_duration()
539 tpm->duration[TPM_SHORT] = drv_usectohz(duration); in tpm_get_duration()
547 tpm->duration[TPM_MEDIUM] = drv_usectohz(duration); in tpm_get_duration()
555 tpm->duration[TPM_LONG] = drv_usectohz(duration); in tpm_get_duration()
558 tpm->duration[TPM_UNDEFINED] = tpm->duration[TPM_LONG]; in tpm_get_duration()
569 tpm_get_version(tpm_state_t *tpm) { in tpm_get_version() argument
583 ASSERT(tpm != NULL); in tpm_get_version()
585 ret = itpm_command(tpm, buf, sizeof (buf)); in tpm_get_version()
607 bcopy(buf + TPM_CAP_VERSION_INFO_OFFSET, &tpm->vers_info, in tpm_get_version()
610 bcopy(tpm->vers_info.tpmVendorID, vendorId, in tpm_get_version()
611 sizeof (tpm->vers_info.tpmVendorID)); in tpm_get_version()
616 tpm->vers_info.version.major, /* Version */ in tpm_get_version()
617 tpm->vers_info.version.minor, in tpm_get_version()
618 tpm->vers_info.version.revMajor, /* Revision */ in tpm_get_version()
619 tpm->vers_info.version.revMinor, in tpm_get_version()
620 (int)ntohs(tpm->vers_info.specLevel), in tpm_get_version()
621 tpm->vers_info.errataRev, in tpm_get_version()
627 if (tpm->vers_info.version.major != 1 && in tpm_get_version()
628 tpm->vers_info.version.minor != 2) { in tpm_get_version()
631 tpm->vers_info.version.major, /* Version */ in tpm_get_version()
632 tpm->vers_info.version.minor); in tpm_get_version()
645 tpm_continue_selftest(tpm_state_t *tpm) { in tpm_continue_selftest() argument
655 ret = itpm_command(tpm, buf, sizeof (buf)); in tpm_continue_selftest()
673 tpm_get_ordinal_duration(tpm_state_t *tpm, uint8_t ordinal) in tpm_get_ordinal_duration() argument
678 ASSERT(tpm != NULL); in tpm_get_ordinal_duration()
711 return (tpm->duration[index]); in tpm_get_ordinal_duration()
720 itpm_command(tpm_state_t *tpm, uint8_t *buf, size_t bufsiz) in itpm_command() argument
726 ASSERT(tpm != NULL && buf != NULL); in itpm_command()
740 ret = tis_send_data(tpm, buf, count); in itpm_command()
753 ret = tis_recv_data(tpm, buf, bufsiz); in itpm_command()
785 tpm_get_burstcount(tpm_state_t *tpm) { in tpm_get_burstcount() argument
789 ASSERT(tpm != NULL); in tpm_get_burstcount()
795 stop = ddi_get_lbolt() + tpm->timeout_d; in tpm_get_burstcount()
801 burstcnt = tpm_get8(tpm, TPM_STS + 1); in tpm_get_burstcount()
802 burstcnt += tpm_get8(tpm, TPM_STS + 2) << 8; in tpm_get_burstcount()
807 delay(tpm->timeout_poll); in tpm_get_burstcount()
820 tpm_set_ready(tpm_state_t *tpm) { in tpm_set_ready() argument
821 tpm_put8(tpm, TPM_STS, TPM_STS_CMD_READY); in tpm_set_ready()
825 receive_data(tpm_state_t *tpm, uint8_t *buf, size_t bufsiz) { in receive_data() argument
833 ASSERT(tpm != NULL && buf != NULL); in receive_data()
836 (tpm_wait_for_stat(tpm, in receive_data()
838 tpm->timeout_c) == DDI_SUCCESS)) { in receive_data()
844 burstcnt = tpm_get_burstcount(tpm); in receive_data()
846 buf[size++] = tpm_get8(tpm, TPM_DATA_FIFO); in receive_data()
849 stsbits = tis_get_status(tpm); in receive_data()
853 tpm_put8(tpm, TPM_STS, TPM_STS_RESPONSE_RETRY); in receive_data()
865 tis_recv_data(tpm_state_t *tpm, uint8_t *buf, size_t bufsiz) { in tis_recv_data() argument
872 ASSERT(tpm != NULL && buf != NULL); in tis_recv_data()
885 size = receive_data(tpm, buf, TPM_HEADER_SIZE); in tis_recv_data()
908 size += receive_data(tpm, (uint8_t *)&buf[TPM_HEADER_SIZE], in tis_recv_data()
919 ret = tpm_wait_for_stat(tpm, TPM_STS_VALID, tpm->timeout_c); in tis_recv_data()
921 status = tis_get_status(tpm); in tis_recv_data()
943 tis_release_locality(tpm, tpm->locality, 0); in tis_recv_data()
946 tpm_set_ready(tpm); in tis_recv_data()
947 tis_release_locality(tpm, tpm->locality, 0); in tis_recv_data()
955 tis_send_data(tpm_state_t *tpm, uint8_t *buf, size_t bufsiz) { in tis_send_data() argument
963 ASSERT(tpm != NULL && buf != NULL); in tis_send_data()
973 status = tis_get_status(tpm); in tis_send_data()
976 tpm_set_ready(tpm); in tis_send_data()
977 ret = tpm_wait_for_stat(tpm, TPM_STS_CMD_READY, tpm->timeout_b); in tis_send_data()
996 burstcnt = tpm_get_burstcount(tpm); in tis_send_data()
1007 tpm_put8(tpm, TPM_DATA_FIFO, buf[count]); in tis_send_data()
1011 ret = tpm_wait_for_stat(tpm, in tis_send_data()
1012 (TPM_STS_VALID | TPM_STS_DATA_EXPECT), tpm->timeout_c); in tis_send_data()
1024 tpm_put8(tpm, TPM_DATA_FIFO, buf[count]); in tis_send_data()
1028 ret = tpm_wait_for_stat(tpm, TPM_STS_VALID, tpm->timeout_c); in tis_send_data()
1037 status = tis_get_status(tpm); in tis_send_data()
1052 tpm_put8(tpm, TPM_STS, TPM_STS_GO); in tis_send_data()
1057 ret = tpm_wait_for_stat(tpm, TPM_STS_DATA_AVAIL | TPM_STS_VALID, in tis_send_data()
1058 tpm_get_ordinal_duration(tpm, ordinal)); in tis_send_data()
1061 status = tis_get_status(tpm); in tis_send_data()
1067 tpm_get_ordinal_duration(tpm, ordinal), in tis_send_data()
1080 tpm_set_ready(tpm); in tis_send_data()
1081 tis_release_locality(tpm, tpm->locality, 0); in tis_send_data()
1089 tis_release_locality(tpm_state_t *tpm, char locality, int force) { in tis_release_locality() argument
1090 ASSERT(tpm != NULL && locality >= 0 && locality < 5); in tis_release_locality()
1093 (tpm_get8(tpm, TPM_ACCESS) & in tis_release_locality()
1100 tpm_put8(tpm, TPM_ACCESS, TPM_ACCESS_ACTIVE_LOCALITY); in tis_release_locality()
1109 tis_check_active_locality(tpm_state_t *tpm, char locality) { in tis_check_active_locality() argument
1113 ASSERT(tpm != NULL && locality >= 0 && locality < 5); in tis_check_active_locality()
1115 old_locality = tpm->locality; in tis_check_active_locality()
1116 tpm->locality = locality; in tis_check_active_locality()
1119 access_bits = tpm_get8(tpm, TPM_ACCESS); in tis_check_active_locality()
1123 tpm->locality = old_locality; in tis_check_active_locality()
1134 tis_request_locality(tpm_state_t *tpm, char locality) { in tis_request_locality() argument
1139 ASSERT(tpm != NULL && locality >= 0 && locality < 5); in tis_request_locality()
1141 ret = tis_check_active_locality(tpm, locality); in tis_request_locality()
1145 tpm->locality = locality; in tis_request_locality()
1149 tpm_put8(tpm, TPM_ACCESS, TPM_ACCESS_REQUEST_USE); in tis_request_locality()
1150 timeout = ddi_get_lbolt() + tpm->timeout_a; in tis_request_locality()
1153 while (tis_check_active_locality(tpm, locality) in tis_request_locality()
1159 myname, tpm->timeout_a); in tis_request_locality()
1163 delay(tpm->timeout_poll); in tis_request_locality()
1166 tpm->locality = locality; in tis_request_locality()
1172 tis_get_status(tpm_state_t *tpm) { in tis_get_status() argument
1173 return (tpm_get8(tpm, TPM_STS)); in tis_get_status()
1177 tpm_wait_for_stat(tpm_state_t *tpm, uint8_t mask, clock_t timeout) { in tpm_wait_for_stat() argument
1182 while ((tis_get_status(tpm) & mask) != mask) { in tpm_wait_for_stat()
1192 delay(tpm->timeout_poll); in tpm_wait_for_stat()
1205 tis_init(tpm_state_t *tpm) { in tis_init() argument
1216 tpm->timeout_a = drv_usectohz(TIS_TIMEOUT_A); in tis_init()
1217 tpm->timeout_b = drv_usectohz(TIS_TIMEOUT_B); in tis_init()
1218 tpm->timeout_c = drv_usectohz(TIS_TIMEOUT_C); in tis_init()
1219 tpm->timeout_d = drv_usectohz(TIS_TIMEOUT_D); in tis_init()
1225 tpm->duration[TPM_SHORT] = drv_usectohz(TPM_DEFAULT_DURATION); in tis_init()
1226 tpm->duration[TPM_MEDIUM] = drv_usectohz(TPM_DEFAULT_DURATION); in tis_init()
1227 tpm->duration[TPM_LONG] = drv_usectohz(TPM_DEFAULT_DURATION); in tis_init()
1228 tpm->duration[TPM_UNDEFINED] = drv_usectohz(TPM_DEFAULT_DURATION); in tis_init()
1231 intf_caps = tpm_get32(tpm, TPM_INTF_CAP); in tis_init()
1257 ret = tis_request_locality(tpm, DEFAULT_LOCALITY); in tis_init()
1264 tpm->timeout_poll = drv_usectohz(TPM_POLLING_TIMEOUT); in tis_init()
1265 tpm->intr_enabled = 0; in tis_init()
1268 ret = tpm_get_timeouts(tpm); in tis_init()
1274 ret = tpm_get_duration(tpm); in tis_init()
1281 ret = tpm_get_version(tpm); in tis_init()
1291 ret = tpm_continue_selftest(tpm); in tis_init()
1355 tpm_resume(tpm_state_t *tpm) in tpm_resume() argument
1357 mutex_enter(&tpm->pm_mutex); in tpm_resume()
1358 if (!tpm->suspended) { in tpm_resume()
1359 mutex_exit(&tpm->pm_mutex); in tpm_resume()
1362 tpm->suspended = 0; in tpm_resume()
1363 cv_broadcast(&tpm->suspend_cv); in tpm_resume()
1364 mutex_exit(&tpm->pm_mutex); in tpm_resume()
1388 tpm_state_t *tpm = NULL; in tpm_attach() local
1400 tpm = ddi_get_soft_state(statep, instance); in tpm_attach()
1401 if (tpm == NULL) { in tpm_attach()
1409 tpm->dip = dip; in tpm_attach()
1420 tpm = ddi_get_soft_state(statep, instance); in tpm_attach()
1421 if (tpm == NULL) { in tpm_attach()
1428 return (tpm_resume(tpm)); in tpm_attach()
1438 tpm->flags = 0; in tpm_attach()
1447 tpm->flags |= TPM_HSVC_REGISTERED; in tpm_attach()
1449 tpm->accattr.devacc_attr_version = DDI_DEVICE_ATTR_V0; in tpm_attach()
1450 tpm->accattr.devacc_attr_endian_flags = DDI_NEVERSWAP_ACC; in tpm_attach()
1451 tpm->accattr.devacc_attr_dataorder = DDI_STRICTORDER_ACC; in tpm_attach()
1454 ret = ddi_dev_nregs(tpm->dip, &nregs); in tpm_attach()
1468 if ((ret = ddi_dev_regsize(tpm->dip, idx, &regsize)) != in tpm_attach()
1480 ret = ddi_regs_map_setup(tpm->dip, idx, (caddr_t *)&tpm->addr, in tpm_attach()
1482 &tpm->accattr, &tpm->handle); in tpm_attach()
1487 tpm->flags |= TPM_DIDREGSMAP; in tpm_attach()
1490 ret = tis_init(tpm); in tpm_attach()
1498 if (tpm->flags & TPM_DIDREGSMAP) { in tpm_attach()
1499 ddi_regs_map_free(&tpm->handle); in tpm_attach()
1500 tpm->handle = NULL; in tpm_attach()
1501 tpm->flags &= ~TPM_DIDREGSMAP; in tpm_attach()
1507 mutex_init(&tpm->dev_lock, NULL, MUTEX_DRIVER, NULL); in tpm_attach()
1508 mutex_init(&tpm->pm_mutex, NULL, MUTEX_DRIVER, NULL); in tpm_attach()
1509 cv_init(&tpm->suspend_cv, NULL, CV_DRIVER, NULL); in tpm_attach()
1515 mutex_enter(&tpm->pm_mutex); in tpm_attach()
1516 tpm->suspended = 0; in tpm_attach()
1517 mutex_exit(&tpm->pm_mutex); in tpm_attach()
1519 tpm->flags |= TPM_DID_MUTEX; in tpm_attach()
1522 tpm->bufsize = TPM_IO_BUF_SIZE; in tpm_attach()
1523 tpm->iobuf = kmem_zalloc((sizeof (uint8_t))*(tpm->bufsize), KM_SLEEP); in tpm_attach()
1524 tpm->flags |= TPM_DID_IO_ALLOC; in tpm_attach()
1526 mutex_init(&tpm->iobuf_lock, NULL, MUTEX_DRIVER, NULL); in tpm_attach()
1527 tpm->flags |= TPM_DID_IO_MUTEX; in tpm_attach()
1529 cv_init(&tpm->iobuf_cv, NULL, CV_DRIVER, NULL); in tpm_attach()
1530 tpm->flags |= TPM_DID_IO_CV; in tpm_attach()
1541 tpm->flags |= TPM_DIDMINOR; in tpm_attach()
1545 if (tpmrng_register(tpm) != DDI_SUCCESS) in tpm_attach()
1552 if (tpm != NULL) { in tpm_attach()
1553 tpm_cleanup(dip, tpm); in tpm_attach()
1555 tpm = NULL; in tpm_attach()
1566 tpm_cleanup(dev_info_t *dip, tpm_state_t *tpm) in tpm_cleanup() argument
1568 if (tpm == NULL) in tpm_cleanup()
1572 (void) tpmrng_unregister(tpm); in tpm_cleanup()
1576 if (tpm->flags & TPM_HSVC_REGISTERED) { in tpm_cleanup()
1578 tpm->flags &= ~(TPM_HSVC_REGISTERED); in tpm_cleanup()
1581 if (tpm->flags & TPM_DID_MUTEX) { in tpm_cleanup()
1582 mutex_destroy(&tpm->dev_lock); in tpm_cleanup()
1583 mutex_destroy(&tpm->pm_mutex); in tpm_cleanup()
1584 cv_destroy(&tpm->suspend_cv); in tpm_cleanup()
1585 tpm->flags &= ~(TPM_DID_MUTEX); in tpm_cleanup()
1587 if (tpm->flags & TPM_DID_IO_ALLOC) { in tpm_cleanup()
1588 ASSERT(tpm->iobuf != NULL); in tpm_cleanup()
1589 kmem_free(tpm->iobuf, (sizeof (uint8_t))*(tpm->bufsize)); in tpm_cleanup()
1590 tpm->flags &= ~(TPM_DID_IO_ALLOC); in tpm_cleanup()
1592 if (tpm->flags & TPM_DID_IO_MUTEX) { in tpm_cleanup()
1593 mutex_destroy(&tpm->iobuf_lock); in tpm_cleanup()
1594 tpm->flags &= ~(TPM_DID_IO_MUTEX); in tpm_cleanup()
1596 if (tpm->flags & TPM_DID_IO_CV) { in tpm_cleanup()
1597 cv_destroy(&tpm->iobuf_cv); in tpm_cleanup()
1598 tpm->flags &= ~(TPM_DID_IO_CV); in tpm_cleanup()
1600 if (tpm->flags & TPM_DIDREGSMAP) { in tpm_cleanup()
1602 if (tpm->handle != NULL) in tpm_cleanup()
1603 ddi_regs_map_free(&tpm->handle); in tpm_cleanup()
1604 tpm->flags &= ~(TPM_DIDREGSMAP); in tpm_cleanup()
1606 if (tpm->flags & TPM_DIDMINOR) { in tpm_cleanup()
1609 tpm->flags &= ~(TPM_DIDMINOR); in tpm_cleanup()
1614 tpm_suspend(tpm_state_t *tpm) in tpm_suspend() argument
1616 if (tpm == NULL) in tpm_suspend()
1618 mutex_enter(&tpm->pm_mutex); in tpm_suspend()
1619 if (tpm->suspended) { in tpm_suspend()
1620 mutex_exit(&tpm->pm_mutex); in tpm_suspend()
1623 tpm->suspended = 1; in tpm_suspend()
1624 mutex_exit(&tpm->pm_mutex); in tpm_suspend()
1634 tpm_state_t *tpm; in tpm_detach() local
1642 if ((tpm = ddi_get_soft_state(statep, instance)) == NULL) { in tpm_detach()
1655 return (tpm_suspend(tpm)); in tpm_detach()
1664 tpm_cleanup(dip, tpm); in tpm_detach()
1668 tpm = NULL; in tpm_detach()
1679 tpm_state_t *tpm; in tpm_getinfo() local
1682 if ((tpm = ddi_get_soft_state(statep, instance)) == NULL) { in tpm_getinfo()
1692 *resultp = tpm->dip; in tpm_getinfo()
1716 tpm_state_t *tpm; in tpm_open() local
1721 if ((tpm = ddi_get_soft_state(statep, instance)) == NULL) { in tpm_open()
1735 TPM_EXCLUSIVE_LOCK(tpm); in tpm_open()
1737 mutex_enter(&tpm->dev_lock); in tpm_open()
1738 if (tpm->dev_held) { in tpm_open()
1743 mutex_exit(&tpm->dev_lock); in tpm_open()
1748 tpm->dev_held = 1; in tpm_open()
1749 mutex_exit(&tpm->dev_lock); in tpm_open()
1760 tpm_state_t *tpm; in tpm_close() local
1763 if ((tpm = ddi_get_soft_state(statep, instance)) == NULL) { in tpm_close()
1777 TPM_EXCLUSIVE_LOCK(tpm); in tpm_close()
1779 ASSERT(tpm->dev_held); in tpm_close()
1781 mutex_enter(&tpm->dev_lock); in tpm_close()
1782 ASSERT(mutex_owned(&tpm->dev_lock)); in tpm_close()
1783 tpm->dev_held = 0; in tpm_close()
1784 mutex_exit(&tpm->dev_lock); in tpm_close()
1797 tpm_state_t *tpm; in tpm_read() local
1800 if ((tpm = ddi_get_soft_state(statep, instance)) == NULL) { in tpm_read()
1814 TPM_EXCLUSIVE_LOCK(tpm); in tpm_read()
1817 ret = tpm_io_lock(tpm); in tpm_read()
1823 if (uiop->uio_resid > tpm->bufsize) { in tpm_read()
1827 myname, (int)uiop->uio_resid, (int)tpm->bufsize); in tpm_read()
1833 ret = tis_recv_data(tpm, tpm->iobuf, tpm->bufsize); in tpm_read()
1842 size = load32(tpm->iobuf, 2); in tpm_read()
1854 ret = uiomove(tpm->iobuf, size, UIO_READ, uiop); in tpm_read()
1863 bzero(tpm->iobuf, tpm->bufsize); in tpm_read()
1867 tpm_unlock(tpm); in tpm_read()
1881 tpm_state_t *tpm; in tpm_write() local
1884 if ((tpm = ddi_get_soft_state(statep, instance)) == NULL) { in tpm_write()
1899 TPM_EXCLUSIVE_LOCK(tpm); in tpm_write()
1910 ret = tpm_io_lock(tpm); in tpm_write()
1916 ret = uiomove(tpm->iobuf, TPM_HEADER_SIZE, UIO_WRITE, uiop); in tpm_write()
1927 size = load32(tpm->iobuf, TPM_PARAMSIZE_OFFSET); in tpm_write()
1930 if (size > tpm->bufsize) { in tpm_write()
1934 myname, (int)size, (int)tpm->bufsize); in tpm_write()
1941 ret = uiomove(tpm->iobuf+TPM_HEADER_SIZE, size-TPM_HEADER_SIZE, in tpm_write()
1953 ret = tis_send_data(tpm, tpm->iobuf, size); in tpm_write()
1963 bzero(tpm->iobuf, tpm->bufsize); in tpm_write()
1966 tpm_unlock(tpm); in tpm_write()
1974 tpm_io_lock(tpm_state_t *tpm) in tpm_io_lock() argument
1979 mutex_enter(&tpm->iobuf_lock); in tpm_io_lock()
1980 ASSERT(mutex_owned(&tpm->iobuf_lock)); in tpm_io_lock()
1985 while (tpm->iobuf_inuse) { in tpm_io_lock()
1986 ret = cv_timedwait(&tpm->iobuf_cv, &tpm->iobuf_lock, timeout); in tpm_io_lock()
1989 mutex_exit(&tpm->iobuf_lock); in tpm_io_lock()
1996 tpm->iobuf_inuse = 1; in tpm_io_lock()
1997 mutex_exit(&tpm->iobuf_lock); in tpm_io_lock()
2005 tpm_unlock(tpm_state_t *tpm) in tpm_unlock() argument
2008 mutex_enter(&tpm->iobuf_lock); in tpm_unlock()
2009 ASSERT(tpm->iobuf_inuse == 1 && mutex_owned(&tpm->iobuf_lock)); in tpm_unlock()
2010 tpm->iobuf_inuse = 0; in tpm_unlock()
2011 cv_broadcast(&tpm->iobuf_cv); in tpm_unlock()
2012 mutex_exit(&tpm->iobuf_lock); in tpm_unlock()
2034 tpm_state_t *tpm = (tpm_state_t *)prov; in tpmrng_ext_info() local
2037 if (tpm == NULL) in tpmrng_ext_info()
2041 (char *)tpm->vers_info.tpmVendorID, in tpmrng_ext_info()
2059 ext_info->ei_hardware_version.cv_major = tpm->vers_info.version.major; in tpmrng_ext_info()
2060 ext_info->ei_hardware_version.cv_minor = tpm->vers_info.version.minor; in tpmrng_ext_info()
2062 tpm->vers_info.version.revMajor; in tpmrng_ext_info()
2064 tpm->vers_info.version.revMinor; in tpmrng_ext_info()
2076 tpmrng_register(tpm_state_t *tpm) in tpmrng_register() argument
2082 ASSERT(tpm != NULL); in tpmrng_register()
2087 tpmrng_prov_info.pi_provider_dev.pd_hw = tpm->dip; in tpmrng_register()
2088 tpmrng_prov_info.pi_provider_handle = tpm; in tpmrng_register()
2090 ret = crypto_register_provider(&tpmrng_prov_info, &tpm->n_prov); in tpmrng_register()
2092 tpm->n_prov = NULL; in tpmrng_register()
2096 crypto_provider_notification(tpm->n_prov, CRYPTO_PROVIDER_READY); in tpmrng_register()
2100 ret = crypto_load_dev_disabled("tpm", ddi_get_instance(tpm->dip), in tpmrng_register()
2110 tpmrng_unregister(tpm_state_t *tpm) in tpmrng_unregister() argument
2113 ASSERT(tpm != NULL); in tpmrng_unregister()
2114 if (tpm->n_prov) { in tpmrng_unregister()
2115 ret = crypto_unregister_provider(tpm->n_prov); in tpmrng_unregister()
2116 tpm->n_prov = NULL; in tpmrng_unregister()
2137 tpm_state_t *tpm; in tpmrng_seed_random() local
2151 tpm = (tpm_state_t *)provider; in tpmrng_seed_random()
2152 if (tpm == NULL) in tpmrng_seed_random()
2156 TPM_EXCLUSIVE_LOCK(tpm); in tpmrng_seed_random()
2158 ret = tpm_io_lock(tpm); in tpmrng_seed_random()
2183 ret = itpm_command(tpm, cmdbuf, buflen); in tpmrng_seed_random()
2184 tpm_unlock(tpm); in tpmrng_seed_random()
2202 tpm_state_t *tpm; in tpmrng_generate_random() local
2216 tpm = (tpm_state_t *)provider; in tpmrng_generate_random()
2217 if (tpm == NULL) in tpmrng_generate_random()
2220 TPM_EXCLUSIVE_LOCK(tpm); in tpmrng_generate_random()
2222 ret = tpm_io_lock(tpm); in tpmrng_generate_random()
2234 ret = itpm_command(tpm, cmdbuf, buflen); in tpmrng_generate_random()
2240 tpm_unlock(tpm); in tpmrng_generate_random()
2251 tpm_unlock(tpm); in tpmrng_generate_random()