diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 1b77464d..41573d2b 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -46,6 +46,16 @@ extern int mc_cmd_server_init(); extern void mc_cmd_server_exit(); extern void mc_cmd_handle(int fd, int cpu, unsigned long args[6]); +#ifdef CMD_DCFA +extern void ibmic_cmd_server_exit(); +extern int ibmic_cmd_server_init(); +#endif + +#ifdef CMD_DCFAMPI +extern void dcfampi_cmd_server_exit(); +extern int dcfampi_cmd_server_init(); +#endif + int __glob_argc = -1; char **__glob_argv = 0; #endif @@ -431,6 +441,20 @@ int main(int argc, char **argv) /** * TODO: need mutex for static structures */ +#ifdef CMD_DCFA + if(ibmic_cmd_server_init()){ + fprintf(stderr, "Error: Failed to initialize ibmic_cmd_server.\n"); + return -1; + } +#endif + +#ifdef CMD_DCFAMPI + if(dcfampi_cmd_server_init()){ + fprintf(stderr, "Error: Failed to initialize dcfampi_cmd_server.\n"); + return -1; + } +#endif + if(mc_cmd_server_init()){ fprintf(stderr, "Error: cmd server init failed\n"); return 1; @@ -695,6 +719,14 @@ int main_loop(int fd, int cpu, pthread_mutex_t *lock) #ifdef USE_SYSCALL_MOD_CALL mc_cmd_server_exit(); +#ifdef CMD_DCFA + ibmic_cmd_server_exit(); +#endif + +#ifdef CMD_DCFAMPI + dcfampi_cmd_server_exit(); +#endif + __dprint("mccmd server exited\n"); #endif exit(0); diff --git a/kernel/Makefile.build.mpiu b/kernel/Makefile.build.dcfa old mode 100755 new mode 100644 similarity index 74% rename from kernel/Makefile.build.mpiu rename to kernel/Makefile.build.dcfa index fa333ca3..f504f6e1 --- a/kernel/Makefile.build.mpiu +++ b/kernel/Makefile.build.dcfa @@ -4,8 +4,14 @@ OBJS += process.o copy.o waitq.o futex.o timer.o DEPSRCS=$(wildcard $(SRC)/*.c) CFLAGS += -I$(SRC)/include -mcmodel=kernel -D__KERNEL__ -CFLAGS += -DDCFA_KMOD -DKNC_MAP_MICPA -DCONFIG_$(CONFIG_V) +CFLAGS += -DKNC_MAP_MICPA -DCONFIG_$(CONFIG_V) $(EXTRA_CFLAGS) +ifeq ("$(DCFA_V)", "k") +CFLAGS += -DDCFA_RUN +else +CFLAGS += -DDCFA_KMOD +endif + LDFLAGS += -e arch_start IHKOBJ = ihk/ihk.o @@ -24,16 +30,28 @@ mkimage_cmd_base = [ -f $(SRC)/script/mkimage.$(TARGET) ] && CC=$(CC) LD=$(LD) L ld_kern_cmd = $(call echo_cmd,LDKERN,$@)$(ld_kern_cmd_base) mkimage_cmd = $(call echo_cmd,MKIMAGE,$@)$(mkimage_cmd_base) -all: depend kernel.img +P_OBJ ?= ./a.out + +all: kernel.img kernel.img: $(OBJS) $(IHKOBJ) $(EXTRA_OBJS) $(ld_kern_cmd) $(mkimage_cmd) -clean: - $(rm_cmd) $(OBJS) kernel.img kernel.img.elf Makefile.dep +kobj: depend $(KERNEL_OBJ) + +$(KERNEL_OBJ): $(OBJS) $(IHKOBJ) + @echo ' ' [with] $^ + $(ld_cmd) + +umod_clean: + $(rm_cmd) $(OBJS) $(IHKOBJ) kernel.img kernel.img.elf Makefile.dep @$(submake) -C $(IHKBASE) $(SUBCMD_OPTS) clean +kmod_clean: + $(rm_cmd) $(OBJS) $(IHKOBJ) $(KERNEL_OBJ) Makefile.dep + @$(submake) -C $(IHKBASE) $(SUBCMD_OPTS) clean + depend: Makefile.dep Makefile.dep: diff --git a/kernel/Makefile.build.dcfa.public b/kernel/Makefile.build.dcfa.public new file mode 100644 index 00000000..605f9892 --- /dev/null +++ b/kernel/Makefile.build.dcfa.public @@ -0,0 +1,24 @@ +IHKDIR=$(IHKBASE)/$(TARGETDIR) + +LDFLAGS += -e arch_start + +include $(SRC)/config/config.$(TARGET) +include $(IHKBASE)/Makefile.common + +ld_kern_cmd_base = $(LD) $(LDFLAGS) -o $@.elf $^ +mkimage_cmd_base = [ -f $(SRC)/script/mkimage.$(TARGET) ] && CC=$(CC) LD=$(LD) LDFLAGS="$(LDFLAGS_MKIMAGE)" OBJDUMP=$(OBJDUMP) OBJCOPY=$(OBJCOPY) sh $(SRC)/script/mkimage.$(TARGET) '$@.elf' '$@' '$(SRC)' || cp $@.elf $@ + +ld_kern_cmd = $(call echo_cmd,LDKERN,$@)$(ld_kern_cmd_base) +mkimage_cmd = $(call echo_cmd,MKIMAGE,$@)$(mkimage_cmd_base) + +P_OBJ ?= ./a.out + +all: kernel_program.img + +kernel_program.img: $(KERNEL_OBJ) $(P_OBJ) + $(ld_kern_cmd) + $(mkimage_cmd) + +FORCE: + +-include Makefile.dep diff --git a/kernel/Makefile.dcfa b/kernel/Makefile.dcfa new file mode 100644 index 00000000..fae0f6f7 --- /dev/null +++ b/kernel/Makefile.dcfa @@ -0,0 +1,102 @@ +BUILD_TARGET ?= attached-mic +SRC = $(CURDIR) +IHKBASE ?= $(SRC)/../../ihk/cokernel +INSTALL_KL_DIR ?= ./ + +O ?= $(KBUILD_OUTPUT) +N ?= kernel_obj.o +V ?= $(VERBOSE) + +CONFIG_V ?= KNF +DCFA_V ?= u + +EXTRA_OBJS ?= + +## compile items + +KERNEL = kernel.img +KERNELS = $(addsuffix /$(KERNEL),$(addprefix $(O)/,$(BUILD_TARGET))) + +KERNEL_OBJ = $(addsuffix /$(N),$(addprefix $(O)/,$(BUILD_TARGET))) +KERNEL_MAKEFILE = $(addsuffix /Makefile,$(addprefix $(O)/,$(BUILD_TARGET))) + +## install items + +ifeq ("$(DCFA_V)", "k") +KERNEL_OBJ_PUB = $(INSTALL_KL_DIR)/$(N) +KERNEL_MAKEFILE_PUB = $(INSTALL_KL_DIR)/Makefile +else +KERNELS_PUB = $(INSTALL_KL_DIR)/$(KERNEL) +KERNEL_MAKEFILE_PUB = $(INSTALL_KL_DIR)/Makefile +endif + +SUBCMD_OPTS = V='$(V)' + +$(if $(O),,$(error Specify the compilation target directory)) +#$(if $(shell ls $(IHKBASE)/Makefile),,\ +# $(error IHK is not found in $(IHKBASE))) + + +.PHONY: kmod umod clean depend +.SECONDARY: $(KERNEL_MAKEFILE) $(KERNEL_MAKEFILE_PUB) + +kmod: $(KERNEL_OBJ) + +umod: $(KERNELS) + +umod_install: + @echo install $(KERNELS_PUB) + @rm -f $(KERNELS_PUB) + @mkdir -p $(dir $(KERNELS_PUB)) + @cp $(KERNELS) $(KERNELS_PUB) + +kmod_install: $(KERNEL_MAKEFILE_PUB) + @echo install $(KERNEL_OBJ_PUB) + @rm -f $(KERNEL_OBJ_PUB) + @cp $(KERNEL_OBJ) $(KERNEL_OBJ_PUB) + +%/kernel.img: %/Makefile + @echo 'Building for' $(dir $@) + @make --no-print-directory -C $(dir $@) $(SUBCMD_OPTS) + +%/$(N): %/Makefile + @echo 'Building for' $(dir $@) + @make kobj --no-print-directory -C $(dir $@) $(SUBCMD_OPTS) + +$(KERNEL_MAKEFILE): Makefile.build.dcfa + rm -f $@ + @mkdir -p $(dir $@) + @echo 'SRC = $(SRC)' > $@ + @echo 'IHKBASE = $(IHKBASE)' >> $@ + @echo 'TARGET = $(notdir $(patsubst %/,%,$(dir $@)))' >> $@ + @echo 'TARGETDIR = $$(shell echo $$(TARGET) | sed "s/-/\//")' >> $@ + @echo 'CONFIG_V = $(CONFIG_V)' >> $@ + @echo 'DCFA_V = $(DCFA_V)' >> $@ + @echo 'KERNEL_OBJ = $(KERNEL_OBJ)' >> $@ + @echo 'EXTRA_OBJS = $(EXTRA_OBJS)' >> $@ + @echo 'EXTRA_CFLAGS = $(EXTRA_CFLAGS)' >> $@ + @cat $^ >> $@ +# @rm -f $(dir $@)/Makefile.dep + +$(KERNEL_MAKEFILE_PUB): Makefile.build.dcfa.public + @echo install $@ + @rm -f $@ + @mkdir -p $(dir $@) + @echo 'SRC = $(SRC)' > $@ + @echo 'IHKBASE = $(IHKBASE)' >> $@ + @echo 'TARGET = $(BUILD_TARGET)' >> $@ + @echo 'TARGETDIR = $$(shell echo $$(TARGET) | sed "s/-/\//")' >> $@ + @echo 'KERNEL_OBJ = $(KERNEL_OBJ_PUB)' >> $@ + @cat $^ >> $@ + +umod_clean: $(addsuffix .umod_clean,$(BUILD_TARGET)) + +kmod_clean: $(addsuffix .kmod_clean,$(BUILD_TARGET)) + +%.umod_clean: $(O)/%/Makefile + @make --no-print-directory -C $(O)/$(basename $@) $(SUBCMD_OPTS) umod_clean + +%.kmod_clean: $(O)/%/Makefile + @make --no-print-directory -C $(O)/$(basename $@) $(SUBCMD_OPTS) kmod_clean + +FORCE: diff --git a/kernel/Makefile.mpiu b/kernel/Makefile.mpiu deleted file mode 100755 index 3e30dc1f..00000000 --- a/kernel/Makefile.mpiu +++ /dev/null @@ -1,47 +0,0 @@ -BUILD_TARGET ?= attached-mic -SRC = $(CURDIR) - -IHKBASE ?= $(SRC)/../../ihk/cokernel -O ?= $(KBUILD_OUTPUT) -V ?= $(VERBOSE) - -CONFIG_V ?= KNF - -EXTRA_OBJS ?= - -KERNEL = kernel.img -KERNELS = $(addsuffix /$(KERNEL),$(addprefix $(O)/,$(BUILD_TARGET))) - -SUBCMD_OPTS = V='$(V)' - -$(if $(O),,$(error Specify the compilation target directory)) -#$(if $(shell ls $(IHKBASE)/Makefile),,\ -# $(error IHK is not found in $(IHKBASE))) - - -.PHONY: all clean depend - -all: $(KERNELS) - -%/kernel.img: %/Makefile - @echo 'Building for' $(dir $@) - @make --no-print-directory -C $(dir $@) $(SUBCMD_OPTS) - -%/Makefile: Makefile.build.mpiu FORCE - rm -f $@ - @mkdir -p $(dir $@) - @echo 'SRC = $(SRC)' > $@ - @echo 'IHKBASE = $(IHKBASE)' >> $@ - @echo 'TARGET = $(notdir $(patsubst %/,%,$(dir $@)))' >> $@ - @echo 'TARGETDIR = $$(shell echo $$(TARGET) | sed "s/-/\//")' >> $@ - @echo 'CONFIG_V = $(CONFIG_V)' >> $@ - @echo 'EXTRA_OBJS = $(EXTRA_OBJS)' >> $@ - @cat Makefile.build.mpiu >> $@ - @rm -f $(dir $@)/Makefile.dep - -clean: $(addsuffix .clean,$(BUILD_TARGET)) - -%.clean: $(O)/%/Makefile - @make --no-print-directory -C $(O)/$(basename $@) $(SUBCMD_OPTS) clean - -FORCE: diff --git a/kernel/syscall.c b/kernel/syscall.c index 227fe18c..611847fa 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -1070,18 +1070,31 @@ SYSCALL_DECLARE(noop) #ifdef DCFA_KMOD +#ifdef CMD_DCFA extern int ibmic_cmd_syscall(char *uargs); -extern int dcfampi_cmd_syscall(char *uargs); extern void ibmic_cmd_exit(int status); +#endif + +#ifdef CMD_DCFAMPI +extern int dcfampi_cmd_syscall(char *uargs); +#endif static int (*mod_call_table[]) (char *) = { +#ifdef CMD_DCFA [1] = ibmic_cmd_syscall, +#endif +#ifdef CMD_DCFAMPI [2] = dcfampi_cmd_syscall, +#endif }; static void (*mod_exit_table[]) (int) = { +#ifdef CMD_DCFA [1] = ibmic_cmd_exit, +#endif +#ifdef CMD_DCFAMPI [2] = NULL, +#endif }; SYSCALL_DECLARE(mod_call) { @@ -1096,6 +1109,8 @@ SYSCALL_DECLARE(mod_call) { if(mod_call_table[mod_id]) return mod_call_table[mod_id]((char*)uargs); + kprintf("ERROR! undefined mod_call id:%d\n", mod_id); + return -ENOSYS; }