~ubuntu-branches/ubuntu/trusty/avr-libc/trusty-proposed

« back to all changes in this revision

Viewing changes to include/avr/boot.h

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2009-10-31 11:52:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091031115210-crjd42sn6ezrj52c
Tags: 1:1.6.7-1
* New upstream relese (closes: #544030)
* Added lintian overrides (closes: #553265)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
27
  POSSIBILITY OF SUCH DAMAGE. */
28
28
 
29
 
/* $Id: boot.h,v 1.27.2.2 2008/05/06 22:04:13 arcanum Exp $ */
 
29
/* $Id: boot.h,v 1.27.2.5 2009/04/25 21:29:10 arcanum Exp $ */
30
30
 
31
31
#ifndef _AVR_BOOT_H_
32
32
#define _AVR_BOOT_H_    1
195
195
#define __BOOT_PAGE_WRITE         (_BV(__SPM_ENABLE) | _BV(PGWRT))
196
196
#define __BOOT_PAGE_FILL          _BV(__SPM_ENABLE)
197
197
#define __BOOT_RWW_ENABLE         (_BV(__SPM_ENABLE) | _BV(__COMMON_ASRE))
 
198
#if defined(BLBSET)
198
199
#define __BOOT_LOCK_BITS_SET      (_BV(__SPM_ENABLE) | _BV(BLBSET))
 
200
#elif defined(RFLB)  /* Some devices have RFLB defined instead of BLBSET. */
 
201
#define __BOOT_LOCK_BITS_SET      (_BV(__SPM_ENABLE) | _BV(RFLB))
 
202
#endif
199
203
 
200
204
#define __boot_page_fill_normal(address, data)   \
201
205
(__extension__({                                 \
202
206
    __asm__ __volatile__                         \
203
207
    (                                            \
204
208
        "movw  r0, %3\n\t"                       \
205
 
        "movw r30, %2\n\t"                       \
206
209
        "sts %0, %1\n\t"                         \
207
210
        "spm\n\t"                                \
208
211
        "clr  r1\n\t"                            \
209
212
        :                                        \
210
213
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
211
214
          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
212
 
          "r" ((uint16_t)address),               \
 
215
          "z" ((uint16_t)address),               \
213
216
          "r" ((uint16_t)data)                   \
214
 
        : "r0", "r30", "r31"                     \
 
217
        : "r0"                                   \
215
218
    );                                           \
216
219
}))
217
220
 
220
223
    __asm__ __volatile__                         \
221
224
    (                                            \
222
225
        "movw  r0, %3\n\t"                       \
223
 
        "movw r30, %2\n\t"                       \
224
226
        "sts %0, %1\n\t"                         \
225
227
        "spm\n\t"                                \
226
228
        ".word 0xffff\n\t"                       \
229
231
        :                                        \
230
232
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
231
233
          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
232
 
          "r" ((uint16_t)address),               \
 
234
          "z" ((uint16_t)address),               \
233
235
          "r" ((uint16_t)data)                   \
234
 
        : "r0", "r30", "r31"                     \
 
236
        : "r0"                                   \
235
237
    );                                           \
236
238
}))
237
239
 
259
261
(__extension__({                                 \
260
262
    __asm__ __volatile__                         \
261
263
    (                                            \
262
 
        "movw r30, %2\n\t"                       \
263
264
        "sts %0, %1\n\t"                         \
264
265
        "spm\n\t"                                \
265
266
        :                                        \
266
267
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
267
268
          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
268
 
          "r" ((uint16_t)address)                \
269
 
        : "r30", "r31"                           \
 
269
          "z" ((uint16_t)address)                \
270
270
    );                                           \
271
271
}))
272
272
 
274
274
(__extension__({                                 \
275
275
    __asm__ __volatile__                         \
276
276
    (                                            \
277
 
        "movw r30, %2\n\t"                       \
278
277
        "sts %0, %1\n\t"                         \
279
278
        "spm\n\t"                                \
280
279
        ".word 0xffff\n\t"                       \
282
281
        :                                        \
283
282
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
284
283
          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
285
 
          "r" ((uint16_t)address)                \
286
 
        : "r30", "r31"                           \
 
284
          "z" ((uint16_t)address)                \
287
285
    );                                           \
288
286
}))
289
287
 
308
306
(__extension__({                                 \
309
307
    __asm__ __volatile__                         \
310
308
    (                                            \
311
 
        "movw r30, %2\n\t"                       \
312
309
        "sts %0, %1\n\t"                         \
313
310
        "spm\n\t"                                \
314
311
        :                                        \
315
312
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
316
313
          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
317
 
          "r" ((uint16_t)address)                \
318
 
        : "r30", "r31"                           \
 
314
          "z" ((uint16_t)address)                \
319
315
    );                                           \
320
316
}))
321
317
 
323
319
(__extension__({                                 \
324
320
    __asm__ __volatile__                         \
325
321
    (                                            \
326
 
        "movw r30, %2\n\t"                       \
327
322
        "sts %0, %1\n\t"                         \
328
323
        "spm\n\t"                                \
329
324
        ".word 0xffff\n\t"                       \
331
326
        :                                        \
332
327
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
333
328
          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
334
 
          "r" ((uint16_t)address)                \
335
 
        : "r30", "r31"                           \
 
329
          "z" ((uint16_t)address)                \
336
330
    );                                           \
337
331
}))
338
332
 
491
485
    uint8_t __result;                                      \
492
486
    __asm__ __volatile__                                   \
493
487
    (                                                      \
494
 
        "ldi r30, %3\n\t"                                  \
495
 
        "ldi r31, 0\n\t"                                   \
496
488
        "sts %1, %2\n\t"                                   \
497
489
        "lpm %0, Z\n\t"                                    \
498
490
        : "=r" (__result)                                  \
499
491
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),                  \
500
492
          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
501
 
          "M" (address)                                    \
502
 
        : "r0", "r30", "r31"                               \
 
493
          "z" ((uint16_t)address)                          \
503
494
    );                                                     \
504
495
    __result;                                              \
505
496
}))