Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

10.4. Nios® II Device Driver Cache Considerations

Device drivers typically access control registers associated with their device. These registers are mapped into the Nios® II address space. When accessing device registers, the data cache must be bypassed to ensure that accesses are not lost or deferred due to the data cache.

When writing a device driver, bypass the data cache with the ldio/stio family of instructions. On Nios® II cores without a data cache, these instructions behave just like their corresponding ld/st instructions, and therefore are benign.

Note: Declaring a C pointer volatile does not make pointer accesses bypass the data cache. The volatile keyword merely prevents the compiler from optimizing out accesses using the pointer. This volatile behavior is different from the methodology for the first-generation Nios processor.