- Rearranged directory structure for forking out ANSTO

- Refactored site specific stuff into a site module
- PSI specific stuff is now in the PSI directory.
- The old version has been tagged with pre-ansto
This commit is contained in:
cvs
2003-06-20 10:18:47 +00:00
commit 064ec37e9a
271 changed files with 115513 additions and 0 deletions

299
sinqhm/FOCUS_gbl.h Executable file
View File

@ -0,0 +1,299 @@
/*======================================= [...SinqHM]FOCUS_gbl.h - Ident V01B
**
** Include file of Gbl Variables for FOCUS_srv and its children.
*/
#ifndef uint
#define uint unsigned int
#endif
#ifndef usint
#define usint unsigned short int
#endif
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef MAX_SLV
#define MAX_SLV 3
#endif
/*
**==================== Global Variables ======================================
** Note:
** On VxWorks, all these global variables are visible by all tasks.
** Any changes to them should therefore only be done if protected
** by a semaphore.
**
** At present, only the parent process changes these variables in a
** 'significant' way (I don't count updating diagnostic counters such
** as FS_bytes_got!).
*/
int FS_errno;
int FS_cnt_SIGUSR1;
char FS_host[32];
char FS_addr[20];
int FS_dbg_mask; /* This is the log'l or of FS_dbg_lev0, etc */
int FS_dbg_lev0, FS_dbg_lev1, FS_dbg_lev2, FS_dbg_lev3;
int FS_cfgn_done; /* == 0 if FOCUS_srv not configured */
/*
** The buffer for holding Hist Mem data is pointed to
** by FS_base_addr.
*/
void *FS_base_addr;
uint FS_mode_ALL; /* The "total" mode of the histogram memory */
uint FS_mode; /* The basic mode of the histogram memory */
uint FS_mode_DEBUG; /* The SQHM__DEBUG bit of FS_mode_ALL */
uint FS_mode_UD; /* The SQHM__UD bit of FS_mode_ALL */
uint FS_mode_BO; /* The SQHM__BO bits of FS_mode_ALL */
uint FS_mode_STROBO; /* The SQHM__STROBO bit of FS_mode_ALL */
uint FS_mode_REFLECT; /* The SQHM__REFLECT bit of FS_mode_ALL */
uint FS_mode_NO_STAT; /* The SQHM__NO_STAT bit of FS_mode_ALL */
uint FS_lo_cntr; /* The first counter in TOF mode */
uint FS_hi_cntr; /* The last counter in TOF mode */
uint FS_lo_bin; /* The first bin of the histogram */
uint FS_hi_bin; /* The last bin of the histogram */
uint FS_bpb; /* The number of bytes per bin */
uint FS_compress; /* The bin compression factor */
uint FS_totl_bytes; /* The total number of bytes of histogram mem */
SEM_ID FS_sem_daq; /* Semaphore to guard FS_dsbl_mask */
usint FS_dsbl_mask; /* The data-acq disable mask */
usint FS_srv_masks[MAX_CLIENTS+1]; /* The daq masks for ..
** .. servers (0 is mask of ..
** .. master process). */
/*--------------------------------------*/
time_t FS_start_time; /* The time that FOCUS-main started */
uint FS_port;
int FS_cnct_skt;
int FS_rw_skt;
pid_t FS_pid; /* PID of Master Process */
pid_t FS_pids[MAX_CLIENTS+1]; /* Index 0 = Filler (not present for
** FOCUS_srv)
** Index 1... = Child servers */
int FS_chld_exit_status[MAX_CLIENTS+1];
int FS_chld_cnct_skt[MAX_CLIENTS+1];
int FS_chld_rw_skt[MAX_CLIENTS+1];
char FS_name[MAX_CLIENTS+1][20]; /* The name of the FOCUS-servers */
char *FS_p_names[MAX_CLIENTS+1]; /* Pointers to the names */
char FS_inst[16]; /* This identifies the instrument */
char FS_def_ident[8]; /* This is Ident of FOCUS_def.h */
char FS_main_ident[8]; /* This is Ident of main program */
char FS_main_date[32]; /* This is compil date of main program */
char FS_serv_ident[8]; /* This is Ident of server program */
char FS_serv_date[32]; /* This is compil date of server program */
char FS_rout_ident[8]; /* This is Ident of routines */
char FS_rout_date[32]; /* This is compil date of routines */
uint FS_bytes_got, FS_bytes_put;
MSG_Q_ID FS_msgQ_to_srv[MAX_CLIENTS+1]; /* Index 0 is for messages ..
** .. to FOCUS-master. The ..
** others are to the various ..
** servers.
*/
uint FS_sem_tmo;
uint FS_use_sem_tmo; /* If True (== 1), enable sem timeouts */
int FS_n_slaves; /* The number of slaves */
char *FS_slaves[MAX_SLV]; /* The names of the slaves */
struct sockaddr_in FS_rmt_socknam[MAX_SLV]; /* Internet addresses of ..
** .. our slaves */
uint FS_lo_det[MAX_SLV]; /* # of first det'r on each ..
** .. slave */
uint FS_hi_det[MAX_SLV]; /* # of last det'r on each ..
** .. slave */
int FS_slv_active[MAX_SLV]; /* True if slave has been ..
** .. cfg'd */
int FS_skt[MAX_CLIENTS+1][MAX_SLV]; /* Client skts for ..
** .. children */
int FS_pkt_siz[MAX_CLIENTS+1][MAX_SLV]; /* Packet sizes ..
** .. for childrn */
/*========================== Define the function prototypes ================*/
int chk_config_alloc (
int skt,
struct req_buff_struct *request,
struct rply_buff_struct *reply);
void failInet (
char *text);
void failInet_port (
char *text, int port);
int FOCUS_server (
pid_t parent_pid,
SEM_ID sem,
int index,
int pkt_size,
int suspend_flag,
int *status);
void FS_catch_int_signal (
int signo);
void FS_catch_signal (
int signo);
void FS_cleanup_children (
int max_chld,
pid_t *pids,
int *pcnt_SIGUSR1,
int verbose,
char **tsk_names,
char *filler_name);
int FS_close_all (
int index);
int FS_close_down_offspring (
int harshness,
int max_chld,
pid_t *pids,
int *exit_stat,
int *pcnt_SIGUSR1,
int verbose,
char **tsk_names,
char *filler_name);
int FS_deconfig_all (
int harshness);
int FS_do_command (
int index,
int skt,
int pkt_size,
struct req_buff_struct *rqst,
struct rply_buff_struct *reply);
int FS_do_config (
int skt,
struct req_buff_struct *request,
struct rply_buff_struct *reply);
int FS_do_daq (
int index,
int sub_cmnd,
struct req_buff_struct *request,
struct rply_buff_struct *reply);
int FS_do_project (
int index,
struct rply_buff_struct *rply_bf,
int rw_skt,
int pkt_size,
uint sub_code,
uint x_lo,
uint nx,
uint y_lo,
uint ny,
uint xdim,
uint h_slct);
int FS_do_read (
int index,
struct rply_buff_struct *rply_bf,
int rw_skt,
int pkt_size,
uint nbins,
uint first,
uint hist_no);
int FS_do_write (
int index,
struct req_buff_struct *req_bf,
struct rply_buff_struct *rply_bf,
int rw_skt,
int pkt_size,
int nbins,
int first,
int bytes_per_bin,
int hist_no);
int FS_do_zero (
struct rply_buff_struct *reply,
int index,
int nbins,
int fst_bin,
int hist_no);
void FS_free_memory (
void *extras);
void FS_kill_children ();
int FS_make_child (
int proc (),
int prty,
int spnd,
int pkt_size,
int max_chld,
pid_t *pids,
int *exit_stat,
int *pcnt_SIGUSR1,
char *name);
int FS_project_hm (
int index,
int pkt_size,
uint *buff,
uint *w_buff,
uint blen_in_bins,
uint sub_code,
uint lo_cntr,
uint hi_cntr,
uint fst_bin,
uint lst_bin);
int FS_read_hm (
int skt,
int pkt_size,
uchar *buff,
uint blen_in_bins,
uint first_bin,
uint last_bin);
int FS_rply_status_send (
int skt,
struct rply_buff_struct *rply_bf,
uint *out_cntr);
int FS_rply_status_setup_and_send (
int skt,
struct rply_buff_struct *rply_bf,
int status,
int sub_status,
char *msg,
uint *out_cntr);
int FS_send_cmnd_to_mstr (
struct sockaddr_in *rmt_sockname,
struct req_buff_struct *request,
int requ_len,
struct rply_buff_struct *reply,
uint *in_cntr,
uint *out_cntr);
void getErrno (
int *his_errno);
pid_t get_pid ();
int net_flush (
int skt,
int nbytes);
void rply_status_setup (
struct rply_buff_struct *rply_bf,
int status,
int sub_status,
char *msg);
int rqst_send_get (
int skt,
struct req_buff_struct *rqst_bf,
int rq_len,
struct rply_buff_struct *rply_bf,
int rp_size,
int *out_cntr,
int *in_cntr,
char *tsk_name);
int setup_host (
char *host,
struct sockaddr_in *sockname,
int port,
int verbose);
void setup_inet_info (
char *host,
int host_size,
char *addr,
int addr_size);
int sleep (
int xx);
int socket_bind (
int port,
char *tsk_name);
char *StrJoin (
char *result,
int result_size,
char *str_a,
char *str_b);
/*===================================================== End of FOCUS_gbl.h */

2705
sinqhm/FOCUS_srv_main.c Executable file

File diff suppressed because it is too large Load Diff

103
sinqhm/Makefile Normal file
View File

@ -0,0 +1,103 @@
#---------------------------------------------------------------------------
# Makefile for the SINQ hist mem client Programs in the sinqhm directory.
# These are:
# sinqhm_ctrl
# sinqhm_client
# sinqhm_bootutil_client
# lwl_client
#
# David Maden, Oct-2000
#--------------------------------------------------------------------------
#
#------------ for DigitalUnix (add -DFORTIFY to CFLAGS for fortified version)
FF = f90
CC = cc
CFLAGS = -std -g -I. -I../hardsup -I$(PGPLOT_DIR) -I/data/koenneck/include
BIN = ../bin
LFLAGS = -L../hardsup -L$PGPLOT_DIR -L/data/lnslib/lib -lX11
#------------ for Linux
## FF = g77
## CC = gcc
## CFLAGS = -g -I. -I../hardsup -I$(PGPLOT_DIR) -DLINUX
## BIN = $(HOME)/bin
## LFLAGS = -L../hardsup -L$PGPLOT_DIR -L/usr/X11R6/lib
#------------
#----------------------------------------------------------
all: $(BIN)/sinqhm_ctrl \
$(BIN)/sinqhm_client \
$(BIN)/sinqhm_bootutil_client \
$(BIN)/lwl_client
@ echo
@ echo " This directory contains SINQ histogram memory software."
@ echo " The make file will make the histogram memory client programs:"
@ echo
@ echo " sinqhm_ctrl"
@ echo " sinqhm_client"
@ echo " sinqhm_bootutil_client"
@ echo " lwl_client"
@ echo
@ echo " To make them, simply specify:"
@ echo
@ echo " make"
@ echo
#----------------------------------------------------------
$(BIN)/sinqhm_ctrl: SinqHM_def.h sinqhm_ctrl.c
@ rm -f $(BIN)/sinqhm_ctrl.old
@ if test -f $(BIN)/sinqhm_ctrl; then \
mv -f $(BIN)/sinqhm_ctrl \
$(BIN)/sinqhm_ctrl.old; \
fi
$(CC) $(CFLAGS) -o $(BIN)/sinqhm_ctrl \
sinqhm_ctrl.c $(LFLAGS) -lhlib -lX11
$(BIN)/sinqhm_client: SinqHM_def.h sinqhm_client.c
@ rm -f $(BIN)/sinqhm_client.old
@ if test -f $(BIN)/sinqhm_client; then \
mv -f $(BIN)/sinqhm_client \
$(BIN)/sinqhm_client.old; \
fi
$(FF) $(CFLAGS) -nofor_main -o $(BIN)/sinqhm_client \
sinqhm_client.c $(LFLAGS) -lhlib -lcpgplot -lpgplot -lX11
$(BIN)/sinqhm_bootutil_client: SinqHM_def.h \
sinqhm_bootutil_client.c
@ rm -f $(BIN)/sinqhm_bootutil_client.old
@ if test -f $(BIN)/sinqhm_bootutil_client; then \
mv -f $(BIN)/sinqhm_bootutil_client \
$(BIN)/sinqhm_bootutil_client.old; \
fi
$(CC) $(CFLAGS) -o $(BIN)/sinqhm_bootutil_client \
sinqhm_bootutil_client.c $(LFLAGS) -lhlib -lX11
$(BIN)/lwl_client: SinqHM_def.h lwl_client.c
@ rm -f $(BIN)/lwl_client.old
@ if test -f $(BIN)/lwl_client; then \
mv -f $(BIN)/lwl_client \
$(BIN)/lwl_client.old; \
fi
$(CC) $(CFLAGS) -o $(BIN)/lwl_client \
lwl_client.c $(LFLAGS) -lhlib -lX11
#----------------------------------------------------------
clean:
- rm -f *.o
- rm -f $(BIN)/sinqhm_ctrl \
$(BIN)/sinqhm_client \
$(BIN)/sinqhm_bootutil_client \
$(BIN)/lwl_client
- rm -f $(BIN)/sinqhm_ctrl.old \
$(BIN)/sinqhm_client.old \
$(BIN)/sinqhm_bootutil_client.old \
$(BIN)/lwl_client.old
#----------------------------------------------------------
.c.o:
$(CC) $(CFLAGS) -c $*.c
#----------------------------------------------------------

1263
sinqhm/SinqHM_bootParamsConfig.c Executable file

File diff suppressed because it is too large Load Diff

631
sinqhm/SinqHM_bootUtil.c Executable file
View File

@ -0,0 +1,631 @@
#define IDENT "1A02"
/*
** +--------------------------------------------------------------+
** | Paul Scherrer Institute |
** | SINQ Division |
** | |
** | This software may be used freely by non-profit organizations.|
** | It may be copied provided that the name of P.S.I. and of the |
** | author is included. Neither P.S.I. nor the author assume any |
** | responsibility for the use of this software outside of P.S.I.|
** +--------------------------------------------------------------+
**
** Module Name . . . . . . . . : [...SINQHM]SinqHM_bootUtil.c
**
** Author . . . . . . . . . . : D. Maden
** Date of creation . . . . . . : Aug 1999
**
** Updates:
** 1A01 16-Aug-1999 DM Initial version.
**---------------------------------------------------------------------------
** SinqHM_bootUtil.c is a simple TCP/IP server for VxWorks.
** It obtains information about the VxWorks boot line.
*/
/*
** To compile and link this program for VxWorks on PSS123, use:
**
set src = "lnsa09:tas_src:[sinqhm]"
rcp -p "${src}SinqHM_bootUtil.c" SinqHM_bootUtil.c
ccvx -I${WIND_BASE}/target/config/all SinqHM_bootUtil.c
** where
ccvx = ccppc -O0 \
-mcpu=603 \
-I${WIND_BASE}/target/h \
-fno-builtin \
-fno-for-scope \
-nostdinc \
-DCPU=PPC603 \
-D_GNU_TOOL \
-gdwarf -c -Wimplicit
** and, on the target,
**
** -> ld < /home/pss123/aco/maden/wind/SinqHM/Dflt/SinqHM_srv.o
** -> ld < /home/pss123/aco/maden/wind/SinqHM/SinqHM_bootUtil.o
** -> taskSpawn "bootUtil", 100, 8, 20000, SinqHM_bootUtil, <port>
** ^
** |
** TCP/IP port number of the "bootUtil" service, dflt = 2300 -+
**
**====================================================================
*/
#include "vxWorks.h" /* always first */
#include "taskLib.h"
#include "sockLib.h"
#include "bootLib.h"
#include "rebootLib.h"
#include "sysLib.h"
#include "usrLib.h"
#include "ioLib.h"
#ifdef MV2600
#include "../config/mv2604/config.h"
#else
#if (CPU == PPC603)
#include "../config/mv1603/config.h"
#elif (CPU == PPC604)
#include "../config/mv1604/config.h"
#endif
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
/*
**==================== Global Definitions =====================================
*/
#include "SinqHM_def.h"
#define MAX_ACTIONS 8
#define MAX_ARGS 10
#define SBU_PORT_DFLT 2300 /* The Dflt Internet Port for Server Requests */
/*
**==================== Global Variables =====================================
*/
uint Sbu_port; /* The port number to use for the service */
char Sbu_name[20]; /* Our task name */
/*
**=============================================================================
** Local routine prototypes.
*/
int sbu_doConfig (int skt);
void sbu_doReboot ();
void sbu_failInet (char *text);
void sbu_failInet_str (char *text, char *str);
void sbu_getErrno (int *his_errno);
void sbu_showHelp (char *errmsg);
char *StrJoin (
char *result,
int result_size,
char *str_a,
char *str_b);
int sbu_doConfig (int skt);
/*
**--------------------------------------------------------------------------*/
int sbu_doConfig (int skt) {
/* ============
** Configure the vxWorks boot information
*/
char hdr_buff[8], *p_addr, recd[1024];
int status, i, j, l_recd, bytes_to_come, toklen, changed;
char *boot_line_addr, *b_status, *tok, *body;
BOOT_PARAMS my_boot_params;
/*----------------------------------------
** Get the new boot information over the network.
**
** Get first 4 bytes which gives the length to follow
*/
status = recv (skt, hdr_buff, 4, 0);
if (status != 4) sbu_failInet ("recv error on bootline header.\n");
i = sscanf (hdr_buff, "%4d%n", &l_recd, &j); /* Convert to binary */
if ((i != 1) || (j != 4)) {
sprintf (recd, "Header bytes are not ASCII coded decimal: 0x%x 0x%x 0x%x 0x%x\n",
hdr_buff[0], hdr_buff[1], hdr_buff[2], hdr_buff[3]);
sbu_failInet (recd);
}
if (l_recd >= sizeof (recd)) {
sprintf (recd, "Too long for buffer. Buffer length = %d\n", l_recd);
sbu_failInet (recd);
}
bytes_to_come = l_recd;
p_addr = recd;
while (bytes_to_come > 0) {
status = recv (skt, p_addr, bytes_to_come, 0);
if (status <= 0) break;
bytes_to_come -= status;
p_addr += status;
}
if (bytes_to_come != 0) {
if (status < 0) {
sbu_failInet ("R/W-Socket recv error");
}else if (status == 0) {
sbu_failInet ("R/W-Socket recv error -- return code = 0");
}
sbu_failInet ("R/W-Socket recv error -- not enough data received");
}
/*
** Initialise the boot line structure with the existing
** contents of the boot line.
*/
boot_line_addr = (char *) BOOT_LINE_ADRS; /* Get pointer to the boot line */
b_status = bootStringToStruct (boot_line_addr, &my_boot_params);
if (*b_status != EOS) {
printf ("\n%s: Bad status from \"bootStringToStruct\": 0x%02x\n",
Sbu_name, *b_status);
return False;
}
/*
** Now scan through the new boot string replacing items in
** the boot line structure as we find them.
*/
printf ("\nNew boot-line items are:\n");
changed = False;
tok = strtok (recd, ":\n");
while (tok != NULL) {
toklen = strlen (tok);
if (tok[toklen+1] == '\n') { /* Watch out for tokens with no body */
tok = strtok (NULL, ":\n"); /* Skip an empty body */
}else {
body = strtok (NULL, "\n");
if ((strcmp (tok, "bootDev") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.bootDev, body) != 0) {
changed = True;
printf (" boot device : %s\n", body);
strcpy (my_boot_params.bootDev, body);
}
}else if ((strcmp (tok, "procNum") == 0) && (body != NULL)) {
status = sscanf (body, "%i%n", &i, &j);
if ((status != 1) || (j != strlen (body))) {
printf ("\n%s: Bad value found for procNum: \"%s\"\n", Sbu_name, body);
return False;
}
if (my_boot_params.procNum != i) {
changed = True;
printf (" processor number : %s\n", body);
my_boot_params.procNum = i;
}
}else if ((strcmp (tok, "hostName") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.hostName, body) != 0) {
changed = True;
printf (" host name : %s\n", body);
strcpy (my_boot_params.hostName, body);
}
}else if ((strcmp (tok, "bootFile") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.bootFile, body) != 0) {
changed = True;
printf (" file name : %s\n", body);
strcpy (my_boot_params.bootFile, body);
}
}else if ((strcmp (tok, "ead") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.ead, body) != 0) {
changed = True;
printf (" inet on ethernet (e) : %s\n", body);
strcpy (my_boot_params.ead, body);
}
}else if ((strcmp (tok, "bad") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.bad, body) != 0) {
changed = True;
printf (" inet on backplane (b): %s\n", body);
strcpy (my_boot_params.bad, body);
}
}else if ((strcmp (tok, "had") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.had, body) != 0) {
changed = True;
printf (" host inet (h) : %s\n", body);
strcpy (my_boot_params.had, body);
}
}else if ((strcmp (tok, "gad") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.gad, body) != 0) {
changed = True;
printf (" gateway inet (g) : %s\n", body);
strcpy (my_boot_params.gad, body);
}
}else if ((strcmp (tok, "usr") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.usr, body) != 0) {
changed = True;
printf (" user (u) : %s\n", body);
strcpy (my_boot_params.usr, body);
}
}else if ((strcmp (tok, "passwd") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.passwd, body) != 0) {
changed = True;
printf (" ftp password (pw) : %s\n", body);
strcpy (my_boot_params.passwd, body);
}
}else if ((strcmp (tok, "flags") == 0) && (body != NULL)) {
status = sscanf (body, "%i%n", &i, &j);
if ((status != 1) || (j != strlen (body))) {
printf ("\n%s: Bad value found for flags: \"%s\"\n", Sbu_name, body);
return False;
}
if (my_boot_params.flags != i) {
changed = True;
printf (" flags (f) : %s\n", body);
my_boot_params.flags = i;
}
}else if ((strcmp (tok, "targetName") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.targetName, body) != 0) {
changed = True;
printf (" target name (tn) : %s\n", body);
strcpy (my_boot_params.targetName, body);
}
}else if ((strcmp (tok, "startupScript") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.startupScript, body) != 0) {
changed = True;
printf (" startup script (s) : %s\n", body);
strcpy (my_boot_params.startupScript, body);
}
}else if ((strcmp (tok, "other") == 0) && (body != NULL)) {
if (strcmp (my_boot_params.other, body) != 0) {
changed = True;
printf (" other (o) : %s\n", body);
strcpy (my_boot_params.other, body);
}
}else {
if (body != NULL) {
printf ("\n%s: Bad token found in new boot string: \"%s\" \"%s\"\n",
Sbu_name, tok, body);
}else {
printf ("\n%s: Token found with NULL body in new boot string: \"%s\"\n",
Sbu_name, tok);
}
printf ("\n%s: Boot string has not been re-configured!\n", Sbu_name);
return False;
}
tok = strtok (NULL, ":");
}
}
if (!changed) printf (" Nothing has been changed!\n");
status = bootStructToString (boot_line_addr, &my_boot_params);
if (status != OK) {
printf ("\n%s: Bad status from \"bootStringToStruct\": 0x%02x\n", Sbu_name,
status);
return False;
}
b_status = bootStringToStruct (boot_line_addr, &my_boot_params);
if (*b_status != EOS) {
printf ("\n%s: Bad status from \"bootStringToStruct\": 0x%02x\n",
Sbu_name, *b_status);
return False;
}
printf ("\nResulting vxWorks Boot-Line is:\n"
" =================\n");
printf (" boot device : %s\n", my_boot_params.bootDev);
printf (" processor number : %d\n", my_boot_params.procNum);
printf (" host name : %s\n", my_boot_params.hostName);
printf (" file name : %s\n", my_boot_params.bootFile);
printf (" inet on ethernet (e) : %s\n", my_boot_params.ead);
printf (" inet on backplane (b): %s\n", my_boot_params.bad);
printf (" host inet (h) : %s\n", my_boot_params.had);
printf (" gateway inet (g) : %s\n", my_boot_params.gad);
printf (" user (u) : %s\n", my_boot_params.usr);
printf (" ftp password (pw) : %s\n", my_boot_params.passwd);
printf (" flags (f) : 0x%x\n", my_boot_params.flags);
printf (" target name (tn) : %s\n", my_boot_params.targetName);
printf (" startup script (s) : %s\n", my_boot_params.startupScript);
printf (" other (o) : %s\n\n", my_boot_params.other);
/*
** Write to non-volatile RAM
*/
status = sysNvRamSet (BOOT_LINE_ADRS, strlen (BOOT_LINE_ADRS) + 1, 0);
if (status != OK) {
printf ("\n%s: Bad status from \"sysNvRamSet\": 0x%02x\n",
Sbu_name, status);
return False;
}
return True;
}
/*
**--------------------------------------------------------------------------*/
void sbu_doReboot () {
/* ============
** Re-boot the vxWorks system by calling reboot.
*/
printf ("This processor is about to be re-booted ...\n");
taskDelay (sysClkRateGet ()/4);
reboot (BOOT_CLEAR);
exit (EXIT_SUCCESS); /* Should not get here! */
}
/*
**--------------------------------------------------------------------------*/
void sbu_failInet (char *text) {
/* =============
** Output the given text and exit the process.
*/
int my_errno;
sbu_getErrno (&my_errno);
printf ("\n### Internet Error ###\n");
printf ( " ### errno = %d.\n", my_errno);
perror (text);
exit (EXIT_FAILURE);
}
/*--------------------------------------------------------------------------*/
void sbu_failInet_str (char *fmt, char *str) {
/* ================
** Call to failInet with an extra parameter.
*/
char my_buff[132];
sprintf (my_buff, fmt, str);
sbu_failInet (my_buff);
/* No return */
}
/*--------------------------------------------------------------------------*/
void sbu_getErrno (int *his_errno) {
/* =============
*/
*his_errno = errno; /* Make copy of errno */
return;
}
/*
**--------------------------------------------------------------------------*/
void sbu_showHelp (char *errmsg) {
/* =============
*/
if (errmsg != NULL) {
printf ("\007\n%s\n", errmsg);
taskDelay (5 * sysClkRateGet ()); /* Give user time to read message */
}
printf ("\n"
"The \"other\" field may be specified as follows:\n"
"\n"
" <action>=<arg0>,..,<argn>/<action>=...\n"
"\n"
"There must be no white space characters in the string. The string may\n"
"be specified in upper or lower case.\n"
"\n"
"<action> may be \"sp\" for \"spawn a task\" or\n"
" \"cfg\" for \"configure SinqHM_srv\"\n"
"\n"
"The following \"sp\" commands are available:\n"
"\n"
" a) sp=SinqHM,<port>,<use-lev-gen>,<VMIO10-base>\n"
" where\n"
" <port> = TCP/IP port number for server. Dflt=2400.\n"
" <use-lev-gen> = flag to indicate if timing levels should be\n"
" generated via a VMIO10 module. If non-zero,\n"
" timing levels are generated. Dflt=0.\n"
" <VMIO10-base> = base address of VMIO10 level-generator\n"
" module. Dflt=0x1900.\n"
" This action spawns the SinqHM histogram memory server task.\n"
"\n"
" b) sp=lwl,<port>,<VMIO10-base>,<verbosity>\n"
" where\n"
" <port> = TCP/IP port number for server. Dflt=3501.\n"
" <VMIO10-base> = base address of VMIO10 test-generator\n"
" module. Dflt=0x1800.\n"
" <verbosity> = verbosity flag. If non-zero, the program is\n"
" verbose. Dflt=0.\n"
" This action spawns the lwl_server task which can be used to feed\n"
" data packets into the hist memory fibre-optic (Licht-Wellen-Leiter)\n"
" link via a VMIO10 test-generator. If the test generator is absent,\n"
" the action can be omitted to avoid a boot-time error message.\n"
"\n"
"The following \"cfg\" commands are available:\n"
"\n"
" a) cfg=HM_DIG,<#-bins>,<#-hists>,<bin-width>,<compress>,<lo-bin>\n"
" where\n"
" <#-bins> = number of bins per histogram. No default.\n"
" <#-hists> = number of defined histograms. Dflt=1.\n"
" <bin-width> = Number of bytes per bin. Dflt=4.\n"
" <compress> = Bin compression factor. Dflt=1.\n"
" <lo-bin> = First bin. Dflt=0.\n"
"\n"
" b) cfg=TOF,<#-bins>,<#-cntrs>,<bin-width>,<compress>,<lo-cntr>\n"
" where\n"
" <#-bins> = number of bins per histogram. No default.\n"
" <#-cntrs> = number of neutron counters. No default.\n"
" <bin-width> = Number of bytes per bin. Dflt=4.\n"
" <compress> = Bin compression factor. Dflt=1.\n"
" <lo-cntr> = # of first counter. Dflt=0.\n"
"\n"
" c) cfg=HM_PSD,... same arguments as HM_DIG (for now).\n"
"\n"
"For example:\n"
" other=\"sp=SinqHM/cfg=HM_DIG,400\"\n"
"\n");
}
/*
**==============================================================================
**
** Main line program
**
**============================================================================*/
int SinqHM_bootUtil (int port, int arg2, int arg3, int arg4,
/* ===============
*/ int arg5, int arg6, int arg7, int arg8, int arg9,
int suspend) {
/*
** Arguments:
** port the TCP/IP port number to use. If 0, use default.
** suspend sunspend ourself immediately if non-zero.
*/
char *local_mem, boot_line[1024], buff[128], cmnd[8];
char *my_task_name;
BOOT_PARAMS my_params;
int status, keep_going, cl_port, my_errno, bl_len;
char *b_status, *p_host;
int my_skt; /* Connection socket */
int rw_skt; /* Read/write socket */
struct sockaddr_in lcl_sockname;
struct sockaddr_in rmt_sockname;
int rmt_sockname_len;
/*============================================================================
*/
my_task_name = taskName (taskIdSelf());
if (suspend != 0) {
printf ("\n%s: Suspending ...\n", my_task_name);
taskSuspend (0); /* We've been told to suspend ourself, ..
** .. presumably for debug reasons.
*/
printf ("\n%s: ... suspension ended!\n", my_task_name);
}
/*============================================================================
** Perform the initialisation of variables ...
*/
StrJoin (Sbu_name, sizeof (Sbu_name), taskName (taskIdSelf ()), "");
printf ("\n%s: Started -- program ident = \"%s\".\n", Sbu_name, IDENT);
local_mem = (char *) BOOT_LINE_ADRS; /* Get pointer to the boot line */
/*============================================================================
*/
b_status = bootStringToStruct (local_mem, &my_params); /* Parse boot line */
if (*b_status != EOS) {
printf ("\n%s: Bad status from \"bootStringToStruct\": 0x%02x\n",
Sbu_name, *b_status);
return False;
}
Sbu_port = SBU_PORT_DFLT;
if ((port >= 128) && (port < 32768)) Sbu_port = port;
/*============================================================================
** Create a TCP/IP socket for receiving connection requests, bind it and
** set it to listen.
*/
my_skt = socket (AF_INET, SOCK_STREAM, 0);
if (my_skt == -1)
sbu_failInet_str ("\n%s: socket error", Sbu_name);
lcl_sockname.sin_family = AF_INET;
lcl_sockname.sin_port = htons (Sbu_port);
lcl_sockname.sin_addr.s_addr = 0;
status = bind (my_skt, (struct sockaddr *) &lcl_sockname,
sizeof (lcl_sockname));
if (status != 0) sbu_failInet_str ("\n%s: bind error", Sbu_name);
status = listen (my_skt, 5);
if (status != 0) sbu_failInet_str ("\n%s: listen error", Sbu_name);
/*
** Clients must now connect to us.
**
** When a connection arrives, the boot line is sent to the client.
*/
printf ("\n%s: waiting for connections on Port %d\n", Sbu_name, Sbu_port);
keep_going = True;
while (keep_going) {
rmt_sockname_len = sizeof (rmt_sockname);
rw_skt = accept (my_skt, (struct sockaddr *) &rmt_sockname,
&rmt_sockname_len);
if (rw_skt == -1) {
sbu_getErrno (&my_errno);
sbu_failInet_str ("\n%s: accept error", Sbu_name);
/* No return */
}
p_host = inet_ntoa (rmt_sockname.sin_addr);
cl_port = ntohs (rmt_sockname.sin_port);
b_status = bootStringToStruct (local_mem, &my_params); /* Parse boot line */
if (*b_status != EOS) {
printf ("\n%s: Bad status from \"bootStringToStruct\": 0x%02x\n", Sbu_name,
*b_status);
return False;
}
StrJoin (boot_line, sizeof (boot_line), "bootDev:", my_params.bootDev);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nprocNum:");
sprintf (buff, "%d", my_params.procNum);
StrJoin (boot_line, sizeof (boot_line), boot_line, buff);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nhostName:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.hostName);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nbootFile:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.bootFile);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nead:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.ead);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nbad:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.bad);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nhad:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.had);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\ngad:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.gad);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nusr:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.usr);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\npasswd:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.passwd);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nflags:");
sprintf (buff, "0x%x", my_params.flags);
StrJoin (boot_line, sizeof (boot_line), boot_line, buff);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\ntargetName:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.targetName);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nstartupScript:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.startupScript);
StrJoin (boot_line, sizeof (boot_line), boot_line, "\nother:");
StrJoin (boot_line, sizeof (boot_line), boot_line, my_params.other);
bl_len = strlen (boot_line) + 1; /* Get len of line (including term'r) */
bl_len = (bl_len + 3) & (~3); /* Round up to a multiple of 4 */
sprintf (buff, "%04.4d", bl_len);
status = send (rw_skt, buff, 4, 0);
if (status != 4) {
sbu_getErrno (&my_errno);
sbu_failInet_str ("\n%s: send error on boot-line header", Sbu_name);
/* No return */
}
status = send (rw_skt, boot_line, bl_len, 0);
if (status != bl_len) {
sbu_getErrno (&my_errno);
sbu_failInet_str ("\n%s: send error on boot-line body", Sbu_name);
/* No return */
}
/*
** Now get a command from the client
*/
status = recv (rw_skt, cmnd, 8, 0);
if (status != 8) {
sbu_getErrno (&my_errno);
sprintf (buff, "\n%s: send error on boot-line body", Sbu_name);
perror (buff);
}else if (strcmp (cmnd, "CLOSE") == 0) {
send (rw_skt, "OK\0\0", 4, 0); /* Acknowledge the command */
}else if (strcmp (cmnd, "CONFIG") == 0) {
printf ("\n%s: CONFIG command received from Host %s, Port %d ...\n",
Sbu_name, p_host, cl_port);
status = sbu_doConfig (rw_skt);
if (status) {
send (rw_skt, "OK\0\0", 4, 0);
}else {
send (rw_skt, "Err", 4, 0);
}
}else if (strcmp (cmnd, "REBOOT") == 0) {
printf ("\n%s: REBOOT command received from Host %s, Port %d ...\n",
Sbu_name, p_host, cl_port);
send (rw_skt, "OK\0\0", 4, 0); /* Acknowledge the command */
status = close (rw_skt);
status = close (my_skt);
sbu_doReboot (); /* There is no return from this call! */
}else if (strcmp (cmnd, "RUNDOWN") == 0) {
printf ("\n%s: RUNDOWN command received from Host %s, Port %d ...\n",
Sbu_name, p_host, cl_port);
send (rw_skt, "OK\0\0", 4, 0); /* Acknowledge the command */
keep_going = False;
}else {
printf ("\n%s: unrecognised command received from Host %s, Port %d:"
"\"%s\"\n", Sbu_name, p_host, cl_port, cmnd);
send (rw_skt, "Err", 4, 0);
}
status = close (rw_skt);
}
status = close (my_skt);
return True;
}
/*================================= End of SinqHM_bootUtil.c ========*/

493
sinqhm/SinqHM_def.h Executable file
View File

