Remove building with NOCRYPTO option
[minix.git] / minix / servers / is / dmp.c
blob487f97e6e83c834c9267d041cf6b1e70d949e6a7
1 /* This file contains information dump procedures. During the initialization
2 * of the Information Service 'known' function keys are registered at the TTY
3 * server in order to receive a notification if one is pressed. Here, the
4 * corresponding dump procedure is called.
6 * The entry points into this file are
7 * map_unmap_fkeys: register or unregister function key maps with TTY
8 * do_fkey_pressed: handle a function key pressed notification
9 */
11 #include "inc.h"
12 #include <minix/vm.h>
14 struct hook_entry {
15 int key;
16 void (*function)(void);
17 char *name;
18 } hooks[] = {
19 { F1, proctab_dmp, "Kernel process table" },
20 { F3, image_dmp, "System image" },
21 { F4, privileges_dmp, "Process privileges" },
22 { F5, monparams_dmp, "Boot monitor parameters" },
23 { F6, irqtab_dmp, "IRQ hooks and policies" },
24 { F7, kmessages_dmp, "Kernel messages" },
25 { F8, vm_dmp, "VM status and process maps" },
26 { F10, kenv_dmp, "Kernel parameters" },
27 { SF1, mproc_dmp, "Process manager process table" },
28 { SF2, sigaction_dmp, "Signals" },
29 { SF3, fproc_dmp, "Filesystem process table" },
30 { SF4, dtab_dmp, "Device/Driver mapping" },
31 { SF5, mapping_dmp, "Print key mappings" },
32 { SF6, rproc_dmp, "Reincarnation server process table" },
33 { SF8, data_store_dmp, "Data store contents" },
34 { SF9, procstack_dmp, "Processes with stack traces" },
37 /* Define hooks for the debugging dumps. This table maps function keys
38 * onto a specific dump and provides a description for it.
40 #define NHOOKS (sizeof(hooks)/sizeof(hooks[0]))
42 /*===========================================================================*
43 * map_unmap_keys *
44 *===========================================================================*/
45 void
46 map_unmap_fkeys(int map)
48 int fkeys, sfkeys;
49 int h, s;
51 fkeys = sfkeys = 0;
53 for (h = 0; h < NHOOKS; h++) {
54 if (hooks[h].key >= F1 && hooks[h].key <= F12)
55 bit_set(fkeys, hooks[h].key - F1 + 1);
56 else if (hooks[h].key >= SF1 && hooks[h].key <= SF12)
57 bit_set(sfkeys, hooks[h].key - SF1 + 1);
60 if (map) s = fkey_map(&fkeys, &sfkeys);
61 else s = fkey_unmap(&fkeys, &sfkeys);
63 if (s != OK)
64 printf("IS: warning, fkey_ctl failed: %d\n", s);
67 /*===========================================================================*
68 * handle_fkey *
69 *===========================================================================*/
70 #define pressed(start, end, bitfield, key) \
71 (((start) <= (key)) && ((end) >= (key)) && \
72 bit_isset((bitfield), ((key) - (start) + 1)))
73 int do_fkey_pressed(m)
74 message *m; /* notification message */
76 int s, h;
77 int fkeys, sfkeys;
79 /* The notification message does not convey any information, other
80 * than that some function keys have been pressed. Ask TTY for details.
82 s = fkey_events(&fkeys, &sfkeys);
83 if (s < 0) {
84 printf("IS: warning, fkey_events failed: %d\n", s);
87 /* Now check which keys were pressed: F1-F12, SF1-SF12. */
88 for(h=0; h < NHOOKS; h++) {
89 if (pressed(F1, F12, fkeys, hooks[h].key)) {
90 hooks[h].function();
91 } else if (pressed(SF1, SF12, sfkeys, hooks[h].key)) {
92 hooks[h].function();
96 /* Don't send a reply message. */
97 return(EDONTREPLY);
100 /*===========================================================================*
101 * key_name *
102 *===========================================================================*/
103 static char *key_name(int key)
105 static char name[15];
107 if(key >= F1 && key <= F12)
108 snprintf(name, sizeof(name), " F%d", key - F1 + 1);
109 else if(key >= SF1 && key <= SF12)
110 snprintf(name, sizeof(name), "Shift+F%d", key - SF1 + 1);
111 else
112 strlcpy(name, "?", sizeof(name));
113 return name;
117 /*===========================================================================*
118 * mapping_dmp *
119 *===========================================================================*/
120 void mapping_dmp(void)
122 int h;
124 printf("Function key mappings for debug dumps in IS server.\n");
125 printf(" Key Description\n");
126 printf("-------------------------------------");
127 printf("------------------------------------\n");
129 for(h=0; h < NHOOKS; h++)
130 printf(" %10s. %s\n", key_name(hooks[h].key), hooks[h].name);
131 printf("\n");