/** * \file mcctrl.h * License details are found in the file LICENSE. * \brief * define data structure * \author Taku Shimosawa \par * Copyright (C) 2011 - 2012 Taku Shimosawa * \author Balazs Gerofi \par * Copyright (C) 2012 RIKEN AICS * \author Gou Nakamura \par * Copyright (C) 2012 - 2013 Hitachi, Ltd. * \author Tomoki Shirasawa \par * Copyright (C) 2012 - 2013 Hitachi, Ltd. * \author Balazs Gerofi \par * Copyright (C) 2013 The University of Tokyo */ /* * HISTORY: * 2013/11/07 hamada added which is required by getrlimit(2) * 2013/10/21 nakamura exclude interpreter's segment from data region * 2013/10/11 nakamura mcexec: add a upper limit of the stack size * 2013/10/11 nakamura mcexec: add a path prefix for interpreter search * 2013/10/11 nakamura mcexec: add a interpreter invocation * 2013/10/08 nakamura add a AT_ENTRY entry to the auxiliary vector * 2013/09/02 shirasawa add terminate thread * 2013/08/19 shirasawa mcexec forward signal to MIC process * 2013/08/07 nakamura add page fault forwarding * 2013/07/26 shirasawa mcexec print signum or exit status * 2013/07/17 nakamura create more mcexec thread so that all cpu to be serviced * 2013/04/17 nakamura add generic system call forwarding */ #ifndef HEADER_MCCTRL_H #define HEADER_MCCTRL_H #include #include #include #include #include #include #include #include #include "sysfs.h" #define SCD_MSG_PREPARE_PROCESS 0x1 #define SCD_MSG_PREPARE_PROCESS_ACKED 0x2 #define SCD_MSG_PREPARE_PROCESS_NACKED 0x7 #define SCD_MSG_SCHEDULE_PROCESS 0x3 #define SCD_MSG_INIT_CHANNEL 0x5 #define SCD_MSG_INIT_CHANNEL_ACKED 0x6 #define SCD_MSG_SYSCALL_ONESIDE 0x4 #define SCD_MSG_SEND_SIGNAL 0x8 #define SCD_MSG_CLEANUP_PROCESS 0x9 #define SCD_MSG_PROCFS_CREATE 0x10 #define SCD_MSG_PROCFS_DELETE 0x11 #define SCD_MSG_PROCFS_REQUEST 0x12 #define SCD_MSG_PROCFS_ANSWER 0x13 #define SCD_MSG_DEBUG_LOG 0x20 #define SCD_MSG_SYSFS_REQ_CREATE 0x30 /* #define SCD_MSG_SYSFS_RESP_CREATE 0x31 */ #define SCD_MSG_SYSFS_REQ_MKDIR 0x32 /* #define SCD_MSG_SYSFS_RESP_MKDIR 0x33 */ #define SCD_MSG_SYSFS_REQ_SYMLINK 0x34 /* #define SCD_MSG_SYSFS_RESP_SYMLINK 0x35 */ #define SCD_MSG_SYSFS_REQ_LOOKUP 0x36 /* #define SCD_MSG_SYSFS_RESP_LOOKUP 0x37 */ #define SCD_MSG_SYSFS_REQ_UNLINK 0x38 /* #define SCD_MSG_SYSFS_RESP_UNLINK 0x39 */ #define SCD_MSG_SYSFS_REQ_SHOW 0x3a #define SCD_MSG_SYSFS_RESP_SHOW 0x3b #define SCD_MSG_SYSFS_REQ_STORE 0x3c #define SCD_MSG_SYSFS_RESP_STORE 0x3d #define SCD_MSG_SYSFS_REQ_RELEASE 0x3e #define SCD_MSG_SYSFS_RESP_RELEASE 0x3f #define SCD_MSG_SYSFS_REQ_SETUP 0x40 #define SCD_MSG_SYSFS_RESP_SETUP 0x41 /* #define SCD_MSG_SYSFS_REQ_CLEANUP 0x42 */ /* #define SCD_MSG_SYSFS_RESP_CLEANUP 0x43 */ #define DMA_PIN_SHIFT 21 #define DO_USER_MODE #define __NR_coredump 999 struct coretable { int len; unsigned long addr; }; struct ikc_scd_packet { int msg; int err; union { /* for traditional SCD_MSG_* */ struct { int ref; int osnum; int pid; int padding; unsigned long arg; }; /* for SCD_MSG_SYSFS_* */ struct { long sysfs_arg1; long sysfs_arg2; long sysfs_arg3; }; }; }; struct mcctrl_priv { ihk_os_t os; struct program_load_desc *desc; }; struct ikc_scd_init_param { unsigned long request_page; unsigned long response_page; unsigned long doorbell_page; unsigned long post_page; }; struct syscall_post { unsigned long v[8]; }; struct syscall_params { unsigned long request_pa; struct syscall_request *request_va; unsigned long response_rpa, response_pa; struct syscall_response *response_va; unsigned long post_pa; struct syscall_post *post_va; unsigned long doorbell_pa; unsigned long *doorbell_va; }; struct wait_queue_head_list_node { struct list_head list; wait_queue_head_t wq_syscall; int pid; int req; }; struct mcctrl_channel { struct ihk_ikc_channel_desc *c; struct syscall_params param; struct ikc_scd_init_param init; void *dma_buf; struct list_head wq_list; ihk_spinlock_t wq_list_lock; }; struct mcctrl_per_proc_data { struct list_head list; int pid; unsigned long rpgtable; /* per process, not per OS */ }; struct sysfsm_req { int busy; int padding; long lresult; wait_queue_head_t wq; }; struct sysfsm_data { size_t sysfs_bufsize; void *sysfs_buf; long sysfs_buf_rpa; long sysfs_buf_pa; struct kobject *sysfs_kobj; struct sysfsm_node *sysfs_root; struct semaphore sysfs_tree_sem; struct semaphore sysfs_io_sem; struct sysfsm_req sysfs_req; ihk_os_t sysfs_os; }; static inline int sysfs_inited(struct sysfsm_data *sdp) { return !!(sdp->sysfs_buf); } /* sysfs_inited() */ struct mcctrl_usrdata { struct ihk_ikc_listen_param listen_param; struct ihk_ikc_listen_param listen_param2; ihk_os_t os; int num_channels; struct mcctrl_channel *channels; unsigned long *mcctrl_doorbell_va; unsigned long mcctrl_doorbell_pa; int remaining_job; int base_cpu; int job_pos; int mcctrl_dma_abort; unsigned long last_thread_exec; wait_queue_head_t wq_prepare; struct list_head per_proc_list; ihk_spinlock_t per_proc_list_lock; void **keys; struct sysfsm_data sysfsm_data; }; struct mcctrl_signal { int cond; int sig; int pid; int tid; char info[128]; }; int mcctrl_ikc_send(ihk_os_t os, int cpu, struct ikc_scd_packet *pisp); int mcctrl_ikc_send_msg(ihk_os_t os, int cpu, int msg, int ref, unsigned long arg); int mcctrl_ikc_is_valid_thread(ihk_os_t os, int cpu); int reserve_user_space(struct mcctrl_usrdata *usrdata, unsigned long *startp, unsigned long *endp); /* syscall.c */ int init_peer_channel_registry(struct mcctrl_usrdata *ud); void destroy_peer_channel_registry(struct mcctrl_usrdata *ud); int register_peer_channel(struct mcctrl_usrdata *ud, void *key, struct mcctrl_channel *ch); int deregister_peer_channel(struct mcctrl_usrdata *ud, void *key, struct mcctrl_channel *ch); struct mcctrl_channel *get_peer_channel(struct mcctrl_usrdata *ud, void *key); int __do_in_kernel_syscall(ihk_os_t os, struct mcctrl_channel *c, struct syscall_request *sc); #define PROCFS_NAME_MAX 1000 struct procfs_read { unsigned long pbuf; /* physical address of the host buffer (request) */ unsigned long offset; /* offset to read (request) */ int count; /* bytes to read (request) */ int eof; /* if eof is detected, 1 otherwise 0. (answer)*/ int ret; /* read bytes (answer) */ int status; /* non-zero if done (answer) */ int newcpu; /* migrated new cpu (answer) */ char fname[PROCFS_NAME_MAX]; /* procfs filename (request) */ }; struct procfs_file { int status; /* status of processing (answer) */ int mode; /* file mode (request) */ char fname[PROCFS_NAME_MAX]; /* procfs filename (request) */ }; /* sysfs_files.c */ void setup_sysfs_files(ihk_os_t os); #endif