#pragma module load_ip_vcm "X-4" /* ***************************************************************************** * * Copyright © 1996 Digital Equipment Corporation. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Digital Equipment Corporation. The name of the * Corporation may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * ***************************************************************************** * * Important Note: * * This coding example uses privileged OpenVMS interfaces. * OpenVMS does not guarantee that these interfaces will * be supported indefinitely, and may change these interfaces * without prior notice. * ***************************************************************************** FACILITY: PPPD ABSTRACT: Simple example to load example IPCP control protocol and VCM. This code requires that you have CMKRNL privilege, and assumes that the image to be loaded in sys$loadable_images, and that the image name is ip_vcm.exe. You will need to change this code to suit your actual needs. AUTHOR: Forrest A. Kenney 13-July-1996 Thanks to Karen Noel for providing the original code that this example is built off of. REVISION HISTORY: X-4 BWK004 Barry W. Kierstein 17-DEC-1996 Replaced the standard Digital copyright with one compatible with the CMU copyright. X-3 BWK003 Barry W. Kierstein 1-AUG-1996 Added "Important Note" disclaimer. X-2 BWK002 Barry W. Kierstein 24-JUL-1996 Corrected copyright notice. X-1 BWK001 Barry W. Kierstein 15-JUL-1996 Initial checkin of this module. */ /* Define data structures and constants */ #include /* Descriptors */ #include /* Loaded image data block */ #include /* Logical names */ #include /* Linkage pairs */ #include /* System service proto-types */ #include /* System service status codes */ #include /* CRTL I/O */ #include /* CTRL strings */ #define _lkpdef lkpdef typedef struct lkpdef LKP; typedef struct _ref_handle /* Dynamic loader reference handle */ { void *base_addr; LDRIMG *ldrimg_ptr; int seq_num; } REF_HANDLE; /* Define special proto-types for the loader routines we need */ extern int ldr$load_image (struct dsc$descriptor_s *execlet_name, int flags, REF_HANDLE *reference_handle); extern int ldr$ref_info (struct dsc$descriptor_s *execlet_name, REF_HANDLE *reference_handle); /* Define proto-type for Kernel routine */ int load_execlet(); /* Global data */ REF_HANDLE reference_handle; /* Dynamic loader ref handle */ struct dsc$descriptor_s execlet_name; /* Execlet name */ char name[] = "IP_VCM.EXE"; /* **++ ** Main - Get us started ** ** Functional description: ** ** This routine exists to simply get us into Kernel mode to load the ** execlet. ** ** Calling convention: ** ** main() ** ** Input parameters: ** ** None ** ** Output parameters: ** ** None ** ** Return value: ** ** Various SS$_xxxx ** ** Environment: ** ** User mode. ** **-- */ int main() { int status; int arglist[1]; /* Call kernel mode routine to load execlet and read symbol vector */ arglist[0] = 0; status = sys$cmkrnl(load_execlet,arglist); if (status & SS$_NORMAL) { printf("Execlet %s loaded\n", name); } else { printf("Status from load_execlet = %x.\n",status); } return (status); } /* **++ ** load_execlet - Load the specified execlet ** ** Functional description: ** ** This routine is called in Kernel Mode and will load the specified ** execlet. ** ** Calling convention: ** ** load_execlet() ** ** Input parameters: ** ** None ** ** Output parameters: ** ** None ** ** Return value: ** ** Various SS$_xxx ** ** Environment: ** ** Kernel mode ** **-- */ int load_execlet () { LKP *symvec; /* Pointer to symbol vector */ int status; /* Set up string descriptor with name of execlet image */ execlet_name.dsc$w_length = strlen (name); execlet_name.dsc$b_dtype = 0; execlet_name.dsc$b_class = 0; execlet_name.dsc$a_pointer = name; /* Try referencing execlet first, in case it is already loaded */ status = ldr$ref_info (&execlet_name, &reference_handle); /* If error, must not be loaded yet */ if (status != SS$_NORMAL) { /* Load execlet */ status = ldr$load_image (&execlet_name, 2, &reference_handle); } return(status); }