[comp.os.minix] MacMinix kernel/memory.c bug fix

drew@everexn.com (Drew Rogge) (12/22/90)

I haven't seen a fix for this on the net yet so here goes...
Below you'll find a patch to MacMinix kernel/memory.c. This patch
fixes the problem which causes 'ps' gives the error message:

    Can't get kernel proc table from /dev/kmem: Error 0

The problem is that 'sizes' is an array of unsigned shorts and
the addition of sizes[0] and sizes[1] (in my case sizes[0] == 287 and
sizes[1] == 225) yields an unsigned short ( == 512) which, when shifted
over by CLICK_SHIFT (8), turns out to be 0... So much for the size
of kernel memory. Note that this problem is very dependent on the
size of the kernel I&D space. If either of the code or data sizes
of my kernal had been one click smaller, then the problem wouldn't
have appeared.

Hope this helps someone out.

Drew Rogge
...!uunet!everexn!drew

--- cut here ---
*** memory.c	Thu Dec 20 21:23:55 1990
--- memory.c00	Thu Dec 20 21:24:50 1990
***************
*** 52,58 ****
  
    /* Initialize this task. */
    ram_origin[KMEM_DEV] = code_base;
!   ram_limit[KMEM_DEV]  = code_base + (((phys_bytes)(sizes[0] + sizes[1])) << CLICK_SHIFT);
  #if (CHIP == INTEL)
    if (!protected_mode)
  	ram_limit[MEM_DEV] = 0x100000;	/* above 1M em_xfer word count fails */
--- 52,58 ----
  
    /* Initialize this task. */
    ram_origin[KMEM_DEV] = code_base;
!   ram_limit[KMEM_DEV]  = code_base + ((sizes[0] + sizes[1]) << CLICK_SHIFT);
  #if (CHIP == INTEL)
    if (!protected_mode)
  	ram_limit[MEM_DEV] = 0x100000;	/* above 1M em_xfer word count fails */
--- end of patch ---