2 * Copyright (c) 2009, Intel Corporation.
7 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
8 * Use is subject to license terms.
11 #ifndef _SYS_AGPGART_IMPL_H
12 #define _SYS_AGPGART_IMPL_H
21 #define AGPGART_MAX_INSTANCES 1
22 #define AGP_MAXKEYS 256
23 #define AGPGART_DEVNODE "agpgart"
26 * The values of type agp_arc_type_t are used as indexes into arc_name
28 * So if agp_arc_type_t's values are changed in the future, the content
29 * of arc_name must be changed accordingly.
38 typedef enum agp_arc_type agp_arc_type_t
;
40 /* linked list structure of multiple agp gart devices access handles */
41 typedef struct amd64_gart_dev_list
{
42 ldi_handle_t gart_devhdl
;
43 struct amd64_gart_dev_list
*next
;
44 } amd64_gart_dev_list_t
;
46 typedef struct amd64_garts_dev
{
48 amd64_gart_dev_list_t
*gart_dev_list_head
;
52 * AGP target and master device register their config space access
54 * In AMD64, gart_device_num is the number of hostbridge (device(1100, 1022))
55 * refer to <<Bios and Kernel Developer's Guide for AMD athlon64 and operton>>
57 typedef struct agp_registered_dev
{
58 amd64_garts_dev_t agprd_cpugarts
;
59 ldi_handle_t agprd_targethdl
;
60 ldi_handle_t agprd_masterhdl
;
61 agp_arc_type_t agprd_arctype
; /* system types */
62 } agp_registered_dev_t
;
65 * If the OS have direct mapping support for mapping physical page frames
66 * directly to user address, we use this struct for memory
69 typedef struct agp_pmem_handle
{
70 devmap_pmem_cookie_t pmem_cookie
;
74 * This struct is used for DDI-compliant memory allocations.
76 typedef struct agp_kmem_handle
{
77 ddi_dma_handle_t kmem_handle
;
78 ddi_dma_cookie_t kmem_dcookie
;
79 uint32_t kmem_cookies_num
;
82 ddi_acc_handle_t kmem_acchdl
;
85 typedef struct keytable_ent
{
86 int kte_type
; /* agp memory type */
87 int kte_key
; /* memory key */
88 uint32_t kte_pgoff
; /* aperture offset bound in pages */
89 pgcnt_t kte_pages
; /* user-requested size in pages */
90 int kte_bound
; /* bound to gart table */
91 void *kte_memhdl
; /* agp_kmem or agp_pmem handle */
92 pfn_t
*kte_pfnarray
; /* page frame numbers allocated */
93 int kte_refcnt
; /* reference count */
96 typedef struct key_list
{
98 struct key_list
*next
;
104 typedef struct agp_kern_info
{
105 uint32_t agpki_mdevid
;
106 agp_version_t agpki_mver
;
107 uint32_t agpki_mstatus
;
108 size_t agpki_presize
; /* valid only for IGD, in KB */
109 uint32_t agpki_tdevid
;
110 agp_version_t agpki_tver
;
111 uint32_t agpki_tstatus
;
112 uint64_t agpki_aperbase
;
113 uint32_t agpki_apersize
; /* in MB */
116 #ifdef _MULTI_DATAMODEL
117 typedef struct _agp_info32
{
118 agp_version_t agpi32_version
;
119 uint32_t agpi32_devid
; /* device VID + DID */
120 uint32_t agpi32_mode
; /* mode of bridge */
121 uint32_t agpi32_aperbase
; /* base of aperture */
122 uint32_t agpi32_apersize
; /* in MB */
123 uint32_t agpi32_pgtotal
; /* max number of pages */
124 uint32_t agpi32_pgsystem
; /* same as pg_total */
125 uint32_t agpi32_pgused
; /* pages consumed */
127 #endif /* _MULTI_DATAMODEL */
130 struct list_head
*next
, *prev
;
131 struct igd_gtt_seg
*gttseg
;
135 typedef struct agpgart_softstate
{
136 dev_info_t
*asoft_dip
;
137 kmutex_t asoft_instmutex
;
138 agp_kern_info_t asoft_info
;
139 int asoft_opened
; /* 0 not opened, non-0 opened */
140 int asoft_acquired
; /* 0 released, 1 acquired */
141 int asoft_agpen
; /* 0 disbaled, 1 enabled */
142 pid_t asoft_curpid
; /* the process accquiring gart */
143 uint32_t asoft_mode
; /* agp mode be set */
144 uint32_t asoft_pgtotal
; /* total available pages */
145 uint32_t asoft_pgused
; /* pages already used */
146 /* resource handles */
147 ldi_ident_t asoft_li
; /* for ldi ops */
148 keytable_ent_t
*asoft_table
; /* key table for all allocated table */
149 ddi_dma_handle_t gart_dma_handle
; /* for GATT table */
150 ddi_acc_handle_t gart_dma_acc_handle
; /* for GATT table */
152 /* gart table info */
153 uint64_t gart_pbase
; /* gart table physical address */
154 caddr_t gart_vbase
; /* kernel-vir addr for GATT table */
155 size_t gart_size
; /* the size of aperture in megabytes */
156 /* all registered agp device in here */
157 agp_registered_dev_t asoft_devreg
;
159 struct list_head mapped_list
;
160 } agpgart_softstate_t
;
162 typedef struct agpgart_ctx
{
164 agpgart_softstate_t
*actx_sc
;
167 #define KMEMP(p) ((agp_kmem_handle_t *)p)
168 #define PMEMP(p) ((agp_pmem_handle_t *)p)
170 int agp_init_kstats(agpgart_softstate_t
*);
171 void agp_fini_kstats(agpgart_softstate_t
*);
179 #endif /* _SYS_AGPGART_IMPL_H */