diff options
| author | rb144127 <none@none> | 2007-01-31 21:19:07 -0800 |
|---|---|---|
| committer | rb144127 <none@none> | 2007-01-31 21:19:07 -0800 |
| commit | ef8846857fcf954444cdc77e72249afef48377d2 (patch) | |
| tree | 2bd9141778f42c81dd6378603d1d80682f1dab8c /usr/src/lib/libpri | |
| parent | 1a05c315fda6fa237b841a16a64cc2e3ba7514c9 (diff) | |
| download | illumos-joyent-ef8846857fcf954444cdc77e72249afef48377d2.tar.gz | |
PSARC/2006/704 libpri shared library and ds_pri kernel driver
6496303 identity information support (pri) for T5120/T5220
6512947 fmdump -v -u command core dumps in strncmp when testing N2 PIU
6518718 Cpumem-diagnosis get SEGV when creating cpu fault
6518722 The value of serial & part numbers are not correct for a cpu fault
6518796 sun4v cpu topology support for the new N2 PRI
Diffstat (limited to 'usr/src/lib/libpri')
| -rw-r--r-- | usr/src/lib/libpri/Makefile | 59 | ||||
| -rw-r--r-- | usr/src/lib/libpri/Makefile.com | 65 | ||||
| -rw-r--r-- | usr/src/lib/libpri/common/llib-lpri | 31 | ||||
| -rw-r--r-- | usr/src/lib/libpri/common/mapfile-vers | 35 | ||||
| -rw-r--r-- | usr/src/lib/libpri/common/pri.c | 182 | ||||
| -rw-r--r-- | usr/src/lib/libpri/common/pri.h | 51 | ||||
| -rw-r--r-- | usr/src/lib/libpri/sparc/Makefile | 30 | ||||
| -rw-r--r-- | usr/src/lib/libpri/sparcv9/Makefile | 31 |
8 files changed, 484 insertions, 0 deletions
diff --git a/usr/src/lib/libpri/Makefile b/usr/src/lib/libpri/Makefile new file mode 100644 index 0000000000..b5fe8834e5 --- /dev/null +++ b/usr/src/lib/libpri/Makefile @@ -0,0 +1,59 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.lib + +HDRS = pri.h +HDRDIR = common + +ROOTHDRDIR = $(ROOT)/usr/platform/sun4v/include/sys + +SUBDIRS = $(MACH) +$(BUILD64)SUBDIRS += $(MACH64) + +all := TARGET = all +clean := TARGET = clean +clobber := TARGET = clobber +install := TARGET = install +lint := TARGET = lint + +.KEEP_STATE: + +all clean clobber lint: $(SUBDIRS) + +check: $(CHECKHDRS) + +install: all .WAIT $(SUBDIRS) + +install_h: $(ROOTHDRS) + +$(SUBDIRS): FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: + +include ../Makefile.targ diff --git a/usr/src/lib/libpri/Makefile.com b/usr/src/lib/libpri/Makefile.com new file mode 100644 index 0000000000..997576cd58 --- /dev/null +++ b/usr/src/lib/libpri/Makefile.com @@ -0,0 +1,65 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +LIBRARY = libpri.a +VERS = .1 + +LIBSRCS = pri.c +OBJECTS = $(LIBSRCS:%.c=%.o) + +include ../../Makefile.lib + +LIBS = $(DYNLIB) $(LINTLIB) + +SRCDIR = ../common +SRCS = $(LIBSRCS:%.c=$(SRCDIR)/%.c) + +CPPFLAGS += -I. -I$(SRC)/uts/sun4v +CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS) +CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS) + +LDLIBS += -lc + +LINTFLAGS = -msux +LINTFLAGS64 = -msux -Xarch=$(MACH64:sparcv9=v9) + +$(LINTLIB) := SRCS = $(LINTSRC:%=$(SRCDIR)/%) +$(LINTLIB) := LINTFLAGS = -nsvx -I$(ROOT)/usr/platform/sun4v/include +$(LINTLIB) := LINTFLAGS64 = -nsvx -Xarch=$(MACH64:sparcv9=v9) \ + -I$(ROOT)/usr/platform/sun4v/include + +.KEEP_STATE: + +all: $(LIBS) + +lint: $(LINTLIB) lintcheck + +pics/%.o: $(SRCDIR)/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + +include ../../Makefile.targ diff --git a/usr/src/lib/libpri/common/llib-lpri b/usr/src/lib/libpri/common/llib-lpri new file mode 100644 index 0000000000..49367dc4da --- /dev/null +++ b/usr/src/lib/libpri/common/llib-lpri @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ +/*PROTOLIB1*/ + +#include <sys/pri.h> diff --git a/usr/src/lib/libpri/common/mapfile-vers b/usr/src/lib/libpri/common/mapfile-vers new file mode 100644 index 0000000000..fdc9b6f686 --- /dev/null +++ b/usr/src/lib/libpri/common/mapfile-vers @@ -0,0 +1,35 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +SUNWprivate { + global: + pri_fini; + pri_get; + pri_init; + local: + *; +}; diff --git a/usr/src/lib/libpri/common/pri.c b/usr/src/lib/libpri/common/pri.c new file mode 100644 index 0000000000..d6785a3fef --- /dev/null +++ b/usr/src/lib/libpri/common/pri.c @@ -0,0 +1,182 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <stdio.h> +#include <sys/param.h> +#include <fcntl.h> +#include <poll.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> + +#include "sys/ds_pri.h" +#include "pri.h" + +/* + * Library init function - currently no-op. + * Returns: Success (0), Failure (-1) + */ +int +pri_init(void) +{ + return (0); +} + +/* + * Library fini function - currently no-op. + * Returns: N/A + */ +void +pri_fini(void) +{ +} + +/* + * PRI retrieval function. + * Description: + * - Library routine to retrieve the Physical Resource Inventory (PRI) + * - Utilized by sun4v platforms which support Logical Domains + * - Interacts with the ds_pri pseudo driver to retrieve the + * PRI. ds_pri driver in turn gets the PRI from the + * Domain Services kernel module. Domain Services gets the + * PRI from the Service Processor via LDC (Logical Domain + * Channel). + * - Consumers of this api include FMA, Zeus, and picld + * - MT-Safe, Stateless + * + * Imports: + * - ds_pri driver interfaces + * + * Arguments: + * - wait: specifies whether caller wants to wait for a new PRI, + * PRI_GET is no-wait, PRI_WAITGET is wait-forever + * - token: opaque PRI token, accepted from and/or returned to caller, + * see write-only or read-write semantics below + * - buf: PRI buffer received from ds_pri driver, returned to caller + * - allocp: caller provided pointer to memory allocator function + * - freep: caller provided pointer to memory free function + * + * Calling Semantics: + * - PRI_GET call ignores the token passed in, and returns + * immediately with current PRI and its token (if any) + * - PRI_WAITGET call returns only upon the receipt of a new PRI + * whose token differs from the token passed in by the caller; + * the passed in token should come from a previous pri_get() + * call with return value >= 0; the new PRI buffer and its token + * are returned to the caller + * - If wait time must be bounded, the caller can spawn a thread + * which makes a PRI_WAITGET call; caller can choose to kill the + * spawned thread after a finite time + * + * Usage Semantics: + * - Caller can use the returned PRI buffer as an argument to + * to md_init_intern() to process it into a machine + * descriptor (md_t) format + * - Caller can choose to supply the same allocator and free + * functions to the md_init_intern() call + * - Once the caller is done using these data structures, + * the following actions need to be performed by the caller: + * - md_fini(mdp) if called md_init_intern() + * - freep(bufp, size) + * + * Returns: + * >0 if PRI is returned successfully (size of PRI buffer) + * 0 if no PRI is available + * -1 if there is an error (errno contains the error code) + * + */ +ssize_t +pri_get(uint8_t wait, uint64_t *token, uint64_t **buf, + void *(*allocp)(size_t), void (*freep)(void *, size_t)) +{ + int fd; /* for device open */ + uint64_t *bufp; /* buf holding PRI */ + size_t size; /* sizeof PRI */ + struct dspri_info pri_info; /* info about PRI */ + struct dspri_info pri_info2; /* for PRI delta check */ + + if ((fd = open(DS_PRI_DRIVER, O_RDONLY)) < 0) + return (-1); + + if (wait == PRI_WAITGET) { + /* wait until have new PRI with different token */ + if (ioctl(fd, DSPRI_WAIT, token) < 0) { + (void) close(fd); + return (-1); + } + } + + do { + /* get info on current PRI */ + if (ioctl(fd, DSPRI_GETINFO, &pri_info) < 0) { + (void) close(fd); + return (-1); + } + + size = (size_t)pri_info.size; + + /* check to see if no PRI available yet */ + if (size == 0) { + *token = pri_info.token; + (void) close(fd); + return (0); + } + + /* allocate a buffer and read the PRI into it */ + if ((bufp = (uint64_t *)allocp(size)) == NULL) { + (void) close(fd); + return (-1); + } + if (read(fd, bufp, size) < 0) { + freep(bufp, size); + (void) close(fd); + return (-1); + } + + /* + * Check whether PRI token changed between the time + * we did the DSPRI_GETINFO ioctl() and the actual + * read() from the ds_pri driver. The token delta check + * tries to catch the above race condition; be sure + * to not leak memory on retries. + */ + if (ioctl(fd, DSPRI_GETINFO, &pri_info2) < 0) { + freep(bufp, size); + (void) close(fd); + return (-1); + } + if (pri_info2.token != pri_info.token) + freep(bufp, size); + + } while (pri_info2.token != pri_info.token); + + /* return the PRI, its token, and its size to the caller */ + *buf = bufp; + *token = pri_info.token; + (void) close(fd); + return ((ssize_t)size); +} diff --git a/usr/src/lib/libpri/common/pri.h b/usr/src/lib/libpri/common/pri.h new file mode 100644 index 0000000000..683fa3f4f2 --- /dev/null +++ b/usr/src/lib/libpri/common/pri.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PRI_H +#define _PRI_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <stdlib.h> +#include <sys/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define PRI_GET 0 +#define PRI_WAITGET 1 +#define DS_PRI_DRIVER "/devices/pseudo/ds_pri@0:ds_pri" + +extern int pri_init(void); +extern void pri_fini(void); +extern ssize_t pri_get(uint8_t wait, uint64_t *token, uint64_t **buf, + void *(*allocp)(size_t), void (*freep)(void *, size_t)); + +#ifdef __cplusplus +} +#endif + +#endif /* _PRI_H */ diff --git a/usr/src/lib/libpri/sparc/Makefile b/usr/src/lib/libpri/sparc/Makefile new file mode 100644 index 0000000000..f91f0270e9 --- /dev/null +++ b/usr/src/lib/libpri/sparc/Makefile @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/lib/libpri/sparcv9/Makefile b/usr/src/lib/libpri/sparcv9/Makefile new file mode 100644 index 0000000000..a9d4d275db --- /dev/null +++ b/usr/src/lib/libpri/sparcv9/Makefile @@ -0,0 +1,31 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.com +include ../../Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) |
