/* Support */
|
/* Support */
|
#include "spr_defs.h"
|
#include "spr_defs.h"
|
#include "support.h"
|
#include "support.h"
|
#include "int.h"
|
|
|
|
void int_main();
|
|
|
|
void ext_except(void) {
|
|
int_main();
|
|
}
|
|
|
|
/* Start function, called by reset exception handler. */
|
/* Start function, called by reset exception handler. */
|
static char *main_argv[2] = {"NULL", " "};
|
static char *main_argv[2] = {"NULL", " "};
|
|
|
void _main(void) {
|
void _main(void) {
|
int i = main(2, main_argv);
|
int i = main(2, main_argv);
|
or32_exit (i);
|
or32_exit (i);
|
}
|
}
|
|
|
/* return value by making a syscall */
|
/* return value by making a syscall */
|
void or32_exit(int i) {
|
void or32_exit(int i) {
|
asm("l.add r3,r0,%0": : "r" (i));
|
asm("l.add r3,r0,%0": : "r" (i));
|
asm("l.nop %0": :"K" (NOP_EXIT));
|
asm("l.nop %0": :"K" (NOP_EXIT));
|
while (1);
|
while (1);
|
}
|
}
|
|
|
|
|
/* print long */
|
/* print long */
|
void report(unsigned long value) {
|
void report(unsigned long value) {
|
asm("l.addi\tr3,%0,0": :"r" (value));
|
asm("l.addi\tr3,%0,0": :"r" (value));
|
asm("l.nop %0": :"K" (NOP_REPORT));
|
asm("l.nop %0": :"K" (NOP_REPORT));
|
}
|
}
|
|
|
/* For writing into SPR. */
|
/* For writing into SPR. */
|
void mtspr(unsigned long spr, unsigned long value) {
|
void mtspr(unsigned long spr, unsigned long value) {
|
asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
|
asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
|
}
|
}
|
|
|
/* For reading SPR. */
|
/* For reading SPR. */
|
unsigned long mfspr(unsigned long spr) {
|
unsigned long mfspr(unsigned long spr) {
|
unsigned long value;
|
unsigned long value;
|
asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
|
asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
|
return value;
|
return value;
|
}
|
}
|
|
|