Commit 126bb03b authored by Al Cho's avatar Al Cho Committed by Greg Kroah-Hartman

Staging: add USB ENE card reader driver

This driver is for the ENE card reader that can be found in many
different laptops.  It was written by ENE, but cleaned up to
work properly in the kernel tree by Novell.
Signed-off-by: default avatarAl Cho <acho@novell.com>
Cc: <yiyingc@ene.com.tw>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 15b9e327
......@@ -159,5 +159,7 @@ source "drivers/staging/sbe-2t3e3/Kconfig"
source "drivers/staging/ath6kl/Kconfig"
source "drivers/staging/keucr/Kconfig"
endif # !STAGING_EXCLUDE_BUILD
endif # STAGING
......@@ -60,3 +60,4 @@ obj-$(CONFIG_ACPI_QUICKSTART) += quickstart/
obj-$(CONFIG_WESTBRIDGE_ASTORIA) += westbridge/astoria/
obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3/
obj-$(CONFIG_ATH6K_LEGACY) += ath6kl/
obj-$(CONFIG_USB_ENESTORAGE) += keucr/
config USB_ENESTORAGE
tristate "USB ENE card reader support"
depends on USB && SCSI
---help---
Say Y here if you wish to control a ENE Card reader.
This option depends on 'SCSI' support being enabled, but you
probably also need 'SCSI device support: SCSI disk support'
(BLK_DEV_SD) for most USB storage devices.
To compile this driver as a module, choose M here: the
module will be called keucr.
EXTRA_CFLAGS += -Idrivers/scsi
obj-$(CONFIG_USB_ENESTORAGE) += keucr.o
keucr-objs := \
usb.o \
scsiglue.o \
transport.o \
init.o \
sdscsi.o \
msscsi.o \
ms.o \
smscsi.o \
smilmain.o \
smilsub.o \
smilecc.o
TODO:
- checkpatch.pl clean
- sparse clean
- determine if the driver should not be using a duplicate
version of the usb-storage scsi interface code, but should
be merged into the drivers/usb/storage/ directory and
infrastructure instead.
- review by the USB developer community
Please send any patches for this driver to Al Cho <acho@novell.com> and
Greg Kroah-Hartman <gregkh@suse.de>.
#ifndef COMMON_INCD
#define COMMON_INCD
typedef void VOID;
typedef u8 BOOLEAN;
typedef u8 BYTE;
typedef u8 *PBYTE;
typedef u16 WORD;
typedef u16 *PWORD;
typedef u32 DWORD;
typedef u32 *PDWORD;
#define swapWORD(w) ((((unsigned short)(w) << 8) & 0xff00) | (((unsigned short)(w) >> 8) & 0x00ff))
#define swapDWORD(dw) ((((unsigned long)(dw) << 24) & 0xff000000) | \
(((unsigned long)(dw) << 8) & 0x00ff0000) | \
(((unsigned long)(dw) >> 8) & 0x0000ff00) | \
(((unsigned long)(dw) >> 24) & 0x000000ff))
#define LittleEndianWORD(w) (w)
#define LittleEndianDWORD(dw) (dw)
#define BigEndianWORD(w) swapWORD(w)
#define BigEndianDWORD(dw) swapDWORD(dw)
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_device.h>
#include "usb.h"
#include "scsiglue.h"
#include "transport.h"
int MS_SCSI_Test_Unit_Ready (struct us_data *us, struct scsi_cmnd *srb);
int MS_SCSI_Inquiry (struct us_data *us, struct scsi_cmnd *srb);
int MS_SCSI_Mode_Sense (struct us_data *us, struct scsi_cmnd *srb);
int MS_SCSI_Start_Stop (struct us_data *us, struct scsi_cmnd *srb);
int MS_SCSI_Read_Capacity (struct us_data *us, struct scsi_cmnd *srb);
int MS_SCSI_Read (struct us_data *us, struct scsi_cmnd *srb);
int MS_SCSI_Write (struct us_data *us, struct scsi_cmnd *srb);
//----- MS_SCSIIrp() --------------------------------------------------
int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
{
int result;
us->SrbStatus = SS_SUCCESS;
switch (srb->cmnd[0])
{
case TEST_UNIT_READY : result = MS_SCSI_Test_Unit_Ready (us, srb); break; //0x00
case INQUIRY : result = MS_SCSI_Inquiry (us, srb); break; //0x12
case MODE_SENSE : result = MS_SCSI_Mode_Sense (us, srb); break; //0x1A
case READ_CAPACITY : result = MS_SCSI_Read_Capacity (us, srb); break; //0x25
case READ_10 : result = MS_SCSI_Read (us, srb); break; //0x28
case WRITE_10 : result = MS_SCSI_Write (us, srb); break; //0x2A
default:
us->SrbStatus = SS_ILLEGAL_REQUEST;
result = USB_STOR_TRANSPORT_FAILED;
break;
}
return result;
}
//----- MS_SCSI_Test_Unit_Ready() --------------------------------------------------
int MS_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
{
//printk("MS_SCSI_Test_Unit_Ready\n");
if (us->MS_Status.Insert && us->MS_Status.Ready)
return USB_STOR_TRANSPORT_GOOD;
else
{
ENE_MSInit(us);
return USB_STOR_TRANSPORT_GOOD;
}
return USB_STOR_TRANSPORT_GOOD;
}
//----- MS_SCSI_Inquiry() --------------------------------------------------
int MS_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
{
//printk("MS_SCSI_Inquiry\n");
BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- MS_SCSI_Mode_Sense() --------------------------------------------------
int MS_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
{
BYTE mediaNoWP[12] = {0x0b,0x00,0x00,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
BYTE mediaWP[12] = {0x0b,0x00,0x80,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
if (us->MS_Status.WtP)
usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
else
usb_stor_set_xfer_buf(us, mediaNoWP, 12, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- MS_SCSI_Read_Capacity() --------------------------------------------------
int MS_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
{
unsigned int offset = 0;
struct scatterlist *sg = NULL;
DWORD bl_num;
WORD bl_len;
BYTE buf[8];
printk("MS_SCSI_Read_Capacity\n");
bl_len = 0x200;
if ( us->MS_Status.IsMSPro )
bl_num = us->MSP_TotalBlock - 1;
else
bl_num = us->MS_Lib.NumberOfLogBlock * us->MS_Lib.blockSize * 2 - 1;
us->bl_num = bl_num;
printk("bl_len = %x\n", bl_len);
printk("bl_num = %x\n", bl_num);
//srb->request_bufflen = 8;
buf[0] = (bl_num>>24) & 0xff;
buf[1] = (bl_num>>16) & 0xff;
buf[2] = (bl_num>> 8) & 0xff;
buf[3] = (bl_num>> 0) & 0xff;
buf[4] = (bl_len>>24) & 0xff;
buf[5] = (bl_len>>16) & 0xff;
buf[6] = (bl_len>> 8) & 0xff;
buf[7] = (bl_len>> 0) & 0xff;
usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF);
//usb_stor_set_xfer_buf(us, buf, srb->request_bufflen, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- MS_SCSI_Read() --------------------------------------------------
int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result=0;
PBYTE Cdb = srb->cmnd;
DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
DWORD blenByte = blen * 0x200;
//printk("SCSIOP_READ --- bn = %X, blen = %X, srb->use_sg = %X\n", bn, blen, srb->use_sg);
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
if (us->MS_Status.IsMSPro)
{
result = ENE_LoadBinCode(us, MSP_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD)
{
printk("Load MSP RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
// set up the command wrapper
memset(bcb, 0, sizeof(bcb));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x02;
bcb->CDB[5] = (BYTE)(bn);
bcb->CDB[4] = (BYTE)(bn>>8);
bcb->CDB[3] = (BYTE)(bn>>16);
bcb->CDB[2] = (BYTE)(bn>>24);
result = ENE_SendScsiCmd(us, FDIR_READ, scsi_sglist(srb), 1);
}
else
{
void *buf;
int offset=0;
WORD phyblk, logblk;
BYTE PageNum;
WORD len;
DWORD blkno;
buf = kmalloc(blenByte, GFP_KERNEL);
result = ENE_LoadBinCode(us, MS_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD)
{
printk("Load MS RW pattern Fail !!\n");
result = USB_STOR_TRANSPORT_ERROR;
goto exit;
}
logblk = (WORD)(bn / us->MS_Lib.PagesPerBlock);
PageNum = (BYTE)(bn % us->MS_Lib.PagesPerBlock);
while(1)
{
if (blen > (us->MS_Lib.PagesPerBlock-PageNum) )
len = us->MS_Lib.PagesPerBlock-PageNum;
else
len = blen;
phyblk = MS_LibConv2Physical(us, logblk);
blkno = phyblk * 0x20 + PageNum;
// set up the command wrapper
memset(bcb, 0, sizeof(bcb));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = 0x200 * len;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x02;
bcb->CDB[5] = (BYTE)(blkno);
bcb->CDB[4] = (BYTE)(blkno>>8);
bcb->CDB[3] = (BYTE)(blkno>>16);
bcb->CDB[2] = (BYTE)(blkno>>24);
result = ENE_SendScsiCmd(us, FDIR_READ, buf+offset, 0);
if (result != USB_STOR_XFER_GOOD)
{
printk("MS_SCSI_Read --- result = %x\n", result);
result = USB_STOR_TRANSPORT_ERROR;
goto exit;
}
blen -= len;
if (blen<=0)
break;
logblk++;
PageNum = 0;
offset += MS_BYTES_PER_PAGE*len;
}
usb_stor_set_xfer_buf(us, buf, blenByte, srb, TO_XFER_BUF);
exit:
kfree(buf);
}
return result;
}
//----- MS_SCSI_Write() --------------------------------------------------
int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result=0;
PBYTE Cdb = srb->cmnd;
DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
DWORD blenByte = blen * 0x200;
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
if (us->MS_Status.IsMSPro)
{
result = ENE_LoadBinCode(us, MSP_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD)
{
printk("Load MSP RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
// set up the command wrapper
memset(bcb, 0, sizeof(bcb));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x00;
bcb->CDB[0] = 0xF0;
bcb->CDB[1] = 0x04;
bcb->CDB[5] = (BYTE)(bn);
bcb->CDB[4] = (BYTE)(bn>>8);
bcb->CDB[3] = (BYTE)(bn>>16);
bcb->CDB[2] = (BYTE)(bn>>24);
result = ENE_SendScsiCmd(us, FDIR_WRITE, scsi_sglist(srb), 1);
}
else
{
void *buf;
int offset=0;
WORD PhyBlockAddr;
BYTE PageNum;
DWORD result;
WORD len, oldphy, newphy;
buf = kmalloc(blenByte, GFP_KERNEL);
usb_stor_set_xfer_buf(us, buf, blenByte, srb, FROM_XFER_BUF);
result = ENE_LoadBinCode(us, MS_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD)
{
printk("Load MS RW pattern Fail !!\n");
result = USB_STOR_TRANSPORT_ERROR;
goto exit;
}
PhyBlockAddr = (WORD)(bn / us->MS_Lib.PagesPerBlock);
PageNum = (BYTE)(bn % us->MS_Lib.PagesPerBlock);
while(1)
{
if (blen > (us->MS_Lib.PagesPerBlock-PageNum) )
len = us->MS_Lib.PagesPerBlock-PageNum;
else
len = blen;
oldphy = MS_LibConv2Physical(us, PhyBlockAddr);
newphy = MS_LibSearchBlockFromLogical(us, PhyBlockAddr);
result = MS_ReaderCopyBlock(us, oldphy, newphy, PhyBlockAddr, PageNum, buf+offset, len);
if (result != USB_STOR_XFER_GOOD)
{
printk("MS_SCSI_Write --- result = %x\n", result);
result = USB_STOR_TRANSPORT_ERROR;
goto exit;
}
us->MS_Lib.Phy2LogMap[oldphy] = MS_LB_NOT_USED_ERASED;
MS_LibForceSetLogicalPair(us, PhyBlockAddr, newphy);
blen -= len;
if (blen<=0)
break;
PhyBlockAddr++;
PageNum = 0;
offset += MS_BYTES_PER_PAGE*len;
}
exit:
kfree(buf);
}
return result;
}
This diff is collapsed.
#ifndef _SCSIGLUE_H_
#define _SCSIGLUE_H_
extern void usb_stor_report_device_reset(struct us_data *us);
extern void usb_stor_report_bus_reset(struct us_data *us);
extern unsigned char usb_stor_sense_invalidCDB[18];
extern struct scsi_host_template usb_stor_host_template;
#endif
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_device.h>
#include "usb.h"
#include "scsiglue.h"
#include "transport.h"
int SD_SCSI_Test_Unit_Ready (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Inquiry (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Mode_Sense (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Start_Stop (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Read_Capacity (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Read (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Write (struct us_data *us, struct scsi_cmnd *srb);
//----- SD_SCSIIrp() --------------------------------------------------
int SD_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
{
int result;
us->SrbStatus = SS_SUCCESS;
switch (srb->cmnd[0])
{
case TEST_UNIT_READY : result = SD_SCSI_Test_Unit_Ready (us, srb); break; //0x00
case INQUIRY : result = SD_SCSI_Inquiry (us, srb); break; //0x12
case MODE_SENSE : result = SD_SCSI_Mode_Sense (us, srb); break; //0x1A
// case START_STOP : result = SD_SCSI_Start_Stop (us, srb); break; //0x1B
case READ_CAPACITY : result = SD_SCSI_Read_Capacity (us, srb); break; //0x25
case READ_10 : result = SD_SCSI_Read (us, srb); break; //0x28
case WRITE_10 : result = SD_SCSI_Write (us, srb); break; //0x2A
default:
us->SrbStatus = SS_ILLEGAL_REQUEST;
result = USB_STOR_TRANSPORT_FAILED;
break;
}
return result;
}
//----- SD_SCSI_Test_Unit_Ready() --------------------------------------------------
int SD_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
{
//printk("SD_SCSI_Test_Unit_Ready\n");
if (us->SD_Status.Insert && us->SD_Status.Ready)
return USB_STOR_TRANSPORT_GOOD;
else
{
ENE_SDInit(us);
return USB_STOR_TRANSPORT_GOOD;
}
return USB_STOR_TRANSPORT_GOOD;
}
//----- SD_SCSI_Inquiry() --------------------------------------------------
int SD_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
{
//printk("SD_SCSI_Inquiry\n");
BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SD_SCSI_Mode_Sense() --------------------------------------------------
int SD_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
{
BYTE mediaNoWP[12] = {0x0b,0x00,0x00,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
BYTE mediaWP[12] = {0x0b,0x00,0x80,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
if (us->SD_Status.WtP)
usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
else
usb_stor_set_xfer_buf(us, mediaNoWP, 12, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SD_SCSI_Read_Capacity() --------------------------------------------------
int SD_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
{
unsigned int offset = 0;
struct scatterlist *sg = NULL;
DWORD bl_num;
WORD bl_len;
BYTE buf[8];
printk("SD_SCSI_Read_Capacity\n");
if ( us->SD_Status.HiCapacity )
{
bl_len = 0x200;
if (us->SD_Status.IsMMC)
bl_num = us->HC_C_SIZE-1;
else
bl_num = (us->HC_C_SIZE + 1) * 1024 - 1;
}
else
{
bl_len = 1<<(us->SD_READ_BL_LEN);
bl_num = us->SD_Block_Mult*(us->SD_C_SIZE+1)*(1<<(us->SD_C_SIZE_MULT+2)) - 1;
}
us->bl_num = bl_num;
printk("bl_len = %x\n", bl_len);
printk("bl_num = %x\n", bl_num);
//srb->request_bufflen = 8;
buf[0] = (bl_num>>24) & 0xff;
buf[1] = (bl_num>>16) & 0xff;
buf[2] = (bl_num>> 8) & 0xff;
buf[3] = (bl_num>> 0) & 0xff;
buf[4] = (bl_len>>24) & 0xff;
buf[5] = (bl_len>>16) & 0xff;
buf[6] = (bl_len>> 8) & 0xff;
buf[7] = (bl_len>> 0) & 0xff;
usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF);
//usb_stor_set_xfer_buf(us, buf, srb->request_bufflen, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SD_SCSI_Read() --------------------------------------------------
int SD_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
PBYTE Cdb = srb->cmnd;
DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
DWORD bnByte = bn * 0x200;
DWORD blenByte = blen * 0x200;
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
result = ENE_LoadBinCode(us, SD_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD)
{
printk("Load SD RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
if ( us->SD_Status.HiCapacity )
bnByte = bn;
// set up the command wrapper
memset(bcb, 0, sizeof(bcb));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[5] = (BYTE)(bnByte);
bcb->CDB[4] = (BYTE)(bnByte>>8);
bcb->CDB[3] = (BYTE)(bnByte>>16);
bcb->CDB[2] = (BYTE)(bnByte>>24);
result = ENE_SendScsiCmd(us, FDIR_READ, scsi_sglist(srb), 1);
return result;
}
//----- SD_SCSI_Write() --------------------------------------------------
int SD_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
PBYTE Cdb = srb->cmnd;
DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
DWORD bnByte = bn * 0x200;
DWORD blenByte = blen * 0x200;
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
result = ENE_LoadBinCode(us, SD_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD)
{
printk("Load SD RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
if ( us->SD_Status.HiCapacity )
bnByte = bn;
// set up the command wrapper
memset(bcb, 0, sizeof(bcb));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x00;
bcb->CDB[0] = 0xF0;
bcb->CDB[5] = (BYTE)(bnByte);
bcb->CDB[4] = (BYTE)(bnByte>>8);
bcb->CDB[3] = (BYTE)(bnByte>>16);
bcb->CDB[2] = (BYTE)(bnByte>>24);
result = ENE_SendScsiCmd(us, FDIR_WRITE, scsi_sglist(srb), 1);
return result;
}
//----- < SMCommon.h> --------------------------------------------------
#ifndef SMCOMMON_INCD
#define SMCOMMON_INCD
/***************************************************************************
Define Difinetion
***************************************************************************/
#define SUCCESS 0x0000 /* SUCCESS */
#define ERROR 0xFFFF /* ERROR */
#define CORRECT 0x0001 /* CORRECTABLE */
/***************************************************************************/
#define NO_ERROR 0x0000 /* NO ERROR */
#define ERR_WriteFault 0x0003 /* Peripheral Device Write Fault */
#define ERR_HwError 0x0004 /* Hardware Error */
#define ERR_DataStatus 0x0010 /* DataStatus Error */
#define ERR_EccReadErr 0x0011 /* Unrecovered Read Error */
#define ERR_CorReadErr 0x0018 /* Recovered Read Data with ECC */
#define ERR_OutOfLBA 0x0021 /* Illegal Logical Block Address */
#define ERR_WrtProtect 0x0027 /* Write Protected */
#define ERR_ChangedMedia 0x0028 /* Medium Changed */
#define ERR_UnknownMedia 0x0030 /* Incompatible Medium Installed */
#define ERR_IllegalFmt 0x0031 /* Medium Format Corrupted */
#define ERR_NoSmartMedia 0x003A /* Medium Not Present */
/***************************************************************************/
//#define SUCCESS 0 /* SUCCESS */
//#define ERROR -1 /* ERROR */
/***************************************************************************/
char Bit_D_Count (BYTE);
char Bit_D_CountWord (WORD);
void StringCopy (char *, char *, int);
int StringCmp (char *, char *, int);
#endif // already included
This diff is collapsed.
#include "usb.h"
#include "scsiglue.h"
#include "transport.h"
//#include "stdlib.h"
//#include "EUCR6SK.h"
#include "smcommon.h"
#include "smil.h"
//#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <dos.h>
//
//#include "EMCRIOS.h"
// CP0-CP5 code table
static BYTE ecctable[256] = {
0x00,0x55,0x56,0x03,0x59,0x0C,0x0F,0x5A,0x5A,0x0F,0x0C,0x59,0x03,0x56,0x55,0x00,
0x65,0x30,0x33,0x66,0x3C,0x69,0x6A,0x3F,0x3F,0x6A,0x69,0x3C,0x66,0x33,0x30,0x65,
0x66,0x33,0x30,0x65,0x3F,0x6A,0x69,0x3C,0x3C,0x69,0x6A,0x3F,0x65,0x30,0x33,0x66,
0x03,0x56,0x55,0x00,0x5A,0x0F,0x0C,0x59,0x59,0x0C,0x0F,0x5A,0x00,0x55,0x56,0x03,
0x69,0x3C,0x3F,0x6A,0x30,0x65,0x66,0x33,0x33,0x66,0x65,0x30,0x6A,0x3F,0x3C,0x69,
0x0C,0x59,0x5A,0x0F,0x55,0x00,0x03,0x56,0x56,0x03,0x00,0x55,0x0F,0x5A,0x59,0x0C,
0x0F,0x5A,0x59,0x0C,0x56,0x03,0x00,0x55,0x55,0x00,0x03,0x56,0x0C,0x59,0x5A,0x0F,
0x6A,0x3F,0x3C,0x69,0x33,0x66,0x65,0x30,0x30,0x65,0x66,0x33,0x69,0x3C,0x3F,0x6A,
0x6A,0x3F,0x3C,0x69,0x33,0x66,0x65,0x30,0x30,0x65,0x66,0x33,0x69,0x3C,0x3F,0x6A,
0x0F,0x5A,0x59,0x0C,0x56,0x03,0x00,0x55,0x55,0x00,0x03,0x56,0x0C,0x59,0x5A,0x0F,
0x0C,0x59,0x5A,0x0F,0x55,0x00,0x03,0x56,0x56,0x03,0x00,0x55,0x0F,0x5A,0x59,0x0C,
0x69,0x3C,0x3F,0x6A,0x30,0x65,0x66,0x33,0x33,0x66,0x65,0x30,0x6A,0x3F,0x3C,0x69,
0x03,0x56,0x55,0x00,0x5A,0x0F,0x0C,0x59,0x59,0x0C,0x0F,0x5A,0x00,0x55,0x56,0x03,
0x66,0x33,0x30,0x65,0x3F,0x6A,0x69,0x3C,0x3C,0x69,0x6A,0x3F,0x65,0x30,0x33,0x66,
0x65,0x30,0x33,0x66,0x3C,0x69,0x6A,0x3F,0x3F,0x6A,0x69,0x3C,0x66,0x33,0x30,0x65,
0x00,0x55,0x56,0x03,0x59,0x0C,0x0F,0x5A,0x5A,0x0F,0x0C,0x59,0x03,0x56,0x55,0x00
};
static void trans_result (BYTE, BYTE, BYTE *, BYTE *);
#define BIT7 0x80
#define BIT6 0x40
#define BIT5 0x20
#define BIT4 0x10
#define BIT3 0x08
#define BIT2 0x04
#define BIT1 0x02
#define BIT0 0x01
#define BIT1BIT0 0x03
#define BIT23 0x00800000L
#define MASK_CPS 0x3f
#define CORRECTABLE 0x00555554L
static void trans_result(reg2,reg3,ecc1,ecc2)
BYTE reg2; // LP14,LP12,LP10,...
BYTE reg3; // LP15,LP13,LP11,...
BYTE *ecc1; // LP15,LP14,LP13,...
BYTE *ecc2; // LP07,LP06,LP05,...
{
BYTE a; // Working for reg2,reg3
BYTE b; // Working for ecc1,ecc2
BYTE i; // For counting
a=BIT7; b=BIT7; // 80h=10000000b
*ecc1=*ecc2=0; // Clear ecc1,ecc2
for(i=0; i<4; ++i) {
if ((reg3&a)!=0)
*ecc1|=b; // LP15,13,11,9 -> ecc1
b=b>>1; // Right shift
if ((reg2&a)!=0)
*ecc1|=b; // LP14,12,10,8 -> ecc1
b=b>>1; // Right shift
a=a>>1; // Right shift
}
b=BIT7; // 80h=10000000b
for(i=0; i<4; ++i) {
if ((reg3&a)!=0)
*ecc2|=b; // LP7,5,3,1 -> ecc2
b=b>>1; // Right shift
if ((reg2&a)!=0)
*ecc2|=b; // LP6,4,2,0 -> ecc2
b=b>>1; // Right shift
a=a>>1; // Right shift
}
}
//static void calculate_ecc(table,data,ecc1,ecc2,ecc3)
void calculate_ecc(table,data,ecc1,ecc2,ecc3)
BYTE *table; // CP0-CP5 code table
BYTE *data; // DATA
BYTE *ecc1; // LP15,LP14,LP13,...
BYTE *ecc2; // LP07,LP06,LP05,...
BYTE *ecc3; // CP5,CP4,CP3,...,"1","1"
{
DWORD i; // For counting
BYTE a; // Working for table
BYTE reg1; // D-all,CP5,CP4,CP3,...
BYTE reg2; // LP14,LP12,L10,...
BYTE reg3; // LP15,LP13,L11,...
reg1=reg2=reg3=0; // Clear parameter
for(i=0; i<256; ++i) {
a=table[data[i]]; // Get CP0-CP5 code from table
reg1^=(a&MASK_CPS); // XOR with a
if ((a&BIT6)!=0)
{ // If D_all(all bit XOR) = 1
reg3^=(BYTE)i; // XOR with counter
reg2^=~((BYTE)i); // XOR with inv. of counter
}
}
// Trans LP14,12,10,... & LP15,13,11,... -> LP15,14,13,... & LP7,6,5,..
trans_result(reg2,reg3,ecc1,ecc2);
*ecc1=~(*ecc1); *ecc2=~(*ecc2); // Inv. ecc2 & ecc3
*ecc3=((~reg1)<<2)|BIT1BIT0; // Make TEL format
}
BYTE correct_data(data,eccdata,ecc1,ecc2,ecc3)
BYTE *data; // DATA
BYTE *eccdata; // ECC DATA
BYTE ecc1; // LP15,LP14,LP13,...
BYTE ecc2; // LP07,LP06,LP05,...
BYTE ecc3; // CP5,CP4,CP3,...,"1","1"
{
DWORD l; // Working to check d
DWORD d; // Result of comparison
DWORD i; // For counting
BYTE d1,d2,d3; // Result of comparison
BYTE a; // Working for add
BYTE add; // Byte address of cor. DATA
BYTE b; // Working for bit
BYTE bit; // Bit address of cor. DATA
d1=ecc1^eccdata[1]; d2=ecc2^eccdata[0]; // Compare LP's
d3=ecc3^eccdata[2]; // Comapre CP's
d=((DWORD)d1<<16) // Result of comparison
+((DWORD)d2<<8)
+(DWORD)d3;
if (d==0) return(0); // If No error, return
if (((d^(d>>1))&CORRECTABLE)==CORRECTABLE)
{ // If correctable
l=BIT23;
add=0; // Clear parameter
a=BIT7;
for(i=0; i<8; ++i) { // Checking 8 bit
if ((d&l)!=0) add|=a; // Make byte address from LP's
l>>=2; a>>=1; // Right Shift
}
bit=0; // Clear parameter
b=BIT2;
for(i=0; i<3; ++i) { // Checking 3 bit
if ((d&l)!=0) bit|=b; // Make bit address from CP's
l>>=2; b>>=1; // Right shift
}
b=BIT0;
data[add]^=(b<<bit); // Put corrected data
return(1);
}
i=0; // Clear count
d&=0x00ffffffL; // Masking
while(d) { // If d=0 finish counting
if (d&BIT0) ++i; // Count number of 1 bit
d>>=1; // Right shift
}
if (i==1)
{ // If ECC error
eccdata[1]=ecc1; eccdata[0]=ecc2; // Put right ECC code
eccdata[2]=ecc3;
return(2);
}
return(3); // Uncorrectable error
}
int _Correct_D_SwECC(buf,redundant_ecc,calculate_ecc)
BYTE *buf;
BYTE *redundant_ecc;
BYTE *calculate_ecc;
{
DWORD err;
err=correct_data(buf,redundant_ecc,*(calculate_ecc+1),*(calculate_ecc),*(calculate_ecc+2));
if (err==1) StringCopy(calculate_ecc,redundant_ecc,3);
if (err==0 || err==1 || err==2)
return(0);
return(-1);
}
void _Calculate_D_SwECC(buf,ecc)
BYTE *buf;
BYTE *ecc;
{
calculate_ecc(ecctable,buf,ecc+1,ecc+0,ecc+2);
}
This diff is collapsed.
This diff is collapsed.
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_device.h>
#include "usb.h"
#include "scsiglue.h"
#include "transport.h"
//#include "smcommon.h"
#include "smil.h"
int SM_SCSI_Test_Unit_Ready (struct us_data *us, struct scsi_cmnd *srb);
int SM_SCSI_Inquiry (struct us_data *us, struct scsi_cmnd *srb);
int SM_SCSI_Mode_Sense (struct us_data *us, struct scsi_cmnd *srb);
int SM_SCSI_Start_Stop (struct us_data *us, struct scsi_cmnd *srb);
int SM_SCSI_Read_Capacity (struct us_data *us, struct scsi_cmnd *srb);
int SM_SCSI_Read (struct us_data *us, struct scsi_cmnd *srb);
int SM_SCSI_Write (struct us_data *us, struct scsi_cmnd *srb);
extern struct SSFDCTYPE Ssfdc;
extern struct ADDRESS Media;
extern PBYTE SMHostAddr;
extern DWORD ErrXDCode;
//----- SM_SCSIIrp() --------------------------------------------------
int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
{
int result;
us->SrbStatus = SS_SUCCESS;
switch (srb->cmnd[0])
{
case TEST_UNIT_READY : result = SM_SCSI_Test_Unit_Ready (us, srb); break; //0x00
case INQUIRY : result = SM_SCSI_Inquiry (us, srb); break; //0x12
case MODE_SENSE : result = SM_SCSI_Mode_Sense (us, srb); break; //0x1A
case READ_CAPACITY : result = SM_SCSI_Read_Capacity (us, srb); break; //0x25
case READ_10 : result = SM_SCSI_Read (us, srb); break; //0x28
case WRITE_10 : result = SM_SCSI_Write (us, srb); break; //0x2A
default:
us->SrbStatus = SS_ILLEGAL_REQUEST;
result = USB_STOR_TRANSPORT_FAILED;
break;
}
return result;
}
//----- SM_SCSI_Test_Unit_Ready() --------------------------------------------------
int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
{
//printk("SM_SCSI_Test_Unit_Ready\n");
if (us->SM_Status.Insert && us->SM_Status.Ready)
return USB_STOR_TRANSPORT_GOOD;
else
{
ENE_SMInit(us);
return USB_STOR_TRANSPORT_GOOD;
}
return USB_STOR_TRANSPORT_GOOD;
}
//----- SM_SCSI_Inquiry() --------------------------------------------------
int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
{
//printk("SM_SCSI_Inquiry\n");
BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SM_SCSI_Mode_Sense() --------------------------------------------------
int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
{
BYTE mediaNoWP[12] = {0x0b,0x00,0x00,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
BYTE mediaWP[12] = {0x0b,0x00,0x80,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
if (us->SM_Status.WtP)
usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
else
usb_stor_set_xfer_buf(us, mediaNoWP, 12, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SM_SCSI_Read_Capacity() --------------------------------------------------
int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
{
unsigned int offset = 0;
struct scatterlist *sg = NULL;
DWORD bl_num;
WORD bl_len;
BYTE buf[8];
printk("SM_SCSI_Read_Capacity\n");
bl_len = 0x200;
bl_num = Ssfdc.MaxLogBlocks * Ssfdc.MaxSectors * Ssfdc.MaxZones - 1;
//printk("MaxLogBlocks = %x\n", Ssfdc.MaxLogBlocks);
//printk("MaxSectors = %x\n", Ssfdc.MaxSectors);
//printk("MaxZones = %x\n", Ssfdc.MaxZones);
//printk("bl_num = %x\n", bl_num);
us->bl_num = bl_num;
printk("bl_len = %x\n", bl_len);
printk("bl_num = %x\n", bl_num);
//srb->request_bufflen = 8;
buf[0] = (bl_num>>24) & 0xff;
buf[1] = (bl_num>>16) & 0xff;
buf[2] = (bl_num>> 8) & 0xff;
buf[3] = (bl_num>> 0) & 0xff;
buf[4] = (bl_len>>24) & 0xff;
buf[5] = (bl_len>>16) & 0xff;
buf[6] = (bl_len>> 8) & 0xff;
buf[7] = (bl_len>> 0) & 0xff;
usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF);
//usb_stor_set_xfer_buf(us, buf, srb->request_bufflen, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SM_SCSI_Read() --------------------------------------------------
int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
{
//struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result=0;
PBYTE Cdb = srb->cmnd;
DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
DWORD blenByte = blen * 0x200;
void *buf;
//printk("SCSIOP_READ --- bn = %X, blen = %X, srb->use_sg = %X\n", bn, blen, srb->use_sg);
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
buf = kmalloc(blenByte, GFP_KERNEL);
result = Media_D_ReadSector(us, bn, blen, buf);
usb_stor_set_xfer_buf(us, buf, blenByte, srb, TO_XFER_BUF);
kfree(buf);
if (!result)
return USB_STOR_TRANSPORT_GOOD;
else
return USB_STOR_TRANSPORT_ERROR;
return USB_STOR_TRANSPORT_GOOD;
}
//----- SM_SCSI_Write() --------------------------------------------------
int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
{
//struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result=0;
PBYTE Cdb = srb->cmnd;
DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
DWORD blenByte = blen * 0x200;
void *buf;
//printk("SCSIOP_Write --- bn = %X, blen = %X, srb->use_sg = %X\n", bn, blen, srb->use_sg);
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
buf = kmalloc(blenByte, GFP_KERNEL);
usb_stor_set_xfer_buf(us, buf, blenByte, srb, FROM_XFER_BUF);
result = Media_D_CopySector(us, bn, blen, buf);
kfree(buf);
if (!result)
return USB_STOR_TRANSPORT_GOOD;
else
return USB_STOR_TRANSPORT_ERROR;
return USB_STOR_TRANSPORT_GOOD;
}
This diff is collapsed.
#ifndef _TRANSPORT_H_
#define _TRANSPORT_H_
#include <linux/blkdev.h>
/* Bulk only data structures */
/* command block wrapper */
struct bulk_cb_wrap {
__le32 Signature; /* contains 'USBC' */
__u32 Tag; /* unique per command id */
__le32 DataTransferLength; /* size of data */
__u8 Flags; /* direction in bit 0 */
__u8 Lun; /* LUN normally 0 */
__u8 Length; /* of of the CDB */
__u8 CDB[16]; /* max command */
};
#define US_BULK_CB_WRAP_LEN 31
#define US_BULK_CB_SIGN 0x43425355 /*spells out USBC */
#define US_BULK_FLAG_IN 1
#define US_BULK_FLAG_OUT 0
/* command status wrapper */
struct bulk_cs_wrap {
__le32 Signature; /* should = 'USBS' */
__u32 Tag; /* same as original command */
__le32 Residue; /* amount not transferred */
__u8 Status; /* see below */
__u8 Filler[18];
};
#define US_BULK_CS_WRAP_LEN 13
#define US_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */
#define US_BULK_STAT_OK 0
#define US_BULK_STAT_FAIL 1
#define US_BULK_STAT_PHASE 2
/* bulk-only class specific requests */
#define US_BULK_RESET_REQUEST 0xff
#define US_BULK_GET_MAX_LUN 0xfe
/* usb_stor_bulk_transfer_xxx() return codes, in order of severity */
#define USB_STOR_XFER_GOOD 0 /* good transfer */
#define USB_STOR_XFER_SHORT 1 /* transferred less than expected */
#define USB_STOR_XFER_STALLED 2 /* endpoint stalled */
#define USB_STOR_XFER_LONG 3 /* device tried to send too much */
#define USB_STOR_XFER_ERROR 4 /* transfer died in the middle */
/* Transport return codes */
#define USB_STOR_TRANSPORT_GOOD 0 /* Transport good, command good */
#define USB_STOR_TRANSPORT_FAILED 1 /* Transport good, command failed */
#define USB_STOR_TRANSPORT_NO_SENSE 2 /* Command failed, no auto-sense */
#define USB_STOR_TRANSPORT_ERROR 3 /* Transport bad (i.e. device dead) */
/*
* We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
* return codes. But now the transport and low-level transfer routines
* treat an abort as just another error (-ENOENT for a cancelled URB).
* It is up to the invoke_transport() function to test for aborts and
* distinguish them from genuine communication errors.
*/
/* CBI accept device specific command */
#define US_CBI_ADSC 0
extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
extern int usb_stor_Bulk_max_lun(struct us_data*);
extern int usb_stor_Bulk_reset(struct us_data*);
extern void usb_stor_print_cmd(struct scsi_cmnd *);
extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
extern void usb_stor_stop_transport(struct us_data*);
extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
u8 request, u8 requesttype, u16 value, u16 index,
void *data, u16 size, int timeout);
extern int usb_stor_clear_halt(struct us_data *us, unsigned int pipe);
extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
void *buf, unsigned int length, unsigned int *act_len);
extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
void *buf, unsigned int length, int use_sg, int *residual);
extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
struct scsi_cmnd* srb);
extern int usb_stor_port_reset(struct us_data *us);
/* Protocol handling routines */
enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF};
extern unsigned int usb_stor_access_xfer_buf(struct us_data*, unsigned char *buffer,
unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **,
unsigned int *offset, enum xfer_buf_dir dir);
extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb,
unsigned int dir);
// ENE scsi function
extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
extern int ENE_InitMedia(struct us_data*);
extern int ENE_SDInit(struct us_data*);
extern int ENE_MSInit(struct us_data*);
extern int ENE_SMInit(struct us_data*);
extern int ENE_ReadSDReg(struct us_data*, u8*);
extern int ENE_SendScsiCmd(struct us_data*, BYTE, void*, int);
extern int ENE_LoadBinCode(struct us_data*, BYTE);
extern int ENE_Read_BYTE(struct us_data*, WORD index, void *buf);
extern int ENE_Read_Data(struct us_data*, void *buf, unsigned int length);
extern int ENE_Write_Data(struct us_data*, void *buf, unsigned int length);
extern void BuildSenseBuffer(struct scsi_cmnd *, int);
// ENE scsi function
extern int SD_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
extern int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
extern int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
// ENE MS function
extern int MS_CardInit(struct us_data *us);
extern void MS_LibFreeAllocatedArea(struct us_data *us);
extern void MS_LibFreeWriteBuf(struct us_data *us);
extern int MS_LibFreeLogicalMap(struct us_data *us);
extern int MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk);
extern int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, DWORD *PageBuf, MS_LibTypeExtdat *ExtraDat);
extern int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy, WORD PhyBlockAddr, BYTE PageNum, PBYTE buf, WORD len);
extern int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr);
extern int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData);
extern int MS_LibAllocLogicalMap(struct us_data *us);
extern int MS_LibSetBootBlockMark(struct us_data *us, WORD phyblk);
extern int MS_LibSetLogicalBlockMark(struct us_data *us, WORD phyblk, WORD mark);
extern int MS_LibSetInitialErrorBlock(struct us_data *us, WORD phyblk);
extern int MS_LibScanLogicalBlockNumber(struct us_data *us, WORD phyblk);
extern int MS_LibAllocWriteBuf(struct us_data *us);
void MS_LibClearWriteBuf(struct us_data *us);
void MS_LibPhy2LogRange(WORD PhyBlock, WORD *LogStart, WORD *LogEnde);
extern int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock, BYTE PageNum, MS_LibTypeExtdat *ExtraDat);
extern int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock, BYTE PageNum, BYTE blen, void *buf);
extern int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk);
extern int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk);
extern int MS_LibErrorPhyBlock(struct us_data *us, WORD phyblk);
extern int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, BYTE OverwriteFlag);
extern int MS_LibSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk);
extern int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock);
extern int MS_CountFreeBlock(struct us_data *us, WORD PhyBlock);
extern int MS_LibSearchBlockFromLogical(struct us_data *us, WORD logblk);
extern int MS_LibSearchBlockFromPhysical(struct us_data *us, WORD phyblk);
// ENE SM function
extern int SM_FreeMem(void);
#endif
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment