[riot-notifications] [RIOT-OS/RIOT] Introduce ATxmega CPU and Boards (#15758)

Gerson Fernando Budke notifications at github.com
Fri Jan 29 14:59:05 CET 2021


@nandojve commented on this pull request.



> @@ -263,108 +297,131 @@ void avr8_exit_isr(void)
 __attribute__((always_inline)) static inline void avr8_context_save(void)
 {
     __asm__ volatile (
-        "push __tmp_reg__                    \n\t"
-        "in   __tmp_reg__, __SREG__          \n\t"
-        "cli                                 \n\t"
-        "push __tmp_reg__                    \n\t"
-#if defined(RAMPZ) && !defined(__AVR_ATmega32U4__)

At AVR-LIB (avr-libc/include/avr/iom32u4.h) the RAMPZ is defined.

The issue is, RAMPZ is only used if MCU have more than 64k words (128k bytes) flash.
The (E)LPM instruction are used for self programming but this MCU only have 32k bytes flash. So, "RAMPZ" will be always 0 in my understanding.

This is the why I switch from registers definitions to flash/ram size. The flash/ram size always will tell the truth about AVR-8 registers. The HW depends on special registers to do run some instructions. I tried to capture all the rules as macros at beginning of file. This allows apply when appropriated on a clear way.

```
#define CHECK_EIND_REG          FLASHEND > 0x1ffff

#if defined(DATAMEM_SIZE)
#define CHECK_RAMPZ_REG         DATAMEM_SIZE > 0xffff || FLASHEND > 0xffff
#define CHECK_RAMPDXY_REG       DATAMEM_SIZE > 0xffff
#else
#define CHECK_RAMPZ_REG         FLASHEND > 0xffff
#define CHECK_RAMPDXY_REG       0
#endif

#if (CHECK_EIND_REG)
#ifndef __EIND__
#define __EIND__                0x3C
#endif
#endif
```

These means, if the program can resides below 128k flash AND don't address above, the context switch can be optimized for bigger devices. Same thinking can be applied to RAMP-D, X, Y.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15758#discussion_r566839603
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210129/075b3742/attachment-0001.htm>


More information about the notifications mailing list