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