bl@cunixa.cc.columbia.edu (Bernard lin) (04/15/91)
The following code is from kernel/system.c. I was trying to find
out how the hole list was constructed by examining the code, I saw
that the hole list entries are constrained by the 64K segment barrier.
I was able to track down (we think) where MINIX was checking whether
the chunk is overlapping the 64K barrier, but I was not sure exactly
how the code works. The sequence of calls from alloc.c is as follows:
mm/alloc.c mem_init() to mm/main.c get_mem() to a SYS_TASK call to
kernel/system.c do_mem().
/*===========================================================================*
* do_mem *
*===========================================================================*/
PRIVATE int do_mem(m_ptr)
register message *m_ptr; /* pointer to request message */
{
/* Return the base and size of the next chunk of memory of a given type. */
#if (CHIP == INTEL)
unsigned mem;
for (mem = 0; mem < NR_MEMS; ++mem) {
if (mem_type[mem] & 0x80) {
mem_size[mem] = check_mem((phys_bytes) mem_base[mem]<<CLICK_SHIFT,
(phys_bytes) mem_size[mem]<<CLICK_SHIFT)
>> CLICK_SHIFT;
mem_type[mem] &= ~0x80;
}
if (mem_size[mem] != 0 && m_ptr->DEVICE == mem_type[mem]) {
m_ptr->COUNT = mem_size[mem];
m_ptr->POSITION = mem_base[mem];
mem_size[mem] = 0; /* now MM has it */
return(OK);
}
}
m_ptr->COUNT = 0; /* no more */
#endif /* (CHIP == INTEL) */
#if (MACHINE == ATARI)
long i;
static int beenhere = 0;
if (beenhere)
m_ptr->COUNT = 0;
else {
/* The ST fills address 0x0436 with the memory size when starting. */
phys_copy((phys_bytes)0x0436, (phys_bytes)&i, (phys_bytes)sizeof(i));
m_ptr->COUNT = i >> CLICK_SHIFT;
beenhere++;
}
#endif /* (MACHINE == ATARI) */
m_ptr->POSITION = 0;
return(OK);
}
/bl