Fix module builds for i386 and amd64.

This commit is contained in:
Mark Murray 2004-08-04 18:30:31 +00:00
parent 98aed8ca56
commit a20ad05beb
8 changed files with 84 additions and 77 deletions

View File

@ -71,14 +71,6 @@ __FBSDID("$FreeBSD$");
* Used in /dev/mem drivers and elsewhere
*/
MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
struct mem_range_softc mem_range_softc;
void
mem_range_AP_init(void)
{
if (mem_range_softc.mr_op && mem_range_softc.mr_op->initAP)
mem_range_softc.mr_op->initAP(&mem_range_softc);
}
/* ARGSUSED */
int
@ -223,35 +215,6 @@ memioctl(struct cdev *dev __unused, u_long cmd, caddr_t data, int flags,
return (error);
}
/*
* Implementation-neutral, kernel-callable functions for manipulating
* memory range attributes.
*/
int
mem_range_attr_get(struct mem_range_desc *mrd, int *arg)
{
/* can we handle this? */
if (mem_range_softc.mr_op == NULL)
return (EOPNOTSUPP);
if (*arg == 0)
*arg = mem_range_softc.mr_ndesc;
else
bcopy(mem_range_softc.mr_desc, mrd,
(*arg) * sizeof(struct mem_range_desc));
return (0);
}
int
mem_range_attr_set(struct mem_range_desc *mrd, int *arg)
{
/* can we handle this? */
if (mem_range_softc.mr_op == NULL)
return (EOPNOTSUPP);
return (mem_range_softc.mr_op->set(&mem_range_softc, mrd, arg));
}
void
dev_mem_md_init(void)
{

View File

@ -142,6 +142,15 @@ static int hlt_logical_cpus;
static struct sysctl_ctx_list logical_cpu_clist;
static u_int bootMP_size;
struct mem_range_softc mem_range_softc;
static void
mem_range_AP_init(void)
{
if (mem_range_softc.mr_op && mem_range_softc.mr_op->initAP)
mem_range_softc.mr_op->initAP(&mem_range_softc);
}
void
mp_topology(void)
{

View File

@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/memrange.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@ -98,7 +97,6 @@ mem_modevent(module_t mod __unused, int type, void *data __unused)
default:
return(EOPNOTSUPP);
break;
}

62
sys/dev/mem/memutil.c Normal file
View File

@ -0,0 +1,62 @@
/*-
* Copyright (c) 2004 Mark R V Murray
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/memrange.h>
#include <sys/systm.h>
/*
* Implementation-neutral, kernel-callable functions for manipulating
* memory range attributes.
*/
int
mem_range_attr_get(struct mem_range_desc *mrd, int *arg)
{
/* can we handle this? */
if (mem_range_softc.mr_op == NULL)
return (EOPNOTSUPP);
if (*arg == 0)
*arg = mem_range_softc.mr_ndesc;
else
bcopy(mem_range_softc.mr_desc, mrd,
(*arg) * sizeof(struct mem_range_desc));
return (0);
}
int
mem_range_attr_set(struct mem_range_desc *mrd, int *arg)
{
/* can we handle this? */
if (mem_range_softc.mr_op == NULL)
return (EOPNOTSUPP);
return (mem_range_softc.mr_op->set(&mem_range_softc, mrd, arg));
}

View File

@ -70,14 +70,6 @@ __FBSDID("$FreeBSD$");
* Used in /dev/mem drivers and elsewhere
*/
MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
struct mem_range_softc mem_range_softc;
void
mem_range_AP_init(void)
{
if (mem_range_softc.mr_op && mem_range_softc.mr_op->initAP)
mem_range_softc.mr_op->initAP(&mem_range_softc);
}
/* ARGSUSED */
int
@ -218,35 +210,6 @@ memioctl(struct cdev *dev __unused, u_long cmd, caddr_t data, int flags,
return (error);
}
/*
* Implementation-neutral, kernel-callable functions for manipulating
* memory range attributes.
*/
int
mem_range_attr_get(struct mem_range_desc *mrd, int *arg)
{
/* can we handle this? */
if (mem_range_softc.mr_op == NULL)
return (EOPNOTSUPP);
if (*arg == 0)
*arg = mem_range_softc.mr_ndesc;
else
bcopy(mem_range_softc.mr_desc, mrd,
(*arg) * sizeof(struct mem_range_desc));
return (0);
}
int
mem_range_attr_set(struct mem_range_desc *mrd, int *arg)
{
/* can we handle this? */
if (mem_range_softc.mr_op == NULL)
return (EOPNOTSUPP);
return (mem_range_softc.mr_op->set(&mem_range_softc, mrd, arg));
}
void
dev_mem_md_init(void)
{

View File

@ -212,6 +212,15 @@ static int hlt_cpus_mask;
static int hlt_logical_cpus;
static struct sysctl_ctx_list logical_cpu_clist;
struct mem_range_softc mem_range_softc;
static void
mem_range_AP_init(void)
{
if (mem_range_softc.mr_op && mem_range_softc.mr_op->initAP)
mem_range_softc.mr_op->initAP(&mem_range_softc);
}
void
mp_topology(void)
{

View File

@ -5,6 +5,9 @@
KMOD= mem
SRCS= memdev.c mem.c
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
SRCS+= memutil.c
.endif
SRCS+= bus_if.h device_if.h vnode_if.h
.include <bsd.kmod.mk>

View File

@ -66,6 +66,6 @@ extern struct mem_range_softc mem_range_softc;
extern int mem_range_attr_get(struct mem_range_desc *mrd, int *arg);
extern int mem_range_attr_set(struct mem_range_desc *mrd, int *arg);
extern void mem_range_AP_init(void);
#endif