I have the following C source files which need to have some code removed and some code added to bypass the data cache on the Nios_2_r2c processor. I have no clue how to do this.
File: switches.c
#include "system.h"
#include "pio_regs.h"
#include "bsu_macros.h"
#include "switches.h"
static struct pio_regs *SW = (struct pio_regs *)SWITCH_BASE;
static REGISTER SH_SW;
bits get_RUN ( void ) {
SH_SW = SW->data;
return getbit(SH_SW, 17);
}
File: ledr.c
#include "system.h"
#include "pio_regs.h"
#include "bsu_macros.h"
#include "ledr.h"
static struct pio_regs *LEDR = (struct pio_regs *)LEDR_BASE;
static REGISTER SH_LEDR;
void LEDR_Init ( void ) {
SH_LEDR = 0;
LEDR->data = 0;
}
void show_RUN ( bits RUN ) {
SH_LEDR = putbit (SH_LEDR, RUN, 12);
LEDR->data = SH_LEDR;
}
Got it with inline assembly using I/O read and writes:
File: switches.c
#include "system.h"
#include "pio_regs.h"
#include "bsu_macros.h"
#include "switches.h"
static struct pio_regs *SW = (struct pio_regs *)SWITCH_BASE;
static REGISTER SH_SW;
bits get_RUN ( void ) {
//SH_SW = SW->data;
__asm("ldwio %0, %1" : "=r"(SH_SW) : "m"(SW->data));
return getbit(SH_SW, 17);
}
File: ledr.c
#include "system.h"
#include "pio_regs.h"
#include "bsu_macros.h"
#include "ledr.h"
static struct pio_regs *LEDR = (struct pio_regs *)LEDR_BASE;
static REGISTER SH_LEDR;
void LEDR_Init ( void ) {
SH_LEDR = 0;
//LEDR->data = 0;
__asm("stwio %0, %1" : "=r"(SH_LEDR) : "m"(SW->data));
}
void show_RUN ( bits RUN ) {
SH_LEDR = putbit (SH_LEDR, RUN, 12);
//LEDR->data = SH_LEDR;
__asm("stwio %0, %1" : "=r"(SH_SW) : "m"(SW->data));
}