c73b70eec4
- Implement a new copyin/readin interface for loading modules. This allows the module loaders to become MI, reducing code duplication. - Simplify the search for an image activator for the loaded kernel. - Use the common module management code for all module metadata. - Add an 'unload' command that throws everything away. - Move the a.out module loader to MI code, add support for a.out kld modules. Submitted by: Alpha changes fixed by Doug Rabson <dfr@freebsd.org>
47 lines
814 B
C
47 lines
814 B
C
/*
|
|
* mjs copyright
|
|
*/
|
|
/*
|
|
* MD primitives supporting placement of module data
|
|
*
|
|
* XXX should check load address/size against memory top.
|
|
*/
|
|
#include <stand.h>
|
|
|
|
#include "libi386.h"
|
|
|
|
#define READIN_BUF 4096
|
|
|
|
int
|
|
i386_copyin(void *src, vm_offset_t dest, size_t len)
|
|
{
|
|
vpbcopy(src, dest, len);
|
|
return(len);
|
|
}
|
|
|
|
int
|
|
i386_readin(int fd, vm_offset_t dest, size_t len)
|
|
{
|
|
void *buf;
|
|
size_t resid, chunk, get, got;
|
|
|
|
chunk = min(READIN_BUF, len);
|
|
buf = malloc(chunk);
|
|
if (buf == NULL)
|
|
return(0);
|
|
|
|
for (resid = len; resid > 0; resid -= got, dest += got) {
|
|
get = min(chunk, resid);
|
|
got = read(fd, buf, get);
|
|
if (got <= 0)
|
|
break;
|
|
vpbcopy(buf, dest, chunk);
|
|
}
|
|
free(buf);
|
|
if (resid != 0)
|
|
printf("i386_readin: %d bytes short\n", resid);
|
|
return(len - resid);
|
|
}
|
|
|
|
|