@ -0,0 +1,493 @@
/*=================================================== [...SinqHM]SinqHM_def.h
**
** Definition Include file for SinqHM_SRV and its clients.
**
**------------------------------------------------------------------------------
*/
#define SINQHM_DEF_ID "V03C"
#ifdef __alpha
#ifndef __vms
#pragma pack 1
#endif
#endif
/*------------------------------------------------------------------------------
*/
#ifndef OffsetOf
#define OffsetOf(type, identifier) ((size_t)(&((type*) NULL)->identifier))
#endif
/*------------------------------------------------------------------------------
** Define some defaults.
*/
#define PORT_BASE 2400 /* The Internet Port for Server Requests */
#define MAX_CLIENTS 8 /* The maximum number of active clients */
#define MAX_TOF_CNTR 32768 /* The maximum number of individual counters ..
** which can be handled in TOF mode */
#define MAX_PSD_CNTR 16777217 /* maximum number of PSD elements */
#define MAX_PSD_ED 3 /* maximum number of additional
single detectors at AMOR
*/
#define MAX_TOF_NBINS 32768 /* The maximum number of bins in a TOF histog */
#define MAX_TOF_EDGE 16 /* The maximum number of TOF edge arrays */
#define VMIO_BASE_ADDR 0x1900 /* VME address of a (possible) VMIO10 module */
#define IDENT_MSGE_LEN 256 /* Length of Ident info for SQHM_IDENT */
#define uchar unsigned char
#define usint unsigned short int
#define uint unsigned int
/*------------------------------------------------------------------------------
** Define some status values (similar to VAXeln).
*/
#define KER__SUCCESS 1
#define KER__BAD_CREATE -2
#define KER__BAD_STATE -4
#define KER__BAD_VALUE -6
#define KER__EXIT_SIGNAL -10
#define KER__BAD_RECV -14
#define KER__BAD_ALLOC -16
#ifndef True
#define True 1
#endif
#ifndef False
#define False 0
#endif
#ifndef NIL
#define NIL '\0'
#endif
/*------------------------------------------------------------------------------
** Define command verbs to SinqHM.
*/
#define SQHM_CNCT 0x01
#define SQHM_CLOSE 0x02
#define SQHM_CONFIG 0x03
#define SQHM_DAQ 0x04
#define SQHM_DBG 0x05
#define SQHM_DECONFIG 0x06
#define SQHM_EXIT 0x07
#define SQHM_IDENT 0x0e
#define SQHM_PROJECT 0x0d
#define SQHM_READ 0x08
#define SQHM_SELECT 0x09
#define SQHM_STATUS 0x0a
#define SQHM_WRITE 0x0b
#define SQHM_ZERO 0x0c
/*
** Define the various operation modes
*/
#define SQHM__TRANS 0x1000 /* Transparent mode */
#define SQHM__HM_DIG 0x2000 /* Hist mode (with digitised read-out) */
#define SQHM__TOF 0x3000 /* Time-of-Flight mode */
#define SQHM__HM_PSD 0x4000 /* Hist mode (with Pos-sens-detect read-out) */
#define SQHM__HRPT 0x5000 /* Hist mode for HRPT */
/*
** Define the various sub-mode bits of the operation modes
*/
#define SQHM__SUB_MODE_MSK 0xff /* Mask for extracting "sub-mode" bits */
#define SQHM__DEBUG 0x01 /* Debug flag - FILLER will suspend itself ..
** .. after starting to allow debugging */
#define SQHM__UD 0x02 /* Use Up/Down bit information */
#define SQHM__BO_MSK 0x18 /* Mask for extracting "bin-overflow" bits */
#define SQHM__BO_IGN 0x00 /* Ignore bin-overflows (bin-contents wrap) */
#define SQHM__BO_SMAX 0x08 /* On bin-overflow, stop at maximum */
#define SQHM__BO_CNT 0x10 /* Keep counts of overflow bins */
#define SQHM__STROBO 0x20 /* Use strobo-bit information */
#define SQHM__REFLECT 0x40 /* Reflect histograms */
#define SQHM__NO_STAT 0x80 /* Suppress status info from "Filler" */
/*
** ----------------------------------------------------------
** SQHM_DAQ sub-function codes
*/
#define DAQ__EXIT 0xffffffff
#define DAQ__CLR 0x01
#define DAQ__GO 0x02
#define DAQ__INH 0x03
#define DAQ__STOP 0x04
#define DAQ__TST 0x05
/*
** ----------------------------------------------------------
** SQHM_PROJECT sub-codes
*/
#define PROJECT__ON_Y 0x0001 /* Project onto y-axis */
#define PROJECT__1_DIM 0x0002 /* Make projection of a 1-dim histogram */
#define PROJECT__COLL 0x0003 /* collapse PSD on one time channel */
#define PROJECT__SAMPLE 0x0004 /* sum a rectangular part of the PSD
detector in time
*/
#define PROJECT__FRAME 0x0005 /* select a frame from a 3D histogram:
2 position dims plus time binning
*/
/*
** ----------------------------------------------------------
** Definition of bits in <flag> of TOF edge-array
*/
#define FLAG__VAR_BIN 0x01 /* Bin span of histogram is variable */
/*
** ----------------------------------------------------------
** Definition of bits in <flags> of SQHM_STATUS response
*/
#define STATUS_FLAGS__PF 0x8000 /* PF - Power Fail */
#define STATUS_FLAGS__SWC 0x4000 /* SWC - Status Word Changed */
#define STATUS_FLAGS__NRL 0x2000 /* NRL - Neutron Rate Low */
#define STATUS_FLAGS__DAQ 0x1000 /* DAQ on -- set if Hdr Mask Bits are
** correct so that data acq is active */
#define STATUS_FLAGS__SYNC3 0x0800 /* Ext Synch Bit #3 */
#define STATUS_FLAGS__SYNC2 0x0400 /* Ext Synch Bit #2 */
#define STATUS_FLAGS__SYNC1 0x0200 /* Ext Synch Bit #1 */
#define STATUS_FLAGS__SYNC0 0x0100 /* Ext Synch Bit #0 */
#define STATUS_FLAGS__UD 0x0080 /* UD - Up/Down */
#define STATUS_FLAGS__GU 0x0040 /* GU - Gummi (i.e. Strobo) */
/*
** ----------------------------------------------------------
*/
#define N_HISTS_MAX 64 /* Maximum number of histograms supported */
#define N_BINS_MAX 0x00ffff /* Maximum histogram bin number permitted */
#define N_TOTAL_BYTES 0x400000 /* Maximum total bytes of histogram */
/*
**------------------------------------------------------------------------------
** Definitions of Filler states in HRPT mode
*/
#define HRPT__SRCH_FRAME 1
#define HRPT__READ_FRAME 2
/*
**------------------------------------------------------------------------------
** Definitions for the LWL Datagrams
*/
#define LWL_HDR_TYPE_MASK (0x1f000000) /* Mask for extracting main dgrm ..
** .. hdr command-type bits */
#define LWL_HDR_PF_MASK (0x80000000) /* Mask for extr Power Fail bit */
#define LWL_HDR_SWC_MASK (0x40000000) /* Mask for extr Status Word Chng bit */
#define LWL_HDR_NRL_MASK (0x20000000) /* Mask for extr Neutron Rate Low bit */
#define LWL_HDR_SYNC3_MASK (0x00800000) /* Mask for one of ext synch bits */
#define LWL_HDR_SYNC2_MASK (0x00400000) /* Mask for one of ext synch bits */
#define LWL_HDR_SYNC1_MASK (0x00200000) /* Mask for one of ext synch bits */
#define LWL_HDR_SYNC0_MASK (0x00100000) /* Mask for one of ext synch bits */
#define LWL_HDR_UD_MASK LWL_HDR_SYNC1_MASK /* Mask for Up/Down bit */
#define LWL_HDR_GU_MASK LWL_HDR_SYNC0_MASK /* Mask for GU bit */
#define LWL_HDR_BA_MASK (0x00f00000) /* Mask for TSI Binning Addr */
#define LWL_HDR_TS_MASK (0x000fffff) /* Mask for TSI Time Stamp */
#define LWL_FIFO_EMPTY (0x1e000000) /* FIFO Empty */
#define LWL_TSI_TR (0x1f000000) /* Time-Status-Info Transp-Mode */
#define LWL_TSI_HM_NC (0x1f000000) /* Time-Status-Info Hist-Mode+No-Coinc */
#define LWL_TSI_HM_C (0x0e000000) /* Time-Status-Info Hist-Mode+Coinc */
#define LWL_TSI_TOF (0x1f000000) /* Time-Status-Info TOF-Mode */
#define LWL_TSI_SM_NC (0x1f000000) /* Time-Status-Info Strobo-Mode+No-Coin */
#define LWL_TSI_SM_C (0x0e000000) /* Time-Status-Info Strobo-Mode+Coinc */
#define LWL_TSI_DT_MSK (0x000fffff) /* Mask for Dead-Time in TSI */
#define LWL_TSI_DTS_MSK (0x000fffff) /* Mask for Delay-Time-to-Start in TSI */
#define LWL_TR_C1 (0x00000001) /* Transp. Mode Chan 1 */
#define LWL_TR_C2 (0x00000002) /* Transp. Mode Chan 2 */
#define LWL_TR_C3 (0x00000003) /* Transp. Mode Chan 3 */
#define LWL_TR_C4 (0x00000004) /* Transp. Mode Chan 4 */
#define LWL_TR_C5 (0x00000005) /* Transp. Mode Chan 5 */
#define LWL_TR_C6 (0x00000006) /* Transp. Mode Chan 6 */
#define LWL_TR_C7 (0x00000007) /* Transp. Mode Chan 7 */
#define LWL_TR_C8 (0x00000008) /* Transp. Mode Chan 8 */
#define LWL_TR_C9 (0x00000009) /* Transp. Mode Chan 9 */
#define LWL_HM_NC (0x10000000) /* Hist-Mode/No-Coinc 0 chan dgrm hdr */
#define LWL_HM_NC_C1 (0x11000000) /* Hist-Mode/No-Coinc 1 chan dgrm hdr */
#define LWL_HM_NC_C2 (0x12000000) /* Hist-Mode/No-Coinc 2 chan dgrm hdr */
#define LWL_HM_NC_C3 (0x13000000) /* Hist-Mode/No-Coinc 3 chan dgrm hdr */
#define LWL_HM_NC_C4 (0x14000000) /* Hist-Mode/No-Coinc 4 chan dgrm hdr */
#define LWL_HM_NC_C5 (0x15000000) /* Hist-Mode/No-Coinc 5 chan dgrm hdr */
#define LWL_HM_NC_C6 (0x16000000) /* Hist-Mode/No-Coinc 6 chan dgrm hdr */
#define LWL_HM_NC_C7 (0x17000000) /* Hist-Mode/No-Coinc 7 chan dgrm hdr */
#define LWL_HM_NC_C8 (0x18000000) /* Hist-Mode/No-Coinc 8 chan dgrm hdr */
#define LWL_HM_NC_C9 (0x19000000) /* Hist-Mode/No-Coinc 9 chan dgrm hdr */
#define LWL_HM_CO (0x10000000) /* Hist-Mode+Coinc 0 chan dgrm hdr */
#define LWL_HM_CO_C2 (0x12000000) /* Hist-Mode+Coinc 2 chan dgrm hdr */
#define LWL_HM_CO_C3 (0x13000000) /* Hist-Mode+Coinc 3 chan dgrm hdr */
#define LWL_HM_CO_C4 (0x14000000) /* Hist-Mode+Coinc 4 chan dgrm hdr */
#define LWL_HM_CO_C5 (0x15000000) /* Hist-Mode+Coinc 5 chan dgrm hdr */
#define LWL_HM_CO_C6 (0x16000000) /* Hist-Mode+Coinc 6 chan dgrm hdr */
#define LWL_HM_CO_C7 (0x17000000) /* Hist-Mode+Coinc 7 chan dgrm hdr */
#define LWL_HM_CO_C8 (0x18000000) /* Hist-Mode+Coinc 8 chan dgrm hdr */
#define LWL_HM_CO_C9 (0x19000000) /* Hist-Mode+Coinc 9 chan dgrm hdr */
#define LWL_TOF_C1 (0x01000000) /* TOF-Mode 1 chan dgrm hdr */
#define LWL_TOF_C2 (0x02000000) /* TOF-Mode 2 chan dgrm hdr */
#define LWL_TOF_C3 (0x03000000) /* TOF-Mode 3 chan dgrm hdr */
#define LWL_TOF_C4 (0x04000000) /* TOF-Mode 4 chan dgrm hdr */
#define LWL_TOF_C5 (0x05000000) /* TOF-Mode 5 chan dgrm hdr */
#define LWL_TOF_C6 (0x06000000) /* TOF-Mode 6 chan dgrm hdr */
#define LWL_TOF_C7 (0x07000000) /* TOF-Mode 7 chan dgrm hdr */
#define LWL_TOF_C8 (0x08000000) /* TOF-Mode 8 chan dgrm hdr */
#define LWL_TOF_C9 (0x09000000) /* TOF-Mode 9 chan dgrm hdr */
#define LWL_GUMMI_MON (0x14000000) /* GUMMI-Mode Monitor datagram */
#define LWL_PSD_TSI 0x0E000000 /* PSD-Mode TSI datagram */
#define LWL_PSD_DATA 0x12000000 /* PSD-mode data datagram */
#define LWL_PSD_ED 0x03000000 /* PSD-mode single detector datagram */
#define LWL_PSD_PWF 0x20000000 /* PSD-mode Power Fail bit */
#define LWL_PSD_TIME 0x000fffff /* PSD-mode time stamp extraction
mask */
#define LWL_PSD_FLASH_MASK 0x00ff /* mask for flash count */
#define LWL_PSD_XORF 0x2000 /* mask for TDC-XORF bit */
#define LWL_PSD_CONF 0x0100 /* mask for TDC-CONF flag */
#define LWL_HDR_ED_MASK 0x1C000000 /* mask for extracting ds4-ds2 */
#define LWL_SM_NC (0x10000000) /* Strobo-Mode/No-Coinc 0 chan dgrm hdr */
#define LWL_SM_NC_C1 (0x11000000) /* Strobo-Mode/No-Coinc 1 chan dgrm hdr */
#define LWL_SM_NC_C2 (0x12000000) /* Strobo-Mode/No-Coinc 2 chan dgrm hdr */
#define LWL_SM_NC_C3 (0x13000000) /* Strobo-Mode/No-Coinc 3 chan dgrm hdr */
#define LWL_SM_NC_C4 (0x14000000) /* Strobo-Mode/No-Coinc 4 chan dgrm hdr */
#define LWL_SM_NC_C5 (0x15000000) /* Strobo-Mode/No-Coinc 5 chan dgrm hdr */
#define LWL_SM_NC_C6 (0x16000000) /* Strobo-Mode/No-Coinc 6 chan dgrm hdr */
#define LWL_SM_NC_C7 (0x17000000) /* Strobo-Mode/No-Coinc 7 chan dgrm hdr */
#define LWL_SM_NC_C8 (0x18000000) /* Strobo-Mode/No-Coinc 8 chan dgrm hdr */
#define LWL_SM_NC_C9 (0x19000000) /* Strobo-Mode/No-Coinc 9 chan dgrm hdr */
#define LWL_SM_CO (0x10000000) /* Strobo-Mode + Coinc 0 chan dgrm hdr */
#define LWL_SM_CO_C1 (0x11000000) /* Strobo-Mode + Coinc 1 chan dgrm hdr */
#define LWL_SM_CO_C2 (0x12000000) /* Strobo-Mode + Coinc 2 chan dgrm hdr */
#define LWL_SM_CO_C3 (0x13000000) /* Strobo-Mode + Coinc 3 chan dgrm hdr */
#define LWL_SM_CO_C4 (0x14000000) /* Strobo-Mode + Coinc 4 chan dgrm hdr */
#define LWL_SM_CO_C5 (0x15000000) /* Strobo-Mode + Coinc 5 chan dgrm hdr */
#define LWL_SM_CO_C6 (0x16000000) /* Strobo-Mode + Coinc 6 chan dgrm hdr */
#define LWL_SM_CO_C7 (0x17000000) /* Strobo-Mode + Coinc 7 chan dgrm hdr */
#define LWL_SM_CO_C8 (0x18000000) /* Strobo-Mode + Coinc 8 chan dgrm hdr */
#define LWL_SM_CO_C9 (0x19000000) /* Strobo-Mode + Coinc 9 chan dgrm hdr */
#define LWL_TSI_MODE_MASK (0x000e) /* Mask for mode in Time Status Info */
#define LWL_TSI_MODE_TR (0x0000) /* TSI Transparent-Mode */
#define LWL_TSI_MODE_HM (0x0002) /* TSI Hist-Mode */
#define LWL_TSI_MODE_TOF (0x0004) /* TSI TOF-Mode */
#define LWL_TSI_MODE_SM1 (0x0006) /* TSI Strobo-Mode 1 - time-stamp coded */
#define LWL_TSI_MODE_TR_UD (0x0008) /* TSI Transparent-Mode Up-Down */
#define LWL_TSI_MODE_HM_UD (0x000a) /* TSI Hist-Mode Up-Down */
#define LWL_TSI_MODE_TOF_UD (0x000c) /* TSI TOF-Mode Up-Down */
#define LWL_TSI_MODE_SM2 (0x000e) /* TSI Strobo-Mode 2 - h/w coded */
/*
**------------------------------------------------------------------------------
** Define structure of a TOF histogram data item.
*/
struct tof_histog {
int cntr_nmbr; /* Counter number */
uint lo_edge; /* Low edge of first bin (20-bit value) */
uint hi_edge; /* Top edge of last bin (20-bit value) */
usint flag; /* Bit mask giving info on histog -- may be
** used to help optimise the code */
usint bytes_per_bin; /* Number of bytes in each histogram bin */
uint n_bins; /* Number of bins in histogram */
uint cnt_early_up; /* Count of early events (pol'n up) */
uint cnt_late_up; /* Count of late events (pol'n up) */
uint cnt_early_down; /* Count of early events (pol'n down) */
uint cnt_late_down; /* Count of late events (pol'n down) */
uint *bin_edge; /* Pointer to array of bin edges */
union { /* Pointer to histogram array */
uchar *b_bin_data; /* .. pointer if it's 8-bit bins */
usint *w_bin_data; /* .. pointer if it's 16-bit bins */
uint *l_bin_data; /* .. pointer if it's 32-bit bins */
} u;
};
/* Define a TOF 'edge-info' structure. This structure is created
** as a result of a TOF 'edge-array' in a SQHM__TOF config cmnd.
*/
struct tof_edge_info {
uint n_bins; /* Number of bins in histogram */
uint flag; /* Flag bits defining type of histo */
uint bin_span; /* Time spanned by a histogram bin (20-bit
** value) if bin width is constant. Otherwise
** it is zero. */
uint hi_edge; /* Top edge of last bin (20-bit value) */
uint edges[2]; /* Array of edge data (20-bit values). There
** are actually (n_bins+1) items in the array
** and give the bottom edges of the bin */
};
/* Define structure of a TOF 'edge-array' in SQHM__TOF config cmnd
*/
struct tof_edge_arr {
uint n_bins; /* Number of bins in histogram */
uint flag; /* Flag (0/1) for fixed/variable bin size */
uint edges[2]; /* Array of bottom edges (20-bit values) */
};
/* Define structure of a TOF 'bank' in SQHM__TOF config command
*/
struct tof_bank {
usint first; /* Number of first counter in bank */
usint n_cntrs; /* Number of counters in bank */
usint edge_indx; /* Index of edge array */
usint bytes_per_bin; /* Number of bytes per bin */
};
/*
**------------------------------------------------------------------------------
** Define command structure.
*/
struct req_buff_struct { /* For messages to SinqHM */
uint bigend;
uint cmnd;
union {
char filler[56];
struct {uint max_pkt,
strt_mode;} cnct;
struct {uint mode;
union {
struct {
uint n_buffs;
uint n_bytes;
} trans;
struct {
uint n_hists;
uint lo_bin;
uint num_bins;
uint bytes_per_bin;
uint compress;
} hm_dig;
struct {
uint n_extra_bytes;
usint n_edges;
usint n_banks;
uint preset_delay;
struct tof_edge_arr edge_0;
struct tof_bank bank_0;
} tof;
struct {
uint n_extra_bytes;
usint n_edges;
usint n_banks;
uint preset_delay;
usint xFactor;
usint yFactor;
usint xOffset;
usint yOffset;
usint xSize;
usint ySize;
struct tof_edge_arr edge_0;
struct tof_bank bank_0;
} psd;
} u;
} cnfg;
struct {uint mask;} dbg;
struct {uint sub_code;} decnfg;
struct {uint sub_cmnd;} daq;
struct {uint sub_code,
x_lo,
nx,
y_lo,
ny,
xdim,
nhist;} project;
struct {uint hist_no,
first_bin,
n_bins;} read;
struct {uint hist_no;} select;
struct {uint hist_no,
first_bin,
n_bins,
bytes_per_bin;} write;
struct {uint hist_no,
first_bin,
n_bins;} zero;
} u;
};
/*
**------------------------------------------------------------------------------
** Define status response structure.
*/
struct rply_buff_struct { /* For messages from SinqHM */
uint bigend;
uint status;
uint sub_status;
union {
char message[52];
struct {uint port;
uint pkt_size;
uint hm_mode;
uint n_hists;
uint num_bins;
uint bytes_per_bin;
uint curr_hist;
uint max_block;
uint total_bytes;
uint lo_cntr;
uint lo_bin;
uint compress;
uint up_time;} cnct;
struct {usint daq_now;
usint daq_was;
usint filler_mask;
usint server_mask;} daq;
struct {uint n_extra_bytes;
uint up_time;
usint offset_vxWorks_ident;
usint offset_vxWorks_date;
usint offset_instr;
usint offset_def_ident;
usint offset_sinqhm_main_ident;
usint offset_sinqhm_main_date;
usint offset_sinqhm_server_ident;
usint offset_sinqhm_server_date;
usint offset_sinqhm_filler_ident;
usint offset_sinqhm_filler_date;
usint offset_sinqhm_routines_ident;
usint offset_sinqhm_routines_date;} ident;
struct {uint n_bins;
uint bytes_per_bin;
uint cnts_lo;
uint cnts_hi;} project;
struct {uint first_bin;
uint n_bins;
uint bytes_per_bin;
uint cnts_lo;
uint cnts_hi;} read;
struct {uint cfg_state;
usint n_hists, curr_hist;
uint num_bins;
uint max_n_hists;
uint max_num_bins;
uchar max_srvrs, act_srvrs, bytes_per_bin, compress;
usint daq_now, filler_mask;
uint max_block;
usint tsi_status, flags;
union {
uint dead_time;
uint dts;
uint both;
} dt_or_dts;
uint num_bad_events;
uint up_time;} status;
} u;
};
/*
**------------------------------------------------------------------------------
** Define structure of message to SinqHM-filler.
*/
struct msg_to_filler_struct { /* For messages to SinqHM-filler */
union {
char message[32]; /* Ensure buffer is 32 bytes total */
struct {
uint cmnd;
uint index;
usint new_mask;} uu;
} u;
};
/*======================================================= End of SinqHM_def.h */

351
sinqhm/SinqHM_gbl.h Executable file
View File

@ -0,0 +1,351 @@
/*======================================= [...SinqHM]SinqHM_gbl.h - Ident V01N
**
** Include file of Gbl Variables for SinqHM_srv and its children.
*/
#ifndef uint
#define uint unsigned int
#endif
#ifndef usint
#define usint unsigned short int
#endif
#ifndef uchar
#define uchar unsigned char
#endif
/*
**==================== Global Variables ======================================
** Note:
** On VxWorks, all these global variables are visible by all tasks.
** Any changes to them should therefore only be done if protected
** by a semaphore.
**
** At present, only the parent process changes these variables in a
** 'significant' way (I don't count updating diagnostic counters such
** as Rw_bytes_got!).
*/
int My_errno;
int Cnt_SIGUSR1;
char Inet_host[32];
char Inet_addr[20];
int Dbg_mask; /* This is the log'l or of Dbg_lev0, etc */
int Dbg_lev0, Dbg_lev1, Dbg_lev2, Dbg_lev3;
int Cfgn_done; /* == 0 if SinqHM_srv not configured */
/*
** The buffer for holding Hist Mem data is pointed to
** by Hist_base_addr.
*/
void *Hist_base_addr;
/*
** The MEN board has a divided memory architecture: below 32 MB everything
** is normal. The area above has to be allocated in a separate memory
** partition with the partition number stored in sysHighMemPart. This
** now is a flag which determines if Hist_base_addr has been allocated in
** such a way in order to be able to free it properly again.
**/
int Hist_base_MEN_alloc;
/*
** The buffer for holding a frame of data for CERCA type
** interfaces (e.g. HRPT) is pointed to by Frame_base_addr.
*/
void *Frame_base_addr;
uint Hm_mode_ALL; /* The "total" mode of the histogram memory */
uint Hm_mode; /* The basic mode of the histogram memory */
uint Hm_mode_DEBUG; /* The SQHM__DEBUG bit of Hm_mode_ALL */
uint Hm_mode_UD; /* The SQHM__UD bit of Hm_mode_ALL */
uint Hm_mode_BO; /* The SQHM__BO bits of Hm_mode_ALL */
uint Hm_mode_STROBO; /* The SQHM__STROBO bit of Hm_mode_ALL */
uint Hm_mode_REFLECT; /* The SQHM__REFLECT bit of Hm_mode_ALL */
uint Hm_mode_NO_STAT; /* The SQHM__NO_STAT bit of Hm_mode_ALL */
uint N_hists; /* The number of histograms */
uint N_bins; /* The number of bins per histogram */
uint Lo_cntr; /* The first counter in TOF mode */
uint Lo_bin; /* The first bin of the histogram */
uint Hi_bin; /* The top bin of the histogram */
uint Bytes_per_bin; /* The number of bytes per bin */
uint Compress; /* The bin compression factor */
uint Curr_hist; /* The currently selected histogram */
uint Total_bytes; /* The total number of bytes of histogram mem */
uint Cnts_lo; /* Count of hits below histogram(s) */
uint Cnts_hi; /* Count of hits above histogram(s) */
uchar *Tran_buff_base; /* Pointer to start of curr buff in TRANS mode */
uchar *Next_char; /* Pointer to next free byte in TRANS mode */
uint Bytes_free; /* Space left in current buffer in TRANS mode */
uint MDI_mode; /* Mode of Multi-detector interface as obtained
** from the Extended Time-Stamp-Info packets */
uint Frame_hdr; /* The frame header (in HRPT mode) */
uint Frame_num; /* The frame number (in HRPT mode) */
usint SinqHM_Dsbl_Mask; /* The data-acq disable mask */
usint Server_masks[MAX_CLIENTS+1]; /* The daq masks for ..
** ..servers (0 is Filler) */
/*--------------------------------------*/
time_t Sqhm_start_time; /* The time that SinqHM-main started */
uint Port_base;
pid_t Parent_pid;
pid_t Child_pid[MAX_CLIENTS+1];
int Child_exit_status[MAX_CLIENTS];
int Child_cnct_skt[MAX_CLIENTS+1];
int Child_rw_skt[MAX_CLIENTS+1];
pid_t Filler_pid; /* The process ID of the SinqHM-filler */
char Filler_name[20]; /* The name of the SinqHM-filler */
char Tsk_name[MAX_CLIENTS+1][20]; /* The name of the SinqHM-servers */
char Instr_name[16]; /* This identifies the instrument */
char Def_ident[8]; /* This is Ident of SinqHM_def.h */
char Sqhm_main_ident[8]; /* This is Ident of main program */
char Sqhm_main_date[32]; /* This is compil date of main program */
char Sqhm_serv_ident[8]; /* This is Ident of server program */
char Sqhm_serv_date[32]; /* This is compil date of server program */
char Sqhm_fill_ident[8]; /* This is Ident of filler program */
char Sqhm_fill_date[32]; /* This is compil date of filler program */
char Sqhm_rout_ident[8]; /* This is Ident of routines */
char Sqhm_rout_date[32]; /* This is compil date of routines */
uint Lwl_hdr_daq_mask; /* Mask of header bits to be tested before
** histogramming a packet */
uint Lwl_hdr_daq_soll; /* Required value of masked hdr bits */
uint Rw_bytes_got, Rw_bytes_put;
uint Nrl_active; /* True if Neutron Rate Low bit set */
uint Daq_active; /* True if Hdr Mask Bits are correct so that
** data acquisition is active */
int Print_hdr; /* Set to True to get header printed in Filler */
uint N_events; /* # of events collected */
uint N_skipped; /* # of events skipped */
uint N_no_coin_tsi; /* # of "normal" TSI packets */
uint N_coin_tsi; /* # of "coincidence-mode" TSI packets */
uint Tof_dts_soll; /* Delay-Time-to-Start (soll-wert) */
uint Tof_count_bad_counter_number; /* Counter of number
** of TOF packets received in which
** the counter number is bad.
*/
uint Num_bad_events; /* Number of bad events (from last "coinc"
** type TSI */
union {
uint dead_time;
uint dts;
uint both;
} Dt_or_dts; /* Dead-time or Delay-Time-to-Start from TSI packets */
usint Tsi_status_info; /* Status info from last TSI */
usint Tsi_flags; /* Various flags from last TSI */
uint *Lwl_fifo; /* This gets set to 0x80810080. ..
** .. It is the address via which ..
** .. one reads data from the fibre ..
** .. optic link (Licht-Wellen-Leiter)
*/
uint *Lwl_csr; /* When we have one, this will get ..
** .. set to the addr of the optic ..
** .. link CSR. In the mean time, it ..
** .. is dummy (Lwl_dummy_csr).
*/
uint Lwl_dummy_csr; /* This is the dummy CSR till we have ..
** .. a real one.
*/
uint Filler_flag;
SEM_ID Sem_Filler;
SEM_ID Sem_Server;
MSG_Q_ID MsgQ_to_filler;
MSG_Q_ID MsgQ_to_server[MAX_CLIENTS+1]; /* Index 0 is for messages ..
** .. to SinqHM-master. The ..
** others are to the various ..
** servers.
*/
uint Sem_tmo;
uint Use_sem_tmo; /* If zero, disable sem timeouts */
/*--------------------------------------*/
struct tof_histog *Tof_descr[MAX_TOF_CNTR]; /* An array of pointers to
** the data structures for the
** histos in TOF mode.
*/
uint N_tof_edges; /* The number of edge arrays */
struct tof_edge_info *Tof_edges[MAX_TOF_EDGE]; /* An array of pointers to
** data structures for the bin
** boundary information.
*/
/*--------------------------------------*/
int FillTimer_active; /* Set True if FillTimer active */
int FillTimer_expired; /* Set True in handler */
timer_t FillTimerId; /* Identifier for Filler timer */
struct itimerspec FillerTime; /* Set to Filler timer interval */
/*--------------------------------------*/
uchar *VmioBase; /* Base address of VMIO10 module, if present */
uchar Vmio_Dummy[64]; /* Dummy VMIO10 addr space, in case absent */
jmp_buf Vmio_trap_env;
/*==========================================================================
Special variables for decoding PSD data: The PSD detector position is
calculated as: coord = TXPOS*calibfactor + caliboffset. Thus we need two
factors for each direction. In addition we need to keep track of flashes
and hits on the detector for diagnostic reasons.
---------------------------------------------------------------------------*/
int psdXOffset;
int psdYOffset;
int psdXFactor;
int psdYFactor;
int psdFlashCount;
int psdHitCount;
int psdXSize;
int psdYSize;
int psdXORF, psdConf;
/*========================== Define the function prototypes ================*/
void catch_int_signal (
int signo);
void catch_machine_check (
int signo);
void catch_signal (
int signo);
int chk_config_alloc (
int skt,
struct req_buff_struct *request,
struct rply_buff_struct *reply);
void cleanup_children ();
int close_down_offspring (
struct req_buff_struct *request,
struct rply_buff_struct *reply);
void do_daq (
struct rply_buff_struct *reply,
int index,
int sub_cmnd);
int do_command (
int index,
int skt,
int pkt_size,
struct req_buff_struct *rqst,
struct rply_buff_struct *reply);
int do_project (
int index,
struct rply_buff_struct *rply_bf,
int rw_skt,
int pkt_size,
uint sub_code,
uint x_lo,
uint nx,
uint y_lo,
uint ny,
uint xdim,
uint h_slct);
int do_read (
int index,
struct rply_buff_struct *rply_bf,
int rw_skt,
int pkt_size,
uint nbins,
uint first,
uint hist_no);
int do_SQHM__HM_DIG_alloc (
struct req_buff_struct *request,
struct rply_buff_struct *reply);
int do_SQHM__HRPT_alloc (
struct req_buff_struct *request,
struct rply_buff_struct *reply);
int do_SQHM__TOF_alloc (
int skt,
struct req_buff_struct *request,
struct rply_buff_struct *reply);
int do_SQHM__PSD_alloc (
int skt,
struct req_buff_struct *request,
struct rply_buff_struct *reply);
int do_SQHM__TRANS_alloc (
struct req_buff_struct *request,
struct rply_buff_struct *reply);
int do_write (
int index,
struct req_buff_struct *req_bf,
struct rply_buff_struct *rply_bf,
int rw_skt,
int pkt_size,
int nbins,
int first,
int bytes_per_bin,
int hist_no);
void do_zero (
struct rply_buff_struct *reply,
int index,
int nbins,
int fst_bin,
int hist_no);
void failInet (
char *text);
void failInet_port (
char *text, int port);
void free_HM_memory (void *extras);
void getErrno (
int *his_errno);
pid_t get_pid ();
int hm_zero (
int index, int nbins, int first, int hist_no);
void kill_children ();
void lwl_Fifo_Flush ();
int lwl_Packet_Read (
uint hdr,
uchar *buff);
int make_child (
int proc (),
int flag,
int pkt_size);
int make_filler (
int suspendMode);
int net_flush (
int skt,
int nbytes);
void process_coinc_tsi (
uint hdr);
void process_psd_tsi (
uint hdr);
void process_no_coinc_tsi (
uint hdr);
void process_gummi_monitor(
uint hdr);
int rply_status_send (
int skt,
struct rply_buff_struct *rply_bf);
void rply_status_setup (
struct rply_buff_struct *rply_bf,
int status,
int sub_status,
char *msg);
int rply_status_setup_and_send (
int skt,
struct rply_buff_struct *rply_bf,
int status,
int sub_status,
char *msg);
uchar *selectNewBuffer (uchar *nxt);
void setupLevelGenerator (
int use_level_gen,
char *base_addr);
void setup_inet_info (
char *host,
int host_size,
char *addr,
int addr_size);
int sleep (
int xx);
char *StrJoin (
char *result,
int result_size,
char *str_a,
char *str_b);
int SinqHM_filler (
int suspend_flag);
void SinqHM_filler_setup_id ();
void SinqHM_routines_setup_id ();
void SinqHM_server_setup_id ();
int SinqHM_server (
int suspend_flag,
int index,
int pkt_size);
/*===================================================== End of SinqHM_gbl.h */

1399
sinqhm/SinqHM_srv_filler.c Executable file

File diff suppressed because it is too large Load Diff

378
sinqhm/SinqHM_srv_main.c Executable file
View File

