sda_cmd.c revision f2b90c3c415ff04d4adb3a54242822b41d74bfd9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* SD card common framework. This module provides most of the common
* functionality so that SecureDigital host adapters and client devices
* (such as the sdcard driver) can share common code.
*
* NB that this file contains a fair bit of non-DDI compliant code.
* But writing a nexus driver would be impossible to do with only DDI
* compliant interfaces.
*/
#include <sys/sysmacros.h>
/*
* Types and Structures.
*/
typedef struct sda_cmd_impl {
/*
* Implementation private stuff.
*/
void *c_private;
/*
* Local Prototypes.
*/
static void sda_cmd_wait(sda_cmd_t *);
static int sda_cmd_ctor(void *, void *, int);
static void sda_cmd_dtor(void *, void *);
/*
* Static Variables.
*/
static kmem_cache_t *sda_cmd_cache;
/*
* Macros.
*/
/*
* Implementation.
*/
void
sda_cmd_init(void)
{
}
void
sda_cmd_fini(void)
{
}
void
{
}
void
{
}
/*ARGSUSED1*/
int
{
sda_cmd_impl_t *c = cbuf;
return (0);
}
/*ARGSUSED1*/
void
{
sda_cmd_impl_t *c = cbuf;
cv_destroy(&c->c_cv);
mutex_destroy(&c->c_lock);
}
void *
{
}
{
}
void
{
/*
* Now we need to make sure that we wake anyone waiting on this
* command to complete, if it is complete.
*/
mutex_enter(&c->c_lock);
/*
* Don't overwrite an earlier error.
*/
}
mutex_exit(&c->c_lock);
} else {
cv_broadcast(&c->c_cv);
mutex_exit(&c->c_lock);
}
} else {
mutex_exit(&c->c_lock);
}
}
void
{
mutex_enter(&c->c_lock);
mutex_exit(&c->c_lock);
}
void
{
mutex_enter(&c->c_lock);
c->c_flags |= SDA_CMDF_BUSY;
mutex_exit(&c->c_lock);
/* checks for cases where the slot can't accept the command */
errno = SDA_EFAULT;
}
if (!slot->s_inserted) {
errno = SDA_ENODEV;
}
/* fail it synchronously */
return;
}
/* Initialization commands go to the head of the class */
if (c->c_flags & SDA_CMDF_INIT) {
} else {
}
}
void
{
c->c_argument = c->c_aarg;
c->c_acmd = 0;
}
{
sda_cmd_impl_t *c;
if (c == NULL) {
return (NULL);
}
c->c_argument = argument;
c->c_resid = 0;
c->c_nblks = 0;
c->c_blksz = 0;
c->c_kvaddr = 0;
c->c_ndmac = 0;
c->c_flags = 0;
c->c_acmd = 0;
return (&(c->c_public));
}
{
sda_cmd_impl_t *c;
if (c == NULL) {
return (NULL);
}
c->c_index = CMD_APP_CMD;
c->c_resid = 0;
c->c_nblks = 0;
c->c_blksz = 0;
c->c_kvaddr = 0;
c->c_ndmac = 0;
c->c_flags = 0;
return (&(c->c_public));
}
void
{
}
{
int errno;
}
case R0:
break;
case R2:
break;
default:
break;
}
}
return (errno);
}