Setting up repository
[linux-libre-firmware.git] / cis-tools / pcmcia / bulkmem.h
1 /*
2  * Definitions for bulk memory services
3  *
4  * The contents of this file are subject to the Mozilla Public License
5  * Version 2.0 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License
7  * at http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific language governing rights and
12  * limitations under the License. 
13  *
14  * The initial developer of the original code is David A. Hinds
15  * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
16  * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
17  *
18  * Alternatively, the contents of this file may be used under the
19  * terms of the GNU General Public License version 2 (the "GPL"), in
20  * which case the provisions of the GPL are applicable instead of the
21  * above.  If you wish to allow the use of your version of this file
22  * only under the terms of the GPL and not to allow others to use
23  * your version of this file under the MPL, indicate your decision by
24  * deleting the provisions above and replace them with the notice and
25  * other provisions required by the GPL.  If you do not delete the
26  * provisions above, a recipient may use your version of this file
27  * under either the MPL or the GPL.
28  */
29
30 #ifndef _LINUX_BULKMEM_H
31 #define _LINUX_BULKMEM_H
32
33 /* For GetFirstRegion and GetNextRegion */
34 typedef struct region_info_t {
35     u_int               Attributes;
36     u_int               CardOffset;
37     u_int               RegionSize;
38     u_int               AccessSpeed;
39     u_int               BlockSize;
40     u_int               PartMultiple;
41     u_char              JedecMfr, JedecInfo;
42     memory_handle_t     next;
43 } region_info_t;
44
45 #define REGION_TYPE             0x0001
46 #define REGION_TYPE_CM          0x0000
47 #define REGION_TYPE_AM          0x0001
48 #define REGION_PREFETCH         0x0008
49 #define REGION_CACHEABLE        0x0010
50 #define REGION_BAR_MASK         0xe000
51 #define REGION_BAR_SHIFT        13
52
53 /* For OpenMemory */
54 typedef struct open_mem_t {
55     u_int               Attributes;
56     u_int               Offset;
57 } open_mem_t;
58
59 /* Attributes for OpenMemory */
60 #define MEMORY_TYPE             0x0001
61 #define MEMORY_TYPE_CM          0x0000
62 #define MEMORY_TYPE_AM          0x0001
63 #define MEMORY_EXCLUSIVE        0x0002
64 #define MEMORY_PREFETCH         0x0008
65 #define MEMORY_CACHEABLE        0x0010
66 #define MEMORY_BAR_MASK         0xe000
67 #define MEMORY_BAR_SHIFT        13
68
69 typedef struct eraseq_entry_t {
70     memory_handle_t     Handle;
71     u_char              State;
72     u_int               Size;
73     u_int               Offset;
74     void                *Optional;
75 } eraseq_entry_t;
76
77 typedef struct eraseq_hdr_t {
78     int                 QueueEntryCnt;
79     eraseq_entry_t      *QueueEntryArray;
80 } eraseq_hdr_t;
81
82 #define ERASE_QUEUED            0x00
83 #define ERASE_IN_PROGRESS(n)    (((n) > 0) && ((n) < 0x80))
84 #define ERASE_IDLE              0xff
85 #define ERASE_PASSED            0xe0
86 #define ERASE_FAILED            0xe1
87
88 #define ERASE_MISSING           0x80
89 #define ERASE_MEDIA_WRPROT      0x84
90 #define ERASE_NOT_ERASABLE      0x85
91 #define ERASE_BAD_OFFSET        0xc1
92 #define ERASE_BAD_TECH          0xc2
93 #define ERASE_BAD_SOCKET        0xc3
94 #define ERASE_BAD_VCC           0xc4
95 #define ERASE_BAD_VPP           0xc5
96 #define ERASE_BAD_SIZE          0xc6
97
98 /* For CopyMemory */
99 typedef struct copy_op_t {
100     u_int               Attributes;
101     u_int               SourceOffset;
102     u_int               DestOffset;
103     u_int               Count;
104 } copy_op_t;
105
106 /* For ReadMemory and WriteMemory */
107 typedef struct mem_op_t {
108     u_int       Attributes;
109     u_int       Offset;
110     u_int       Count;
111 } mem_op_t;
112
113 #define MEM_OP_BUFFER           0x01
114 #define MEM_OP_BUFFER_USER      0x00
115 #define MEM_OP_BUFFER_KERNEL    0x01
116 #define MEM_OP_DISABLE_ERASE    0x02
117 #define MEM_OP_VERIFY           0x04
118
119 /* For RegisterMTD */
120 typedef struct mtd_reg_t {
121     u_int       Attributes;
122     u_int       Offset;
123     u_long      MediaID;
124 } mtd_reg_t;
125
126 /*
127  *  Definitions for MTD requests
128  */
129
130 typedef struct mtd_request_t {
131     u_int       SrcCardOffset;
132     u_int       DestCardOffset;
133     u_int       TransferLength;
134     u_int       Function;
135     u_long      MediaID;
136     u_int       Status;
137     u_int       Timeout;
138 } mtd_request_t;
139
140 /* Fields in MTD Function */
141 #define MTD_REQ_ACTION          0x003
142 #define MTD_REQ_ERASE           0x000
143 #define MTD_REQ_READ            0x001
144 #define MTD_REQ_WRITE           0x002
145 #define MTD_REQ_COPY            0x003
146 #define MTD_REQ_NOERASE         0x004
147 #define MTD_REQ_VERIFY          0x008
148 #define MTD_REQ_READY           0x010
149 #define MTD_REQ_TIMEOUT         0x020
150 #define MTD_REQ_LAST            0x040
151 #define MTD_REQ_FIRST           0x080
152 #define MTD_REQ_KERNEL          0x100
153
154 /* Status codes */
155 #define MTD_WAITREQ     0x00
156 #define MTD_WAITTIMER   0x01
157 #define MTD_WAITRDY     0x02
158 #define MTD_WAITPOWER   0x03
159
160 /*
161  *  Definitions for MTD helper functions
162  */
163
164 /* For MTDModifyWindow */
165 typedef struct mtd_mod_win_t {
166     u_int       Attributes;
167     u_int       AccessSpeed;
168     u_int       CardOffset;
169 } mtd_mod_win_t;
170
171 /* For MTDSetVpp */
172 typedef struct mtd_vpp_req_t {
173     u_char      Vpp1, Vpp2;
174 } mtd_vpp_req_t;
175
176 /* For MTDRDYMask */
177 typedef struct mtd_rdy_req_t {
178     u_int       Mask;
179 } mtd_rdy_req_t;
180
181 enum mtd_helper {
182     MTDRequestWindow, MTDModifyWindow, MTDReleaseWindow,
183     MTDSetVpp, MTDRDYMask
184 };
185
186 #endif /* _LINUX_BULKMEM_H */