@ -0,0 +1,378 @@
#define IDENT "1D02"
/*
** +--------------------------------------------------------------+
** | Paul Scherrer Institute |
** | SINQ Division |
** | |
** | This software may be used freely by non-profit organizations.|
** | It may be copied provided that the name of P.S.I. and of the |
** | author is included. Neither P.S.I. nor the author assume any |
** | responsibility for the use of this software outside of P.S.I.|
** +--------------------------------------------------------------+
**
** Module Name . . . . . . . . : [...SinqHM]SinqHM_srv_main.c
**
** Author . . . . . . . . . . : D. Maden
** Date of creation . . . . . . : Oct 1996
**
** Updates:
** 1A01 1-Oct-1996 DM Initial version.
** 1B01 16-Jul-1997 DM Flush fibre-optic FIFO on SQHM_ZERO and SQHM_WRITE.
** 1C01 24-Jun-1998 DM Add TOF support.
** 1C06 10-Aug-1999 DM Add instrument dependent conditional code.
**---------------------------------------------------------------------------
** SinqHM_srv_main.c is the main program of a SINQ Histogram Memory process
** which will run in a front-end processor and perform the necessary
** operations for a SINQ multi-detector.
**
** Communication between SinqHM_srv and the client is via TCP/IP protocol.
**
** To compile and link this program for VxWorks on PSS123, use:
**
ccvx '-DINST="<instr>"' SinqHM_srv_main.c
ccvx '-DINST="<instr>"' SinqHM_srv_routines.c
ccvx '-DINST="<instr>"' SinqHM_srv_filler.c
ccvx '-DINST="<instr>"' SinqHM_srv_server.c
** where
ccvx = ccppc -O0 \
-mcpu=603 \
-I${WIND_BASE}/target/h \
-fno-builtin \
-fno-for-scope \
-nostdinc \
-DCPU=PPC603 \
-D_GNU_TOOL \
-gdwarf -c -Wimplicit
** and
** <instr> = DMC, SANS, FOCUS, HRPT, TRICS or POLDI
ldppc -o SinqHM_srv.o -r SinqHM_srv_main.o \
SinqHM_srv_routines.o \
SinqHM_srv_filler.o \
SinqHM_srv_server.o
** and, on the target,
**
** -> ld < /home/pss123/aco/maden/wind/SinqHM/SinqHM_srv.o
** -> taskSpawn "SinqHM_srv", 100, 8, 20000, SinqHM_srv, <port>
** ^
** |
** default = 2400 ------+
**
**====================================================================
*/
#include "vxWorks.h"
#include "taskLib.h"
#include "msgQLib.h"
#include "sockLib.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <setjmp.h>
#include <time.h>
#include <signal.h> /* Get POSIX signal definitions. */
#include <timers.h>
#include <sys/mman.h> /* Get POSIX mem mgmnt definitions. */
#include <sys/wait.h> /* Get POSIX wait definitions. */
/*
**==================== Global Definitions =====================================
*/
#include "SinqHM_def.h"
#include "SinqHM_gbl.h"
/*
**=============================================================================
** Local routines.
**
** None
*/
/*==============================================================================
** Main line program
** ------------------
**============================================================================*/
int SinqHM_srv (int port, int use_level_gen, char *base_addr,
int arg4, int arg5, int arg6, int arg7, int arg8, int arg9,
int suspend) {
/*============================================================================*/
struct req_buff_struct req_buff;
struct rply_buff_struct rply_buff;
int i, j, is, status, cntr;
int keep_going = OK;
int bytes_to_come, n_bytes_got;
char *p_addr;
int cl_port;
int do_send;
int cnct_skt; /* Connection socket */
int rw_skt; /* Read/write socket */
struct sockaddr_in lcl_sockname;
struct sockaddr_in rmt_sockname;
int rmt_sockname_len;
int pkt_size;
time_t timer;
sigset_t proc_sigmask;
struct sigaction sig_action;
/*============================================================================
*/
if (suspend != 0) {
printf ("\nSinqHM_srv: Suspending ...\n");
taskSuspend (0); /* We've been told to suspend ourself, ..
** .. presumably for debug reasons.
*/
printf ("\nSinqHM_srv: Suspension ended!\n");
}
/*============================================================================
** Perform the initialisation of global variables ...
*/
StrJoin (Instr_name, sizeof (Instr_name), INST, ""); /* Save the instr.
** name in a global
*/
StrJoin (Def_ident, sizeof (Def_ident), SINQHM_DEF_ID, "");
StrJoin (Sqhm_main_ident, sizeof (Sqhm_main_ident), IDENT, "");
StrJoin (Sqhm_main_date, sizeof (Sqhm_main_date), __DATE__, ", ");
StrJoin (Sqhm_main_date, sizeof (Sqhm_main_date), Sqhm_main_date, __TIME__);
SinqHM_server_setup_id ();
SinqHM_filler_setup_id ();
SinqHM_routines_setup_id ();
time (&Sqhm_start_time); /* Initialise the start time */
StrJoin (Tsk_name[0], sizeof (Tsk_name[0]), taskName (get_pid ()), "");
Dbg_mask = 0;
Dbg_lev0 = 0;
Dbg_lev1 = 1;
Dbg_lev2 = 0;
Dbg_lev3 = 0;
Cfgn_done = 0; /* Force a configuration before we can do anything. */
free_HM_memory (NULL); /* Release memory (possibly) in case ..
** .. of a restart of the program */
Parent_pid = get_pid ();
Filler_pid = 0;
for (i = 0; i <= MAX_CLIENTS; i++) {
Child_pid[i] = 0;
Child_exit_status[i] = 0;
}
if (Sem_Filler == NULL) {
Sem_Filler = semBCreate (SEM_Q_FIFO, SEM_FULL);
}
if (Sem_Server == NULL) {
Sem_Server = semBCreate (SEM_Q_FIFO,SEM_FULL);
}
/*
** Debug hint - set Use_sem_tmo to zero to disable semaphore time-outs
** during debug sessions. This will stop FILLER falling off.
*/
Sem_tmo = 10; /* 10 second time-out by default */
Use_sem_tmo = 0;
setupLevelGenerator (use_level_gen, base_addr);
/*============================================================================
** Clear the process signal mask to let in all signals (actually, on
** PPC VxWorks this seems to cause all signals to get ignored!) and then
** declare action routine for SIGUSR1. Our children signal with SIGUSR1
** just before they exit in a more or less controlled manner. If the
** child gets deleted from the shell, it will not signal.
*/
Cnt_SIGUSR1 = 0;
status = sigemptyset (&proc_sigmask);
status = sigprocmask (SIG_SETMASK, &proc_sigmask, NULL);
status = sigemptyset (&sig_action.sa_mask);
sig_action.sa_handler = catch_signal;
sig_action.sa_flags = 0;
if (sigaction (SIGUSR1, &sig_action, NULL) == -1) {
getErrno (&My_errno);
perror ("sigaction error:");
exit (0);
}
/*============================================================================
** Get a port number to use. If the argument "port" is not
** a valid port number (not in range 128 to 32767), use PORT_BASE.
*/
Port_base = PORT_BASE;
if ((port >= 128) && (port < 32768)) Port_base = port;
/*============================================================================
** Create a TCP/IP socket for receiving connection requests, bind it and
** set it to listen.
*/
cnct_skt = socket (AF_INET, SOCK_STREAM, 0);
if (cnct_skt == -1)
failInet_port ("\nhmRoot%d -- Cnct-Socket socket error", Port_base);
status = 1;
setsockopt(cnct_skt, SOL_SOCKET, SO_REUSEADDR, &status, sizeof(int));
lcl_sockname.sin_family = AF_INET;
lcl_sockname.sin_port = htons (Port_base);
lcl_sockname.sin_addr.s_addr = 0;
status = bind (cnct_skt, (struct sockaddr *) &lcl_sockname,
sizeof (lcl_sockname));
if (status != 0) failInet_port ("\nhmRoot%d -- Cnct-Socket bind error",
Port_base);
status = listen (cnct_skt, 5);
if (status != 0) failInet_port ("\nhmRoot%d -- Cnct-Socket listen error",
Port_base);
/*
** Clients must now connect to the Connect-port and send either a
** connect, configure, deconfigure, status or exit request. A
** successful configure request must precede any connection request.
**
** When a configure request arrives, the histogram data structures are
** initialised, the histogram filler process (FILLER) is spawned and
** connection requests are enabled. A status reply is sent to the
** client and the connection closed.
**
** When a connection request arrives, a child will be spawned to
** handle the connection. The child will be told which port to use
** and he will release a semaphore when the port is ready. The parent
** then sends the client a reply to tell him which port to use. The
** connection is then closed to await further connections.
*/
setup_inet_info (Inet_host, sizeof (Inet_host), /* Find out who we are */
Inet_addr, sizeof (Inet_addr));
printf ("\n%s: Program Ident = \"%s\". Started on %s (%s).\n",
Tsk_name[0], IDENT, Inet_host, Inet_addr);
printf ("%s: Protocol Ident = \"%s\"\n", Tsk_name[0], SINQHM_DEF_ID);
#ifndef INST
#error Define the target instrument via the symbol "INST"!
#endif
if (strcmp (INST, "DMC") == 0) {
printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "DMC");
Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK;
Lwl_hdr_daq_soll = 0;
}else if (strcmp (INST, "SANS") == 0) {
printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "SANS");
Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK;
Lwl_hdr_daq_soll = 0;
}else if (strcmp (INST, "FOCUS") == 0) {
/*
Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK | LWL_HDR_SYNC2_MASK;
Lwl_hdr_daq_soll = 0;
*/
Lwl_hdr_daq_mask = 0x00f00000;
Lwl_hdr_daq_soll = 0x00200000;
printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "FOCUS");
}else if (strcmp (INST, "HRPT") == 0) {
printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "HRPT");
Lwl_hdr_daq_mask = LWL_HDR_SYNC0_MASK | LWL_HDR_SYNC2_MASK;
Lwl_hdr_daq_soll = LWL_HDR_SYNC2_MASK;
}else if (strcmp (INST, "TRICS") == 0) {
printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "TriCS");
/*
Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK | LWL_PSD_PWF;
Lwl_hdr_daq_soll = 0;
*/
Lwl_hdr_daq_mask = 0x00f00000;
Lwl_hdr_daq_soll = 0x00e00000;
}else if (strcmp(INST,"AMOR") == 0) {
printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "AMOR");
Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK | LWL_PSD_PWF;
Lwl_hdr_daq_soll = 0;
/*
Lwl_hdr_daq_mask = 0x00f00000;
Lwl_hdr_daq_soll = 0x00600000;
*/
}else if (strcmp (INST, "POLDI") == 0) {
printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "POLDI");
Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK;
Lwl_hdr_daq_soll = 0;
printf ("%s: Warning -- Lwl_hdr_daq_mask and Lwl_hdr_daq_soll are "
"provisional!\n", Tsk_name[0]);
}else {
printf ("%s: Instrument is not defined\n", Tsk_name[0]);
Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK;
Lwl_hdr_daq_soll = 0;
}
printf ("%s: Lwl_hdr_daq_mask = 0x%08x", Tsk_name[0], Lwl_hdr_daq_mask);
if ((Lwl_hdr_daq_mask & LWL_HDR_NRL_MASK) != 0) printf (" NRL");
if ((Lwl_hdr_daq_mask & LWL_HDR_SYNC3_MASK) != 0) printf (" SYNC3");
if ((Lwl_hdr_daq_mask & LWL_HDR_SYNC2_MASK) != 0) printf (" SYNC2");
if ((Lwl_hdr_daq_mask & LWL_HDR_SYNC1_MASK) != 0) printf (" SYNC1");
if ((Lwl_hdr_daq_mask & LWL_HDR_SYNC0_MASK) != 0) printf (" SYNC0");
printf ("\n%s: Lwl_hdr_daq_soll = 0x%08x", Tsk_name[0], Lwl_hdr_daq_soll);
if ((Lwl_hdr_daq_soll & LWL_HDR_NRL_MASK) != 0) printf (" NRL");
if ((Lwl_hdr_daq_soll & LWL_HDR_SYNC3_MASK) != 0) printf (" SYNC3");
if ((Lwl_hdr_daq_soll & LWL_HDR_SYNC2_MASK) != 0) printf (" SYNC2");
if ((Lwl_hdr_daq_soll & LWL_HDR_SYNC1_MASK) != 0) printf (" SYNC1");
if ((Lwl_hdr_daq_soll & LWL_HDR_SYNC0_MASK) != 0) printf (" SYNC0");
printf ("\n");
while (keep_going == OK) {
rmt_sockname_len = sizeof (rmt_sockname);
rw_skt = accept (cnct_skt, (struct sockaddr *) &rmt_sockname,
&rmt_sockname_len);
if (rw_skt == -1) {
getErrno (&My_errno);
failInet_port ("\nhmRoot%d -- Cnct-Socket accept error", Port_base);
/* No return */
}
Rw_bytes_got = 0; Rw_bytes_put = 0;
p_addr = inet_ntoa (rmt_sockname.sin_addr);
cl_port = ntohs (rmt_sockname.sin_port);
printf ("\n%s: Connected to Host %s, Port %d.\n",
Tsk_name[0], p_addr, cl_port);
bytes_to_come = sizeof (req_buff); /* Read a command */
p_addr = (char *) &req_buff;
while (bytes_to_come > 0) {
n_bytes_got = recv (rw_skt, p_addr, bytes_to_come, 0);
if (n_bytes_got <= 0) break;
Rw_bytes_got += n_bytes_got;
bytes_to_come -= n_bytes_got;
p_addr += n_bytes_got;
}
if (Cnt_SIGUSR1 > 0) { /* Have any children exited? */
if (Dbg_lev0) printf ("hmRoot%d: Cleaning up children ...", Port_base);
cleanup_children (); /* Yes, update our database. */
if (Dbg_lev0) printf ("\n ... cleanup of children done.\n");
}
if (n_bytes_got < 0) {
printf ("\007"
"%s -- R/W-Socket recv error\n", Tsk_name[0]);
printf ("%s -- Connection to %s will be closed.\n", Tsk_name[0],
inet_ntoa (rmt_sockname.sin_addr));
}else if (n_bytes_got == 0) {
printf ("\007"
"%s -- no command received!\n", Tsk_name[0]);
printf ("%s -- Connection to %s will be closed.\n", Tsk_name[0],
inet_ntoa (rmt_sockname.sin_addr));
}else if (n_bytes_got != sizeof (req_buff)) {
printf ("\007"
"%s -- command packet has wrong number of bytes:"
" %d instead of %d\n", Tsk_name[0],
n_bytes_got, sizeof (req_buff));
printf ("%s -- Connection to %s will be closed.\n", Tsk_name[0],
inet_ntoa (rmt_sockname.sin_addr));
}else if (ntohl (req_buff.bigend) != 0x12345678) {
printf ("\007"
"%s -- big-endian/little-endian problem!\n"
" Buffer received in non-network byte order!\n", Tsk_name[0]);
}else {
do_command (0, rw_skt, 4096, &req_buff, &rply_buff);
}
close (rw_skt);
if (ntohl (req_buff.cmnd) == SQHM_EXIT) keep_going = !OK;
}
close (cnct_skt);
exit (KER__SUCCESS);
}
/*========================================= End of SinqHM_srv_main.c ========*/

4130
sinqhm/SinqHM_srv_routines.c Executable file

File diff suppressed because it is too large Load Diff

284
sinqhm/SinqHM_srv_server.c Executable file
View File

@ -0,0 +1,284 @@
#define IDENT "1A08"
/*
** +--------------------------------------------------------------+
** | Paul Scherrer Institute |
** | SINQ Division |
** | |
** | This software may be used freely by non-profit organizations.|
** | It may be copied provided that the name of P.S.I. and of the |
** | author is included. Neither P.S.I. nor the author assume any |
** | responsibility for the use of this software outside of P.S.I.|
** +--------------------------------------------------------------+
**
** Module Name . . . . . . . . : [...SinqHM]SinqHM_srv_server.c
**
** Author . . . . . . . . . . : D. Maden
** Date of creation . . . . . . : Oct 1996
**
** Updates:
** 1A01 2-Oct-1996 DM Initial version.
**
** SinqHM_srv_server.c forms a child process of the SINQ Histogram Memory
** process. It does the communication with the client.
**
** To compile this program for VxWorks on PSS123, use:
**
ccvx SinqHM_srv_server.c
** where
ccvx = ccppc -O0 \
-mcpu=603 \
-I${WIND_BASE}/target/h \
-fno-builtin \
-fno-for-scope \
-nostdinc \
-DCPU=PPC603 \
-D_GNU_TOOL \
-gdwarf -c -Wimplicit
**
**====================================================================
*/
#include <vxWorks.h>
#include <taskLib.h>
#include <msgQLib.h>
#include <sockLib.h>
#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
#include <unistd.h> /* Get the POSIX environment defined ..
** .. see DEC OSF/1 Guide to Realtime Programming */
#include <errno.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/mman.h> /* Get POSIX mem mgmnt definitions. */
#include <signal.h> /* Get POSIX signal definitions. */
#include <timers.h>
#include <sys/wait.h> /* Get POSIX wait definitions. */
/*
**==================== Global Definitions =====================================
*/
#include "SinqHM_def.h"
#include "SinqHM_gbl.h"
/*==============================================================================
Local Routines for SRV
** None
*/
/*==============================================================================
Global Routines for SRV
**
*/
void SinqHM_server_setup_id () {
/* ======================
** Simply copy some ident information to global variables
** for use by the SQHM_IDENT request.
*/
StrJoin (Sqhm_serv_ident, sizeof (Sqhm_serv_ident), IDENT, "");
StrJoin (Sqhm_serv_date, sizeof (Sqhm_serv_date), __DATE__, ", ");
StrJoin (Sqhm_serv_date, sizeof (Sqhm_serv_date), Sqhm_serv_date, __TIME__);
}
/*==============================================================================
Here beginneth the main code for SinqHM_server ...
**
** Note: There must be NO return from this function.
*/
int SinqHM_server (int suspend_flag, int index, int pkt_size) {
/* =============
**
** Set up TCP/IP port for operations with client, accept his
** connection and perform services for him.
*/
int status, status0, status1;
int i, is, nbytes, bytes_to_come;
char recd[80];
char *p_nxt_byte;
int cnct_skt, rw_skt;
struct sockaddr_in my_lcl_sockname;
struct sockaddr_in my_rmt_sockname;
int my_rmt_sockname_len;
char *buff_pntr;
int port;
sigset_t proc_sigmask;
struct sigaction sig_action;
struct req_buff_struct my_req_bf;
struct rply_buff_struct my_rply_bf;
port = Port_base + index;
/*============================================================================
*/
StrJoin (Tsk_name[index], sizeof (Tsk_name[0]), taskName (get_pid ()), "");
if (suspend_flag != 0) {
printf ("\n%s: Suspending ..\n", Tsk_name[index]);
taskSuspend (0); /* We've been told to suspend ourself, ..
** .. presumably for debug reasons.
*/
printf ("\n%s: Suspension ended!\n", Tsk_name[index]);
}
/*============================================================================
** Define our signal mask first and define an action routine to catch
** the SIGINT signal our parent will send us when he wants us to exit.
*/
status = sigemptyset (&proc_sigmask);
status = sigprocmask (SIG_SETMASK, &proc_sigmask, NULL);
status = sigemptyset (&sig_action.sa_mask);
sig_action.sa_handler = catch_int_signal;
sig_action.sa_flags = 0;
if (sigaction (SIGINT, &sig_action, NULL) == -1) {
getErrno (&My_errno);
perror ("sigaction error:");
Child_exit_status[index] = -1; /* Tell our parent we've given up */
is = semGive (Sem_Server); /* Let our parent continue */
exit (KER__BAD_VALUE);
}
/*============================================================================
** Create a TCP/IP socket for communication, bind it and listen.
*/
Child_cnct_skt[index] = 0;
cnct_skt = socket (AF_INET, SOCK_STREAM, 0);
if (cnct_skt == -1) {
perror (StrJoin (recd, sizeof (recd),
Tsk_name[index], " -- cnct_skt socket error"));
Child_exit_status[index] = -2; /* Tell our parent we've given up */
is = semGive (Sem_Server); /* Let our parent continue */
exit (KER__BAD_VALUE);
}
status = 1;
setsockopt(cnct_skt, SOL_SOCKET, SO_REUSEADDR, &status, sizeof(int));
my_lcl_sockname.sin_family = AF_INET;
my_lcl_sockname.sin_port = htons (port);
my_lcl_sockname.sin_addr.s_addr = 0;
status = bind (cnct_skt, (struct sockaddr *) &my_lcl_sockname,
sizeof (my_lcl_sockname));
if (status != 0) {
close (cnct_skt);
perror (StrJoin (recd, sizeof (recd),
Tsk_name[index], " -- cnct_skt bind error"));
Child_exit_status[index] = -2; /* Tell our parent we've given up */
is = semGive (Sem_Server); /* Let our parent continue */
exit (KER__BAD_VALUE);
}
status = listen (cnct_skt, 1);
if (status != 0) {
close (cnct_skt);
perror (StrJoin (recd, sizeof (recd),
Tsk_name[index], " -- cnct_skt listen error"));
Child_exit_status[index] = -3; /* Tell our parent we've given up */
is = semGive (Sem_Server); /* Let our parent continue */
exit (KER__BAD_VALUE);
}
/*============================================================================
** Tell parent our cnct port is set up and waiting by releasing
** semaphore so that our parent can continue. The parent will then
** send a message to the client telling him which port he is to use.
*/
is = semGive (Sem_Server);
if (is != OK) {
kill (Parent_pid, SIGUSR1); /* Inform parent that we are in trouble */
printf ("%s -- sem release error\n", Tsk_name[index]);
close (cnct_skt);
exit (KER__BAD_VALUE);
}
Child_cnct_skt[index] = cnct_skt;
/*============================================================================
** Ensure that our bit in SinqHM_Dsbl_Mask is clear.
*/
do_daq (&my_rply_bf, index, DAQ__CLR);
/*============================================================================
** Wait for the client to connect to our port
*/
my_rmt_sockname_len = sizeof (my_rmt_sockname);
rw_skt = accept (cnct_skt, (struct sockaddr *) &my_rmt_sockname,
&my_rmt_sockname_len);
if (rw_skt == -1) {
perror (StrJoin (recd, sizeof (recd),
Tsk_name[index], " -- cnct_skt accept error"));
close (cnct_skt);
Child_cnct_skt[index] = 0;
kill (Parent_pid, SIGUSR1); /* Inform parent that we are in trouble */
exit (KER__BAD_VALUE);
}
Child_rw_skt[index] = rw_skt;
/*
**-------------------------------------------------------------------------
** Here is the main recv loop
*/
main_loop:
/*=========
*/ bytes_to_come = sizeof (my_req_bf); /* Read a command */
p_nxt_byte = (char *) &my_req_bf;
while (bytes_to_come > 0) {
nbytes = recv (rw_skt, p_nxt_byte, bytes_to_come, 0);
if (nbytes <= 0) break;
Rw_bytes_got += nbytes;
bytes_to_come -= nbytes;
p_nxt_byte += nbytes;
}
if ((bytes_to_come == 0) &&
(ntohl (my_req_bf.bigend) == 0x12345678) &&
(ntohl (my_req_bf.cmnd) != SQHM_CLOSE)) {
is = do_command (index, rw_skt, pkt_size, &my_req_bf, &my_rply_bf);
if (is == OK) goto main_loop; /* Break out of loop on error */
}
/*
** End of the main recv loop
**-------------------------------------------------------------------------
** Get here if we drop out of the "recv" loop.
** This should only happen on getting a SQHM_CLOSE message.
** Anything else is a fatal error.
*/
do_daq (&my_rply_bf, index, DAQ__CLR); /* Ensure our inhibit bit is clear */
close (rw_skt); Child_rw_skt[index] = 0;
close (cnct_skt); Child_cnct_skt[index] = 0;
/*
** Check the various error conditions
*/
if (bytes_to_come != 0) { /* Was a complete request read? */
/* No, it may be a network error, in which case
** nbytes is -1, or nothing was read, which
** indicates that our client simply closed
** his connection (forgetting to send a
** SQHM_CLOSE message), or the client has
** screwed up the protocol! */
if (nbytes == -1) {
/* It's a network error */
perror (StrJoin (recd, sizeof (recd),
Tsk_name[index], " -- rw_skt recv error"));
status = KER__EXIT_SIGNAL;
}else if (bytes_to_come == sizeof (my_req_bf)) {
/* Our client simply closed his connection.
** Treat this as normal. */
printf ("\n%s exiting.\n", Tsk_name[index]);
status = KER__SUCCESS;
}else {
printf ("\n%s -- rw_skt recv wrong number of bytes: %d\n",
Tsk_name[index], nbytes);
status = KER__EXIT_SIGNAL;
}
}else if (ntohl (my_req_bf.bigend) != 0x12345678) {
/* Network byte-order wrong! */
printf ("\n%s -- big-endian/little-endian problem!\n"
" Buffer received in non-network byte order!\n", Tsk_name[index]);
status = KER__EXIT_SIGNAL;
}else if (ntohl (my_req_bf.cmnd) == SQHM_CLOSE) {
/* SQHM_CLOSE request received. This is normal */
printf ("\n%s exiting.\n", Tsk_name[index]);
status = KER__SUCCESS;
}else {
/* Unrecognised request received! */
printf ("\n%s -- unrecognised command received: 0x%x\n",
Tsk_name[index], ntohl (my_req_bf.cmnd));
status = KER__EXIT_SIGNAL;
}
kill (Parent_pid, SIGUSR1); /* Inform parent that we are exiting */
exit (status);
}
/*======================================= End of SinqHM_srv_server.c ========*/

415
sinqhm/bld Executable file
View File

@ -0,0 +1,415 @@
#! /bin/csh
# pss123:~sinqhm/wind/SinqHM/<instr>/bld V01G
#
# Script to compile and link the SinqHM_srv programs for vxWorks
#
# rcp -p "lnsa04:sinqhm/bld" ~/wind/SinqHM/bld
## printf 'Arg 0 = "%s"\n' $0
## printf 'Arg 1 = "%s"\n' $1
## printf 'Arg 2 = "%s"\n' $2
## printf 'Arg 3 = "%s"\n' $3
set proc = "$0"
if (`expr match "$proc" "\/"` != 1) set proc = "./$0"
cd $proc:h # Build in bld's directory!
#------------------------------------------------------------------------------
# Uncomment the following command to disable remote-copy operations
#
## alias rcp 'echo " Warning -- remote copy disabled"; echo \!\!:* > /dev/null'
#------------------------------------------------------------------------------
if ("`whoami`" == "maden") then
set src = "maden@lnsa06:sinqhm/"
else if ("`whoami`" == "sinqhm") then
set src = "koenneck@lnsa17:src/sics/sinqhm/"
else
echo Sorry, you are not recognised by this script.
exit
endif
#------------------------------------------------------------------------------
alias ccvx 'ccppc -O0 -mcpu=603 -I${WIND_BASE}/target/h ' \
'-fno-builtin -fno-for-scope ' \
'-nostdinc -DCPU=PPC603 -D_GNU_TOOL -gdwarf -c -Wimplicit'
#
set Insts = (dev dmc sans focus hrpt trics poldi amor)
if (("$1" == "") || \
("$1" == "?") || \
("$1" == "h") || \
("$1" == "he") || \
("$1" == "hel") || \
("$1" == "help")) goto show_help
printf "\n"
printf "Working directory is %s\n" "$cwd"
printf 'Source is "%s"\n' "$src"
printf "\n"
if ("$1" == "bld") goto bld
if ("$1" == "startup") goto startup
if ("$1" == "basic") goto basic
foreach inst ($Insts)
if ("$1" == "$inst") goto $inst
end
printf '\aI do not know how to build "%s"\!\n' $1
goto show_help
#===========================================================================
show_help_0:
printf '\n\007You must specify what you want to build\!\n\n'
show_help:
#=========
echo "Usage:"
echo " bld bld - copy over new version of bld script."
echo " bld startup - copy over new version of startup script."
echo " bld basic - build basic system."
echo " bld <inst> all - build all modules for instrument <inst>."
echo " bld <inst> SinqHM_srv [<module>] - build SinqHM_srv module"
echo " bld <inst> lwl_server - build lwl_server module"
echo " bld <inst> SinqHM_bootParamsConfig - build auto-config module"
echo " bld <inst> SinqHM_bootUtil - build boot-utility module"
echo " bld focus FOCUS_srv [<module>] - build FOCUS_srv module"
echo " bld <inst> auto - build auto-spawn system"
echo " "
echo "Valid instruments are:"
echo " $Insts"
echo " "
exit
#-----------------------------------------------------------------------------
bld:
#===
echo " Copying bld (previous version is bld.save) ..."
mv bld bld.save
rcp -p "${src}bld" ./bld
rcp -p "${src}bld2" ./bld2
rcp -p "${src}bld604" ./bld604
exit
#-----------------------------------------------------------------------------
startup:
#=======
echo " Copying startup ..."
rcp -p "${src}startup.template" ./startup
exit
#-----------------------------------------------------------------------------
basic:
#=====
set dflt = "$cwd"
cd $WIND_BASE/target/config/mv1603
echo " "
echo "Default directory changed to:"
echo " $cwd"
printf "Building vxWorks_basic system image ...\n\n"
touch config.h # Force a complete re-compilation
make ADDED_CFLAGS=" -DSINQHM_SPAWN=0" \
ADDED_MODULES=""
mv vxWorks vxWorks_basic
mv vxWorks.sym vxWorks.sym_basic
cp -p vxWorks_basic $dflt/vxWorks_basic
cp -p vxWorks.sym_basic $dflt/vxWorks.sym
cd $dflt
echo " Done. Result is $dflt/vxWorks_basic"
exit
#=============================================================================
# Now follow labels for all the valid instruments.
dev:
#----
set instr = Devel
set defn = '-DINST="Devel" -DDevel'
set direc = Devel/NEW
goto comn
dmc:
#---
set instr = DMC
set defn = '-DINST="DMC" -DDMC'
set direc = DMC/NEW
goto comn
sans:
#----
set instr = SANS
set defn = '-DINST="SANS" -DSANS'
set direc = SANS/NEW
goto comn
focus:
#-----
set instr = FOCUS
set defn = '-DINST="FOCUS" -DFOCUS'
set direc = FOCUS/NEW
goto comn
hrpt:
#----
set instr = HRPT
set defn = '-DINST="HRPT" -DHRPT'
set direc = HRPT/NEW
goto comn
trics:
#-----
set instr = TriCS
set defn = '-DINST="TRICS" -DTRICS'
set direc = TRICS
goto comn
poldi:
#-----
set instr = POLDI
set defn = '-DINST="POLDI" -DPOLDI'
set direc = POLDI/NEW
goto comn
amor:
#----
set instr = AMOR
set defn = '-DINST="AMOR" -DAMOR'
set direc = AMOR/NEW
goto comn
comn:
#----
echo The selected instrument is ${instr}.
if ("$2" == "") goto show_help_0
cd $direc
printf "Working directory changed to %s\n" "$cwd"
if ("$2" == "SinqHM_srv") goto SinqHM_srv
if ("$2" == "lwl_server") goto lwl_server
if ("$2" == "SinqHM_bootParamsConfig") goto SinqHM_bootParamsConfig
if ("$2" == "SinqHM_bootUtil") goto SinqHM_bootUtil
if (("$instr" == "FOCUS") && ("$2" == "FOCUS_srv")) goto FOCUS_srv
if ("$2" == "auto") goto auto
if ("$2" != "all") then
printf '\007I do not know how to build "%s" for %s\!\n' "$2" $instr
printf 'Type "bld help" for help\!\n'
exit
endif
#--------------------------------------------------------------
SinqHM_srv:
#==========
set Mods = (SinqHM_gbl.h \
SinqHM_def.h \
vmio10_def.h \
SinqHM_srv_main.c \
SinqHM_srv_routines.c \
SinqHM_srv_filler.c \
SinqHM_srv_server.c)
if (("$3" == "") || ("$3" == "all")) goto SinqHM_srv_all
foreach module ($Mods)
if ("$3" == "$module") goto SinqHM_srv_cpy
end
if (("$3" != "?") && \
("$3" != "h") && \
("$3" != "he") && \
("$3" != "hel") && \
("$3" != "help")) then
printf '"%s" is not a recognised module of SinqHM_srv\!\n\n' "$3"
endif
printf 'To build SinqHM_srv, use the command:\n'
printf '\n'
printf ' bld <instr> SinqHM_srv [module]\n'
printf '\n'
printf 'Valid instruments are:\n'
printf '\n'
printf ' %s\n' "$Insts"
printf '\n'
printf 'Valid modules are:\n'
printf '\n'
foreach module ($Mods)
printf ' %s\n' "$module"
end
printf '\n'
exit
#----------------------------------------------------------------------------
SinqHM_srv_cpy:
#--------------
echo " Copying $3 ..."
rcp -p "${src}$3" ./$3
if ("$3" == "SinqHM_gbl.h") goto SinqHM_srv_compile_all
if ("$3" == "SinqHM_def.h") goto SinqHM_srv_compile_all
if ("$3" == "vmio10_def.h") goto SinqHM_srv_compile_all
echo " Compiling $3 ..."
ccvx $defn $3
goto SinqHM_srv_link
SinqHM_srv_all:
#--------------
echo " "
echo "Building SinqHM_srv ..."
echo " Copying header files ..."
rcp -p "${src}SinqHM_gbl.h" ./SinqHM_gbl.h
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
rcp -p "${src}vmio10_def.h" ./vmio10_def.h
echo " Copying source files ..."
rcp -p "${src}SinqHM_srv_main.c" ./SinqHM_srv_main.c
rcp -p "${src}SinqHM_srv_routines.c" ./SinqHM_srv_routines.c
rcp -p "${src}SinqHM_srv_filler.c" ./SinqHM_srv_filler.c
rcp -p "${src}SinqHM_srv_server.c" ./SinqHM_srv_server.c
SinqHM_srv_compile_all:
#----------------------
echo " Compiling SinqHM_srv_main.c ..."
ccvx $defn SinqHM_srv_main.c
echo " Compiling SinqHM_srv_routines.c ..."
ccvx $defn SinqHM_srv_routines.c
echo " Compiling SinqHM_srv_filler.c ..."
ccvx $defn SinqHM_srv_filler.c
echo " Compiling SinqHM_srv_server.c ..."
ccvx $defn SinqHM_srv_server.c
SinqHM_srv_link:
#---------------
echo " Linking ..."
ldppc -o SinqHM_srv.o -r \
SinqHM_srv_main.o SinqHM_srv_routines.o \
SinqHM_srv_filler.o SinqHM_srv_server.o
echo " Done. Result is $cwd/SinqHM_srv.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
lwl_server:
#==========
echo " "
echo "Building lwl_server ..."
echo " Copying header files ..."
rcp -p "${src}vmio10_def.h" ./vmio10_def.h
echo " Copying source files ..."
rcp -p "${src}lwl_server.c" ./lwl_server.c
echo " Compiling lwl_server.c ..."
ccvx $defn lwl_server.c
echo " Done. Result is $cwd/lwl_server.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
SinqHM_bootParamsConfig:
#=======================
echo " "
echo "Building SinqHM_bootParamsConfig ..."
echo " Copying header files ..."
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source files ..."
rcp -p "${src}SinqHM_bootParamsConfig.c" \
./SinqHM_bootParamsConfig.c
echo " Compiling SinqHM_bootParamsConfig.c ..."
ccvx $defn -I${WIND_BASE}/target/config/all \
SinqHM_bootParamsConfig.c
echo " Done. Result is $cwd/SinqHM_bootParamsConfig.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
SinqHM_bootUtil:
#===============
echo " "
echo "Building SinqHM_bootUtil ..."
echo " Copying header file ..."
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source file ..."
rcp -p "${src}SinqHM_bootUtil.c" \
./SinqHM_bootUtil.c
echo " Compiling SinqHM_bootUtil.c ..."
ccvx $defn -I${WIND_BASE}/target/config/all SinqHM_bootUtil.c
echo " Done. Result is $cwd/SinqHM_bootUtil.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
FOCUS_srv:
#==========
if ($instr != "FOCUS") goto FOCUS_srv_skp
set Mods = ( FOCUS_gbl.h \
SinqHM_def.h \
FOCUS_srv_main.c )
if (("$3" == "") || ("$3" == "all")) goto FOCUS_srv_all
foreach module ( $Mods )
if ("$3" == "$module") goto FOCUS_srv_cpy
end
if (("$3" != "?") && \
("$3" != "h") && \
("$3" != "he") && \
("$3" != "hel") && \
("$3" != "help")) then
printf '"%s" is not a recognised module of FOCUS_srv\!\n\n' "$3"
endif
printf 'To build FOCUS_srv, use the command:\n'
printf '\n'
printf ' bld <instr> FOCUS_srv [module]\n'
printf '\n'
printf 'Valid instruments are:\n'
printf '\n'
printf ' %s\n' "focus"
printf '\n'
printf 'Valid modules are:\n'
printf '\n'
foreach module ($Mods)
printf ' %s\n' "$module"
end
printf '\n'
exit
#----------------------------------------------------------------------------
FOCUS_srv_cpy:
#--------------
echo " Copying $3 ..."
rcp -p "${src}$3" ./$3
if ("$3" == "FOCUS_gbl.h") goto FOCUS_srv_compile_all
if ("$3" == "SinqHM_def.h") goto FOCUS_srv_compile_all
echo " Compiling $3 ..."
ccvx $defn $3
goto FOCUS_srv_link
FOCUS_srv_all:
#--------------
echo " "
echo "Building FOCUS_srv ..."
echo " Copying header files ..."
rcp -p "${src}FOCUS_gbl.h" ./FOCUS_gbl.h
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source files ..."
rcp -p "${src}FOCUS_srv_main.c" ./FOCUS_srv_main.c
FOCUS_srv_compile_all:
#----------------------
echo " Compiling FOCUS_srv_main.c ..."
ccvx $defn FOCUS_srv_main.c
FOCUS_srv_link:
#---------------
echo " Linking ..."
ldppc -o FOCUS_srv.o -r \
FOCUS_srv_main.o
echo " Done. Result is $cwd/FOCUS_srv.o"
FOCUS_srv_skp:
#-------------
if ("$2" != "all") exit
#---------------------------------------------------------------------------
auto:
#====
set dflt = "$cwd"
cd $WIND_BASE/target/config/mv1603
echo " "
echo "Default directory changed to:"
echo " $cwd"
printf "\n\n==================================================\n"
printf \
"\n\nBuilding vxWorks_auto system image for $instr Instrument ...\n\n"
touch config.h # Force a complete re-compilation
set mods = ( $dflt/SinqHM_srv.o \
$dflt/lwl_server.o \
$dflt/SinqHM_bootParamsConfig.o \
$dflt/SinqHM_bootUtil.o )
if ($instr == FOCUS) set mods = ( $mods $dflt/FOCUS_srv.o )
make ADDED_CFLAGS=" -DSINQHM_SPAWN=1" \
ADDED_MODULES="$mods"
mv vxWorks vxWorks_auto
mv vxWorks.sym vxWorks.sym_auto
cp -p vxWorks_auto $dflt/vxWorks_auto
cp -p vxWorks.sym_auto $dflt/vxWorks.sym
cd $dflt
echo " Done. Result is $dflt/vxWorks_auto"
exit
#------------------------------------------------------------------ End of bld

