29949e866e40b95795203f3ee46f44a197c946e4stevel * CDDL HEADER START
29949e866e40b95795203f3ee46f44a197c946e4stevel * The contents of this file are subject to the terms of the
29949e866e40b95795203f3ee46f44a197c946e4stevel * Common Development and Distribution License (the "License").
29949e866e40b95795203f3ee46f44a197c946e4stevel * You may not use this file except in compliance with the License.
29949e866e40b95795203f3ee46f44a197c946e4stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
29949e866e40b95795203f3ee46f44a197c946e4stevel * See the License for the specific language governing permissions
29949e866e40b95795203f3ee46f44a197c946e4stevel * and limitations under the License.
29949e866e40b95795203f3ee46f44a197c946e4stevel * When distributing Covered Code, include this CDDL HEADER in each
29949e866e40b95795203f3ee46f44a197c946e4stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
29949e866e40b95795203f3ee46f44a197c946e4stevel * If applicable, add the following below this CDDL HEADER, with the
29949e866e40b95795203f3ee46f44a197c946e4stevel * fields enclosed by brackets "[]" replaced with your own identifying
29949e866e40b95795203f3ee46f44a197c946e4stevel * information: Portions Copyright [yyyy] [name of copyright owner]
29949e866e40b95795203f3ee46f44a197c946e4stevel * CDDL HEADER END
29949e866e40b95795203f3ee46f44a197c946e4stevel * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Use is subject to license terms.
29949e866e40b95795203f3ee46f44a197c946e4stevel#pragma ident "%Z%%M% %I% %E% SMI"
29949e866e40b95795203f3ee46f44a197c946e4stevelextern "C" {
29949e866e40b95795203f3ee46f44a197c946e4stevel/* useful debugging stuff */
29949e866e40b95795203f3ee46f44a197c946e4stevel * OBP supplies us with two register sets for the AC nodes. They are:
29949e866e40b95795203f3ee46f44a197c946e4stevel * 0 miscellaneous regs
29949e866e40b95795203f3ee46f44a197c946e4stevel * 1 Cache tags
29949e866e40b95795203f3ee46f44a197c946e4stevel * We do not use the cache tags for anything in the kernel, so we
29949e866e40b95795203f3ee46f44a197c946e4stevel * do not map them in.
29949e866e40b95795203f3ee46f44a197c946e4stevel/* Macros for physical acccess, fhc.h has to be present */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_BCSR(board) (FHC_BOARD_BASE(2*(board)) + FHC_OFFSET + \
29949e866e40b95795203f3ee46f44a197c946e4stevel/* Register set 0 Offsets */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* Use predefined strings to name the kstats from this driver. */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* used for the picN kstats */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_COUNTER_TO_PIC0(CNTR) ((CNTR) & 0xFFFFFFFFULL)
29949e866e40b95795203f3ee46f44a197c946e4stevel/* used to clear/set the pcr */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* used for programming the pic */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_SET_PIC_BUS_PAUSE(BRD) (0x80000000LL - 0x9ac4 - ((BRD) << 3))
29949e866e40b95795203f3ee46f44a197c946e4stevel/* defines for AC Board Configuration and Status Register */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* defines for Memory decode registers */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* size of a memory SIMM group */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define RASIZE0(memctl) (8 << ((((memctl) >> 8) & 0x7) << 1))
29949e866e40b95795203f3ee46f44a197c946e4stevel#define RASIZE1(memctl) (8 << ((((memctl) >> 11) & 0x7) << 1))
29949e866e40b95795203f3ee46f44a197c946e4stevel * Interleave factor of a memory SIMM group.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Possible values are 1, 2, 4, 8, and 16. 1 means not interleaved.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Larger groups can be interleaved with smaller groups. Groups
29949e866e40b95795203f3ee46f44a197c946e4stevel * on the same board can be interleaved as well.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Physical base mask of a memory SIMM group. Note that this is
29949e866e40b95795203f3ee46f44a197c946e4stevel * not the real physical base, and is just used to match up the
29949e866e40b95795203f3ee46f44a197c946e4stevel * interleaving of groups. The mask bits (UK) are used to mask
29949e866e40b95795203f3ee46f44a197c946e4stevel * out the match (UM) field so that the bases can be compared.
29949e866e40b95795203f3ee46f44a197c946e4stevel#define GRP_BASE(memdec) (GRP_UM(memdec) & ~(GRP_UK(memdec)))
29949e866e40b95795203f3ee46f44a197c946e4stevel#define GRP_LBASE(memdec) (GRP_LM(memdec) & ~(GRP_LK(memdec)))
29949e866e40b95795203f3ee46f44a197c946e4stevel#define GRP_REALBASE(m) ((GRP_BASE(m) << 26) | (GRP_LBASE(m) << 6))
29949e866e40b95795203f3ee46f44a197c946e4stevel#define GRP_UK2SPAN(memdec) ((GRP_UK(memdec) + 1) << 26)
29949e866e40b95795203f3ee46f44a197c946e4stevel#define GRP_SPANMB(memdec) (GRP_UK2SPAN(memdec) >> 20)
29949e866e40b95795203f3ee46f44a197c946e4stevel * memory states and conditions for sunfire memory system
29949e866e40b95795203f3ee46f44a197c946e4stevelenum ac_bank_status { StUnknown = 0, StNoMem, StBad, StActive, StSpare };
29949e866e40b95795203f3ee46f44a197c946e4stevelenum ac_bank_condition { ConUnknown = 0, ConOK, ConFailing, ConFailed,
29949e866e40b95795203f3ee46f44a197c946e4stevel * AC memory bank ioctl interface.
29949e866e40b95795203f3ee46f44a197c946e4stevel/* 'G' (for gigabytes!) does not appear to be used elsewhere in the kernel */
29949e866e40b95795203f3ee46f44a197c946e4stevel * For all AC_MEM_ ioctls the arg pointer points to a sysc_cfga_cmd_t
29949e866e40b95795203f3ee46f44a197c946e4stevel * except for AC_MEM_ADMIN_VER. The private pointer then points to a
29949e866e40b95795203f3ee46f44a197c946e4stevel * structure of the appropriate type, if required.
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_MEM_ADMIN_VER (AC_IOC|0) /* arg is &ac_mem_version_t */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_MEM_CONFIGURE (AC_IOC|1) /* private == NULL */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_MEM_UNCONFIGURE (AC_IOC|2) /* private == NULL */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_MEM_TEST_START (AC_IOC|4) /* ac_mem_test_start_t */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_MEM_TEST_STOP (AC_IOC|5) /* ac_mem_test_stop_t */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_MEM_TEST_READ (AC_IOC|6) /* ac_mem_test_read_t */
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_MEM_TEST_WRITE (AC_IOC|7) /* ac_mem_test_write_t */
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef enum {
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_PRECHARGE, /* not enough precharge for slot */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_HW_COMPAT, /* incompatible hardware found during dr */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_NON_DR_PROM, /* prom not support Dynamic Reconfiguration */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_CORE_RESOURCE, /* core resource cannot be removed */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_DR_INIT, /* error encountered in sysc_dr_init op */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_NDI_ATTACH, /* error encountered in NDI attach operations */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_NDI_DETACH, /* error encountered in NDI detach operations */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_MEM_TEST_PAR, /* invalid memory test parameter(s) */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_KPM_CANCELLED, /* kphysm_del_cancel (for complete) */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_KPM_REFUSED, /* kphysm_pre_del failed (for complete) */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_KPM_FAULT, /* memory access test failed (add) */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_KPM_RESOURCE, /* some resource was not available */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_KPM_NOHANDLES, /* cannot allocate any more handles */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_KPM_NONRELOC, /* non-relocatable pages in span */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_KPM_BUSY, /* memory in span is being deleted */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_KPM_SEQUENCE, /* function called out of sequence */
29949e866e40b95795203f3ee46f44a197c946e4stevel AC_ERR_MEM_DEINTLV /* could not de-interleave memory */
29949e866e40b95795203f3ee46f44a197c946e4stevel * Config admin command structure for AC_MEM ioctls.
29949e866e40b95795203f3ee46f44a197c946e4stevel caddr32_t outputstr; /* output returned from ioctl */
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef uint_t ac_mem_version_t; /* platform interface rev */
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel * page_size gives the requires size for the read or write buffer.
29949e866e40b95795203f3ee46f44a197c946e4stevel * A read can be restricted to one or more line_size units starting
29949e866e40b95795203f3ee46f44a197c946e4stevel * at a multiple of line_size units from the start of the page.
29949e866e40b95795203f3ee46f44a197c946e4stevel * afar_base is the physical base of the bank being tested so
29949e866e40b95795203f3ee46f44a197c946e4stevel * that the afar value can be translated to an offset into the bank.
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel * line_offset is in the range 0 - (page_size/line_size)-1
29949e866e40b95795203f3ee46f44a197c946e4stevel * line_count is in the range 1 - (page_size/line_size)
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel * Data will be transferred in/out of the buffer at:
29949e866e40b95795203f3ee46f44a197c946e4stevel * (page_buf + (line_offset*line_size))
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel/* Kernel's view of ILP32 structure version. */
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel caddr32_t error_buf; /* sunfire_processor_error_regs_t */
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* _SYSCALL32 */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* structure returned from AC_MEM_STAT ioctl */
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel /* to supply address, group, info */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* Kernel's view of ILP32 structure version. */
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel /* to supply address, group, info */
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* _SYSCALL32 */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* Command values in cmd_cfga.arg for the AC_MEM_EXERCISE ioctl. */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* Stats structure for AC_MEMX_RELOCATE_ALL (cmd_cfga.private != NULL). */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* End of ioctl interface. */
29949e866e40b95795203f3ee46f44a197c946e4steveltypedef struct {
29949e866e40b95795203f3ee46f44a197c946e4stevel#define AC_ERR_SET(pkt, err) (pkt)->cmd_cfga.errtype = (err)
29949e866e40b95795203f3ee46f44a197c946e4stevel * Test for a valid size setting. The size must be set as
29949e866e40b95795203f3ee46f44a197c946e4stevel * a contiguous number of bits starting at the least significant bit.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Adding one to such a number causes a carry to be propagated to
29949e866e40b95795203f3ee46f44a197c946e4stevel * the first zero bit, eg 00111 -> 01000. Thus for a correctly
29949e866e40b95795203f3ee46f44a197c946e4stevel * formed value, the AND of the two numbers is 0.
29949e866e40b95795203f3ee46f44a197c946e4stevel#define GRP_SIZE_IS_SET(memdec) ((GRP_UK(memdec) & (GRP_UK(memdec) + 1)) == 0)
29949e866e40b95795203f3ee46f44a197c946e4stevel/* set the decode register bits according to the desired bank layout */
29949e866e40b95795203f3ee46f44a197c946e4stevel * Driver minor number macros.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Attachment point names.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Memory Database
29949e866e40b95795203f3ee46f44a197c946e4stevel * This information is generally accessed through the bd_list so we will
29949e866e40b95795203f3ee46f44a197c946e4stevel * just protect it by that for now.
29949e866e40b95795203f3ee46f44a197c946e4stevel/* Structures used in the driver to manage the hardware */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* fields protected by bd_list lock */
29949e866e40b95795203f3ee46f44a197c946e4stevel struct ac_mem_info bank[2]; /* memory bank information */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* Mapped addresses of registers */
29949e866e40b95795203f3ee46f44a197c946e4stevel void *ac_base; /* Base address of Address Controller */
29949e866e40b95795203f3ee46f44a197c946e4stevel volatile uint64_t *ac_memdecode0; /* Memory Decode 0 */
29949e866e40b95795203f3ee46f44a197c946e4stevel volatile uint64_t *ac_memdecode1; /* Memory Decode 1 */
29949e866e40b95795203f3ee46f44a197c946e4stevel volatile uint64_t *ac_counter; /* AC counter register */
29949e866e40b95795203f3ee46f44a197c946e4stevel kstat_t *ac_counters_ksp; /* performance counter kstat */
29949e866e40b95795203f3ee46f44a197c946e4stevelextern void ac_blkcopy(caddr_t, caddr_t, uint_t, uint_t);
29949e866e40b95795203f3ee46f44a197c946e4stevel/* kstat structure used by ac to pass data to user programs. */
29949e866e40b95795203f3ee46f44a197c946e4stevel struct kstat_named ac_memctl; /* AC Memory control */
29949e866e40b95795203f3ee46f44a197c946e4stevel struct kstat_named ac_memdecode0; /* AC Memory Decode Bank 0 */
29949e866e40b95795203f3ee46f44a197c946e4stevel struct kstat_named ac_memdecode1; /* AC Memory Decode Bank 1 */
29949e866e40b95795203f3ee46f44a197c946e4stevel struct kstat_named ac_mccr; /* AC Mem Counter Control */
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* _KERNEL */
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* _SYS_AC_H */