xref: /titanic_52/usr/src/cmd/fm/modules/sun4v/generic-mem/gmem_page.h (revision 1529f529004c61fcfd0d95ab79b0f257d6ad4451)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _GMEM_PAGE_H
27 #define	_GMEM_PAGE_H
28 
29 
30 /*
31  * Routines for the creation of page retirement faults and for the management of
32  * page-related state.
33  */
34 
35 #include <gmem_state.h>
36 #include <gmem_fmri.h>
37 
38 #include <fm/fmd_api.h>
39 #include <sys/types.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #define	PAGE_MKVERSION(version)	(version)
46 
47 #define	CMD_PAGE_VERSION_0	PAGE_MKVERSION(0)
48 #define	CMD_PAGE_VERSION	CMD_PAGE_VERSION_0
49 
50 #define	CMD_PAGE_VERSIONED(page)	((page)->page_version)
51 
52 typedef struct gmem_page_pers {
53 	gmem_header_t pagep_header;	/* Nodetype must be CMD_NT_PAGE */
54 	uint_t pagep_version;
55 	gmem_fmri_t pagep_asru;		/* ASRU for this DIMM */
56 	uint64_t pagep_physbase;	/* base phys addr for page */
57 	uint64_t pagep_offset;		/* page offset */
58 	uint_t pagep_flags;		/* CMD_MEM_F_* */
59 } gmem_page_pers_t;
60 
61 typedef struct gmem_page {
62 	gmem_page_pers_t page_pers;
63 	gmem_case_t page_case;		/* Open CE case against this page */
64 } gmem_page_t;
65 
66 #define	CMD_PAGE_MAXSIZE sizeof (gmem_page_pers_t)
67 #define	CMD_PAGE_MINSIZE sizeof (gmem_page_pers_t)
68 
69 #define	page_header		page_pers.pagep_header
70 #define	page_nodetype		page_pers.pagep_header.hdr_nodetype
71 #define	page_bufname		page_pers.pagep_header.hdr_bufname
72 #define	page_version		page_pers.pagep_version
73 #define	page_asru		page_pers.pagep_asru
74 #define	page_asru_nvl		page_pers.pagep_asru.fmri_nvl
75 #define	page_flags		page_pers.pagep_flags
76 #define	page_physbase		page_pers.pagep_physbase
77 #define	page_offset		page_pers.pagep_offset
78 #define	page_list		page_header.hdr_list
79 
80 /*
81  * Page retirement
82  *
83  * When a page is to be retired, these routines are called to generate and
84  * manage a fault.memory.page against the page.
85  */
86 extern int gmem_page_fault(fmd_hdl_t *, nvlist_t *, nvlist_t *, fmd_event_t *,
87     uint64_t, uint64_t);
88 extern void gmem_page_close(fmd_hdl_t *, void *);
89 
90 extern gmem_page_t *gmem_page_create(fmd_hdl_t *, nvlist_t *, uint64_t,
91     uint64_t);
92 extern gmem_page_t *gmem_page_lookup(uint64_t);
93 
94 extern void gmem_page_dirty(fmd_hdl_t *, gmem_page_t *);
95 extern void *gmem_page_restore(fmd_hdl_t *, fmd_case_t *, gmem_case_ptr_t *);
96 extern void gmem_page_validate(fmd_hdl_t *);
97 extern void gmem_page_destroy(fmd_hdl_t *, gmem_page_t *);
98 extern void gmem_page_fini(fmd_hdl_t *);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* _GMEM_PAGE_H */
105