mcamd_api.h revision 8a40a695ee676a322b094e9afe5375567bfb51e3
/*
* 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
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _MCAMD_API_H
#define _MCAMD_API_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* routines not implemented there are required to be implemented in the
* kernel or userland consumer of this interface (such as the mc-amd driver).
* The common code must use the wrapper functions provided by the consumer
* to navigate the MC tree, get properties etc.
*/
#if defined(_KERNEL)
#else
#include <string.h>
#include <assert.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Consumers of this common code must implement the following types.
*/
typedef struct mcamd_node mcamd_node_t;
struct mcamd_hdl;
/*
* Properties and raw register values for an mcamd_node_t are retrieved via
* mcamd_get_numprop(s) and mcamd_get_cfgreg(s) specifying a property or
* register code below.
*/
typedef uint64_t mcamd_prop_t;
typedef uint32_t mcamd_cfgreg_t;
typedef enum mcamd_propcode {
/*
* Common properties
*/
MCAMD_PROP_NUM = 0x4000,
#define MCAMD_PROPSTR_NUM "num"
#define MCAMD_PROPSTR_SIZE "size"
#define MCAMD_PROPSTR_BASE_ADDR "base-addr"
/*
* Memory controller properties
*/
MCAMD_PROP_REV = 0x5000,
#define MCAMD_PROPSTR_REV "revision"
#define MCAMD_PROPSTR_LIM_ADDR "lim-addr"
#define MCAMD_PROPSTR_ILEN "node-ilen"
#define MCAMD_PROPSTR_ILSEL "node-ilsel"
#define MCAMD_PROPSTR_CSINTLVFCTR "cs-intlv-factor"
#define MCAMD_PROPSTR_DRAMHOLE_SIZE "dram-hole-size"
#define MCAMD_PROPSTR_ACCESS_WIDTH "access-width"
#define MCAMD_PROPSTR_CSBANKMAPREG "bank-mapping"
#define MCAMD_PROPSTR_BANKSWZL "bankswizzle"
#define MCAMD_PROPSTR_MOD64MUX "mismatched-dimm-support"
#define MCAMD_PROPSTR_SPARECS "spare-csnum"
#define MCAMD_PROPSTR_BADCS "bad-csnum"
/*
* Chip-select properties
*/
MCAMD_PROP_MASK = 0x6000,
#define MCAMD_PROPSTR_MASK "mask"
#define MCAMD_PROPSTR_CSBE "cs-bank-enable"
#define MCAMD_PROPSTR_SPARE "online-spare"
#define MCAMD_PROPSTR_TESTFAIL "failed-test"
#define MCAMD_PROPSTR_CSDIMM1 "dimm1-num"
#define MCAMD_PROPSTR_CSDIMM2 "dimm2-num"
#define MCAMD_PROPSTR_DIMMRANK "dimm-rank"
typedef enum mcamd_regcode {
MCAMD_REG_DRAMBASE = 0x7000,
/*
* Flags for mcamd_dprintf
*/
#define MCAMD_DBG_ERR 0x1
#define MCAMD_DBG_FLOW 0x2
typedef union mcamd_dimm_offset_un mcamd_dimm_offset_un_t;
/*
* Offset definition. Encode everything in a single uint64_t, allowing some
* Some consumers will handle this as an opaque uint64 to be passed around,
* while others will want to look inside via the union defined below. Since
* we must support a 32-bit kernel we structure this as two uint32_t.
*/
#define MCAMD_OFFSET_VERSION_0 0x0
union mcamd_dimm_offset_un {
struct {
struct {
} lo;
struct {
} hi;
} _dou_hilo;
};
#define do_offset _dou_offset
/*
* The following work on an offset treated as a uint64_t.
*/
/*
* Value to be used to indicate an invalid offset.
*/
#define MCAMD_RC_INVALID_OFFSET 0x0
/*
* Routines provided by the common mcamd code.
*/
extern const char *mcamd_get_propname(mcamd_propcode_t);
uint64_t *);
uint_t *);
int *, int *);
extern void *mcamd_set_errno_ptr(struct mcamd_hdl *, int);
extern const char *mcamd_strerror(int);
extern const char *mcamd_errmsg(struct mcamd_hdl *);
/*
* Routines to be provided by wrapper code.
*/
mcamd_node_t *);
mcamd_node_t *);
mcamd_node_t *);
extern int mcamd_get_numprops(struct mcamd_hdl *, ...);
extern int mcamd_get_cfgregs(struct mcamd_hdl *, ...);
extern int mcamd_errno(struct mcamd_hdl *);
extern int mcamd_set_errno(struct mcamd_hdl *, int);
extern void mcamd_dprintf(struct mcamd_hdl *, int, const char *, ...);
#ifdef __cplusplus
}
#endif
#endif /* _MCAMD_API_H */