NUC472_NUC442_BSP V3.03.005
The Board Support Package for NUC472/NUC442
Umas.h
Go to the documentation of this file.
1
2#ifndef _UMAS_H_
3#define _UMAS_H_
4
5#include "UmasScsi.h"
6
7
9
10#define UMAS_MAX_DEV 1
11
12#undef DEBUG
13//#define DEBUG
14//#define UMAS_VERBOSE_DEBUG
15
16/* Debug Options */
17#ifdef UMAS_VERBOSE_DEBUG
18#define UMAS_DEBUG printf
19#define UMAS_VDEBUG printf
20#else
21#ifdef DEBUG
22#define UMAS_DEBUG printf
23#else
24#define UMAS_DEBUG(...)
25#endif
26#define UMAS_VDEBUG(...)
27#endif
28
29struct umas_data;
30
31/*
32 * Unusual device list definitions
33 */
34
35typedef struct umas_unusual_dev
36{
37 uint8_t useProtocol;
38 uint8_t useTransport;
39} UMAS_UUDEV_T;
40
41
42/* Flag definitions */
43#define UMAS_FL_SINGLE_LUN 0x00000001 /* allow access to only LUN 0 */
44#define UMAS_FL_MODE_XLATE 0x00000002 /* translate _6 to _10 commands for
45 Win/MacOS compatibility */
46#define UMAS_FL_START_STOP 0x00000004 /* ignore START_STOP commands */
47#define UMAS_FL_IGNORE_SER 0x00000010 /* Ignore the serial number given */
48#define UMAS_FL_SCM_MULT_TARG 0x00000020 /* supports multiple targets */
49
50typedef int (*trans_cmnd)(SCSI_CMD_T *, struct umas_data *);
51typedef int (*trans_reset)(struct umas_data *);
52typedef void (*proto_cmnd)(SCSI_CMD_T*, struct umas_data *);
53
54
55struct umas_drive;
56
57/* we allocate one of these for every device that we remember */
58typedef struct umas_data /* LINUX: struct us_data */
59{
60 USB_DEV_T *pusb_dev; /* this usb_device */
61 uint16_t vendor_id;
62 uint16_t product_id;
63 uint32_t sector_size;
64 uint32_t sector_number;
65
66 /* information about the device -- only good if device is attached */
67 uint8_t ifnum; /* interface number */
68 uint8_t ep_in; /* bulk in endpoint */
69 uint8_t ep_out; /* bulk out endpoint */
70 int ep_int; /* interrupt endpoint */
71
72 struct umas_data *next; /* next device */
73 uint32_t flags; /* from filter initially */
74
75 /* information about the device -- always good */
76 char *transport_name;
77 char *protocol_name;
78 uint8_t subclass;
79 uint8_t protocol;
80 uint8_t max_lun;
81
82 /* function pointers for this device */
83 trans_cmnd transport; /* transport function */
84 trans_reset transport_reset; /* transport device reset */
85 proto_cmnd proto_handler; /* protocol handler */
86
87 /* SCSI interfaces */
88 SCSI_CMD_T srb; /* current srb */
89
90 int ip_wanted; /* is an IRQ expected? (atomic_t) */
91 URB_T *current_urb; /* non-int USB requests */
92 URB_T *irq_urb; /* for USB int requests */
93 uint8_t irqbuf[4]; /* buffer for USB IRQ */
94 uint8_t irqdata[2]; /* data from USB IRQ */
95
96 UMAS_UUDEV_T *unusual_dev; /* If unusual device */
97 struct umas_drive *drive_list;
98} UMAS_DATA_T;
99
100
101typedef struct umas_drive
102{
103 UMAS_DATA_T *umas;
104 uint8_t lun_no;
105 void *client; /* file system client data */
106 struct umas_drive *next; /* next device */
107} UMAS_DRIVE_T;
108
109
110
111/*======================================================= Global Variables ==*/
112
113/* The structure which defines our driver */
114extern USB_DRIVER_T _UsbMassStorageDriver; /* LINUX: usb_storage_driver */
115
116
117/*===================================================== Exported Functions ==*/
118extern int UMAS_InitUmasDriver(void);
119
120extern int UMAS_InitUmasDevice(UMAS_DATA_T *umas);
121
122extern void UMAS_ScanAllDevice(void);
123extern void UMAS_ScanDeviceLun(UMAS_DATA_T *umas);
124
125/*
126 * Debug helper routines, in UsbDebug.c
127 */
128extern void UMAS_DEBUG_ShowCommand(SCSI_CMD_T *srb);
129extern void UMAS_DEBUG_PrintScsiCommand(SCSI_CMD_T *cmd);
130
131#include "UmasProtocol.h"
132#include "UmasTransport.h"
133
135
136#endif /* _UMAS_H_ */
HIDDEN_SYMBOLS struct usb_device USB_DEV_T