/* #define DISABLE_LOGS */ #define MSG_BUFF_SZ (10*1024*1024) #define MAX_INT_ITF 1024 #define MSG_QBYTES 20*MSG_BUFF_SZ #define ENABLE_DAC #define SCHED_PRIO 40 #define SCHED_TYPE SCHED_FIFO #define EXEC_PRIO 50 #define BRIDGE_PRIO 30 #define SYNC_PRIO 45 #define SND_PRIO SCHED_PRIO+5 #define RCV_PRIO SCHED_PRIO+5 #define DEFAULT_INTERNAL_BW 10000000 #define TS_ERROR_FRAC 10 #define FILE_SEPARATOR_CH '/' /* default path for daemons config file */ #define DEFAULT_DAEMONS_FILE "/usr/local/etc/platform.conf" /* default path for xitf config file */ #define DEFAULT_XITF_FILE "/usr/local/etc/xitf.conf" /* base phal path */ #define DEFAULT_RES_PATH "/etc/phal/" /* path for lock files */ #define LOCK_PATH "/tmp/" #define LOCK_PREFIX "phdefault" #define LOCK_FILE "lock" /* path to downloaded new processes */ #define RCV_PROC_PATH "/tmp/" #define DEFAULT_CPU_MIPS 0 #define DEF_FILE_LEN SYSTEM_STR_MAX_LEN /* Shared memory configuration */ #define HW_API_SHM_KEY 0xAA #define HW_API_MSG_KEY 0x11 #define DATA_MSG_KEY 0x22 #define SEMAPHORE_KEY 0xFF /** structure for keeping path of daemons to launch */ struct launch_daemons { char path[SYSTEM_STR_MAX_LEN]; char output[SYSTEM_STR_MAX_LEN]; int pid; time_t cpu[3]; int cpu_usec; int last_finish; int semid; }; #define MAX_EXT_ITF 10 /* external network interfaces config db */ struct ext_itf { xitfid_t id; int mode; int port; char address[15]; int pid; int bpid; int fsock; int fd; int in_mbox_id; int out_mbox_id; hwitf_t in_key_id; hwitf_t out_key_id; int type; struct hwapi_xitf_i info; }; /** Network Database */ struct net_db { int nof_ext_itf; pid_t net_chld; char full_bridge; char litendian; struct ext_itf ext_itf[MAX_EXT_ITF]; }; /* database sizes */ #define MAX_CORES 32 #define MAX_PROCS 250 /** In linux, this can't be greater than linux/sem.h SEMMSL constant */ #define MAX_DAEMONS 15 #define MAX_VARS 2000 #define DAC_NSAMPLES_MAX (1024*1024) #define VAR_TABLE_SZ (500*1024) #define ITF_OPT_EXTERNAL 0xF00 #define ITF_OPT_URGENT 0xFF #define ITF_OPT_URGENT_W 0xF0 #define ITF_OPT_URGENT_R 0x0F #define ITF_OPT_BLOCKING 0xF000 /** Internal interface database */ struct int_itf { int id; hwitf_t key_id; char r_obj[SYSTEM_STR_MAX_LEN]; char w_obj[SYSTEM_STR_MAX_LEN]; char r_itf[SYSTEM_STR_MAX_LEN]; char w_itf[SYSTEM_STR_MAX_LEN]; int opts; hwitf_t remote_id; int delay; int network_pid; int network_bpid; int callback_pid; void (*callback) (hwitf_t); }; struct proc_time { time_t sys_syscpu; time_t sys_usrcpu; time_t lst_syscpu; time_t lst_usrcpu; int scnt; int ucnt; int last_cntxt; }; struct dac_cfg { struct dac_interface *ptr; char filename[128]; int ts_len; int NsamplesIn; int NsamplesOut; float dacinbuff[DAC_NSAMPLES_MAX]; float dacoutbuff[DAC_NSAMPLES_MAX]; }; /** Common HW-API database */ struct hw_api_db { /** network db (see below */ struct net_db net_db; /** daemons structure */ struct launch_daemons daemons[MAX_DAEMONS]; /** internal interfaces */ struct int_itf int_itf[MAX_INT_ITF]; /** process database */ struct hwapi_proc_i proc_db[MAX_PROCS]; int semids[MAX_CORES]; int semdaemons; struct proc_time proc_time[MAX_PROCS]; /** variable database */ struct hwapi_var_i var_db[MAX_VARS]; /* variable data contents */ char var_table[VAR_TABLE_SZ]; /** cpu information */ struct hwapi_cpu_i cpu_info; /** zero time reference */ time_t init_time; int sync_ts; int exec_pid; int exec_slot_div; int memCnt; char flushout; char printbt_atexit; char printbt_atterm; int default_delay; int numsamples; struct dac_cfg dac; char lock_file[DEF_FILE_LEN]; int status_sem_id; char run_as_daemon; char priority; char do_nice; char output_file[DEF_FILE_LEN]; char report_file[DEF_FILE_LEN]; char res_path[DEF_FILE_LEN]; }; #define MSG_MAGIC 0x1321 /** Runph Daemon message commands */ #define HWD_SETUP_XITF 0x0 #define HWD_CREATE_XITF 0x1 #define HWD_DAEMON_INIT 0x2 #define HWD_RESTART_XITF 0x3 #define HWD_CREATE_PROCESS 0x4 #define HWD_REMOVE_PROCESS 0x5 #define HWD_READ_XITF_CFG 0x6 #define HWD_RUN_PROCESS 0x7 /* some constants for internal messaging */ #define TSTAMP_PKT_BITS 4 #define TSTAMP_PKT_MASK 0xF #define TSTAMP_MAX_RED 15 /* packet message header */ struct msghead { long dst; /* message type, must be > 0 */ long src; int opts; int tstamp; }; /** message buffer structure */ struct msgbuff { struct msghead head; char body[MSG_BUFF_SZ]; }; #define MSG_SZ (sizeof(struct msgbuff)) #define MSG_HEAD_SZ (sizeof(struct msghead)) int send_urgent_signal(struct int_itf *itf_db, hwitf_t itf_id); #ifdef ENABLE_DAC void close_dac(); int configure_dac (struct dac_cfg *dac, int sid, int sidx); #endif