1 /* LOSC.C       (c) Copyright Jan Jaeger, 2009                       */
2 /*              Hercules Licensed Operating System Check             */
3 
4 #include "hstdinc.h"
5 
6 #if !defined(_HENGINE_DLL_)
7 #define _HENGINE_DLL_
8 #endif
9 
10 #if !defined(_LOSC_C_)
11 #define _LOSC_C_
12 #endif
13 
14 #include "hercules.h"
15 
16 #ifdef OPTION_MSGCLR
17 #define KEEPMSG "<pnl,color(lightred,black),keep>"
18 #else
19 #define KEEPMSG ""
20 #endif
21 
22 static char *licensed_os[] = {
23       "MVS", /* Generic name for MVS, OS/390, z/OS       */
24       "VM",  /* Generic name for VM, VM/XA, VM/ESA, z/VM */
25       "VSE",
26       "TPF",
27       NULL };
28 
29 static int    os_licensed = 0;
30 static int    check_done = 0;
31 
losc_set(int license_status)32 void losc_set (int license_status)
33 {
34     os_licensed = license_status;
35     check_done = 0;
36 }
37 
losc_check(char * ostype)38 void losc_check(char *ostype)
39 {
40 char **lictype;
41 int i;
42 CPU_BITMAP mask;
43 
44     if(check_done)
45         return;
46     else
47         check_done = 1;
48 
49     for(lictype = licensed_os; *lictype; lictype++)
50     {
51         if(!strncasecmp(ostype, *lictype, strlen(*lictype)))
52         {
53             if(os_licensed == PGM_PRD_OS_LICENSED)
54             {
55                 logmsg(_(
56                 KEEPMSG "HHCCF039W PGMPRDOS LICENSED specified.\n"
57                 KEEPMSG "          A licensed program product operating system is running.\n"
58                 KEEPMSG "          You are responsible for meeting all conditions of your\n"
59                 KEEPMSG "          software licenses.\n"));
60             }
61             else
62             {
63                 logmsg(_(
64                 KEEPMSG "HHCCF079A A licensed program product operating system has been\n"
65                 KEEPMSG "          detected. All processors have been stopped.\n"));
66                 mask = sysblk.started_mask;
67                 for (i = 0; mask; i++)
68                 {
69                     if (mask & 1)
70                     {
71                         REGS *regs = sysblk.regs[i];
72                         regs->opinterv = 1;
73                         regs->cpustate = CPUSTATE_STOPPING;
74                         ON_IC_INTERRUPT(regs);
75                         signal_condition(&regs->intcond);
76                     }
77                     mask >>= 1;
78                 }
79             }
80         }
81     }
82 }
83