2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
8 #include <sys/sunddi.h>
9 #include <sys/sunldi.h>
10 #include <sys/agpgart.h>
11 #include <sys/agp/agpdefs.h>
12 #include <sys/agp/agpgart_impl.h>
15 * The values of type agp_arc_type_t are used as indices into arc_name
16 * So if agp_arc_type_t's values are changed in the future, the content
17 * of arc_name must be changed accordingly.
19 static const char *arc_name
[] = {
28 static char *agpkstat_name
[] = {
46 agp_set_char_kstat(kstat_named_t
*knp
, const char *s
)
48 (void) strlcpy(knp
->value
.c
, s
, sizeof (knp
->value
.c
));
52 agp_kstat_update(kstat_t
*ksp
, int flag
)
54 agpgart_softstate_t
*sc
;
58 if (flag
!= KSTAT_READ
)
64 agp_set_char_kstat(knp
++, arc_name
[sc
->asoft_devreg
.agprd_arctype
]);
65 (knp
++)->value
.ui32
= sc
->asoft_info
.agpki_mdevid
;
66 (knp
++)->value
.ui32
= (sc
->asoft_info
.agpki_mver
.agpv_major
<<16) |
67 sc
->asoft_info
.agpki_mver
.agpv_minor
;
68 (knp
++)->value
.ui32
= sc
->asoft_info
.agpki_mstatus
;
69 (knp
++)->value
.ui64
= (sc
->asoft_info
.agpki_presize
<< 10) & UI32_MASK
;
70 (knp
++)->value
.ui32
= sc
->asoft_info
.agpki_tdevid
;
71 (knp
++)->value
.ui32
= (sc
->asoft_info
.agpki_tver
.agpv_major
<<16) |
72 sc
->asoft_info
.agpki_tver
.agpv_minor
;
73 (knp
++)->value
.ui32
= sc
->asoft_info
.agpki_tstatus
;
74 (knp
++)->value
.ui64
= sc
->asoft_info
.agpki_aperbase
;
76 (sc
->asoft_info
.agpki_apersize
<< 20) & UI32_MASK
;
78 tmp
= sc
->asoft_agpen
;
79 agp_set_char_kstat(knp
++, (tmp
> 0) ? "yes" : "no");
81 (knp
++)->value
.ui32
= sc
->asoft_mode
;
82 (knp
++)->value
.ui64
= (sc
->asoft_pgused
<< 12) & UI32_MASK
;
88 agp_init_kstats(agpgart_softstate_t
*sc
)
97 instance
= ddi_get_instance(sc
->asoft_dip
);
99 ksp
= kstat_create(AGPGART_DEVNODE
, instance
, "agpinfo", "agp",
100 KSTAT_TYPE_NAMED
, sizeof (agpkstat_name
)/sizeof (char *) - 1,
101 KSTAT_FLAG_PERSISTENT
);
105 ksp
->ks_private
= sc
;
106 ksp
->ks_update
= agp_kstat_update
;
107 for (knp
= ksp
->ks_data
; (np
= (*aknp
)) != NULL
; knp
++, aknp
++) {
111 type
= KSTAT_DATA_UINT64
;
115 type
= KSTAT_DATA_CHAR
;
118 type
= KSTAT_DATA_UINT32
;
122 kstat_named_init(knp
, np
, type
);
132 agp_fini_kstats(agpgart_softstate_t
*sc
)
134 ASSERT(sc
->asoft_ksp
);
135 kstat_delete(sc
->asoft_ksp
);