432
sinqhm/bld2 Executable file
View File

@ -0,0 +1,432 @@
#! /bin/csh
# pss123:~sinqhm/wind/SinqHM/<instr>/bld V01G
#
# Script to compile and link the SinqHM_srv programs for vxWorks
#
# rcp -p "lnsa04:sinqhm/bld" ~/wind/SinqHM/bld
#
# This version is for the Tornado 2.0.2 version and the MVME2604 board
# as used at AMOR and SANS
#
# Mark Koennecke, February 2002
## printf 'Arg 0 = "%s"\n' $0
## printf 'Arg 1 = "%s"\n' $1
## printf 'Arg 2 = "%s"\n' $2
## printf 'Arg 3 = "%s"\n' $3
#----------------------------------------------------------------------------
set proc = "$0"
if (`expr match "$proc" "\/"` != 1) set proc = "./$0"
cd $proc:h # Build in bld's directory!
#------------------------------------------------------------------------------
# Uncomment the following command to disable remote-copy operations
#
## alias rcp 'echo " Warning -- remote copy disabled"; echo \!\!:* > /dev/null'
#------------------------------------------------------------------------------
if ("`whoami`" == "maden") then
set src = "maden@lnsa06:sinqhm/"
else if ("`whoami`" == "sinqhm") then
set src = "koenneck@lnsa17:src/sics/sinqhm/"
else
echo Sorry, you are not recognised by this script.
exit
endif
#------------------------------------------------------------------------------
# alias ccvx 'ccppc -O0 -mcpu=603 -I${WIND_BASE}/target/h ' \
# '-fno-builtin -fno-for-scope ' \
# '-nostdinc -DCPU=PPC603 -D_GNU_TOOL -gdwarf -c -Wimplicit'
alias ccvx 'ccppc ' \
'-B/home/pss123/aco/sinqhm/wind2/2.0.2/host/sun4-solaris2/lib/gcc-lib/' \
' -mstrict-align -fdollars-in-identifiers -O2 -fvolatile -fno-builtin' \
' -fno-for-scope -Wall -I/h -I. '\
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/config/all ' \
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/h '\
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/src/config '\
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/src/drv -DCPU=PPC604 '\
' -DMV2600 -DSINQHM_SPAWN=1 -c '
#
set Insts = (dev dmc sans focus hrpt trics poldi amor)
if (("$1" == "") || \
("$1" == "?") || \
("$1" == "h") || \
("$1" == "he") || \
("$1" == "hel") || \
("$1" == "help")) goto show_help
printf "\n"
printf "Working directory is %s\n" "$cwd"
printf 'Source is "%s"\n' "$src"
printf "\n"
if ("$1" == "bld") goto bld
if ("$1" == "startup") goto startup
if ("$1" == "basic") goto basic
foreach inst ($Insts)
if ("$1" == "$inst") goto $inst
end
printf '\aI do not know how to build "%s"\!\n' $1
goto show_help
#===========================================================================
show_help_0:
printf '\n\007You must specify what you want to build\!\n\n'
show_help:
#=========
echo "Usage:"
echo " bld bld - copy over new version of bld script."
echo " bld startup - copy over new version of startup script."
echo " bld basic - build basic system."
echo " bld <inst> all - build all modules for instrument <inst>."
echo " bld <inst> SinqHM_srv [<module>] - build SinqHM_srv module"
echo " bld <inst> lwl_server - build lwl_server module"
echo " bld <inst> SinqHM_bootParamsConfig - build auto-config module"
echo " bld <inst> SinqHM_bootUtil - build boot-utility module"
echo " bld focus FOCUS_srv [<module>] - build FOCUS_srv module"
echo " bld <inst> auto - build auto-spawn system"
echo " "
echo "Valid instruments are:"
echo " $Insts"
echo " "
exit
#-----------------------------------------------------------------------------
bld:
#===
echo " Copying bld (previous version is bld.save) ..."
mv bld bld.save
rcp -p "${src}bld" ./bld
rcp -p "${src}bld2" ./bld2
rcp -p "${src}tornado2" ./tornado2
exit
#-----------------------------------------------------------------------------
startup:
#=======
echo " Copying startup ..."
rcp -p "${src}startup.template" ./startup
exit
#-----------------------------------------------------------------------------
basic:
#=====
set dflt = "$cwd"
cd $WIND_BASE/target/config/mv2604
echo " "
echo "Default directory changed to:"
echo " $cwd"
printf "Building vxWorks_basic system image ...\n\n"
touch config.h # Force a complete re-compilation
make ADDED_CFLAGS=" -DSINQHM_SPAWN=0" \
ADDED_MODULES=""
mv vxWorks vxWorks_basic
mv vxWorks.sym vxWorks.sym_basic
cp -p vxWorks_basic $dflt/vxWorks_basic
cp -p vxWorks.sym_basic $dflt/vxWorks.sym
cd $dflt
echo " Done. Result is $dflt/vxWorks_basic"
exit
#=============================================================================
# Now follow labels for all the valid instruments.
dev:
#----
set instr = Devel
set defn = '-DINST="Devel" -DDevel'
set direc = Devel/NEW
goto comn
dmc:
#---
set instr = DMC
set defn = '-DINST="DMC" -DDMC'
set direc = DMC/NEW
goto comn
sans:
#----
set instr = SANS
set defn = '-DINST="SANS" -DSANS'
set direc = SANS/NEW
goto comn
focus:
#-----
set instr = FOCUS
set defn = '-DINST="FOCUS" -DFOCUS'
set direc = FOCUS/NEW
goto comn
hrpt:
#----
set instr = HRPT
set defn = '-DINST="HRPT" -DHRPT'
set direc = HRPT/NEW
goto comn
trics:
#-----
set instr = TriCS
set defn = '-DINST="TRICS" -DTRICS'
set direc = TRICS
goto comn
poldi:
#-----
set instr = POLDI
set defn = '-DINST="POLDI" -DPOLDI'
set direc = POLDI/NEW
goto comn
amor:
#----
set instr = AMOR
set defn = '-DINST="AMOR" -DAMOR'
set direc = AMOR/NEW
goto comn
comn:
#----
echo The selected instrument is ${instr}.
if ("$2" == "") goto show_help_0
cd $direc
printf "Working directory changed to %s\n" "$cwd"
if ("$2" == "SinqHM_srv") goto SinqHM_srv
if ("$2" == "lwl_server") goto lwl_server
if ("$2" == "SinqHM_bootParamsConfig") goto SinqHM_bootParamsConfig
if ("$2" == "SinqHM_bootUtil") goto SinqHM_bootUtil
if (("$instr" == "FOCUS") && ("$2" == "FOCUS_srv")) goto FOCUS_srv
if ("$2" == "auto") goto auto
if ("$2" != "all") then
printf '\007I do not know how to build "%s" for %s\!\n' "$2" $instr
printf 'Type "bld help" for help\!\n'
exit
endif
#--------------------------------------------------------------
SinqHM_srv:
#==========
set Mods = (SinqHM_gbl.h \
SinqHM_def.h \
vmio10_def.h \
SinqHM_srv_main.c \
SinqHM_srv_routines.c \
SinqHM_srv_filler.c \
SinqHM_srv_server.c)
if (("$3" == "") || ("$3" == "all")) goto SinqHM_srv_all
foreach module ($Mods)
if ("$3" == "$module") goto SinqHM_srv_cpy
end
if (("$3" != "?") && \
("$3" != "h") && \
("$3" != "he") && \
("$3" != "hel") && \
("$3" != "help")) then
printf '"%s" is not a recognised module of SinqHM_srv\!\n\n' "$3"
endif
printf 'To build SinqHM_srv, use the command:\n'
printf '\n'
printf ' bld <instr> SinqHM_srv [module]\n'
printf '\n'
printf 'Valid instruments are:\n'
printf '\n'
printf ' %s\n' "$Insts"
printf '\n'
printf 'Valid modules are:\n'
printf '\n'
foreach module ($Mods)
printf ' %s\n' "$module"
end
printf '\n'
exit
#----------------------------------------------------------------------------
SinqHM_srv_cpy:
#--------------
echo " Copying $3 ..."
rcp -p "${src}$3" ./$3
if ("$3" == "SinqHM_gbl.h") goto SinqHM_srv_compile_all
if ("$3" == "SinqHM_def.h") goto SinqHM_srv_compile_all
if ("$3" == "vmio10_def.h") goto SinqHM_srv_compile_all
echo " Compiling $3 ..."
ccvx $defn $3
goto SinqHM_srv_link
SinqHM_srv_all:
#--------------
echo " "
echo "Building SinqHM_srv ..."
echo " Copying header files ..."
rcp -p "${src}SinqHM_gbl.h" ./SinqHM_gbl.h
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
rcp -p "${src}vmio10_def.h" ./vmio10_def.h
echo " Copying source files ..."
rcp -p "${src}SinqHM_srv_main.c" ./SinqHM_srv_main.c
rcp -p "${src}SinqHM_srv_routines.c" ./SinqHM_srv_routines.c
rcp -p "${src}SinqHM_srv_filler.c" ./SinqHM_srv_filler.c
rcp -p "${src}SinqHM_srv_server.c" ./SinqHM_srv_server.c
SinqHM_srv_compile_all:
#----------------------
echo " Compiling SinqHM_srv_main.c ..."
ccvx $defn SinqHM_srv_main.c
echo " Compiling SinqHM_srv_routines.c ..."
ccvx $defn SinqHM_srv_routines.c
echo " Compiling SinqHM_srv_filler.c ..."
ccvx $defn SinqHM_srv_filler.c
echo " Compiling SinqHM_srv_server.c ..."
ccvx $defn SinqHM_srv_server.c
SinqHM_srv_link:
#---------------
echo " Linking ..."
ldppc -o SinqHM_srv.o -r \
SinqHM_srv_main.o SinqHM_srv_routines.o \
SinqHM_srv_filler.o SinqHM_srv_server.o
echo " Done. Result is $cwd/SinqHM_srv.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
lwl_server:
#==========
echo " "
echo "Building lwl_server ..."
echo " Copying header files ..."
rcp -p "${src}vmio10_def.h" ./vmio10_def.h
echo " Copying source files ..."
rcp -p "${src}lwl_server.c" ./lwl_server.c
echo " Compiling lwl_server.c ..."
ccvx $defn lwl_server.c
echo " Done. Result is $cwd/lwl_server.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
SinqHM_bootParamsConfig:
#=======================
echo " "
echo "Building SinqHM_bootParamsConfig ..."
echo " Copying header files ..."
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source files ..."
rcp -p "${src}SinqHM_bootParamsConfig.c" \
./SinqHM_bootParamsConfig.c
echo " Compiling SinqHM_bootParamsConfig.c ..."
ccvx $defn -I${WIND_BASE}/target/config/all \
SinqHM_bootParamsConfig.c
echo " Done. Result is $cwd/SinqHM_bootParamsConfig.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
SinqHM_bootUtil:
#===============
echo " "
echo "Building SinqHM_bootUtil ..."
echo " Copying header file ..."
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source file ..."
rcp -p "${src}SinqHM_bootUtil.c" \
./SinqHM_bootUtil.c
echo " Compiling SinqHM_bootUtil.c ..."
ccvx $defn -I${WIND_BASE}/target/config/all SinqHM_bootUtil.c
echo " Done. Result is $cwd/SinqHM_bootUtil.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
FOCUS_srv:
#==========
if ($instr != "FOCUS") goto FOCUS_srv_skp
set Mods = ( FOCUS_gbl.h \
SinqHM_def.h \
FOCUS_srv_main.c )
if (("$3" == "") || ("$3" == "all")) goto FOCUS_srv_all
foreach module ( $Mods )
if ("$3" == "$module") goto FOCUS_srv_cpy
end
if (("$3" != "?") && \
("$3" != "h") && \
("$3" != "he") && \
("$3" != "hel") && \
("$3" != "help")) then
printf '"%s" is not a recognised module of FOCUS_srv\!\n\n' "$3"
endif
printf 'To build FOCUS_srv, use the command:\n'
printf '\n'
printf ' bld <instr> FOCUS_srv [module]\n'
printf '\n'
printf 'Valid instruments are:\n'
printf '\n'
printf ' %s\n' "focus"
printf '\n'
printf 'Valid modules are:\n'
printf '\n'
foreach module ($Mods)
printf ' %s\n' "$module"
end
printf '\n'
exit
#----------------------------------------------------------------------------
FOCUS_srv_cpy:
#--------------
echo " Copying $3 ..."
rcp -p "${src}$3" ./$3
if ("$3" == "FOCUS_gbl.h") goto FOCUS_srv_compile_all
if ("$3" == "SinqHM_def.h") goto FOCUS_srv_compile_all
echo " Compiling $3 ..."
ccvx $defn $3
goto FOCUS_srv_link
FOCUS_srv_all:
#--------------
echo " "
echo "Building FOCUS_srv ..."
echo " Copying header files ..."
rcp -p "${src}FOCUS_gbl.h" ./FOCUS_gbl.h
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source files ..."
rcp -p "${src}FOCUS_srv_main.c" ./FOCUS_srv_main.c
FOCUS_srv_compile_all:
#----------------------
echo " Compiling FOCUS_srv_main.c ..."
ccvx $defn FOCUS_srv_main.c
FOCUS_srv_link:
#---------------
echo " Linking ..."
ldppc -o FOCUS_srv.o -r \
FOCUS_srv_main.o
echo " Done. Result is $cwd/FOCUS_srv.o"
FOCUS_srv_skp:
#-------------
if ("$2" != "all") exit
#---------------------------------------------------------------------------
auto:
#====
set dflt = "$cwd"
cd $WIND_BASE/target/config/mv2604
echo " "
echo "Default directory changed to:"
echo " $cwd"
printf "\n\n==================================================\n"
printf \
"\n\nBuilding vxWorks_auto system image for $instr Instrument ...\n\n"
touch config.h # Force a complete re-compilation
set mods = ( $dflt/SinqHM_srv.o \
$dflt/lwl_server.o \
$dflt/SinqHM_bootParamsConfig.o \
$dflt/SinqHM_bootUtil.o )
if ($instr == FOCUS) set mods = ( $mods $dflt/FOCUS_srv.o )
make ADDED_CFLAGS=" -DSINQHM_SPAWN=1" \
ADDED_MODULES="$mods"
mv vxWorks vxWorks_auto
mv vxWorks.sym vxWorks.sym_auto
cp -p vxWorks_auto $dflt/vxWorks_auto
cp -p vxWorks.sym_auto $dflt/vxWorks.sym
cd $dflt
echo " Done. Result is $dflt/vxWorks_auto"
exit
#------------------------------------------------------------------ End of bld

439
sinqhm/bldmen Executable file
View File

@ -0,0 +1,439 @@
#! /bin/csh
# pss123:~sinqhm/wind/SinqHM/<instr>/bld V01G
#
# Script to compile and link the SinqHM_srv programs for vxWorks
#
# rcp -p "lnsa04:sinqhm/bld" ~/wind/SinqHM/bld
#
# This version is for the Tornado 2.0.2 version and the MEN-A12 board
# for testing.
#
# Mark Koennecke, October 2002
## printf 'Arg 0 = "%s"\n' $0
## printf 'Arg 1 = "%s"\n' $1
## printf 'Arg 2 = "%s"\n' $2
## printf 'Arg 3 = "%s"\n' $3
#----------------------------------------------------------------------------
set proc = "$0"
if (`expr match "$proc" "\/"` != 1) set proc = "./$0"
cd $proc:h # Build in bld's directory!
#------------------------------------------------------------------------------
# Uncomment the following command to disable remote-copy operations
#
## alias rcp 'echo " Warning -- remote copy disabled"; echo \!\!:* > /dev/null'
#------------------------------------------------------------------------------
if ("`whoami`" == "maden") then
set src = "maden@lnsa06:sinqhm/"
else if ("`whoami`" == "sinqhm") then
set src = "koenneck@lnsa17:src/sics/sinqhm/"
else
echo Sorry, you are not recognised by this script.
exit
endif
#------------------------------------------------------------------------------
# alias ccvx 'ccppc -O0 -mcpu=603 -I${WIND_BASE}/target/h ' \
# '-fno-builtin -fno-for-scope ' \
# '-nostdinc -DCPU=PPC603 -D_GNU_TOOL -gdwarf -c -Wimplicit'
setenv MEN_WORK_DIR /home/pss123/aco/sinqhm/wind2/MEN
setenv MEN /home/pss123/aco/sinqhm/wind2/MEN
alias ccvx 'ccppc ' \
'-B/home/pss123/aco/sinqhm/wind2/2.0.2/host/sun4-solaris2/lib/gcc-lib/' \
' -mstrict-align -ansi -nostdinc -O2 -fvolatile -fno-builtin' \
' -fno-for-scope -Wall -I/h -I$MEN/VXWORKS/INCLUDE/NATIVE '\
' -I$MEN/VXWORKS/INCLUDE/COM -I$MEN/VXWORKS -I. '\
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/config/all ' \
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/config/men_824x_ali ' \
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/h '\
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/src/config '\
' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/src/drv -DCPU=PPC603 '\
' -DMEN_A012 -DSINQHM_SPAWN=1 -c '
#
set Insts = (dev dmc sans focus hrpt trics poldi amor)
if (("$1" == "") || \
("$1" == "?") || \
("$1" == "h") || \
("$1" == "he") || \
("$1" == "hel") || \
("$1" == "help")) goto show_help
printf "\n"
printf "Working directory is %s\n" "$cwd"
printf 'Source is "%s"\n' "$src"
printf "\n"
if ("$1" == "bld") goto bld
if ("$1" == "startup") goto startup
if ("$1" == "basic") goto basic
foreach inst ($Insts)
if ("$1" == "$inst") goto $inst
end
printf '\aI do not know how to build "%s"\!\n' $1
goto show_help
#===========================================================================
show_help_0:
printf '\n\007You must specify what you want to build\!\n\n'
show_help:
#=========
echo "Usage:"
echo " bld bld - copy over new version of bld script."
echo " bld startup - copy over new version of startup script."
echo " bld basic - build basic system."
echo " bld <inst> all - build all modules for instrument <inst>."
echo " bld <inst> SinqHM_srv [<module>] - build SinqHM_srv module"
echo " bld <inst> lwl_server - build lwl_server module"
echo " bld <inst> SinqHM_bootParamsConfig - build auto-config module"
echo " bld <inst> SinqHM_bootUtil - build boot-utility module"
echo " bld focus FOCUS_srv [<module>] - build FOCUS_srv module"
echo " bld <inst> auto - build auto-spawn system"
echo " "
echo "Valid instruments are:"
echo " $Insts"
echo " "
exit
#-----------------------------------------------------------------------------
bld:
#===
echo " Copying bld (previous version is bld.save) ..."
mv bld bld.save
rcp -p "${src}bld" ./bld
rcp -p "${src}bld2" ./bld2
rcp -p "${src}tornado2" ./tornado2
exit
#-----------------------------------------------------------------------------
startup:
#=======
echo " Copying startup ..."
rcp -p "${src}startup.template" ./startup
exit
#-----------------------------------------------------------------------------
basic:
#=====
set dflt = "$cwd"
cd $WIND_BASE/target/config/men_824x_ali
echo " "
echo "Default directory changed to:"
echo " $cwd"
printf "Building vxWorks_basic system image ...\n\n"
touch config.h # Force a complete re-compilation
make ADDED_CFLAGS=" -DSINQHM_SPAWN=0" \
ADDED_MODULES=""
mv vxWorks vxWorks_basic
mv vxWorks.sym vxWorks.sym_basic
cp -p vxWorks_basic $dflt/vxWorks_basic
cp -p vxWorks.sym_basic $dflt/vxWorks.sym
cd $dflt
echo " Done. Result is $dflt/vxWorks_basic"
exit
#=============================================================================
# Now follow labels for all the valid instruments.
dev:
#----
set instr = Devel
set defn = '-DINST="Devel" -DDevel'
set direc = Devel/NEW
goto comn
dmc:
#---
set instr = DMC
set defn = '-DINST="DMC" -DDMC'
set direc = DMC/NEW
goto comn
sans:
#----
set instr = SANS
set defn = '-DINST="SANS" -DSANS'
set direc = SANS/NEW
goto comn
focus:
#-----
set instr = FOCUS
set defn = '-DINST="FOCUS" -DFOCUS'
set direc = FOCUS/NEW
goto comn
hrpt:
#----
set instr = HRPT
set defn = '-DINST="HRPT" -DHRPT'
set direc = HRPT/NEW
goto comn
trics:
#-----
set instr = TriCS
set defn = '-DINST="TRICS" -DTRICS'
set direc = TRICS
goto comn
poldi:
#-----
set instr = POLDI
set defn = '-DINST="POLDI" -DPOLDI'
set direc = POLDI/NEW
goto comn
amor:
#----
set instr = AMOR
set defn = '-DINST="AMOR" -DAMOR'
set direc = AMOR/NEW
goto comn
comn:
#----
echo The selected instrument is ${instr}.
if ("$2" == "") goto show_help_0
cd $direc
printf "Working directory changed to %s\n" "$cwd"
if ("$2" == "SinqHM_srv") goto SinqHM_srv
if ("$2" == "lwl_server") goto lwl_server
if ("$2" == "SinqHM_bootParamsConfig") goto SinqHM_bootParamsConfig
if ("$2" == "SinqHM_bootUtil") goto SinqHM_bootUtil
if (("$instr" == "FOCUS") && ("$2" == "FOCUS_srv")) goto FOCUS_srv
if ("$2" == "auto") goto auto
if ("$2" != "all") then
printf '\007I do not know how to build "%s" for %s\!\n' "$2" $instr
printf 'Type "bld help" for help\!\n'
exit
endif
#--------------------------------------------------------------
SinqHM_srv:
#==========
set Mods = (SinqHM_gbl.h \
SinqHM_def.h \
vmio10_def.h \
SinqHM_srv_main.c \
SinqHM_srv_routines.c \
SinqHM_srv_filler.c \
SinqHM_srv_server.c)
if (("$3" == "") || ("$3" == "all")) goto SinqHM_srv_all
foreach module ($Mods)
if ("$3" == "$module") goto SinqHM_srv_cpy
end
if (("$3" != "?") && \
("$3" != "h") && \
("$3" != "he") && \
("$3" != "hel") && \
("$3" != "help")) then
printf '"%s" is not a recognised module of SinqHM_srv\!\n\n' "$3"
endif
printf 'To build SinqHM_srv, use the command:\n'
printf '\n'
printf ' bld <instr> SinqHM_srv [module]\n'
printf '\n'
printf 'Valid instruments are:\n'
printf '\n'
printf ' %s\n' "$Insts"
printf '\n'
printf 'Valid modules are:\n'
printf '\n'
foreach module ($Mods)
printf ' %s\n' "$module"
end
printf '\n'
exit
#----------------------------------------------------------------------------
SinqHM_srv_cpy:
#--------------
echo " Copying $3 ..."
rcp -p "${src}$3" ./$3
if ("$3" == "SinqHM_gbl.h") goto SinqHM_srv_compile_all
if ("$3" == "SinqHM_def.h") goto SinqHM_srv_compile_all
if ("$3" == "vmio10_def.h") goto SinqHM_srv_compile_all
echo " Cpy Compiling $3 ..."
ccvx $defn $3
goto SinqHM_srv_link
SinqHM_srv_all:
#--------------
echo " "
echo "Building SinqHM_srv ..."
echo " Copying header files ..."
rcp -p "${src}SinqHM_gbl.h" ./SinqHM_gbl.h
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
rcp -p "${src}vmio10_def.h" ./vmio10_def.h
echo " Copying source files ..."
rcp -p "${src}SinqHM_srv_main.c" ./SinqHM_srv_main.c
rcp -p "${src}SinqHM_srv_routines.c" ./SinqHM_srv_routines.c
rcp -p "${src}SinqHM_srv_filler.c" ./SinqHM_srv_filler.c
rcp -p "${src}SinqHM_srv_server.c" ./SinqHM_srv_server.c
SinqHM_srv_compile_all:
#----------------------
echo " Compiling SinqHM_srv_main.c ..."
ccvx $defn -o SinqHM_srv_main.o SinqHM_srv_main.c
echo " Compiling SinqHM_srv_routines.c ..."
ccvx $defn -o SinqHM_srv_routines.o SinqHM_srv_routines.c
echo " Compiling SinqHM_srv_filler.c ..."
ccvx $defn -o SinqHM_srv_filler.o SinqHM_srv_filler.c
echo " Compiling SinqHM_srv_server.c ..."
ccvx $defn -o SinqHM_srv_server.o SinqHM_srv_server.c
SinqHM_srv_link:
#---------------
echo " Linking ..."
ldppc -o SinqHM_srv.o -r \
SinqHM_srv_main.o SinqHM_srv_routines.o \
SinqHM_srv_filler.o SinqHM_srv_server.o
echo " Done. Result is $cwd/SinqHM_srv.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
lwl_server:
#==========
echo " "
echo "Building lwl_server ..."
echo " Copying header files ..."
rcp -p "${src}vmio10_def.h" ./vmio10_def.h
echo " Copying source files ..."
rcp -p "${src}lwl_server.c" ./lwl_server.c
echo " Compiling lwl_server.c ..."
ccvx $defn -o lwl_server.o lwl_server.c
echo " Done. Result is $cwd/lwl_server.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
SinqHM_bootParamsConfig:
#=======================
echo " "
echo "Building SinqHM_bootParamsConfig ..."
echo " Copying header files ..."
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source files ..."
rcp -p "${src}SinqHM_bootParamsConfig.c" \
./SinqHM_bootParamsConfig.c
echo " Compiling SinqHM_bootParamsConfig.c ..."
ccvx $defn -I${WIND_BASE}/target/config/all \
-o SinqHM_bootParamsConfig.o SinqHM_bootParamsConfig.c
echo " Done. Result is $cwd/SinqHM_bootParamsConfig.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
SinqHM_bootUtil:
#===============
echo " "
echo "Building SinqHM_bootUtil ..."
echo " Copying header file ..."
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source file ..."
rcp -p "${src}SinqHM_bootUtil.c" \
./SinqHM_bootUtil.c
echo " Compiling SinqHM_bootUtil.c ..."
ccvx $defn -I${WIND_BASE}/target/config/all \
-o SinqHM_bootUtil.o SinqHM_bootUtil.c
echo " Done. Result is $cwd/SinqHM_bootUtil.o"
if ("$2" != "all") exit
#---------------------------------------------------------------------------
FOCUS_srv:
#==========
if ($instr != "FOCUS") goto FOCUS_srv_skp
set Mods = ( FOCUS_gbl.h \
SinqHM_def.h \
FOCUS_srv_main.c )
if (("$3" == "") || ("$3" == "all")) goto FOCUS_srv_all
foreach module ( $Mods )
if ("$3" == "$module") goto FOCUS_srv_cpy
end
if (("$3" != "?") && \
("$3" != "h") && \
("$3" != "he") && \
("$3" != "hel") && \
("$3" != "help")) then
printf '"%s" is not a recognised module of FOCUS_srv\!\n\n' "$3"
endif
printf 'To build FOCUS_srv, use the command:\n'
printf '\n'
printf ' bld <instr> FOCUS_srv [module]\n'
printf '\n'
printf 'Valid instruments are:\n'
printf '\n'
printf ' %s\n' "focus"
printf '\n'
printf 'Valid modules are:\n'
printf '\n'
foreach module ($Mods)
printf ' %s\n' "$module"
end
printf '\n'
exit
#----------------------------------------------------------------------------
FOCUS_srv_cpy:
#--------------
echo " Copying $3 ..."
rcp -p "${src}$3" ./$3
if ("$3" == "FOCUS_gbl.h") goto FOCUS_srv_compile_all
if ("$3" == "SinqHM_def.h") goto FOCUS_srv_compile_all
echo " Compiling $3 ..."
ccvx $defn $3
goto FOCUS_srv_link
FOCUS_srv_all:
#--------------
echo " "
echo "Building FOCUS_srv ..."
echo " Copying header files ..."
rcp -p "${src}FOCUS_gbl.h" ./FOCUS_gbl.h
rcp -p "${src}SinqHM_def.h" ./SinqHM_def.h
echo " Copying source files ..."
rcp -p "${src}FOCUS_srv_main.c" ./FOCUS_srv_main.c
FOCUS_srv_compile_all:
#----------------------
echo " Compiling FOCUS_srv_main.c ..."
ccvx $defn FOCUS_srv_main.c
FOCUS_srv_link:
#---------------
echo " Linking ..."
ldppc -o FOCUS_srv.o -r \
FOCUS_srv_main.o
echo " Done. Result is $cwd/FOCUS_srv.o"
FOCUS_srv_skp:
#-------------
if ("$2" != "all") exit
#---------------------------------------------------------------------------
auto:
#====
set dflt = "$cwd"
cd $WIND_BASE/target/config/men_824x_ali
echo " "
echo "Default directory changed to:"
echo " $cwd"
printf "\n\n==================================================\n"
printf \
"\n\nBuilding vxWorks_auto system image for $instr Instrument ...\n\n"
touch config.h # Force a complete re-compilation
set mods = ( $dflt/SinqHM_srv.o \
$dflt/lwl_server.o \
$dflt/SinqHM_bootParamsConfig.o \
$dflt/SinqHM_bootUtil.o )
if ($instr == FOCUS) set mods = ( $mods $dflt/FOCUS_srv.o )
make ADDED_CFLAGS=" -DSINQHM_SPAWN=1" \
ADDED_MODULES="$mods"
mv vxWorks vxWorks_auto
mv vxWorks.sym vxWorks.sym_auto
cp -p vxWorks_auto $dflt/vxWorks_auto
cp -p vxWorks.sym_auto $dflt/vxWorks.sym
cd $dflt
echo " Done. Result is $dflt/vxWorks_auto"
exit
#------------------------------------------------------------------ End of bld

1572
sinqhm/hist_mem_notes.tex Executable file

File diff suppressed because it is too large Load Diff

2677
sinqhm/hist_mem_spec.tex Executable file

File diff suppressed because it is too large Load Diff

1632
sinqhm/hist_mem_spec_fig1.ps Executable file

File diff suppressed because it is too large Load Diff

808
sinqhm/hist_mem_spec_fig2.ps Executable file
View File

