extern uid_t console_user;
+extern unsigned long strtoul(const char *, char **, int);
+
/* Global vfs data structures for hfs */
hfs_chashinsert(from_cp);
hfs_chashinsert(to_cp);
+
+ /*
+ * When a file moves out of "Cleanup At Startup"
+ * we can drop its NODUMP status.
+ */
+ if ((from_cp->c_flags & UF_NODUMP) &&
+ (from_cp->c_parentcnid != to_cp->c_parentcnid)) {
+ from_cp->c_flags &= ~UF_NODUMP;
+ from_cp->c_flag |= C_CHANGE;
+ }
+
+ if ((to_cp->c_flags & UF_NODUMP) &&
+ (to_cp->c_parentcnid != from_cp->c_parentcnid)) {
+ to_cp->c_flags &= ~UF_NODUMP;
+ to_cp->c_flag |= C_CHANGE;
+ }
+
Err_Exit:
if (to_rvp)
vrele(to_rvp);
* When MNT_WAIT is requested and the zero fill timeout
* has expired then we must explicitly zero out any areas
* that are currently marked invalid (holes).
+ *
+ * Files with NODUMP can bypass zero filling here.
*/
if ((wait || (cp->c_flag & C_ZFWANTSYNC)) &&
+ ((cp->c_flags & UF_NODUMP) == 0) &&
UBCINFOEXISTS(vp) && (fp = VTOF(vp)) &&
cp->c_zftimeout != 0) {
int devblksize;
cp->c_mode = 0; /* Suppress VOP_UPDATES */
error = VOP_TRUNCATE(rvp, (off_t)0, IO_NDELAY, NOCRED, p);
cp->c_mode = mode;
- if (error && !dataforkbusy)
+ if (error)
goto out;
- else {
- /*
- * XXX could also force an update on vp
- * and fail the remove.
- */
- error = 0;
- }
truncated = 1;
}
}
} else /* Not busy */ {
- if (vp->v_type == VDIR && cp->c_entries > 0)
- panic("hfs_remove: attempting to delete a non-empty directory!");
- if (vp->v_type != VDIR && cp->c_blocks > 0)
- panic("hfs_remove: attempting to delete a non-empty file!");
+ if (cp->c_blocks > 0) {
+ printf("hfs_remove: attempting to delete a non-empty file!");
+ error = EBUSY;
+ goto out;
+ }
/* Lock catalog b-tree */
error = hfs_metafilelocking(hfsmp, kHFSCatalogFileID, LK_EXCLUSIVE, p);
error = cat_delete(hfsmp, &cp->c_desc, &cp->c_attr);
- if (error && error != ENXIO && truncated) {
+ if (error && error != ENXIO && error != ENOENT && truncated) {
if ((cp->c_datafork && cp->c_datafork->ff_data.cf_size != 0) ||
(cp->c_rsrcfork && cp->c_rsrcfork->ff_data.cf_size != 0)) {
panic("hfs: remove: couldn't delete a truncated file! (%d, data sz %lld; rsrc sz %lld)",
fdcp = VTOC(fdvp);
fcp = VTOC(fvp);
+ /*
+ * When a file moves out of "Cleanup At Startup"
+ * we can drop its NODUMP status.
+ */
+ if ((fcp->c_flags & UF_NODUMP) &&
+ (fvp->v_type == VREG) &&
+ (fdvp != tdvp) &&
+ (fdcp->c_desc.cd_nameptr != NULL) &&
+ (strcmp(fdcp->c_desc.cd_nameptr, "Cleanup At Startup") == 0)) {
+ fcp->c_flags &= ~UF_NODUMP;
+ fcp->c_flag |= C_CHANGE;
+ tv = time;
+ (void) VOP_UPDATE(fvp, &tv, &tv, 0);
+ }
+
hfs_global_shared_lock_acquire(hfsmp);
grabbed_lock = 1;
if (hfsmp->jnl) {
if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
- vput(dvp);
+
+ /*
+ * Check if a file is located in the "Cleanup At Startup"
+ * directory. If it is then tag it as NODUMP so that we
+ * can be lazy about zero filling data holes.
+ */
+ if ((error == 0) && (vnodetype == VREG) &&
+ (dcp->c_desc.cd_nameptr != NULL) &&
+ (strcmp(dcp->c_desc.cd_nameptr, "Cleanup At Startup") == 0)) {
+ struct vnode *ddvp;
+ cnid_t parid;
+
+ parid = dcp->c_parentcnid;
+ vput(dvp);
+ dvp = NULL;
+
+ /*
+ * The parent of "Cleanup At Startup" should
+ * have the ASCII name of the userid.
+ */
+ if (VFS_VGET(HFSTOVFS(hfsmp), &parid, &ddvp) == 0) {
+ if (VTOC(ddvp)->c_desc.cd_nameptr &&
+ (cp->c_uid == strtoul(VTOC(ddvp)->c_desc.cd_nameptr, 0, 0))) {
+ cp->c_flags |= UF_NODUMP;
+ cp->c_flag |= C_CHANGE;
+ }
+ vput(ddvp);
+ }
+ }
+
+ if (dvp)
+ vput(dvp);
// XXXdbg
if (started_tr) {
return (sysctl_rdint(oldp, oldlenp, newp, gPEClockFrequencyInfo.bus_clock_rate_hz));
case HW_CPU_FREQ:
return (sysctl_rdint(oldp, oldlenp, newp, gPEClockFrequencyInfo.cpu_clock_rate_hz));
+ case HW_TB_FREQ:
+ return (sysctl_rdint(oldp, oldlenp, newp, gPEClockFrequencyInfo.timebase_frequency_hz));
#if __ppc__
case HW_VECTORUNIT:
return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.vector_unit));
m->m_flags |= M_BCAST;
else
m->m_flags |= M_MCAST;
+ } else {
+ /*
+ * When the driver is put into promiscuous mode we may receive unicast
+ * frames that are not intended for our interfaces. They are filtered
+ * here to keep them from traveling further up the stack to code that
+ * is not expecting them or prepared to deal with them. In the near
+ * future, the filtering done here will be moved even further down the
+ * stack into the IONetworkingFamily, preventing even interface
+ * filter NKE's from receiving promiscuous packets. Please use BPF.
+ */
+ #define ETHER_CMP(x, y) ( ((u_int16_t *) x)[0] != ((u_int16_t *) y)[0] || \
+ ((u_int16_t *) x)[1] != ((u_int16_t *) y)[1] || \
+ ((u_int16_t *) x)[2] != ((u_int16_t *) y)[2] )
+
+ if (ETHER_CMP(eh->ether_dhost, ((struct arpcom *) ifp)->ac_enaddr)) {
+ m_freem(m);
+ return EJUSTRETURN;
+ }
}
data = mtod(m, u_int8_t*);
return;
}
if (isaddr.s_addr == myaddr.s_addr) {
+ struct kev_msg ev_msg;
+ struct kev_in_collision *in_collision;
+ u_char storage[sizeof(struct kev_in_collision) + 6];
+ in_collision = (struct kev_in_collision*)storage;
+
log(LOG_ERR,
"duplicate IP address %s sent from ethernet address %s\n",
inet_ntoa(isaddr), ether_sprintf(buf, ea->arp_sha));
+
+ /* Send a kernel event so anyone can learn of the conflict */
+ in_collision->link_data.if_family = ac->ac_if.if_family;
+ in_collision->link_data.if_unit = ac->ac_if.if_unit;
+ strncpy(&in_collision->link_data.if_name[0], ac->ac_if.if_name, IFNAMSIZ);
+ in_collision->ia_ipaddr = isaddr;
+ in_collision->hw_len = ETHER_ADDR_LEN;
+ bcopy((caddr_t)ea->arp_sha, (caddr_t)in_collision->hw_addr, sizeof(ea->arp_sha));
+ ev_msg.vendor_code = KEV_VENDOR_APPLE;
+ ev_msg.kev_class = KEV_NETWORK_CLASS;
+ ev_msg.kev_subclass = KEV_INET_SUBCLASS;
+ ev_msg.event_code = KEV_INET_ARPCOLLISION;
+ ev_msg.dv[0].data_ptr = in_collision;
+ ev_msg.dv[0].data_length = sizeof(struct kev_in_collision) + 6;
+ ev_msg.dv[1].data_length = 0;
+ kev_post_msg(&ev_msg);
+
itaddr = myaddr;
goto reply;
}
struct in_addr ia_dstaddr;
};
+struct kev_in_collision {
+ struct net_event_data link_data; /* link colliding arp was received on */
+ struct in_addr ia_ipaddr; /* IP address we and another node are using */
+ u_char hw_len; /* length of hardware address */
+ u_char hw_addr[0]; /* variable length hardware address */
+};
+
/*
* Define inet event subclass and specific inet events.
#define KEV_INET_SIFDSTADDR 4
#define KEV_INET_SIFBRDADDR 5
#define KEV_INET_SIFNETMASK 6
+#define KEV_INET_ARPCOLLISION 7 /* use kev_in_collision */
#endif /* __APPLE__ */
/*
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
if (reply->rp_astatus != 0) {
error = ntohl(reply->rp_u.rpu_errno);
printf("rpc denied, error=%d\n", error);
- continue;
+ /* convert rpc error to errno */
+ switch (error) {
+ case RPC_MISMATCH:
+ error = ERPCMISMATCH;
+ break;
+ case RPC_AUTHERR:
+ error = EAUTH;
+ break;
+ }
+ goto out;
}
/* Did the call succeed? */
if ((error = ntohl(reply->rp_u.rpu_ok.rp_rstatus)) != 0) {
printf("rpc status=%d\n", error);
- continue;
+ /* convert rpc error to errno */
+ switch (error) {
+ case RPC_PROGUNAVAIL:
+ error = EPROGUNAVAIL;
+ break;
+ case RPC_PROGMISMATCH:
+ error = EPROGMISMATCH;
+ break;
+ case RPC_PROCUNAVAIL:
+ error = EPROCUNAVAIL;
+ break;
+ case RPC_GARBAGE:
+ error = EINVAL;
+ break;
+ case RPC_SYSTEM_ERR:
+ error = EIO;
+ break;
+ }
+ goto out;
}
goto gotreply; /* break two levels */
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
panic("nfs_boot_init: no ether");
}
+int nfs_boot_getfh(nd, procp, v3)
+ struct nfs_diskless *nd;
+ struct proc *procp;
+ int v3;
+{
+ panic("nfs_boot_getfh: no ether");
+}
+
#else /* NETHER */
/*
struct sockaddr_in *mdsin, char *servname, char *path));
/* mountd RPC */
-static int md_mount __P((struct sockaddr_in *mdsin, char *path,
- u_char *fh));
+static int md_mount __P((struct sockaddr_in *mdsin, char *path, int v3,
+ u_char *fhp, u_long *fhlenp));
/* other helpers */
-static int get_file_handle __P((char *pathname, struct nfs_dlmount *ndmntp));
+static int get_file_handle __P((struct nfs_dlmount *ndmntp));
#define IP_FORMAT "%d.%d.%d.%d"
boolean_t do_bpgetfile = TRUE;
int error = 0;
struct in_addr my_ip;
- char * root_path = NULL;
struct sockaddr_in * sin_p;
/* by this point, networking must already have been configured */
}
/* get the root path information */
- MALLOC(root_path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
+ MALLOC_ZONE(nd->nd_root.ndm_path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
sin_p = &nd->nd_root.ndm_saddr;
bzero((caddr_t)sin_p, sizeof(*sin_p));
sin_p->sin_len = sizeof(*sin_p);
sin_p->sin_family = AF_INET;
if (netboot_rootpath(&sin_p->sin_addr, nd->nd_root.ndm_host,
sizeof(nd->nd_root.ndm_host),
- root_path, MAXPATHLEN) == TRUE) {
+ nd->nd_root.ndm_path, MAXPATHLEN) == TRUE) {
do_bpgetfile = FALSE;
do_bpwhoami = FALSE;
}
}
if (do_bpgetfile) {
error = bp_getfile(&bp_sin, "root", &nd->nd_root.ndm_saddr,
- nd->nd_root.ndm_host, root_path);
+ nd->nd_root.ndm_host, nd->nd_root.ndm_path);
if (error) {
printf("nfs_boot: bootparam get root: %d\n", error);
goto failed;
}
}
-
- error = get_file_handle(root_path, &nd->nd_root);
- if (error) {
- printf("nfs_boot: get_file_handle() root failed, %d\n", error);
- goto failed;
- }
#if !defined(NO_MOUNT_PRIVATE)
if (do_bpgetfile) { /* get private path */
- char * private_path = NULL;
-
- MALLOC(private_path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
+ MALLOC_ZONE(nd->nd_private.ndm_path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
error = bp_getfile(&bp_sin, "private",
&nd->nd_private.ndm_saddr,
- nd->nd_private.ndm_host, private_path);
+ nd->nd_private.ndm_host,
+ nd->nd_private.ndm_path);
if (!error) {
char * check_path = NULL;
- MALLOC(check_path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
- sprintf(check_path, "%s/private", root_path);
+ MALLOC_ZONE(check_path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
+ snprintf(check_path, MAXPATHLEN, "%s/private", nd->nd_root.ndm_path);
if ((nd->nd_root.ndm_saddr.sin_addr.s_addr
== nd->nd_private.ndm_saddr.sin_addr.s_addr)
- && (strcmp(check_path, private_path) == 0)) {
+ && (strcmp(check_path, nd->nd_private.ndm_path) == 0)) {
/* private path is prefix of root path, don't mount */
nd->nd_private.ndm_saddr.sin_addr.s_addr = 0;
}
- else {
- error = get_file_handle(private_path,
- &nd->nd_private);
- if (error) {
- printf("nfs_boot: get_file_handle() private failed, %d\n", error);
- goto failed;
- }
- }
- _FREE(check_path, M_TEMP);
+ FREE_ZONE(check_path, MAXPATHLEN, M_NAMEI);
}
else {
/* private key not defined, don't mount */
nd->nd_private.ndm_saddr.sin_addr.s_addr = 0;
}
- _FREE(private_path, M_TEMP);
}
else {
error = 0;
#endif NO_MOUNT_PRIVATE
failed:
thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- _FREE(root_path, M_TEMP);
+ return (error);
+}
+
+/*
+ * Called with a partially initialized nfs_diskless struct
+ * with file handles to be filled in.
+ */
+int
+nfs_boot_getfh(nd, procp, v3)
+ struct nfs_diskless *nd;
+ struct proc *procp;
+ int v3;
+{
+ int error = 0;
+
+ thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
+
+ nd->nd_root.ndm_nfsv3 = v3;
+ error = get_file_handle(&nd->nd_root);
+ if (error) {
+ printf("nfs_boot: get_file_handle(v%d) root failed, %d\n",
+ v3 ? 3 : 2, error);
+ goto failed;
+ }
+
+#if !defined(NO_MOUNT_PRIVATE)
+ if (nd->nd_private.ndm_saddr.sin_addr.s_addr) {
+ /* get private file handle */
+ nd->nd_private.ndm_nfsv3 = v3;
+ error = get_file_handle(&nd->nd_private);
+ if (error) {
+ printf("nfs_boot: get_file_handle(v%d) private failed, %d\n",
+ v3 ? 3 : 2, error);
+ goto failed;
+ }
+ }
+#endif NO_MOUNT_PRIVATE
+ failed:
+ thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
return (error);
}
static int
-get_file_handle(pathname, ndmntp)
- char *pathname; /* path on server */
- struct nfs_dlmount *ndmntp; /* output */
+get_file_handle(ndmntp)
+ struct nfs_dlmount *ndmntp;
{
char *sp, *dp, *endp;
int error;
* Get file handle for "key" (root or swap)
* using RPC to mountd/mount
*/
- error = md_mount(&ndmntp->ndm_saddr, pathname, ndmntp->ndm_fh);
+ error = md_mount(&ndmntp->ndm_saddr, ndmntp->ndm_path, ndmntp->ndm_nfsv3,
+ ndmntp->ndm_fh, &ndmntp->ndm_fhlen);
if (error)
return (error);
endp = dp + MNAMELEN - 1;
dp += strlen(dp);
*dp++ = ':';
- for (sp = pathname; *sp && dp < endp;)
+ for (sp = ndmntp->ndm_path; *sp && dp < endp;)
*dp++ = *sp++;
*dp = '\0';
return (0);
* Also, sets sin->sin_port to the NFS service port.
*/
static int
-md_mount(mdsin, path, fhp)
+md_mount(mdsin, path, v3, fhp, fhlenp)
struct sockaddr_in *mdsin; /* mountd server address */
char *path;
+ int v3;
u_char *fhp;
+ u_long *fhlenp;
{
/* The RPC structures */
struct rpc_string *str;
struct rdata {
u_long errno;
- u_char fh[NFSX_V2FH];
+ u_char data[NFSX_V3FHMAX + sizeof(u_long)];
} *rdata;
struct mbuf *m;
int error, mlen, slen;
+ int mntversion = v3 ? RPCMNT_VER3 : RPCMNT_VER1;
/* Get port number for MOUNTD. */
- error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER1,
+ error = krpc_portmap(mdsin, RPCPROG_MNT, mntversion,
&mdsin->sin_port);
if (error) return error;
bcopy(path, str->data, slen);
/* Do RPC to mountd. */
- error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER1,
+ error = krpc_call(mdsin, RPCPROG_MNT, mntversion,
RPCMNT_MOUNT, &m, NULL);
if (error)
return error; /* message already freed */
+ /*
+ * the reply must be long enough to hold the errno plus either of:
+ * + a v2 filehandle
+ * + a v3 filehandle length + a v3 filehandle
+ */
mlen = m->m_len;
- if (mlen < sizeof(*rdata))
+ if (mlen < sizeof(u_long))
goto bad;
rdata = mtod(m, struct rdata *);
error = ntohl(rdata->errno);
if (error)
- goto bad;
- bcopy(rdata->fh, fhp, NFSX_V2FH);
+ goto out;
+ if (v3) {
+ u_long fhlen;
+ u_char *fh;
+ if (mlen < sizeof(u_long)*2)
+ goto bad;
+ fhlen = ntohl(*(u_long*)rdata->data);
+ fh = rdata->data + sizeof(u_long);
+ if (mlen < (sizeof(u_long)*2 + fhlen))
+ goto bad;
+ bcopy(fh, fhp, fhlen);
+ *fhlenp = fhlen;
+ } else {
+ if (mlen < (sizeof(u_long) + NFSX_V2FH))
+ goto bad;
+ bcopy(rdata->data, fhp, NFSX_V2FH);
+ *fhlenp = NFSX_V2FH;
+ }
/* Set port number for NFS use. */
- error = krpc_portmap(mdsin, NFS_PROG, NFS_VER2,
+ error = krpc_portmap(mdsin, NFS_PROG, v3 ? NFS_VER3 : NFS_VER2,
&mdsin->sin_port);
goto out;
/*
- * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
VFS_SET(nfs_vfsops, nfs, MOUNT_NFS, VFCF_NETWORK);
#endif
-/*
- * This structure must be filled in by a primary bootstrap or bootstrap
- * server for a diskless/dataless machine. It is initialized below just
- * to ensure that it is allocated to initialized data (.data not .bss).
- */
-struct nfs_diskless nfs_diskless = { 0 };
-int nfs_diskless_valid = 0;
-
-/* XXX CSM 11/25/97 Upgrade sysctl.h someday */
-#ifdef notyet
-SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD,
- &nfs_diskless_valid, 0, "");
-
-SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD,
- nfs_diskless.root_hostnam, 0, "");
-
-SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD,
- &nfs_diskless.root_saddr, sizeof nfs_diskless.root_saddr,
- "%Ssockaddr_in", "");
-
-SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_swappath, CTLFLAG_RD,
- nfs_diskless.swap_hostnam, 0, "");
-
-SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_swapaddr, CTLFLAG_RD,
- &nfs_diskless.swap_saddr, sizeof nfs_diskless.swap_saddr,
- "%Ssockaddr_in","");
-#endif
-
void nfsargs_ntoh __P((struct nfs_args *));
static int
struct mount *mppriv;
struct vnode *vppriv;
#endif /* NO_MOUNT_PRIVATE */
+ int v3;
procp = current_proc(); /* XXX */
panic("nfs_boot_init failed with %d\n", error);
}
+ /* try NFSv3 first, if that fails then try NFSv2 */
+ v3 = 1;
+
+tryagain:
+ error = nfs_boot_getfh(&nd, procp, v3);
+ if (error) {
+ if (v3) {
+ printf("nfs_boot_getfh(v3) failed with %d, trying v2...\n", error);
+ v3 = 0;
+ goto tryagain;
+ }
+ panic("nfs_boot_getfh(v2) failed with %d\n", error);
+ }
+
/*
* Create the root mount point.
*/
#else
if (error = nfs_mount_diskless(&nd.nd_root, "/", NULL, &vp, &mp)) {
#endif /* NO_MOUNT_PRIVATE */
- panic("nfs_mount_diskless failed with %d\n", error);
+ if (v3) {
+ printf("nfs_mount_diskless(v3) failed with %d, trying v2...\n", error);
+ v3 = 0;
+ goto tryagain;
+ }
+ panic("nfs_mount_diskless root failed with %d\n", error);
}
printf("root on %s\n", (char *)&nd.nd_root.ndm_host);
error = nfs_mount_diskless_private(&nd.nd_private, "/private",
NULL, &vppriv, &mppriv);
if (error) {
- panic("nfs_mount_diskless failed with %d\n", error);
+ panic("nfs_mount_diskless private failed with %d\n", error);
}
printf("private on %s\n", (char *)&nd.nd_private.ndm_host);
#endif /* NO_MOUNT_PRIVATE */
+ if (nd.nd_root.ndm_path)
+ FREE_ZONE(nd.nd_root.ndm_path, MAXPATHLEN, M_NAMEI);
+ if (nd.nd_private.ndm_path)
+ FREE_ZONE(nd.nd_private.ndm_path, MAXPATHLEN, M_NAMEI);
+
/* Get root attributes (for the time). */
error = VOP_GETATTR(vp, &attr, procp->p_ucred, procp);
if (error) panic("nfs_mountroot: getattr for root");
args.addrlen = args.addr->sa_len;
args.sotype = SOCK_DGRAM;
args.fh = ndmntp->ndm_fh;
- args.fhsize = NFSX_V2FH; /* need to try v3, then v2 */
+ args.fhsize = ndmntp->ndm_fhlen;
args.hostname = ndmntp->ndm_host;
args.flags = NFSMNT_RESVPORT;
+ if (ndmntp->ndm_nfsv3)
+ args.flags |= NFSMNT_NFSV3;
MGET(m, M_DONTWAIT, MT_SONAME);
bcopy((caddr_t)args.addr, mtod(m, caddr_t),
args.addrlen = args.addr->sa_len;
args.sotype = SOCK_DGRAM;
args.fh = ndmntp->ndm_fh;
- args.fhsize = NFSX_V2FH;
+ args.fhsize = ndmntp->ndm_fhlen;
args.hostname = ndmntp->ndm_host;
args.flags = NFSMNT_RESVPORT;
+ if (ndmntp->ndm_nfsv3)
+ args.flags |= NFSMNT_NFSV3;
MGET(m, M_DONTWAIT, MT_SONAME);
bcopy((caddr_t)args.addr, mtod(m, caddr_t),
struct nfs_dlmount {
struct sockaddr_in ndm_saddr; /* Address of file server */
char ndm_host[MNAMELEN]; /* Host name for mount pt */
- u_char ndm_fh[NFSX_V2FH]; /* The file's file handle */
+ char *ndm_path; /* path name for mount pt */
+ u_long ndm_nfsv3; /* NFSv3 or NFSv2? */
+ u_long ndm_fhlen; /* length of file handle */
+ u_char ndm_fh[NFSX_V3FHMAX]; /* The file's file handle */
};
/*
#define RPC_PROGMISMATCH 2
#define RPC_PROCUNAVAIL 3
#define RPC_GARBAGE 4 /* I like this one */
+#define RPC_SYSTEM_ERR 5
#define RPC_MISMATCH 0
#define RPC_AUTHERR 1
#define HW_L2CACHESIZE 20 /* int: L2 Cache Size in Bytes */
#define HW_L3SETTINGS 21 /* int: L3 Cache Settings */
#define HW_L3CACHESIZE 22 /* int: L3 Cache Size in Bytes */
-#define HW_MAXID 23 /* number of valid hw ids */
+#define HW_TB_FREQ 23 /* int: Bus Frequency */
+#define HW_MAXID 24 /* number of valid hw ids */
#define CTL_HW_NAMES { \
{ 0, 0 }, \
{ "l2settings", CTLTYPE_INT }, \
{ "l2cachesize", CTLTYPE_INT }, \
{ "l3settings", CTLTYPE_INT }, \
- { "l3cachesize", CTLTYPE_INT } \
+ { "l3cachesize", CTLTYPE_INT }, \
+ { "tbfrequency", CTLTYPE_INT } \
}
/*
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>System Resource Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>System Resource Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.kernel</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleRequired</key>
<string>Root</string>
<key>OSKernelResource</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>AppleNMI Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>AppleNMI Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.driver.AppleNMI</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleRequired</key>
<string>Root</string>
<key>OSKernelResource</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>Apple Platform Family Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>Apple Platform Family Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.iokit.ApplePlatformFamily</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
<string>1.0</string>
<key>OSBundleRequired</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>BSD Kernel Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>BSD Kernel Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.kernel.bsd</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
<string>1.1</string>
<key>OSBundleRequired</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>ADB Family Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>ADB Family Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.iokit.IOADBFamily</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
<string>1.0.0b1</string>
<key>OSBundleRequired</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>I/O Kit Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>I/O Kit Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.kernel.iokit</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
<string>1.0.0b1</string>
<key>OSBundleRequired</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>AppleNMI Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>AppleNMI Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.iokit.IONVRAMFamily</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
<string>1.1</string>
<key>OSBundleRequired</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>System Management Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>System Management Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.iokit.IOSystemManagementFamily</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
<string>1.0.0b1</string>
<key>OSBundleRequired</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>Libkern Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>Libkern Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.kernel.libkern</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
<string>1.0.0b1</string>
<key>OSBundleRequired</key>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
- <string>Mach Kernel Pseudoextension, Apple Computer Inc, 6.3</string>
+ <string>Mach Kernel Pseudoextension, Apple Computer Inc, 6.4</string>
<key>CFBundleIdentifier</key>
<string>com.apple.kernel.mach</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>6.3</string>
+ <string>6.4</string>
<key>OSBundleCompatibleVersion</key>
<string>1.0.0b1</string>
<key>OSBundleRequired</key>
bool responseValid ( unsigned long x );
IOReturn allowCancelCommon ( void );
void computeDesiredState ( void );
+ void rebuildChildClampBits ( void );
};
#endif /* ! _IOKIT_IOSERVICE_H */
bool IOCPU::start(IOService *provider)
{
- OSData *busFrequency, *cpuFrequency, *decFrequency;
+ OSData *busFrequency, *cpuFrequency, *timebaseFrequency;
if (!super::start(provider)) return false;
// Correct the bus, cpu and dec frequencies in the device tree.
busFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.bus_clock_rate_hz, 4);
cpuFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.cpu_clock_rate_hz, 4);
- decFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.dec_clock_rate_hz, 4);
+ timebaseFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.timebase_frequency_hz, 4);
provider->setProperty("bus-frequency", busFrequency);
provider->setProperty("clock-frequency", cpuFrequency);
- provider->setProperty("timebase-frequency", decFrequency);
+ provider->setProperty("timebase-frequency", timebaseFrequency);
busFrequency->release();
cpuFrequency->release();
- decFrequency->release();
+ timebaseFrequency->release();
setProperty("IOCPUID", (UInt32)this, 32);
addressMap, logical, length );
#endif
- if( (addressMap == kernel_map) || (addressMap == get_task_map(current_task()))) {
+ if( true /* && (addressMap == kernel_map) || (addressMap == get_task_map(current_task()))*/) {
if( _memEntry && (addressMap == kernel_map) && (kIOMemoryRequiresWire & _flags))
addressMap = IOPageableMapForAddress( logical );
}
}
}
-
+
theNub->release();
if ( (pm_vars->theControllingDriver == NULL) || // if not fully initialized
return IOPMNoErr; // we can do no more
}
+ // Perhaps the departing child was holding up idle or system sleep - we need to re-evaluate our
+ // childrens' requests. Clear and re-calculate our kIOPMChildClamp and kIOPMChildClamp2 bits.
+ rebuildChildClampBits();
+
computeDesiredState(); // this may be different now
changeState(); // change state if we can now tolerate lower power
IOLockUnlock(pm_vars->parentLock);
}
+//*********************************************************************************
+// rebuildChildClampBits
+//
+// The ChildClamp bits (kIOPMChildClamp & kIOPMChildClamp2) in our capabilityFlags
+// indicate that one of our children (or grandchildren or great-grandchildren or ...)
+// doesn't support idle or system sleep in its current state. Since we don't track the
+// origin of each bit, every time any child changes state we have to clear these bits
+// and rebuild them.
+//*********************************************************************************
+
+void IOService::rebuildChildClampBits(void)
+{
+ unsigned long i;
+ OSIterator * iter;
+ OSObject * next;
+ IOPowerConnection * connection;
+
+
+ // A child's desires has changed. We need to rebuild the child-clamp bits in our
+ // power state array. Start by clearing the bits in each power state.
+
+ for ( i = 0; i < pm_vars->theNumberOfPowerStates; i++ ) {
+ pm_vars->thePowerStates[i].capabilityFlags &= ~(kIOPMChildClamp | kIOPMChildClamp2);
+ }
+
+ // Now loop through the children. When we encounter the calling child, save
+ // the computed state as this child's desire. And while we're at it, set the ChildClamp bits
+ // in any of our states that some child has requested with clamp on.
+
+ iter = getChildIterator(gIOPowerPlane);
+
+ if ( iter )
+ {
+ while ( (next = iter->getNextObject()) )
+ {
+ if ( (connection = OSDynamicCast(IOPowerConnection,next)) )
+ {
+ if ( connection->getPreventIdleSleepFlag() )
+ pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp;
+ if ( connection->getPreventSystemSleepFlag() )
+ pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp2;
+ }
+ }
+ iter->release();
+ }
+
+}
+
//*********************************************************************************
// requestPowerDomainState
IOLockLock(pm_vars->childLock);
-// A child's desires has changed. We need to rebuild the child-clamp bits in our
-// power state array. Start by clearing the bits in each power state.
-
- for ( i = 0; i < pm_vars->theNumberOfPowerStates; i++ ) {
- pm_vars->thePowerStates[i].capabilityFlags &= ~(kIOPMChildClamp | kIOPMChildClamp2);
- }
-
-// Now loop through the children. When we encounter the calling child, save
-// the computed state as this child's desire. And while we're at it, set the ChildClamp bits
-// in any of our states that some child has requested with clamp on.
-
+ // Now loop through the children. When we encounter the calling child, save
+ // the computed state as this child's desire.
iter = getChildIterator(gIOPowerPlane);
if ( iter ) {
connection->setPreventSystemSleepFlag(desiredState & kIOPMPreventSystemSleep);
connection->setChildHasRequestedPower();
}
- if ( connection->getPreventIdleSleepFlag() ) {
- pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp;
- }
- if ( connection->getPreventSystemSleepFlag() ) {
- pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp2;
- }
}
}
iter->release();
}
+
+ // Since a child's power requirements may have changed, clear and rebuild
+ // kIOPMChildClamp and kIOPMChildClamp2 (idle and system sleep clamps)
+ rebuildChildClampBits();
IOLockUnlock(pm_vars->childLock);
ourRequest |= kIOPMPreventSystemSleep;
}
- if ( priv->previousRequest == ourRequest ) { // is this a new desire?
- return IOPMNoErr; // no, the parent knows already, just return
+ // is this a new desire?
+ if ( priv->previousRequest == ourRequest )
+ {
+ // no, the parent knows already, just return
+ return IOPMNoErr;
}
if ( priv->we_are_root ) {
*/
const char * gIOKernelKmods =
"{
- 'com.apple.kernel' = '6.3';
- 'com.apple.kernel.bsd' = '6.3';
- 'com.apple.kernel.iokit' = '6.3';
- 'com.apple.kernel.libkern' = '6.3';
- 'com.apple.kernel.mach' = '6.3';
- 'com.apple.iokit.IOADBFamily' = '6.3';
- 'com.apple.iokit.IONVRAMFamily' = '6.3';
- 'com.apple.iokit.IOSystemManagementFamily' = '6.3';
- 'com.apple.iokit.ApplePlatformFamily' = '6.3';
- 'com.apple.driver.AppleNMI' = '6.3';
+ 'com.apple.kernel' = '6.4';
+ 'com.apple.kernel.bsd' = '6.4';
+ 'com.apple.kernel.iokit' = '6.4';
+ 'com.apple.kernel.libkern' = '6.4';
+ 'com.apple.kernel.mach' = '6.4';
+ 'com.apple.iokit.IOADBFamily' = '6.4';
+ 'com.apple.iokit.IONVRAMFamily' = '6.4';
+ 'com.apple.iokit.IOSystemManagementFamily' = '6.4';
+ 'com.apple.iokit.ApplePlatformFamily' = '6.4';
+ 'com.apple.driver.AppleNMI' = '6.4';
}";
assert((task->swap_state & TASK_SW_ELIGIBLE) == 0);
#endif /* TASK_SWAPPER */
+ if(task->dynamic_working_set)
+ tws_hash_destroy((tws_hash_t)task->dynamic_working_set);
+
+
eml_task_deallocate(task);
ipc_task_terminate(task);
shared_region_mapping_dealloc(task->system_shared_region);
+ /*
+ * Flush working set here to avoid I/O in reaper thread
+ */
if(task->dynamic_working_set)
- tws_hash_destroy((tws_hash_t)task->dynamic_working_set);
+ tws_hash_ws_flush((tws_hash_t)
+ task->dynamic_working_set);
/*
* We no longer need to guard against being aborted, so restore
#endif /* KERNEL_PRIVATE */
#include <mach/machine/vm_param.h>
-#include <mach/machine/vm_types.h>
+
+#include <mach/vm_types.h>
/*
* The machine independent pages are refered to as PAGES. A page
#endif /* PAGE_SIZE_FIXED */
#ifndef ASSEMBLER
+
+/*
+ * Convert addresses to pages and vice versa. No rounding is used.
+ * The atop_32 and ptoa_32 macros should not be use on 64 bit types.
+ * The round_page_64 and trunc_page_64 macros should be used instead.
+ */
+
+#define atop_32(x) ((uint32_t)(x) >> PAGE_SHIFT)
+#define ptoa_32(x) ((uint32_t)(x) << PAGE_SHIFT)
+#define atop_64(x) ((uint64_t)(x) >> PAGE_SHIFT)
+#define ptoa_64(x) ((uint64_t)(x) << PAGE_SHIFT)
+
/*
- * Convert addresses to pages and vice versa.
- * No rounding is used.
+ * While the following block is enabled, the legacy atop and ptoa
+ * macros will behave correctly. If not, they will generate
+ * invalid lvalue errors.
*/
-#define atop(x) (((natural_t)(x)) >> PAGE_SHIFT)
-#define ptoa(x) ((vm_offset_t)((x) << PAGE_SHIFT))
+#if 1
+#define atop(x) ((uint32_t)(x) >> PAGE_SHIFT)
+#define ptoa(x) ((uint32_t)(x) << PAGE_SHIFT)
+#else
+#define atop(x) (0UL = 0)
+#define ptoa(x) (0UL = 0)
+#endif
+
/*
* Round off or truncate to the nearest page. These will work
* for either addresses or counts. (i.e. 1 byte rounds to 1 page
- * bytes.
+ * bytes. The round_page_32 and trunc_page_32 macros should not be
+ * use on 64 bit types. The round_page_64 and trunc_page_64 macros
+ * should be used instead.
+ */
+
+#define round_page_32(x) (((uint32_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
+#define trunc_page_32(x) ((uint32_t)(x) & ~((signed)PAGE_MASK))
+#define round_page_64(x) (((uint64_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
+#define trunc_page_64(x) ((uint64_t)(x) & ~((signed)PAGE_MASK))
+
+
+/*
+ * While the following block is enabled, the legacy round_page
+ * and trunc_page macros will behave correctly. If not, they will
+ * generate invalid lvalue errors.
*/
-#define round_page(x) ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) & ~PAGE_MASK))
-#define trunc_page(x) ((vm_offset_t)(((vm_offset_t)(x)) & ~PAGE_MASK))
+#if 1
+#define round_page(x) (((uint32_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
+#define trunc_page(x) ((uint32_t)(x) & ~((signed)PAGE_MASK))
+#else
+#define round_page(x) (0UL = 0)
+#define trunc_page(x) (0UL = 0)
+#endif
+
+/*
+ * Enable the following block to find uses of xxx_32 macros that should
+ * be xxx_64. These macros only work in C code, not C++. The resulting
+ * binaries are not functional. Look for invalid lvalue errors in
+ * the compiler output.
+ *
+ * Enabling the following block will also find use of the xxx_64 macros
+ * that have been passed pointers. The parameters should be case to an
+ * unsigned long type first. Look for invalid operands to binary + error
+ * in the compiler output.
+ */
-#define round_page_64(x) ((unsigned long long)((((unsigned long long)(x)) + PAGE_MASK_64) & ~PAGE_MASK_64))
-#define trunc_page_64(x) ((unsigned long long)(((unsigned long long)(x)) & ~PAGE_MASK_64))
+#if 0
+#undef atop_32
+#undef ptoa_32
+#undef round_page_32
+#undef trunc_page_32
+#undef atop_64
+#undef ptoa_64
+#undef round_page_64
+#undef trunc_page_64
+
+#ifndef __cplusplus
+
+#define atop_32(x) \
+ (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \
+ (*(long *)0), \
+ (0UL)) = 0)
+
+#define ptoa_32(x) \
+ (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \
+ (*(long *)0), \
+ (0UL)) = 0)
+
+#define round_page_32(x) \
+ (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \
+ (*(long *)0), \
+ (0UL)) = 0)
+
+#define trunc_page_32(x) \
+ (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \
+ (*(long *)0), \
+ (0UL)) = 0)
+#else
+
+#define atop_32(x) (0)
+#define ptoa_32(x) (0)
+#define round_page_32(x) (0)
+#define trunc_page_32(x) (0)
+
+#endif /* ! __cplusplus */
+
+#define atop_64(x) ((uint64_t)((x) + (uint8_t *)0))
+#define ptoa_64(x) ((uint64_t)((x) + (uint8_t *)0))
+#define round_page_64(x) ((uint64_t)((x) + (uint8_t *)0))
+#define trunc_page_64(x) ((uint64_t)((x) + (uint8_t *)0))
+
+#endif
/*
* Determine whether an address is page-aligned, or a count is
GratefulDebWork[i].GDdepth = boot_video_info->v_depth;
GratefulDebWork[i].GDcollgn = nrmlgn;
-// RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 6; /* (Update every 16th of a second (16 fps) */
- RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 5; /* (Update every 8th of a second (8 fps) */
-// RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 4; /* (Update every 4th of a second (4 fps) */
-// RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 3; /* (Update every 2th of a second (2 fps) */
-// RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 2; /* (Update every 1 second (1 fps) */
+// RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 4; /* (Update every 16th of a second (16 fps) */
+ RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 3; /* (Update every 8th of a second (8 fps) */
+// RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 2; /* (Update every 4th of a second (4 fps) */
+// RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 1; /* (Update every 2th of a second (2 fps) */
+// RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 0; /* (Update every 1 second (1 fps) */
sync();
pproc = &per_proc_info[cpu]; /* Point to our block */
/*
- * Since we've been signaled, wait just under 1ms for the signal lock to pass
+ * Since we've been signaled, wait about 31 ms for the signal lock to pass
*/
if(!hw_lock_mbits(&pproc->MPsigpStat, (MPsigpMsgp | MPsigpAck), (MPsigpBusy | MPsigpPass),
- (MPsigpBusy | MPsigpPass | MPsigpAck), (gPEClockFrequencyInfo.bus_clock_rate_hz >> 7))) {
+ (MPsigpBusy | MPsigpPass | MPsigpAck), (gPEClockFrequencyInfo.timebase_frequency_hz >> 5))) {
panic("cpu_signal_handler: Lock pass timed out\n");
}
if((busybitset == 0) &&
(!hw_lock_mbits(&tpproc->MPsigpStat, MPsigpMsgp, 0, MPsigpBusy,
- (gPEClockFrequencyInfo.bus_clock_rate_hz >> 13)))) { /* Try to lock the message block with a .5ms timeout */
+ (gPEClockFrequencyInfo.timebase_frequency_hz >> 11)))) { /* Try to lock the message block with a .5ms timeout */
mpproc->numSIGPtimo++; /* Account for timeouts */
return KERN_FAILURE; /* Timed out, take your ball and go home... */
}
}
kern_return_t
-tws_lookup(
+tws_internal_lookup(
tws_hash_t tws,
vm_object_offset_t offset,
vm_object_t object,
if(object->private)
return KERN_SUCCESS;
- if(!tws_lock_try(tws)) {
- return KERN_FAILURE;
- }
-
index = do_tws_hash(object, offset,
tws->number_of_elements, tws->number_of_lines);
loop = 0;
age_of_cache = ((sched_tick
- tws->time_of_creation) >> SCHED_TICK_SHIFT);
if (age_of_cache > 35) {
- tws_unlock(tws);
return KERN_OPERATION_TIMED_OUT;
}
}
age_of_cache = ((sched_tick
- tws->time_of_creation) >> SCHED_TICK_SHIFT);
if (age_of_cache > 60) {
- tws_unlock(tws);
return KERN_OPERATION_TIMED_OUT;
}
}
set = cache_ele->element->line/tws->number_of_lines;
ele_line = cache_ele->element->line - set;
*line = &tws->cache[set][ele_line];
- tws_unlock(tws);
return KERN_SUCCESS;
}
- tws_unlock(tws);
return KERN_FAILURE;
}
+kern_return_t
+tws_lookup(
+ tws_hash_t tws,
+ vm_object_offset_t offset,
+ vm_object_t object,
+ tws_hash_line_t *line)
+{
+ kern_return_t kr;
+
+ if(!tws_lock_try(tws)) {
+ return KERN_FAILURE;
+ }
+ kr = tws_internal_lookup(tws,
+ offset, object, line);
+ tws_unlock(tws);
+ return kr;
+}
+
kern_return_t
tws_expand_working_set(
vm_offset_t tws,
object_size = object->size;
}
+ if((!tws) || (!tws_lock_try(tws))) {
+ return;
+ }
+
age_of_cache = ((sched_tick
- tws->time_of_creation) >> SCHED_TICK_SHIFT);
if (*start >= *end)
panic("bad clipping occurred\n");
+ tws_unlock(tws);
return;
}
}
(object_size >=
(after + PAGE_SIZE_64))) {
if(length >= pre_heat_size) {
- if(tws_lookup(tws, after, object,
+ if(tws_internal_lookup(tws, after, object,
&line) != KERN_SUCCESS) {
vm_object_offset_t extend;
extend = after + PAGE_SIZE_64;
- if(tws_lookup(tws, extend, object,
+ if(tws_internal_lookup(tws, extend, object,
&line) != KERN_SUCCESS) {
break;
}
before -= PAGE_SIZE_64;
if(length >= pre_heat_size) {
- if(tws_lookup(tws, before, object,
+ if(tws_internal_lookup(tws, before, object,
&line) != KERN_SUCCESS) {
vm_object_offset_t extend;
if (extend == 0)
break;
extend -= PAGE_SIZE_64;
- if(tws_lookup(tws, extend, object,
+ if(tws_internal_lookup(tws, extend, object,
&line) != KERN_SUCCESS) {
break;
}
*start -= PAGE_SIZE_64;
length += PAGE_SIZE;
}
+ tws_unlock(tws);
}
tws_line_signal(
}
+void
+tws_hash_ws_flush(tws_hash_t tws) {
+ tws_startup_t scache;
+ if(tws == NULL) {
+ return;
+ }
+ tws_lock(tws);
+ if(tws->startup_name != NULL) {
+ scache = tws_create_startup_list(tws);
+ if(scache == NULL) {
+ /* dump the name cache, we'll */
+ /* get it next time */
+ kfree((vm_offset_t)
+ tws->startup_name,
+ tws->startup_name_length);
+ tws->startup_name = NULL;
+ tws_unlock(tws);
+ return;
+ }
+ bsd_write_page_cache_file(tws->uid, tws->startup_name,
+ scache, scache->tws_hash_size,
+ tws->mod, tws->fid);
+ kfree((vm_offset_t)scache,
+ scache->tws_hash_size);
+ kfree((vm_offset_t)
+ tws->startup_name,
+ tws->startup_name_length);
+ tws->startup_name = NULL;
+ }
+ tws_unlock(tws);
+ return;
+}
+
void
tws_hash_destroy(tws_hash_t tws)
{
tws_startup_t startup,
vm_offset_t cache_size);
+void
+tws_hash_ws_flush(
+ tws_hash_t tws);
+
#endif /* _VM_TASK_WORKING_SET_H_ */
unsigned long bus_to_cpu_rate_den;
unsigned long bus_to_dec_rate_num;
unsigned long bus_to_dec_rate_den;
+ unsigned long timebase_frequency_hz;
+ unsigned long timebase_frequency_num;
+ unsigned long timebase_frequency_den;
};
typedef struct clock_frequency_info_t clock_frequency_info_t;
* pe_clock_speed.c - Determine the best guess for the processor and bus
* speed buy using the values returned by run_clock_test.
*
- * (c) Apple Computer, Inc. 1998-2000
+ * (c) Apple Computer, Inc. 1998-2002
*
* Writen by: Josh de Cesare
*
gPEClockFrequencyInfo.bus_to_dec_rate_num = 1;
gPEClockFrequencyInfo.bus_to_dec_rate_den = 4;
+ // Assume that the timebase frequency is derived from the bus clock.
+ gPEClockFrequencyInfo.timebase_frequency_num = bus_freq_num;
+ gPEClockFrequencyInfo.timebase_frequency_den = bus_freq_den * 4;
+
// Set the truncated numbers in gPEClockFrequencyInfo.
gPEClockFrequencyInfo.bus_clock_rate_hz = tmp_bus_speed;
gPEClockFrequencyInfo.cpu_clock_rate_hz = tmp_cpu_speed;
gPEClockFrequencyInfo.dec_clock_rate_hz = tmp_bus_speed / 4;
+ gPEClockFrequencyInfo.timebase_frequency_hz = tmp_bus_speed / 4;
PE_call_timebase_callback();
}
gPEClockFrequencyInfo.bus_clock_rate_hz = 100000000;
gPEClockFrequencyInfo.cpu_clock_rate_hz = 300000000;
gPEClockFrequencyInfo.dec_clock_rate_hz = 25000000;
-
+ gPEClockFrequencyInfo.timebase_frequency_hz = 25000000;
+
// Try to get the values from the device tree.
if (DTFindEntry("device_type", "cpu", &cpu) == kSuccess) {
if (DTGetProperty(cpu, "bus-frequency",
gPEClockFrequencyInfo.cpu_clock_rate_hz = *value;
if (DTGetProperty(cpu, "timebase-frequency",
- (void **)&value, &size) == kSuccess)
+ (void **)&value, &size) == kSuccess) {
gPEClockFrequencyInfo.dec_clock_rate_hz = *value;
+ gPEClockFrequencyInfo.timebase_frequency_hz= *value;
+ }
}
// Set the num / den pairs form the hz values.
+ gPEClockFrequencyInfo.timebase_frequency_num = gPEClockFrequencyInfo.timebase_frequency_hz;
+ gPEClockFrequencyInfo.timebase_frequency_den = 1;
+
gPEClockFrequencyInfo.bus_clock_rate_num = gPEClockFrequencyInfo.bus_clock_rate_hz;
gPEClockFrequencyInfo.bus_clock_rate_den = 1;
struct timebase_freq_t timebase_freq;
unsigned long num, den, cnt;
- num = gPEClockFrequencyInfo.bus_clock_rate_num * gPEClockFrequencyInfo.bus_to_dec_rate_num;
- den = gPEClockFrequencyInfo.bus_clock_rate_den * gPEClockFrequencyInfo.bus_to_dec_rate_den;
+ num = gPEClockFrequencyInfo.timebase_frequency_num;
+ den = gPEClockFrequencyInfo.timebase_frequency_den;
cnt = 2;
while (cnt <= den) {