sda_mem.c revision 86e3bca69f59096fa71848f8e8614c38ac86a24a
/*
* 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 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Memory target support for SDcard.
*/
static int sda_mem_errno(sda_err_t);
static void sda_mem_done(sda_cmd_t *);
static void sda_mem_getstring(uint32_t *, char *, int, int);
/*
* To minimize complexity and reduce layering, we implement almost the
* entire memory card driver (sdcard) here. The memory card still
* needs to be a separate driver though, due to the requirement to
* have both SCSI HBA bus ops and SD bus ops.
*/
/*
* Everything beyond this is private.
*/
int
{
/* the hot path */
return (0);
}
switch (errno) {
case SDA_ENOMEM:
return (ENOMEM);
case SDA_ETIME:
return (ETIMEDOUT);
case SDA_EWPROTECT:
return (EROFS);
case SDA_ESUSPENDED:
case SDA_ENODEV:
return (ENODEV);
case SDA_EFAULT:
case SDA_ECRC7:
case SDA_EPROTO:
case SDA_ERESET:
case SDA_EIO:
case SDA_ERESID:
default:
return (EIO);
}
}
void
{
}
int
{
return (EINVAL);
}
return (ENOMEM);
}
} else {
}
/* other fields are set by sda_cmd_alloc */
return (0);
}
int
{
return (EIO);
}
} else {
}
}
int
{
return (EIO);
}
return (EROFS);
}
} else {
}
}
void
{
}
int
{
return (ENXIO);
}
return (0);
}
{
val <<= 1;
}
return (val);
}
void
{
while (len--) {
hibit -= 8;
}
*s = 0;
}
{
0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80
};
10000, 100000, 1000000, 10000000, 0, 0, 0, 0,
};
}
int
{
int csdver;
switch (csdver) {
case 0:
bshift = 9;
break;
case 1:
rblen = 512;
cmult = 1024;
bshift = 0;
break;
default:
csdver);
return (DDI_FAILURE);
}
csdver);
return (DDI_FAILURE);
}
case 0: /* MMC 1.0 - 1.2 */
case 1: /* MMC 1.4 */
break;
case 2: /* MMC 2.0 - 2.2 */
case 3: /* MMC 3.1 - 3.3 */
case 4: /* MMC 4.x */
break;
default:
/* this error isn't fatal to us */
break;
}
bshift = 9;
} else {
return (DDI_FAILURE);
}
/*
*
* The spec requires that block size 512 be supported.
* The media may have a different native size, but 512
* byte blocks will always work. This is true for SDcard,
* and apparently for MMC as well.
*/
}
return (DDI_SUCCESS);
}