I found the answer in the official MIPS documentation:
7.3 Software detection of the DSP ASE
You can find out if your core supports the DSP ASE by testing the Config3[DDSP] bit (see notes to Figure 2.4).
Then you need to enable use of instructions from the MIPS DSP ASE by setting Status[MX] to 1.
Programming the MIPS32® 24KE™ Core Family, p. 73
So I wanted to make detection, whether the DSP ASE is present on the chip, by reading the Config3 register:
dsp.c:
Code:
/*
MIPS DSP ASE test
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
unsigned int k;
printf("\n\nDSP instructions test\n\n");
/*
Get the contents of Config3 register (CP0[16,3])
*/
printf("Trying to read Config3 register ...\n");
k=({ int __res; \
__asm__ __volatile__( \
"mfc0\t%0,$16,3\n\t" \
: "=r" (__res)); \
__res;});
printf("Config3 register: %x",k);
exit(0);
}
Makefile:
Code:
TARGET = dsp
SHELL = /bin/sh
CCDIR = /opt/slug/optware/toolchain/mipsel-linux-uclibc/gcc-4.1.1-uclibc-0.9.28
MIPSCC = $(CCDIR)/bin/mipsel-linux-uclibc-gcc
SOURCE = $(TARGET).c
PARAMS = -march="mips32r2" -mtune="mips32r2" -mdsp -static
$(TARGET) : $(SOURCE)
$(MIPSCC) $(SOURCE) -o $(TARGET) $(PARAMS)
@echo "OK."
asm : $(SOURCE)
$(MIPSCC) $(SOURCE) -o $(TARGET).asm $(PARAMS) -S
@echo "ASM OK."
Compilation is OK, but when I try to run the program on my router, the message is still same:
Illegal instruction
It is maybe more global problem. Should I have some special permission of the operating system?
I use Optware compiler (uClibc). I got it from nslu2-linux.org. Instalation instructions are in the middle of the page under heading And what if the program I need is not available in the existing packages?
My router runs on Oleg firmware.