drop safemap code
[minix.git] / servers / is / dmp.c
blobbbae0f81c1389c2ca057df43432ab4c0c8c97b5b
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 map_unmap_fkeys(map)
46 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(k) ((F1<=(k)&&(k)<=F12 && bit_isset(m->FKEY_FKEYS,((k)-F1+1)))\
71 || (SF1<=(k) && (k)<=SF12 && bit_isset(m->FKEY_SFKEYS, ((k)-SF1+1))))
72 int do_fkey_pressed(m)
73 message *m; /* notification message */
75 int s, h;
77 /* The notification message does not convey any information, other
78 * than that some function keys have been pressed. Ask TTY for details.
80 m->m_type = FKEY_CONTROL;
81 m->FKEY_REQUEST = FKEY_EVENTS;
82 if (OK != (s=sendrec(TTY_PROC_NR, m)))
83 printf("IS: warning, sendrec to TTY failed: %d\n", s);
85 /* Now check which keys were pressed: F1-F12, SF1-SF12. */
86 for(h=0; h < NHOOKS; h++)
87 if(pressed(hooks[h].key))
88 hooks[h].function();
90 /* Don't send a reply message. */
91 return(EDONTREPLY);
94 /*===========================================================================*
95 * key_name *
96 *===========================================================================*/
97 static char *key_name(int key)
99 static char name[15];
101 if(key >= F1 && key <= F12)
102 snprintf(name, sizeof(name), " F%d", key - F1 + 1);
103 else if(key >= SF1 && key <= SF12)
104 snprintf(name, sizeof(name), "Shift+F%d", key - SF1 + 1);
105 else
106 strlcpy(name, "?", sizeof(name));
107 return name;
111 /*===========================================================================*
112 * mapping_dmp *
113 *===========================================================================*/
114 void mapping_dmp(void)
116 int h;
118 printf("Function key mappings for debug dumps in IS server.\n");
119 printf(" Key Description\n");
120 printf("-------------------------------------");
121 printf("------------------------------------\n");
123 for(h=0; h < NHOOKS; h++)
124 printf(" %10s. %s\n", key_name(hooks[h].key), hooks[h].name);
125 printf("\n");