|
|
researchv9-SUN3
#define DUMMY(x) x(){ panic("x"); }
DUMMY(dumpsys)
#include "../h/param.h"
#include "../h/callout.h"
#include "../h/map.h"
/*
* untimeout is called to remove a function timeout call
* from the callout structure.
*/
untimeout(fun, arg)
int (*fun)();
caddr_t arg;
{
register struct callout *p1, *p2;
register int s;
s = splclock();
for (p1 = &calltodo; (p2 = p1->c_next) != 0; p1 = p2) {
if (p2->c_func == fun && p2->c_arg == arg) {
if (p2->c_next && p2->c_time > 0)
p2->c_next->c_time += p2->c_time;
p1->c_next = p2->c_next;
p2->c_next = callfree;
callfree = p2;
break;
}
}
(void) splx(s);
}
/*
* Allocate 'size' units from the given map, starting at address 'addr'.
* Return 'addr' if successful, 0 if not.
* This may cause the creation or destruction of a resource map segment.
*
* This routine will return failure status if there is not enough room
* for a required additional map segment.
*
* An attempt to use this on 'swapmap' will result in
* a failure return. This is due mainly to laziness and could be fixed
* to do the right thing, although it probably will never be used.
*/
rmget(mp, size, addr)
register struct map *mp;
{
register struct mapent *ep = (struct mapent *)(mp+1);
register struct mapent *bp, *bp2;
if (size <= 0)
panic("rmget");
if (mp == swapmap)
return (0);
/*
* Look for a map segment containing the requested address.
* If none found, return failure.
*/
for (bp = ep; bp->m_size; bp++)
if (bp->m_addr <= addr && bp->m_addr + bp->m_size > addr)
break;
if (bp->m_size == 0)
return (0);
/*
* If segment is too small, return failure.
* If big enough, allocate the block, compressing or expanding
* the map as necessary.
*/
if (bp->m_addr + bp->m_size < addr + size)
return (0);
if (bp->m_addr == addr)
if (bp->m_addr + bp->m_size == addr + size) {
/*
* Allocate entire segment and compress map
*/
bp2 = bp;
while (bp2->m_size) {
bp2++;
(bp2-1)->m_addr = bp2->m_addr;
(bp2-1)->m_size = bp2->m_size;
}
} else {
/*
* Allocate first part of segment
*/
bp->m_addr += size;
bp->m_size -= size;
}
else
if (bp->m_addr + bp->m_size == addr + size) {
/*
* Allocate last part of segment
*/
bp->m_size -= size;
} else {
/*
* Allocate from middle of segment, but only
* if table can be expanded.
*/
for (bp2=bp; bp2->m_size; bp2++)
;
if (bp2 == mp->m_limit)
return (0);
while (bp2 > bp) {
(bp2+1)->m_addr = bp2->m_addr;
(bp2+1)->m_size = bp2->m_size;
bp2--;
}
(bp+1)->m_addr = addr + size;
(bp+1)->m_size =
bp->m_addr + bp->m_size - (addr + size);
bp->m_size = addr - bp->m_addr;
}
return (addr);
}
/*
* Set the local ethernet address
*/
localetheraddr(f, t)
u_char *f, *t;
{
static first = 1;
static u_char ether[6];
if (first && f) {
first = 0;
bcopy(f, ether, 6);
printf("Ethernet address = ");
printf("%x:%x:%x:%x:%x:%x\n",
f[0], f[1], f[2], f[3], f[4], f[5]);
}
if (t)
bcopy(ether, t, 6);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.