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 | ␉{ 0x10029589,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
202 | ␉{ 0x10029588,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
203 | ␉{ 0x100294C3,␉"ATI Radeon 2400 Series"␉␉␉},␊ |
204 | ␉{ 0x100294C4,␉"ATI Radeon 2400 Series"␉␉␉},␊ |
205 | ␉{ 0x100294C6,␉"ATI Radeon 2400 Series"␉␉␉},␊ |
206 | ␉{ 0x10029400,␉"ATI Radeon 2900 Series"␉␉␉},␊ |
207 | ␉{ 0x10029405,␉"ATI Radeon 2900GT Series"␉␉␉},␊ |
208 | ␉{ 0x10029581,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
209 | ␉{ 0x10029583,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
210 | ␉{ 0x10029586,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
211 | ␉{ 0x10029587,␉"ATI Radeon 2600 Series"␉␉␉},␊ |
212 | ␉{ 0x100294C9,␉"ATI Radeon 2400 Series"␉␉␉},␊ |
213 | ␉{ 0x10029501,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
214 | ␉{ 0x10029505,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
215 | ␉{ 0x10029515,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
216 | ␉{ 0x10029507,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
217 | ␉{ 0x10029500,␉"ATI Radeon 3800 Series"␉␉␉},␊ |
218 | ␉{ 0x1002950F,␉"ATI Radeon 3800X2 Series"␉␉␉},␊ |
219 | ␉{ 0x100295C5,␉"ATI Radeon 3400 Series"␉␉␉},␊ |
220 | ␉{ 0x100295C7,␉"ATI Radeon 3400 Series"␉␉␉},␊ |
221 | ␉{ 0x100295C0,␉"ATI Radeon 3400 Series"␉␉␉},␊ |
222 | ␉{ 0x10029596,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
223 | ␉{ 0x10029590,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
224 | ␉{ 0x10029599,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
225 | ␉{ 0x10029597,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
226 | ␉{ 0x10029598,␉"ATI Radeon 3600 Series"␉␉␉},␊ |
227 | ␉{ 0x10029442,␉"ATI Radeon 4850 Series"␉␉␉},␊ |
228 | ␉{ 0x10029440,␉"ATI Radeon 4870 Series"␉␉␉},␊ |
229 | ␉{ 0x1002944C,␉"ATI Radeon 4830 Series"␉␉␉},␊ |
230 | ␉{ 0x10029460,␉"ATI Radeon 4890 Series"␉␉␉},␊ |
231 | ␉{ 0x10029462,␉"ATI Radeon 4890 Series"␉␉␉},␊ |
232 | ␉{ 0x10029441,␉"ATI Radeon 4870X2 Series"␉␉␉},␊ |
233 | ␉{ 0x10029443,␉"ATI Radeon 4850X2 Series"␉␉␉},␊ |
234 | ␉{ 0x10029444,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
235 | ␉{ 0x10029446,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
236 | ␉{ 0x1002944E,␉"ATI Radeon 4730 Series"␉␉␉},␊ |
237 | ␉{ 0x10029450,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
238 | ␉{ 0x10029452,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
239 | ␉{ 0x10029456,␉"ATI Radeon 4800 Series"␉␉␉},␊ |
240 | ␉{ 0x1002944A,␉"ATI Radeon 4800 Mobility Series"␉},␊ |
241 | ␉{ 0x1002945A,␉"ATI Radeon 4800 Mobility Series"␉},␊ |
242 | ␉{ 0x1002945B,␉"ATI Radeon 4800 Mobility Series"␉},␊ |
243 | ␉{ 0x1002944B,␉"ATI Radeon 4800 Mobility Series"␉},␊ |
244 | ␉{ 0x10029490,␉"ATI Radeon 4670 Series"␉␉␉},␊ |
245 | ␉{ 0x10029498,␉"ATI Radeon 4650 Series"␉␉␉},␊ |
246 | ␉{ 0x10029490,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
247 | ␉{ 0x10029498,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
248 | ␉{ 0x1002949E,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
249 | ␉{ 0x10029480,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
250 | ␉{ 0x10029488,␉"ATI Radeon 4600 Series"␉␉␉},␊ |
251 | ␉{ 0x10029540,␉"ATI Radeon 4500 Series"␉␉␉},␊ |
252 | ␉{ 0x10029541,␉"ATI Radeon 4500 Series"␉␉␉},␊ |
253 | ␉{ 0x1002954E,␉"ATI Radeon 4500 Series"␉␉␉},␊ |
254 | ␉{ 0x10029552,␉"ATI Radeon 4300 Mobility Series"␉},␊ |
255 | ␉{ 0x10029553,␉"ATI Radeon 4500 Mobility Series"␉},␊ |
256 | ␉{ 0x1002954F,␉"ATI Radeon 4300 Series"␉␉␉},␊ |
257 | ␉{ 0x100294B3,␉"ATI Radeon 4770 Series"␉␉␉},␊ |
258 | ␉{ 0x100294B5,␉"ATI Radeon 4770 Series"␉␉␉},␊ |
259 | ␉{ 0x100268B8,␉"ATI Radeon 5700 Series"␉␉␉},␊ |
260 | ␉{ 0x100268BE,␉"ATI Radeon 5700 Series"␉␉␉},␊ |
261 | ␉{ 0x10026898,␉"ATI Radeon 5800 Series"␉␉␉},␊ |
262 | ␉{ 0x10026899,␉"ATI Radeon 5800 Series"␉␉␉}␊ |
263 | };␊ |
264 | ␊ |
265 | // <= 10.6.7␊ |
266 | static struct ati_chipsets_t ATIFramebuffers_pre[] = {␊ |
267 | ␉{ 0x00000000,␉"Megalodon"␉},␊ |
268 | // =============================␊ |
269 | ␉{ 0x10027181,␉"Megalodon"␉},␊ |
270 | /*␉{ 0x10027183,␉"Caretta"␉},␊ |
271 | ␉{ 0x10027187,␉"Caretta"␉},␊ |
272 | ␉{ 0x100271C5,␉"Wormy"␉␉}, // ??␊ |
273 | ␉{ 0x100271D4,␉"Wormy"␉␉}, // ??*/␊ |
274 | // =============================␊ |
275 | ␉{ 0x10029589,␉"Lamna"␉␉},␊ |
276 | ␉{ 0x10029588,␉"Lamna"␉␉},␊ |
277 | ␉{ 0x100294C3,␉"Iago"␉␉},␊ |
278 | ␉{ 0x100294C4,␉"Iago"␉␉},␊ |
279 | ␉{ 0x100294C6,␉"Iago"␉␉},␊ |
280 | ␉{ 0x10029400,␉"Franklin"␉},␊ |
281 | ␉{ 0x10029405,␉"Franklin"␉},␊ |
282 | ␉{ 0x10029581,␉"Hypoprion"␉},␊ |
283 | ␉{ 0x10029583,␉"Hypoprion"␉},␊ |
284 | ␉{ 0x10029586,␉"Hypoprion"␉},␊ |
285 | ␉{ 0x10029587,␉"Hypoprion"␉},␊ |
286 | ␉{ 0x100294C9,␉"Iago"␉␉},␊ |
287 | ␉{ 0x10029501,␉"Megalodon"␉},␊ |
288 | ␉{ 0x10029505,␉"Megalodon"␉},␊ |
289 | ␉{ 0x10029515,␉"Megalodon"␉},␊ |
290 | ␉{ 0x10029507,␉"Megalodon"␉},␊ |
291 | ␉{ 0x10029500,␉"Megalodon"␉},␊ |
292 | ␉{ 0x1002950F,␉"Triakis"␉},␊ |
293 | ␉{ 0x100295C5,␉"Iago"␉␉},␊ |
294 | ␉{ 0x100295C7,␉"Iago"␉␉},␊ |
295 | ␉{ 0x100295C0,␉"Iago"␉␉},␊ |
296 | ␉{ 0x10029596,␉"Megalodon"␉},␊ |
297 | ␉{ 0x10029590,␉"Megalodon"␉},␊ |
298 | ␉{ 0x10029599,␉"Megalodon"␉},␊ |
299 | ␉{ 0x10029597,␉"Megalodon"␉},␊ |
300 | ␉{ 0x10029598,␉"Megalodon"␉},␊ |
301 | ␉{ 0x10029442,␉"Motmot"␉},␊ |
302 | ␉{ 0x10029440,␉"Motmot"␉},␊ |
303 | ␉{ 0x1002944C,␉"Motmot"␉},␊ |
304 | ␉{ 0x10029460,␉"Motmot"␉},␊ |
305 | ␉{ 0x10029462,␉"Motmot"␉},␊ |
306 | ␉{ 0x10029441,␉"Motmot"␉},␊ |
307 | ␉{ 0x10029443,␉"Motmot"␉},␊ |
308 | ␉{ 0x10029444,␉"Motmot"␉},␊ |
309 | ␉{ 0x10029446,␉"Motmot"␉},␊ |
310 | ␉{ 0x1002944E,␉"Motmot"␉},␊ |
311 | ␉{ 0x10029450,␉"Motmot"␉},␊ |
312 | ␉{ 0x10029452,␉"Motmot"␉},␉␉␊ |
313 | ␉{ 0x10029456,␉"Motmot"␉},␉␉␊ |
314 | ␉{ 0x1002944A,␉"Motmot"␉},␊ |
315 | ␉{ 0x1002945A,␉"Motmot"␉},␊ |
316 | ␉{ 0x1002945B,␉"Motmot"␉},␊ |
317 | ␉{ 0x1002944B,␉"Motmot"␉},␊ |
318 | ␉{ 0x10029490,␉"Peregrine"␉},␊ |
319 | ␉{ 0x10029498,␉"Peregrine"␉},␊ |
320 | ␉{ 0x1002949E,␉"Peregrine"␉},␊ |
321 | ␉{ 0x10029480,␉"Peregrine"␉},␊ |
322 | ␉{ 0x10029488,␉"Peregrine"␉},␊ |
323 | ␉{ 0x10029540,␉"Peregrine"␉},␊ |
324 | ␉{ 0x10029541,␉"Peregrine"␉},␊ |
325 | ␉{ 0x1002954E,␉"Peregrine"␉},␊ |
326 | ␉{ 0x10029552,␉"Peregrine"␉},␊ |
327 | ␉{ 0x10029553,␉"Peregrine"␉},␊ |
328 | ␉{ 0x1002954F,␉"Peregrine"␉},␊ |
329 | ␉{ 0x100294B3,␉"Peregrine"␉},␊ |
330 | ␉{ 0x100294B5,␉"Peregrine"␉},␊ |
331 | ␉{ 0x100268B8,␉"Motmot"␉},␊ |
332 | ␉{ 0x100268BE,␉"Motmot"␉},␊ |
333 | ␉{ 0x10026898,␉"Motmot"␉},␊ |
334 | ␉{ 0x10026899,␉"Motmot"␉}␊ |
335 | };␊ |
336 | ␊ |
337 | // >= 10.6.8␊ |
338 | static struct ati_chipsets_t ATIFramebuffers_post[] = {␊ |
339 | ␉{ 0x00000000,␉"Megalodon"␉},␊ |
340 | // =============================␊ |
341 | ␉{ 0x10027181,␉"Caretta"␉},␊ |
342 | ␉{ 0x10027183,␉"Caretta"␉},␊ |
343 | ␉{ 0x10027187,␉"Caretta"␉},␊ |
344 | ␉{ 0x100271C5,␉"Wormy"␉␉}, // ??␊ |
345 | ␉{ 0x100271D4,␉"Wormy"␉␉}, // ??␊ |
346 | // =============================␊ |
347 | /*␉{ 0x10029589,␉"Lamna"␉␉},␊ |
348 | ␉{ 0x10029588,␉"Lamna"␉␉},␊ |
349 | ␉{ 0x100294C3,␉"Iago"␉␉},␊ |
350 | ␉{ 0x100294C4,␉"Iago"␉␉},␊ |
351 | ␉{ 0x100294C6,␉"Iago"␉␉},␊ |
352 | ␉{ 0x10029400,␉"Franklin"␉},␊ |
353 | ␉{ 0x10029405,␉"Franklin"␉},␊ |
354 | ␉{ 0x10029581,␉"Hypoprion"␉},␊ |
355 | ␉{ 0x10029583,␉"Hypoprion"␉},␊ |
356 | ␉{ 0x10029586,␉"Hypoprion"␉},␊ |
357 | ␉{ 0x10029587,␉"Hypoprion"␉},␊ |
358 | ␉{ 0x100294C9,␉"Iago"␉␉},␊ |
359 | ␉{ 0x10029501,␉"Megalodon"␉},␊ |
360 | ␉{ 0x10029505,␉"Megalodon"␉},␊ |
361 | ␉{ 0x10029515,␉"Megalodon"␉},␊ |
362 | ␉{ 0x10029507,␉"Megalodon"␉},␊ |
363 | ␉{ 0x10029500,␉"Megalodon"␉},␊ |
364 | ␉{ 0x1002950F,␉"Triakis"␉},␊ |
365 | ␉{ 0x100295C5,␉"Iago"␉␉},␊ |
366 | ␉{ 0x100295C7,␉"Iago"␉␉},␊ |
367 | ␉{ 0x100295C0,␉"Iago"␉␉},␊ |
368 | ␉{ 0x10029596,␉"Megalodon"␉},␊ |
369 | ␉{ 0x10029590,␉"Megalodon"␉},␊ |
370 | ␉{ 0x10029599,␉"Megalodon"␉},␊ |
371 | ␉{ 0x10029597,␉"Megalodon"␉},␊ |
372 | ␉{ 0x10029598,␉"Megalodon"␉},␊ |
373 | ␉{ 0x10029442,␉"Motmot"␉},␊ |
374 | ␉{ 0x10029440,␉"Motmot"␉},␊ |
375 | ␉{ 0x1002944C,␉"Motmot"␉},␊ |
376 | ␉{ 0x10029460,␉"Motmot"␉},␊ |
377 | ␉{ 0x10029462,␉"Motmot"␉},␊ |
378 | ␉{ 0x10029441,␉"Motmot"␉},␊ |
379 | ␉{ 0x10029443,␉"Motmot"␉},␊ |
380 | ␉{ 0x10029444,␉"Motmot"␉},␊ |
381 | ␉{ 0x10029446,␉"Motmot"␉},␊ |
382 | ␉{ 0x1002944E,␉"Motmot"␉},␊ |
383 | ␉{ 0x10029450,␉"Motmot"␉},␊ |
384 | ␉{ 0x10029452,␉"Motmot"␉},␉␉␊ |
385 | ␉{ 0x10029456,␉"Motmot"␉},␉␉␊ |
386 | ␉{ 0x1002944A,␉"Motmot"␉},␊ |
387 | ␉{ 0x1002945A,␉"Motmot"␉},␊ |
388 | ␉{ 0x1002945B,␉"Motmot"␉},␊ |
389 | ␉{ 0x1002944B,␉"Motmot"␉},␊ |
390 | ␉{ 0x10029490,␉"Peregrine"␉},␊ |
391 | ␉{ 0x10029498,␉"Peregrine"␉},␊ |
392 | ␉{ 0x1002949E,␉"Peregrine"␉},*/␊ |
393 | ␉{ 0x10029480,␉"Gliff"␉␉}//, Akbar␊ |
394 | /*␉{ 0x10029488,␉"Peregrine"␉},␊ |
395 | ␉{ 0x10029540,␉"Peregrine"␉},␊ |
396 | ␉{ 0x10029541,␉"Peregrine"␉},␊ |
397 | ␉{ 0x1002954E,␉"Peregrine"␉},␊ |
398 | ␉{ 0x10029552,␉"Peregrine"␉},␊ |
399 | ␉{ 0x10029553,␉"Peregrine"␉},␊ |
400 | ␉{ 0x1002954F,␉"Peregrine"␉},␊ |
401 | ␉{ 0x100294B3,␉"Peregrine"␉},␊ |
402 | ␉{ 0x100294B5,␉"Peregrine"␉},␊ |
403 | ␉{ 0x100268B8,␉"Motmot"␉},␊ |
404 | ␉{ 0x100268BE,␉"Motmot"␉},␊ |
405 | ␉{ 0x10026898,␉"Motmot"␉},␊ |
406 | ␉{ 0x10026899,␉"Motmot"␉}*/␊ |
407 | };␊ |
408 | ␊ |
409 | static uint32_t accessROM(pci_dt_t *ati_dev, unsigned int mode)␊ |
410 | {␊ |
411 | ␉uint32_t␉␉bar[7];␊ |
412 | ␉volatile uint32_t␉*regs;␊ |
413 | ␊ |
414 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
415 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
416 | ␊ |
417 | ␉if (mode) {␊ |
418 | ␉␉if (mode != 1) {␊ |
419 | ␉␉␉return 0xe00002c7;␊ |
420 | ␉␉}␊ |
421 | ␉␉REG32W(0x179c, 0x00080000);␊ |
422 | ␉␉REG32W(0x1798, 0x00080721);␊ |
423 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
424 | ␉␉REG32W(0x1600, 0x14030300);␊ |
425 | ␉␉REG32W(0x1798, 0x21);␊ |
426 | ␉␉REG32W(0x17a0, 0x21);␊ |
427 | ␉␉REG32W(0x179c, 0x00);␊ |
428 | ␉␉REG32W(0x17a0, 0x21);␊ |
429 | ␉␉REG32W(0x1798, 0x21);␊ |
430 | ␉␉REG32W(0x1798, 0x21);␊ |
431 | ␉} else {␊ |
432 | ␉␉REG32W(0x1600, 0x14030302);␉␊ |
433 | ␉␉REG32W(0x1798, 0x21);␊ |
434 | ␉␉REG32W(0x17a0, 0x21);␊ |
435 | ␉␉REG32W(0x179c, 0x00080000);␊ |
436 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
437 | ␉␉REG32W(0x1798, 0x00080721);␊ |
438 | ␉␉REG32W(0x1798, 0x21);␊ |
439 | ␉␉REG32W(0x17a0, 0x21);␊ |
440 | ␉␉REG32W(0x179c, 0x00);␊ |
441 | ␉␉REG32W(0x1604, 0x0400e9fc);␊ |
442 | ␉␉REG32W(0x161c, 0x00);␊ |
443 | ␉␉REG32W(0x1620, 0x9f);␊ |
444 | ␉␉REG32W(0x1618, 0x00040004);␊ |
445 | ␉␉REG32W(0x161c, 0x00);␊ |
446 | ␉␉REG32W(0x1604, 0xe9fc);␊ |
447 | ␉␉REG32W(0x179c, 0x00080000);␊ |
448 | ␉␉REG32W(0x1798, 0x00080721);␊ |
449 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
450 | ␉␉REG32W(0x1798, 0x21);␊ |
451 | ␉␉REG32W(0x17a0, 0x21);␊ |
452 | ␉␉REG32W(0x179c, 0x00);␊ |
453 | ␉}␊ |
454 | ␉return 0;␊ |
455 | }␊ |
456 | ␊ |
457 | static uint8_t *readAtomBIOS(pci_dt_t *ati_dev)␊ |
458 | {␊ |
459 | ␉uint32_t␉␉bar[7];␊ |
460 | ␉uint32_t␉␉*BIOSBase;␊ |
461 | ␉uint32_t␉␉counter;␊ |
462 | ␉volatile uint32_t␉*regs;␊ |
463 | ␊ |
464 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
465 | ␉regs = (volatile uint32_t *) (bar[2] & ~0x0f);␊ |
466 | ␉accessROM(ati_dev, 0);␊ |
467 | ␉REG32W(0xa8, 0);␊ |
468 | ␉REG32R(0xac);␊ |
469 | ␉REG32W(0xa8, 0);␊ |
470 | ␉REG32R(0xac);␉␊ |
471 | ␊ |
472 | ␉BIOSBase = malloc(0x10000);␊ |
473 | ␉REG32W(0xa8, 0);␊ |
474 | ␉BIOSBase[0] = REG32R(0xac);␊ |
475 | ␉counter = 4;␊ |
476 | ␉do {␊ |
477 | ␉␉REG32W(0xa8, counter);␊ |
478 | ␉␉BIOSBase[counter/4] = REG32R(0xac);␊ |
479 | ␉␉counter +=4;␊ |
480 | ␉} while (counter != 0x10000);␊ |
481 | ␉accessROM((pci_dt_t *)regs, 1);␊ |
482 | ␊ |
483 | ␉if (*(uint16_t *)BIOSBase != 0xAA55) {␊ |
484 | ␉␉printf("Wrong BIOS signature: %04x\n", *(uint16_t *)BIOSBase);␊ |
485 | ␉␉return 0;␊ |
486 | ␉}␊ |
487 | ␉return (uint8_t *)BIOSBase;␊ |
488 | }␊ |
489 | ␊ |
490 | #define R5XX_CONFIG_MEMSIZE␉0x00F8 //Azi:---␊ |
491 | #define R6XX_CONFIG_MEMSIZE␉0x5428␊ |
492 | ␊ |
493 | uint32_t getvramsizekb(pci_dt_t *ati_dev)␊ |
494 | {␊ |
495 | ␉uint32_t␉␉bar[7];␊ |
496 | ␉uint32_t␉␉size;␊ |
497 | ␉volatile uint32_t␉*regs;␊ |
498 | ␊ |
499 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
500 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
501 | ␉if (ati_dev->device_id < 0x9400) {␊ |
502 | ␉␉size = (REG32R(R5XX_CONFIG_MEMSIZE)) >> 10;␊ |
503 | ␉} else {␊ |
504 | ␉␉size = (REG32R(R6XX_CONFIG_MEMSIZE)) >> 10;␊ |
505 | ␉}␊ |
506 | ␉return size;␊ |
507 | }␊ |
508 | ␊ |
509 | #define AVIVO_D1CRTC_CONTROL␉0x6080␊ |
510 | #define AVIVO_CRTC_EN␉␉␉(1<<0)␊ |
511 | #define AVIVO_D2CRTC_CONTROL␉0x6880␊ |
512 | ␊ |
513 | static bool radeon_card_posted(pci_dt_t *ati_dev)␊ |
514 | {␊ |
515 | ␉// if devid matches biosimage(from legacy) devid - posted card, fails with X2/crossfire cards.␊ |
516 | /*␉char *biosimage = 0xC0000;␊ |
517 | ␉␊ |
518 | ␉if ((uint8_t)biosimage[0] == 0x55 && (uint8_t)biosimage[1] == 0xaa)␊ |
519 | ␉{␊ |
520 | ␉␉option_rom_pci_header_t *rom_pci_header; ␊ |
521 | ␉␉rom_pci_header = (option_rom_pci_header_t*)(biosimage + (uint8_t)biosimage[24] + (uint8_t)biosimage[25]*256);␊ |
522 | ␉␊ |
523 | ␉if (rom_pci_header->signature == 0x52494350)␊ |
524 | ␉␉{␊ |
525 | ␉␉if (rom_pci_header->device_id == ati_dev->device_id)␊ |
526 | ␉␉␉{␊ |
527 | ␉␉␉␉return true;␊ |
528 | ␉␉␉␉printf("Card was POSTed\n");␊ |
529 | ␉␉␉}␊ |
530 | ␉␉}␊ |
531 | ␉}␊ |
532 | ␉return false;␊ |
533 | ␉printf("Card was not POSTed\n");␊ |
534 | ␉*/␊ |
535 | ␉//fails yet␊ |
536 | ␉uint32_t␉␉bar[7];␊ |
537 | ␉uint32_t␉␉val;␊ |
538 | ␉volatile uint32_t␉*regs;␊ |
539 | ␊ |
540 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18);␊ |
541 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
542 | ␊ |
543 | ␉val = REG32R(AVIVO_D1CRTC_CONTROL) | REG32R(AVIVO_D2CRTC_CONTROL);␊ |
544 | ␉if (val & AVIVO_CRTC_EN) {␊ |
545 | ␉␉return true;␊ |
546 | ␉} else {␊ |
547 | ␉␉return false;␊ |
548 | ␉}␊ |
549 | }␊ |
550 | ␊ |
551 | static uint32_t load_ati_bios_file(const char *filename, uint8_t *buf, int bufsize)␊ |
552 | {␊ |
553 | ␉int␉fd;␊ |
554 | ␉int␉size;␊ |
555 | ␊ |
556 | ␉if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) {␊ |
557 | ␉␉return 0;␊ |
558 | ␉}␊ |
559 | ␉size = file_size(fd);␊ |
560 | ␉if (size > bufsize) {␊ |
561 | ␉␉printf("Filesize of %s is bigger than expected! Truncating to 0x%x Bytes!\n", filename, bufsize);␊ |
562 | ␉␉size = bufsize;␊ |
563 | ␉}␊ |
564 | ␉size = read(fd, (char *)buf, size);␊ |
565 | ␉close(fd);␊ |
566 | ␉return size > 0 ? size : 0;␊ |
567 | }␊ |
568 | ␊ |
569 | static char *get_ati_model(uint32_t id)␊ |
570 | {␊ |
571 | ␉int i;␊ |
572 | ␉␊ |
573 | ␉for (i = 0; i < (sizeof(ATIChipsets) / sizeof(ATIChipsets[0])); i++) {␊ |
574 | ␉␉if (ATIChipsets[i].device == id) {␊ |
575 | ␉␉␉return ATIChipsets[i].name;␊ |
576 | ␉␉}␊ |
577 | ␉}␊ |
578 | ␉return ATIChipsets[0].name;␊ |
579 | }␊ |
580 | ␊ |
581 | static char *get_ati_fb(uint32_t id)␊ |
582 | {␊ |
583 | ␉int␉i;␊ |
584 | ␉␊ |
585 | ␉// limit patch to Snow & Lion explicitly!?␊ |
586 | ␉if ((gMacOSVersion[3] == '6') && (gMacOSVersion[5] >= '8'))␊ |
587 | ␉{␊ |
588 | ␉␉for (i = 0; i < (sizeof(ATIFramebuffers_post) / sizeof(ATIFramebuffers_post[0])); i++)␊ |
589 | ␉␉{␊ |
590 | ␉␉␉if (ATIFramebuffers_post[i].device == id)␊ |
591 | ␉␉␉{␊ |
592 | ␉␉␉␉verbose("Framebuffer ( >= 10.6.8): %s\n", ATIFramebuffers_post[i].name);␊ |
593 | ␉␉␉␉return ATIFramebuffers_post[i].name;␊ |
594 | ␉␉␉}␊ |
595 | ␉␉}␊ |
596 | ␉␉verbose("Framebuffer (default post): %s\n", ATIFramebuffers_post[0].name);␊ |
597 | ␉␉return ATIFramebuffers_post[0].name;␊ |
598 | ␉}␊ |
599 | ␉else␊ |
600 | ␉{␊ |
601 | ␉␉for (i = 0; i < (sizeof(ATIFramebuffers_pre) / sizeof(ATIFramebuffers_pre[0])); i++)␊ |
602 | ␉␉{␊ |
603 | ␉␉␉if (ATIFramebuffers_pre[i].device == id)␊ |
604 | ␉␉␉{␊ |
605 | ␉␉␉␉verbose("Framebuffer ( <= 10.6.7): %s\n", ATIFramebuffers_pre[i].name);␊ |
606 | ␉␉␉␉return ATIFramebuffers_pre[i].name;␊ |
607 | ␉␉␉}␊ |
608 | ␉␉}␊ |
609 | ␉␉verbose("Framebuffer (default): %s\n", ATIFramebuffers_pre[0].name);␊ |
610 | ␉␉return ATIFramebuffers_pre[0].name;␊ |
611 | ␉}␊ |
612 | }␊ |
613 | ␊ |
614 | static int devprop_add_iopciconfigspace(struct DevPropDevice *device, pci_dt_t *ati_dev)␊ |
615 | {␊ |
616 | ␉int␉i;␊ |
617 | ␉uint8_t␉*config_space;␊ |
618 | ␊ |
619 | ␉if (!device || !ati_dev) {␊ |
620 | ␉␉return 0;␊ |
621 | ␉}␊ |
622 | ␉verbose("dumping pci config space, 256 bytes\n");␊ |
623 | ␉config_space = malloc(256);␊ |
624 | ␉for (i=0; i<=255; i++) {␊ |
625 | ␉␉config_space[i] = pci_config_read8( ati_dev->dev.addr, i);␊ |
626 | ␉}␊ |
627 | ␉devprop_add_value(device, "ATY,PCIConfigSpace", config_space, 256);␊ |
628 | ␉free (config_space);␊ |
629 | ␉return 1;␊ |
630 | }␊ |
631 | ␊ |
632 | static int devprop_add_ati_template_4xxx(struct DevPropDevice *device)␊ |
633 | {␊ |
634 | ␉if(!device)␊ |
635 | ␉␉return 0;␊ |
636 | ␉␊ |
637 | //␉if(!DP_ADD_TEMP_VAL(device, ati_compatible_0))␊ |
638 | //␉␉return 0;␊ |
639 | //␉if(!DP_ADD_TEMP_VAL(device, ati_compatible_1))␊ |
640 | //␉␉return 0;␊ |
641 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))␊ |
642 | ␉␉return 0;␊ |
643 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_1))␊ |
644 | ␉␉return 0;␊ |
645 | //␉if(!DP_ADD_TEMP_VAL(device, ati_device_type))␊ |
646 | //␉␉return 0;␊ |
647 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name_0))␊ |
648 | //␉␉return 0;␊ |
649 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
650 | //␉␉return 0;␊ |
651 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name))␊ |
652 | //␉␉return 0;␊ |
653 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efidisplay_0))␊ |
654 | ␉␉return 0;␊ |
655 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_0))␊ |
656 | ␉␉return 0;␊ |
657 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_1))␊ |
658 | ␉␉return 0;␊ |
659 | //␉if(!DP_ADD_TEMP_VAL(device, ati_slot_name))␊ |
660 | //␉␉return 0;␊ |
661 | ␉if(!DP_ADD_TEMP_VAL(device, ati_card_no))␊ |
662 | ␉␉return 0;␊ |
663 | ␉if(!DP_ADD_TEMP_VAL(device, ati_copyright))␊ |
664 | ␉␉return 0;␊ |
665 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_compile_d))␊ |
666 | ␉␉return 0;␊ |
667 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_version))␊ |
668 | ␉␉return 0;␊ |
669 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionB))␊ |
670 | ␉␉return 0;␊ |
671 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionE))␊ |
672 | ␉␉return 0;␊ |
673 | ␉if(!DP_ADD_TEMP_VAL(device, ati_mrt))␊ |
674 | ␉␉return 0;␊ |
675 | ␉if(!DP_ADD_TEMP_VAL(device, ati_romno))␊ |
676 | ␉␉return 0;␊ |
677 | ␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
678 | ␉␉return 0;␊ |
679 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_0))␊ |
680 | ␉␉return 0;␊ |
681 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_1))␊ |
682 | ␉␉return 0;␊ |
683 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_display_con_fl_type_0))␊ |
684 | ␉␉return 0;␊ |
685 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aux_power_conn))␊ |
686 | ␉␉return 0;␊ |
687 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_backlight_ctrl))␊ |
688 | ␉␉return 0;␊ |
689 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl01_coher))␊ |
690 | ␉␉return 0;␊ |
691 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_disp_conf))␊ |
692 | ␉␉return 0;␊ |
693 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_drv_type))␊ |
694 | ␉␉return 0;␊ |
695 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_enbl_mode))␊ |
696 | ␉␉return 0;␊ |
697 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_init_stat))␊ |
698 | ␉␉return 0;␊ |
699 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation))␊ |
700 | ␉␉return 0;␊ |
701 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mclk))␊ |
702 | ␉␉return 0;␊ |
703 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_rev_id))␊ |
704 | ␉␉return 0;␊ |
705 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_vend_id))␊ |
706 | ␉␉return 0;␊ |
707 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_sclk))␊ |
708 | ␉␉return 0;␊ |
709 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_vendor_id))␊ |
710 | ␉␉return 0;␊ |
711 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))␊ |
712 | ␉␉return 0;␊ |
713 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mvad))␊ |
714 | ␉␉return 0;␊ |
715 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_saved_config))␊ |
716 | ␉␉return 0;␊ |
717 | ␉return 1;␊ |
718 | }␊ |
719 | ␊ |
720 | static int devprop_add_ati_template(struct DevPropDevice *device)␊ |
721 | {␊ |
722 | ␉if(!device)␊ |
723 | ␉␉return 0;␊ |
724 | ␊ |
725 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))␊ |
726 | ␉␉return 0;␉␊ |
727 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))␊ |
728 | ␉␉return 0;␊ |
729 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_1))␊ |
730 | ␉␉return 0;␊ |
731 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efidisplay_0_n4))␊ |
732 | ␉␉return 0;␊ |
733 | //␉if(!DP_ADD_TEMP_VAL(device, ati_slot_name_n4))␊ |
734 | //␉␉return 0;␊ |
735 | ␉if(!DP_ADD_TEMP_VAL(device, ati_card_no))␊ |
736 | ␉␉return 0;␊ |
737 | ␉if(!DP_ADD_TEMP_VAL(device, ati_copyright))␊ |
738 | ␉␉return 0;␊ |
739 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_compile_d))␊ |
740 | ␉␉return 0;␊ |
741 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_version))␊ |
742 | ␉␉return 0;␊ |
743 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionB))␊ |
744 | ␉␉return 0;␊ |
745 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionE))␊ |
746 | ␉␉return 0;␊ |
747 | ␉if(!DP_ADD_TEMP_VAL(device, ati_mrt))␊ |
748 | ␉␉return 0;␊ |
749 | ␉if(!DP_ADD_TEMP_VAL(device, ati_romno))␊ |
750 | ␉␉return 0;␊ |
751 | ␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
752 | ␉␉return 0;␊ |
753 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_0_n4))␊ |
754 | ␉␉return 0;␊ |
755 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_1_n4))␊ |
756 | ␉␉return 0;␊ |
757 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aux_power_conn))␊ |
758 | ␉␉return 0;␊ |
759 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_backlight_ctrl))␊ |
760 | ␉␉return 0;␊ |
761 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl01_coher))␊ |
762 | ␉␉return 0;␊ |
763 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_drv_type))␊ |
764 | ␉␉return 0;␊ |
765 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_enbl_mode))␊ |
766 | ␉␉return 0;␊ |
767 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_rev_id))␊ |
768 | ␉␉return 0;␊ |
769 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_vend_id))␊ |
770 | ␉␉return 0;␊ |
771 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_vendor_id))␊ |
772 | ␉␉return 0;␊ |
773 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_emc_disp_list_n4))␊ |
774 | ␉␉return 0;␊ |
775 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_fb_offset_n4))␊ |
776 | ␉␉return 0;␊ |
777 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_hwgpio_n4))␊ |
778 | ␉␉return 0;␊ |
779 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_iospace_offset_n4))␊ |
780 | ␉␉return 0;␊ |
781 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mclk_n4))␊ |
782 | ␉␉return 0;␊ |
783 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_sclk_n4))␊ |
784 | ␉␉return 0;␊ |
785 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_refclk_n4))␊ |
786 | ␉␉return 0;␊ |
787 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_regspace_offset_n4))␊ |
788 | ␉␉return 0;␊ |
789 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation_n4))␊ |
790 | ␉␉return 0;␊ |
791 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_0_n4))␊ |
792 | ␉␉return 0;␊ |
793 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_1_n4))␊ |
794 | ␉␉return 0;␊ |
795 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_swgpio_info_n4))␊ |
796 | ␉␉return 0;␊ |
797 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation_n4))␊ |
798 | ␉␉return 0;␊ |
799 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mvad_n4))␊ |
800 | ␉␉return 0;␊ |
801 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_saved_config_n4))␊ |
802 | ␉␉return 0;␊ |
803 | ␉return 1;␊ |
804 | }␊ |
805 | ␊ |
806 | bool setup_ati_devprop(pci_dt_t *ati_dev)␊ |
807 | {␊ |
808 | ␉struct DevPropDevice␉*device;␊ |
809 | ␉char␉␉␉␉␉*devicepath;␊ |
810 | ␉char␉␉␉␉␉*model;␊ |
811 | ␉const char␉␉␉␉*framebuffer;␊ |
812 | ␉char␉␉␉␉␉ tmp[64];␊ |
813 | ␉uint8_t␉␉␉␉␉*rom = NULL;␊ |
814 | ␉uint32_t␉␉␉␉ rom_size = 0;␊ |
815 | ␉option_rom_pci_header_t *rom_pci_header;␊ |
816 | ␉uint8_t␉␉␉␉␉*bios;␊ |
817 | ␉uint32_t␉␉␉␉ bios_size;␊ |
818 | ␉uint32_t␉␉␉␉ vram_size;␊ |
819 | ␉uint32_t␉␉␉␉ boot_display;␊ |
820 | ␉uint8_t␉␉␉␉␉ cmd;␊ |
821 | ␉bool␉␉␉␉␉ doit;␊ |
822 | ␉bool␉␉␉␉␉ toFree;␊ |
823 | ␉␊ |
824 | ␉devicepath = get_pci_dev_path(ati_dev);␊ |
825 | ␉␊ |
826 | ␉cmd = pci_config_read8(ati_dev->dev.addr, 4);␊ |
827 | ␉verbose("old pci command - %x\n", cmd);␊ |
828 | ␉if (cmd == 0) {␊ |
829 | ␉␉pci_config_write8(ati_dev->dev.addr, 4, 6);␉␊ |
830 | ␉␉cmd = pci_config_read8(ati_dev->dev.addr, 4);␊ |
831 | ␉␉verbose("new pci command - %x\n", cmd);␊ |
832 | ␉}␊ |
833 | ␉␊ |
834 | ␉model = get_ati_model((ati_dev->vendor_id << 16) | ati_dev->device_id);␊ |
835 | ␉framebuffer = getStringForKey(kAtiConfig, &bootInfo->bootConfig);␊ |
836 | ␉␊ |
837 | ␉if (framebuffer == 0)␊ |
838 | ␉{␊ |
839 | ␉␉framebuffer = get_ati_fb((ati_dev->vendor_id << 16) | ati_dev->device_id);␊ |
840 | ␉}␊ |
841 | ␉else␊ |
842 | ␉{␊ |
843 | ␉␉verbose("(AtiConfig) Framebuffer set to: %s\n", framebuffer);␊ |
844 | ␉}␊ |
845 | ␉␊ |
846 | ␉if (!string) {␊ |
847 | ␉␉string = devprop_create_string();␊ |
848 | ␉}␊ |
849 | ␉device = devprop_add_device(string, devicepath);␊ |
850 | ␉if (!device) {␊ |
851 | ␉␉printf("Failed initializing dev-prop string dev-entry, press any key...\n");␊ |
852 | ␉␉getchar();␊ |
853 | ␉␉return false;␊ |
854 | ␉}␊ |
855 | ␊ |
856 | ␉/* FIXME: for primary graphics card only */␊ |
857 | ␉if (radeon_card_posted(ati_dev)) {␊ |
858 | ␉␉boot_display = 1;␊ |
859 | ␉} else {␊ |
860 | ␉␉boot_display = 0;␊ |
861 | ␉}␊ |
862 | ␉verbose("boot display - %x\n", boot_display);␊ |
863 | ␉devprop_add_value(device, "@0,AAPL,boot-display", (uint8_t*)&boot_display, 4);␊ |
864 | ␊ |
865 | ␉if ((framebuffer[0] == 'M' && framebuffer[1] == 'o' && framebuffer[2] == 't') ||␊ |
866 | ␉␉(framebuffer[0] == 'S' && framebuffer[1] == 'h' && framebuffer[2] == 'r') ||␊ |
867 | ␉␉(framebuffer[0] == 'P' && framebuffer[1] == 'e' && framebuffer[2] == 'r')) //faster than strcmp ;)␊ |
868 | ␉␉devprop_add_ati_template_4xxx(device);␊ |
869 | ␉else {␊ |
870 | ␉␉devprop_add_ati_template(device);␊ |
871 | ␉␉vram_size = getvramsizekb(ati_dev) * 1024;␊ |
872 | ␉␉if ((vram_size > 0x80000000) || (vram_size == 0)) {␊ |
873 | ␉␉␉vram_size = 0x10000000;␉//vram reported wrong, defaulting to 256 mb␊ |
874 | ␉␉}␊ |
875 | ␉␉devprop_add_value(device, "VRAM,totalsize", (uint8_t*)&vram_size, 4);␊ |
876 | ␉␉ati_vram_memsize_0.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
877 | ␉␉ati_vram_memsize_0.data[7] = (vram_size >> 24) & 0xFF;␉␉␊ |
878 | ␉␉ati_vram_memsize_1.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
879 | ␉␉ati_vram_memsize_1.data[7] = (vram_size >> 24) & 0xFF;␊ |
880 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_0);␊ |
881 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_1);␊ |
882 | ␉␉devprop_add_iopciconfigspace(device, ati_dev);␉␉␊ |
883 | ␉}␊ |
884 | ␉devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));␊ |
885 | ␉devprop_add_value(device, "ATY,DeviceID", (uint8_t*)&ati_dev->device_id, 2);␊ |
886 | ␊ |
887 | ␉//fb setup␊ |
888 | ␉sprintf(tmp, "Slot-%x",devices_number);␊ |
889 | ␉devprop_add_value(device, "AAPL,slot-name", (uint8_t*)tmp, strlen(tmp) + 1);␊ |
890 | ␉devices_number++;␊ |
891 | ␊ |
892 | ␉sprintf(tmp, ati_compatible_0[1], framebuffer);␊ |
893 | ␉devprop_add_value(device, (char *) ati_compatible_0[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
894 | ␊ |
895 | ␉sprintf(tmp, ati_compatible_1[1], framebuffer);␊ |
896 | ␉devprop_add_value(device, (char *) ati_compatible_1[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
897 | ␊ |
898 | ␉sprintf(tmp, ati_device_type[1], framebuffer);␊ |
899 | ␉devprop_add_value(device, (char *) ati_device_type[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
900 | ␊ |
901 | ␉sprintf(tmp, ati_name[1], framebuffer);␊ |
902 | ␉devprop_add_value(device, (char *) ati_name[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
903 | ␊ |
904 | ␉sprintf(tmp, ati_name_0[1], framebuffer);␊ |
905 | ␉devprop_add_value(device, (char *) ati_name_0[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
906 | ␊ |
907 | ␉sprintf(tmp, ati_name_1[1], framebuffer);␊ |
908 | ␉devprop_add_value(device, (char *) ati_name_1[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
909 | ␊ |
910 | ␉sprintf(tmp, "bt(0,0)/Extra/%04x_%04x.rom", (uint16_t)ati_dev->vendor_id, (uint16_t)ati_dev->device_id);␊ |
911 | ␉if (getBoolForKey(kUseAtiROMKey, &doit, &bootInfo->chameleonConfig) && doit) {␊ |
912 | ␉␉verbose("looking for ati video bios file %s\n", tmp);␊ |
913 | ␉␉rom = malloc(0x20000);␊ |
914 | ␉␉rom_size = load_ati_bios_file(tmp, rom, 0x20000);␊ |
915 | ␉␉if (rom_size > 0) {␊ |
916 | ␉␉␉verbose("Using ATI Video BIOS File %s (%d Bytes)\n", tmp, rom_size);␊ |
917 | ␉␉␉if (rom_size > 0x10000) {␊ |
918 | ␉␉␉␉rom_size = 0x10000; //we dont need rest anyway;␊ |
919 | ␉␉␉}␊ |
920 | ␉␉} else {␊ |
921 | ␉␉␉printf("ERROR: unable to open ATI Video BIOS File %s\n", tmp);␊ |
922 | ␉␉}␊ |
923 | ␉}␊ |
924 | ␉if (rom_size == 0) {␊ |
925 | ␉␉if (boot_display) {␉␉// no custom rom␊ |
926 | ␉␉␉bios = NULL;␉// try to dump from legacy space, otherwise can result in 100% fan speed␊ |
927 | ␉␉} else {␊ |
928 | ␉␉␉// readAtomBios result in bug on some cards (100% fan speed and black screen),␊ |
929 | ␉␉␉// not using it for posted card, reading from legacy space instead␊ |
930 | ␉␉␉bios = readAtomBIOS(ati_dev);␊ |
931 | ␉␉}␊ |
932 | ␉} else {␊ |
933 | ␉␉bios = rom;␉//going custom rom way␊ |
934 | ␉␉verbose("Using rom %s\n", tmp);␊ |
935 | ␉}␊ |
936 | ␉if (bios == NULL) {␊ |
937 | ␉␉bios = (uint8_t *)0x000C0000;␊ |
938 | ␉␉toFree = false;␊ |
939 | ␉␉verbose("Not going to use bios image file\n");␊ |
940 | ␉} else {␊ |
941 | ␉␉toFree = true;␊ |
942 | ␉}␊ |
943 | ␊ |
944 | ␉if (bios[0] == 0x55 && bios[1] == 0xaa) {␊ |
945 | ␉␉verbose("Found bios image\n");␊ |
946 | ␉␉bios_size = bios[2] * 512;␊ |
947 | ␊ |
948 | ␉␉rom_pci_header = (option_rom_pci_header_t*)(bios + bios[24] + bios[25]*256);␊ |
949 | ␊ |
950 | ␉␉if (rom_pci_header->signature == 0x52494350) {␊ |
951 | ␉␉␉if (rom_pci_header->device_id != ati_dev->device_id) {␊ |
952 | ␉␉␉␉verbose("Bios image (%x) doesnt match card (%x), ignoring\n", rom_pci_header->device_id, ati_dev->device_id);␊ |
953 | ␉␉␉} else {␊ |
954 | ␉␉␉␉if (toFree)␊ |
955 | ␉␉␉␉{␊ |
956 | ␉␉␉␉␉verbose("Adding binimage to card %x from mmio space with size %x\n", ati_dev->device_id, bios_size);␊ |
957 | ␉␉␉␉} else {␊ |
958 | ␉␉␉␉␉verbose("Adding binimage to card %x from legacy space with size %x\n", ati_dev->device_id, bios_size);␊ |
959 | ␉␉␉␉}␊ |
960 | ␉␉␉␉devprop_add_value(device, "ATY,bin_image", bios, bios_size);␊ |
961 | ␉␉␉}␊ |
962 | ␉␉} else {␊ |
963 | ␉␉␉verbose("Wrong pci header signature %x\n", rom_pci_header->signature);␊ |
964 | ␉␉}␊ |
965 | ␉} else {␊ |
966 | ␉␉verbose("Bios image not found at %x, content %x %x\n", bios, bios[0], bios[1]);␊ |
967 | ␉}␊ |
968 | ␉if (toFree) {␊ |
969 | ␉␉free(bios);␊ |
970 | ␉}␊ |
971 | ␉stringdata = malloc(sizeof(uint8_t) * string->length);␊ |
972 | ␉memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);␊ |
973 | ␉stringlength = string->length;␊ |
974 | ␊ |
975 | ␉return true;␊ |
976 | }␊ |
977 | |