yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #ifndef __MS_ADAPTER_H |
| 2 | #define __MS_ADAPTER_H |
| 3 | |
| 4 | #include "fs_func.h" |
| 5 | |
| 6 | #define MAX_DISK_DRVER 4 |
| 7 | #define USBMS_INVALID_MAX_LUN 0xFF |
| 8 | #define DEFAULT_MAX_GPD_OF_LUN 64 |
| 9 | #define NAND_READ_SZ (1024*16) |
| 10 | #define NAND_WRITE_SZ (1024*32) |
| 11 | |
| 12 | typedef enum |
| 13 | { |
| 14 | USB_STORAGE_DEV_STATUS_OK = 0, |
| 15 | USB_STORAGE_DEV_STATUS_MEDIA_CHANGE, |
| 16 | USB_STORAGE_DEV_STATUS_NOMEDIA, |
| 17 | USB_STORAGE_DEV_STATUS_WP, |
| 18 | USB_STORAGE_DEV_STATUS_MAX |
| 19 | } USB_STORAGE_DEV_STATUS; |
| 20 | |
| 21 | |
| 22 | typedef enum |
| 23 | { |
| 24 | USB_STORAGE_DEV_NOR, |
| 25 | USB_STORAGE_DEV_NAND, |
| 26 | USB_STORAGE_DEV_CARD, |
| 27 | USB_STORAGE_DEV_CDROM, |
| 28 | USB_STORAGE_DEV_NONE |
| 29 | }USB_STORAGE_DEV_TYPE; |
| 30 | |
| 31 | /* read capacity command structure */ |
| 32 | typedef struct |
| 33 | { |
| 34 | kal_uint32 LastBA; /*depend on the target*/ |
| 35 | kal_uint32 BlkLen; /*512*/ |
| 36 | } Read_Capacity_Info; |
| 37 | |
| 38 | typedef struct |
| 39 | { |
| 40 | kal_bool (* usbms_read)(void *data, kal_uint32 lba, kal_uint16 lba_num); |
| 41 | kal_bool (* usbms_write)(void *data, kal_uint32 lba, kal_uint16 lba_num); |
| 42 | kal_bool (* usbms_read_gpd)(qbm_gpd *head,qbm_gpd *tail, kal_uint32 lba, kal_uint16 lba_num); //read with GPD |
| 43 | kal_bool (* usbms_write_gpd)(qbm_gpd *head,qbm_gpd *tail, kal_uint32 lba, kal_uint16 lba_num); //write with GPD |
| 44 | kal_bool (* usbms_query_max_bd_num)(kal_uint16 *max_bd_num); //query the max BD number, the driver can receive |
| 45 | kal_bool (* usbms_format)(void); |
| 46 | USB_STORAGE_DEV_STATUS (* usbms_checkmedia_exist)(void); |
| 47 | kal_bool (* usbms_prevmedia_removal)(kal_bool enable); |
| 48 | kal_bool (* usbms_read_capacity)(kal_uint32 *max_lba, kal_uint32 *lba_len); |
| 49 | // kal_bool (* usbms_read_formatcapacity)(kal_uint32 *no_of_blks, kal_uint32 *blk_len); |
| 50 | USB_STORAGE_DEV_TYPE (* usbms_dev_type)(void); |
| 51 | }USB_DiskDriver_STRUCT; |
| 52 | |
| 53 | typedef enum |
| 54 | { |
| 55 | MS_READ = 0, |
| 56 | MS_WRITE |
| 57 | } MS_DIRECTION; |
| 58 | |
| 59 | extern FS_HANDLE g_cdrom_drive_handle; |
| 60 | /* translate fd type to usb dev type*/ |
| 61 | extern USB_STORAGE_DEV_TYPE MS_Trans_Fs_Type(FS_DEVICE_TYPE_ENUM type); |
| 62 | extern kal_uint8 MS_Get_Max_LUN(void); |
| 63 | extern void MS_DeRegister_DiskDriver(kal_uint8 disk_index); |
| 64 | extern void MS_Change_Register_DiskDriver(kal_uint8 disk_index, USB_DiskDriver_STRUCT *disk_api); |
| 65 | extern USB_STORAGE_DEV_STATUS MS_Checkmedia_Exist(kal_uint8 LUN); |
| 66 | extern kal_bool MS_Format(kal_uint8 LUN); |
| 67 | extern kal_bool MS_Read_Capacity(kal_uint8 LUN, kal_uint32 *max_lba, kal_uint32 *lba_len); |
| 68 | //extern kal_bool MS_Read_FormatCapacity(kal_uint8 LUN, kal_uint32 *max_lba, kal_uint32 *sec_len); |
| 69 | extern kal_bool MS_Read_Write(MS_DIRECTION direct, void *dev_t,qbm_gpd *head,qbm_gpd *tail, kal_uint16 lba_num); |
| 70 | extern kal_bool MS_Prevmedia_Removal(kal_uint8 LUN, kal_bool enable); |
| 71 | extern USB_STORAGE_DEV_TYPE MS_Dev_Type(kal_uint8 LUN); |
| 72 | extern kal_uint8 MS_Register_DiskDriver(USB_DiskDriver_STRUCT *disk_api); |
| 73 | extern kal_uint8 MS_Set_Current_Driver(kal_uint32 drv); |
| 74 | extern kal_uint32 MS_Get_Current_Driver(void); |
| 75 | extern void MS_Adapter_Deinit(void); |
| 76 | extern void MS_Init_Normal_Mode(void); |
| 77 | extern void MS_End_Normal_Mode(void); |
| 78 | extern kal_uint16 MS_Query_Max_BD_Num(kal_uint8 LUN); |
| 79 | extern void FAT_Init(void); |
| 80 | |
| 81 | #endif |
| 82 | |
| 83 | |