@ -0,0 +1,808 @@
%!PS-Adobe-2.1
%%Creator: DECwrite V3.0-2
%%+Copyright (c) 1990,1994 DIGITAL EQUIPMENT CORPORATION.
%%+All Rights Reserved.
%%DocumentFonts: (atend)
%%EndComments
%%BeginProcSet DEC_WRITE 1.10
save/DEC_WRITE_dict 150 dict def DEC_WRITE_dict begin/$D exch def/$I 0
def/$S 0 def/$C matrix def/$R matrix def/$L matrix def/$E matrix
def/pat1{/px exch def/pa 8 array def 0 1 7{/py exch def/pw 4 string def 0 1
3{pw exch px py 1 getinterval putinterval}for pa py pw put}for}def/pat2{/pi
exch def/cflag exch def save cflag 1 eq{eoclip}{clip}ifelse
newpath{clippath pathbbox}stopped not{/ph exch def/pw exch def/py exch
def/px exch def/px px 3072 div floor 3072 mul def/py py 3072 div floor 3072
mul def px py translate/pw pw px sub 3072 div floor 1 add cvi def/ph ph py
sub 3072 div floor 1 add cvi def pw 3072 mul ph 3072 mul scale/pw pw 32 mul
def/ph ph 32 mul def/px 0 def/py 0 def pw ph pi[pw 0 0 ph 0 0]{pa py get/px
px 32 add def px pw ge{/px 0 def/py py 1 add 8 mod def}if}pi
type/booleantype eq{imagemask}{image}ifelse}if restore}def/PS{/_op exch
def/_np 8 string def 0 1 7{/_ii exch def/num _op _ii get def _np 7 _ii sub
num -4 bitshift PX num 15 and 4 bitshift -4 bitshift PX 4 bitshift or
put}for _np}def/PX{[15 7 11 3 13 5 9 1 14 6 10 2 12 4 8 0]exch
get}def/FR{0.7200 0 $E defaultmatrix dtransform/yres exch def/xres exch def
xres dup mul yres dup mul add sqrt}def/SU{/_sf exch def/_sa exch def/_cs
exch def/_mm $C currentmatrix def/rm _sa $R rotate def/sm _cs dup $L scale
def sm rm _mm _mm concatmatrix _mm concatmatrix pop 1 0 _mm dtransform/y1
exch def/x1 exch def/_vl x1 dup mul y1 dup mul add sqrt def/_fq FR _vl div
def/_na y1 x1 atan def _mm 2 get _mm 1 get mul _mm 0 get _mm 3 get mul sub
0 gt{{neg}/_sf load concatprocs/_sf exch def}if _fq _na/_sf load
setscreen}def/BO{/_yb exch def/_xb exch def/_bv _bs _yb _bw mul _xb 8 idiv
add get def/_mk 1 7 _xb 8 mod sub bitshift def _bv _mk and 0 ne $I 1 eq
xor}def/BF{DEC_WRITE_dict begin/_yy exch def/_xx exch def/_xi _xx 1 add 2
div _bp mul cvi def/_yi _yy 1 add 2 div _bp mul cvi def _xi _yi BO{/_nb _nb
1 add def 1}{/_fb _fb 1 add def 0}ifelse end}def/setpattern{/_cz exch
def/_bw exch def/_bp exch def/_bs exch PS def/_nb 0 def/_fb 0 def _cz 0/BF
load SU{}settransfer _fb _fb _nb add div setgray/$S 1
def}def/invertpattern{$S 0 eq{{1 exch sub}currenttransfer concatprocs
settransfer}if}def/invertscreen{/$I 1 def/$S 0 def}def/revertscreen{/$I 0
def}def/setrect{/$h exch def/$w exch def/$y exch def/$x exch def newpath $x
$y moveto $w $x add $y lineto $w $x add $h $y add lineto $x $h $y add
lineto closepath}def/concatprocs{/_p2 exch cvlit def/_p1 exch cvlit def/_pn
_p1 length _p2 length add array def _pn 0 _p1 putinterval _pn _p1 length
_p2 putinterval _pn cvx}def/OF/findfont load def/findfont{dup
DEC_WRITE_dict exch known{DEC_WRITE_dict exch get}if DEC_WRITE_dict/OF get
exec}def
mark/ISOLatin1Encoding
8#000 1 8#001{StandardEncoding exch get}for /emdash/endash
8#004 1 8#025{StandardEncoding exch get}for /quotedblleft/quotedblright
8#030 1 8#054{StandardEncoding exch get}for /minus 8#056 1 8#217
{StandardEncoding exch get}for/dotlessi 8#301 1 8#317{StandardEncoding
exch get}for/space/exclamdown/cent/sterling/currency/yen/brokenbar/section
/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered
/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde
/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave
/Iacute/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde
/Odieresis/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave
/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
256 array astore def cleartomark
/encodefont{findfont dup maxlength dict begin{1 index/FID ne{def}{pop
pop}ifelse}forall/Encoding exch def dup/FontName exch def currentdict
definefont end}def/loads{/$/ISOLatin1Encoding load def/&/encodefont load
def/*/invertpattern load def/+/revertscreen load def/-/invertscreen load
def/:/concatprocs load def/^/setpattern load def/~/pat1 load def/_/pat2
load def/@/setrect load def/A/arcn load def/B/ashow load def/C/curveto load
def/D/def load def/E/eofill load def/F/findfont load def/G/setgray load
def/H/closepath load def/I/clip load def/J/fill load def/K/kshow load
def/L/lineto load def/M/moveto load def/N/newpath load def/O/rotate load
def/P/pop load def/R/grestore load def/S/gsave load def/T/translate load
def/U/sub load def/V/div load def/W/widthshow load def/X/exch load
def/Y/awidthshow load def/a/save load def/c/setlinecap load def/d/setdash
load def/e/restore load def/f/setfont load def/g/initclip load def/h/show
load def/i/setmiterlimit load def/j/setlinejoin load def/k/stroke load
def/l/rlineto load def/m/rmoveto load def/n/currentfont load
def/o/scalefont load def/p/currentpoint load def/q/setrgbcolor load
def/r/currenttransfer load def/s/scale load def/t/setmatrix load
def/u/settransfer load def/w/setlinewidth load def/x/matrix load
def/y/currentmatrix load def}def
end
%%EndProcSet
%%EndProlog
%%BeginSetup
DEC_WRITE_dict begin
loads
version cvi 23.0 gt {
currentdict {dup type /arraytype eq
{bind def} {pop pop} ifelse} forall} if
0.0100 0.0100 s
%%EndSetup
%%Page: 1 1
/$P a D
g N
0 84189 T
7087 -5669 T
N
312 -1212 M
312 -2653 M
-7087 5669 T
7087 -1169 T
N
312 -1212 M
-7087 1169 T
7087 -5669 T
N
312 -1212 M
312 -2653 M
-7087 5669 T
N
S
7085 -80769 48178 58098 @ I N
7085 -22671 T
N
N
35450 -14207 M
35450 -20478 L
S
300 w
0 c
0 j
[100 400] 0 d
0.00 G k
R
N
N
34939 -27801 M
34939 -31417 L
S
300 w
0 c
0 j
[100 400] 0 d
0.00 G k
R
N
N
22559 -31416 M
34940 -31416 L
S
300 w
0 c
0 j
[100 400] 0 d
0.00 G k
R
N
N
28850 -22464 M
36291 -22464 L
S
300 w
0 c
0 j
[100 400] 0 d
0.00 G k
R
N
N
25364 -27471 M
32805 -27471 L
S
300 w
0 c
0 j
[100 400] 0 d
0.00 G k
R
N
N
34838 -8181 M
44702 -8181 L
S
150 w
0 c
0 j
[400 400 100 400] 0 d
0.00 G k
R
N
N
37261 -11835 M
44702 -11835 L
S
300 w
0 c
0 j
[400 400] 0 d
0.00 G k
R
N
N
5116 -41296 M
13045 -41296 L
10151 -40810 L
17399 -40810 L
S
150 w
0 c
0 j
0.00 G k
R
N
N
5329 -46076 M
10817 -46076 L
8814 -45591 L
13831 -45591 L
S
150 w
0 c
0 j
0.00 G k
R
N
N
5097 -50856 M
8568 -50856 L
7302 -50369 L
10477 -50369 L
S
150 w
0 c
0 j
0.00 G k
R
N
N
8049 -22253 M
14559 -22253 L
12183 -21767 L
18134 -21767 L
S
150 w
0 c
0 j
0.00 G k
R
N
N
8204 -27033 M
12656 -27033 L
11031 -26548 L
15101 -26548 L
S
150 w
0 c
0 j
0.00 G k
R
N
N
7974 -31812 M
9684 -31812 L
9060 -31326 L
10624 -31326 L
S
150 w
0 c
0 j
0.00 G k
R
N
17555 -25215 12599 6410 @
S
0.00 1 X U G J
R
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
20553 -21763 M
/Times-Bold-ISOLatin1 $
/Times-Bold & P
/Times-Bold-ISOLatin1 F 1800 o f
0.000000 0.000000 0.000000 q
(SinqHM) h
20181 -23488 M
(Server #3) h
13917 -29995 12599 6410 @
S
0.00 1 X U G J
R
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
16915 -26543 M
(SinqHM) h
16543 -28268 M
(Server #2) h
26356 -14253 11683 6411 @
S
1.00 G J
R
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
29996 -9172 M
n 0.667 o f
(SinqHM) h
28430 -10621 M
(Histogrammer) h
N
8038 -14590 M
12490 -14590 L
10865 -14105 L
14935 -14105 L
S
150 w
0 c
0 j
0.00 G k
R
N
N
7750 -8385 M
7750 -35227 L
4980 -31609 L
4980 -55005 L
S
924 w
0 c
0 j
0.00 G k
R
N
N
3483 -52783 M
4980 -56897 L
6477 -52783 L
H
S
0.00 G J
R
N
N
9247 -10607 M
7750 -6493 L
6253 -10607 L
H
S
0.00 G J
R
N
5615 -16587 M
n 1.167 o f
(N) h
5810 -18140 M
(e) h
5888 -19694 M
(t) h
5615 -21246 M
(w) h
5770 -22800 M
(o) h
5810 -24354 M
(r) h
5732 -25906 M
(k) h
14414 -17086 12599 6410 @
S
0.00 1 X U G J
R
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
17412 -13634 M
n 1.286 o f
(SinqHM) h
17965 -15359 M
(Master) h
30797 -12069 M
n 0.667 o f
(Filler) h
N
38178 -18846 M
31080 -20545 L
31080 -27341 L
38178 -29040 L
45279 -27341 L
45279 -20545 L
H
S
1.00 G E
R
S
152 w
1 c
1 j
0.00 G k
R
N
34329 -24949 M
/Times-Italic-ISOLatin1 $
/Times-Italic & P
/Times-Italic-ISOLatin1 F 1800 o f
(Histogram) h
32030 -26884 M
(Storage & Status) h
N
37575 -22189 M
36742 -19887 L
36839 -19851 L
36839 -19851 L
37005 -19786 L
37171 -19741 L
37331 -19716 L
37489 -19705 L
37489 -19705 L
37668 -20198 L
37668 -20198 L
37823 -20201 L
37976 -20215 L
38278 -20271 L
38278 -20271 L
38101 -19776 L
38101 -19776 L
38420 -19849 L
38741 -19915 L
38741 -19915 L
38918 -20408 L
38918 -20408 L
39078 -20431 L
39242 -20444 L
39405 -20445 L
39574 -20432 L
39574 -20432 L
39752 -20916 L
39752 -20916 L
39582 -20933 L
39415 -20931 L
39253 -20916 L
39095 -20896 L
39095 -20896 L
38918 -20408 L
38918 -20408 L
38597 -20340 L
38278 -20271 L
38278 -20271 L
38456 -20757 L
38456 -20757 L
38772 -20827 L
39095 -20896 L
39095 -20896 L
39271 -21382 L
39271 -21382 L
38950 -21315 L
38634 -21244 L
38634 -21244 L
38456 -20757 L
38456 -20757 L
38152 -20703 L
37999 -20687 L
37842 -20684 L
37842 -20684 L
37668 -20198 L
37668 -20198 L
37509 -20209 L
37347 -20234 L
37182 -20278 L
37016 -20345 L
37016 -20345 L
37192 -20831 L
37192 -20831 L
37360 -20764 L
37524 -20720 L
37685 -20694 L
37842 -20684 L
37842 -20684 L
38021 -21173 L
38021 -21173 L
37862 -21180 L
37701 -21207 L
37536 -21252 L
37368 -21317 L
37368 -21317 L
37684 -22189 L
37575 -22189 L
S
0.50 G E
R
S
41 w
1 c
1 j
0.00 G k
R
N
N
37368 -21317 M
37192 -20831 L
S
41 w
1 c
1 j
0.00 G k
R
N
N
37016 -20345 M
36839 -19851 L
S
41 w
1 c
1 j
0.00 G k
R
N
N
37489 -19705 M
37644 -19708 L
37798 -19724 L
38101 -19776 L
S
41 w
1 c
1 j
0.00 G k
R
N
N
38741 -19915 M
38901 -19938 L
39063 -19951 L
39226 -19953 L
39396 -19938 L
39396 -19938 L
39574 -20432 L
S
41 w
1 c
1 j
0.00 G k
R
N
N
39752 -20916 M
39927 -21406 L
39927 -21406 L
39756 -21418 L
39592 -21418 L
39431 -21406 L
39271 -21382 L
S
41 w
1 c
1 j
0.00 G k
R
N
N
38634 -21244 M
38328 -21191 L
38175 -21175 L
38021 -21173 L
S
41 w
1 c
1 j
0.00 G k
R
N
40756 -21309 M
/Times-Bold-ISOLatin1 F 800 o f
(Semaphores) h
10279 -34774 12599 6410 @
S
0.00 1 X U G J
R
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
13277 -31322 M
n 2.250 o f
(SinqHM) h
12905 -33047 M
(Server #1) h
N
2399 -37411 M
40612 -37411 L
S
150 w
0 c
0 j
[400 400] 0 d
0.00 G k
R
N
32402 -35854 M
/Times-Roman-ISOLatin1 $
/Times-Roman & P
/Times-Roman-ISOLatin1 F 1800 o f
(PowerPC) h
33153 -40255 M
(Host\(s\)) h
17025 -44258 12599 6410 @
S
0.00 1 X U G J
R
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
19850 -41697 M
/Times-Bold-ISOLatin1 F 1800 o f
(Client #3) h
13387 -49038 12599 6410 @
S
0.00 1 X U G J
R
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
16212 -46477 M
(Client #2) h
9749 -53817 12599 6410 @
S
0.00 1 X U G J
R
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
12574 -51256 M
(Client #1) h
41622 -22578 M
n 0.444 o f
(Signals) h
38442 -10637 M
/Helvetica-ISOLatin1 $
/Helvetica & P
/Helvetica-ISOLatin1 F 1000 o f
(Detector Data) h
N
42386 -11027 M
40331 -11027 L
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
N
40798 -10777 M
40112 -11027 L
40798 -11277 L
H
S
0.00 G J
R
N
N
42737 -7309 M
39542 -7309 L
S
75 w
0 c
0 j
2 i
0.00 G k
R
N
N
42270 -7559 M
42956 -7309 L
42270 -7059 L
H
S
0.00 G J
R
N
33772 -6855 M
(Configuration and Control) h
R
showpage
$P e
%%Trailer
$D end restore
% DEC_WRITE_dict
%%Pages: 1
%%DocumentFonts: Times-Bold
%%+ Times-Italic
%%+ Times-Roman
%%+ Helvetica

1048
sinqhm/hist_mem_spec_fig3.ps Executable file

File diff suppressed because it is too large Load Diff

1336
sinqhm/hist_mem_spec_fig4.ps Executable file

File diff suppressed because it is too large Load Diff

1423
sinqhm/lwl_client.c Executable file

File diff suppressed because it is too large Load Diff

485
sinqhm/lwl_server.c Executable file
View File

@ -0,0 +1,485 @@
#define ident "1B03"
/*
** +--------------------------------------------------------------+
** | Paul Scherrer Institute |
** | Computing Section |
** | |
** | This software may be used freely by non-profit organizations.|
** | It may be copied provided that the name of P.S.I. and of the |
** | author is included. Neither P.S.I. nor the author assume any |
** | responsibility for the use of this software outside of P.S.I.|
** +--------------------------------------------------------------+
**
** Module Name . . . . . . . . : [...SINQHM]LWL_SERVER.C
**
** Author . . . . . . . . . . : D. Maden
** Date of creation . . . . . . : Oct 1996
**
** Updates:
** 1A01 1-Oct-1996 DM Initial version.
**---------------------------------------------------------------------------
** LWL_SERVER.C is the main program of a SINQ Histogram Memory process
** which will run in a front-end processor, accept a TCP/IP connection
** and transfer received data into the LWL (Licht-Wellen-Leiter) Test
** generator.
**
** To compile this program for VxWorks on PSS123, use:
**
ccvx lwl_server.c
** where
ccvx = ccppc -O0 \
-mcpu=603 \
-I${WIND_BASE}/target/h \
-fno-builtin \
-fno-for-scope \
-nostdinc \
-DCPU=PPC603 \
-D_GNU_TOOL \
-gdwarf -c -Wimplicit
** and, on the target,
**
** -> ld < lwl_server.o
** -> taskSpawn "lwl_server", 100, 8, 20000, lwl_server, \
** <port>, <base-addr>, <verbose>
** ^ ^ ^
** | | |
** default = 3501 ------+ | |
** default = 0x1800 --------------+ |
** verbose mode if non-zero ------------------+
**
** To suppress VME access, e.g. for test purposes, compile with the
** option
** -D_NO_VME
**====================================================================
*/
#include <vxWorks.h>
#include <taskLib.h>
#include <msgQLib.h>
#include <sockLib.h>
#include <hostLib.h>
#include <inetLib.h>
#include <sysLib.h>
#include <vme.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
/*** #include <sys/file.h> ***/ /* Get POSIX file definitions. */
#include <signal.h> /* Get POSIX signal definitions. */
#include <sys/mman.h> /* Get POSIX mem mgmnt definitions. */
#include <sys/wait.h> /* Get POSIX wait definitions. */
#include "vmio10_def.h"
/*
**==================== Global Definitions =====================================
*/
#define DFLT_PORT 3501
#define DFLT_BASE_ADDR 0x1800
/*
**==================== Global Variables =====================================
*/
char *LwlBase;
char Lwl_dummy[64]; /* Dummy array - used only when VME access ..
** .. is disabled. */
int Lwl_cnct_skt = 0; /* Connection socket */
int Lwl_rw_skt = 0; /* Read/write socket */
char Lwl_inet_node[20];
char Lwl_inet_addr[20];
int Lwl_my_errno;
/*
**=============================================================================
** Local routines.
** Forward references ...
*/
void lwl_enable ();
void lwl_failInet (char *text);
void lwl_getErrno (int *his_errno);
void lwl_resetcio ();
void lwl_setup_inet_info ();
void lwl_vmio_byte_send (char bit8, char lobits);
void lwl_vmio_init ();
void lwl_vmio_send (char nbytes, char *buff);
void lwl_vmio_tg_reset ();
void lwl_vmio_transp_init ();
/*
**-----------------------------------------------------------------*/
void lwl_enable () {
/* ==========
** output/input enable for IC6 ,IC7
*/
LwlBase[VMIO_AB_CNTL] = 0x01;
LwlBase[VMIO_AB_CNTL] = 0x94;
LwlBase[VMIO_CD_CNTL] = 0x01;
LwlBase[VMIO_CD_CNTL] = 0x94;
}
/*
**-----------------------------------------------------------------*/
void lwl_failInet (char *text) {
/* ============
** Output the given text and exit the process.
*/
int my_errno;
lwl_getErrno (&my_errno);
printf ("\n### Internet Error ###\n");
printf (" ### errno = %d.\n", my_errno);
perror (text);
exit (EXIT_FAILURE);
}
/*
**-----------------------------------------------------------------*/
void lwl_getErrno (int *his_errno) {
/* ============
*/
*his_errno = errno; /* Make copy of errno */
return;
}
/*
**-----------------------------------------------------------------*/
void lwl_resetcio () {
/* ============
** Software reset for cio
*/
char aux;
aux = LwlBase[VMIO_AB_CNTL];
LwlBase[VMIO_AB_CNTL] = 0x00;
aux = LwlBase[VMIO_AB_CNTL];
LwlBase[VMIO_AB_CNTL] = 0x00;
LwlBase[VMIO_AB_CNTL] = 0x01;
LwlBase[VMIO_AB_CNTL] = 0x00;
aux = LwlBase[VMIO_CD_CNTL];
LwlBase[VMIO_CD_CNTL] = 0x00;
aux = LwlBase[VMIO_CD_CNTL];
LwlBase[VMIO_CD_CNTL] = 0x00;
LwlBase[VMIO_CD_CNTL] = 0x01;
LwlBase[VMIO_CD_CNTL] = 0x00;
}
/*
**-----------------------------------------------------------------*/
void lwl_setup_inet_info () {
/* ===================
** Get Internet Nodename and Address from System.
*/
int status;
struct in_addr my_addr;
status = gethostname (Lwl_inet_node, sizeof (Lwl_inet_node));
if (status != 0) sprintf (Lwl_inet_node, "Undefined");
my_addr.s_addr = hostGetByName (Lwl_inet_node);
inet_ntoa_b (my_addr, Lwl_inet_addr);
}
/*
**-----------------------------------------------------------------*/
void lwl_vmio_byte_send (char bit8, char lobits) {
/* ==================
** Send a byte (well, 9 bits really) via the VMIO10.
*/
char aux;
do { /* Wait for Output Reg. empty */
LwlBase[VMIO_AB_CNTL] = 0X09; /* Select Port B status reg .. */
aux = LwlBase[VMIO_AB_CNTL]; /* .. and read it. */
} while ((aux & 0x08) == 0); /* Test its "empty" bit */
LwlBase[VMIO_PORT_C] = bit8; /* Send Bit-8 */
LwlBase[VMIO_PORT_B] = lobits; /* Output the other bits */
}
/*
**-----------------------------------------------------------------*/
void lwl_vmio_init () {
/* =============
** initialise VMIO10 Module
*/
LwlBase[VMIO_CD_CNTL] = 0x2A; /* Port D %00101010 */
LwlBase[VMIO_CD_CNTL] = 0x00; /* %00000000, non inverting */
LwlBase[VMIO_CD_CNTL] = 0x2B; /* %00101011 */
LwlBase[VMIO_CD_CNTL] = 0x0F; /* %00001111, Run, EF0_S, Q2, Q1, Q0 */
LwlBase[VMIO_AB_CNTL] = 0x2A; /* Port B */
LwlBase[VMIO_AB_CNTL] = 0x00;
LwlBase[VMIO_AB_CNTL] = 0x2B;
LwlBase[VMIO_AB_CNTL] = 0x00;
LwlBase[VMIO_AB_CNTL] = 0x22; /* Port A %00100010 */
LwlBase[VMIO_AB_CNTL] = 0x00; /* %00000000, non inverting */
LwlBase[VMIO_AB_CNTL] = 0x23; /* %00100011 */
LwlBase[VMIO_AB_CNTL] = 0x00; /* %00000000, all output */
LwlBase[VMIO_CD_CNTL] = 0x22; /* Port C */
LwlBase[VMIO_CD_CNTL] = 0x00;
LwlBase[VMIO_CD_CNTL] = 0x23;
LwlBase[VMIO_CD_CNTL] = 0x00;
}
/*
**-----------------------------------------------------------------*/
void lwl_vmio_send (
/* ============= Send bytes to the LWL.
*/ char nbytes,
char *buff) {
/*
** The bytes are buff[0] to buff[nbytes-1]. buff[0] gives the
** headerbit for buff[1]. The remainder are sent with the 9th
** bit clear.
*/
int i;
char aux;
/*
** ---------- loop sending the bytes ---------------
*/
LwlBase[VMIO_PORT_C] = 0; /* Mode = 0 */
if (nbytes < 2) return;
lwl_vmio_byte_send (buff[0], buff[1]); /* 2 bytes define the first "LWL-byte" */
if (nbytes < 3) return;
for (i = 2; i < nbytes; i++) { /* The remaining bytes have Bit-8 = 0 */
lwl_vmio_byte_send (0x00, buff[i]);
}
}
/*
**-----------------------------------------------------------------*/
void lwl_vmio_tg_reset () {
/* =================
** Initialise VMIO10 Test Generator Piggyback
*/
LwlBase[VMIO_PORT_AB] = 0x02; /* Clear Write, Strobe */
LwlBase[VMIO_PORT_C] = 0x00; /* Mode = 0 -> R,W = High */
LwlBase[VMIO_PORT_C] = 0x07; /* Mode = reset */
LwlBase[VMIO_PORT_C] = 0x00; /* Mode = 0 */
}
/*
**-----------------------------------------------------------------*/
void lwl_vmio_transp_init () {
/* ====================
** Initialise VMIO10 ready for transparent
** transmission of data.
*/
/*
** ---------- initialize i/o ---------------
*/
LwlBase[VMIO_AB_CNTL] = 0x28; /* Port B output port-Mode Spec. Reg */
LwlBase[VMIO_AB_CNTL] = 0x80;
LwlBase[VMIO_AB_CNTL] = 0x29; /* Port B handshake interlock */
LwlBase[VMIO_AB_CNTL] = 0x00;
}
/*==============================================================================
** Main line program
** ------------------
**============================================================================*/
int lwl_server (int port, int base_addr, int verbose,
int arg4, int arg5, int arg6, int arg7, int arg8, int arg9,
int suspend) {
/*============================================================================*/
STATUS status;
char *my_task_name;
int i, j, n_bytes_got, bytes_to_get;
int msg_cnt = 0;
char *p_addr;
int cl_port;
struct sockaddr_in lcl_sockname;
struct sockaddr_in rmt_sockname;
int rmt_sockname_len;
char nbytes, buff[256], *p_buff;
/*============================================================================
*/
my_task_name = taskName (taskIdSelf());
if (suspend != 0) {
printf ("\n%s: Suspending ...\n", my_task_name);
taskSuspend (0); /* We've been told to suspend ourself, ..
** .. presumably for debug reasons.
*/
printf ("\n%s: ... suspension ended!\n", my_task_name);
}
/*============================================================================
** Perform the initialisation of global variables ...
*/
if (Lwl_cnct_skt != 0) {
printf ("\007Lwl_cnct_skt = %d -- still open? ... ", Lwl_cnct_skt);
status = close (Lwl_cnct_skt);
if (status != ERROR) taskDelay (30); /* Pause, maybe, to let system ..
** .. tidy up. */
printf ("it has been closed!\n");
Lwl_cnct_skt = 0;
}
if (Lwl_rw_skt != 0) {
printf ("\007Lwl_rw_skt = %d -- still open? ...", Lwl_rw_skt);
status = close (Lwl_rw_skt);
if (status != ERROR) taskDelay (30); /* Pause, maybe, to let system ..
** .. tidy up. */
printf ("it has been closed!\n");
Lwl_rw_skt = 0;
}
/*============================================================================
** Get a port number to use. If the argument "port" is not
** a valid port number (not in range 128 to 32767), use DFLT_PORT.
*/
if ((port < 128) || (port > 32767)) port = DFLT_PORT;
/*============================================================================
** Get the VME base address of the Test Generator Module.
** If the argument "base_addr" is zero, use DFLT_BASE_ADDR.
*/
if (base_addr == 0) base_addr = DFLT_BASE_ADDR;
#ifdef _NO_VME
printf ("LWL_SERVER: Warning, VME access disabled.\n");
LwlBase = Lwl_dummy;
#else
status = sysBusToLocalAdrs (VME_AM_USR_SHORT_IO,
(char *) base_addr, &LwlBase);
if (status != OK) {
printf ("Error status from sysBusToLocalAdrs\n");
return ERROR;
}
#endif /* _NO_VME */
/*
** Initialise the Test Generator Module.
*/
lwl_resetcio ();
lwl_vmio_init ();
lwl_enable ();
lwl_vmio_tg_reset ();
/*============================================================================
** Create a TCP/IP socket for receiving connection requests, bind it and
** set it to listen.
*/
Lwl_cnct_skt = socket (AF_INET, SOCK_STREAM, 0);
if (Lwl_cnct_skt == -1) lwl_failInet ("\nLWL_SERVER -- Cnct-Socket socket error");
lcl_sockname.sin_family = AF_INET;
lcl_sockname.sin_port = htons (port);
lcl_sockname.sin_addr.s_addr = 0;
status = bind (Lwl_cnct_skt, (struct sockaddr *) &lcl_sockname,
sizeof (lcl_sockname));
if (status != 0) lwl_failInet ("\nLWL_SERVER -- Cnct-Socket bind error");
status = listen (Lwl_cnct_skt, 5);
if (status != 0) lwl_failInet ("\nLWL_SERVER -- Cnct-Socket listen error");
lwl_setup_inet_info (); /* Find out who we are */
printf ("\nLWL_SERVER Ident \"%s\" started on %s (%s). Port %d.\n",
ident, Lwl_inet_node, Lwl_inet_addr, port);
if (verbose != 0) printf ("Verbose mode\n");
/*
**===============================================
** Loop accepting connections from clients.
*/
while (TRUE) {
rmt_sockname_len = sizeof (rmt_sockname);
Lwl_rw_skt = accept (Lwl_cnct_skt, (struct sockaddr *) &rmt_sockname,
&rmt_sockname_len);
if (Lwl_rw_skt <= 0) {
lwl_getErrno (&Lwl_my_errno);
close (Lwl_cnct_skt);
Lwl_cnct_skt = 0;
lwl_failInet ("\nLWL_SERVER -- Cnct-Socket accept error"); /* No return */
}
p_addr = inet_ntoa (rmt_sockname.sin_addr);
cl_port = ntohs (rmt_sockname.sin_port);
printf ("\nLWL_SERVER_%d: Connected to Node %s, Port %d.\n",
port, p_addr, cl_port);
lwl_vmio_transp_init (); /* Ensure the VMIO10 module is in correct mode. */
/*
**=======================================================
** Loop reading messages from client.
*/
n_bytes_got = recv (Lwl_rw_skt, &nbytes, 1, NULL);
while ((n_bytes_got == 1) && (nbytes != 0)) {
if (verbose != 0) printf ("\nLWL:%3d", nbytes);
/*
** See if it's a "special" request (0x80 to 0xff).
*/
if ((nbytes & 0x80) == 0) {
msg_cnt++;
bytes_to_get = nbytes;
p_buff = buff;
while (bytes_to_get > 0) {
n_bytes_got = recv (Lwl_rw_skt, p_buff, bytes_to_get, NULL);
if (n_bytes_got != bytes_to_get) {
if (n_bytes_got <= 0) {
printf ("\nLWL_SERVER: recv error on message %d; "
" recv status = %d\n", n_bytes_got);
printf (" This is fatal - closing connection to %s.\n",
inet_ntoa (rmt_sockname.sin_addr));
close (Lwl_rw_skt);
Lwl_rw_skt = 0;
close (Lwl_cnct_skt);
Lwl_cnct_skt = 0;
return ERROR;
}
}
bytes_to_get -= n_bytes_got;
p_buff += n_bytes_got;
}
if (verbose != 0) {
for (i = 0; i < nbytes; i++) {
if ((i % 16 == 0) && (i != 0)) {
printf ("\n %02x", buff[i]);
}else {
printf (" %02x", buff[i]);
}
}
printf ("\n");
}
lwl_vmio_send (nbytes, buff); /* Send the bytes to the LWL. */
}else if (nbytes == 0x81) {
printf ("\nLWL_SERVER: message count set to zero\n");
msg_cnt = 0;
}else if (nbytes == 0x82) {
printf ("\nLWL_SERVER: message count = %d\n", msg_cnt);
}else {
printf ("\nLWL_SERVER: unrecognised request received -- exiting!\n");
printf (" Request byte = 0x%x\n", nbytes);
close (Lwl_rw_skt);
Lwl_rw_skt = 0;
close (Lwl_cnct_skt);
Lwl_cnct_skt = 0;
return ERROR;
}
n_bytes_got = recv (Lwl_rw_skt, &nbytes, 1, NULL);
}
/*
** End of loop reading messages from client.
**===============================================
*/
if (n_bytes_got <= 0) {
printf ("\nLWL_SERVER -- R/W-Socket recv error.\n");
printf (" Closing connection to %s.\n",
inet_ntoa (rmt_sockname.sin_addr));
}else {
printf ("\nLWL_SERVER -- client %s has terminated his connection.\n",
inet_ntoa (rmt_sockname.sin_addr));
}
close (Lwl_rw_skt);
Lwl_rw_skt = 0;
}
/*
** End of loop accepting connections from clients.
**======================================================
*/
return OK;
}
/*========================================= End of LWL_SERVER.C ========*/

202
sinqhm/make_sinqhm.com Executable file
View File

@ -0,0 +1,202 @@
$! TAS_SRC:[SINQHM]MAKE_SINQHM.COM Ident V01A
$! =============================
$!
$! V01D 12-May-2000 DM. Initial version
$!-------------------------------------------------------------------------
$ progs = "lwl_client," + -
"sinqhm_bootutil_client," + -
"sinqhm_client," + -
"sinqhm_ctrl"
$ progs = f$edit (progs, "collapse, upcase") + ","
$!-------------------------------------------------------------------------
$ if p1 .nes. "?" .and. -
p1 .nes. "H" .and. -
p1 .nes. "HE" .and. -
p1 .nes. "HEL" .and. -
p1 .nes. "HELP" then goto skip_help
$ type sys$input
-------------------------------------------------------------------------
Usage:
@TAS_SRC:[SINQHM]MAKE_SINQHM.COM <exe-list>
where
<exe-list> = list of programs to make.
<exe-list> must be a comma separated list without white space chars.
If <exe-list> is empty, everything is created. Otherwise, just the named
programs are created. The programs which may be selected are:
$
$ cnt = 0
$ exe_loop:
$ exe = f$element (cnt, ",", progs)
$ cnt = cnt + 1
$ if (exe .nes. ",") .and. (exe .nes. "") then say " ''exe'
$ if exe .nes. "," then goto exe_loop
$ type sys$input
All programs are compiled with debug. If MAD_EXE is not
"TASMAD_DISK:[MAD.EXE]", _DBG versions of .EXE files are also created.
-------------------------------------------------------------------------
$ exit
$ skip_help:
$ say := write sys$output
$ bel[0,8] = 7
$
$ fopt = "/debug/noopt/include=tas_src:[def]"
$ if f$getsyi("ARCH_TYPE") .eq. 2 then fopt = fopt + "/sep"
$
$ copt = "/decc/prefix=all/debug/noopt"
$
$ no_dbg := false
$ if f$trnlnm ("mad_exe") .eqs. "TASMAD_DISK:[MAD.EXE]" then -
no_dbg := true
$ if .not. no_dbg then say "Debug execs will also be created ...
$! ***********************************************************
$ targ = f$element (0, "]", f$environment ("procedure")) + "]"
$ targ_obj = f$element (0, "]", f$environment ("procedure")) + ".OBJ]"
$
$ mad_exe = f$trnlnm ("mad_exe")
$
$ if p1 .eqs. "" then p1 := all
$ if p1 .eqs. "ALL" then goto do_all
$!
$! Get here to build selected utilities.
$!
$ cnt = 0 ! First loop selecting no progs.
$ lp0:
$ nxt = f$element (cnt, ",", progs)
$ cnt = cnt + 1
$ if nxt .eqs. "" then goto lp0_end
$ do_'nxt' := false
$ goto lp0
$ lp0_end:
$! Now pick out the items in P1
$!
$ pp1 = f$edit (p1, "collapse, upcase") + ","
$ u_len = f$length (progs)
$ cnt = 0
$ lp1:
$ nxt = f$element (cnt, ",", pp1)
$ nxtt = nxt + ","
$ cnt = cnt + 1
$ if nxt .eqs. "" then goto lp1_end
$ if f$locate (nxtt, progs) .lt. u_len then goto lp1_ok
$ say "''bel'''nxt' is not a recognised TASMAD utility!
$ exit
$ lp1_ok:
$ do_'nxt' := true
$ goto lp1
$ lp1_end:
$ goto do_comn
$!----------------------------------------------------------------------
$ do_all:
$ cnt = 0 ! Loop selecting all progs.
$ lp2:
$ nxt = f$element (cnt, ",", progs)
$ cnt = cnt + 1
$ if nxt .eqs. "" then goto lp2_end
$ do_'nxt' := true
$ goto lp2
$ lp2_end:
$ do_comn:
$!-----------------------------------------------------------------
$! Compile and build LWL_CLIENT
$!
$ if .not. do_lwl_client then goto skp_lwl_client
$ say "Compiling and linking LWL_CLIENT ...
$ cc 'copt' 'targ'lwl_client + tas_src:[lib]sinq_c.tlb/lib
$ link /exe=mad_exe:lwl_client sys$input/opt
lwl_client
tas_src:[lib]sinq_dbg/lib
sys$share:decw$xlibshr/share
$ purge mad_exe:lwl_client.exe
$ rename mad_exe:lwl_client.exe;0 lwl_client.exe;1
$
$ if no_dbg then goto lwl_client_no_dbg
$ link /debug /exe=mad_exe:lwl_client_dbg sys$input/opt
lwl_client
tas_src:[lib]sinq_dbg/lib
sys$share:decw$xlibshr/share
$ purge mad_exe:lwl_client_dbg.exe
$ rename mad_exe:lwl_client_dbg.exe;0 lwl_client_dbg.exe;1
$ lwl_client_no_dbg:
$ delete/nolog lwl_client.obj;*
$ skp_lwl_client:
$!-----------------------------------------------------------------
$! Compile and build SINQHM_BOOTUTIL_CLIENT
$!
$ if .not. do_sinqhm_bootutil_client then goto skp_sinqhm_bootutil_client
$ say "Compiling and linking SINQHM_BOOTUTIL_CLIENT ...
$ cc 'copt' 'targ'sinqhm_bootutil_client + tas_src:[lib]sinq_c.tlb/lib
$ link /exe=mad_exe:sinqhm_bootutil_client sys$input/opt
sinqhm_bootutil_client
tas_src:[lib]sinq_dbg/lib
sys$share:decw$xlibshr/share
$ purge mad_exe:sinqhm_bootutil_client.exe
$ rename mad_exe:sinqhm_bootutil_client.exe;0 -
sinqhm_bootutil_client.exe;1
$
$ if no_dbg then goto sinqhm_bootutil_client_no_dbg
$ link /debug /exe=mad_exe:sinqhm_bootutil_client_dbg sys$input/opt
sinqhm_bootutil_client
tas_src:[lib]sinq_dbg/lib
sys$share:decw$xlibshr/share
$ purge mad_exe:sinqhm_bootutil_client_dbg.exe
$ rename mad_exe:sinqhm_bootutil_client_dbg.exe;0 -
sinqhm_bootutil_client_dbg.exe;1
$ sinqhm_bootutil_client_no_dbg:
$ delete/nolog sinqhm_bootutil_client.obj;*
$ skp_sinqhm_bootutil_client:
$!-----------------------------------------------------------------
$! Compile and build SINQHM_CLIENT
$!
$ if .not. do_sinqhm_client then goto skp_sinqhm_client
$ say "Compiling and linking SINQHM_CLIENT ...
$ cc 'copt' 'targ'sinqhm_client + tas_src:[lib]sinq_c.tlb/lib
$ link /exe=mad_exe:sinqhm_client sys$input/opt
sinqhm_client
tas_src:[lib]sinq_dbg/lib
pgplot_dir:cpgplot.olb/lib
pgplot_dir:grpckg.olb/lib
sys$share:decw$xlibshr/share
$ purge mad_exe:sinqhm_client.exe
$ rename mad_exe:sinqhm_client.exe;0 sinqhm_client.exe;1
$
$ if no_dbg then goto sinqhm_client_no_dbg
$ link /debug /exe=mad_exe:sinqhm_client_dbg sys$input/opt
sinqhm_client
tas_src:[lib]sinq_dbg/lib
pgplot_dir:cpgplot.olb/lib
pgplot_dir:grpckg.olb/lib
sys$share:decw$xlibshr/share
$ purge mad_exe:sinqhm_client_dbg.exe
$ rename mad_exe:sinqhm_client_dbg.exe;0 sinqhm_client_dbg.exe;1
$ sinqhm_client_no_dbg:
$ delete/nolog sinqhm_client.obj;*
$ skp_sinqhm_client:
$!-----------------------------------------------------------------
$! Compile and build SINQHM_CTRL
$!
$ if .not. do_sinqhm_ctrl then goto skp_sinqhm_ctrl
$ say "Compiling and linking SINQHM_CTRL ...
$ cc 'copt' 'targ'sinqhm_ctrl + tas_src:[lib]sinq_c.tlb/lib
$ link /exe=mad_exe:sinqhm_ctrl sys$input/opt
sinqhm_ctrl
tas_src:[lib]sinq_dbg/lib
sys$share:decw$xlibshr/share
$ purge mad_exe:sinqhm_ctrl.exe
$ rename mad_exe:sinqhm_ctrl.exe;0 sinqhm_ctrl.exe;1
$
$ if no_dbg then goto sinqhm_ctrl_no_dbg
$ link /debug /exe=mad_exe:sinqhm_ctrl_dbg sys$input/opt
sinqhm_ctrl
tas_src:[lib]sinq_dbg/lib
sys$share:decw$xlibshr/share
$ purge mad_exe:sinqhm_ctrl_dbg.exe
$ rename mad_exe:sinqhm_ctrl_dbg.exe;0 sinqhm_ctrl_dbg.exe;1
$ sinqhm_ctrl_no_dbg:
$ delete/nolog sinqhm_ctrl.obj;*
$ skp_sinqhm_ctrl:
$!-----------------------------------------------------------------
$ exit

354
sinqhm/monitor.c Normal file
View File

@ -0,0 +1,354 @@
/*****************************************************************************
* File: monitor.c
* Purpose: to allow a user to easily edit memory using 1,2
* or 4 byte
* words.
* Author: Scott Johnson
* Host Sys: VxWorks
* Started: 01/20/90
* Updates: 02/13/90 added my own display routine
* 03/29/90 added history
* 08/22/90 fixed repeat command (return key)
* 11/13/90 bus errors are trapped
* Mark Koennecke
* 04/02/2002 for Tornado 2.0.2
*****************************************************************************/
/* tabstop = 4 */
#include "vxWorks.h"
#include "strLib.h"
#include "stdioLib.h"
int data_type = 2; /* 1 = byte 2 = word 4 = long */
static void help(void);
static int process_command(char *command);
int monitor (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
int a8, int a9, int suspend)
{
char command [80];
char input [80];
char *from_read;
printf ("VxWorks history added 03/29/90\n");
printf ("Bus Error trapping added 11/13/90\n\n");
do
{
switch (data_type)
{
case 1 : printf ("byte>"); break;
case 2 : printf ("word>"); break;
case 4 : printf ("long>"); break;
}
if ((from_read = fgets(input,79,stdin)) != EOF)
{
if ( strlen(input) == 0 && (strlen(command) != 0))
{
printf ("%s\n", command);
process_command (command);
}
else
{
printf ("%s\n", input);
process_command (input);
strcpy (command, input);
}
}
} while ((input [0] != 'q') && (from_read != EOF));
fflush (stdin);
fflush (stdout);
return 1;
}
static int process_command (command)
char *command;
{
unsigned long longInt, longVal;
unsigned short shortInt;
unsigned char byte;
unsigned char *ptr;
unsigned char *address, *size;
unsigned int start, end, value;
int scanned;
char ch;
switch (command [0])
{
case 'q' : /* user wants to quit so do nothing */
case '#' : /* comment character */
break;
case 'f' : /* block fill */
scanned=sscanf(command,"%c %x %x %x",&ch,&address,&size,&longInt);
if (scanned != 4)
printf ("usage : f address size value\n");
else
{
for (ptr = address ;(int)ptr < ((int)size + (int)address);
ptr+=data_type)
{
switch (data_type)
{
case 1 :
if (vxMemProbe (ptr, READ, data_type, &byte) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
return (1);
}
else
*((unsigned char *) ptr) = byte;
break;
case 2 :
if (vxMemProbe (ptr, READ, data_type, &shortInt) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
return (1);
}
else
*((unsigned short *) ptr) = shortInt;
break;
case 4 :
if (vxMemProbe (ptr, READ, data_type, &longInt) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
return (1);
}
else
*((unsigned long *) ptr) = longInt;
break;
}
}
}
break;
case 's' : /* scan range */
scanned=sscanf(command,"%c %x %x %x",&ch,&start,&end,&value);
if (scanned != 4)
printf ("usage : s start end value\n");
else
{
/**
scanning does not work: some memory locations lock up!!!!
*/
printf("Scanning from %x %x for %x\n", start, end, value);
for (ptr = start ;(unsigned int)ptr < end;
ptr+=data_type)
{
switch (data_type)
{
case 1 :
if (vxMemProbe (ptr, READ, data_type, &byte) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
}
else {
if((unsigned char)*ptr == value){
printf("Value found at %08x\n",ptr);
}
}
break;
case 2 :
if (vxMemProbe (ptr, READ, data_type, &shortInt) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
}
else
{
if((unsigned short)*ptr == value){
printf("Value found at %08x\n",ptr);
}
}
break;
case 4 :
if (vxMemProbe (ptr, READ, data_type, &longInt) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
}
else
{
if((unsigned int)*ptr == value){
printf("Value found at %08x\n",ptr);
}
}
}
}
}
printf("Finished scanning....\n");
break;
case 'l' :
data_type = 4;
break;
case 'b' :
data_type = 1;
break;
case 'w' :
if (command [1] == 'o')
data_type = 2;
else
{
scanned=sscanf(command,"%c %x %x",&ch,&ptr,&longInt);
if (scanned != 3)
printf ("usage : w address value\n");
else
{
switch (data_type)
{
case 1 :
byte = (unsigned char) longInt;
if (vxMemProbe (ptr, WRITE, data_type, &byte) != OK)
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
else
printf("%06X : %02X\n",(unsigned) ptr, byte);
break;
case 2 :
shortInt = (unsigned short) longInt;
if (vxMemProbe (ptr, WRITE, data_type, &shortInt) != OK)
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
else
printf ("%06X : %04X\n", (unsigned) ptr, shortInt);
break;
case 4 :
if (vxMemProbe (ptr, WRITE, data_type, &longInt) != OK)
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
else
printf ("%06X : %08X\n", (unsigned) ptr, longInt);
break;
}
}
}
break;
case 'r' :
scanned = sscanf (command,"%c %x", &ch,&ptr);
if (scanned != 2)
printf ("usage : r address\n");
else
{
switch (data_type)
{
case 1 :
if (vxMemProbe (ptr, READ, data_type, &byte) != OK)
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
else
printf ("%06x : %02x\n",(unsigned) ptr, byte);
break;
case 2 :
if (vxMemProbe (ptr, READ, data_type, &shortInt) != OK)
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
else
printf ("%06x : %04x\n",(unsigned) ptr, shortInt);
break;
case 4 :
if (vxMemProbe (ptr, READ, data_type, &longInt) != OK)
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
else
printf ("%06X : %08X\n", (unsigned) ptr, longInt);
break;
}
}
break;
case 'd' : /* use VxWorks display routine */
scanned = sscanf (command,"%c %x", &ch,&ptr);
if (scanned != 2)
printf ("usage : d address\n");
else
{
int x,y;
for (y=0;y<16;y++)
{
printf ("%06X-", (unsigned int) ptr);
for (x=0;x<16/data_type;x++, ptr += data_type)
{
switch (data_type)
{
case 1 :
if (vxMemProbe (ptr, READ, data_type, &byte) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
return (1);
}
else
printf (" %02x", byte);
break;
case 2 :
if (vxMemProbe (ptr, READ, data_type, &shortInt) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
return (1);
}
else
printf (" %04x", shortInt);
break;
case 4 :
if (vxMemProbe (ptr, READ, data_type, &longInt) != OK)
{
printf ("Bus error: address = %06x, data size = %d\n",
(unsigned int) ptr, data_type);
return (1);
}
else
printf (" %08x", longInt);
break;
}
}
printf ("\n");
}
}
break;
case 'h' :
help ();
break;
default :
printf ("Unrecognized command. Use h for help.\n");
break;
}
return 1;
}
static void help ()
{
printf ("===================================================\n");
printf ("= Monitor =\n");
printf ("= By Scott Johnson =\n");
printf ("===================================================\n");
printf ("Commands:\n");
printf ("[r]ead address..................reads given address\n");
printf ("[w]rite address value...........writes value to address\n");
printf ("[b]yte..........................read/write 8 bits\n");
printf ("[wo]rd..........................read/write 16 bits\n");
printf ("[l]ong..........................read/write 32 bits\n");
printf ("[d]isplay address...............show memory at address\n");
printf ("[f]ill address size value.......fill a block with value\n");
printf
("[s]scan start end value.........scan range between start end for value\n");
printf ("[q]uit..........................quit\n");
printf ("\n");
printf ("Features:\n");
printf ("1) Hit return to do a command again.\n");
printf ("2) VxWorks history is supported\n");
printf ("3) Redirect a script file while in the shell to easily\n");
printf (" setup multiple locations.\n");
printf (" Ex: -> monitor < script_file \n");
printf ("\n");
printf ("Remember to end script files with a 'q'\n");
printf ("\n");
}

743
sinqhm/psi_logo.ps Executable file
View File

@ -0,0 +1,743 @@
%!PS-Adobe-2.1
%%Creator: DECwrite V3.0-2
%%+Copyright (c) 1990,1994 DIGITAL EQUIPMENT CORPORATION.
%%+All Rights Reserved.
%%DocumentFonts: (atend)
%%EndComments
%%BeginProcSet DEC_WRITE 1.10
save/DEC_WRITE_dict 150 dict def DEC_WRITE_dict begin/$D exch def/$I 0
def/$S 0 def/$C matrix def/$R matrix def/$L matrix def/$E matrix
def/pat1{/px exch def/pa 8 array def 0 1 7{/py exch def/pw 4 string def 0 1
3{pw exch px py 1 getinterval putinterval}for pa py pw put}for}def/pat2{/pi
exch def/cflag exch def save cflag 1 eq{eoclip}{clip}ifelse
newpath{clippath pathbbox}stopped not{/ph exch def/pw exch def/py exch
def/px exch def/px px 3072 div floor 3072 mul def/py py 3072 div floor 3072
mul def px py translate/pw pw px sub 3072 div floor 1 add cvi def/ph ph py
sub 3072 div floor 1 add cvi def pw 3072 mul ph 3072 mul scale/pw pw 32 mul
def/ph ph 32 mul def/px 0 def/py 0 def pw ph pi[pw 0 0 ph 0 0]{pa py get/px
px 32 add def px pw ge{/px 0 def/py py 1 add 8 mod def}if}pi
type/booleantype eq{imagemask}{image}ifelse}if restore}def/PS{/_op exch
def/_np 8 string def 0 1 7{/_ii exch def/num _op _ii get def _np 7 _ii sub
num -4 bitshift PX num 15 and 4 bitshift -4 bitshift PX 4 bitshift or
put}for _np}def/PX{[15 7 11 3 13 5 9 1 14 6 10 2 12 4 8 0]exch
get}def/FR{0.7200 0 $E defaultmatrix dtransform/yres exch def/xres exch def
xres dup mul yres dup mul add sqrt}def/SU{/_sf exch def/_sa exch def/_cs
exch def/_mm $C currentmatrix def/rm _sa $R rotate def/sm _cs dup $L scale
def sm rm _mm _mm concatmatrix _mm concatmatrix pop 1 0 _mm dtransform/y1
exch def/x1 exch def/_vl x1 dup mul y1 dup mul add sqrt def/_fq FR _vl div
def/_na y1 x1 atan def _mm 2 get _mm 1 get mul _mm 0 get _mm 3 get mul sub
0 gt{{neg}/_sf load concatprocs/_sf exch def}if _fq _na/_sf load
setscreen}def/BO{/_yb exch def/_xb exch def/_bv _bs _yb _bw mul _xb 8 idiv
add get def/_mk 1 7 _xb 8 mod sub bitshift def _bv _mk and 0 ne $I 1 eq
xor}def/BF{DEC_WRITE_dict begin/_yy exch def/_xx exch def/_xi _xx 1 add 2
div _bp mul cvi def/_yi _yy 1 add 2 div _bp mul cvi def _xi _yi BO{/_nb _nb
1 add def 1}{/_fb _fb 1 add def 0}ifelse end}def/setpattern{/_cz exch
def/_bw exch def/_bp exch def/_bs exch PS def/_nb 0 def/_fb 0 def _cz 0/BF
load SU{}settransfer _fb _fb _nb add div setgray/$S 1
def}def/invertpattern{$S 0 eq{{1 exch sub}currenttransfer concatprocs
settransfer}if}def/invertscreen{/$I 1 def/$S 0 def}def/revertscreen{/$I 0
def}def/setrect{/$h exch def/$w exch def/$y exch def/$x exch def newpath $x
$y moveto $w $x add $y lineto $w $x add $h $y add lineto $x $h $y add
lineto closepath}def/concatprocs{/_p2 exch cvlit def/_p1 exch cvlit def/_pn
_p1 length _p2 length add array def _pn 0 _p1 putinterval _pn _p1 length
_p2 putinterval _pn cvx}def/OF/findfont load def/findfont{dup
DEC_WRITE_dict exch known{DEC_WRITE_dict exch get}if DEC_WRITE_dict/OF get
exec}def
mark/ISOLatin1Encoding
8#000 1 8#001{StandardEncoding exch get}for /emdash/endash
8#004 1 8#025{StandardEncoding exch get}for /quotedblleft/quotedblright
8#030 1 8#054{StandardEncoding exch get}for /minus 8#056 1 8#217
{StandardEncoding exch get}for/dotlessi 8#301 1 8#317{StandardEncoding
exch get}for/space/exclamdown/cent/sterling/currency/yen/brokenbar/section
/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered
/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde
/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave
/Iacute/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde
/Odieresis/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave
/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
256 array astore def cleartomark
/encodefont{findfont dup maxlength dict begin{1 index/FID ne{def}{pop
pop}ifelse}forall/Encoding exch def dup/FontName exch def currentdict
definefont end}def/loads{/$/ISOLatin1Encoding load def/&/encodefont load
def/*/invertpattern load def/+/revertscreen load def/-/invertscreen load
def/:/concatprocs load def/^/setpattern load def/~/pat1 load def/_/pat2
load def/@/setrect load def/A/arcn load def/B/ashow load def/C/curveto load
def/D/def load def/E/eofill load def/F/findfont load def/G/setgray load
def/H/closepath load def/I/clip load def/J/fill load def/K/kshow load
def/L/lineto load def/M/moveto load def/N/newpath load def/O/rotate load
def/P/pop load def/R/grestore load def/S/gsave load def/T/translate load
def/U/sub load def/V/div load def/W/widthshow load def/X/exch load
def/Y/awidthshow load def/a/save load def/c/setlinecap load def/d/setdash
load def/e/restore load def/f/setfont load def/g/initclip load def/h/show
load def/i/setmiterlimit load def/j/setlinejoin load def/k/stroke load
def/l/rlineto load def/m/rmoveto load def/n/currentfont load
def/o/scalefont load def/p/currentpoint load def/q/setrgbcolor load
def/r/currenttransfer load def/s/scale load def/t/setmatrix load
def/u/settransfer load def/w/setlinewidth load def/x/matrix load
def/y/currentmatrix load def}def
end
%%EndProcSet
%%EndProlog
%%BeginSetup
DEC_WRITE_dict begin
loads
version cvi 23.0 gt {
currentdict {dup type /arraytype eq
{bind def} {pop pop} ifelse} forall} if
0.0100 0.0100 s
%%EndSetup
%%Page: 1 1
/$P a D
g N
0 84189 T
7087 -79802 T
N
312 -1212 M
-7087 79802 T
7087 -1169 T
N
312 -1212 M
-7087 1169 T
7087 -5669 T
N
312 -1212 M
312 -12072 M
-7087 5669 T
N
S
7087 -16800 14877 9419 @ I N
7087 -7381 T
N
N
3855 -2089 M
3855 -5168 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
4021 -1834 M
6176 -1834 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
6344 -2088 M
6344 -4034 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
5337 -4410 M
5337 -5164 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
4060 -5343 M
5185 -5342 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
5526 -4199 M
6174 -4199 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
4960 -3016 M
5569 -3016 L
S
200 w
0 c
0 j
0.00 G k
R
N
S
N
/ctm_cached x y D
4077 -2057 T
217 229 s
0 0 1 -191 -259 A
ctm_cached t
N
/ctm_cached x y D
4077 -2057 T
217 229 s
0 0 1 -191 -259 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
4125 -5053 T
273 293 s
0 0 1 -101 -169 A
ctm_cached t
N
/ctm_cached x y D
4125 -5053 T
273 293 s
0 0 1 -101 -169 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
5087 -5079 T
254 271 s
0 0 1 -11 -79 A
ctm_cached t
N
/ctm_cached x y D
5087 -5079 T
254 271 s
0 0 1 -11 -79 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
5587 -4417 T
261 230 s
0 0 1 -191 -259 A
ctm_cached t
N
/ctm_cached x y D
5587 -4417 T
261 230 s
0 0 1 -191 -259 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
6114 -3986 T
229 213 s
0 0 1 -11 -79 A
ctm_cached t
N
/ctm_cached x y D
6114 -3986 T
229 213 s
0 0 1 -11 -79 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
6090 -2152 T
263 328 s
0 0 1 79 11 A
ctm_cached t
N
/ctm_cached x y D
6090 -2152 T
263 328 s
0 0 1 79 11 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
N
6361 -4355 M
6357 -5209 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
6573 -1846 M
8675 -1846 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
8871 -2060 M
8871 -2877 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
8872 -3309 M
8872 -5208 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
6615 -5378 M
8693 -5378 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
7270 -3041 M
8693 -3041 L
S
200 w
0 c
0 j
0.00 G k
R
N
S
N
/ctm_cached x y D
6659 -2136 T
317 298 s
0 0 1 -191 -259 A
ctm_cached t
N
/ctm_cached x y D
6659 -2136 T
317 298 s
0 0 1 -191 -259 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
6686 -5127 T
334 262 s
0 0 1 -101 -169 A
ctm_cached t
N
/ctm_cached x y D
6686 -5127 T
334 262 s
0 0 1 -101 -169 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
8573 -5134 T
307 249 s
0 0 1 -11 -79 A
ctm_cached t
N
/ctm_cached x y D
8573 -5134 T
307 249 s
0 0 1 -11 -79 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
8576 -2126 T
297 288 s
0 0 1 79 11 A
ctm_cached t
N
/ctm_cached x y D
8576 -2126 T
297 288 s
0 0 1 79 11 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
8626 -2813 T
245 227 s
0 0 1 -11 -79 A
ctm_cached t
N
/ctm_cached x y D
8626 -2813 T
245 227 s
0 0 1 -11 -79 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
8620 -3358 T
255 323 s
0 0 1 79 11 A
ctm_cached t
N
/ctm_cached x y D
8620 -3358 T
255 323 s
0 0 1 79 11 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
N
6540 -4199 M
7966 -4199 L
S
200 w
0 c
0 j
0.00 G k
R
N
S
N
/ctm_cached x y D
6594 -4396 T
239 202 s
0 0 1 -191 -259 A
ctm_cached t
N
/ctm_cached x y D
6594 -4396 T
239 202 s
0 0 1 -191 -259 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
6615 -3952 T
276 247 s
0 0 1 -101 -169 A
ctm_cached t
N
/ctm_cached x y D
6615 -3952 T
276 247 s
0 0 1 -101 -169 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
9236 -2164 T
367 313 s
0 0 1 -191 -259 A
ctm_cached t
N
/ctm_cached x y D
9236 -2164 T
367 313 s
0 0 1 -191 -259 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
S
N
/ctm_cached x y D
9163 -5091 T
291 254 s
0 0 1 -101 -169 A
ctm_cached t
N
/ctm_cached x y D
9163 -5091 T
291 254 s
0 0 1 -101 -169 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
N
9100 -5340 M
10370 -5340 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
10571 -5155 M
10571 -2157 L
S
200 w
0 c
0 j
0.00 G k
R
N
S
N
/ctm_cached x y D
10299 -5073 T
279 271 s
0 0 1 -11 -79 A
ctm_cached t
N
/ctm_cached x y D
10299 -5073 T
279 271 s
0 0 1 -11 -79 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
N
9154 -1858 M
10427 -1858 L
S
200 w
0 c
0 j
0.00 G k
R
N
N
8871 -2833 M
8871 -3294 L
S
200 w
0 c
0 j
0.00 G k
R
N
2124 -4538 1569 1658 @
S
0.75 G J
R
N
10721 -4526 1569 1658 @
S
0.75 G J
R
N
N
6142 -4296 M
6267 -4191 L
6320 -4252 L
6198 -4354 L
H
S
0.75 G E
R
N
N
5604 -4321 M
5475 -4391 L
5475 -4485 L
6253 -4485 L
6253 -4374 L
6173 -4317 L
H
S
0.75 G E
R
N
S
N
/ctm_cached x y D
10350 -2201 T
225 349 s
0 0 1 79 11 A
ctm_cached t
N
/ctm_cached x y D
10350 -2201 T
225 349 s
0 0 1 79 11 A
ctm_cached t
S
200 w
0 c
0 j
0.00 G k
R
R
R
showpage
$P e
%%Trailer
$D end restore
% DEC_WRITE_dict
%%Pages: 1
%%DocumentFonts:

1385
sinqhm/sinq_logo.ps Executable file

File diff suppressed because it is too large Load Diff

1311
sinqhm/sinqhm_bootutil_client.c Executable file

File diff suppressed because it is too large Load Diff

3124
sinqhm/sinqhm_client.c Executable file

File diff suppressed because it is too large Load Diff

2038
sinqhm/sinqhm_ctrl.c Executable file

File diff suppressed because it is too large Load Diff

944
sinqhm/usrConfig.c Executable file
View File

@ -0,0 +1,944 @@
/* usrConfig.c - user-defined system configuration library */
/* Copyright 1984-1998 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
** This file should be copied to the VxWorks directory tree, e.g:
** pss123> set src = "lnsa09:tas_src:[sinqhm]"
** pss123> if ("$USER" != "maden") set src = "lnsg@$src"
** pss123> rcp -p "${src}usrConfig.c" \
** $WIND_BASE/target/config/all/usrConfig.c
** pss123> rcp -p "${src}bld." $HOME/wind/SinqHM/bld
**
** The system images are:
**
** $HOME/wind/SinqHM/vxWorks_basic
** $HOME/wind/SinqHM/<instr>/vxWorks_auto
**
** Using the Tornado tools:
** =======================
** To build the system image WITHOUT the SinqHM modules:
** a) Start WindCFG with no target selected.
** b) Select the "mv1603" BSP.
** c) Select configuration "SinqHM"
** d) Start up the editor and ensure that "SINQHM_SPAWN"
** is either not defined or is defined to be 0.
** e) Select the Build option.
** f) Copy file vxWorks to $HOME/wind/SinqHM/vxWorks_basic.
**
** To build the system image WITH the SinqHM modules:
** a) Start WindCFG with no target selected.
** b) Select the "mv1603" BSP.
** c) Select configuration "SinqHM_spawn_<instr>".
** d) Start up the editor and ensure that "SINQHM_SPAWN"
** is defined to be non-zero, e.g:
** #define SINQHM_SPAWN 1
** e) Select the Build option.
** f) Copy file $HOME/wind/ppc/target/config/mv1603/vxWorks
** to $HOME/wind/SinqHM/<instr>/vxWorks_auto.
**
** Using the bld script:
** ====================
** To build system images using the bld script:
**
** a) without the SinqHM modules:
** pss123> $HOME/wind/SinqHM/bld basic
** b) with the SinqHM modules:
** pss123> $HOME/wind/SinqHM/bld <instr> all
**
** Warnings:
** The bld script will only work if SINQHM_SPAWN is NOT
** defined in $HOME/wind/1.0.1-SENS/ppc/target/config/mv1603/config.h
**
** When using the bld script, be sure that the file
** $HOME/wind/1.0.1-SENS/ppc/target/config/mv1603/configdb.h
** is set to select the correct VxWorks options. It is
** easiest to use the Tornado WindCFG tool to do this.
*/
/*
modification history
--------------------
V01F 29-Feb-2000 DM. Update for Tornado /1.0.1-SENS/ + updates to
the above comments.
V01B 4-Aug-1997 DM. Just spawn SinqHM_bootParamsConfig. This then spawns
anything else which is specified in the boot line.
V01A 3-Jun-1997 DM. Include spawning of SinqHM modules.
18u,22sep98,cth merged in tffs, http, java changes for wv2.0 fcs
18r,22apr98,hdn added comment for tffsDrv().
18t,17apr98,nps added support for rBuffShow.
18s,09mar98,sjw merge in HTTP and JAVA changes for conflict resolution
18q,19jan98,hdn changed a condition macro to include tffsDrv().
18r,18dec97,cth replaced windview, timestamp initialization with windviewConfig
18q,13nov97,cth changed WV evtInstInit to wvLibInit2; removed connRtnSet,
evtTaskInit; added include wvLib.h, rBuffLib.h
18p,23sep97,yp added support for TFFS.
18p,18aug97,nps changed WV buffer initialization with the rBuff API.
18o,26feb97,dat added INCLUDE_USER_APPL and USER_APPL_INIT, spr 8071.
18n,13dec96,elp changed syncLibInit() into symSyncLibInit().
18m,18nov96,dds SPR 2529: return status for sysScsiInit is now checked.
18l,06nov96,ms removed 17n hack to usrClock.
18k,01nov96,hdn added support for PCMCIA.
18j,21oct96,hdn changed paramerters for new LPT driver.
18i,04oct96,elp added INCLUDE_SYM_TBL_SYNC (SPR# 6775).
18h,11jul96,tam changed copyright year from 1995 to 1996.
18l,19jul96,hdn added support for ATA driver.
18k,25jun96,jmb Eliminated alternative WDB macro names (SPR #5707).
18j,25jun96,dbt Initialized _func_selWakeupListInit before tyLib (SPR #3314).
18i,21jun96,jmb update copyright. SPR #6364
18h,21jun96,jmb long modhist -- deleted entries prior to 1994. SPR #6528
18g,12mar96,tam removed all #if (CPU == PPC403).
18p,06jun96,ism bumped copyright to 1996.
18o,26jan96,ism cleaned up vxsim/solaris version
18f,02oct95,kvk added sysHwInit2() for PPC603.
18e,27sep95,tpr removed #if (CPU_FAMILY != PPC) staff.
18n,07nov95,srh fixed C++ support comments.
18m,29oct95,dat fixed warnings about printf arguments
18l,11oct95,jdi doc: changed .pG to .tG.
18k,10oct95,dat new BSP revision id. Added WDB Banner printing
18j,15jun95,ms updated for new serial drivers.
18i,09jun95,ms cleaned up console initialization
18h,30may95,p_m added initialization of formatted I/O library.
replaced spyStop() by spyLibInit().
18g,22may95,p_m no longer initialize object format specific libraries if
loader is not included.
18f,22may95,myz modified new serial device initialization for x86 support
18e,22may95,ms added some WDB agent support
18e,30oct95,ism updated for SIMSPARCSOLARIS
18d,28mar95,kkk added scalability support, changed edata and end to arrays
(SPR #3917), changed baud rate to be a macro in configAll.h
18g,25may95,yao changed to bzero bss segment for PPC.
18f,04apr95,caf added PPC cache support.
18e,03mar95,yao added shsHwInit2 () for PPC403.
18d,24feb95,caf added PPC support.
18c,20nov94,kdl added hashLibInit() when using dosFs.
18b,09nov94,jds additions for scsi backward compatability ; scsi[12]IfInit()
18a,04nov94,kdl merge cleanup.
17l,02aug94,tpr added cacheEnable (BRANCH_CACHE) for the MC68060.
17m,15oct94,hdn added LPT driver.
17o,20jul94,ms changed INCLUDE_AOUT_HPPA to INCLUDE_SOM_COFF
17n,02may94,ms added VxSim HP hack to usrClock().
17q,15mar94,smb renamed tEvtTask parameters.
17p,15feb94,smb defined WV_MODE, EVTBUFFER_ADDRESS for wvInstInit().
17o,12jan94,kdl modified posix initialization; added queued signal init.
*/
/*
DESCRIPTION
This library is the WRS-supplied configuration module for VxWorks. It
contains the root task, the primary system initialization routine, the
network initialization routine, and the clock interrupt routine.
The include file config.h includes a number of system-dependent parameters used
in this file.
In an effort to simplify the presentation of the configuration of vxWorks,
this file has been split into smaller files. These additional configuration
source files are located in ../../src/config/usr[xxx].c and are #included into
this file below. This file contains the bulk of the code a customer is
likely to customize.
The module usrDepend.c contains checks that guard against unsupported
configurations suchas INCLUDE_NFS without INCLUDE_RPC. The module
usrKernel.c contains the core initialization of the kernel which is rarely
customized, but provided for information. The module usrNetwork.c now
contains all network initialization code. Finally, the module usrExtra.c
contains the conditional inclusion of the optional packages selected in
configAll.h.
The source code necessary for the configuration selected is entirely
included in this file during compilation as part of a standard build in
the board support package. No other make is necessary.
INCLUDE FILES:
config.h
SEE ALSO:
.tG "Getting Started, Cross-Development"
*/
#include "vxWorks.h" /* always first */
#include "config.h" /* board support configuration header */
#include "usrConfig.h" /* general configuration header */
#include "usrDepend.c" /* include dependency rules */
#include "usrKernel.c" /* kernel configuration */
#include "usrExtra.c" /* conditionally included packages */
#ifdef INCLUDE_HTTP
#include "http/httpLib.h" /* Wind Web Server interfaces */
#endif
/* global variables */
int consoleFd; /* fd of initial console device */
char consoleName[20]; /* console device name, eg. "/tyCo/0" */
SYMTAB_ID statSymTbl; /* system error status symbol table id*/
SYMTAB_ID standAloneSymTbl; /* STANDALONE version symbol table id */
SYMTAB_ID sysSymTbl; /* system symbol table id */
BOOT_PARAMS sysBootParams; /* parameters from boot line */
int sysStartType; /* type of boot (WARM, COLD, etc) */
/*******************************************************************************
*
* usrInit - user-defined system initialization routine
*
* This is the first C code executed after the system boots. This routine is
* called by the assembly language start-up routine sysInit() which is in the
* sysALib module of the target-specific directory. It is called with
* interrupts locked out. The kernel is not multitasking at this point.
*
* This routine starts by clearing BSS; thus all variables are initialized to 0,
* as per the C specification. It then initializes the hardware by calling
* sysHwInit(), sets up the interrupt/exception vectors, and starts kernel
* multitasking with usrRoot() as the root task.
*
* RETURNS: N/A
*
* SEE ALSO: kernelLib
*
* ARGSUSED0
*/
void usrInit
(
int startType
)
{
#if (CPU_FAMILY == SPARC)
excWindowInit (); /* SPARC window management */
#endif
/* configure data and instruction cache if available and leave disabled */
#ifdef INCLUDE_CACHE_SUPPORT
cacheLibInit (USER_I_CACHE_MODE, USER_D_CACHE_MODE);
#endif /* INCLUDE_CACHE_SUPPORT */
#if CPU_FAMILY!=SIMSPARCSUNOS && CPU_FAMILY!=SIMHPPA && CPU_FAMILY!=SIMSPARCSOLARIS
/* don't assume bss variables are zero before this call */
bzero (edata, end - edata); /* zero out bss variables */
#endif /* CPU_FAMILY!=SIMSPARCSUNOS && CPU_FAMILY!=SIMHPPA && CPU_FAMILY!=SIMSPARCSOLARIS */
sysStartType = startType; /* save type of system start */
intVecBaseSet ((FUNCPTR *) VEC_BASE_ADRS); /* set vector base table */
#if (CPU_FAMILY == AM29XXX)
excSpillFillInit (); /* am29k stack cache managemt */
#endif
#ifdef INCLUDE_EXC_HANDLING
excVecInit (); /* install exception vectors */
excShowInit (); /* install sysExcMsg handlers */
#endif /* INCLUDE_EXC_HANDLING */
sysHwInit (); /* initialize system hardware */
usrKernelInit (); /* configure the Wind kernel */
#ifdef INCLUDE_CACHE_SUPPORT
#ifdef USER_I_CACHE_ENABLE
cacheEnable (INSTRUCTION_CACHE); /* enable instruction cache */
#endif /* USER_I_CACHE_ENABLE */
#ifdef USER_D_CACHE_ENABLE
cacheEnable (DATA_CACHE); /* enable data cache */
#endif /* USER_D_CACHE_ENABLE */
#if (CPU == MC68060)
#ifdef USER_B_CACHE_ENABLE
cacheEnable (BRANCH_CACHE); /* enable branch cache */
#endif /* USER_B_CACHE_ENABLE */
#endif /* (CPU == MC68060) */
#endif /* INCLUDE_CACHE_SUPPORT */
/* start the kernel specifying usrRoot as the root task */
kernelInit ((FUNCPTR) usrRoot, ROOT_STACK_SIZE,
#ifdef INCLUDE_WDB
(char *) FREE_RAM_ADRS + WDB_POOL_SIZE,
#else
(char *) FREE_RAM_ADRS,
#endif
sysMemTop (), ISR_STACK_SIZE, INT_LOCK_LEVEL);
}
/*******************************************************************************
*
* usrRoot - the root task
*
* This is the first task to run under the multitasking kernel. It performs
* all final initialization and then starts other tasks.
*
* It initializes the I/O system, installs drivers, creates devices, and sets
* up the network, etc., as necessary for a particular configuration. It
* may also create and load the system symbol table, if one is to be included.
* It may then load and spawn additional tasks as needed. In the default
* configuration, it simply initializes the VxWorks shell.
*
* RETURNS: N/A
*/
void usrRoot
(
char * pMemPoolStart, /* start of system memory partition */
unsigned memPoolSize /* initial size of mem pool */
)
{
char tyName [20];
int ix;
#if (SINQHM_SPAWN != 0)
/*-----------------------------------------------------------------
** Define local variables and templates for SinqHM modules
*/
void SinqHM_bootParamsConfig (void);
/*-----------------------------------------------------------------*/
#endif /* (SINQHM_SPAWN != 0) */
/* Initialize the memory pool before initializing any other package.
* The memory associated with the root task will be reclaimed at the
* completion of its activities.
*/
#ifdef INCLUDE_MEM_MGR_FULL
memInit (pMemPoolStart, memPoolSize); /* initialize memory pool */
#else
memPartLibInit (pMemPoolStart, memPoolSize);/* initialize memory pool */
#endif /* INCLUDE_MEM_MGR_FULL */
#ifdef INCLUDE_SHOW_ROUTINES
memShowInit (); /* initialize memShow routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#if defined(INCLUDE_MMU_BASIC) || defined(INCLUDE_MMU_FULL)
usrMmuInit (); /* initialize the mmu */
#endif /* defined(INCLUDE_MMU_BASIC) || defined(INCLUDE_MMU_FULL) */
/* set up system timer */
sysClkConnect ((FUNCPTR) usrClock, 0); /* connect clock ISR */
sysClkRateSet (60); /* set system clock rate */
sysClkEnable (); /* start it */
/*
* select sould be initialized after NFS and RPC for proper delete
* hook order but _func_selWakeupListInit should be set
* before tyLib module (SPR #3314).
*/
#ifdef INCLUDE_SELECT
_func_selWakeupListInit = (FUNCPTR) selWakeupListInit;
#endif /* INCLUDE_SELECT */
/* initialize I/O system */
#ifdef INCLUDE_IO_SYSTEM
iosInit (NUM_DRIVERS, NUM_FILES, "/null");
consoleFd = NONE; /* assume no console device */
#ifdef INCLUDE_TYCODRV_5_2
#ifdef INCLUDE_TTY_DEV
if (NUM_TTY > 0)
{
tyCoDrv (); /* install console driver */
for (ix = 0; ix < NUM_TTY; ix++) /* create serial devices */
{
sprintf (tyName, "%s%d", "/tyCo/", ix);
(void) tyCoDevCreate (tyName, ix, 512, 512);
if (ix == CONSOLE_TTY)
strcpy (consoleName, tyName); /* store console name */
}
consoleFd = open (consoleName, O_RDWR, 0);
/* set baud rate */
(void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
(void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
}
#endif /* INCLUDE_TTY_DEV */
#else /* !INCLUDE_TYCODRV_5_2 */
#ifdef INCLUDE_TTY_DEV
if (NUM_TTY > 0)
{
ttyDrv(); /* install console driver */
for (ix = 0; ix < NUM_TTY; ix++) /* create serial devices */
{
#if (defined(INCLUDE_WDB) && (WDB_COMM_TYPE == WDB_COMM_SERIAL))
if (ix == WDB_TTY_CHANNEL) /* don't use WDBs channel */
continue;
#endif
sprintf (tyName, "%s%d", "/tyCo/", ix);
(void) ttyDevCreate (tyName, sysSerialChanGet(ix), 512, 512);
if (ix == CONSOLE_TTY) /* init the tty console */
{
strcpy (consoleName, tyName);
consoleFd = open (consoleName, O_RDWR, 0);
(void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
(void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
}
}
}
#endif /* INCLUDE_TTY_DEV */
#ifdef INCLUDE_PC_CONSOLE
pcConDrv ();
for (ix = 0; ix < N_VIRTUAL_CONSOLES; ix++)
{
sprintf (tyName, "%s%d", "/pcConsole/", ix);
(void) pcConDevCreate (tyName,ix, 512, 512);
if (ix == PC_CONSOLE) /* init the console device */
{
strcpy (consoleName, tyName);
consoleFd = open (consoleName, O_RDWR, 0);
(void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
(void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
}
}
#endif /* INCLUDE_PC_CONSOLE */
#endif /* !INCLUDE_TYCODRV_5_2 */
ioGlobalStdSet (STD_IN, consoleFd);
ioGlobalStdSet (STD_OUT, consoleFd);
ioGlobalStdSet (STD_ERR, consoleFd);
#endif /* INCLUDE_IO_SYSTEM */
/* initialize symbol table facilities */
#ifdef INCLUDE_SYM_TBL
hashLibInit (); /* initialize hash table package */
symLibInit (); /* initialize symbol table package */
#ifdef INCLUDE_SHOW_ROUTINES
symShowInit (); /* initialize symbol table show */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_SYM_TBL */
/* initialize exception handling */
#if defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK)
excInit (); /* initialize exception handling */
#endif /* defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK) */
#ifdef INCLUDE_LOGGING
logInit (consoleFd, MAX_LOG_MSGS); /* initialize logging */
#endif /* INCLUDE_LOGGING */
#ifdef INCLUDE_SIGNALS
sigInit (); /* initialize signals */
#endif /* INCLUDE_SIGNALS */
/* initialize debugging */
#ifdef INCLUDE_DEBUG
dbgInit (); /* initialize debugging */
#endif /* INCLUDE_DEBUG */
/* initialize pipe driver */
#ifdef INCLUDE_PIPES
pipeDrv (); /* install pipe driver */
#endif /* INCLUDE_PIPES */
/* initialize standard I/O package */
#ifdef INCLUDE_STDIO
stdioInit (); /* initialize standard I/O library */
#ifdef INCLUDE_SHOW_ROUTINES
stdioShowInit ();
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_STDIO */
/* initialize POSIX queued signals */
#if defined(INCLUDE_POSIX_SIGNALS) && defined(INCLUDE_SIGNALS)
sigqueueInit (NUM_SIGNAL_QUEUES); /* initialize queued signals */
#endif
/* initialize POSIX semaphores */
#ifdef INCLUDE_POSIX_SEM
semPxLibInit ();
#ifdef INCLUDE_SHOW_ROUTINES
semPxShowInit ();
#endif /* INCLUDE_SHOW_POUTINES */
#endif /* INCLUDE_POSIX_SEM */
/* initialize POSIX message queues */
#ifdef INCLUDE_POSIX_MQ
mqPxLibInit (MQ_HASH_SIZE);
#ifdef INCLUDE_SHOW_ROUTINES
mqPxShowInit ();
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_POSIX_MQ */
/* initialize POSIX async I/O support */
#ifdef INCLUDE_POSIX_AIO
aioPxLibInit (MAX_LIO_CALLS);
#ifdef INCLUDE_POSIX_AIO_SYSDRV
aioSysInit (MAX_AIO_SYS_TASKS, AIO_TASK_PRIORITY, AIO_TASK_STACK_SIZE);
#endif /* INCLUDE_POSIX_AIO_SYSDRV */
#endif /* INCLUDE_POSIX_AIO */
/* initialize filesystems and disk drivers */
#ifdef INCLUDE_DOSFS
hashLibInit (); /* initialize hash table package */
dosFsInit (NUM_DOSFS_FILES); /* init dosFs filesystem */
#endif /* INCLUDE_DOSFS */
#ifdef INCLUDE_RAWFS
rawFsInit (NUM_RAWFS_FILES); /* init rawFs filesystem */
#endif /* INCLUDE_RAWFS */
#ifdef INCLUDE_RT11FS
rt11FsInit (NUM_RT11FS_FILES); /* init rt11Fs filesystem */
#endif /* INCLUDE_RT11FS */
#ifdef INCLUDE_RAMDRV
ramDrv (); /* initialize ram disk driver */
#endif /* INCLUDE_RAMDRV */
#ifdef INCLUDE_SCSI
/*
* initialize either the SCSI1 or SCSI2 interface; initialize SCSI2 when
* the SCSI2 interface is available.
*/
#ifndef INCLUDE_SCSI2
scsi1IfInit ();
#else
scsi2IfInit ();
#endif
/* initialize SCSI controller */
if (sysScsiInit () == OK)
{
usrScsiConfig (); /* configure SCSI peripherals */
}
else
{
printf ("sysScsiInit() Failed, SCSI system not initialized\n");
}
#endif /* INCLUDE_SCSI */
#ifdef INCLUDE_FD
fdDrv (FD_INT_VEC, FD_INT_LVL); /* initialize floppy disk driver */
#endif /* INCLUDE_FD */
#ifdef INCLUDE_IDE
ideDrv (IDE_INT_VEC, IDE_INT_LVL, IDE_CONFIG); /* init IDE disk driver */
#endif /* INCLUDE_IDE */
#ifdef INCLUDE_ATA
{ /* initialize hard disk driver */
IMPORT ATA_RESOURCE ataResources[];
ATA_RESOURCE *pAtaResource;
for (ix = 0; ix < ATA_MAX_CTRLS; ix++)
{
pAtaResource = &ataResources[ix];
if (pAtaResource->ctrlType == IDE_LOCAL)
ataDrv (ix, pAtaResource->drives, pAtaResource->intVector,
pAtaResource->intLevel, pAtaResource->configType,
pAtaResource->semTimeout, pAtaResource->wdgTimeout);
}
}
#ifdef INCLUDE_SHOW_ROUTINES
ataShowInit (); /* install ATA/IDE show routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_ATA */
#ifdef INCLUDE_LPT
{
IMPORT LPT_RESOURCE lptResources[];
lptDrv (LPT_CHANNELS, &lptResources[0]); /* init LPT parallel driver */
}
#endif /* INCLUDE_LPT */
#ifdef INCLUDE_PCMCIA
#ifdef INCLUDE_SHOW_ROUTINES
pcmciaShowInit (); /* install PCMCIA show routines */
#endif /* INCLUDE_SHOW_ROUTINES */
pcmciaInit (); /* init PCMCIA Lib */
#endif /* INCLUDE_PCMCIA */
#ifdef INCLUDE_TFFS
tffsDrv (); /* it should be after pcmciaInit() */
#endif /* INCLUDE_TFFS */
#ifdef INCLUDE_FORMATTED_IO
fioLibInit (); /* initialize formatted I/O */
#endif /* INCLUDE_FORMATTED_IO */
/* initialize floating point facilities */
#ifdef INCLUDE_FLOATING_POINT
floatInit (); /* initialize floating point I/O */
#endif /* INCLUDE_FLOATING_POINT */
/* install software floating point emulation (if applicable) */
#ifdef INCLUDE_SW_FP
mathSoftInit (); /* use software emulation for fp math */
#endif /* INCLUDE_SW_FP */
/* install hardware floating point support (if applicable) */
#ifdef INCLUDE_HW_FP
mathHardInit (); /* do fppInit() & install hw fp math */
#ifdef INCLUDE_SHOW_ROUTINES
fppShowInit (); /* install hardware fp show routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_HW_FP */
/* initialize performance monitoring tools */
#ifdef INCLUDE_SPY
spyLibInit (); /* install task cpu utilization tool */
#endif /* INCLUDE_SPY */
#ifdef INCLUDE_TIMEX
timexInit (); /* install function timing tool */
#endif /* INCLUDE_TIMEX */
#ifdef INCLUDE_ENV_VARS
envLibInit (ENV_VAR_USE_HOOKS); /* initialize environment variable */
#endif /* INCLUDE_ENV_VARS */
/* initialize object module loader */
#ifdef INCLUDE_LOADER
moduleLibInit (); /* initialize module manager */
#if defined(INCLUDE_AOUT)
loadAoutInit (); /* use a.out format */
#else /* coff or ecoff */
#if defined(INCLUDE_ECOFF)
loadEcoffInit (); /* use ecoff format */
#else /* ecoff */
#if defined(INCLUDE_COFF)
loadCoffInit (); /* use coff format */
#else /* coff */
#if defined(INCLUDE_ELF)
loadElfInit (); /* use elf format */
#else
#if defined(INCLUDE_SOM_COFF)
loadSomCoffInit ();
#endif
#endif
#endif
#endif
#endif
#endif /* INCLUDE_LOADER */
/* initialize wtx client to synchronize host and target symbol tables */
#ifdef INCLUDE_SYM_TBL_SYNC
symSyncLibInit ();
#endif /* INCLUDE_SYM_TBL_SYNC */
/* initialize network */
#ifdef INCLUDE_NET_INIT
usrBootLineInit (sysStartType); /* crack the bootline */
usrNetInit (BOOT_LINE_ADRS); /* initialize network support */
#endif /* INCLUDE_NET_INIT */
#ifdef INCLUDE_PASSFS
{
extern STATUS passFsInit ();
extern void *passFsDevInit ();
char passName [256];
if (passFsInit (1) == OK)
{
extern char vxsim_hostname[];
extern char vxsim_cwd[];
sprintf (passName, "%s:", vxsim_hostname);
if (passFsDevInit (passName) == NULL)
{
printf ("passFsDevInit failed for <%s>\n", passName);
}
else
{
sprintf (passName, "%s:%s", vxsim_hostname, vxsim_cwd);
ioDefPathSet (passName);
}
}
else
printf ("passFsInit failed\n");
}
#endif /* INCLUDE_PASSFS */
#ifdef INCLUDE_DOS_DISK
{
char unixName [80];
extern void unixDrv ();
extern void unixDiskInit ();
extern char *u_progname; /* home of executable */
char *pLastSlash;
unixDrv ();
pLastSlash = strrchr (u_progname, '/');
pLastSlash = (pLastSlash == NULL) ? u_progname : (pLastSlash + 1);
sprintf (unixName, "/tmp/%s%d.dos", pLastSlash, sysProcNumGet());
unixDiskInit (unixName, "A:", 0);
}
#endif /* INCLUDE_DOS_DISK */
/* initialize shared memory objects */
#ifdef INCLUDE_SM_OBJ /* unbundled shared memory objects */
usrSmObjInit (BOOT_LINE_ADRS);
#endif /* INCLUDE_SM_OBJ */
/* write protect text segment & vector table only after bpattach () */
#ifdef INCLUDE_MMU_FULL /* unbundled mmu product */
#ifdef INCLUDE_PROTECT_TEXT
if (vmTextProtect () != OK)
printf ("\nError protecting text segment. errno = %x\n", errno);
#endif /* INCLUDE_PROTECT_TEXT */
#ifdef INCLUDE_PROTECT_VEC_TABLE
if (intVecTableWriteProtect () != OK)
printf ("\nError protecting vector table. errno = %x\n", errno);
#endif /* INCLUDE_PROTECT_VEC_TABLE */
#endif /* INCLUDE_MMU_FULL */
/* initialize select only after NFS and RPC for proper delete hook order */
#ifdef INCLUDE_SELECT
selectInit ();
#endif /* INCLUDE_SELECT */
/* create system and status symbol tables */
#ifdef INCLUDE_STANDALONE_SYM_TBL
sysSymTbl = symTblCreate (SYM_TBL_HASH_SIZE_LOG2, TRUE, memSysPartId);
printf ("\nAdding %ld symbols for standalone.\n", standTblSize);
for (ix = 0; ix < standTblSize; ix++) /* fill in from built in table*/
symTblAdd (sysSymTbl, &(standTbl[ix]));
#endif /* INCLUDE_STANDALONE_SYM_TBL */
#ifdef INCLUDE_NET_SYM_TBL
sysSymTbl = symTblCreate (SYM_TBL_HASH_SIZE_LOG2, TRUE, memSysPartId);
netLoadSymTbl (); /* fill in table from host */
#endif /* INCLUDE_NET_SYM_TBL */
#ifdef INCLUDE_STAT_SYM_TBL
statSymTbl = symTblCreate (STAT_TBL_HASH_SIZE_LOG2, FALSE, memSysPartId);
for (ix = 0; ix < statTblSize; ix ++) /* fill in from built in table*/
symTblAdd (statSymTbl, &(statTbl [ix]));
#endif /* INCLUDE_STAT_SYM_TBL */
/* initialize C++ support library */
#if defined (INCLUDE_CPLUS) && defined (INCLUDE_CPLUS_MIN)
#error Define only one of INCLUDE_CPLUS or INCLUDE_CPLUS_MIN, not both
#endif
#ifdef INCLUDE_CPLUS /* all standard C++ runtime support */
cplusLibInit ();
#endif
#ifdef INCLUDE_CPLUS_MIN /* minimal C++ runtime support */
cplusLibMinInit ();
#endif
/* initialize Wind Web Server */
#ifdef INCLUDE_HTTP
httpd ();
#endif /* INCLUDE_HTTP */
/* initialize windview support */
#ifdef INCLUDE_RBUFF /* install rBuff support */
rBuffLibInit();
#ifdef INCLUDE_SHOW_ROUTINES
rBuffShowInit (); /* install rBuff show routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_RBUFF */
#ifdef INCLUDE_WINDVIEW
windviewConfig ();
#endif /* INCLUDE_WINDVIEW */
/* initialize the WDB debug agent */
#ifdef INCLUDE_WDB
wdbConfig();
#ifdef INCLUDE_WDB_BANNER
#ifndef INCLUDE_SHELL
/* short banner, like the bootPrintLogo banner */
printf ("\n\n");
printf ("%17s%s", "","VxWorks\n\n");
printf ("Copyright 1984-1996 Wind River Systems, Inc.\n\n");
printf (" CPU: %s\n", sysModel ());
printf (" VxWorks: " VXWORKS_VERSION "\n");
printf (" BSP version: " BSP_VERSION BSP_REV "\n");
printf (" Creation date: %s %s\n", __DATE__, __TIME__);
printf (" WDB: %s.\n\n",
((wdbRunsExternal () || wdbRunsTasking ()) ?
"Ready" : "Agent configuration failed") );
#endif /*INCLUDE_SHELL*/
#endif /*INCLUDE_WDB_BANNER*/
#endif /* INCLUDE_WDB */
/* initialize interactive shell */
#ifdef INCLUDE_SHELL
#ifdef INCLUDE_SECURITY /* include shell security */
if ((sysFlags & SYSFLG_NO_SECURITY) == 0)
{
loginInit (); /* initialize login table */
shellLoginInstall (loginPrompt, NULL); /* install security program */
/* add additional users here as required */
loginUserAdd (LOGIN_USER_NAME, LOGIN_PASSWORD);
}
#endif /* INCLUDE_SECURITY */
printLogo (); /* print out the banner page */
printf (" ");
printf ("CPU: %s. Processor #%d.\n", sysModel (), sysProcNumGet ());
printf (" ");
printf ("Memory Size: 0x%x.", (UINT)(sysMemTop () - (char *)LOCAL_MEM_LOCAL_ADRS));
printf (" BSP version " BSP_VERSION BSP_REV ".");
#if defined(INCLUDE_WDB) && defined(INCLUDE_WDB_BANNER)
printf ("\n ");
printf ("WDB: %s.",
((wdbRunsExternal () || wdbRunsTasking ()) ?
"Ready" : "Agent configuration failed") );
#endif /*INCLUDE_WDB && INCLUDE_WDB_BANNER*/
printf ("\n\n");
#ifdef INCLUDE_STARTUP_SCRIPT /* run a startup script */
if (sysBootParams.startupScript [0] != EOS)
usrStartupScript (sysBootParams.startupScript);
#endif /* INCLUDE_STARTUP_SCRIPT */
shellInit (SHELL_STACK_SIZE, TRUE); /* create the shell */
/* only include the simple demo if the shell is NOT included */
#else
#if defined(INCLUDE_DEMO) /* create demo w/o shell */
taskSpawn ("demo", 20, 0, 2000, (FUNCPTR)usrDemo, 0,0,0,0,0,0,0,0,0,0);
#endif /* mips cpp no elif */
#endif /* INCLUDE_SHELL */
#if defined(INCLUDE_JAVA)
javaConfig ();
#endif /* INCLUDE_JAVA */
#ifdef INCLUDE_USER_APPL
/* Startup the user's application */
USER_APPL_INIT; /* must be a valid C statement or block */
#endif
#if (SINQHM_SPAWN != 0)
printf ("Spawning SinqHM_bootParamsConfig ...\n");
taskSpawn ("hmConfig", 100, VX_FP_TASK, 20000,
(FUNCPTR) SinqHM_bootParamsConfig,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
/*------------------------------------------------------------------*/
#endif /* (SINQHM_SPAWN != 0) */
}
/*******************************************************************************
*
* usrClock - user-defined system clock interrupt routine
*
* This routine is called at interrupt level on each clock interrupt.
* It is installed by usrRoot() with a sysClkConnect() call.
* It calls all the other packages that need to know about clock ticks,
* including the kernel itself.
*
* If the application needs anything to happen at the system clock interrupt
* level, it can be added to this routine.
*
* RETURNS: N/A
*/
void usrClock ()
{
tickAnnounce (); /* announce system tick to kernel */
}
#ifdef INCLUDE_DEMO
/********************************************************************************
* usrDemo - example application without shell
*
* This routine is spawned as a task at the end of usrRoot(), if INCLUDE_DEMO
* is defined, and INCLUDE_SHELL is NOT defined in configAll.h or config.h.
* It is intended to indicate how a shell-less application can be linked,
* loaded, and ROMed.
*
* NOMANUAL
*/
void usrDemo (void)
{
char string [40];
printf ("VxWorks (for %s) version %s.\n", sysModel (), vxWorksVersion);
printf ("Kernel: %s.\n", kernelVersion ());
printf ("Made on %s.\n", creationDate);
FOREVER
{
printf ("\nThis is a test. Type something: ");
fioRdString (STD_IN, string, sizeof (string));
printf ("\nYou typed \"%s\".\n", string);
if (strcmp (string, "0") == 0)
memShow (0);
if (strcmp (string, "1") == 0)
memShow (1);
}
}
#endif /* INCLUDE_DEMO */

125
sinqhm/usrConfig.c_diffs Executable file
View File

@ -0,0 +1,125 @@
The following is the output generated by diff for the distribution copy
of usrConfig.c and the version used for generating the SinqHM_srv
Histogram Memory bootable image.
24-Nov-1999
Date of Distribution Version: Jul 12 1996
Date of SinqHM_srv Version: Nov 24 1999
======================================================================
6,58d5
< /*
< ** This file should be copied to the VxWorks directory tree, e.g:
< ** pss123> set src = "lnsa09:tas_src:[sinqhm]"
< ** pss123> if ("$USER" != "maden") set src = "lnsg@$src"
< ** pss123> rcp -p "${src}usrConfig.c" \
< ** $HOME/wind/ppc/target/config/all/usrConfig.c
< ** pss123> rcp -p "${src}bld." $HOME/wind/SinqHM/bld
< **
< ** The system images are:
< **
< ** $HOME/wind/SinqHM/vxWorks_basic
< ** $HOME/wind/SinqHM/<instr>/vxWorks_auto
< **
< ** Using the Tornado tools:
< ** =======================
< ** To build the system image WITHOUT the SinqHM modules:
< ** a) Start WindCFG with no target selected.
< ** b) Select the "mv1603" BSP.
< ** c) Select configuration "SinqHM"
< ** d) Start up the editor and ensure that "SINQHM_SPAWN"
< ** is either not defined or is defined to be 0.
< ** e) Select the Build option.
< ** f) Copy file vxWorks to $HOME/wind/SinqHM/vxWorks_basic.
< **
< ** To build the system image WITH the SinqHM modules:
< ** a) Start WindCFG with no target selected.
< ** b) Select the "mv1603" BSP.
< ** c) Select configuration "SinqHM_spawn_<instr>".
< ** d) Start up the editor and ensure that "SINQHM_SPAWN"
< ** is defined to be non-zero, e.g:
< ** #define SINQHM_SPAWN 1
< ** e) Select the Build option.
< ** f) Copy file $HOME/wind/ppc/target/config/mv1603/vxWorks
< ** to $HOME/wind/SinqHM/<instr>/vxWorks_auto.
< **
< ** Using the bld script:
< ** ====================
< ** To build system images using the bld script:
< **
< ** a) without the SinqHM modules:
< ** pss123> $HOME/wind/SinqHM/bld basic
< ** b) with the SinqHM modules:
< ** pss123> bld <instr> all
< **
< ** Warnings:
< ** The bld script will only work if SINQHM_SPAWN is NOT
< ** defined in $HOME/wind/ppc/target/config/mv1603/config.h
< **
< ** When using the bld script, be sure that the file
< ** $HOME/wind/ppc/target/config/mv1603/configdb.h
< ** is set to select the correct VxWorks options. It is
< ** easiest to use the Tornado WindCFG tool to do this.
< */
62,67d8
< V01E 24-Nov-1999 DM. Yet more updates to the above comments.
< V01D 18-Jun-1999 DM. More updates to the above comments.
< V01C 11-Dec-1998 DM. Just update the above comments.
< V01B 4-Aug-1997 DM. Just spawn SinqHM_bootParamsConfig. This then spawns
< anything else which is specified in the boot line.
< V01A 3-Jun-1997 DM. Include spawning of SinqHM modules.
402,411d342
< #if (SINQHM_SPAWN != 0)
< /*-----------------------------------------------------------------
< ** Define local variables and templates for SinqHM modules
< */
<
< void SinqHM_bootParamsConfig (void);
<
< /*-----------------------------------------------------------------*/
< #endif /* (SINQHM_SPAWN != 0) */
<
415a347
>
913c845
< printf (" Creation date: %s %s\n", __DATE__, __TIME__);
---
> printf (" Creation date: %s\n", __DATE__);
969,975d900
< #if (SINQHM_SPAWN != 0)
< printf ("Spawning SinqHM_bootParamsConfig ...\n");
< taskSpawn ("hmConfig", 100, VX_FP_TASK, 20000,
< (FUNCPTR) SinqHM_bootParamsConfig,
< 2400, 0, 0, 0, 0, 0, 0, 0, 0, 0);
< /*------------------------------------------------------------------*/
< #endif /* (SINQHM_SPAWN != 0) */
1025,1033c950,967
< /*
< ** int fd;
< */
< printf ("VxWorks (for %s) version %s\n", sysModel (), vxWorksVersion);
< printf ("Kernel: %s\n", kernelVersion ());
< printf ("Made on %s\n", creationDate);
< printf ("Delaying for 10 secs ...");
< taskDelay (600);
< printf (" done\n");
---
> char string [40];
>
> printf ("VxWorks (for %s) version %s.\n", sysModel (), vxWorksVersion);
> printf ("Kernel: %s.\n", kernelVersion ());
> printf ("Made on %s.\n", creationDate);
>
> FOREVER
> {
> printf ("\nThis is a test. Type something: ");
> fioRdString (STD_IN, string, sizeof (string));
> printf ("\nYou typed \"%s\".\n", string);
>
> if (strcmp (string, "0") == 0)
> memShow (0);
>
> if (strcmp (string, "1") == 0)
> memShow (1);
> }
1034a969
>
========================================================================= End

996
sinqhm/usrConfig2604.c Executable file
View File

@ -0,0 +1,996 @@
/* usrConfig.c - user-defined system configuration library */
/* Copyright 1984-1998 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
31-01-2002,Mark Koennecke, added code for starting the SinqHM stuff.
***********************************************************************
This file has to copied to
/home/pss123/aco/sinqhm/wind2/2.0.2/target/config/all/usrConfig.c
**********************************************************************
19f,10mar99,drm Changing WINDMP to VXFUSION to reflect new product name.
19e,08oct98,rlp added support for UGL and HTML.
19d,17sep98,ms call cplusDemanglerInit if INCLUDE_CPLUS and INCLUDE_LOADER
19c,17sep98,cym added code to calculate proper IP address for PCSIM.
19b,01sep98,drm added code to initialize WindMP
19a,10aug98,cym added code to inform tornado when the NT simulator is up.
18z,23apr98,yp merged in TrueFFS support
18y,22apr98,elp created group 1 module when standalone (fixed SPR# 20301).
18w,22apr98,hdn added comment for tffsDrv().
18t,17apr98,nps added support for rBuffShow.
18s,09mar98,sjw merge in HTTP and JAVA changes for conflict resolution
18r,18dec97,cth replaced windview, timestamp initialization with windviewConfig
18q,13nov97,cth changed WV evtInstInit to wvLibInit2; removed connRtnSet,
evtTaskInit; added include wvLib.h, rBuffLib.h
18p,18aug97,nps changed WV buffer initialization with the rBuff API.
18x,06mar98,ms changed copyright year from 1996 to 1998.
18v,04feb98,jpd fix unsigned/signed warning (usrRoot); updated copyright date.
18u,25feb98,jgn removed call to excShowInit(), it is called by excInit()
if needed (SPR #20625)
18t,19jan98,hdn changed a condition macro to include tffsDrv().
18p,06jan98,cym added SIMNT as processor not to clear bss.
18s,23sep97,yp added support for TFFS.
18r,13aug97,cdp add Thumb (ARM7TDMI_T) support;
'fix' unsigned/signed comparison in usrRoot.
18q,26feb97,dat added INCLUDE_USER_APPL and USER_APPL_INIT, spr 8071.
18p,05feb97,cdp remove ARM test hook (_func_armStartup).
18o,12dec96,cdp added _func_armStartup for ARM platforms.
18n,13dec96,elp changed syncLibInit() into symSyncLibInit().
18m,18nov96,dds SPR 2529: return status for sysScsiInit is now checked.
18l,06nov96,ms removed 17n hack to usrClock.
18k,01nov96,hdn added support for PCMCIA.
18j,21oct96,hdn changed paramerters for new LPT driver.
18i,04oct96,elp added INCLUDE_SYM_TBL_SYNC (SPR# 6775).
18h,11jul96,tam changed copyright year from 1995 to 1996.
18l,19jul96,hdn added support for ATA driver.
18k,25jun96,jmb Eliminated alternative WDB macro names (SPR #5707).
18j,25jun96,dbt Initialized _func_selWakeupListInit before tyLib (SPR #3314).
18i,21jun96,jmb update copyright. SPR #6364
18h,21jun96,jmb long modhist -- deleted entries prior to 1994. SPR #6528
18g,12mar96,tam removed all #if (CPU == PPC403).
18p,06jun96,ism bumped copyright to 1996.
18o,26jan96,ism cleaned up vxsim/solaris version
18f,02oct95,kvk added sysHwInit2() for PPC603.
18e,27sep95,tpr removed #if (CPU_FAMILY != PPC) staff.
18n,07nov95,srh fixed C++ support comments.
18m,29oct95,dat fixed warnings about printf arguments
18l,11oct95,jdi doc: changed .pG to .tG.
18k,10oct95,dat new BSP revision id. Added WDB Banner printing
18j,15jun95,ms updated for new serial drivers.
18i,09jun95,ms cleaned up console initialization
18h,30may95,p_m added initialization of formatted I/O library.
replaced spyStop() by spyLibInit().
18g,22may95,p_m no longer initialize object format specific libraries if
loader is not included.
18f,22may95,myz modified new serial device initialization for x86 support
18e,22may95,ms added some WDB agent support
18e,30oct95,ism updated for SIMSPARCSOLARIS
18d,28mar95,kkk added scalability support, changed edata and end to arrays
(SPR #3917), changed baud rate to be a macro in configAll.h
18g,25may95,yao changed to bzero bss segment for PPC.
18f,04apr95,caf added PPC cache support.
18e,03mar95,yao added shsHwInit2 () for PPC403.
18d,24feb95,caf added PPC support.
18c,20nov94,kdl added hashLibInit() when using dosFs.
18b,09nov94,jds additions for scsi backward compatability ; scsi[12]IfInit()
18a,04nov94,kdl merge cleanup.
17l,02aug94,tpr added cacheEnable (BRANCH_CACHE) for the MC68060.
17m,15oct94,hdn added LPT driver.
17o,20jul94,ms changed INCLUDE_AOUT_HPPA to INCLUDE_SOM_COFF
17n,02may94,ms added VxSim HP hack to usrClock().
17q,15mar94,smb renamed tEvtTask parameters.
17p,15feb94,smb defined WV_MODE, EVTBUFFER_ADDRESS for wvInstInit().
17o,12jan94,kdl modified posix initialization; added queued signal init.
*/
/*
DESCRIPTION
This library is the WRS-supplied configuration module for VxWorks. It
contains the root task, the primary system initialization routine, the
network initialization routine, and the clock interrupt routine.
The include file config.h includes a number of system-dependent parameters used
in this file.
In an effort to simplify the presentation of the configuration of vxWorks,
this file has been split into smaller files. These additional configuration
source files are located in ../../src/config/usr[xxx].c and are #included into
this file below. This file contains the bulk of the code a customer is
likely to customize.
The module usrDepend.c contains checks that guard against unsupported
configurations suchas INCLUDE_NFS without INCLUDE_RPC. The module
usrKernel.c contains the core initialization of the kernel which is rarely
customized, but provided for information. The module usrNetwork.c now
contains all network initialization code. Finally, the module usrExtra.c
contains the conditional inclusion of the optional packages selected in
configAll.h.
The source code necessary for the configuration selected is entirely
included in this file during compilation as part of a standard build in
the board support package. No other make is necessary.
INCLUDE FILES:
config.h
SEE ALSO:
.tG "Getting Started, Cross-Development"
*/
#include "vxWorks.h" /* always first */
#include "config.h" /* board support configuration header */
#include "usrConfig.h" /* general configuration header */
#include "usrDepend.c" /* include dependency rules */
#include "usrKernel.c" /* kernel configuration */
#include "usrExtra.c" /* conditionally included packages */
#if CPU==SIMNT
extern int simUpMutex;
extern int win_ReleaseMutex(int hMutex);
#endif
#ifdef INCLUDE_HTTP
#include "http/httpLib.h" /* Wind Web Server interfaces */
#endif
/* global variables */
int consoleFd; /* fd of initial console device */
char consoleName[20]; /* console device name, eg. "/tyCo/0" */
SYMTAB_ID statSymTbl; /* system error status symbol table id*/
SYMTAB_ID standAloneSymTbl; /* STANDALONE version symbol table id */
SYMTAB_ID sysSymTbl; /* system symbol table id */
BOOT_PARAMS sysBootParams; /* parameters from boot line */
int sysStartType; /* type of boot (WARM, COLD, etc) */
/*******************************************************************************
*
* usrInit - user-defined system initialization routine
*
* This is the first C code executed after the system boots. This routine is
* called by the assembly language start-up routine sysInit() which is in the
* sysALib module of the target-specific directory. It is called with
* interrupts locked out. The kernel is not multitasking at this point.
*
* This routine starts by clearing BSS; thus all variables are initialized to 0,
* as per the C specification. It then initializes the hardware by calling
* sysHwInit(), sets up the interrupt/exception vectors, and starts kernel
* multitasking with usrRoot() as the root task.
*
* RETURNS: N/A
*
* SEE ALSO: kernelLib
*
* ARGSUSED0
*/
void usrInit
(
int startType
)
{
#if (CPU_FAMILY == SPARC)
excWindowInit (); /* SPARC window management */
#endif
/* configure data and instruction cache if available and leave disabled */
#ifdef INCLUDE_CACHE_SUPPORT
cacheLibInit (USER_I_CACHE_MODE, USER_D_CACHE_MODE);
#endif /* INCLUDE_CACHE_SUPPORT */
#if CPU_FAMILY!=SIMNT && CPU_FAMILY!=SIMSPARCSUNOS && CPU_FAMILY!=SIMHPPA && CPU_FAMILY!=SIMSPARCSOLARIS
/* don't assume bss variables are zero before this call */
bzero (edata, end - edata); /* zero out bss variables */
#endif /* CPU_FAMILY!=SIMNT && CPU_FAMILY!=SIMSPARCSUNOS && CPU_FAMILY!=SIMHPPA && CPU_FAMILY!=SIMSPARCSOLARIS */
sysStartType = startType; /* save type of system start */
intVecBaseSet ((FUNCPTR *) VEC_BASE_ADRS); /* set vector base table */
#if (CPU_FAMILY == AM29XXX)
excSpillFillInit (); /* am29k stack cache managemt */
#endif
#ifdef INCLUDE_EXC_HANDLING
excVecInit (); /* install exception vectors */
#endif /* INCLUDE_EXC_HANDLING */
sysHwInit (); /* initialize system hardware */
usrKernelInit (); /* configure the Wind kernel */
#ifdef INCLUDE_CACHE_SUPPORT
#ifdef USER_I_CACHE_ENABLE
cacheEnable (INSTRUCTION_CACHE); /* enable instruction cache */
#endif /* USER_I_CACHE_ENABLE */
#ifdef USER_D_CACHE_ENABLE
cacheEnable (DATA_CACHE); /* enable data cache */
#endif /* USER_D_CACHE_ENABLE */
#if (CPU == MC68060)
#ifdef USER_B_CACHE_ENABLE
cacheEnable (BRANCH_CACHE); /* enable branch cache */
#endif /* USER_B_CACHE_ENABLE */
#endif /* (CPU == MC68060) */
#endif /* INCLUDE_CACHE_SUPPORT */
/* start the kernel specifying usrRoot as the root task */
kernelInit ((FUNCPTR) usrRoot, ROOT_STACK_SIZE,
#ifdef INCLUDE_WDB
(char *) FREE_RAM_ADRS + WDB_POOL_SIZE,
#else
(char *) FREE_RAM_ADRS,
#endif
sysMemTop (), ISR_STACK_SIZE, INT_LOCK_LEVEL);
}
/*******************************************************************************
*
* usrRoot - the root task
*
* This is the first task to run under the multitasking kernel. It performs
* all final initialization and then starts other tasks.
*
* It initializes the I/O system, installs drivers, creates devices, and sets
* up the network, etc., as necessary for a particular configuration. It
* may also create and load the system symbol table, if one is to be included.
* It may then load and spawn additional tasks as needed. In the default
* configuration, it simply initializes the VxWorks shell.
*
* RETURNS: N/A
*/
void usrRoot
(
char * pMemPoolStart, /* start of system memory partition */
unsigned memPoolSize /* initial size of mem pool */
)
{
char tyName [20];
int ix;
#if (SINQHM_SPAWN != 0)
/*-----------------------------------------------------------------
** Define local variables and templates for SinqHM modules
*/
void SinqHM_bootParamsConfig (void);
/*-----------------------------------------------------------------*/
#endif /* (SINQHM_SPAWN != 0) */
/* Initialize the memory pool before initializing any other package.
* The memory associated with the root task will be reclaimed at the
* completion of its activities.
*/
#ifdef INCLUDE_MEM_MGR_FULL
memInit (pMemPoolStart, memPoolSize); /* initialize memory pool */
#else
memPartLibInit (pMemPoolStart, memPoolSize);/* initialize memory pool */
#endif /* INCLUDE_MEM_MGR_FULL */
#ifdef INCLUDE_SHOW_ROUTINES
memShowInit (); /* initialize memShow routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#if defined(INCLUDE_MMU_BASIC) || defined(INCLUDE_MMU_FULL)
usrMmuInit (); /* initialize the mmu */
#endif /* defined(INCLUDE_MMU_BASIC) || defined(INCLUDE_MMU_FULL) */
/* set up system timer */
sysClkConnect ((FUNCPTR) usrClock, 0); /* connect clock ISR */
sysClkRateSet (60); /* set system clock rate */
sysClkEnable (); /* start it */
/*
* select sould be initialized after NFS and RPC for proper delete
* hook order but _func_selWakeupListInit should be set
* before tyLib module (SPR #3314).
*/
#ifdef INCLUDE_SELECT
_func_selWakeupListInit = (FUNCPTR) selWakeupListInit;
#endif /* INCLUDE_SELECT */
/* initialize I/O system */
#ifdef INCLUDE_IO_SYSTEM
iosInit (NUM_DRIVERS, NUM_FILES, "/null");
consoleFd = NONE; /* assume no console device */
#ifdef INCLUDE_TYCODRV_5_2
#ifdef INCLUDE_TTY_DEV
if (NUM_TTY > 0)
{
tyCoDrv (); /* install console driver */
for (ix = 0; ix < NUM_TTY; ix++) /* create serial devices */
{
sprintf (tyName, "%s%d", "/tyCo/", ix);
(void) tyCoDevCreate (tyName, ix, 512, 512);
if (ix == CONSOLE_TTY)
strcpy (consoleName, tyName); /* store console name */
}
consoleFd = open (consoleName, O_RDWR, 0);
/* set baud rate */
(void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
(void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
}
#endif /* INCLUDE_TTY_DEV */
#else /* !INCLUDE_TYCODRV_5_2 */
#ifdef INCLUDE_TTY_DEV
if (NUM_TTY > 0)
{
ttyDrv(); /* install console driver */
for (ix = 0; ix < NUM_TTY; ix++) /* create serial devices */
{
#if (defined(INCLUDE_WDB) && (WDB_COMM_TYPE == WDB_COMM_SERIAL))
if (ix == WDB_TTY_CHANNEL) /* don't use WDBs channel */
continue;
#endif
sprintf (tyName, "%s%d", "/tyCo/", ix);
(void) ttyDevCreate (tyName, sysSerialChanGet(ix), 512, 512);
if (ix == CONSOLE_TTY) /* init the tty console */
{
strcpy (consoleName, tyName);
consoleFd = open (consoleName, O_RDWR, 0);
(void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
(void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
}
}
}
#endif /* INCLUDE_TTY_DEV */
#ifdef INCLUDE_PC_CONSOLE
pcConDrv ();
for (ix = 0; ix < N_VIRTUAL_CONSOLES; ix++)
{
sprintf (tyName, "%s%d", "/pcConsole/", ix);
(void) pcConDevCreate (tyName,ix, 512, 512);
if (ix == PC_CONSOLE) /* init the console device */
{
strcpy (consoleName, tyName);
consoleFd = open (consoleName, O_RDWR, 0);
(void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
(void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
}
}
#endif /* INCLUDE_PC_CONSOLE */
#endif /* !INCLUDE_TYCODRV_5_2 */
ioGlobalStdSet (STD_IN, consoleFd);
ioGlobalStdSet (STD_OUT, consoleFd);
ioGlobalStdSet (STD_ERR, consoleFd);
#endif /* INCLUDE_IO_SYSTEM */
/* initialize symbol table facilities */
#ifdef INCLUDE_SYM_TBL
hashLibInit (); /* initialize hash table package */
symLibInit (); /* initialize symbol table package */
#ifdef INCLUDE_SHOW_ROUTINES
symShowInit (); /* initialize symbol table show */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_SYM_TBL */
/* initialize exception handling */
#if defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK)
excInit (); /* initialize exception handling */
#endif /* defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK) */
#ifdef INCLUDE_LOGGING
logInit (consoleFd, MAX_LOG_MSGS); /* initialize logging */
#endif /* INCLUDE_LOGGING */
#ifdef INCLUDE_SIGNALS
sigInit (); /* initialize signals */
#endif /* INCLUDE_SIGNALS */
/* initialize debugging */
#ifdef INCLUDE_DEBUG
dbgInit (); /* initialize debugging */
#endif /* INCLUDE_DEBUG */
/* initialize pipe driver */
#ifdef INCLUDE_PIPES
pipeDrv (); /* install pipe driver */
#endif /* INCLUDE_PIPES */
/* initialize standard I/O package */
#ifdef INCLUDE_STDIO
stdioInit (); /* initialize standard I/O library */
#ifdef INCLUDE_SHOW_ROUTINES
stdioShowInit ();
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_STDIO */
/* initialize POSIX queued signals */
#if defined(INCLUDE_POSIX_SIGNALS) && defined(INCLUDE_SIGNALS)
sigqueueInit (NUM_SIGNAL_QUEUES); /* initialize queued signals */
#endif
/* initialize POSIX semaphores */
#ifdef INCLUDE_POSIX_SEM
semPxLibInit ();
#ifdef INCLUDE_SHOW_ROUTINES
semPxShowInit ();
#endif /* INCLUDE_SHOW_POUTINES */
#endif /* INCLUDE_POSIX_SEM */
/* initialize POSIX message queues */
#ifdef INCLUDE_POSIX_MQ
mqPxLibInit (MQ_HASH_SIZE);
#ifdef INCLUDE_SHOW_ROUTINES
mqPxShowInit ();
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_POSIX_MQ */
/* initialize POSIX async I/O support */
#ifdef INCLUDE_POSIX_AIO
aioPxLibInit (MAX_LIO_CALLS);
#ifdef INCLUDE_POSIX_AIO_SYSDRV
aioSysInit (MAX_AIO_SYS_TASKS, AIO_TASK_PRIORITY, AIO_TASK_STACK_SIZE);
#endif /* INCLUDE_POSIX_AIO_SYSDRV */
#endif /* INCLUDE_POSIX_AIO */
/* initialize filesystems and disk drivers */
#ifdef INCLUDE_DOSFS
hashLibInit (); /* initialize hash table package */
dosFsInit (NUM_DOSFS_FILES); /* init dosFs filesystem */
#endif /* INCLUDE_DOSFS */
#ifdef INCLUDE_RAWFS
rawFsInit (NUM_RAWFS_FILES); /* init rawFs filesystem */
#endif /* INCLUDE_RAWFS */
#ifdef INCLUDE_RT11FS
rt11FsInit (NUM_RT11FS_FILES); /* init rt11Fs filesystem */
#endif /* INCLUDE_RT11FS */
#ifdef INCLUDE_RAMDRV
ramDrv (); /* initialize ram disk driver */
#endif /* INCLUDE_RAMDRV */
#ifdef INCLUDE_SCSI
/*
* initialize either the SCSI1 or SCSI2 interface; initialize SCSI2 when
* the SCSI2 interface is available.
*/
#ifndef INCLUDE_SCSI2
scsi1IfInit ();
#else
scsi2IfInit ();
#endif
/* initialize SCSI controller */
if (sysScsiInit () == OK)
{
usrScsiConfig (); /* configure SCSI peripherals */
}
else
{
printf ("sysScsiInit() Failed, SCSI system not initialized\n");
}
#endif /* INCLUDE_SCSI */
#ifdef INCLUDE_FD
fdDrv (FD_INT_VEC, FD_INT_LVL); /* initialize floppy disk driver */
#endif /* INCLUDE_FD */
#ifdef INCLUDE_IDE
ideDrv (IDE_INT_VEC, IDE_INT_LVL, IDE_CONFIG); /* init IDE disk driver */
#endif /* INCLUDE_IDE */
#ifdef INCLUDE_ATA
{ /* initialize hard disk driver */
IMPORT ATA_RESOURCE ataResources[];
ATA_RESOURCE *pAtaResource;
for (ix = 0; ix < ATA_MAX_CTRLS; ix++)
{
pAtaResource = &ataResources[ix];
if (pAtaResource->ctrlType == IDE_LOCAL)
ataDrv (ix, pAtaResource->drives, pAtaResource->intVector,
pAtaResource->intLevel, pAtaResource->configType,
pAtaResource->semTimeout, pAtaResource->wdgTimeout);
}
}
#ifdef INCLUDE_SHOW_ROUTINES
ataShowInit (); /* install ATA/IDE show routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_ATA */
#ifdef INCLUDE_LPT
{
IMPORT LPT_RESOURCE lptResources[];
lptDrv (LPT_CHANNELS, &lptResources[0]); /* init LPT parallel driver */
}
#endif /* INCLUDE_LPT */
#ifdef INCLUDE_PCMCIA
#ifdef INCLUDE_SHOW_ROUTINES
pcmciaShowInit (); /* install PCMCIA show routines */
#endif /* INCLUDE_SHOW_ROUTINES */
pcmciaInit (); /* init PCMCIA Lib */
#endif /* INCLUDE_PCMCIA */
#ifdef INCLUDE_TFFS
tffsDrv (); /* it should be after pcmciaInit() */
#endif /* INCLUDE_TFFS */
#ifdef INCLUDE_FORMATTED_IO
fioLibInit (); /* initialize formatted I/O */
#endif /* INCLUDE_FORMATTED_IO */
/* initialize floating point facilities */
#ifdef INCLUDE_FLOATING_POINT
floatInit (); /* initialize floating point I/O */
#endif /* INCLUDE_FLOATING_POINT */
/* install software floating point emulation (if applicable) */
#ifdef INCLUDE_SW_FP
mathSoftInit (); /* use software emulation for fp math */
#endif /* INCLUDE_SW_FP */
/* install hardware floating point support (if applicable) */
#ifdef INCLUDE_HW_FP
mathHardInit (); /* do fppInit() & install hw fp math */
#ifdef INCLUDE_SHOW_ROUTINES
fppShowInit (); /* install hardware fp show routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_HW_FP */
/* initialize performance monitoring tools */
#ifdef INCLUDE_SPY
spyLibInit (); /* install task cpu utilization tool */
#endif /* INCLUDE_SPY */
#ifdef INCLUDE_TIMEX
timexInit (); /* install function timing tool */
#endif /* INCLUDE_TIMEX */
#ifdef INCLUDE_ENV_VARS
envLibInit (ENV_VAR_USE_HOOKS); /* initialize environment variable */
#endif /* INCLUDE_ENV_VARS */
#ifdef INCLUDE_NTPASSFS
{
extern int ntPassFsInit();
extern int ntPassFsDevInit();
ntPassFsInit(1);
ntPassFsDevInit("host:");
}
#endif /* INCLUDE_NTPASSFS */
/* initialize object module loader */
#ifdef INCLUDE_LOADER
moduleLibInit (); /* initialize module manager */
#if defined(INCLUDE_AOUT)
loadAoutInit (); /* use a.out format */
#else /* coff or ecoff */
#if defined(INCLUDE_ECOFF)
loadEcoffInit (); /* use ecoff format */
#else /* ecoff */
#if defined(INCLUDE_COFF)
loadCoffInit (); /* use coff format */
#else /* coff */
#if defined(INCLUDE_ELF)
loadElfInit (); /* use elf format */
#else
#if defined(INCLUDE_SOM_COFF)
loadSomCoffInit ();
#else
#if defined(INCLUDE_PECOFF)
{
extern int loadPecoffInit();
loadPecoffInit ();
}
#endif
#endif
#endif
#endif
#endif
#endif
#endif /* INCLUDE_LOADER */
/* initialize wtx client to synchronize host and target symbol tables */
#ifdef INCLUDE_SYM_TBL_SYNC
symSyncLibInit ();
#endif /* INCLUDE_SYM_TBL_SYNC */
/* initialize network */
#ifdef INCLUDE_NET_INIT
usrBootLineInit (sysStartType); /* crack the bootline */
usrNetInit (BOOT_LINE_ADRS); /* initialize network support */
#if CPU==SIMNT
{
extern int simProcnum;
char ulipIP[] = "90.0.0.1";
ulipIP[7] = '1'+simProcnum;
routeAdd("0.0.0.0",ulipIP);
}
#endif /* CPU==SIMNT */
#endif /* INCLUDE_NET_INIT */
#ifdef INCLUDE_PASSFS
{
extern STATUS passFsInit ();
extern void *passFsDevInit ();
char passName [256];
if (passFsInit (1) == OK)
{
extern char vxsim_hostname[];
extern char vxsim_cwd[];
sprintf (passName, "%s:", vxsim_hostname);
if (passFsDevInit (passName) == NULL)
{
printf ("passFsDevInit failed for <%s>\n", passName);
}
else
{
sprintf (passName, "%s:%s", vxsim_hostname, vxsim_cwd);
ioDefPathSet (passName);
}
}
else
printf ("passFsInit failed\n");
}
#endif /* INCLUDE_PASSFS */
#ifdef INCLUDE_DOS_DISK
{
char unixName [80];
extern void unixDrv ();
extern void unixDiskInit ();
extern char *u_progname; /* home of executable */
char *pLastSlash;
unixDrv ();
pLastSlash = strrchr (u_progname, '/');
pLastSlash = (pLastSlash == NULL) ? u_progname : (pLastSlash + 1);
sprintf (unixName, "/tmp/%s%d.dos", pLastSlash, sysProcNumGet());
unixDiskInit (unixName, "A:", 0);
}
#endif /* INCLUDE_DOS_DISK */
/* initialize shared memory objects */
#ifdef INCLUDE_SM_OBJ /* unbundled shared memory objects */
usrSmObjInit (BOOT_LINE_ADRS);
#endif /* INCLUDE_SM_OBJ */
/* initialize WindMP */
#ifdef INCLUDE_VXFUSION /* unbundled VxFusion (distributed objects) */
usrVxFusionInit (BOOT_LINE_ADRS);
#ifdef INCLUDE_SHOW_ROUTINES
{
extern void msgQDistShowInit();
extern void distNameShowInit ();
extern void distIfShowInit ();
extern void msgQDistGrpShowInit ();
msgQDistShowInit();
distNameShowInit ();
distIfShowInit ();
msgQDistGrpShowInit ();
}
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_WINDMP */
/* write protect text segment & vector table only after bpattach () */
#ifdef INCLUDE_MMU_FULL /* unbundled mmu product */
#ifdef INCLUDE_PROTECT_TEXT
if (vmTextProtect () != OK)
printf ("\nError protecting text segment. errno = %x\n", errno);
#endif /* INCLUDE_PROTECT_TEXT */
#ifdef INCLUDE_PROTECT_VEC_TABLE
if (intVecTableWriteProtect () != OK)
printf ("\nError protecting vector table. errno = %x\n", errno);
#endif /* INCLUDE_PROTECT_VEC_TABLE */
#endif /* INCLUDE_MMU_FULL */
/* initialize select only after NFS and RPC for proper delete hook order */
#ifdef INCLUDE_SELECT
selectInit ();
#endif /* INCLUDE_SELECT */
/* create system and status symbol tables */
#ifdef INCLUDE_STANDALONE_SYM_TBL
sysSymTbl = symTblCreate (SYM_TBL_HASH_SIZE_LOG2, TRUE, memSysPartId);
#ifdef INCLUDE_SYM_TBL_SYNC
/* create a module (group 1) that is not synchronized (SPR# 20301) */
moduleCreate ("vxWorks.sym",
#if (defined INCLUDE_AOUT)
MODULE_A_OUT,
#elif ((defined INCLUDE_COFF) || (defined INCLUDE_ECOFF) || \
(defined INCLUDE_SOMCOFF))
MODULE_ECOFF,
#elif (defined INCLUDE_ELF)
MODULE_ELF,
#endif /* INCLUDE_AOUT */
HIDDEN_MODULE|LOAD_NO_SYMBOLS);
#endif /* INCLUDE_SYM_TBL_SYNC */
printf ("\nAdding %ld symbols for standalone.\n", standTblSize);
/* fill in from built in table*/
for (ix = 0; (ULONG) ix < standTblSize; ix++)
#if (CPU == ARM7TDMI_T)
thumbSymTblAdd (sysSymTbl, &(standTbl[ix]));
#else
symTblAdd (sysSymTbl, &(standTbl[ix]));
#endif /* CPU==ARM7TDMI_T `*/
#endif /* INCLUDE_STANDALONE_SYM_TBL */
#ifdef INCLUDE_NET_SYM_TBL
sysSymTbl = symTblCreate (SYM_TBL_HASH_SIZE_LOG2, TRUE, memSysPartId);
netLoadSymTbl (); /* fill in table from host */
#endif /* INCLUDE_NET_SYM_TBL */
#ifdef INCLUDE_STAT_SYM_TBL
statSymTbl = symTblCreate (STAT_TBL_HASH_SIZE_LOG2, FALSE, memSysPartId);
for (ix = 0; (ULONG)ix < statTblSize; ix ++) /* fill in from builtin table*/
symTblAdd (statSymTbl, &(statTbl [ix]));
#endif /* INCLUDE_STAT_SYM_TBL */
/* initialize C++ support library */
#if defined (INCLUDE_CPLUS) && defined (INCLUDE_CPLUS_MIN)
#error Define only one of INCLUDE_CPLUS or INCLUDE_CPLUS_MIN, not both
#endif
#ifdef INCLUDE_CPLUS /* all standard C++ runtime support */
cplusLibInit ();
#ifdef INCLUDE_LOADER
cplusDemanglerInit ();
#endif
#endif
#ifdef INCLUDE_CPLUS_MIN /* minimal C++ runtime support */
cplusLibMinInit ();
#ifdef INCLUDE_LOADER
cplusDemanglerInit ();
#endif
#endif
/* initialize Wind Web Server */
#ifdef INCLUDE_HTTP
httpd ();
#endif /* INCLUDE_HTTP */
#ifdef INCLUDE_RBUFF /* install rBuff support */
rBuffLibInit();
#ifdef INCLUDE_SHOW_ROUTINES
rBuffShowInit (); /* install rBuff show routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_RBUFF */
#ifdef INCLUDE_WINDVIEW
windviewConfig ();
#endif /* INCLUDE_WINDVIEW */
/* initialize the WDB debug agent */
#ifdef INCLUDE_WDB
wdbConfig();
#ifdef INCLUDE_WDB_BANNER
#ifndef INCLUDE_SHELL
/* short banner, like the bootPrintLogo banner */
printf ("\n\n");
printf ("%17s%s", "","VxWorks\n\n");
printf ("Copyright 1984-1998 Wind River Systems, Inc.\n\n");
printf (" CPU: %s\n", sysModel ());
printf (" VxWorks: " VXWORKS_VERSION "\n");
printf (" BSP version: " BSP_VERSION BSP_REV "\n");
printf (" Creation date: %s\n", __DATE__);
printf (" WDB: %s.\n\n",
((wdbRunsExternal () || wdbRunsTasking ()) ?
"Ready" : "Agent configuration failed") );
#endif /*INCLUDE_SHELL*/
#endif /*INCLUDE_WDB_BANNER*/
#endif /* INCLUDE_WDB */
/* initialize interactive shell */
#ifdef INCLUDE_SHELL
#ifdef INCLUDE_SECURITY /* include shell security */
if ((sysFlags & SYSFLG_NO_SECURITY) == 0)
{
loginInit (); /* initialize login table */
shellLoginInstall (loginPrompt, NULL); /* install security program */
/* add additional users here as required */
loginUserAdd (LOGIN_USER_NAME, LOGIN_PASSWORD);
}
#endif /* INCLUDE_SECURITY */
printLogo (); /* print out the banner page */
printf (" ");
printf ("CPU: %s. Processor #%d.\n", sysModel (), sysProcNumGet ());
printf (" ");
printf ("Memory Size: 0x%x.", (UINT)(sysMemTop () - (char *)LOCAL_MEM_LOCAL_ADRS));
printf (" BSP version " BSP_VERSION BSP_REV ".");
#if defined(INCLUDE_WDB) && defined(INCLUDE_WDB_BANNER)
printf ("\n ");
printf ("WDB: %s.",
((wdbRunsExternal () || wdbRunsTasking ()) ?
"Ready" : "Agent configuration failed") );
#endif /*INCLUDE_WDB && INCLUDE_WDB_BANNER*/
printf ("\n\n");
#ifdef INCLUDE_STARTUP_SCRIPT /* run a startup script */
if (sysBootParams.startupScript [0] != EOS)
usrStartupScript (sysBootParams.startupScript);
#endif /* INCLUDE_STARTUP_SCRIPT */
shellInit (SHELL_STACK_SIZE, TRUE); /* create the shell */
/* only include the simple demo if the shell is NOT included */
#else
#if defined(INCLUDE_DEMO) /* create demo w/o shell */
taskSpawn ("demo", 20, 0, 2000, (FUNCPTR)usrDemo, 0,0,0,0,0,0,0,0,0,0);
#endif /* mips cpp no elif */
#endif /* INCLUDE_SHELL */
#ifdef INCLUDE_UGL
usrUglInit ();
#endif /* INCLUDE_UGL */
#if defined(INCLUDE_JAVA)
javaConfig ();
#endif /* INCLUDE_JAVA */
#ifdef INCLUDE_HTML
usrHtmlInit ();
#endif /* INCLUDE_HTML */
#if CPU==SIMNT
win_ReleaseMutex(simUpMutex);
#endif
#ifdef INCLUDE_USER_APPL
/* Startup the user's application */
USER_APPL_INIT; /* must be a valid C statement or block */
#endif
#if (SINQHM_SPAWN != 0)
printf ("Spawning SinqHM_bootParamsConfig ...\n");
taskSpawn ("hmConfig", 100, VX_FP_TASK, 20000,
(FUNCPTR) SinqHM_bootParamsConfig,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
/*------------------------------------------------------------------*/
#endif /* (SINQHM_SPAWN != 0) */
}
/*******************************************************************************
*
* usrClock - user-defined system clock interrupt routine
*
* This routine is called at interrupt level on each clock interrupt.
* It is installed by usrRoot() with a sysClkConnect() call.
* It calls all the other packages that need to know about clock ticks,
* including the kernel itself.
*
* If the application needs anything to happen at the system clock interrupt
* level, it can be added to this routine.
*
* RETURNS: N/A
*/
void usrClock ()
{
tickAnnounce (); /* announce system tick to kernel */
}
#ifdef INCLUDE_DEMO
/********************************************************************************
* usrDemo - example application without shell
*
* This routine is spawned as a task at the end of usrRoot(), if INCLUDE_DEMO
* is defined, and INCLUDE_SHELL is NOT defined in configAll.h or config.h.
* It is intended to indicate how a shell-less application can be linked,
* loaded, and ROMed.
*
* NOMANUAL
*/
void usrDemo (void)
{
char string [40];
printf ("VxWorks (for %s) version %s.\n", sysModel (), vxWorksVersion);
printf ("Kernel: %s.\n", kernelVersion ());
printf ("Made on %s.\n", creationDate);
FOREVER
{
printf ("\nThis is a test. Type something: ");
fioRdString (STD_IN, string, sizeof (string));
printf ("\nYou typed \"%s\".\n", string);
if (strcmp (string, "0") == 0)
memShow (0);
if (strcmp (string, "1") == 0)
memShow (1);
}
}
#endif /* INCLUDE_DEMO */

44
sinqhm/vmio10_def.h Executable file
View File

@ -0,0 +1,44 @@
#ifndef VMIO10_DEF_ID
#define VMIO10_DEF_ID "V01A"
/*=================================================== [...SINQHM]VMIO10_DEF.H
**
** Definition Include file for VMIO10 VME Module.
**
** The module has 2 Z8536-CIO chips, each of which has 2 I/O ports (A and B)
** and 3 counter/timer registers. Hence, the module has 4 I/O ports and
** 6 counter/timers. Just to confuse things, we call the 4 ports A, B, C and D!
** Ports A & B are associated with the first Z8536-CIO and Ports C & D are
** associated with the second Z8536-CIO.
**------------------------------------------------------------------------------
** VME offsets for the first Z8536-CIO.
*/
#define VMIO_PORT_AB 0x01
#define VMIO_PORT_B 0x11
#define VMIO_PORT_A 0x21
#define VMIO_AB_CNTL 0x31
/*
** VME offsets for the second Z8536-CIO.
*/
#define VMIO_PORT_CD 0x09
#define VMIO_PORT_D 0x19
#define VMIO_PORT_C 0x29
#define VMIO_CD_CNTL 0x39
/*
** Z8536-CIO register definitions
*/
#define Z8536_MICR 0x00 /* Master Interrupt Control Register */
#define Z8536_MCCR 0x01 /* Master Config Control Register */
#define Z8536_DPPR_A 0x22 /* Data Path Polarity Register - Port A */
#define Z8536_DPPR_B 0x2a /* Data Path Polarity Register - Port B */
#define Z8536_DPPR_C 0x05 /* Data Path Polarity Register - Port C */
#define Z8536_DDR_A 0x23 /* Data Direction Register - Port A */
#define Z8536_DDR_B 0x2b /* Data Direction Register - Port B */
#define Z8536_DDR_C 0x06 /* Data Direction Register - Port C */
#define Z8536_SIOCR_A 0x24 /* Special I/O Control Register - Port A */
#define Z8536_SIOCR_B 0x2c /* Special I/O Control Register - Port B */
#define Z8536_SIOCR_C 0x07 /* Special I/O Control Register - Port C */
/*======================================================= End of VMIO10_DEF.H */
#endif

307
sinqhm/vmio_utility.c Executable file
View File

@ -0,0 +1,307 @@
#define ident "1A01"
/*
** +--------------------------------------------------------------+
** | Paul Scherrer Institute |
** | Computing Section |
** | |
** | This software may be used freely by non-profit organizations.|
** | It may be copied provided that the name of P.S.I. and of the |
** | author is included. Neither P.S.I. nor the author assume any |
** | responsibility for the use of this software outside of P.S.I.|
** +--------------------------------------------------------------+
**
** Module Name . . . . . . . . : [...SINQHM]VMIO_UTILITY.C
**
** Author . . . . . . . . . . : D. Maden
** Date of creation . . . . . . : Mar 1997
**
** Updates:
** 1A01 14-Mar-1997 DM Initial version.
**---------------------------------------------------------------------------
** VMIO_UTILITY.C is a set of routines for setting up and using a VMIO10.
**
** To compile this program for VxWorks on PSS123, use:
**
ccvx vmio_utility.c
** where
ccvx = ccppc -O0 \
-mcpu=603 \
-I${WIND_BASE}/target/h \
-fno-builtin \
-fno-for-scope \
-nostdinc \
-DCPU=PPC603 \
-D_GNU_TOOL \
-gdwarf -c -Wimplicit
** and, on the target,
**
** -> ld < vmio_utility.o
**====================================================================
*/
#include <vxWorks.h>
#include <taskLib.h>
#include <sysLib.h>
#include <vme.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include "vmio10_def.h"
/*
**==================== Global Definitions =====================================
*/
#define NIL 0x00
#define DFLT_BASE_ADDR 0x1900
/*
**==================== Global Variables =====================================
*/
char *VmioBase;
char Vme_dummy[256]; /* Dummy array - used only when VME access ..
** .. is disabled. */
char Null = 0x00;
char Bit8 = 0x10;
int My_errno;
int Go_on;
int Signal_has_happened;
jmp_buf Trap_env;
/*
**=============================================================================
** Local routines.
** Forward references ...
*/
void vmio_byte_send (char bit8, char lobits);
void vmio_enable (int ab_enbl, int bc_enbl);
void vmio_pol_dir (int a_pol, int a_dir,
int b_pol, int b_dir,
int c_pol, int c_dir,
int d_pol, int d_dir);
void vmio_reset ();
void vmio_send (char nbytes, char *buff);
void vmio_transp_init ();
/*
**-----------------------------------------------------------------*/
void Signal_Handler (int sigint) {
/* ==============
*/
Signal_has_happened = 1;
printf ("Got into Signal_Handler\n");
longjmp (Trap_env, 1);
}
/*
**-----------------------------------------------------------------*/
void vmio_byte_send (char bit8, char lobits) {
/* ==============
** Send a byte (well, 9 bits really) via the VMIO10.
*/
char aux;
do { /* Wait for Output Reg. empty */
VmioBase[VMIO_AB_CNTL] = 0X09; /* Select Port B status reg .. */
aux = VmioBase[VMIO_AB_CNTL]; /* .. and read it. */
} while ((aux & 0x08) == 0); /* Test its "empty" bit */
VmioBase[VMIO_PORT_C] = bit8; /* Send Bit-8 */
VmioBase[VMIO_PORT_B] = lobits; /* Output the other bits */
}
/*
**-----------------------------------------------------------------*/
void vmio_enable (int ab_enbl, int bc_enbl) {
/* ===========
** output/input enable for IC6 ,IC7
*/
VmioBase[VMIO_AB_CNTL] = Z8536_MCCR; /* Select Master Config Control Reg */
VmioBase[VMIO_AB_CNTL] = ab_enbl;
VmioBase[VMIO_CD_CNTL] = Z8536_MCCR;
VmioBase[VMIO_CD_CNTL] = bc_enbl;
}
/*
**-----------------------------------------------------------------*/
void vmio_pol_dir (
/* ============ Set Polarity and Direction of VMIO10 Module
** A, B, C and D registers.
** Polarity bit = 0 for non-inverting.
** Direction bit = 0 for output.
*/ int a_pol,
int a_dir,
int b_pol,
int b_dir,
int c_pol,
int c_dir,
int d_pol,
int d_dir) {
VmioBase[VMIO_AB_CNTL] = Z8536_DPPR_A; /* Port A %10'0010, Data Path Pol */
VmioBase[VMIO_AB_CNTL] = a_pol;
VmioBase[VMIO_AB_CNTL] = Z8536_DDR_A; /* Port A %10'0011, Data Direction */
VmioBase[VMIO_AB_CNTL] = a_dir;
VmioBase[VMIO_AB_CNTL] = Z8536_DPPR_B; /* Port B %10'1010, Data Path Pol */
VmioBase[VMIO_AB_CNTL] = b_pol;
VmioBase[VMIO_AB_CNTL] = Z8536_DDR_B; /* Port B %10'1011, Data Direction */
VmioBase[VMIO_AB_CNTL] = b_dir;
VmioBase[VMIO_CD_CNTL] = Z8536_DPPR_A; /* Port C %10'0010, Data Path Pol */
VmioBase[VMIO_CD_CNTL] = c_pol;
VmioBase[VMIO_CD_CNTL] = Z8536_DDR_A; /* Port C %10'0011, Data Direction */
VmioBase[VMIO_CD_CNTL] = c_dir;
VmioBase[VMIO_CD_CNTL] = Z8536_DPPR_B; /* Port D %10'1010, Data Path Pol */
VmioBase[VMIO_CD_CNTL] = d_pol;
VmioBase[VMIO_CD_CNTL] = Z8536_DDR_B; /* Port D %10'0011, Data Direction */
VmioBase[VMIO_CD_CNTL] = d_dir;
}
/*
**-----------------------------------------------------------------*/
void vmio_reset () {
/* ==========
** Software reset for VMIO10 module
*/
char aux;
/*
** Start by forcing the state machine into State 0
*/
aux = VmioBase[VMIO_AB_CNTL]; /* Read Cntrl to ensure not State 1 */
VmioBase[VMIO_AB_CNTL] = NIL; /* Write zero to Cntrl to ensure not in ..
** .. "Reset State" */
aux = VmioBase[VMIO_AB_CNTL]; /* Read Cntrl to ensure State 0 */
VmioBase[VMIO_AB_CNTL] = Z8536_MICR; /* Select the Master Int Ctrl Reg */
VmioBase[VMIO_AB_CNTL] = 0x01; /* Set the reset bit */
VmioBase[VMIO_AB_CNTL] = NIL; /* Then clear it to complete reset */
/*
** Repeat for the other Z8536-CIO
*/
aux = VmioBase[VMIO_CD_CNTL];
VmioBase[VMIO_CD_CNTL] = NIL;
aux = VmioBase[VMIO_CD_CNTL];
VmioBase[VMIO_CD_CNTL] = Z8536_MICR;
VmioBase[VMIO_CD_CNTL] = 0x01;
VmioBase[VMIO_CD_CNTL] = NIL;
}
/*
**-----------------------------------------------------------------*/
void vmio_send (
/* ========= Send bytes to the LWL.
*/ char nbytes,
char *buff) {
/*
** The bytes are buff[0] to buff[nbytes-1]. buff[0] gives the
** headerbit for buff[1]. The remainder are sent with the 9th
** bit clear.
*/
int i;
char aux;
/*
** ---------- loop sending the bytes ---------------
*/
VmioBase[VMIO_PORT_C] = 0; /* Mode = 0 */
if (nbytes < 2) return;
vmio_byte_send (buff[0], buff[1]); /* 2 bytes define the first "LWL-byte" */
if (nbytes < 3) return;
for (i = 2; i < nbytes; i++) { /* The remaining bytes have Bit-8 = 0 */
vmio_byte_send (NIL, buff[i]);
}
}
/*
**-----------------------------------------------------------------*/
void vmio_transp_init () {
/* ================
** Initialise VMIO10 ready for transparent
** transmission of data.
*/
/*
** ---------- initialize i/o ---------------
*/
VmioBase[VMIO_AB_CNTL] = 0x28; /* Port B output port-Mode Spec. Reg */
VmioBase[VMIO_AB_CNTL] = 0x80;
VmioBase[VMIO_AB_CNTL] = 0x29; /* Port B handshake interlock */
VmioBase[VMIO_AB_CNTL] = 0x00;
}
/*==============================================================================
** Main line program
** ------------------
**============================================================================*/
int vmio_utility (char *base_addr) {
/*============================================================================*/
STATUS status;
int i;
char aux;
void (* sig_status) (int);
/*============================================================================
** Perform the initialisation of global variables ...
*/
/*============================================================================
** Get the VME base address of the Test Generator Module.
** If the argument "base_addr" is zero, use DFLT_BASE_ADDR.
*/
if (base_addr == NULL) base_addr = (char *) DFLT_BASE_ADDR;
#ifdef _NO_VME
printf ("VMIO_UTILITY: Warning, VME access disabled.\n");
VmioBase = &Vme_dummy[0];
#else
status = sysBusToLocalAdrs (VME_AM_USR_SHORT_IO, base_addr, &VmioBase);
if (status != OK) {
printf ("Error status from sysBusToLocalAdrs\n");
return ERROR;
}
#endif
/*
** See if the module is present
*/
Signal_has_happened = 0;
sig_status = signal (SIGBUS, Signal_Handler); /* Catch machine checks */
if (sig_status == SIG_ERR) {
printf (" Problem setting up a signal handler!\n");
return ERROR;
}
i = setjmp (Trap_env);
if (i == 0) aux = VmioBase[VMIO_AB_CNTL];
if (Signal_has_happened != 0) {
printf ("VMIO10 Module not present -- exiting!\n");
return ERROR;
}
/*
** Reset the VMIO10 Module.
*/
vmio_reset ();
/*
** Set Ports A, B, C and D to non-inverting and output
*/
vmio_pol_dir (NIL, NIL, /* Port A */
NIL, NIL, /* Port B */
NIL, NIL, /* Port C */
NIL, NIL); /* Port D */
/*
** Enable Ports A, B, C and D.
*/
vmio_enable (0x84, 0x84);
Go_on = 0;
for (;;) {
for (i=0; i<1000; i++) {}
if (Go_on != 0) break;
VmioBase[VMIO_PORT_A] = 0xff;
VmioBase[VMIO_PORT_A] = 0x00;
VmioBase[VMIO_PORT_A] = 0xff;
VmioBase[VMIO_PORT_A] = 0x00;
VmioBase[VMIO_PORT_A] = 0xff;
VmioBase[VMIO_PORT_A] = 0x00;
}
printf ("Vmio_Utility exiting\n");
return OK;
}
/*===================================== End of VMIO_UTILITY.C =============*/