freebsd-dev/sys/boot/i386/libi386/i386_copy.c
Mike Smith c73b70eec4 Bootloader update.
- 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>
1998-08-31 21:10:43 +00:00

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);
}