Add a new VM map, lkm_map, which machine-dependent code can provide
in the event that it needs to use a special VM range (x86_64 falls into this category). We fall back onto kernel_map if machine-dependent code doesn't create a special map.
This commit is contained in:
parent
6596b29802
commit
80f8dbe30a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: init_main.c,v 1.209 2002/10/23 09:14:12 jdolecek Exp $ */
|
||||
/* $NetBSD: init_main.c,v 1.210 2002/11/05 01:24:35 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.209 2002/10/23 09:14:12 jdolecek Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.210 2002/11/05 01:24:35 thorpej Exp $");
|
||||
|
||||
#include "fs_nfs.h"
|
||||
#include "opt_nfsserver.h"
|
||||
|
@ -103,6 +103,9 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.209 2002/10/23 09:14:12 jdolecek Exp
|
|||
#ifndef PIPE_SOCKETPAIR
|
||||
#include <sys/pipe.h>
|
||||
#endif
|
||||
#ifdef LKM
|
||||
#include <sys/lkm.h>
|
||||
#endif
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
@ -236,6 +239,11 @@ main(void)
|
|||
*/
|
||||
procinit();
|
||||
|
||||
#ifdef LKM
|
||||
/* Initialize the LKM system. */
|
||||
lkm_init();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create process 0 (the swapper).
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_lkm.c,v 1.61 2002/10/23 09:14:19 jdolecek Exp $ */
|
||||
/* $NetBSD: kern_lkm.c,v 1.62 2002/11/05 01:24:36 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.61 2002/10/23 09:14:19 jdolecek Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.62 2002/11/05 01:24:36 thorpej Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
|
@ -69,6 +69,11 @@ __KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.61 2002/10/23 09:14:19 jdolecek Exp $
|
|||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
struct vm_map *lkm_map;
|
||||
|
||||
#define LKM_SPACE_ALLOC(size) uvm_km_alloc(lkm_map, (size))
|
||||
#define LKM_SPACE_FREE(addr, size) uvm_km_free(lkm_map, (addr), (size))
|
||||
|
||||
#if !defined(DEBUG) && defined(LKMDEBUG)
|
||||
# define DEBUG
|
||||
#endif
|
||||
|
@ -118,6 +123,17 @@ const struct cdevsw lkm_cdevsw = {
|
|||
nostop, notty, nopoll, nommap, nokqfilter,
|
||||
};
|
||||
|
||||
void
|
||||
lkm_init(void)
|
||||
{
|
||||
/*
|
||||
* If machine-dependent code hasn't initialized the lkm_map
|
||||
* then just use kernel_map.
|
||||
*/
|
||||
if (lkm_map == NULL)
|
||||
lkm_map = kernel_map;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
lkmopen(dev, flag, devtype, p)
|
||||
|
@ -169,14 +185,14 @@ lkmunreserve()
|
|||
#ifdef DDB
|
||||
db_del_symbol_table(curp->private.lkm_any->lkm_name);
|
||||
#endif
|
||||
uvm_km_free(kernel_map, curp->syms, curp->sym_size);/**/
|
||||
LKM_SPACE_FREE(curp->syms, curp->sym_size);
|
||||
curp->syms = 0;
|
||||
}
|
||||
/*
|
||||
* Actually unreserve the memory
|
||||
*/
|
||||
if (curp && curp->area) {
|
||||
uvm_km_free(kernel_map, curp->area, curp->size);/**/
|
||||
LKM_SPACE_FREE(curp->area, curp->size);
|
||||
curp->area = 0;
|
||||
}
|
||||
lkm_state = LKMS_IDLE;
|
||||
|
@ -263,7 +279,7 @@ lkmioctl(dev, cmd, data, flag, p)
|
|||
*/
|
||||
curp->size = resrvp->size;
|
||||
|
||||
curp->area = uvm_km_alloc(kernel_map, curp->size);/**/
|
||||
curp->area = LKM_SPACE_ALLOC(curp->size);
|
||||
|
||||
curp->offset = 0; /* load offset */
|
||||
|
||||
|
@ -272,7 +288,7 @@ lkmioctl(dev, cmd, data, flag, p)
|
|||
if (cmd == LMRESERV && resrvp->sym_size) {
|
||||
curp->sym_size = resrvp->sym_size;
|
||||
curp->sym_symsize = resrvp->sym_symsize;
|
||||
curp->syms = (u_long)uvm_km_alloc(kernel_map, curp->sym_size);/**/
|
||||
curp->syms = (u_long) LKM_SPACE_ALLOC(curp->sym_size);
|
||||
curp->sym_offset = 0;
|
||||
resrvp->sym_addr = curp->syms; /* ret symbol addr */
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lkm.h,v 1.24 2002/09/18 22:59:36 lha Exp $ */
|
||||
/* $NetBSD: lkm.h,v 1.25 2002/11/05 01:24:38 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Header file used by loadable kernel modules and loadable kernel module
|
||||
|
@ -296,6 +296,9 @@ extern int lkmdispatch __P((struct lkm_table *, int));
|
|||
} \
|
||||
return lkmdispatch(lkmtp, cmd);
|
||||
|
||||
extern struct vm_map *lkm_map;
|
||||
void lkm_init(void);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue