#!/usr/local/bin/perl -w
#
# simpram_host
#
# release 1, version 0
#
# (C) 1997 by Jochen Rhrig
#
# The following environment variables that are needed by the host program
# are set in simpram
#
# SBP_HOSTMODULEPATH
# SBP_HOSTRC
# SBP_HOSTMODULEFILE
# SBP_LOADER
# SBP_PRAMOS_ISSUE
# SBP_PRAMOS_MOTD
# SBP_HOSTRC
#
# The following environment variables that are needed to call the host
# properly are set in simpram
#
# HOST, HOST_LOADERRC, GLOBAL_MEMSIZE, PRAM_DEVICE,PROG_DEVICE, INTS_DEVICE,
# PROGRAM
#

sleep 5; # just to be sure that the simulator has mapped the "device"-files

$run="$ENV{'HOST'} --tcp-port 4000".
     " -r".
     " -P".
     " -c".
     " --sysv-messages".
     " --pramsim".
     " -M $ENV{'GLOBAL_MEMSIZE'}".
     " --loaderrc $ENV{'HOST_LOADERRC'}".
     " --pram-device $ENV{'PRAM_DEVICE'}".
     " --prog-device $ENV{'PROG_DEVICE'}".
     " --ints-device $ENV{'INTS_DEVICE'}";

#echo $run;
#sleep 5;

if($ENV{'NONINTERACTIVE'})
{
    open BLUBBER, "|$run";
    print BLUBBER "load $ENV{'PROGRAM'}\n";
}
else
{
    system "$ENV{'WRITE_STDIN_PROG'} -n load $ENV{'PROGRAM'}";
    exec   "$run";
}
