minor refactoring; does not work on the i386 yet.

This commit is contained in:
christos 2005-06-25 06:30:19 +00:00
parent e6c16a46dc
commit f63c68071c
2 changed files with 28 additions and 39 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_commpage.c,v 1.7 2005/02/26 23:10:18 perry Exp $ */
/* $NetBSD: darwin_commpage.c,v 1.8 2005/06/25 06:30:19 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_commpage.c,v 1.7 2005/02/26 23:10:18 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_commpage.c,v 1.8 2005/06/25 06:30:19 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: darwin_commpage.c,v 1.7 2005/02/26 23:10:18 perry Ex
#include <sys/proc.h>
#include <machine/cpu.h>
#include <machine/darwin_machdep.h>
#include <uvm/uvm_extern.h>
#include <uvm/uvm_map.h>
@ -53,10 +54,17 @@ __KERNEL_RCSID(0, "$NetBSD: darwin_commpage.c,v 1.7 2005/02/26 23:10:18 perry Ex
#include <compat/darwin/darwin_commpage.h>
/* XXX: this does not belong here! */
#ifdef __powerpc__
#include "opt_altivec.h"
#endif
#ifdef DEBUG_DARWIN
#define DPRINTF(a) uprintf a
#else
#define DPRINTF(a)
#endif
static struct uvm_object *darwin_commpage_uao = NULL;
static void darwin_commpage_init(struct darwin_commpage *);
@ -85,6 +93,8 @@ darwin_commpage_map(p)
UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW,
UVM_INH_SHARE, UVM_ADV_RANDOM, 0));
if (error != 0) {
DPRINTF(("kernel uvm_map darwin_compage failed "
"(error %d)\n", error));
uao_detach(darwin_commpage_uao);
darwin_commpage_uao = NULL;
return -1;
@ -93,6 +103,8 @@ darwin_commpage_map(p)
error = uvm_map_pageable(kernel_map, kvaddr,
kvaddr + memsize, FALSE, 0);
if (error != 0) {
DPRINTF(("kernel uvm_map_pageable darwin_compage "
"failed (error %d)\n", error));
uao_detach(darwin_commpage_uao);
darwin_commpage_uao = NULL;
return -1;
@ -108,15 +120,12 @@ darwin_commpage_map(p)
memsize, darwin_commpage_uao, 0, 0,
UVM_MAPFLAG(UVM_PROT_RX, UVM_PROT_RX,
UVM_INH_SHARE, UVM_ADV_NORMAL, UVM_FLAG_FIXED))) != 0) {
#ifdef DEBUG_DARWIN
printf("uvm_map darwin_commpage failed (error %d)\n", error);
#endif
DPRINTF(("user uvm_map darwin_commpage failed at "
"0x%08lx/memsize (error %d)\n", (long)pvaddr, error));
return -1;
}
#ifdef DEBUG_DARWIN
printf("mapped darwin_commpage at 0x%08lx\n", (long)pvaddr);
#endif
DPRINTF(("mapped darwin_commpage at 0x%08lx\n", (long)pvaddr));
return 0;
}
@ -145,7 +154,7 @@ darwin_commpage_init(dcp)
/*
* XXX Only one page is mapped yet (see higher in the file)
*/
bzero(dcp, sizeof(*dcp));
(void)memset(dcp, 0, sizeof(*dcp));
dcp->dcp_version = DARWIN_COMMPAGE_VERSION;
@ -160,12 +169,18 @@ darwin_commpage_init(dcp)
dcp->dcp_ncpu = ncpu;
dcp->dcp_cap |= (ncpu << DARWIN_CAP_NCPUSHIFT);
#ifdef DARWIN_CAP_UP
if (ncpu == 1)
dcp->dcp_cap |= DARWIN_CAP_UP;
#endif
/* XXX: This needs to be processor specific */
#ifdef ALTIVEC
dcp->dcp_altivec = 1;
dcp->dcp_vector = 1;
dcp->dcp_cap |= DARWIN_CAP_ALTIVEC;
#endif
#ifdef _LP64
#if defined(_LP64) && defined(DARWIN_CAP_64BIT)
dcp->dcp_64bit = 1;
dcp->dcp_cap |= DARWIN_CAP_64BIT;
#endif
@ -206,7 +221,4 @@ darwin_commpage_init(dcp)
DCP_MEMCPY(bcopy);
DCP_MEMCPY(memcpy);
DCP_MEMCPY(bigcopy);
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_commpage.h,v 1.4 2004/07/11 19:38:14 manu Exp $ */
/* $NetBSD: darwin_commpage.h,v 1.5 2005/06/25 06:30:19 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -39,29 +39,6 @@
#ifndef _DARWIN_COMMPAGE_H_
#define _DARWIN_COMMPAGE_H_
#define DARWIN_COMMPAGE_BASE 0xffff8000
#define DARWIN_COMMPAGE_LEN 0x00002000 /* 2 pages */
#define DARWIN_COMMPAGE_VERSION 1
#define DARWIN_CAP_ALTIVEC 0x00000001
#define DARWIN_CAP_64BIT 0x00000002
#define DARWIN_CAP_CACHE32 0x00000004
#define DARWIN_CAP_CACHE64 0x00000008
#define DARWIN_CAP_CACHE128 0x00000010
#define DARWIN_CAP_DODCBA 0x00000020
#define DARWIN_CAP_DCBA 0x00000040
#define DARWIN_CAP_DOSTREAM 0x00000080
#define DARWIN_CAP_STREAM 0x00000100
#define DARWIN_CAP_DODCBT 0x00000200
#define DARWIN_CAP_DCBT 0x00000400
#define DARWIN_CAP_UP 0x00008000
#define DARWIN_CAP_NCPUMASK 0x00ff0000
#define DARWIN_CAP_NCPUSHIFT 16
#define DARWIN_CAP_GRAPHOP 0x08000000
#define DARWIN_CAP_STFIWX 0x10000000
#define DARWIN_CAP_FSQRTX 0x20000000
struct darwin_commpage {
int dcp_signature; /* 0/0x000 */
char dcp_pad1[26];
@ -69,7 +46,7 @@ struct darwin_commpage {
char dcp_cap; /* 32/0x020 */
char dcp_ncpu; /* 33/0x021 */
char dcp_pad2[2];
char dcp_altivec; /* 36/0x024 */
char dcp_vector; /* 36/0x024 */
char dcp_64bit; /* 37/0x025 */
short dcp_cachelinelen; /* 38/0x026 */
char dcp_pad3[24];