summaryrefslogtreecommitdiff
path: root/linux/pcmcia-cs/include/pcmcia/bulkmem.h
blob: 7748d44329e36e9e37d38fb4e522e999050f33c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 * Definitions for bulk memory services
 *
 * bulkmem.h 1.13 2001/08/24 12:16:12
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License
 * at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and
 * limitations under the License. 
 *
 * The initial developer of the original code is David A. Hinds
 * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
 *
 * Alternatively, the contents of this file may be used under the
 * terms of the GNU General Public License version 2 (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of the
 * above.  If you wish to allow the use of your version of this file
 * only under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting the provisions above and replace them with the notice and
 * other provisions required by the GPL.  If you do not delete the
 * provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL.
 * bulkmem.h 1.3 1995/05/27 04:49:49
 */

#ifndef _LINUX_BULKMEM_H
#define _LINUX_BULKMEM_H

/* For GetFirstRegion and GetNextRegion */
typedef struct region_info_t {
    u_int		Attributes;
    u_int		CardOffset;
    u_int		RegionSize;
    u_int		AccessSpeed;
    u_int		BlockSize;
    u_int		PartMultiple;
    u_char		JedecMfr, JedecInfo;
    memory_handle_t	next;
} region_info_t;

#define REGION_TYPE		0x0001
#define REGION_TYPE_CM		0x0000
#define REGION_TYPE_AM		0x0001
#define REGION_PREFETCH		0x0008
#define REGION_CACHEABLE	0x0010
#define REGION_BAR_MASK		0xe000
#define REGION_BAR_SHIFT	13

/* For OpenMemory */
typedef struct open_mem_t {
    u_int		Attributes;
    u_int		Offset;
} open_mem_t;

/* Attributes for OpenMemory */
#define MEMORY_TYPE		0x0001
#define MEMORY_TYPE_CM		0x0000
#define MEMORY_TYPE_AM		0x0001
#define MEMORY_EXCLUSIVE	0x0002
#define MEMORY_PREFETCH		0x0008
#define MEMORY_CACHEABLE	0x0010
#define MEMORY_BAR_MASK		0xe000
#define MEMORY_BAR_SHIFT	13

typedef struct eraseq_entry_t {
    memory_handle_t	Handle;
    u_char		State;
    u_int		Size;
    u_int		Offset;
    void		*Optional;
} eraseq_entry_t;

typedef struct eraseq_hdr_t {
    int			QueueEntryCnt;
    eraseq_entry_t	*QueueEntryArray;
} eraseq_hdr_t;

#define ERASE_QUEUED		0x00
#define ERASE_IN_PROGRESS(n)	(((n) > 0) && ((n) < 0x80))
#define ERASE_IDLE		0xff
#define ERASE_PASSED		0xe0
#define ERASE_FAILED		0xe1

#define ERASE_MISSING		0x80
#define ERASE_MEDIA_WRPROT	0x84
#define ERASE_NOT_ERASABLE	0x85
#define ERASE_BAD_OFFSET	0xc1
#define ERASE_BAD_TECH		0xc2
#define ERASE_BAD_SOCKET	0xc3
#define ERASE_BAD_VCC		0xc4
#define ERASE_BAD_VPP		0xc5
#define ERASE_BAD_SIZE		0xc6

/* For CopyMemory */
typedef struct copy_op_t {
    u_int		Attributes;
    u_int		SourceOffset;
    u_int		DestOffset;
    u_int		Count;
} copy_op_t;

/* For ReadMemory and WriteMemory */
typedef struct mem_op_t {
    u_int	Attributes;
    u_int	Offset;
    u_int	Count;
} mem_op_t;

#define MEM_OP_BUFFER		0x01
#define MEM_OP_BUFFER_USER	0x00
#define MEM_OP_BUFFER_KERNEL	0x01
#define MEM_OP_DISABLE_ERASE	0x02
#define MEM_OP_VERIFY		0x04

/* For RegisterMTD */
typedef struct mtd_reg_t {
    u_int	Attributes;
    u_int	Offset;
    u_long	MediaID;
} mtd_reg_t;

/*
 *  Definitions for MTD requests
 */

typedef struct mtd_request_t {
    u_int	SrcCardOffset;
    u_int	DestCardOffset;
    u_int	TransferLength;
    u_int	Function;
    u_long	MediaID;
    u_int	Status;
    u_int	Timeout;
} mtd_request_t;

/* Fields in MTD Function */
#define MTD_REQ_ACTION		0x003
#define MTD_REQ_ERASE		0x000
#define MTD_REQ_READ		0x001
#define MTD_REQ_WRITE		0x002
#define MTD_REQ_COPY		0x003
#define MTD_REQ_NOERASE		0x004
#define MTD_REQ_VERIFY		0x008
#define MTD_REQ_READY		0x010
#define MTD_REQ_TIMEOUT		0x020
#define MTD_REQ_LAST		0x040
#define MTD_REQ_FIRST		0x080
#define MTD_REQ_KERNEL		0x100

/* Status codes */
#define MTD_WAITREQ	0x00
#define MTD_WAITTIMER	0x01
#define MTD_WAITRDY	0x02
#define MTD_WAITPOWER	0x03

/*
 *  Definitions for MTD helper functions
 */

/* For MTDModifyWindow */
typedef struct mtd_mod_win_t {
    u_int	Attributes;
    u_int	AccessSpeed;
    u_int	CardOffset;
} mtd_mod_win_t;

/* For MTDSetVpp */
typedef struct mtd_vpp_req_t {
    u_char	Vpp1, Vpp2;
} mtd_vpp_req_t;

/* For MTDRDYMask */
typedef struct mtd_rdy_req_t {
    u_int	Mask;
} mtd_rdy_req_t;

enum mtd_helper {
    MTDRequestWindow, MTDModifyWindow, MTDReleaseWindow,
    MTDSetVpp, MTDRDYMask
};

#ifdef IN_CARD_SERVICES
extern int MTDHelperEntry(int func, void *a1, void *a2);
#else
extern int MTDHelperEntry(int func, ...);
#endif

#endif /* _LINUX_BULKMEM_H */