sda_cmd.c revision 3f7d54a6b84904c8f4d8daa4c7b577bede7df8b9
/*
* 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
*/
/*
*/
/*
* 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.
*/
#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;
}
/*
* We have to return failure conditions asynchronously.
* What we do in this case is mark the command failed,
* and move it to the abortlist so that the slot thread
* will execute the failure notification asynchronously.
*
* NB: using 0 for flags ensures that we don't execute
* the notification callback yet, we're just stashing
* the errno.
*/
} else if (c->c_flags & SDA_CMDF_INIT) {
/* Initialization commands go to the head of the class */
} 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_dmah = 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);
}