home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / sysutl / sysprof3.arc / PROFCTRL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-20  |  48.1 KB  |  1,120 lines

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /*                                 Listing 2                                 */
  4. /*                                                                           */
  5. /*  NAME : PROFCTRL                                                          */
  6. /*                                                                           */
  7. /*  DATE : March 30, 1988                                                    */
  8. /*                                                                           */
  9. /*  AUTHOR : (C) Copyright 1988 G. Kent Cobb - All Rights Reserved           */
  10. /*                                                                           */
  11. /*  DESCRIPTION :                                                            */
  12. /*      This program provides control functions for the terminate-and-stay-  */
  13. /*      resident system profiler.  The syntax for executing PROFCTRL is:     */
  14. /*                                                                           */
  15. /*                                                                           */
  16. /*                          |   STATUS                     |                 */
  17. /*                          |     ON                       |                 */
  18. /*                 PROFCTRL |     OFF                      |                 */
  19. /*                          |    ZERO                      |                 */
  20. /*                          |   REPORT [output-file-name]  |                 */
  21. /*                                                                           */
  22. /*      The ON and OFF options affect the accumulation of interrupt data;    */
  23. /*      STATUS reports the current state; ZERO erases all data that has      */
  24. /*      been accumulated; and REPORT generates a listing that describes      */
  25. /*      the contents of the tables.                                          */
  26. /*                                                                           */
  27. /*      SYS_PROF and PROFCTRL are most easily used in a batch file, such as: */
  28. /*                                                                           */
  29. /*                                                                           */
  30. /*                            SYS_PROF                                       */
  31. /*                            PROFCTRL zero                                  */
  32. /*                            PROFCTRL on                                    */
  33. /*                            chkdsk c:                                      */
  34. /*                            PROFCTRL off                                   */
  35. /*                            PROFCTRL report temp                           */
  36. /*                            d:list temp                                    */
  37. /*                                                                           */
  38. /*****************************************************************************/
  39. /*  modifications for Turbo C and updated function descriptions              */
  40. /*  by Ralf Brown, 5/18/89                                                   */
  41. /*****************************************************************************/
  42. /*  additional function call tracking added by Ralf Brown, 6/18/89           */
  43. /*****************************************************************************/
  44.  
  45. #include "stdio.h"
  46. #include "dos.h"
  47. #ifdef __TURBOC__
  48. #  include <stdlib.h>
  49. #  include <string.h>
  50. #endif __TURBOC__
  51.  
  52. #define NUM_INTS 13
  53. #define END_OF_STRING '\0'
  54.  
  55. #define CONTROL_INTERRUPT   96
  56. #define STATUS          0
  57. #define OFF             1
  58. #define ON              2
  59. #define FIND            3
  60. #define ZERO            4
  61. #define REPORT          5
  62.  
  63. #define DOS             0x21
  64. #define GET_INT_VECTOR  0x35
  65.  
  66. #ifdef __TURBOC__  /* prototype the functions */
  67. int error_exit(void) ;
  68. int tally_total_ticks(void) ;
  69. int print_interrupt_summary( int, char *descriptions[] ) ;
  70. int print_line(char *title, long number, long duration) ;
  71. #endif __TURBOC__
  72.  
  73. struct tally
  74.     {
  75.     long time;
  76.     long number;
  77.     };
  78.  
  79. long total_ticks;       /*  TOTAL NUMBER OF TIMER TICKS RECORDED.  */
  80.  
  81. char *int_desc[NUM_INTS+1] = {"OTHER",
  82.                               "PRINT SCREEN - INTERRUPT 5H",
  83.                               "VIDEO BIOS - INTERRUPT 10H",
  84.                               "DISK SERVICES - INTERRUPT 13H",
  85.                               "COMM PORT - INTERRUPT 14H",
  86.                               "SYSTEM UTILITY SERVICES - INTERRUPT 15H",
  87.                               "KEYBOARD BIOS - INTERRUPT 16H",
  88.                               "PRINTER BIOS - INTERRUPT 17H",
  89.                               "DOS FUNCTIONS - INTERRUPT 21H",
  90.                               "DOS ABSOLUTE DISK READ - INTERRUPT 25H",
  91.                               "DOS ABSOLUTE DISK WRITE - INTERRUPT 26H",
  92.                               "NETWORK - INTERRUPT 2AH",
  93.                               "MULTIPLEX - INTERRUPT 2FH",
  94.                               "EXPANDED MEMORY DRIVER - INTERRUPT 67H" };
  95.  
  96. int max_services[NUM_INTS+1] = {0,0,29,29,6,223,19,3,109,0,0,7,206,108};
  97.  
  98. char *other_services[] = {""};
  99. char *print_screen_services[] = {""};
  100. char *video_services[] = {"00 - Set Mode",
  101.                           "01 - Set Cursor Size",
  102.                           "02 - Set Cursor Position",
  103.                           "03 - Get Cursor Position",
  104.                           "04 - Get Light Pen Position",
  105.                           "05 - Set Active Page",
  106.                           "06 - Scroll Up",
  107.                           "07 - Scroll Down",
  108.                           "08 - Read Character and Attribute",
  109.                           "09 - Write Character and Attribute",
  110.                           "0A - Write Character",
  111.                           "0B - Set Palette",
  112.                           "0C - Write Dot",
  113.                           "0D - Read Dot",
  114.                           "0E - Write TTY",
  115.                           "0F - Get Mode",
  116.                           "10 - Service 16",
  117.                           "11 - Service 17",
  118.                           "12 - Alternate function select",
  119.                           "13 - Write String",
  120.                           "14 - LCD fonts",
  121.                           "15 - Get physical display parameters",
  122.                           "16 - Service 22",
  123.                           "17 - Service 23",
  124.                           "18 - Service 24",
  125.                           "19 - Service 25",
  126.                           "1A - Display combination",
  127.                           "1B - Functionality/State information",
  128.                           "1C - Save/Restore video state",
  129.                           "Undefined services"};
  130. char *disk_services[] = {"00 - Reset Diskette System",
  131.                          "01 - Get Diskette Status",
  132.                          "02 - Read Sectors",
  133.                          "03 - Write Sectors",
  134.                          "04 - Verify Sectors",
  135.                          "05 - Format Track",
  136.                          "06 - Fixed Disk - Format track",
  137.                          "07 - Fixed Disk - Format drive",
  138.                          "08 - Get Drive Parameters",
  139.                          "09 - Initialize Parameter Tables",
  140.                          "0A - Read Long",
  141.                          "0B - Write Long",
  142.                          "0C - Seek to Cylinder",
  143.                          "0D - Alternate Disk Reset",
  144.                          "0E - Read sector buffer",
  145.                          "0F - Write sector buffer",
  146.                          "10 - Test Ready",
  147.                          "11 - Recalibrate Drive",
  148.                          "12 - Controller RAM Diagnostics",
  149.                          "13 - Drive Diagnostics",
  150.                          "14 - Controller Diagnostics",
  151.                          "15 - Get Disk Type",
  152.                          "16 - Change Disk Status",
  153.                          "17 - Set Disk Type",
  154.                          "18 - Set Media Type for Format",
  155.                          "19 - Park Heads (ESDI)",
  156.                          "1A - Format ESDI Drive",
  157.                          "1B - Get ESDI Manufacturing Header",
  158.                          "1C - Get ESDI info",
  159.                          "Undefined services"};
  160. char *comm_services[] = {"00 - Initialize Serial Port",
  161.                        "01 - Send Character",
  162.                        "02 - Receive Character",
  163.                        "03 - Get Status",
  164.                        "04 - Extended Initialization",
  165.                        "05 - Extended Port Control",
  166.                        "Undefined services"};
  167. char *sys_util_services[] = {
  168.                        "00 - Turn on cassette motor",
  169.                        "01 - Turn off cassette motor",
  170.                        "02 - Read cassette",
  171.                        "03 - Write cassette",
  172.                        "04 - Service 4",
  173.                        "05 - Service 5",
  174.                        "06 - Service 6",
  175.                        "07 - Service 7",
  176.                        "08 - Service 8",
  177.                        "09 - Service 9",
  178.                        "0A - Service 10",
  179.                        "0B - Service 11",
  180.                        "0C - Service 12",
  181.                        "0D - Service 13",
  182.                        "0E - Service 14",
  183.                        "0F - Format Unit periodic interrupt",
  184.                        "10 - TopView/DESQview",
  185.                        "11 - TopView/DESQview",
  186.                        "12 - TopView/DESQview 'SEND' interface",
  187.                        "13 - Service 19",
  188.                        "14 - Service 20",
  189.                        "15 - Service 21",
  190.                        "16 - Service 22",
  191.                        "17 - Service 23",
  192.                        "18 - Service 24",
  193.                        "19 - Service 25",
  194.                        "1A - Service 26",
  195.                        "1B - Service 27",
  196.                        "1C - Service 28",
  197.                        "1D - Service 29",
  198.                        "1E - Service 30",
  199.                        "1F - Service 31",
  200.                        "20 - SysReq ",
  201.                        "21 - POST error log",
  202.                        "22 - Service 34",
  203.                        "23 - Service 35",
  204.                        "24 - Service 36",
  205.                        "25 - Service 37",
  206.                        "26 - Service 38",
  207.                        "27 - Service 39",
  208.                        "28 - Service 40",
  209.                        "29 - Service 41",
  210.                        "2A - Service 42",
  211.                        "2B - Service 43",
  212.                        "2C - Service 44",
  213.                        "2D - Service 45",
  214.                        "2E - Service 46",
  215.                        "2F - Service 47",
  216.                        "30 - Service 48",
  217.                        "31 - Service 49",
  218.                        "32 - Service 50",
  219.                        "33 - Service 51",
  220.                        "34 - Service 52",
  221.                        "35 - Service 53",
  222.                        "36 - Service 54",
  223.                        "37 - Service 55",
  224.                        "38 - Service 56",
  225.                        "39 - Service 57",
  226.                        "3A - Service 58",
  227.                        "3B - Service 59",
  228.                        "3C - Service 60",
  229.                        "3D - Service 61",
  230.                        "3E - Service 62",
  231.                        "3F - Service 63",
  232.                        "40 - Read/Modify system profiles",
  233.                        "41 - Wait on external event",
  234.                        "42 - CONVERTIBLE: request power off",
  235.                        "43 - CONVERTIBLE: read system status",
  236.                        "44 - CONVERTIBLE: (de)activate internal modem",
  237.                        "45 - Service 69",
  238.                        "46 - Service 70",
  239.                        "47 - Service 71",
  240.                        "48 - Service 72",
  241.                        "49 - Service 73",
  242.                        "4A - Service 74",
  243.                        "4B - Service 75",
  244.                        "4C - Service 76",
  245.                        "4D - Service 77",
  246.                        "4E - Service 78",
  247.                        "4F - Keyboard intercept",
  248.                        "50 - Service 80",
  249.                        "51 - Service 81",
  250.                        "52 - Service 82",
  251.                        "53 - Service 83",
  252.                        "54 - Service 84",
  253.                        "55 - Service 85",
  254.                        "56 - Service 86",
  255.                        "57 - Service 87",
  256.                        "58 - Service 88",
  257.                        "59 - Service 89",
  258.                        "5A - Service 90",
  259.                        "5B - Service 91",
  260.                        "5C - Service 92",
  261.                        "5D - Service 93",
  262.                        "5E - Service 94",
  263.                        "5F - Service 95",
  264.                        "60 - Service 96",
  265.                        "61 - Service 97",
  266.                        "62 - Service 98",
  267.                        "63 - Service 99",
  268.                        "64 - Service 100",
  269.                        "65 - Service 101",
  270.                        "66 - Service 102",
  271.                        "67 - Service 103",
  272.                        "68 - Service 104",
  273.                        "69 - Service 105",
  274.                        "6A - Service 106",
  275.                        "6B - Service 107",
  276.                        "6C - Service 108",
  277.                        "6D - Service 109",
  278.                        "6E - Service 110",
  279.                        "6F - Service 111",
  280.                        "70 - Service 112",
  281.                        "71 - Service 113",
  282.                        "72 - Service 114",
  283.                        "73 - Service 115",
  284.                        "74 - Service 116",
  285.                        "75 - Service 117",
  286.                        "76 - Service 118",
  287.                        "77 - Service 119",
  288.                        "78 - Service 120",
  289.                        "79 - Service 121",
  290.                        "7A - Service 122",
  291.                        "7B - Service 123",
  292.                        "7C - Service 124",
  293.                        "7D - Service 125",
  294.                        "7E - Service 126",
  295.                        "7F - Service 127",
  296.                        "80 - device open",
  297.                        "81 - device close",
  298.                        "82 - device program terminate",
  299.                        "83 - event wait",
  300.                        "84 - read joystick",
  301.                        "85 - SysReq key pressed/released",
  302.                        "86 - wait",
  303.                        "87 - extended memory block move",
  304.                        "88 - get extended memory size",
  305.                        "89 - switch to protected mode",
  306.                        "8A - Service 138",
  307.                        "8B - Service 139",
  308.                        "8C - Service 140",
  309.                        "8D - Service 141",
  310.                        "8E - Service 142",
  311.                        "8F - Service 143",
  312.                        "90 - device busy loop",
  313.                        "91 - complete device busy loop",
  314.                        "92 - Service 146",
  315.                        "93 - Service 147",
  316.                        "94 - Service 148",
  317.                        "95 - Service 149",
  318.                        "96 - Service 150",
  319.                        "97 - Service 151",
  320.                        "98 - Service 152",
  321.                        "99 - Service 153",
  322.                        "9A - Service 154",
  323.                        "9B - Service 155",
  324.                        "9C - Service 156",
  325.                        "9D - Service 157",
  326.                        "9E - Service 158",
  327.                        "9F - Service 159",
  328.                        "A0 - Service 160",
  329.                        "A1 - Service 161",
  330.                        "A2 - Service 162",
  331.                        "A3 - Service 163",
  332.                        "A4 - Service 164",
  333.                        "A5 - Service 165",
  334.                        "A6 - Service 166",
  335.                        "A7 - Service 167",
  336.                        "A8 - Service 168",
  337.                        "A9 - Service 169",
  338.                        "AA - Service 170",
  339.                        "AB - Service 171",
  340.                        "AC - Service 172",
  341.                        "AD - Service 173",
  342.                        "AE - Service 174",
  343.                        "AF - Service 175",
  344.                        "B0 - Service 176",
  345.                        "B1 - Service 177",
  346.                        "B2 - Service 178",
  347.                        "B3 - Service 179",
  348.                        "B4 - Service 180",
  349.                        "B5 - Service 181",
  350.                        "B6 - Service 182",
  351.                        "B7 - Service 183",
  352.                        "B8 - Service 184",
  353.                        "B9 - Service 185",
  354.                        "BA - Service 186",
  355.                        "BB - Service 187",
  356.                        "BC - Service 188",
  357.                        "BD - Service 189",
  358.                        "BE - Service 190",
  359.                        "BF - Service 191",
  360.                        "C0 - Get system configuration",
  361.                        "C1 - Return BIOS extended data area",
  362.                        "C2 - Pointing device interface",
  363.                        "C3 - enable/disable watchdog timeout",
  364.                        "C4 - programmable option select",
  365.                        "C5 - Service 197",
  366.                        "C6 - Service 198",
  367.                        "C7 - Service 199",
  368.                        "C8 - Service 200",
  369.                        "C9 - Service 201",
  370.                        "CA - Service 202",
  371.                        "CB - Service 203",
  372.                        "CC - Service 204",
  373.                        "CD - Service 205",
  374.                        "CE - Service 206",
  375.                        "CF - Service 207",
  376.                        "D0 - Service 208",
  377.                        "D1 - Service 209",
  378.                        "D2 - Service 210",
  379.                        "D3 - Service 211",
  380.                        "D4 - service 212",
  381.                        "D5 - service 213",
  382.                        "D6 - service 214",
  383.                        "D7 - service 215",
  384.                        "D8 - service 216",
  385.                        "D9 - service 217",
  386.                        "DA - service 218",
  387.                        "DB - service 219",
  388.                        "DC - service 220",
  389.                        "DD - service 221",
  390.                        "DE - DESQview ",
  391.                        "Undefined services" } ;
  392. char *keyboard_services[] = {"00 - Read Character",
  393.                              "01 - Character Waiting?",
  394.                              "02 - Get Shift Status",
  395.                              "03 - Set Delays",
  396.                              "04 - Set Keyclick",
  397.                              "05 - Write to Keyboard",
  398.                              "06 - Service 6",
  399.                              "07 - Service 7",
  400.                              "08 - Service 8",
  401.                              "09 - Service 9",
  402.                              "0A - Service 10",
  403.                              "0B - Service 11",
  404.                              "0C - Service 12",
  405.                              "0D - Service 13",
  406.                              "0E - Service 14",
  407.                              "0F - Service 15",
  408.                              "10 - Read Extended Keystroke",
  409.                              "11 - Extended Key Waiting?",
  410.                              "12 - Extended Shift Status",
  411.                              "Undefined services"};
  412. char *printer_services[] = {"00 - Send Byte",
  413.                             "01 - Initialize Printer",
  414.                             "02 - Get Printer Status",
  415.                             "Undefined services"};
  416. char *dos_services[] = {"00 - Terminate",
  417.                         "01 - Keyboard Input With Echo",
  418.                         "02 - Display Output",
  419.                         "03 - Serial Input",
  420.                         "04 - Serial Output",
  421.                         "05 - Printer Output",
  422.                         "06 - Keyboard/Display I/O",
  423.                         "07 - Keyboard Input No Echo",
  424.                         "08 - Keyboard Input No Echo",
  425.                         "09 - Display String",
  426.                         "0A - Buffered Keyboard Input",
  427.                         "0B - Keyboard Status",
  428.                         "0C - Clear Keyboard",
  429.                         "0D - Reset Disk",
  430.                         "0E - Set Default Drive",
  431.                         "0F - Open File FCB Mode",
  432.                         "10 - Close File FCB Mode",
  433.                         "11 - Find First File FCB Mode",
  434.                         "12 - Find Next File FCB Mode",
  435.                         "13 - Delete File FCB Mode",
  436.                         "14 - Read Sequential",
  437.                         "15 - Write Sequential",
  438.                         "16 - Create File FCB Mode",
  439.                         "17 - Rename File FCB Mode",
  440.                         "18 - Service 24",
  441.                         "19 - Get Default Drive",
  442.                         "1A - Set Disk Transfer Area",
  443.                         "1B - Get FAT Info, Default Drive",
  444.                         "1C - Get FAT Info, Any Drive",
  445.                         "1D - Service 29",
  446.                         "1E - Service 30",
  447.                         "1F - Get Default Drive Params",
  448.                         "20 - Service 32",
  449.                         "21 - Read Random",
  450.                         "22 - Write Random",
  451.                         "23 - Get File Size",
  452.                         "24 - Set Random Record Field",
  453.                         "25 - Set Interrupt Vector",
  454.                         "26 - Create Program Segment",
  455.                         "27 - Read Random, Multiple Records",
  456.                         "28 - Write Random, Multiple Records",
  457.                         "29 - Parse Filename",
  458.                         "2A - Get Date",
  459.                         "2B - Set Date",
  460.                         "2C - Get Time",
  461.                         "2D - Set Time",
  462.                         "2E - Set Disk Write Verification",
  463.                         "2F - Get DTA Address",
  464.                         "30 - Get DOS Version Number",
  465.                         "31 - Terminate and Stay Resident",
  466.                         "32 - Get Drive Parameter Block",
  467.                         "33 - Get/Set Ctrl Break",
  468.                         "34 - Get INDOS Flag",
  469.                         "35 - Get Interrupt Vector",
  470.                         "36 - Get Disk Free Space",
  471.                         "37 - Switchar/Availdev",
  472.                         "38 - Get Country-Dependent Info",
  473.                         "39 - Make Directory",
  474.                         "3A - Remove Directory",
  475.                         "3B - Change Default Directory",
  476.                         "3C - Create File, Handle Mode",
  477.                         "3D - Open File, Handle Mode",
  478.                         "3E - Close File, Handle Mode",
  479.                         "3F - Read from File or Device",
  480.                         "40 - Write to File or Device",
  481.                         "41 - Delete File, Handle Mode",
  482.                         "42 - Move File Pointer",
  483.                         "43 - Get/Set File Attributes",
  484.                         "44 - I/O Control for Devices",
  485.                         "45 - Duplicate File Handle",
  486.                         "46 - Force File Handle Duplication",
  487.                         "47 - Get Default Directory",
  488.                         "48 - Allocate Memory",
  489.                         "49 - Free Memory",
  490.                         "4A - Modify Allocated Memory",
  491.                         "4B - EXEC",
  492.                         "4C - Terminate Process",
  493.                         "4D - Get Return Code",
  494.                         "4E - Find First File, Handle Mode",
  495.                         "4F - Find Next File, Handle Mode",
  496.                         "50 - Set PSP",
  497.                         "51 - Get PSP",
  498.                         "52 - Get DOS list-of-lists",
  499.                         "53 - Translate BIOS Parameter Block",
  500.                         "54 - Get Verify State",
  501.                         "55 - Create Child PSP",
  502.                         "56 - Rename File, Handle Mode",
  503.                         "57 - Get/Set File Date and Time",
  504.                         "58 - Get/Set Memory Allocation Strategy",
  505.                         "59 - Get Extended Error",
  506.                         "5A - Create Temporary File",
  507.                         "5B - Create New File",
  508.                         "5C - Lock/Unlock File Access",
  509.                         "5D - SHARE.EXE-related",
  510.                         "5E - Network Services",
  511.                         "5F - Network Services",
  512.                         "60 - Canonicalize Filename",
  513.                         "61 - Service 97 - unused",
  514.                         "62 - Get PSP Address",
  515.                         "63 - Get Lead Byte Table",
  516.                         "64 - Network-related",
  517.                         "65 - Get Extended Country Info",
  518.                         "66 - Code Page Support",
  519.                         "67 - Set Handle Count",
  520.                         "68 - Commit File",
  521.                         "69 - Get/Set Disk Serial Number",
  522.                         "6A - Service 106",
  523.                         "6B - Service 107",
  524.                         "6C - Extended Open/Create",
  525.                         "Undefined services"};
  526. char *disk_read_services[] = {""};
  527. char *disk_write_services[] = {""};
  528. char *network2A_services[] = {
  529.                         "00 - Network installation check",
  530.                         "01 - Execute NetBIOS request",
  531.                         "02 - Set Network printer mode",
  532.                         "03 - Check direct I/O",
  533.                         "04 - Execute NetBIOS",
  534.                         "05 - Get network resource info",
  535.                         "06 - Print-stream control",
  536.                         "Other services (network hooks)"};
  537. char *multiplex_services[] = {
  538.                         "00 - Service 0",
  539.                         "01 - PRINT",
  540.                         "02 - PC LAN Program redirector",
  541.                         "03 - Service 3",
  542.                         "04 - Service 4",
  543.                         "05 - Critical Error msg override",
  544.                         "06 - ASSIGN",
  545.                         "07 - Service 7",
  546.                         "08 - DRIVER.SYS support",
  547.                         "09 - Service 9",
  548.                         "0A - Service 10",
  549.                         "0B - Service 11",
  550.                         "0C - Service 12",
  551.                         "0D - Service 13",
  552.                         "0E - Service 14",
  553.                         "0F - Service 15",
  554.                         "10 - SHARE",
  555.                         "11 - Network redirector",
  556.                         "12 - Network/SHARE support",
  557.                         "13 - Service 19",
  558.                         "14 - NLSFUNC",
  559.                         "15 - CDROM",
  560.                         "16 - Service 22",
  561.                         "17 - Service 23",
  562.                         "18 - Service 24",
  563.                         "19 - SHELLB.COM",
  564.                         "1A - ANSI.SYS",
  565.                         "1B - XMA2EMS.SYS",
  566.                         "1C - Service 28",
  567.                         "1D - Service 29",
  568.                         "1E - Service 30",
  569.                         "1F - Service 31",
  570.                         "20 - Service 32",
  571.                         "21 - Service 33",
  572.                         "22 - Service 34",
  573.                         "23 - Service 35",
  574.                         "24 - Service 36",
  575.                         "25 - Service 37",
  576.                         "26 - Service 38",
  577.                         "27 - Service 39",
  578.                         "28 - Service 40",
  579.                         "29 - Service 41",
  580.                         "2A - Service 42",
  581.                         "2B - Service 43",
  582.                         "2C - Service 44",
  583.                         "2D - Service 45",
  584.                         "2E - Service 46",
  585.                         "2F - Service 47",
  586.                         "30 - Service 48",
  587.                         "31 - Service 49",
  588.                         "32 - Service 50",
  589.                         "33 - Service 51",
  590.                         "34 - Service 52",
  591.                         "35 - Service 53",
  592.                         "36 - Service 54",
  593.                         "37 - Service 55",
  594.                         "38 - Service 56",
  595.                         "39 - Service 57",
  596.                         "3A - Service 58",
  597.                         "3B - Service 59",
  598.                         "3C - Service 60",
  599.                         "3D - Service 61",
  600.                         "3E - Service 62",
  601.                         "3F - Service 63",
  602.                         "40 - Service 64",
  603.                         "41 - Service 65",
  604.                         "42 - Service 66",
  605.                         "43 - XMS driver",
  606.                         "44 - Service 68",
  607.                         "45 - Service 69",
  608.                         "46 - Service 70",
  609.                         "47 - Service 71",
  610.                         "48 - Service 72",
  611.                         "49 - Service 73",
  612.                         "4A - Service 74",
  613.                         "4B - Service 75",
  614.                         "4C - Service 76",
  615.                         "4D - Service 77",
  616.                         "4E - Service 78",
  617.                         "4F - Service 79",
  618.                         "50 - Service 80",
  619.                         "51 - Service 81",
  620.                         "52 - Service 82",
  621.                         "53 - Service 83",
  622.                         "54 - TesSeRact TSR interface",
  623.                         "55 - Service 85",
  624.                         "56 - Service 86",
  625.                         "57 - Service 87",
  626.                         "58 - Service 88",
  627.                         "59 - Service 89",
  628.                         "5A - Service 90",
  629.                         "5B - Service 91",
  630.                         "5C - Service 92",
  631.                         "5D - Service 93",
  632.                         "5E - Service 94",
  633.                         "5F - Service 95",
  634.                         "60 - Service 96",
  635.                         "61 - Service 97",
  636.                         "62 - Service 98",
  637.                         "63 - Service 99",
  638.                         "64 - SCRNSAV2.COM",
  639.                         "65 - Service 101",
  640.                         "66 - Service 102",
  641.                         "67 - Service 103",
  642.                         "68 - Service 104",
  643.                         "69 - Service 105",
  644.                         "6A - Service 106",
  645.                         "6B - Service 107",
  646.                         "6C - Service 108",
  647.                         "6D - Service 109",
  648.                         "6E - Service 110",
  649.                         "6F - Service 111",
  650.                         "70 - Service 112",
  651.                         "71 - Service 113",
  652.                         "72 - Service 114",
  653.                         "73 - Service 115",
  654.                         "74 - Service 116",
  655.                         "75 - Service 117",
  656.                         "76 - Service 118",
  657.                         "77 - Service 119",
  658.                         "78 - Service 120",
  659.                         "79 - Service 121",
  660.                         "7A - Novell Netware",
  661.                         "7B - Service 123",
  662.                         "7C - Service 124",
  663.                         "7D - Service 125",
  664.                         "7E - Service 126",
  665.                         "7F - Service 127",
  666.                         "80 - EASY-NET",
  667.                         "81 - Service 129",
  668.                         "82 - Service 130",
  669.                         "83 - Service 131",
  670.                         "84 - Service 132",
  671.                         "85 - Service 133",
  672.                         "86 - Service 134",
  673.                         "87 - Service 135",
  674.                         "88 - Service 136",
  675.                         "89 - WHOA!.COM",
  676.                         "8A - Service 138",
  677.                         "8B - Service 139",
  678.                         "8C - Service 140",
  679.                         "8D - Service 141",
  680.                         "8E - Service 142",
  681.                         "8F - Service 143",
  682.                         "90 - Service 144",
  683.                         "91 - Service 145",
  684.                         "92 - Service 146",
  685.                         "93 - Service 147",
  686.                         "94 - Service 148",
  687.                         "95 - Service 149",
  688.                         "96 - Service 150",
  689.                         "97 - Service 151",
  690.                         "98 - Service 152",
  691.                         "99 - Service 153",
  692.                         "9A - Service 154",
  693.                         "9B - Service 155",
  694.                         "9C - Service 156",
  695.                         "9D - Service 157",
  696.                         "9E - Service 158",
  697.                         "9F - Service 159",
  698.                         "A0 - Service 160",
  699.                         "A1 - Service 161",
  700.                         "A2 - Service 162",
  701.                         "A3 - Service 163",
  702.                         "A4 - Service 164",
  703.                         "A5 - Service 165",
  704.                         "A6 - Service 166",
  705.                         "A7 - Service 167",
  706.                         "A8 - Service 168",
  707.                         "A9 - Service 169",
  708.                         "AA - VIDCLOCK.COM",
  709.                         "AB - Service 171",
  710.                         "AC - Service 172",
  711.                         "AD - DISPLAY.SYS/KEYB.COM",
  712.                         "AE - COMMAND.COM installable cmds",
  713.                         "AF - Service 175",
  714.                         "B0 - GRAFTABL",
  715.                         "B1 - Service 177",
  716.                         "B2 - Service 178",
  717.                         "B3 - Service 179",
  718.                         "B4 - Service 180",
  719.                         "B5 - Service 181",
  720.                         "B6 - Service 182",
  721.                         "B7 - APPEND",
  722.                         "B8 - Network",
  723.                         "B9 - Service 185",
  724.                         "BA - Service 186",
  725.                         "BB - Service 187",
  726.                         "BC - Service 188",
  727.                         "BD - Service 189",
  728.                         "BE - Service 190",
  729.                         "BF - PC LAN Program",
  730.                         "C0 - Service 192",
  731.                         "C1 - Service 193",
  732.                         "C2 - Service 194",
  733.                         "C3 - Service 195",
  734.                         "C4 - Service 196",
  735.                         "C5 - Service 197",
  736.                         "C6 - Service 198",
  737.                         "C7 - Service 199",
  738.                         "C8 - Service 200",
  739.                         "C9 - Service 201",
  740.                         "CA - Service 202",
  741.                         "CB - Communicating App Spec",
  742.                         "CC - Service 204",
  743.                         "CD - Intel Image Processing Interface",
  744.                         "Undefined services"
  745.                       } ;
  746. char *ems_services[] = {"00 - Service 0",
  747.                         "01 - Service 1",
  748.                         "02 - Service 2",
  749.                         "03 - Service 3",
  750.                         "04 - Service 4",
  751.                         "05 - Service 5",
  752.                         "06 - Service 6",
  753.                         "07 - Service 7",
  754.                         "08 - Service 8",
  755.                         "09 - Service 9",
  756.                         "0A - Service 10",
  757.                         "0B - Service 11",
  758.                         "0C - Service 12",
  759.                         "0D - Service 13",
  760.                         "0E - Service 14",
  761.                         "0F - Service 15",
  762.                         "10 - Service 16",
  763.                         "11 - Service 17",
  764.                         "12 - Service 18",
  765.                         "13 - Service 19",
  766.                         "14 - Service 20",
  767.                         "15 - Service 21",
  768.                         "16 - Service 22",
  769.                         "17 - Service 23",
  770.                         "18 - Service 24",
  771.                         "19 - Service 25",
  772.                         "1A - Service 26",
  773.                         "1B - Service 27",
  774.                         "1C - Service 28",
  775.                         "1D - Service 29",
  776.                         "1E - Service 30",
  777.                         "1F - Service 31",
  778.                         "20 - Service 32",
  779.                         "21 - Service 33",
  780.                         "22 - Service 34",
  781.                         "23 - Service 35",
  782.                         "24 - Service 36",
  783.                         "25 - Service 37",
  784.                         "26 - Service 38",
  785.                         "27 - Service 39",
  786.                         "28 - Service 40",
  787.                         "29 - Service 41",
  788.                         "2A - Service 42",
  789.                         "2B - Service 43",
  790.                         "2C - Service 44",
  791.                         "2D - Service 45",
  792.                         "2E - Service 46",
  793.                         "2F - Service 47",
  794.                         "30 - Service 48",
  795.                         "31 - Service 49",
  796.                         "32 - Service 50",
  797.                         "33 - Service 51",
  798.                         "34 - Service 52",
  799.                         "35 - Service 53",
  800.                         "36 - Service 54",
  801.                         "37 - Service 55",
  802.                         "38 - Service 56",
  803.                         "39 - Service 57",
  804.                         "3A - Service 58",
  805.                         "3B - Service 59",
  806.                         "3C - Service 60",
  807.                         "3D - Service 61",
  808.                         "3E - Service 62",
  809.                         "3F - Service 63",
  810.                         "40 - Get manager status",
  811.                         "41 - Get page frame segment",
  812.                         "42 - Get number of pages",
  813.                         "43 - Get handle and allocate memory",
  814.                         "44 - Map memory",
  815.                         "45 - Release handle and memory",
  816.                         "46 - Get EMM version",
  817.                         "47 - Save mapping context",
  818.                         "48 - Restore mapping context",
  819.                         "49 - reserved - Get I/O port address",
  820.                         "4A - reserved - Get Translation Array",
  821.                         "4B - Get number of EMM handles",
  822.                         "4C - Get pages owned by handle",
  823.                         "4D - Get pages for all handles",
  824.                         "4E - Get or Set page map",
  825.                         "4F - Get/Set partial page map",
  826.                         "50 - Map/Unmap multiple handle pages",
  827.                         "51 - Reallocate pages",
  828.                         "52 - Get/Set handle attributes",
  829.                         "53 - Get/Set handle name",
  830.                         "54 - Get handle directory",
  831.                         "55 - Alter page map and jump",
  832.                         "56 - Alter page map and call",
  833.                         "57 - Move/Exchange memory region",
  834.                         "58 - Get mappable physical address array",
  835.                         "59 - Get expanded memory hardware information",
  836.                         "5A - Allocate standard/raw pages",
  837.                         "5B - Alternate map register set",
  838.                         "5C - Prepare for warm boot",
  839.                         "5D - Enable/Disable OS function set",
  840.                         "5E - Service 94",
  841.                         "5F - Service 95",
  842.                         "60 - EEMS: Get physical window array",
  843.                         "61 - EEMS: Generic accelerator card support",
  844.                         "62 - Service 98",
  845.                         "63 - Service 99",
  846.                         "64 - Service 100",
  847.                         "65 - Service 101",
  848.                         "66 - Service 102",
  849.                         "67 - Service 103",
  850.                         "68 - EEMS: Get addresses of all page frames",
  851.                         "69 - EEMS: Map page into frame",
  852.                         "6A - EEMS: Page mapping",
  853.                         "6B - Service 107",
  854.                         "undefined services"
  855.                        } ;
  856.  
  857. char **service_descriptions[NUM_INTS+1] = {other_services,
  858.                                            print_screen_services,
  859.                                            video_services,
  860.                                            disk_services,
  861.                                            comm_services,
  862.                                            sys_util_services,
  863.                                            keyboard_services,
  864.                                            printer_services,
  865.                                            dos_services,
  866.                                            disk_read_services,
  867.                                            disk_write_services,
  868.                                            network2A_services,
  869.                                            multiplex_services,
  870.                                            ems_services };
  871.  
  872. FILE *output_file;
  873.  
  874. main ( argc , argv )
  875. int argc;
  876. char *argv[];
  877. {
  878. union REGS registers;
  879. struct SREGS segregs;
  880. int function;
  881. int save_status;
  882. FILE *fopen();
  883. int int_number;
  884.  
  885. printf("\n\n(C) Copyright 1988 G. Kent Cobb - All Rights Reserved\n\tEnhanced by Ralf Brown\n");
  886. if (argc < 2)
  887.     error_exit();
  888.  
  889. if (stricmp(argv[1],"STATUS") == 0)
  890.     function = 0;
  891. else if (stricmp(argv[1],"OFF") == 0)
  892.     function = 1;
  893. else if (stricmp(argv[1],"ON") == 0)
  894.     function = 2;
  895. else if (stricmp(argv[1],"ZERO") == 0)
  896.     function = 4;
  897. else if (stricmp(argv[1],"REPORT") == 0)
  898.     function = 5;
  899. else
  900.     error_exit();
  901.  
  902.           /*  CHECK TO MAKE SURE THAT sys_prof HAS BEEN INSTALLED.  */
  903.  
  904. registers.h.ah = GET_INT_VECTOR;
  905. registers.h.al = CONTROL_INTERRUPT;
  906. int86x(DOS,®isters,®isters,&segregs);
  907. if ((registers.x.bx == 0) && (segregs.es == 0))
  908.     {
  909.     printf("\n\nSYS_PROF has not been installed.");
  910.     exit(2);
  911.     }
  912.  
  913. switch (function)
  914.     {
  915.  
  916. /*  IF TURNING PROFILER OFF OR ON, DROP THROUGH TO REPORT THE STATUS ALSO.  */
  917.  
  918.     case OFF:
  919.     case ON:
  920.         registers.h.ah = function;
  921.         int86(CONTROL_INTERRUPT,®isters,®isters);
  922.     case STATUS:
  923.         registers.h.ah = STATUS;
  924.         int86(CONTROL_INTERRUPT,®isters,®isters);
  925.         printf("\n\nProfiler is %s",(registers.x.ax == 0) ? "OFF" : "ON" );
  926.         break;
  927.     case ZERO:
  928.         registers.h.ah = function;
  929.         int86(CONTROL_INTERRUPT,®isters,®isters);
  930.         printf("\n\nProfiler tables re-initialized.");
  931.         break;
  932.     case REPORT:
  933.  
  934.                     /*  GET THE CURRENT PROFILER STATUS.  */
  935.  
  936.         registers.h.ah = STATUS;
  937.         int86(CONTROL_INTERRUPT,®isters,®isters);
  938.         save_status = registers.x.ax;
  939.  
  940.                      /*  TURN ACCUMULATION OFF FOR NOW.  */
  941.  
  942.         registers.h.ah = OFF;
  943.         int86(CONTROL_INTERRUPT,®isters,®isters);
  944.  
  945.                /*  GET THE ADDRESS OF THE ACCUMULATION TABLE.  */
  946.  
  947.         registers.h.ah = FIND;
  948.         int86x(CONTROL_INTERRUPT,®isters,®isters,&segregs);
  949.  
  950.               /*  OPEN THE FILE WHICH WILL CONTAIN THE OUTPUT.  */
  951.  
  952.         if (argc > 2)
  953.             {
  954.             if ((output_file = fopen(argv[2],"w")) == NULL)
  955.                 {
  956.                 printf("\n\nCannot open output file.");
  957.                 exit(2);
  958.                 }
  959.             }
  960.         else
  961.             output_file = stdprn;
  962.  
  963.                /*  CALCULATE THE TOTAL NUMBER OF TIMER TICKS.  */
  964.  
  965.         tally_total_ticks();
  966.  
  967.                          /*  PRINT OUT THE HEADERS.  */
  968.  
  969.         fprintf(output_file,
  970.         "                                         Number of      Number of    Percent of\n");
  971.         fprintf(output_file,
  972.         "             Service                    Occurrences    Timer ticks   Total Time\n");
  973.  
  974.                 /*  PRINT OUT A SUMMARY FOR EACH INTERRUPT.  */
  975.  
  976.         for (int_number = 1; int_number <= NUM_INTS; int_number++)
  977.             print_interrupt_summary(int_number,service_descriptions[int_number]);
  978.         print_interrupt_summary(0,service_descriptions[0]);
  979.  
  980.         fprintf(output_file,"\n\n");
  981.         fprintf(output_file,
  982.         "\n                          Total time: %ld timer ticks",total_ticks);
  983.         fprintf(output_file,
  984.                      "\n                                       %ld seconds\n",
  985.                                                      (long)(total_ticks/18.2));
  986.  
  987.         /*  IF ACCUMULATION WAS ON WHEN WE STARTED, TURN IT BACK ON.  */
  988.  
  989.         if (save_status != 0)
  990.             {
  991.             registers.h.ah = ON;
  992.             int86(CONTROL_INTERRUPT,®isters,®isters);
  993.             }
  994.  
  995.     default:
  996.  
  997.         break;
  998.     }  /*  END OF SWITCH (FUNCTION)  */
  999.  
  1000. exit(0);
  1001. }  /*  END OF MAIN  */
  1002.  
  1003. print_interrupt_summary ( int_number , descriptions )
  1004.  
  1005. int int_number;
  1006.  
  1007. char *descriptions[];
  1008. {
  1009. struct tally far *beginning_address , far *address;
  1010. int non_zero , service;
  1011. long total_time , total_number;
  1012. int idx;
  1013. union REGS registers;
  1014. struct SREGS segregs;
  1015.  
  1016.   /*  GET THE ADDRESS OF THE TABULATED DATA FOR THIS PARTICULAR INTERRUPT.  */
  1017.  
  1018. registers.h.ah = FIND;
  1019. int86x(CONTROL_INTERRUPT,®isters,®isters,&segregs);
  1020. #ifdef __TURBOC__
  1021.    beginning_address = MK_FP(segregs.es,registers.x.bx) ;
  1022. #else
  1023.    FP_SEG(beginning_address) = segregs.es;
  1024.    FP_OFF(beginning_address) = registers.x.bx;
  1025. #endif __TURBOC__
  1026. for (idx = 0; idx < int_number; idx++)
  1027.     beginning_address += (1+max_services[idx]);
  1028.  
  1029.    /*  CALCULATE THE TOTAL NUMBER OF TIMER TICKS SPENT IN THIS INTERRUPT.  */
  1030.  
  1031. for (service = 0 , total_number = 0L , address = beginning_address;
  1032.                    service <= max_services[int_number]; address++ , service++)
  1033.     total_number += address->number;
  1034.  
  1035.           /*  DON'T PRINT ANYTHING IF THIS INTERRUPT WAS NOT USED.  */
  1036.  
  1037. if (total_number == 0)
  1038.     return;
  1039.  
  1040.              /*  PRINT OUT THE HEADER DESCRIBING THE INTERRUPT.  */
  1041.  
  1042. fprintf(output_file,"\n\n%s\n",int_desc[int_number]);
  1043.  
  1044.             /*  NOW PRINT OUT THE INFORMATION FOR EACH SERVICE.  */
  1045.  
  1046. for (service = 0 , total_time = 0L , address = beginning_address , non_zero = 0;
  1047.                      service <= max_services[int_number]; address++ , service++)
  1048.     {
  1049.     if (address->number != 0)
  1050.         {
  1051.         print_line(descriptions[service],address->number,address->time);
  1052.         non_zero++;
  1053.         }
  1054.     total_time += address->time;
  1055.     }
  1056.  
  1057.  /*  AFTER DETAILING EACH SERVICE, PRINT OUT THE SUMMARY FOR ALL SERVICES.  */
  1058.  
  1059. if (non_zero > 1)
  1060.     print_line("TOTAL",total_number,total_time);
  1061.  
  1062. return;
  1063. }  /*  END OF PRINT_INTERRUPT_SUMMARY  */
  1064.  
  1065. print_line ( title , number , duration )
  1066. char *title;
  1067. long number;
  1068. long duration;
  1069. {
  1070. char string[120];
  1071. static char blanks[40] = "                                       ";
  1072.  
  1073. sprintf(string,"\n     %s",title);
  1074. strcat(string,blanks);
  1075. string[40] = END_OF_STRING;
  1076. sprintf(&string[40],"%8ld        %8ld        %5.2f",number,duration,
  1077.                                              (float)(100*duration)/total_ticks);
  1078. fputs(string,output_file);
  1079. return;
  1080. }  /*  END OF PRINT_LINE  */
  1081.  
  1082. tally_total_ticks()
  1083. {
  1084. struct tally far *ptr;
  1085. union REGS registers;
  1086. struct SREGS segregs;
  1087. int idx , total_services;
  1088.  
  1089.                   /*  CALCULATE THE TOTAL NUMBER OF BINS.  */
  1090.  
  1091. for (idx = 0 , total_services = 0; idx <= NUM_INTS; idx++)
  1092.     total_services += (1+max_services[idx]);
  1093.  
  1094.                      /*  GET THE ADDRESS OF THE TABLE.  */
  1095.  
  1096. registers.h.ah = FIND;
  1097. int86x(CONTROL_INTERRUPT,®isters,®isters,&segregs);
  1098. #ifdef __TURBOC__
  1099.    ptr = MK_FP(segregs.es,registers.x.bx) ;
  1100. #else
  1101.    FP_SEG(ptr) = segregs.es;
  1102.    FP_OFF(ptr) = registers.x.bx;
  1103. #endif __TURBOC__
  1104.  
  1105. for (idx = 0 , total_ticks = 0; idx < total_services; idx++ , ptr++)
  1106.     total_ticks += ptr->time;
  1107.  
  1108. return;
  1109. }  /*  END OF TALLY_TOTAL_TICKS  */
  1110.  
  1111. error_exit()
  1112.  
  1113. {
  1114. printf("\n\nProper syntax is:\n\n               ");
  1115. printf("PROFCTRL STATUS | OFF | ON | ZERO | REPORT");
  1116. exit(1);
  1117. }  /*  END OF ERROR_EXIT  */
  1118.  
  1119.  
  1120.