e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * CDDL HEADER START
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * The contents of this file are subject to the terms of the
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * Common Development and Distribution License (the "License").
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * You may not use this file except in compliance with the License.
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * See the License for the specific language governing permissions
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * and limitations under the License.
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * When distributing Covered Code, include this CDDL HEADER in each
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * If applicable, add the following below this CDDL HEADER, with the
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * fields enclosed by brackets "[]" replaced with your own identifying
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * information: Portions Copyright [yyyy] [name of copyright owner]
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * CDDL HEADER END
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * Use is subject to license terms.
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Yeextern int cpu_get_mem_addr(char *, char *, uint64_t, uint64_t *);
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye /* Verify FMRI scheme name and version number */
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye if ((nvlist_lookup_string(nvl, FM_FMRI_SCHEME, &scheme) != 0) ||
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye (nvlist_lookup_uint8(nvl, FM_VERSION, &version) != 0) ||
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * There are two ways a physical address can be obtained from a mem
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * scheme FMRI. One way is to use the "offset" and "serial"
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * members, if they are present, together with the "unum" member to
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * calculate a physical address. This is the preferred way since
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * it is independent of possible changes to the programming of
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * underlying hardware registers that may change the physical address.
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * If the "offset" member is not present, then the address is
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * retrieved from the "physaddr" member.
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye if (nvlist_lookup_uint64(nvl, FM_FMRI_MEM_OFFSET, &offset) != 0) {
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye if (nvlist_lookup_uint64(nvl, FM_FMRI_MEM_PHYSADDR, &pa) !=
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye } else if (nvlist_lookup_string(nvl, FM_FMRI_MEM_UNUM, &unum) != 0 ||
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye nvlist_lookup_string_array(nvl, FM_FMRI_MEM_SERIAL_ID, &serids,
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye err = cpu_get_mem_addr(unum, serids[0], offset, &pa);
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye /* Fall back to physaddr */