1 /* ***********************************************************
  2    *                                                         *
  3    * Copyright, (C) Honeywell Bull Inc., 1987                *
  4    *                                                         *
  5    * Copyright, (C) Honeywell Information Systems Inc., 1986 *
  6    *                                                         *
  7    *********************************************************** */
  8 
  9 /* HISTORY COMMENTS:
 10   1) change(86-05-09,Lee), approve(87-07-13,MCR7580), audit(87-07-13,Leskiw),
 11      install(87-08-07,MR12.1-1072):
 12      Created.
 13   2) change(86-06-10,Westcott), approve(87-07-13,MCR7580),
 14      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 15      Changed to support ws_stack.
 16                                                    END HISTORY COMMENTS */
 17 
 18 /* : PROCEDURE FUNCTION (i_creins):
 19 
 20 Create an instance of the calling application within MOWSE.
 21 Interrupt routine to service a request from the caller for putting its mcb
 22 into an entry in the local CAT.  Upon successfully finding a free entry in
 23 the local cat, the fields in the entry are initialized, the mcb pointer field
 24 in the local CAT is set to the one passed from the caller and the major
 25 capability number (obtained from searching the local CAT for a free entry
 26 and from the local system id) is placed in the major capability field of
 27 the mcb in the caller.
 28 */
 29 
 30 /* : NOTES
 31 */
 32 
 33 #include <dos.h>
 34 #include <cat.h>
 35 #include <ws_dcls.h>
 36 #include <ws_stack.h>
 37 #include <ws_error.h>
 38 #include <ws_msg.h>
 39 #include <wsmincap.h>
 40 
 41 extern local_cat l_CAT[];              /* Local cat table */
 42 extern char      mysystem;             /* IBMPC system id */
 43 extern int       packet_mode;          /* Flags that mowse is active on remote */
 44 
 45 i_creins (p_ws_ptr,p_cips)
 46 
 47 ws_stack *p_ws_ptr;                    /* Callers registers */
 48 struct cretinst_param_struct *p_cips;  /* Create instance information */
 49 {
 50 int cap_index;                         /* Cat index */
 51 int cap_num;                           /* Capability number */
 52 int code;                              /* Error code */
 53 int namelen;                           /* character counter */
 54 struct alter_cat_msg alter_cat;
 55 
 56 /* : If MOWSE is not active on the remote, return error */
 57 
 58    if (!packet_mode)
 59       return (WSNOTACT);
 60 
 61 /* : find an unused CAT entry in the local CAT
 62      - if no available entry in local CAT, return the error code */
 63 
 64    if ((cap_index = find_free_cat() ) < 0)
 65       return(cap_index);
 66 
 67    p_cips -> system_id = WSIBMPC;
 68    p_cips -> major_capability = cap_index + MIN_CAPABILITY_NUMBER;
 69 
 70 /* : reset all flags */
 71 
 72    l_CAT[cap_index].flags = 0;
 73    l_CAT[cap_index].pad = 0;
 74 
 75    if (!(p_cips -> entry_pt))
 76       l_CAT[cap_index].flags |= NULL_BIT;
 77 
 78 /* : initialize sleep time to 0 */
 79 
 80    l_CAT[cap_index].sleep_time = 0;
 81 
 82 /* : initialize the mcb pointer with the one passed from caller */
 83 
 84    l_CAT[cap_index].mcb_ptr = p_cips -> mcb_ptr;
 85    l_CAT[cap_index].ws_entry = p_cips -> entry_pt;
 86    l_CAT[cap_index].sregs.cs = p_cips -> cs_reg;;
 87 
 88 /* : initialize the register values */
 89 
 90    l_CAT[cap_index].sregs.es = p_ws_ptr -> esreg;
 91    l_CAT[cap_index].sregs.ds = p_ws_ptr -> dsreg;
 92    l_CAT[cap_index].sregs.ss = p_ws_ptr -> ssreg;
 93    l_CAT[cap_index].bpreg = p_ws_ptr -> bpreg;
 94    l_CAT[cap_index].spreg = p_ws_ptr -> spreg;
 95    l_CAT[cap_index].waitreg  = 0;
 96 
 97 /* : SEND A MESSAGE TO REMOTE MACHINE TO ADD TO ITS REMOTE CAT */
 98 
 99    alter_cat.system = WSMULTICS;
100    alter_cat.major = WSMAJCAP;
101    alter_cat.minor = WS_ADD_TO_RAT;
102    alter_cat.source_system = mysystem;
103    alter_cat.source_major = WSMAJCAP;
104    alter_cat.rat_major = cap_index + MIN_CAPABILITY_NUMBER;
105 
106    for(namelen=0; namelen < 32; namelen++) {
107       if (p_cips -> capability_name[namelen] < ' ')
108          break;
109    }
110    send_i_mess(&alter_cat, sizeof(struct alter_cat_msg) - 2,
111    &p_cips -> capability_name[0],namelen);
112 
113    return(WSNOERR);
114 }