avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] [bug #25120] pgm_read_*_far() functions cause incorrect u


From: Luke Morrison
Subject: [avr-libc-dev] [bug #25120] pgm_read_*_far() functions cause incorrect usage of the Z pointer for RAM access in ATxmega series
Date: Thu, 18 Dec 2008 15:35:27 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4

URL:
  <http://savannah.nongnu.org/bugs/?25120>

                 Summary: pgm_read_*_far() functions cause incorrect usage of
the Z pointer for RAM access in ATxmega series
                 Project: AVR C Runtime Library
            Submitted by: lfmorrison
            Submitted on: Thu 18 Dec 2008 03:35:25 PM GMT
                Category: Header
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Header files
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: Any
           Fixed Release: None

    _______________________________________________________

Details:

The pgm_read_*_far() functions manipulate the RAMPZ register but do not
restore it when they are finished.

This behavior is usually safe for any part with 64 KiB or less of data memory
address space, because the RAMPZ register is only ever used in relation to the
ELPM instruction.  Saving and restoring the RAMPZ register would normally be
an unnecessary waste of cycles and Flash in such circumstances.

However, with the ATxmega series of devices, the RAMPZ register is also used
every time any indirect data memory access happens through the Z pointer via
the normal LD and ST instructions.  As soon as one of the pgm_read_*_far()
functions is invoked, the RAMPZ register will be left in a modified state,
rendering any subsequent compiler-generated indirect access of data memory
through the Z pointer invalid.  This also makes pgm_read_*_far()
interrupt-unsafe on such devices.

Possible fixes include:
1) Modify the pgm_read_*_far() functions to save and restore the RAMPZ
register if the functions are used in a device which also uses RAMPZ as part
of its normal indirect data access.
2) Modify GCC so that it never uses the Z pointer to indirectly access data
memory on a device which also uses RAMPZ as part of its normal indirect data
access.
3) Modify GCC to set the RAMPZ register appropriately (initially this might
mean simply zeroing it) every time it begins accessing data memory through the
Z pointer on a device which uses also RAMPZ as part of its normal indirect
data access.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?25120>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]