#include "is.h"
-#define NHOOKS 17
+#define NHOOKS 18
struct hook_entry {
int key;
{ SF4, dtab_dmp, "Device/Driver mapping" },
{ SF5, mapping_dmp, "Print key mappings" },
{ SF6, rproc_dmp, "Reincarnation server process table" },
+ { SF7, holes_dmp, "Memory free list" },
};
/*===========================================================================*
if (OK != (s=sendrec(TTY_PROC_NR, m)))
report("IS", "warning, sendrec to TTY failed", s);
- /* Now check which keys were pressed: F1-F12. */
+ /* Now check which keys were pressed: F1-F12, SF1-SF12. */
for(h = 0; h < NHOOKS; h++)
if(pressed(hooks[h].key))
hooks[h].function();
#include "is.h"
#include "../pm/mproc.h"
#include <timers.h>
+#include <minix/config.h>
+#include <minix/type.h>
PUBLIC struct mproc mproc[NR_PROCS];
prev_i = i;
}
+/*===========================================================================*
+ * holes_dmp *
+ *===========================================================================*/
+PUBLIC void holes_dmp(void)
+{
+ static struct hole holes[_NR_HOLES];
+ int h;
+ int largest_bytes = 0, total_bytes = 0;
+
+ if(getsysinfo(PM_PROC_NR, SI_MEM_ALLOC, holes) != OK) {
+ printf("Obtaining memory hole list failed.\n");
+ return;
+ }
+ printf("Available memory stats\n");
+
+ for(h = 0; h < _NR_HOLES; h++) {
+ if(holes[h].h_base && holes[h].h_len) {
+ int bytes;
+ bytes = (holes[h].h_len << CLICK_SHIFT);
+ printf("%08lx: %6d kB\n",
+ holes[h].h_base << CLICK_SHIFT, bytes / 1024);
+ if(bytes > largest_bytes) largest_bytes = bytes;
+ total_bytes += bytes;
+ }
+ }
+ printf("\nTotal memory free: %d kB\n"
+ "Largest contiguous chunk: %d kB\n"
+ "Uncontiguous rest: %d kB (%d%% of total free)\n",
+ total_bytes/1024,
+ largest_bytes/1024,
+ (total_bytes-largest_bytes)/1024,
+ 100*(total_bytes/100-largest_bytes/100)/total_bytes);
+
+ return;
+}
+
/* Set key mappings. IS takes all of F1-F12 and Shift+F1-F6. */
fkeys = sfkeys = 0;
for (i=1; i<=12; i++) bit_set(fkeys, i);
- for (i=1; i<= 6; i++) bit_set(sfkeys, i);
+ for (i=1; i<= 7; i++) bit_set(sfkeys, i);
if ((s=fkey_map(&fkeys, &sfkeys)) != OK)
report("IS", "warning, fkey_map failed:", s);
}
*/
fkeys = sfkeys = 0;
for (i=1; i<=12; i++) bit_set(fkeys, i);
- for (i=1; i<= 6; i++) bit_set(sfkeys, i);
+ for (i=1; i<= 7; i++) bit_set(sfkeys, i);
if ((s=fkey_unmap(&fkeys, &sfkeys)) != OK)
report("IS", "warning, unfkey_map failed:", s);
/* dmp_pm.c */
_PROTOTYPE( void mproc_dmp, (void) );
_PROTOTYPE( void sigaction_dmp, (void) );
+_PROTOTYPE( void holes_dmp, (void) );
/* dmp_fs.c */
_PROTOTYPE( void dtab_dmp, (void) );
* free_mem: release a previously allocated chunk of memory
* mem_init: initialize the tables when PM start up
* max_hole: returns the largest hole currently available
+ * mem_holes_copy: for outsiders who want a copy of the hole-list
*/
#include "pm.h"
#include <minix/com.h>
#include <minix/callnr.h>
+#include <minix/type.h>
+#include <minix/config.h>
#include <signal.h>
#include <stdlib.h>
+#include <string.h>
#include "mproc.h"
#include "../../kernel/const.h"
#include "../../kernel/config.h"
#include "../../kernel/type.h"
-#define NR_HOLES (2*NR_PROCS) /* max # entries in hole table */
#define NIL_HOLE (struct hole *) 0
-PRIVATE struct hole {
- struct hole *h_next; /* pointer to next entry on the list */
- phys_clicks h_base; /* where does the hole begin? */
- phys_clicks h_len; /* how big is the hole? */
-} hole[NR_HOLES];
+PRIVATE struct hole hole[_NR_HOLES];
PRIVATE struct hole *hole_head; /* pointer to first hole */
PRIVATE struct hole *free_slots;/* ptr to list of unused table slots */
prev_ptr->h_next = hp->h_next;
hp->h_next = free_slots;
+ hp->h_base = hp->h_len = 0;
free_slots = hp;
}
register struct hole *hp;
/* Put all holes on the free list. */
- for (hp = &hole[0]; hp < &hole[NR_HOLES]; hp++) hp->h_next = hp + 1;
- hole[NR_HOLES-1].h_next = NIL_HOLE;
+ for (hp = &hole[0]; hp < &hole[_NR_HOLES]; hp++) {
+ hp->h_next = hp + 1;
+ hp->h_base = hp->h_len = 0;
+ }
+ hole[_NR_HOLES-1].h_next = NIL_HOLE;
hole_head = NIL_HOLE;
free_slots = &hole[0];
#endif
}
+/*===========================================================================*
+ * mem_holes_copy *
+ *===========================================================================*/
+PUBLIC int mem_holes_copy(struct hole *holecopies, size_t *bytes)
+{
+ if(*bytes < sizeof(hole)) return ENOSPC;
+ memcpy(holecopies, hole, sizeof(hole));
+ *bytes = sizeof(hole);
+ return OK;
+}
+
#if ENABLE_SWAP
/*===========================================================================*
* swap_on *
#include <sys/svrctl.h>
#include <sys/resource.h>
#include <minix/com.h>
+#include <minix/config.h>
+#include <minix/type.h>
#include <string.h>
#include "mproc.h"
#include "param.h"
vir_bytes src_addr, dst_addr;
struct kinfo kinfo;
size_t len;
- int s;
+ static struct hole holes[_NR_HOLES];
+ int s, r;
+ size_t holesize;
switch(m_in.info_what) {
case SI_KINFO: /* kernel info is obtained via PM */
src_addr = (vir_bytes) mproc;
len = sizeof(struct mproc) * NR_PROCS;
break;
+ case SI_MEM_ALLOC:
+ holesize = sizeof(holes);
+ if((r=mem_holes_copy(holes, &holesize)) != OK) return r;
+ src_addr = (vir_bytes) holes;
+ len = holesize;
+ break;
default:
return(EINVAL);
}
#define swap_in() ((void)0)
#define swap_inqueue(rmp) ((void)0)
#endif /* !SWAP */
+_PROTOTYPE(int mem_holes_copy, (struct hole *, size_t *) );
/* break.c */
_PROTOTYPE( int adjust, (struct mproc *rmp,