2014-08-28 16:56:48 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "elf_loader.h"
|
|
|
|
#include "corecom.h"
|
|
|
|
#include "gpio.h"
|
|
|
|
#include "rtio.h"
|
|
|
|
#include "dds.h"
|
|
|
|
#include "symbols.h"
|
|
|
|
|
|
|
|
static const struct symbol syscalls[] = {
|
2014-09-05 12:03:22 +08:00
|
|
|
{"rpc", rpc},
|
|
|
|
{"gpio_set", gpio_set},
|
|
|
|
{"rtio_set", rtio_set},
|
|
|
|
{"rtio_sync", rtio_sync},
|
|
|
|
{"dds_program", dds_program},
|
|
|
|
{NULL, NULL}
|
2014-08-28 16:56:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static long long int gcd64(long long int a, long long int b)
|
|
|
|
{
|
2014-09-05 12:03:22 +08:00
|
|
|
long long int c;
|
2014-08-28 16:56:48 +08:00
|
|
|
|
2014-09-05 12:03:22 +08:00
|
|
|
while(a) {
|
|
|
|
c = a;
|
|
|
|
a = b % a;
|
|
|
|
b = c;
|
|
|
|
}
|
|
|
|
return b;
|
2014-08-28 16:56:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct symbol arithmetic[] = {
|
2014-09-05 12:03:22 +08:00
|
|
|
{"__gcd64", gcd64},
|
|
|
|
{NULL, NULL}
|
2014-08-28 16:56:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void *resolve_symbol(const char *name)
|
|
|
|
{
|
2014-09-05 12:03:22 +08:00
|
|
|
if(strncmp(name, "__syscall_", 10) == 0)
|
|
|
|
return find_symbol(syscalls, name + 10);
|
|
|
|
return find_symbol(arithmetic, name);
|
2014-08-28 16:56:48 +08:00
|
|
|
}
|