1 | /*␊ |
2 | * ATI injector␊ |
3 | *␊ |
4 | * Copyright (C) 2009 Jasmin Fazlic, iNDi, netkas␊ |
5 | *␊ |
6 | * ATI injector is free software: you can redistribute it and/or modify␊ |
7 | * it under the terms of the GNU General Public License as published by␊ |
8 | * the Free Software Foundation, either version 3 of the License, or␊ |
9 | * (at your option) any later version.␊ |
10 | *␊ |
11 | * ATI driver and injector is distributed in the hope that it will be useful,␊ |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of␊ |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the␊ |
14 | * GNU General Public License for more details.␊ |
15 | *␊ |
16 | * You should have received a copy of the GNU General Public License␊ |
17 | * along with ATI injector. If not, see <http://www.gnu.org/licenses/>.␊ |
18 | */ ␊ |
19 | /*␊ |
20 | * Alternatively you can choose to comply with APSL␊ |
21 | */␊ |
22 | ␊ |
23 | #include "libsa.h"␊ |
24 | #include "saio_internal.h"␊ |
25 | #include "bootstruct.h"␊ |
26 | #include "pci.h"␊ |
27 | #include "platform.h"␊ |
28 | #include "device_inject.h"␊ |
29 | #include "ati.h"␊ |
30 | ␊ |
31 | #ifndef DEBUG_ATI␊ |
32 | #define DEBUG_ATI 0␊ |
33 | #endif␊ |
34 | ␊ |
35 | #if DEBUG_ATI␊ |
36 | #define DBG(x...)␉printf(x)␊ |
37 | #else␊ |
38 | #define DBG(x...)␊ |
39 | #endif␊ |
40 | ␊ |
41 | #define kUseAtiROMKey␉␉"UseAtiROM"␊ |
42 | #define kAtiConfig␉␉␉"AtiConfig"␊ |
43 | ␊ |
44 | #define MAX_NUM_DCB_ENTRIES 16␊ |
45 | ␊ |
46 | #define TYPE_GROUPED 0xff␊ |
47 | ␊ |
48 | extern uint32_t devices_number;␊ |
49 | ␊ |
50 | // ====================//====================␊ |
51 | // properties␊ |
52 | ␊ |
53 | // "@"␊ |
54 | const char *ati_name_0[]␉␉␉␉␉␉␉= { "@0,name",␉␉␉␉"ATY,%s"␉};␊ |
55 | const char *ati_name_1[]␉␉␉␉␉␉␉= { "@1,name",␉␉␉␉"ATY,%s"␉};␊ |
56 | const char *ati_device_type_0[]␉␉␉␉␉␉= { "@0,device_type",␉␉"display"␉};␊ |
57 | const char *ati_device_type_1[]␉␉␉␉␉␉= { "@1,device_type",␉␉"display"␉};␊ |
58 | const char *ati_compatible_0[]␉␉␉␉␉␉= { "@0,compatible",␉␉"ATY,%s"␉};␊ |
59 | const char *ati_compatible_1[]␉␉␉␉␉␉= { "@1,compatible",␉␉"ATY,%s"␉};␊ |
60 | const char *ati_efidisplay_0[]␉␉␉␉␉␉= { "@0,ATY,EFIDisplay",␉"TMDSB"␉␉};␊ |
61 | const char *ati_display_type_0[]␉␉␉␉␉= { "@0,display-type",␉␉"LCD"␉␉};␊ |
62 | const char *ati_display_type_1[]␉␉␉␉␉= { "@1,display-type",␉␉"NONE"␉␉};␊ |
63 | ␊ |
64 | // no "@"␊ |
65 | const char *ati_name[]␉␉␉␉␉␉␉␉= { "name",␉␉␉␉␉"ATY,%sParent"␉};␊ |
66 | const char *ati_device_type[]␉␉␉␉␉␉= { "device_type",␉␉␉"ATY,%sParent"␉};␊ |
67 | const char *ati_card_no[]␉␉␉␉␉␉␉= { "ATY,Card#",␉␉␉"109-B77101-00"␉};␊ |
68 | const char *ati_copyright[]␉␉␉␉␉␉␉= { "ATY,Copyright",␉␉"Copyright AMD Inc. All Rights Reserved. 2005-2009" };␊ |
69 | const char *ati_efi_compile_d[]␉␉␉␉␉␉= { "ATY,EFICompileDate",␉"Jan 26 2009"␉␉␉};␊ |
70 | const char *ati_efi_version[]␉␉␉␉␉␉= { "ATY,EFIVersion",␉␉"01.00.318"␉␉␉␉};␊ |
71 | const char *ati_efi_versionB[]␉␉␉␉␉␉= { "ATY,EFIVersionB",␉␉"113-SBSJ1G04-00R-02"␉};␊ |
72 | const char *ati_efi_versionE[]␉␉␉␉␉␉= { "ATY,EFIVersionE",␉␉"113-B7710A-318"␉␉};␊ |
73 | const char *ati_mrt[]␉␉␉␉␉␉␉␉= { "ATY,MRT",␉␉␉␉" " };␊ |
74 | const char *ati_romno[]␉␉␉␉␉␉␉␉= { "ATY,Rom#",␉␉␉␉"113-B7710C-176" };␊ |
75 | // non 48xx key ???␊ |
76 | const char *ati_efidisplay_0_n4[]␉␉␉␉␉= { "@0,ATY,EFIDisplay",␉"TMDSA" };␊ |
77 | ␊ |
78 | // =====//=====␊ |
79 | ␊ |
80 | // ati_data_key "@"␊ |
81 | struct ati_data_key ati_connector_type_0␉␉␉= { 0x04, "@0,connector-type",␉␉␉{0x00, 0x04, 0x00, 0x00} };␊ |
82 | struct ati_data_key ati_connector_type_1␉␉␉= { 0x04, "@1,connector-type",␉␉␉{0x04, 0x00, 0x00, 0x00} };␊ |
83 | struct ati_data_key ati_display_con_fl_type_0␉␉= { 0x04, "@0,display-connect-flags",␉{0x00, 0x00, 0x04, 0x00} };␊ |
84 | // non 48xx keys ???␊ |
85 | struct ati_data_key ati_connector_type_0_n4␉␉␉= { 0x04, "@0,connector-type",␉␉␉{0x04, 0x00, 0x00, 0x00} };␊ |
86 | struct ati_data_key ati_connector_type_1_n4␉␉␉= { 0x04, "@1,connector-type",␉␉␉{0x00, 0x02, 0x00, 0x00} };␊ |
87 | struct ati_data_key ati_vram_memsize_0␉␉␉␉= { 0x08, "@0,VRAM,memsize",␉␉␉{0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00} };␊ |
88 | struct ati_data_key ati_vram_memsize_1␉␉␉␉= { 0x08, "@1,VRAM,memsize",␉␉␉{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
89 | ␊ |
90 | // no "@"␊ |
91 | struct ati_data_key ati_aux_power_conn␉␉␉␉= { 0x04, "AAPL,aux-power-connected",␉{0x01, 0x00, 0x00, 0x00} };␊ |
92 | struct ati_data_key ati_backlight_ctrl␉␉␉␉= { 0x04, "AAPL,backlight-control",␉␉{0x00, 0x00, 0x00, 0x00} };␊ |
93 | struct ati_data_key ati_aapl01_coher␉␉␉␉= { 0x04, "AAPL01,Coherency",␉␉␉{0x01, 0x00, 0x00, 0x00} };␊ |
94 | struct ati_data_key ati_efi_disp_conf␉␉␉␉= { 0x08, "ATY,EFIDispConfig",␉␉␉{0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} };␊ |
95 | struct ati_data_key ati_efi_drv_type␉␉␉␉= { 0x01, "ATY,EFIDriverType",␉␉␉{0x02} };␊ |
96 | struct ati_data_key ati_efi_enbl_mode␉␉␉␉= { 0x01, "ATY,EFIEnabledMode",␉␉␉{0x01} };␊ |
97 | struct ati_data_key ati_efi_init_stat␉␉␉␉= { 0x04, "ATY,EFIHWInitStatus",␉␉{0x00, 0x00, 0x00, 0x00} };␊ |
98 | struct ati_data_key ati_efi_orientation␉␉␉␉= { 0x02, "ATY,EFIOrientation",␉␉␉{0x02, 0x00} };␊ |
99 | struct ati_data_key ati_mclk␉␉␉␉␉␉= { 0x04, "ATY,MCLK",␉␉␉␉␉{0x70, 0x2e, 0x11, 0x00} };␊ |
100 | struct ati_data_key ati_mem_rev_id␉␉␉␉␉= { 0x02, "ATY,MemRevisionID",␉␉␉{0x03, 0x00} };␊ |
101 | struct ati_data_key ati_mem_vend_id␉␉␉␉␉= { 0x02, "ATY,MemVendorID",␉␉␉{0x02, 0x00} };␊ |
102 | struct ati_data_key ati_sclk␉␉␉␉␉␉= { 0x04, "ATY,SCLK",␉␉␉␉␉{0x28, 0xdb, 0x0b, 0x00} };␊ |
103 | struct ati_data_key ati_vendor_id␉␉␉␉␉= { 0x02, "ATY,VendorID",␉␉␉␉{0x02, 0x10} };␊ |
104 | ␊ |
105 | struct ati_data_key ati_platform_info␉␉␉␉= { 0x80, "ATY,PlatformInfo",␊ |
106 | ␉{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
107 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
108 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
109 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
110 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
111 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
112 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
113 | ␊ |
114 | struct ati_data_key ati_mvad␉␉␉␉␉␉= { 0x40, "MVAD",␊ |
115 | ␉{0x3f, 0x5c, 0x82, 0x02, 0xff, 0x90, 0x00, 0x54, 0x60, 0x00, 0xac, 0x10, 0xa0, 0x17, 0x00, 0x03, 0xb0, 0x68, 0x00, 0x0a,␊ |
116 | ␉ 0xa0, 0x0a, 0x30, 0x00, 0x20, 0x00, 0x40, 0x06, 0x6e, 0x06, 0x03, 0x00, 0x06, 0x00, 0x40, 0x06, 0x00, 0x0a, 0x10, 0x01,␊ |
117 | ␉ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x10, 0x06,␊ |
118 | ␉ 0x92, 0x20, 0x00, 0x03} };␊ |
119 | ␊ |
120 | struct ati_data_key ati_saved_config␉␉␉␉= { 0x100, "saved-config",␊ |
121 | ␉{0x3f, 0x5c, 0x82, 0x02, 0xff, 0x90, 0x00, 0x54, 0x60, 0x00, 0xac, 0x10, 0xa0, 0x17, 0x00, 0x03, 0xb0, 0x68, 0x00, 0x0a,␊ |
122 | ␉ 0xa0, 0x0a, 0x30, 0x00, 0x20, 0x00, 0x40, 0x06, 0x6e, 0x06, 0x03, 0x00, 0x06, 0x00, 0x40, 0x06, 0x00, 0x0a, 0x10, 0x01,␊ |
123 | ␉ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x10, 0x06,␊ |
124 | ␉ 0x92, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
125 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,␊ |
126 | ␉ 0x00, 0x00, 0x00, 0x02, 0xee, 0x02, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44,␊ |
127 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00,␊ |
128 | ␉ 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
129 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
130 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
131 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
132 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
133 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
134 | // non 48xx keys ???␊ |
135 | struct ati_data_key ati_fb_offset_n4␉␉␉␉= { 0x08, "ATY,FrameBufferOffset",␉␉{0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00} };␊ |
136 | struct ati_data_key ati_hwgpio_n4␉␉␉␉␉= { 0x04, "ATY,HWGPIO",␉␉␉␉␉{0x23, 0xa8, 0x48, 0x00} };␊ |
137 | struct ati_data_key ati_iospace_offset_n4␉␉␉= { 0x08, "ATY,IOSpaceOffset",␉␉␉{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00} };␊ |
138 | struct ati_data_key ati_mclk_n4␉␉␉␉␉␉= { 0x04, "ATY,MCLK",␉␉␉␉␉{0x00, 0x35, 0x0c, 0x00} };␊ |
139 | struct ati_data_key ati_sclk_n4␉␉␉␉␉␉= { 0x04, "ATY,SCLK",␉␉␉␉␉{0x60, 0xae, 0x0a, 0x00} };␊ |
140 | struct ati_data_key ati_refclk_n4␉␉␉␉␉= { 0x04, "ATY,RefCLK",␉␉␉␉␉{0x8c, 0x0a, 0x00, 0x00} };␊ |
141 | struct ati_data_key ati_regspace_offset_n4␉␉␉= { 0x08, "ATY,RegisterSpaceOffset",␉{0x00, 0x00, 0x00, 0x00, 0x90, 0xa2, 0x00, 0x00} };␊ |
142 | struct ati_data_key ati_aapl_blackscr_prefs_0_n4␉= { 0x04, "AAPL00,blackscreen-preferences", {0x00, 0x00, 0x00, 0x00} };␊ |
143 | struct ati_data_key ati_aapl_blackscr_prefs_1_n4␉= { 0x04, "AAPL01,blackscreen-preferences", {0x00, 0x00, 0x00, 0x00} };␊ |
144 | struct ati_data_key ati_swgpio_info_n4␉␉␉␉= { 0x04, "ATY,SWGPIO Info",␉␉␉{0x00, 0x48, 0xa8, 0x23} };␊ |
145 | struct ati_data_key ati_efi_orientation_n4␉␉␉= { 0x01, "ATY,EFIOrientation",␉␉␉{0x08} };␊ |
146 | ␊ |
147 | struct ati_data_key ati_aapl_emc_disp_list_n4␉␉= { 0x40, "AAPL,EMC-Display-List",␊ |
148 | ␉{0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00,␊ |
149 | ␉ 0x1b, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x1c, 0x92, 0x00, 0x00,␊ |
150 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
151 | ␉ 0x00, 0x00, 0x00, 0x00} };␊ |
152 | ␊ |
153 | struct ati_data_key ati_mvad_n4␉␉␉␉ ␉␉= { 0x100, "MVAD",␊ |
154 | ␉{0x3e, 0x5c, 0x82, 0x00, 0xff, 0x90, 0x00, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3c, 0x80, 0x07,␊ |
155 | ␉ 0x20, 0x08, 0x30, 0x00, 0x20, 0x00, 0xb0, 0x04, 0xd3, 0x04, 0x03, 0x00, 0x06, 0x00, 0xb0, 0x04, 0x80, 0x07, 0x00, 0x01,␊ |
156 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
157 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
158 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,␊ |
159 | ␉ 0x00, 0x00, 0x00, 0x02, 0x90, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44,␊ |
160 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00,␊ |
161 | ␉ 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
162 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
163 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
164 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
165 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
166 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
167 | ␊ |
168 | struct ati_data_key ati_saved_config_n4␉␉ ␉␉= { 0x100, "saved-config",␊ |
169 | ␉{0x3e, 0x5c, 0x82, 0x00, 0xff, 0x90, 0x00, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3c, 0x80, 0x07,␊ |
170 | ␉ 0x20, 0x08, 0x30, 0x00, 0x20, 0x00, 0xb0, 0x04, 0xd3, 0x04, 0x03, 0x00, 0x06, 0x00, 0xb0, 0x04, 0x80, 0x07, 0x00, 0x01,␊ |
171 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
172 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
173 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,␊ |
174 | ␉ 0x00, 0x00, 0x00, 0x02, 0x90, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44,␊ |
175 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00,␊ |
176 | ␉ 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
177 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
178 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
179 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
180 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,␊ |
181 | ␉ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
182 | ␊ |
183 | // ====================//====================␊ |
184 | ␊ |
185 | /* ???␊ |
186 | struct pcir_s {␊ |
187 | ␉uint32_t signature;␊ |
188 | ␉uint16_t vid;␊ |
189 | ␉uint16_t devid;␊ |
190 | };*/␊ |
191 | ␊ |
192 | static struct ati_chipsets_t ATIChipsets[] = {␊ |
193 | ␉{ 0x00000000,␉"Unknown"␉␉␉␉␉␉␉},␊ |
194 | // =====================================================␊ |
195 | ␉{ 0x10027181,␉"ATI Radeon X1600 Series"␉␉␉}, // Azi␊ |
196 | ␉{ 0x10027183,␉"ATI Radeon X1550 Series"␉␉␉}, // Beej␊ |
197 | ␉{ 0x10027187,␉"ATI Radeon X1300 Series"␉␉␉}, // Mckibble␊ |
198 | ␉{ 0x100271C5,␉"ATI Mobility Radeon X1600"␉␉␉}, // Darles, Derc - looks like it's a no go ??␊ |
199 | ␉{ 0x100271D4,␉"ATI Mobility FireGL V5250"␉␉␉}, // Downlord - ??␊ |
200 | ␉␊ |
201 | ␉{ 0x10027244,␉"ATI RADEON X1950 Series"␉␉␉}, // tlfrance␊ |
202 | // =====================================================␊ |
203 | ␉{ 0x10029589,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
204 | ␉{ 0x10029588,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
205 | ␉{ 0x100294C3,␉"ATI Radeon 2400 Series"␉␉␉},␊ |
206 | ␉{ 0x100294C4,␉"ATI Radeon 2400 Series"␉␉␉},␊ |
207 | ␉{ 0x100294C6,␉"ATI Radeon 2400 Series"␉␉␉},␊ |
208 | ␉{ 0x10029400,␉"ATI Radeon 2900 Series"␉␉␉},␊ |
209 | ␉{ 0x10029405,␉"ATI Radeon 2900GT Series"␉␉␉},␊ |
210 | ␉{ 0x10029581,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
211 | ␉{ 0x10029583,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
212 | ␉{ 0x10029586,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
213 | ␉{ 0x10029587,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
214 | ␉{ 0x100294C9,␉"ATI Radeon 2400 Series"␉␉␉},␊ |
215 | ␉{ 0x10029501,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
216 | ␉{ 0x10029505,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
217 | ␉{ 0x10029515,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
218 | ␉{ 0x10029507,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
219 | ␉{ 0x10029500,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
220 | ␉{ 0x1002950F,␉"ATI Radeon 3800X2 Series"␉␉␉},␊ |
221 | ␉{ 0x100295C5,␉"ATI Radeon 3400 Series"␉␉␉},␊ |
222 | ␉{ 0x100295C7,␉"ATI Radeon 3400 Series"␉␉␉},␊ |
223 | ␉{ 0x100295C0,␉"ATI Radeon 3400 Series"␉␉␉},␊ |
224 | ␉{ 0x10029596,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
225 | ␉{ 0x10029590,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
226 | ␉{ 0x10029599,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
227 | ␉{ 0x10029597,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
228 | ␉{ 0x10029598,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
229 | ␉{ 0x10029442,␉"ATI Radeon 4850 Series"␉␉␉},␊ |
230 | ␉{ 0x10029440,␉"ATI Radeon 4870 Series"␉␉␉},␊ |
231 | ␉{ 0x1002944C,␉"ATI Radeon 4830 Series"␉␉␉},␊ |
232 | ␉{ 0x10029460,␉"ATI Radeon 4890 Series"␉␉␉},␊ |
233 | ␉{ 0x10029462,␉"ATI Radeon 4890 Series"␉␉␉},␊ |
234 | ␉{ 0x10029441,␉"ATI Radeon 4870X2 Series"␉␉␉},␊ |
235 | ␉{ 0x10029443,␉"ATI Radeon 4850X2 Series"␉␉␉},␊ |
236 | ␉{ 0x10029444,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
237 | ␉{ 0x10029446,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
238 | ␉{ 0x1002944E,␉"ATI Radeon 4730 Series"␉␉␉},␊ |
239 | ␉{ 0x10029450,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
240 | ␉{ 0x10029452,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
241 | ␉{ 0x10029456,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
242 | ␉{ 0x1002944A,␉"ATI Radeon 4800 Mobility Series"␉},␊ |
243 | ␉{ 0x1002945A,␉"ATI Radeon 4800 Mobility Series"␉},␊ |
244 | ␉{ 0x1002945B,␉"ATI Radeon 4800 Mobility Series"␉},␊ |
245 | ␉{ 0x1002944B,␉"ATI Radeon 4800 Mobility Series"␉},␊ |
246 | ␉{ 0x10029490,␉"ATI Radeon 4670 Series"␉␉␉},␊ |
247 | ␉{ 0x10029498,␉"ATI Radeon 4650 Series"␉␉␉},␊ |
248 | ␉{ 0x10029490,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
249 | ␉{ 0x10029498,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
250 | ␉{ 0x1002949E,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
251 | ␉{ 0x10029480,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
252 | ␉{ 0x10029488,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
253 | ␉{ 0x10029540,␉"ATI Radeon 4500 Series"␉␉␉},␊ |
254 | ␉{ 0x10029541,␉"ATI Radeon 4500 Series"␉␉␉},␊ |
255 | ␉{ 0x1002954E,␉"ATI Radeon 4500 Series"␉␉␉},␊ |
256 | ␉{ 0x10029552,␉"ATI Radeon 4300 Mobility Series"␉},␊ |
257 | ␉{ 0x10029553,␉"ATI Radeon 4500 Mobility Series"␉},␊ |
258 | ␉{ 0x1002954F,␉"ATI Radeon 4300 Series"␉␉␉},␊ |
259 | ␉{ 0x100294B3,␉"ATI Radeon 4770 Series"␉␉␉},␊ |
260 | ␉{ 0x100294B5,␉"ATI Radeon 4770 Series"␉␉␉},␊ |
261 | ␉{ 0x100268B8,␉"ATI Radeon 5700 Series"␉␉␉},␊ |
262 | ␉{ 0x100268BE,␉"ATI Radeon 5700 Series"␉␉␉},␊ |
263 | ␉{ 0x10026898,␉"ATI Radeon 5800 Series"␉␉␉},␊ |
264 | ␉{ 0x10026899,␉"ATI Radeon 5800 Series"␉␉␉}␊ |
265 | };␊ |
266 | ␊ |
267 | // <= 10.6.7␊ |
268 | static struct ati_chipsets_t ATIFramebuffers_pre[] = {␊ |
269 | ␉{ 0x00000000,␉"Megalodon"␉},␊ |
270 | // =============================␊ |
271 | ␉{ 0x10027181,␉"Megalodon"␉},␊ |
272 | /*␉{ 0x10027183,␉"Caretta"␉},␊ |
273 | ␉{ 0x10027187,␉"Caretta"␉},␊ |
274 | ␉{ 0x100271C5,␉"Wormy"␉␉}, // ??␊ |
275 | ␉{ 0x100271D4,␉"Wormy"␉␉}, // ??␊ |
276 | ␉␊ |
277 | ␉{ 0x10027244,␉"Alopias"␉},*/␊ |
278 | // =============================␊ |
279 | ␉{ 0x10029589,␉"Lamna"␉␉},␊ |
280 | ␉{ 0x10029588,␉"Lamna"␉␉},␊ |
281 | ␉{ 0x100294C3,␉"Iago"␉␉},␊ |
282 | ␉{ 0x100294C4,␉"Iago"␉␉},␊ |
283 | ␉{ 0x100294C6,␉"Iago"␉␉},␊ |
284 | ␉{ 0x10029400,␉"Franklin"␉},␊ |
285 | ␉{ 0x10029405,␉"Franklin"␉},␊ |
286 | ␉{ 0x10029581,␉"Hypoprion"␉},␊ |
287 | ␉{ 0x10029583,␉"Hypoprion"␉},␊ |
288 | ␉{ 0x10029586,␉"Hypoprion"␉},␊ |
289 | ␉{ 0x10029587,␉"Hypoprion"␉},␊ |
290 | ␉{ 0x100294C9,␉"Iago"␉␉},␊ |
291 | ␉{ 0x10029501,␉"Megalodon"␉},␊ |
292 | ␉{ 0x10029505,␉"Megalodon"␉},␊ |
293 | ␉{ 0x10029515,␉"Megalodon"␉},␊ |
294 | ␉{ 0x10029507,␉"Megalodon"␉},␊ |
295 | ␉{ 0x10029500,␉"Megalodon"␉},␊ |
296 | ␉{ 0x1002950F,␉"Triakis"␉},␊ |
297 | ␉{ 0x100295C5,␉"Iago"␉␉},␊ |
298 | ␉{ 0x100295C7,␉"Iago"␉␉},␊ |
299 | ␉{ 0x100295C0,␉"Iago"␉␉},␊ |
300 | ␉{ 0x10029596,␉"Megalodon"␉},␊ |
301 | ␉{ 0x10029590,␉"Megalodon"␉},␊ |
302 | ␉{ 0x10029599,␉"Megalodon"␉},␊ |
303 | ␉{ 0x10029597,␉"Megalodon"␉},␊ |
304 | ␉{ 0x10029598,␉"Megalodon"␉},␊ |
305 | ␉{ 0x10029442,␉"Motmot"␉},␊ |
306 | ␉{ 0x10029440,␉"Motmot"␉},␊ |
307 | ␉{ 0x1002944C,␉"Motmot"␉},␊ |
308 | ␉{ 0x10029460,␉"Motmot"␉},␊ |
309 | ␉{ 0x10029462,␉"Motmot"␉},␊ |
310 | ␉{ 0x10029441,␉"Motmot"␉},␊ |
311 | ␉{ 0x10029443,␉"Motmot"␉},␊ |
312 | ␉{ 0x10029444,␉"Motmot"␉},␊ |
313 | ␉{ 0x10029446,␉"Motmot"␉},␊ |
314 | ␉{ 0x1002944E,␉"Motmot"␉},␊ |
315 | ␉{ 0x10029450,␉"Motmot"␉},␊ |
316 | ␉{ 0x10029452,␉"Motmot"␉},␉␉␊ |
317 | ␉{ 0x10029456,␉"Motmot"␉},␉␉␊ |
318 | ␉{ 0x1002944A,␉"Motmot"␉},␊ |
319 | ␉{ 0x1002945A,␉"Motmot"␉},␊ |
320 | ␉{ 0x1002945B,␉"Motmot"␉},␊ |
321 | ␉{ 0x1002944B,␉"Motmot"␉},␊ |
322 | ␉{ 0x10029490,␉"Peregrine"␉},␊ |
323 | ␉{ 0x10029498,␉"Peregrine"␉},␊ |
324 | ␉{ 0x1002949E,␉"Peregrine"␉},␊ |
325 | ␉{ 0x10029480,␉"Peregrine"␉},␊ |
326 | ␉{ 0x10029488,␉"Peregrine"␉},␊ |
327 | ␉{ 0x10029540,␉"Peregrine"␉},␊ |
328 | ␉{ 0x10029541,␉"Peregrine"␉},␊ |
329 | ␉{ 0x1002954E,␉"Peregrine"␉},␊ |
330 | ␉{ 0x10029552,␉"Peregrine"␉},␊ |
331 | ␉{ 0x10029553,␉"Peregrine"␉},␊ |
332 | ␉{ 0x1002954F,␉"Peregrine"␉},␊ |
333 | ␉{ 0x100294B3,␉"Peregrine"␉},␊ |
334 | ␉{ 0x100294B5,␉"Peregrine"␉},␊ |
335 | ␉{ 0x100268B8,␉"Motmot"␉},␊ |
336 | ␉{ 0x100268BE,␉"Motmot"␉},␊ |
337 | ␉{ 0x10026898,␉"Motmot"␉},␊ |
338 | ␉{ 0x10026899,␉"Motmot"␉}␊ |
339 | };␊ |
340 | ␊ |
341 | // >= 10.6.8␊ |
342 | static struct ati_chipsets_t ATIFramebuffers_post[] = {␊ |
343 | ␉{ 0x00000000,␉"Megalodon"␉},␊ |
344 | // =============================␊ |
345 | ␉{ 0x10027181,␉"Caretta"␉},␊ |
346 | ␉{ 0x10027183,␉"Caretta"␉},␊ |
347 | ␉{ 0x10027187,␉"Caretta"␉},␊ |
348 | ␉{ 0x100271C5,␉"Wormy"␉␉}, // ??␊ |
349 | ␉{ 0x100271D4,␉"Wormy"␉␉}, // ??␊ |
350 | ␉␊ |
351 | ␉{ 0x10027244,␉"Alopias"␉},␊ |
352 | // =============================␊ |
353 | /*␉{ 0x10029589,␉"Lamna"␉␉},␊ |
354 | ␉{ 0x10029588,␉"Lamna"␉␉},␊ |
355 | ␉{ 0x100294C3,␉"Iago"␉␉},␊ |
356 | ␉{ 0x100294C4,␉"Iago"␉␉},␊ |
357 | ␉{ 0x100294C6,␉"Iago"␉␉},␊ |
358 | ␉{ 0x10029400,␉"Franklin"␉},␊ |
359 | ␉{ 0x10029405,␉"Franklin"␉},␊ |
360 | ␉{ 0x10029581,␉"Hypoprion"␉},␊ |
361 | ␉{ 0x10029583,␉"Hypoprion"␉},␊ |
362 | ␉{ 0x10029586,␉"Hypoprion"␉},␊ |
363 | ␉{ 0x10029587,␉"Hypoprion"␉},␊ |
364 | ␉{ 0x100294C9,␉"Iago"␉␉},␊ |
365 | ␉{ 0x10029501,␉"Megalodon"␉},␊ |
366 | ␉{ 0x10029505,␉"Megalodon"␉},␊ |
367 | ␉{ 0x10029515,␉"Megalodon"␉},␊ |
368 | ␉{ 0x10029507,␉"Megalodon"␉},␊ |
369 | ␉{ 0x10029500,␉"Megalodon"␉},␊ |
370 | ␉{ 0x1002950F,␉"Triakis"␉},␊ |
371 | ␉{ 0x100295C5,␉"Iago"␉␉},␊ |
372 | ␉{ 0x100295C7,␉"Iago"␉␉},␊ |
373 | ␉{ 0x100295C0,␉"Iago"␉␉},␊ |
374 | ␉{ 0x10029596,␉"Megalodon"␉},␊ |
375 | ␉{ 0x10029590,␉"Megalodon"␉},␊ |
376 | ␉{ 0x10029599,␉"Megalodon"␉},␊ |
377 | ␉{ 0x10029597,␉"Megalodon"␉},␊ |
378 | ␉{ 0x10029598,␉"Megalodon"␉},␊ |
379 | ␉{ 0x10029442,␉"Motmot"␉},␊ |
380 | ␉{ 0x10029440,␉"Motmot"␉},␊ |
381 | ␉{ 0x1002944C,␉"Motmot"␉},␊ |
382 | ␉{ 0x10029460,␉"Motmot"␉},␊ |
383 | ␉{ 0x10029462,␉"Motmot"␉},␊ |
384 | ␉{ 0x10029441,␉"Motmot"␉},␊ |
385 | ␉{ 0x10029443,␉"Motmot"␉},␊ |
386 | ␉{ 0x10029444,␉"Motmot"␉},␊ |
387 | ␉{ 0x10029446,␉"Motmot"␉},␊ |
388 | ␉{ 0x1002944E,␉"Motmot"␉},␊ |
389 | ␉{ 0x10029450,␉"Motmot"␉},␊ |
390 | ␉{ 0x10029452,␉"Motmot"␉},␉␉␊ |
391 | ␉{ 0x10029456,␉"Motmot"␉},␉␉␊ |
392 | ␉{ 0x1002944A,␉"Motmot"␉},␊ |
393 | ␉{ 0x1002945A,␉"Motmot"␉},␊ |
394 | ␉{ 0x1002945B,␉"Motmot"␉},␊ |
395 | ␉{ 0x1002944B,␉"Motmot"␉},␊ |
396 | ␉{ 0x10029490,␉"Peregrine"␉},␊ |
397 | ␉{ 0x10029498,␉"Peregrine"␉},␊ |
398 | ␉{ 0x1002949E,␉"Peregrine"␉},*/␊ |
399 | ␉{ 0x10029480,␉"Gliff"␉␉}//, Akbar␊ |
400 | /*␉{ 0x10029488,␉"Peregrine"␉},␊ |
401 | ␉{ 0x10029540,␉"Peregrine"␉},␊ |
402 | ␉{ 0x10029541,␉"Peregrine"␉},␊ |
403 | ␉{ 0x1002954E,␉"Peregrine"␉},␊ |
404 | ␉{ 0x10029552,␉"Peregrine"␉},␊ |
405 | ␉{ 0x10029553,␉"Peregrine"␉},␊ |
406 | ␉{ 0x1002954F,␉"Peregrine"␉},␊ |
407 | ␉{ 0x100294B3,␉"Peregrine"␉},␊ |
408 | ␉{ 0x100294B5,␉"Peregrine"␉},␊ |
409 | ␉{ 0x100268B8,␉"Motmot"␉},␊ |
410 | ␉{ 0x100268BE,␉"Motmot"␉},␊ |
411 | ␉{ 0x10026898,␉"Motmot"␉},␊ |
412 | ␉{ 0x10026899,␉"Motmot"␉}*/␊ |
413 | };␊ |
414 | ␊ |
415 | static uint32_t accessROM(pci_dt_t *ati_dev, unsigned int mode)␊ |
416 | {␊ |
417 | ␉uint32_t␉␉bar[7];␊ |
418 | ␉volatile uint32_t␉*regs;␊ |
419 | ␊ |
420 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
421 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
422 | ␊ |
423 | ␉if (mode) {␊ |
424 | ␉␉if (mode != 1) {␊ |
425 | ␉␉␉return 0xe00002c7;␊ |
426 | ␉␉}␊ |
427 | ␉␉REG32W(0x179c, 0x00080000);␊ |
428 | ␉␉REG32W(0x1798, 0x00080721);␊ |
429 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
430 | ␉␉REG32W(0x1600, 0x14030300);␊ |
431 | ␉␉REG32W(0x1798, 0x21);␊ |
432 | ␉␉REG32W(0x17a0, 0x21);␊ |
433 | ␉␉REG32W(0x179c, 0x00);␊ |
434 | ␉␉REG32W(0x17a0, 0x21);␊ |
435 | ␉␉REG32W(0x1798, 0x21);␊ |
436 | ␉␉REG32W(0x1798, 0x21);␊ |
437 | ␉} else {␊ |
438 | ␉␉REG32W(0x1600, 0x14030302);␉␊ |
439 | ␉␉REG32W(0x1798, 0x21);␊ |
440 | ␉␉REG32W(0x17a0, 0x21);␊ |
441 | ␉␉REG32W(0x179c, 0x00080000);␊ |
442 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
443 | ␉␉REG32W(0x1798, 0x00080721);␊ |
444 | ␉␉REG32W(0x1798, 0x21);␊ |
445 | ␉␉REG32W(0x17a0, 0x21);␊ |
446 | ␉␉REG32W(0x179c, 0x00);␊ |
447 | ␉␉REG32W(0x1604, 0x0400e9fc);␊ |
448 | ␉␉REG32W(0x161c, 0x00);␊ |
449 | ␉␉REG32W(0x1620, 0x9f);␊ |
450 | ␉␉REG32W(0x1618, 0x00040004);␊ |
451 | ␉␉REG32W(0x161c, 0x00);␊ |
452 | ␉␉REG32W(0x1604, 0xe9fc);␊ |
453 | ␉␉REG32W(0x179c, 0x00080000);␊ |
454 | ␉␉REG32W(0x1798, 0x00080721);␊ |
455 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
456 | ␉␉REG32W(0x1798, 0x21);␊ |
457 | ␉␉REG32W(0x17a0, 0x21);␊ |
458 | ␉␉REG32W(0x179c, 0x00);␊ |
459 | ␉}␊ |
460 | ␉return 0;␊ |
461 | }␊ |
462 | ␊ |
463 | static uint8_t *readAtomBIOS(pci_dt_t *ati_dev)␊ |
464 | {␊ |
465 | ␉uint32_t␉␉bar[7];␊ |
466 | ␉uint32_t␉␉*BIOSBase;␊ |
467 | ␉uint32_t␉␉counter;␊ |
468 | ␉volatile uint32_t␉*regs;␊ |
469 | ␊ |
470 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
471 | ␉regs = (volatile uint32_t *) (bar[2] & ~0x0f);␊ |
472 | ␉accessROM(ati_dev, 0);␊ |
473 | ␉REG32W(0xa8, 0);␊ |
474 | ␉REG32R(0xac);␊ |
475 | ␉REG32W(0xa8, 0);␊ |
476 | ␉REG32R(0xac);␉␊ |
477 | ␊ |
478 | ␉BIOSBase = malloc(0x10000);␊ |
479 | ␉REG32W(0xa8, 0);␊ |
480 | ␉BIOSBase[0] = REG32R(0xac);␊ |
481 | ␉counter = 4;␊ |
482 | ␉do {␊ |
483 | ␉␉REG32W(0xa8, counter);␊ |
484 | ␉␉BIOSBase[counter/4] = REG32R(0xac);␊ |
485 | ␉␉counter +=4;␊ |
486 | ␉} while (counter != 0x10000);␊ |
487 | ␉accessROM((pci_dt_t *)regs, 1);␊ |
488 | ␊ |
489 | ␉if (*(uint16_t *)BIOSBase != 0xAA55) {␊ |
490 | ␉␉printf("Wrong BIOS signature: %04x\n", *(uint16_t *)BIOSBase);␊ |
491 | ␉␉return 0;␊ |
492 | ␉}␊ |
493 | ␉return (uint8_t *)BIOSBase;␊ |
494 | }␊ |
495 | ␊ |
496 | #define R5XX_CONFIG_MEMSIZE␉0x00F8 //Azi:---␊ |
497 | #define R6XX_CONFIG_MEMSIZE␉0x5428␊ |
498 | ␊ |
499 | uint32_t getvramsizekb(pci_dt_t *ati_dev)␊ |
500 | {␊ |
501 | ␉uint32_t␉␉bar[7];␊ |
502 | ␉uint32_t␉␉size;␊ |
503 | ␉volatile uint32_t␉*regs;␊ |
504 | ␊ |
505 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
506 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
507 | ␉if (ati_dev->device_id < 0x9400) {␊ |
508 | ␉␉size = (REG32R(R5XX_CONFIG_MEMSIZE)) >> 10;␊ |
509 | ␉} else {␊ |
510 | ␉␉size = (REG32R(R6XX_CONFIG_MEMSIZE)) >> 10;␊ |
511 | ␉}␊ |
512 | ␉return size;␊ |
513 | }␊ |
514 | ␊ |
515 | #define AVIVO_D1CRTC_CONTROL␉0x6080␊ |
516 | #define AVIVO_CRTC_EN␉␉␉(1<<0)␊ |
517 | #define AVIVO_D2CRTC_CONTROL␉0x6880␊ |
518 | ␊ |
519 | static bool radeon_card_posted(pci_dt_t *ati_dev)␊ |
520 | {␊ |
521 | ␉// if devid matches biosimage(from legacy) devid - posted card, fails with X2/crossfire cards.␊ |
522 | /*␉char *biosimage = 0xC0000;␊ |
523 | ␉␊ |
524 | ␉if ((uint8_t)biosimage[0] == 0x55 && (uint8_t)biosimage[1] == 0xaa)␊ |
525 | ␉{␊ |
526 | ␉␉option_rom_pci_header_t *rom_pci_header; ␊ |
527 | ␉␉rom_pci_header = (option_rom_pci_header_t*)(biosimage + (uint8_t)biosimage[24] + (uint8_t)biosimage[25]*256);␊ |
528 | ␉␊ |
529 | ␉if (rom_pci_header->signature == 0x52494350)␊ |
530 | ␉␉{␊ |
531 | ␉␉if (rom_pci_header->device_id == ati_dev->device_id)␊ |
532 | ␉␉␉{␊ |
533 | ␉␉␉␉return true;␊ |
534 | ␉␉␉␉printf("Card was POSTed\n");␊ |
535 | ␉␉␉}␊ |
536 | ␉␉}␊ |
537 | ␉}␊ |
538 | ␉return false;␊ |
539 | ␉printf("Card was not POSTed\n");␊ |
540 | ␉*/␊ |
541 | ␉//fails yet␊ |
542 | ␉uint32_t␉␉bar[7];␊ |
543 | ␉uint32_t␉␉val;␊ |
544 | ␉volatile uint32_t␉*regs;␊ |
545 | ␊ |
546 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18);␊ |
547 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
548 | ␊ |
549 | ␉val = REG32R(AVIVO_D1CRTC_CONTROL) | REG32R(AVIVO_D2CRTC_CONTROL);␊ |
550 | ␉if (val & AVIVO_CRTC_EN) {␊ |
551 | ␉␉return true;␊ |
552 | ␉} else {␊ |
553 | ␉␉return false;␊ |
554 | ␉}␊ |
555 | }␊ |
556 | ␊ |
557 | static uint32_t load_ati_bios_file(const char *filename, uint8_t *buf, int bufsize)␊ |
558 | {␊ |
559 | ␉int␉fd;␊ |
560 | ␉int␉size;␊ |
561 | ␊ |
562 | ␉if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) {␊ |
563 | ␉␉return 0;␊ |
564 | ␉}␊ |
565 | ␉size = file_size(fd);␊ |
566 | ␉if (size > bufsize) {␊ |
567 | ␉␉printf("Filesize of %s is bigger than expected! Truncating to 0x%x Bytes!\n", filename, bufsize);␊ |
568 | ␉␉size = bufsize;␊ |
569 | ␉}␊ |
570 | ␉size = read(fd, (char *)buf, size);␊ |
571 | ␉close(fd);␊ |
572 | ␉return size > 0 ? size : 0;␊ |
573 | }␊ |
574 | ␊ |
575 | static char *get_ati_model(uint32_t id)␊ |
576 | {␊ |
577 | ␉int i;␊ |
578 | ␉␊ |
579 | ␉for (i = 0; i < (sizeof(ATIChipsets) / sizeof(ATIChipsets[0])); i++) {␊ |
580 | ␉␉if (ATIChipsets[i].device == id) {␊ |
581 | ␉␉␉return ATIChipsets[i].name;␊ |
582 | ␉␉}␊ |
583 | ␉}␊ |
584 | ␉return ATIChipsets[0].name;␊ |
585 | }␊ |
586 | ␊ |
587 | static char *get_ati_fb(uint32_t id)␊ |
588 | {␊ |
589 | ␉int␉i;␊ |
590 | ␉␊ |
591 | ␉// limit patch to Snow & Lion explicitly!?␊ |
592 | ␉if ((gMacOSVersion[3] == '6') && (gMacOSVersion[5] >= '8'))␊ |
593 | ␉{␊ |
594 | ␉␉for (i = 0; i < (sizeof(ATIFramebuffers_post) / sizeof(ATIFramebuffers_post[0])); i++)␊ |
595 | ␉␉{␊ |
596 | ␉␉␉if (ATIFramebuffers_post[i].device == id)␊ |
597 | ␉␉␉{␊ |
598 | ␉␉␉␉verbose("Framebuffer ( >= 10.6.8): %s\n", ATIFramebuffers_post[i].name);␊ |
599 | ␉␉␉␉return ATIFramebuffers_post[i].name;␊ |
600 | ␉␉␉}␊ |
601 | ␉␉}␊ |
602 | ␉␉verbose("Framebuffer (default post): %s\n", ATIFramebuffers_post[0].name);␊ |
603 | ␉␉return ATIFramebuffers_post[0].name;␊ |
604 | ␉}␊ |
605 | ␉else␊ |
606 | ␉{␊ |
607 | ␉␉for (i = 0; i < (sizeof(ATIFramebuffers_pre) / sizeof(ATIFramebuffers_pre[0])); i++)␊ |
608 | ␉␉{␊ |
609 | ␉␉␉if (ATIFramebuffers_pre[i].device == id)␊ |
610 | ␉␉␉{␊ |
611 | ␉␉␉␉verbose("Framebuffer ( <= 10.6.7): %s\n", ATIFramebuffers_pre[i].name);␊ |
612 | ␉␉␉␉return ATIFramebuffers_pre[i].name;␊ |
613 | ␉␉␉}␊ |
614 | ␉␉}␊ |
615 | ␉␉verbose("Framebuffer (default): %s\n", ATIFramebuffers_pre[0].name);␊ |
616 | ␉␉return ATIFramebuffers_pre[0].name;␊ |
617 | ␉}␊ |
618 | }␊ |
619 | ␊ |
620 | static int devprop_add_iopciconfigspace(struct DevPropDevice *device, pci_dt_t *ati_dev)␊ |
621 | {␊ |
622 | ␉int␉i;␊ |
623 | ␉uint8_t␉*config_space;␊ |
624 | ␊ |
625 | ␉if (!device || !ati_dev) {␊ |
626 | ␉␉return 0;␊ |
627 | ␉}␊ |
628 | ␉verbose("dumping pci config space, 256 bytes\n");␊ |
629 | ␉config_space = malloc(256);␊ |
630 | ␉for (i=0; i<=255; i++) {␊ |
631 | ␉␉config_space[i] = pci_config_read8( ati_dev->dev.addr, i);␊ |
632 | ␉}␊ |
633 | ␉devprop_add_value(device, "ATY,PCIConfigSpace", config_space, 256);␊ |
634 | ␉free (config_space);␊ |
635 | ␉return 1;␊ |
636 | }␊ |
637 | ␊ |
638 | static int devprop_add_ati_template_4xxx(struct DevPropDevice *device)␊ |
639 | {␊ |
640 | ␉if(!device)␊ |
641 | ␉␉return 0;␊ |
642 | ␉␊ |
643 | //␉if(!DP_ADD_TEMP_VAL(device, ati_compatible_0))␊ |
644 | //␉␉return 0;␊ |
645 | //␉if(!DP_ADD_TEMP_VAL(device, ati_compatible_1))␊ |
646 | //␉␉return 0;␊ |
647 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))␊ |
648 | ␉␉return 0;␊ |
649 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_1))␊ |
650 | ␉␉return 0;␊ |
651 | //␉if(!DP_ADD_TEMP_VAL(device, ati_device_type))␊ |
652 | //␉␉return 0;␊ |
653 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name_0))␊ |
654 | //␉␉return 0;␊ |
655 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
656 | //␉␉return 0;␊ |
657 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name))␊ |
658 | //␉␉return 0;␊ |
659 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efidisplay_0))␊ |
660 | ␉␉return 0;␊ |
661 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_0))␊ |
662 | ␉␉return 0;␊ |
663 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_1))␊ |
664 | ␉␉return 0;␊ |
665 | //␉if(!DP_ADD_TEMP_VAL(device, ati_slot_name))␊ |
666 | //␉␉return 0;␊ |
667 | ␉if(!DP_ADD_TEMP_VAL(device, ati_card_no))␊ |
668 | ␉␉return 0;␊ |
669 | ␉if(!DP_ADD_TEMP_VAL(device, ati_copyright))␊ |
670 | ␉␉return 0;␊ |
671 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_compile_d))␊ |
672 | ␉␉return 0;␊ |
673 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_version))␊ |
674 | ␉␉return 0;␊ |
675 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionB))␊ |
676 | ␉␉return 0;␊ |
677 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionE))␊ |
678 | ␉␉return 0;␊ |
679 | ␉if(!DP_ADD_TEMP_VAL(device, ati_mrt))␊ |
680 | ␉␉return 0;␊ |
681 | ␉if(!DP_ADD_TEMP_VAL(device, ati_romno))␊ |
682 | ␉␉return 0;␊ |
683 | ␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
684 | ␉␉return 0;␊ |
685 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_0))␊ |
686 | ␉␉return 0;␊ |
687 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_1))␊ |
688 | ␉␉return 0;␊ |
689 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_display_con_fl_type_0))␊ |
690 | ␉␉return 0;␊ |
691 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aux_power_conn))␊ |
692 | ␉␉return 0;␊ |
693 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_backlight_ctrl))␊ |
694 | ␉␉return 0;␊ |
695 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl01_coher))␊ |
696 | ␉␉return 0;␊ |
697 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_disp_conf))␊ |
698 | ␉␉return 0;␊ |
699 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_drv_type))␊ |
700 | ␉␉return 0;␊ |
701 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_enbl_mode))␊ |
702 | ␉␉return 0;␊ |
703 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_init_stat))␊ |
704 | ␉␉return 0;␊ |
705 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation))␊ |
706 | ␉␉return 0;␊ |
707 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mclk))␊ |
708 | ␉␉return 0;␊ |
709 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_rev_id))␊ |
710 | ␉␉return 0;␊ |
711 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_vend_id))␊ |
712 | ␉␉return 0;␊ |
713 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_sclk))␊ |
714 | ␉␉return 0;␊ |
715 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_vendor_id))␊ |
716 | ␉␉return 0;␊ |
717 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))␊ |
718 | ␉␉return 0;␊ |
719 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mvad))␊ |
720 | ␉␉return 0;␊ |
721 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_saved_config))␊ |
722 | ␉␉return 0;␊ |
723 | ␉return 1;␊ |
724 | }␊ |
725 | ␊ |
726 | static int devprop_add_ati_template(struct DevPropDevice *device)␊ |
727 | {␊ |
728 | ␉if(!device)␊ |
729 | ␉␉return 0;␊ |
730 | ␊ |
731 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))␊ |
732 | ␉␉return 0;␉␊ |
733 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))␊ |
734 | ␉␉return 0;␊ |
735 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_1))␊ |
736 | ␉␉return 0;␊ |
737 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efidisplay_0_n4))␊ |
738 | ␉␉return 0;␊ |
739 | //␉if(!DP_ADD_TEMP_VAL(device, ati_slot_name_n4))␊ |
740 | //␉␉return 0;␊ |
741 | ␉if(!DP_ADD_TEMP_VAL(device, ati_card_no))␊ |
742 | ␉␉return 0;␊ |
743 | ␉if(!DP_ADD_TEMP_VAL(device, ati_copyright))␊ |
744 | ␉␉return 0;␊ |
745 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_compile_d))␊ |
746 | ␉␉return 0;␊ |
747 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_version))␊ |
748 | ␉␉return 0;␊ |
749 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionB))␊ |
750 | ␉␉return 0;␊ |
751 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionE))␊ |
752 | ␉␉return 0;␊ |
753 | ␉if(!DP_ADD_TEMP_VAL(device, ati_mrt))␊ |
754 | ␉␉return 0;␊ |
755 | ␉if(!DP_ADD_TEMP_VAL(device, ati_romno))␊ |
756 | ␉␉return 0;␊ |
757 | ␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
758 | ␉␉return 0;␊ |
759 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_0_n4))␊ |
760 | ␉␉return 0;␊ |
761 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_1_n4))␊ |
762 | ␉␉return 0;␊ |
763 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aux_power_conn))␊ |
764 | ␉␉return 0;␊ |
765 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_backlight_ctrl))␊ |
766 | ␉␉return 0;␊ |
767 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl01_coher))␊ |
768 | ␉␉return 0;␊ |
769 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_drv_type))␊ |
770 | ␉␉return 0;␊ |
771 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_enbl_mode))␊ |
772 | ␉␉return 0;␊ |
773 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_rev_id))␊ |
774 | ␉␉return 0;␊ |
775 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_vend_id))␊ |
776 | ␉␉return 0;␊ |
777 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_vendor_id))␊ |
778 | ␉␉return 0;␊ |
779 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_emc_disp_list_n4))␊ |
780 | ␉␉return 0;␊ |
781 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_fb_offset_n4))␊ |
782 | ␉␉return 0;␊ |
783 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_hwgpio_n4))␊ |
784 | ␉␉return 0;␊ |
785 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_iospace_offset_n4))␊ |
786 | ␉␉return 0;␊ |
787 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mclk_n4))␊ |
788 | ␉␉return 0;␊ |
789 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_sclk_n4))␊ |
790 | ␉␉return 0;␊ |
791 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_refclk_n4))␊ |
792 | ␉␉return 0;␊ |
793 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_regspace_offset_n4))␊ |
794 | ␉␉return 0;␊ |
795 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation_n4))␊ |
796 | ␉␉return 0;␊ |
797 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_0_n4))␊ |
798 | ␉␉return 0;␊ |
799 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_1_n4))␊ |
800 | ␉␉return 0;␊ |
801 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_swgpio_info_n4))␊ |
802 | ␉␉return 0;␊ |
803 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation_n4))␊ |
804 | ␉␉return 0;␊ |
805 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mvad_n4))␊ |
806 | ␉␉return 0;␊ |
807 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_saved_config_n4))␊ |
808 | ␉␉return 0;␊ |
809 | ␉return 1;␊ |
810 | }␊ |
811 | ␊ |
812 | bool setup_ati_devprop(pci_dt_t *ati_dev)␊ |
813 | {␊ |
814 | ␉struct DevPropDevice␉*device;␊ |
815 | ␉char␉␉␉␉␉*devicepath;␊ |
816 | ␉char␉␉␉␉␉*model;␊ |
817 | ␉const char␉␉␉␉*framebuffer;␊ |
818 | ␉char␉␉␉␉␉ tmp[64];␊ |
819 | ␉uint8_t␉␉␉␉␉*rom = NULL;␊ |
820 | ␉uint32_t␉␉␉␉ rom_size = 0;␊ |
821 | ␉option_rom_pci_header_t *rom_pci_header;␊ |
822 | ␉uint8_t␉␉␉␉␉*bios;␊ |
823 | ␉uint32_t␉␉␉␉ bios_size;␊ |
824 | ␉uint32_t␉␉␉␉ vram_size;␊ |
825 | ␉uint32_t␉␉␉␉ boot_display;␊ |
826 | ␉uint8_t␉␉␉␉␉ cmd;␊ |
827 | ␉bool␉␉␉␉␉ doit;␊ |
828 | ␉bool␉␉␉␉␉ toFree;␊ |
829 | ␉␊ |
830 | ␉devicepath = get_pci_dev_path(ati_dev);␊ |
831 | ␉␊ |
832 | ␉cmd = pci_config_read8(ati_dev->dev.addr, 4);␊ |
833 | ␉verbose("old pci command - %x\n", cmd);␊ |
834 | ␉if (cmd == 0) {␊ |
835 | ␉␉pci_config_write8(ati_dev->dev.addr, 4, 6);␉␊ |
836 | ␉␉cmd = pci_config_read8(ati_dev->dev.addr, 4);␊ |
837 | ␉␉verbose("new pci command - %x\n", cmd);␊ |
838 | ␉}␊ |
839 | ␉␊ |
840 | ␉model = get_ati_model((ati_dev->vendor_id << 16) | ati_dev->device_id);␊ |
841 | ␉framebuffer = getStringForKey(kAtiConfig, &bootInfo->bootConfig);␊ |
842 | ␉␊ |
843 | ␉if (framebuffer == 0)␊ |
844 | ␉{␊ |
845 | ␉␉framebuffer = get_ati_fb((ati_dev->vendor_id << 16) | ati_dev->device_id);␊ |
846 | ␉}␊ |
847 | ␉else␊ |
848 | ␉{␊ |
849 | ␉␉verbose("(AtiConfig) Framebuffer set to: %s\n", framebuffer);␊ |
850 | ␉}␊ |
851 | ␉␊ |
852 | ␉if (!string) {␊ |
853 | ␉␉string = devprop_create_string();␊ |
854 | ␉}␊ |
855 | ␉device = devprop_add_device(string, devicepath);␊ |
856 | ␉if (!device) {␊ |
857 | ␉␉printf("Failed initializing dev-prop string dev-entry, press any key...\n");␊ |
858 | ␉␉getchar();␊ |
859 | ␉␉return false;␊ |
860 | ␉}␊ |
861 | ␊ |
862 | ␉/* FIXME: for primary graphics card only */␊ |
863 | ␉if (radeon_card_posted(ati_dev)) {␊ |
864 | ␉␉boot_display = 1;␊ |
865 | ␉} else {␊ |
866 | ␉␉boot_display = 0;␊ |
867 | ␉}␊ |
868 | ␉verbose("boot display - %x\n", boot_display);␊ |
869 | ␉devprop_add_value(device, "@0,AAPL,boot-display", (uint8_t*)&boot_display, 4);␊ |
870 | ␊ |
871 | ␉if ((framebuffer[0] == 'M' && framebuffer[1] == 'o' && framebuffer[2] == 't') ||␊ |
872 | ␉␉(framebuffer[0] == 'S' && framebuffer[1] == 'h' && framebuffer[2] == 'r') ||␊ |
873 | ␉␉(framebuffer[0] == 'P' && framebuffer[1] == 'e' && framebuffer[2] == 'r')) //faster than strcmp ;)␊ |
874 | ␉␉devprop_add_ati_template_4xxx(device);␊ |
875 | ␉else {␊ |
876 | ␉␉devprop_add_ati_template(device);␊ |
877 | ␉␉vram_size = getvramsizekb(ati_dev) * 1024;␊ |
878 | ␉␉if ((vram_size > 0x80000000) || (vram_size == 0)) {␊ |
879 | ␉␉␉vram_size = 0x10000000;␉//vram reported wrong, defaulting to 256 mb␊ |
880 | ␉␉}␊ |
881 | ␉␉devprop_add_value(device, "VRAM,totalsize", (uint8_t*)&vram_size, 4);␊ |
882 | ␉␉ati_vram_memsize_0.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
883 | ␉␉ati_vram_memsize_0.data[7] = (vram_size >> 24) & 0xFF;␉␉␊ |
884 | ␉␉ati_vram_memsize_1.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
885 | ␉␉ati_vram_memsize_1.data[7] = (vram_size >> 24) & 0xFF;␊ |
886 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_0);␊ |
887 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_1);␊ |
888 | ␉␉devprop_add_iopciconfigspace(device, ati_dev);␉␉␊ |
889 | ␉}␊ |
890 | ␉devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));␊ |
891 | ␉devprop_add_value(device, "ATY,DeviceID", (uint8_t*)&ati_dev->device_id, 2);␊ |
892 | ␊ |
893 | ␉//fb setup␊ |
894 | ␉sprintf(tmp, "Slot-%x",devices_number);␊ |
895 | ␉devprop_add_value(device, "AAPL,slot-name", (uint8_t*)tmp, strlen(tmp) + 1);␊ |
896 | ␉devices_number++;␊ |
897 | ␊ |
898 | ␉sprintf(tmp, ati_compatible_0[1], framebuffer);␊ |
899 | ␉devprop_add_value(device, (char *) ati_compatible_0[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
900 | ␊ |
901 | ␉sprintf(tmp, ati_compatible_1[1], framebuffer);␊ |
902 | ␉devprop_add_value(device, (char *) ati_compatible_1[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
903 | ␊ |
904 | ␉sprintf(tmp, ati_device_type[1], framebuffer);␊ |
905 | ␉devprop_add_value(device, (char *) ati_device_type[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
906 | ␊ |
907 | ␉sprintf(tmp, ati_name[1], framebuffer);␊ |
908 | ␉devprop_add_value(device, (char *) ati_name[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
909 | ␊ |
910 | ␉sprintf(tmp, ati_name_0[1], framebuffer);␊ |
911 | ␉devprop_add_value(device, (char *) ati_name_0[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
912 | ␊ |
913 | ␉sprintf(tmp, ati_name_1[1], framebuffer);␊ |
914 | ␉devprop_add_value(device, (char *) ati_name_1[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
915 | ␊ |
916 | ␉sprintf(tmp, "bt(0,0)/Extra/%04x_%04x.rom", (uint16_t)ati_dev->vendor_id, (uint16_t)ati_dev->device_id);␊ |
917 | ␉if (getBoolForKey(kUseAtiROMKey, &doit, &bootInfo->chameleonConfig) && doit) {␊ |
918 | ␉␉verbose("looking for ati video bios file %s\n", tmp);␊ |
919 | ␉␉rom = malloc(0x20000);␊ |
920 | ␉␉rom_size = load_ati_bios_file(tmp, rom, 0x20000);␊ |
921 | ␉␉if (rom_size > 0) {␊ |
922 | ␉␉␉verbose("Using ATI Video BIOS File %s (%d Bytes)\n", tmp, rom_size);␊ |
923 | ␉␉␉if (rom_size > 0x10000) {␊ |
924 | ␉␉␉␉rom_size = 0x10000; //we dont need rest anyway;␊ |
925 | ␉␉␉}␊ |
926 | ␉␉} else {␊ |
927 | ␉␉␉printf("ERROR: unable to open ATI Video BIOS File %s\n", tmp);␊ |
928 | ␉␉}␊ |
929 | ␉}␊ |
930 | ␉if (rom_size == 0) {␊ |
931 | ␉␉if (boot_display) {␉␉// no custom rom␊ |
932 | ␉␉␉bios = NULL;␉// try to dump from legacy space, otherwise can result in 100% fan speed␊ |
933 | ␉␉} else {␊ |
934 | ␉␉␉// readAtomBios result in bug on some cards (100% fan speed and black screen),␊ |
935 | ␉␉␉// not using it for posted card, reading from legacy space instead␊ |
936 | ␉␉␉bios = readAtomBIOS(ati_dev);␊ |
937 | ␉␉}␊ |
938 | ␉} else {␊ |
939 | ␉␉bios = rom;␉//going custom rom way␊ |
940 | ␉␉verbose("Using rom %s\n", tmp);␊ |
941 | ␉}␊ |
942 | ␉if (bios == NULL) {␊ |
943 | ␉␉bios = (uint8_t *)0x000C0000;␊ |
944 | ␉␉toFree = false;␊ |
945 | ␉␉verbose("Not going to use bios image file\n");␊ |
946 | ␉} else {␊ |
947 | ␉␉toFree = true;␊ |
948 | ␉}␊ |
949 | ␊ |
950 | ␉if (bios[0] == 0x55 && bios[1] == 0xaa) {␊ |
951 | ␉␉verbose("Found bios image\n");␊ |
952 | ␉␉bios_size = bios[2] * 512;␊ |
953 | ␊ |
954 | ␉␉rom_pci_header = (option_rom_pci_header_t*)(bios + bios[24] + bios[25]*256);␊ |
955 | ␊ |
956 | ␉␉if (rom_pci_header->signature == 0x52494350) {␊ |
957 | ␉␉␉if (rom_pci_header->device_id != ati_dev->device_id) {␊ |
958 | ␉␉␉␉verbose("Bios image (%x) doesnt match card (%x), ignoring\n", rom_pci_header->device_id, ati_dev->device_id);␊ |
959 | ␉␉␉} else {␊ |
960 | ␉␉␉␉if (toFree)␊ |
961 | ␉␉␉␉{␊ |
962 | ␉␉␉␉␉verbose("Adding binimage to card %x from mmio space with size %x\n", ati_dev->device_id, bios_size);␊ |
963 | ␉␉␉␉} else {␊ |
964 | ␉␉␉␉␉verbose("Adding binimage to card %x from legacy space with size %x\n", ati_dev->device_id, bios_size);␊ |
965 | ␉␉␉␉}␊ |
966 | ␉␉␉␉devprop_add_value(device, "ATY,bin_image", bios, bios_size);␊ |
967 | ␉␉␉}␊ |
968 | ␉␉} else {␊ |
969 | ␉␉␉verbose("Wrong pci header signature %x\n", rom_pci_header->signature);␊ |
970 | ␉␉}␊ |
971 | ␉} else {␊ |
972 | ␉␉verbose("Bios image not found at %x, content %x %x\n", bios, bios[0], bios[1]);␊ |
973 | ␉}␊ |
974 | ␉if (toFree) {␊ |
975 | ␉␉free(bios);␊ |
976 | ␉}␊ |
977 | ␉stringdata = malloc(sizeof(uint8_t) * string->length);␊ |
978 | ␉memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);␊ |
979 | ␉stringlength = string->length;␊ |
980 | ␊ |
981 | ␉return true;␊ |
982 | }␊ |
983 | |