opal_flash.c (2aaf9152a852aba9eb2036b95f4948ee77988826) | opal_flash.c (3c8c50f955d2a33816a1e9b3af2636cda08b427f) |
---|---|
1/*- 2 * Copyright (c) 2019 Justin Hibbits 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 161 unchanged lines hidden (view full) --- 170 return (EIO); 171 172 token = opal_alloc_async_token(); 173 174 /* 175 * Read one page at a time. It's not guaranteed that the buffer is 176 * physically contiguous. 177 */ | 1/*- 2 * Copyright (c) 2019 Justin Hibbits 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 161 unchanged lines hidden (view full) --- 170 return (EIO); 171 172 token = opal_alloc_async_token(); 173 174 /* 175 * Read one page at a time. It's not guaranteed that the buffer is 176 * physically contiguous. 177 */ |
178 rv = 0; |
|
178 while (count > 0) { 179 size = MIN(count, PAGE_SIZE); | 179 while (count > 0) { 180 size = MIN(count, PAGE_SIZE); |
181 size = MIN(size, PAGE_SIZE - ((u_long)data & PAGE_MASK)); |
|
180 rv = opal_call(OPAL_FLASH_READ, sc->sc_opal_id, off, 181 vtophys(data), size, token); | 182 rv = opal_call(OPAL_FLASH_READ, sc->sc_opal_id, off, 183 vtophys(data), size, token); |
182 if (rv == OPAL_ASYNC_COMPLETION) | 184 if (rv == OPAL_ASYNC_COMPLETION) { |
183 rv = opal_wait_completion(&msg, sizeof(msg), token); | 185 rv = opal_wait_completion(&msg, sizeof(msg), token); |
186 if (rv == OPAL_SUCCESS) 187 rv = msg.params[1]; 188 } |
|
184 if (rv != OPAL_SUCCESS) 185 break; 186 count -= size; 187 off += size; | 189 if (rv != OPAL_SUCCESS) 190 break; 191 count -= size; 192 off += size; |
193 data += size; |
|
188 } 189 opal_free_async_token(token); 190 if (rv == OPAL_SUCCESS) 191 rv = 0; 192 else 193 rv = EIO; 194 195 return (rv); --- 8 unchanged lines hidden (view full) --- 204 /* Ensure we write aligned to a full block size. */ 205 if (off % sc->sc_disk->d_stripesize != 0 || 206 count % sc->sc_disk->d_stripesize != 0) 207 return (EIO); 208 209 token = opal_alloc_async_token(); 210 211 rv = opal_call(OPAL_FLASH_ERASE, sc->sc_opal_id, off, count, token); | 194 } 195 opal_free_async_token(token); 196 if (rv == OPAL_SUCCESS) 197 rv = 0; 198 else 199 rv = EIO; 200 201 return (rv); --- 8 unchanged lines hidden (view full) --- 210 /* Ensure we write aligned to a full block size. */ 211 if (off % sc->sc_disk->d_stripesize != 0 || 212 count % sc->sc_disk->d_stripesize != 0) 213 return (EIO); 214 215 token = opal_alloc_async_token(); 216 217 rv = opal_call(OPAL_FLASH_ERASE, sc->sc_opal_id, off, count, token); |
212 if (rv == OPAL_ASYNC_COMPLETION) | 218 if (rv == OPAL_ASYNC_COMPLETION) { |
213 rv = opal_wait_completion(&msg, sizeof(msg), token); | 219 rv = opal_wait_completion(&msg, sizeof(msg), token); |
220 if (rv == OPAL_SUCCESS) 221 rv = msg.params[1]; 222 } |
|
214 opal_free_async_token(token); 215 216 if (rv == OPAL_SUCCESS) 217 rv = 0; 218 else 219 rv = EIO; 220 221 return (rv); --- 19 unchanged lines hidden (view full) --- 241 token = opal_alloc_async_token(); 242 243 /* 244 * Write one page at a time. It's not guaranteed that the buffer is 245 * physically contiguous. 246 */ 247 while (count > 0) { 248 size = MIN(count, PAGE_SIZE); | 223 opal_free_async_token(token); 224 225 if (rv == OPAL_SUCCESS) 226 rv = 0; 227 else 228 rv = EIO; 229 230 return (rv); --- 19 unchanged lines hidden (view full) --- 250 token = opal_alloc_async_token(); 251 252 /* 253 * Write one page at a time. It's not guaranteed that the buffer is 254 * physically contiguous. 255 */ 256 while (count > 0) { 257 size = MIN(count, PAGE_SIZE); |
258 size = MIN(size, PAGE_SIZE - ((u_long)data & PAGE_MASK)); |
|
249 rv = opal_call(OPAL_FLASH_WRITE, sc->sc_opal_id, off, 250 vtophys(data), size, token); | 259 rv = opal_call(OPAL_FLASH_WRITE, sc->sc_opal_id, off, 260 vtophys(data), size, token); |
251 if (rv == OPAL_ASYNC_COMPLETION) | 261 if (rv == OPAL_ASYNC_COMPLETION) { |
252 rv = opal_wait_completion(&msg, sizeof(msg), token); | 262 rv = opal_wait_completion(&msg, sizeof(msg), token); |
263 if (rv == OPAL_SUCCESS) 264 rv = msg.params[1]; 265 } |
|
253 if (rv != OPAL_SUCCESS) 254 break; 255 count -= size; 256 off += size; | 266 if (rv != OPAL_SUCCESS) 267 break; 268 count -= size; 269 off += size; |
270 data += size; |
|
257 } 258 opal_free_async_token(token); 259 260 if (rv == OPAL_SUCCESS) 261 rv = 0; 262 else 263 rv = EIO; 264 --- 108 unchanged lines hidden --- | 271 } 272 opal_free_async_token(token); 273 274 if (rv == OPAL_SUCCESS) 275 rv = 0; 276 else 277 rv = EIO; 278 --- 108 unchanged lines hidden --- |