Browse Source

First cut of formal ABI definition, so that the same definition can be

used to generate the function table in lsi as the header file which
code can include to get a matching ABI definition.
master
Gavan Fantom 18 years ago
parent
commit
10ac321771
  1. 11
      src/lsi/Makefile
  2. 40
      src/lsi/abi.h
  3. 39
      src/lsi/abispec
  4. 50
      src/lsi/makeabi
  5. 70
      src/lsi/vm.c

11
src/lsi/Makefile

@ -5,6 +5,9 @@ PREFIX?= /usr/local
OBJS= main.o vm.o plugins.o dmx.o midi.o beatdetect.o fft.o map3d.o mouse.o OBJS= main.o vm.o plugins.o dmx.o midi.o beatdetect.o fft.o map3d.o mouse.o
SRCS= main.c vm.c plugins.c dmx.c midi.c beatdetect.c fft.c map3d.c mouse.c SRCS= main.c vm.c plugins.c dmx.c midi.c beatdetect.c fft.c map3d.c mouse.c
OBJS+= abi.o
SRCS+= abi.c
COMMONOBJS= mem.o hash.o COMMONOBJS= mem.o hash.o
COMMONDIR= ../common COMMONDIR= ../common
@ -20,6 +23,12 @@ PROGOBJS= ${OBJS} ${COMMONOBJS:S/^/${COMMONDIR}\//}
lsi: ${OBJS} lsi: ${OBJS}
${LINK.c} -o ${.TARGET} ${PROGOBJS} ${LDLIBS} ${LINK.c} -o ${.TARGET} ${PROGOBJS} ${LDLIBS}
abi.c: abispec makeabi
./makeabi abispec
abi.lh: abispec makeabi
./makeabi abispec
install: lsi install: lsi
${INSTALL} -d ${PREFIX}/bin ${INSTALL} -d ${PREFIX}/bin
${INSTALL} -c lsi ${PREFIX}/bin/lsi ${INSTALL} -c lsi ${PREFIX}/bin/lsi
@ -28,4 +37,4 @@ depend:
mkdep -- ${CFLAGS} ${CPPFLAGS} ${SRCS} mkdep -- ${CFLAGS} ${CPPFLAGS} ${SRCS}
clean: clean:
rm -f ${OBJS} lsi rm -f ${OBJS} lsi abi.c abi.lh

40
src/lsi/abi.h

@ -0,0 +1,40 @@
/* abi.h */
typedef int (*vm_intfn)(void);
/*
* We must include here all prototypes for functions which can be
* included in the ABI function table
*/
int vm_intfn_nop(void);
int vm_intfn_global_store(void);
int vm_intfn_global_load(void);
int vm_intfn_global_array_store(void);
int vm_intfn_global_array_load(void);
int vm_intfn_printint(void);
int vm_intfn_printreal(void);
int vm_intfn_printstr(void);
int vm_intfn_dmxsetchannel(void);
int vm_intfn_dmxoutput(void);
int vm_intfn_gettime(void);
int vm_intfn_waittime(void);
int vm_intfn_wait(void);
int vm_intfn_wakeup(void);
int vm_intfn_spawn(void);
int vm_intfn_midi_read(void);
int vm_intfn_beatdetect_read(void);
int vm_intfn_beatdetect_phase(void);
int vm_intfn_beatdetect_confidence(void);
int vm_intfn_realtoint(void);
int vm_intfn_inttoreal(void);
int vm_intfn_map3d_setcal(void);
int vm_intfn_map3d_calibrate(void);
int vm_intfn_map3d_transform(void);
int vm_intfn_map3d_setparams(void);
int vm_intfn_map3d_load(void);
int vm_intfn_map3d_save(void);
int vm_intfn_sin(void);
int vm_intfn_cos(void);
int vm_intfn_random(void);
int vm_intfn_mouse_read(void);

39
src/lsi/abispec

@ -0,0 +1,39 @@
/* This should be a master file specifying all aspects of ABI */
/* Function assignments */
function nop
function global_store
function global_load
function global_array_store
function global_array_load
function printint
function printreal
function printstr
function dmxsetchannel
function dmxoutput
function gettime
function waittime
function wait
function wakeup
function spawn
function midi_read
function beatdetect_read
function beatdetect_phase
function beatdetect_confidence
funciton realtoint
function inttoreal
function map3d_setcal
function map3d_calibrate
function map3d_transform
function map3d_setparams
function map3d_load
function map3d_save
function sin
function cos
function random
function mouse_read
/*
* The ABI should be identified by a SHA1 hash of this file
*/

50
src/lsi/makeabi

@ -0,0 +1,50 @@
#!/bin/sh
INFILE=$1
if [ "X${INFILE}" = "X" ]
then
echo "Usage: $0 abispec"
exit 1
fi
ABI=abi.c
HEADER=abi.lh
FNCOUNT=0
do_function()
{
echo " vm_intfn_${ARG1}," >>${ABI}
echo "fndefint ${ARG1} ${FNCOUNT};" >>${HEADER}
FNCOUNT=$((${FNCOUNT}+1))
}
cat <<EOF >${ABI}
/* abi.c */
/* autogenerated - do not edit */
#include "abi.h"
vm_intfn vm_intfn_table[] = {
EOF
cat <<EOF >${HEADER}
/* abi.lh */
/* autogenerated - do not edit */
EOF
while read TYPE ARG1 ARG2
do
case "$TYPE" in
function) do_function
;;
esac
done <${INFILE}
cat <<EOF >>${ABI}
};
const int vm_intfn_size = sizeof(vm_intfn_table) / sizeof(vm_intfn);
EOF

