make includes fix from trunk
[minix.git] / servers / is / dmp.c
blobdfe123d3b6b8c4067acb0c011ab0160a52e3f265
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 { F2, memmap_dmp, "Process memory maps" },
21 { F3, image_dmp, "System image" },
22 { F4, privileges_dmp, "Process privileges" },
23 { F5, monparams_dmp, "Boot monitor parameters" },
24 { F6, irqtab_dmp, "IRQ hooks and policies" },
25 { F7, kmessages_dmp, "Kernel messages" },
26 { F8, vm_dmp, "VM status and process maps" },
27 { F10, kenv_dmp, "Kernel parameters" },
28 { F11, timing_dmp, "Timing details (if enabled)" },
29 { SF1, mproc_dmp, "Process manager process table" },
30 { SF2, sigaction_dmp, "Signals" },
31 { SF3, fproc_dmp, "Filesystem process table" },
32 { SF4, dtab_dmp, "Device/Driver mapping" },
33 { SF5, mapping_dmp, "Print key mappings" },
34 { SF6, rproc_dmp, "Reincarnation server process table" },
35 { SF8, data_store_dmp, "Data store contents" },
36 { SF9, procstack_dmp, "Processes with stack traces" },
39 /* Define hooks for the debugging dumps. This table maps function keys
40 * onto a specific dump and provides a description for it.
42 #define NHOOKS (sizeof(hooks)/sizeof(hooks[0]))
44 /*===========================================================================*
45 * map_unmap_keys *
46 *===========================================================================*/
47 PUBLIC void map_unmap_fkeys(map)
48 int map;
50 int fkeys, sfkeys;
51 int h, s;
53 fkeys = sfkeys = 0;
55 for (h = 0; h < NHOOKS; h++) {
56 if (hooks[h].key >= F1 && hooks[h].key <= F12)
57 bit_set(fkeys, hooks[h].key - F1 + 1);
58 else if (hooks[h].key >= SF1 && hooks[h].key <= SF12)
59 bit_set(sfkeys, hooks[h].key - SF1 + 1);
62 if (map) s = fkey_map(&fkeys, &sfkeys);
63 else s = fkey_unmap(&fkeys, &sfkeys);
65 if (s != OK)
66 printf("IS: warning, fkey_ctl failed: %d\n", s);
69 /*===========================================================================*
70 * handle_fkey *
71 *===========================================================================*/
72 #define pressed(k) ((F1<=(k)&&(k)<=F12 && bit_isset(m->FKEY_FKEYS,((k)-F1+1)))\
73 || (SF1<=(k) && (k)<=SF12 && bit_isset(m->FKEY_SFKEYS, ((k)-SF1+1))))
74 PUBLIC int do_fkey_pressed(m)
75 message *m; /* notification message */
77 int s, h;
79 /* The notification message does not convey any information, other
80 * than that some function keys have been pressed. Ask TTY for details.
82 m->m_type = FKEY_CONTROL;
83 m->FKEY_REQUEST = FKEY_EVENTS;
84 if (OK != (s=sendrec(TTY_PROC_NR, m)))
85 printf("IS: warning, sendrec to TTY 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(hooks[h].key))
90 hooks[h].function();
92 /* Don't send a reply message. */
93 return(EDONTREPLY);
96 /*===========================================================================*
97 * key_name *
98 *===========================================================================*/
99 PRIVATE char *key_name(int key)
101 static char name[15];
103 if(key >= F1 && key <= F12)
104 sprintf(name, " F%d", key - F1 + 1);
105 else if(key >= SF1 && key <= SF12)
106 sprintf(name, "Shift+F%d", key - SF1 + 1);
107 else
108 sprintf(name, "?");
109 return name;
113 /*===========================================================================*
114 * mapping_dmp *
115 *===========================================================================*/
116 PUBLIC void mapping_dmp(void)
118 int h;
120 printf("Function key mappings for debug dumps in IS server.\n");
121 printf(" Key Description\n");
122 printf("-------------------------------------");
123 printf("------------------------------------\n");
125 for(h=0; h < NHOOKS; h++)
126 printf(" %10s. %s\n", key_name(hooks[h].key), hooks[h].name);
127 printf("\n");