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

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

[avr-libc-dev] [EEPROM] patch: Fix mis-feature of lacking EEPROM support


From: Björn Haase
Subject: [avr-libc-dev] [EEPROM] patch: Fix mis-feature of lacking EEPROM support for many targets / rewrite of eeprom functions
Date: Sun, 10 Jul 2005 21:38:00 +0200
User-agent: KMail/1.7.1

Hi,

find enclosed a re-write of the AVR eeprom routines that 1.) fixes the bug of 
lacking support for many targets and 2.) uses a more code-efficient 
implementation.

The patch does not rely on a complete multi-lib build. (Presently there are 
only two different positions of the EEPROM registers.) Providing an entire 
per-device lib only because of EEPROM handling seems to be an overkill. 
Instead my patch derives from one single eeprom.s several object modules for 
all of the different (presently two) locations of the eeprom registers.

1.) The eeprom.s now honors the new #define symbols 
EEPROM_REG_LOCATIONS_OVERRIDE (for overriding avr/io.h settings by -D option) 
and __EEPROM_REG_LOCATIONS__ (to be defined in avr/io.h for controllers 
deviating from the default addresses). These symbols are meant to contain the 
hex addresses of the three individual EEPROM access registers (EEDR, EEAR and 
EECR).
2.) The build system is changed such that it generates from one source file 
several object files. One for each known location of the EEPROM register set, 
thus currently two.

The calling convention of the EEPROM functions has been changed. Now the 
eeprom address consistently is passed in X registers (read byte, read block 
and write byte and write block). For read byte and write byte the __tmp_reg__ 
is used for passing values. The byte access functions now implement an 
auto-increment feature for the x register so that the write word functions 
could now be replaced without code size penalties by two byte access calls. 
The corresponding expanders are defined as inline functions.

The supplied block transfer functions are now only used for known constant 
loop count <= 256. The transfer functions uses the zero register as loop 
counter. They receive the ram addresses in the z register. For larger or 
variable moves, the patterns generate small inline sequences within the 
calling function's code.

I have also included a EEMEM define symbol for setting the section attributes 
of variables in EE memory space.

The main benefit of the new patterns is that the compiler now can exploit that 
the eeprom access routines do not change almost any register. My observation 
is that this helps much reducing code size, particularly if the application 
is having lots of scattered eeprom accesses.

Yours,

Björn

2005-07-07  Bjoern Haase <address@hidden>

        * include/avr/eeprom.h: re-write of all functions 
        and documentation update. EEMEM, add.
        * include/avr/iocan128.h: __EEPROM_REG_LOCATIONS__ define
        * include/avr/iom165.h, include/avr/iom169.h: Ditto.
        * include/avr/iom325.h, include/avr/iom3250.h: Ditto.
        * include/avr/iom645.h, include/avr/iom6450.h: Ditto.
        * include/avr/iomx8.h: Ditto.
        * libc/misc/Makefile.am: 
        lib_a_asm_sources modify, eeprom_asm_sources add,
        lib_a_LIBADD add, lib_a_DEPENDENCIES add
        rule "%.1C1D1E.o: %.S" add, rule "%.1F2021.o: %.S" add
        * libc/misc/eeprom.S: complete re-write
        * libc/misc/ee_rw.S, libc/misc/ee/ww.S: remove

Attachment: eeprom_fix.patch
Description: Text Data


reply via email to

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