70
src/lsi/vm.c

@ -67,78 +67,14 @@ struct hashentry *arrayhash[HASHSIZE];
#define GLOB_MAXNAMELEN 1024 #define GLOB_MAXNAMELEN 1024
int vm_intfn_nop(void);
int vm_intfn_global_store(void);
int vm_intfn_global_load(void);
int vm_intfn_global_array_store(void);
int vm_intfn_global_array_load(void);
int vm_intfn_printint(void);
int vm_intfn_printreal(void);
int vm_intfn_printstr(void);
int vm_intfn_dmxsetchannel(void);
int vm_intfn_dmxoutput(void);
int vm_intfn_gettime(void);
int vm_intfn_waittime(void);
int vm_intfn_wait(void);
int vm_intfn_wakeup(void);
int vm_intfn_spawn(void);
int vm_intfn_midi_read(void);
int vm_intfn_beatdetect_read(void);
int vm_intfn_beatdetect_phase(void);
int vm_intfn_beatdetect_confidence(void);
int vm_intfn_realtoint(void);
int vm_intfn_inttoreal(void);
int vm_intfn_map3d_setcal(void);
int vm_intfn_map3d_calibrate(void);
int vm_intfn_map3d_transform(void);
int vm_intfn_map3d_setparams(void);
int vm_intfn_map3d_load(void);
int vm_intfn_map3d_save(void);
int vm_intfn_sin(void);
int vm_intfn_cos(void);
int vm_intfn_random(void);
int vm_intfn_mouse_read(void);
void vm_destroy(struct vm_thread *); void vm_destroy(struct vm_thread *);
void vm_unqueue(struct vm_thread *); void vm_unqueue(struct vm_thread *);
void vm_queue(struct vm_thread *, int); void vm_queue(struct vm_thread *, int);
typedef int (*vm_intfn)(void); #include "abi.h"
vm_intfn vm_intfn_table[] = {
vm_intfn_nop,
vm_intfn_global_store,
vm_intfn_global_load,
vm_intfn_global_array_store,
vm_intfn_global_array_load,
vm_intfn_printint,
vm_intfn_printreal,
vm_intfn_printstr,
vm_intfn_dmxsetchannel,
vm_intfn_dmxoutput,
vm_intfn_gettime,
vm_intfn_waittime,
vm_intfn_wait,
vm_intfn_wakeup,
vm_intfn_spawn,
vm_intfn_midi_read,
vm_intfn_beatdetect_read,
vm_intfn_beatdetect_phase,
vm_intfn_beatdetect_confidence,
vm_intfn_realtoint,
vm_intfn_inttoreal,
vm_intfn_map3d_setcal,
vm_intfn_map3d_calibrate,
vm_intfn_map3d_transform,
vm_intfn_map3d_setparams,
vm_intfn_map3d_load,
vm_intfn_map3d_save,
vm_intfn_sin,
vm_intfn_cos,
vm_intfn_random,
vm_intfn_mouse_read,
};
const int vm_intfn_size = sizeof(vm_intfn_table) / sizeof(vm_intfn); extern vm_intfn vm_intfn_table[];
extern const int vm_intfn_size;
void stack_push(struct vm_thread *thread, stkentry e); void stack_push(struct vm_thread *thread, stkentry e);
void stack_pop(struct vm_thread *thread, int count); void stack_pop(struct vm_thread *thread, int count);

Loading…
Cancel
Save