Root/
Source at commit 307 created 12 years 10 months ago. By ifabio, merge changes from trunk (929). Also merge the module changes from Azimutz branche (fix compile error) Also edited the info.plist into AHCIPortInjector.kext: http://forum.voodooprojects.org/index.php/topic,1170.0.html | |
---|---|
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 | ␊ |
26 | #include "bootstruct.h"␊ |
27 | #include "pci.h"␊ |
28 | #include "platform.h"␊ |
29 | #include "device_inject.h"␊ |
30 | #include "ati.h"␊ |
31 | ␊ |
32 | #ifndef DEBUG_ATI␊ |
33 | #define DEBUG_ATI 0␊ |
34 | #endif␊ |
35 | ␊ |
36 | #if DEBUG_ATI␊ |
37 | #define DBG(x...)␉printf(x)␊ |
38 | #else␊ |
39 | #define DBG(x...)␊ |
40 | #endif␊ |
41 | ␊ |
42 | #define kUseAtiROMKey␉␉"UseAtiROM"␊ |
43 | ␊ |
44 | #define MAX_NUM_DCB_ENTRIES 16␊ |
45 | ␊ |
46 | #define TYPE_GROUPED 0xff␊ |
47 | ␊ |
48 | extern uint32_t devices_number;␊ |
49 | ␊ |
50 | const char *ati_compatible_0[]␉␉␉= { "@0,compatible", "ATY,%s" };␊ |
51 | const char *ati_compatible_1[]␉␉␉= { "@1,compatible", "ATY,%s" };␊ |
52 | const char *ati_device_type_0[]␉␉␉= { "@0,device_type", "display" };␊ |
53 | const char *ati_device_type_1[]␉␉␉= { "@1,device_type", "display" };␊ |
54 | const char *ati_device_type[]␉␉␉= { "device_type", "ATY,%sParent" };␊ |
55 | const char *ati_name_0[]␉␉␉= { "@0,name", "ATY,%s" };␊ |
56 | const char *ati_name_1[]␉␉␉= { "@1,name", "ATY,%s" };␊ |
57 | const char *ati_name[]␉␉␉␉= { "name", "ATY,%sParent" };␊ |
58 | const char *ati_efidisplay_0[]␉␉␉= { "@0,ATY,EFIDisplay", "TMDSB" };␊ |
59 | struct ati_data_key ati_connector_type_0␉= { 0x04, "@0,connector-type", {0x00, 0x04, 0x00, 0x00} };␊ |
60 | struct ati_data_key ati_connector_type_1␉= { 0x04, "@1,connector-type", {0x04, 0x00, 0x00, 0x00} };␊ |
61 | struct ati_data_key ati_display_con_fl_type_0␉= { 0x04, "@0,display-connect-flags", {0x00, 0x00, 0x04, 0x00} };␊ |
62 | const char *ati_display_type_0[]␉␉= { "@0,display-type", "LCD" };␊ |
63 | const char *ati_display_type_1[]␉␉= { "@1,display-type", "NONE" };␊ |
64 | struct ati_data_key ati_aux_power_conn␉␉= { 0x04, "AAPL,aux-power-connected", {0x01, 0x00, 0x00, 0x00} };␊ |
65 | struct ati_data_key ati_backlight_ctrl␉␉= { 0x04, "AAPL,backlight-control", {0x00, 0x00, 0x00, 0x00} };␊ |
66 | struct ati_data_key ati_aapl01_coher␉␉= { 0x04, "AAPL01,Coherency", {0x01, 0x00, 0x00, 0x00} };␊ |
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 | struct ati_data_key ati_efi_disp_conf␉␉= { 0x08, "ATY,EFIDispConfig", {0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} };␊ |
71 | struct ati_data_key ati_efi_drv_type␉␉= { 0x01, "ATY,EFIDriverType", {0x02} };␊ |
72 | struct ati_data_key ati_efi_enbl_mode␉␉= { 0x01, "ATY,EFIEnabledMode", {0x01} };␊ |
73 | struct ati_data_key ati_efi_init_stat␉␉= { 0x04, "ATY,EFIHWInitStatus", {0x00, 0x00, 0x00, 0x00} };␊ |
74 | struct ati_data_key ati_efi_orientation␉␉= { 0x02, "ATY,EFIOrientation", {0x02, 0x00} };␊ |
75 | const char *ati_efi_version[]␉␉␉= { "ATY,EFIVersion", "01.00.318" };␊ |
76 | const char *ati_efi_versionB[]␉␉␉= { "ATY,EFIVersionB", "113-SBSJ1G04-00R-02" };␊ |
77 | const char *ati_efi_versionE[]␉␉␉= { "ATY,EFIVersionE", "113-B7710A-318" };␊ |
78 | struct ati_data_key ati_mclk␉␉␉= { 0x04, "ATY,MCLK", {0x70, 0x2e, 0x11, 0x00} };␊ |
79 | struct ati_data_key ati_mem_rev_id␉␉= { 0x02, "ATY,MemRevisionID", {0x03, 0x00} };␊ |
80 | struct ati_data_key ati_mem_vend_id␉␉= { 0x02, "ATY,MemVendorID", {0x02, 0x00} };␊ |
81 | const char *ati_mrt[]␉␉␉␉= { "ATY,MRT", " " };␊ |
82 | const char *ati_romno[]␉␉␉␉= { "ATY,Rom#", "113-B7710C-176" };␊ |
83 | struct ati_data_key ati_sclk␉␉␉= { 0x04, "ATY,SCLK", {0x28, 0xdb, 0x0b, 0x00} };␊ |
84 | struct ati_data_key ati_vendor_id␉␉= { 0x02, "ATY,VendorID", {0x02, 0x10} };␊ |
85 | struct ati_data_key ati_platform_info␉␉= { 0x80, "ATY,PlatformInfo", {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
86 | struct ati_data_key ati_mvad␉␉␉= { 0x40, "MVAD", {0x3f, 0x5c, 0x82, 0x02, 0xff, 0x90, 0x00, 0x54, 0x60, 0x00, 0xac, 0x10, 0xa0, 0x17, 0x00, 0x03, 0xb0, 0x68, 0x00, 0x0a, 0xa0, 0x0a, 0x30, 0x00, 0x20, 0x00, 0x40, 0x06, 0x6e, 0x06, 0x03, 0x00, 0x06, 0x00, 0x40, 0x06, 0x00, 0x0a, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x10, 0x06, 0x92, 0x20, 0x00, 0x03} };␊ |
87 | struct ati_data_key ati_saved_config␉␉= { 0x100, "saved-config", {0x3f, 0x5c, 0x82, 0x02, 0xff, 0x90, 0x00, 0x54, 0x60, 0x00, 0xac, 0x10, 0xa0, 0x17, 0x00, 0x03, 0xb0, 0x68, 0x00, 0x0a, 0xa0, 0x0a, 0x30, 0x00, 0x20, 0x00, 0x40, 0x06, 0x6e, 0x06, 0x03, 0x00, 0x06, 0x00, 0x40, 0x06, 0x00, 0x0a, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x10, 0x06, 0x92, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xee, 0x02, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
88 | ///non 48xx keys␊ |
89 | const char *ati_efidisplay_0_n4[]␉␉= { "@0,ATY,EFIDisplay", "TMDSA" };␊ |
90 | struct ati_data_key ati_connector_type_0_n4␉= { 0x04, "@0,connector-type", {0x04, 0x00, 0x00, 0x00} };␊ |
91 | struct ati_data_key ati_connector_type_1_n4␉= { 0x04, "@1,connector-type", {0x00, 0x02, 0x00, 0x00} };␊ |
92 | struct ati_data_key ati_aapl_emc_disp_list_n4␉= { 0x40, "AAPL,EMC-Display-List", {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x1b, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x1c, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
93 | struct ati_data_key ati_fb_offset_n4␉␉= { 0x08, "ATY,FrameBufferOffset", {0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00} };␊ |
94 | struct ati_data_key ati_hwgpio_n4␉␉= { 0x04, "ATY,HWGPIO", {0x23, 0xa8, 0x48, 0x00} };␊ |
95 | struct ati_data_key ati_iospace_offset_n4␉= { 0x08, "ATY,IOSpaceOffset", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00} };␊ |
96 | struct ati_data_key ati_mclk_n4␉␉␉= { 0x04, "ATY,MCLK", {0x00, 0x35, 0x0c, 0x00} };␊ |
97 | struct ati_data_key ati_sclk_n4␉␉␉= { 0x04, "ATY,SCLK", {0x60, 0xae, 0x0a, 0x00} };␊ |
98 | struct ati_data_key ati_refclk_n4␉␉= { 0x04, "ATY,RefCLK", {0x8c, 0x0a, 0x00, 0x00} };␊ |
99 | struct ati_data_key ati_regspace_offset_n4␉= { 0x08, "ATY,RegisterSpaceOffset", {0x00, 0x00, 0x00, 0x00, 0x90, 0xa2, 0x00, 0x00} };␊ |
100 | struct ati_data_key ati_vram_memsize_0␉␉= { 0x08, "@0,VRAM,memsize", {0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00} };␊ |
101 | struct ati_data_key ati_vram_memsize_1␉␉= { 0x08, "@1,VRAM,memsize", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
102 | struct ati_data_key ati_aapl_blackscr_prefs_0_n4= { 0x04, "AAPL00,blackscreen-preferences", {0x00, 0x00, 0x00, 0x00} };␊ |
103 | struct ati_data_key ati_aapl_blackscr_prefs_1_n4= { 0x04, "AAPL01,blackscreen-preferences", {0x00, 0x00, 0x00, 0x00} };␊ |
104 | struct ati_data_key ati_swgpio_info_n4␉␉= { 0x04, "ATY,SWGPIO Info", {0x00, 0x48, 0xa8, 0x23} };␊ |
105 | struct ati_data_key ati_efi_orientation_n4␉= { 0x01, "ATY,EFIOrientation", {0x08} };␊ |
106 | struct ati_data_key ati_mvad_n4␉␉␉= { 0x100, "MVAD", {0x3e, 0x5c, 0x82, 0x00, 0xff, 0x90, 0x00, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3c, 0x80, 0x07, 0x20, 0x08, 0x30, 0x00, 0x20, 0x00, 0xb0, 0x04, 0xd3, 0x04, 0x03, 0x00, 0x06, 0x00, 0xb0, 0x04, 0x80, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x90, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
107 | struct ati_data_key ati_saved_config_n4␉␉= { 0x100, "saved-config", {0x3e, 0x5c, 0x82, 0x00, 0xff, 0x90, 0x00, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3c, 0x80, 0x07, 0x20, 0x08, 0x30, 0x00, 0x20, 0x00, 0xb0, 0x04, 0xd3, 0x04, 0x03, 0x00, 0x06, 0x00, 0xb0, 0x04, 0x80, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x90, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
108 | ␊ |
109 | struct pcir_s {␊ |
110 | ␉uint32_t signature;␊ |
111 | ␉uint16_t vid;␊ |
112 | ␉uint16_t devid;␊ |
113 | };␊ |
114 | ␊ |
115 | // Known cards as of 2008/08/26␊ |
116 | static struct ati_chipsets_t ATIKnownChipsets[] = {␊ |
117 | ␉{ 0x00000000, "Unknown" } ,␊ |
118 | //␉{ 0x10027181, "ATI Radeon 1300 Series"} ,␊ |
119 | ␉{ 0x10029589, "ATI Radeon 2600 Series"} ,␊ |
120 | ␉{ 0x10029588, "ATI Radeon 2600 Series"} ,␊ |
121 | ␉{ 0x100294C3, "ATI Radeon 2400 Series"} ,␊ |
122 | ␉{ 0x100294C4, "ATI Radeon 2400 Series"} ,␊ |
123 | ␉{ 0x100294C6, "ATI Radeon 2400 Series"} ,␊ |
124 | ␉{ 0x10029400, "ATI Radeon 2900 Series"} ,␊ |
125 | ␉{ 0x10029405, "ATI Radeon 2900GT Series"} ,␊ |
126 | ␉{ 0x10029581, "ATI Radeon 2600 Series"} ,␊ |
127 | ␉{ 0x10029583, "ATI Radeon 2600 Series"} ,␊ |
128 | ␉{ 0x10029586, "ATI Radeon 2600 Series"} ,␊ |
129 | ␉{ 0x10029587, "ATI Radeon 2600 Series"} ,␊ |
130 | ␉{ 0x100294C9, "ATI Radeon 2400 Series"} ,␊ |
131 | ␉{ 0x10029501, "ATI Radeon 3800 Series"} ,␊ |
132 | ␉{ 0x10029505, "ATI Radeon 3800 Series"} ,␊ |
133 | ␉{ 0x10029515, "ATI Radeon 3800 Series"} ,␊ |
134 | ␉{ 0x10029507, "ATI Radeon 3800 Series"} ,␊ |
135 | ␉{ 0x10029500, "ATI Radeon 3800 Series"} ,␊ |
136 | ␉{ 0x1002950F, "ATI Radeon 3800X2 Series"} ,␊ |
137 | ␉{ 0x100295C5, "ATI Radeon 3400 Series"} ,␊ |
138 | ␉{ 0x100295C7, "ATI Radeon 3400 Series"} ,␊ |
139 | ␉{ 0x100295C0, "ATI Radeon 3400 Series"} ,␊ |
140 | ␉{ 0x10029596, "ATI Radeon 3600 Series"} ,␊ |
141 | ␉{ 0x10029590, "ATI Radeon 3600 Series"} ,␊ |
142 | ␉{ 0x10029599, "ATI Radeon 3600 Series"} ,␊ |
143 | ␉{ 0x10029597, "ATI Radeon 3600 Series"} ,␊ |
144 | ␉{ 0x10029598, "ATI Radeon 3600 Series"} ,␊ |
145 | ␉{ 0x10029442, "ATI Radeon 4850 Series"} ,␊ |
146 | ␉{ 0x10029440, "ATI Radeon 4870 Series"} ,␊ |
147 | ␉{ 0x1002944C, "ATI Radeon 4830 Series"} ,␊ |
148 | ␉{ 0x10029460, "ATI Radeon 4890 Series"} ,␊ |
149 | ␉{ 0x10029462, "ATI Radeon 4890 Series"} ,␊ |
150 | ␉{ 0x10029441, "ATI Radeon 4870X2 Series"} ,␊ |
151 | ␉{ 0x10029443, "ATI Radeon 4850X2 Series"} ,␊ |
152 | ␉{ 0x10029444, "ATI Radeon 4800 Series"} ,␊ |
153 | ␉{ 0x10029446, "ATI Radeon 4800 Series"} ,␊ |
154 | ␉{ 0x1002944E, "ATI Radeon 4730 Series"} ,␊ |
155 | ␉{ 0x10029450, "ATI Radeon 4800 Series"} ,␊ |
156 | ␉{ 0x10029452, "ATI Radeon 4800 Series"} ,␉␉␊ |
157 | ␉{ 0x10029456, "ATI Radeon 4800 Series"} ,␉␉␊ |
158 | ␉{ 0x1002944A, "ATI Radeon 4800 Mobility Series"} ,␊ |
159 | ␉{ 0x1002945A, "ATI Radeon 4800 Mobility Series"} ,␊ |
160 | ␉{ 0x1002945B, "ATI Radeon 4800 Mobility Series"} ,␊ |
161 | ␉{ 0x1002944B, "ATI Radeon 4800 Mobility Series"} ,␊ |
162 | { 0x10029490, "ATI Radeon 4670 Series"} ,␊ |
163 | { 0x10029498, "ATI Radeon 4650 Series"} ,␊ |
164 | ␉{ 0x10029490, "ATI Radeon 4600 Series"} ,␊ |
165 | ␉{ 0x10029498, "ATI Radeon 4600 Series"} ,␊ |
166 | ␉{ 0x1002949E, "ATI Radeon 4600 Series"} ,␊ |
167 | ␉{ 0x10029480, "ATI Radeon 4600 Series"} ,␊ |
168 | ␉{ 0x10029488, "ATI Radeon 4600 Series"} ,␊ |
169 | ␉{ 0x10029540, "ATI Radeon 4500 Series"} ,␊ |
170 | ␉{ 0x10029541, "ATI Radeon 4500 Series"} ,␊ |
171 | ␉{ 0x1002954E, "ATI Radeon 4500 Series"} ,␊ |
172 | ␉{ 0x10029552, "ATI Radeon 4300 Mobility Series"} ,␊ |
173 | ␉{ 0x10029553, "ATI Radeon 4500 Mobility Series"} ,␊ |
174 | ␉{ 0x1002954F, "ATI Radeon 4300 Series"} ,␊ |
175 | { 0x100294B3, "ATI Radeon 4770 Series"} ,␊ |
176 | { 0x100294B5, "ATI Radeon 4770 Series"} ,␊ |
177 | { 0x100268B8, "ATI Radeon 5700 Series"} ,␊ |
178 | { 0x100268BE, "ATI Radeon 5700 Series"} ,␊ |
179 | { 0x10026898, "ATI Radeon 5800 Series"} ,␊ |
180 | { 0x10026899, "ATI Radeon 5800 Series"}␊ |
181 | };␊ |
182 | ␊ |
183 | static struct ati_chipsets_t ATIKnownFramebuffers[] = {␊ |
184 | ␉{ 0x00000000, "Megalodon" },␊ |
185 | //␉{ 0x10027181, "Caretta" },␊ |
186 | ␉{ 0x10029589, "Lamna"} ,␊ |
187 | ␉{ 0x10029588, "Lamna"} ,␊ |
188 | ␉{ 0x100294C3, "Iago"} ,␊ |
189 | ␉{ 0x100294C4, "Iago"} ,␊ |
190 | ␉{ 0x100294C6, "Iago"} ,␊ |
191 | ␉{ 0x10029400, "Franklin"} ,␊ |
192 | ␉{ 0x10029405, "Franklin"} ,␊ |
193 | ␉{ 0x10029581, "Hypoprion"} ,␊ |
194 | ␉{ 0x10029583, "Hypoprion"} ,␊ |
195 | ␉{ 0x10029586, "Hypoprion"} ,␊ |
196 | ␉{ 0x10029587, "Hypoprion"} ,␊ |
197 | ␉{ 0x100294C9, "Iago"} ,␊ |
198 | ␉{ 0x10029501, "Megalodon"} ,␊ |
199 | ␉{ 0x10029505, "Megalodon"} ,␊ |
200 | ␉{ 0x10029515, "Megalodon"} ,␊ |
201 | ␉{ 0x10029507, "Megalodon"} ,␊ |
202 | ␉{ 0x10029500, "Megalodon"} ,␊ |
203 | ␉{ 0x1002950F, "Triakis"} ,␊ |
204 | ␉{ 0x100295C5, "Iago"} ,␊ |
205 | ␉{ 0x100295C7, "Iago"} ,␊ |
206 | ␉{ 0x100295C0, "Iago"} ,␊ |
207 | ␉{ 0x10029596, "Megalodon"} ,␊ |
208 | ␉{ 0x10029590, "Megalodon"} ,␊ |
209 | ␉{ 0x10029599, "Megalodon"} ,␊ |
210 | ␉{ 0x10029597, "Megalodon"} ,␊ |
211 | ␉{ 0x10029598, "Megalodon"} ,␊ |
212 | ␉{ 0x10029442, "Motmot"} ,␊ |
213 | ␉{ 0x10029440, "Motmot"} ,␊ |
214 | ␉{ 0x1002944C, "Motmot"} ,␊ |
215 | ␉{ 0x10029460, "Motmot"} ,␊ |
216 | ␉{ 0x10029462, "Motmot"} ,␊ |
217 | ␉{ 0x10029441, "Motmot"} ,␊ |
218 | ␉{ 0x10029443, "Motmot"} ,␊ |
219 | ␉{ 0x10029444, "Motmot"} ,␊ |
220 | ␉{ 0x10029446, "Motmot"} ,␊ |
221 | ␉{ 0x1002944E, "Motmot"} ,␊ |
222 | ␉{ 0x10029450, "Motmot"} ,␊ |
223 | ␉{ 0x10029452, "Motmot"} ,␉␉␊ |
224 | ␉{ 0x10029456, "Motmot"} ,␉␉␊ |
225 | ␉{ 0x1002944A, "Motmot"} ,␊ |
226 | ␉{ 0x1002945A, "Motmot"} ,␊ |
227 | ␉{ 0x1002945B, "Motmot"} ,␊ |
228 | ␉{ 0x1002944B, "Motmot"} ,␊ |
229 | { 0x10029490, "Peregrine"} ,␊ |
230 | { 0x10029498, "Peregrine"} ,␊ |
231 | { 0x1002949E, "Peregrine"} ,␊ |
232 | { 0x10029480, "Peregrine"} ,␊ |
233 | { 0x10029488, "Peregrine"} ,␊ |
234 | { 0x10029540, "Peregrine"} ,␊ |
235 | { 0x10029541, "Peregrine"} ,␊ |
236 | { 0x1002954E, "Peregrine"} ,␊ |
237 | { 0x10029552, "Peregrine"} ,␊ |
238 | { 0x10029553, "Peregrine"} ,␊ |
239 | { 0x1002954F, "Peregrine"} ,␊ |
240 | { 0x100294B3, "Peregrine"},␊ |
241 | { 0x100294B5, "Peregrine"},␊ |
242 | { 0x100268B8, "Motmot"},␊ |
243 | { 0x100268BE, "Motmot"},␊ |
244 | { 0x10026898, "Motmot"},␊ |
245 | { 0x10026899, "Motmot"}␊ |
246 | };␊ |
247 | ␊ |
248 | static uint32_t accessROM(pci_dt_t *ati_dev, unsigned int mode)␊ |
249 | {␊ |
250 | ␉uint32_t␉␉bar[7];␊ |
251 | ␉volatile uint32_t␉*regs;␊ |
252 | ␊ |
253 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
254 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
255 | ␊ |
256 | ␉if (mode) {␊ |
257 | ␉␉if (mode != 1) {␊ |
258 | ␉␉␉return 0xe00002c7;␊ |
259 | ␉␉}␊ |
260 | ␉␉REG32W(0x179c, 0x00080000);␊ |
261 | ␉␉REG32W(0x1798, 0x00080721);␊ |
262 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
263 | ␉␉REG32W(0x1600, 0x14030300);␊ |
264 | ␉␉REG32W(0x1798, 0x21);␊ |
265 | ␉␉REG32W(0x17a0, 0x21);␊ |
266 | ␉␉REG32W(0x179c, 0x00);␊ |
267 | ␉␉REG32W(0x17a0, 0x21);␊ |
268 | ␉␉REG32W(0x1798, 0x21);␊ |
269 | ␉␉REG32W(0x1798, 0x21);␊ |
270 | ␉} else {␊ |
271 | ␉␉REG32W(0x1600, 0x14030302);␉␊ |
272 | ␉␉REG32W(0x1798, 0x21);␊ |
273 | ␉␉REG32W(0x17a0, 0x21);␊ |
274 | ␉␉REG32W(0x179c, 0x00080000);␊ |
275 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
276 | ␉␉REG32W(0x1798, 0x00080721);␊ |
277 | ␉␉REG32W(0x1798, 0x21);␊ |
278 | ␉␉REG32W(0x17a0, 0x21);␊ |
279 | ␉␉REG32W(0x179c, 0x00);␊ |
280 | ␉␉REG32W(0x1604, 0x0400e9fc);␊ |
281 | ␉␉REG32W(0x161c, 0x00);␊ |
282 | ␉␉REG32W(0x1620, 0x9f);␊ |
283 | ␉␉REG32W(0x1618, 0x00040004);␊ |
284 | ␉␉REG32W(0x161c, 0x00);␊ |
285 | ␉␉REG32W(0x1604, 0xe9fc);␊ |
286 | ␉␉REG32W(0x179c, 0x00080000);␊ |
287 | ␉␉REG32W(0x1798, 0x00080721);␊ |
288 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
289 | ␉␉REG32W(0x1798, 0x21);␊ |
290 | ␉␉REG32W(0x17a0, 0x21);␊ |
291 | ␉␉REG32W(0x179c, 0x00);␊ |
292 | ␉}␊ |
293 | ␉return 0;␊ |
294 | }␊ |
295 | ␊ |
296 | static uint8_t *readAtomBIOS(pci_dt_t *ati_dev)␊ |
297 | {␊ |
298 | ␉uint32_t␉␉bar[7];␊ |
299 | ␉uint32_t␉␉*BIOSBase;␊ |
300 | ␉uint32_t␉␉counter;␊ |
301 | ␉volatile uint32_t␉*regs;␊ |
302 | ␊ |
303 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
304 | ␉regs = (volatile uint32_t *) (bar[2] & ~0x0f);␊ |
305 | ␉accessROM(ati_dev, 0);␊ |
306 | ␉REG32W(0xa8, 0);␊ |
307 | ␉REG32R(0xac);␊ |
308 | ␉REG32W(0xa8, 0);␊ |
309 | ␉REG32R(0xac);␉␊ |
310 | ␊ |
311 | ␉BIOSBase = malloc(0x10000);␊ |
312 | ␉REG32W(0xa8, 0);␊ |
313 | ␉BIOSBase[0] = REG32R(0xac);␊ |
314 | ␉counter = 4;␊ |
315 | ␉do {␊ |
316 | ␉␉REG32W(0xa8, counter);␊ |
317 | ␉␉BIOSBase[counter/4] = REG32R(0xac);␊ |
318 | ␉␉counter +=4;␊ |
319 | ␉} while (counter != 0x10000);␊ |
320 | ␉accessROM((pci_dt_t *)regs, 1);␊ |
321 | ␊ |
322 | ␉if (*(uint16_t *)BIOSBase != 0xAA55) {␊ |
323 | ␉␉printf("Wrong BIOS signature: %04x\n", *(uint16_t *)BIOSBase);␊ |
324 | ␉␉return 0;␊ |
325 | ␉}␊ |
326 | ␉return (uint8_t *)BIOSBase;␊ |
327 | }␊ |
328 | ␊ |
329 | #define R5XX_CONFIG_MEMSIZE␉0x00F8 //Azi:---␊ |
330 | #define R6XX_CONFIG_MEMSIZE␉0x5428␊ |
331 | ␊ |
332 | uint32_t getvramsizekb(pci_dt_t *ati_dev)␊ |
333 | {␊ |
334 | ␉uint32_t␉␉bar[7];␊ |
335 | ␉uint32_t␉␉size;␊ |
336 | ␉volatile uint32_t␉*regs;␊ |
337 | ␊ |
338 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
339 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
340 | ␉if (ati_dev->device_id < 0x9400) {␊ |
341 | ␉␉size = (REG32R(R5XX_CONFIG_MEMSIZE)) >> 10;␊ |
342 | ␉} else {␊ |
343 | ␉␉size = (REG32R(R6XX_CONFIG_MEMSIZE)) >> 10;␊ |
344 | ␉}␊ |
345 | ␉return size;␊ |
346 | }␊ |
347 | ␊ |
348 | #define AVIVO_D1CRTC_CONTROL␉0x6080␊ |
349 | #define AVIVO_CRTC_EN␉␉(1<<0)␊ |
350 | #define AVIVO_D2CRTC_CONTROL␉0x6880␊ |
351 | ␊ |
352 | static bool radeon_card_posted(pci_dt_t *ati_dev)␊ |
353 | {␊ |
354 | ␉// if devid matches biosimage(from legacy) devid - posted card, fails with X2/crossfire cards.␊ |
355 | /*␉char *biosimage = 0xC0000;␊ |
356 | ␉␊ |
357 | ␉if ((uint8_t)biosimage[0] == 0x55 && (uint8_t)biosimage[1] == 0xaa)␊ |
358 | ␉{␊ |
359 | ␉␉option_rom_pci_header_t *rom_pci_header; ␊ |
360 | ␉␉rom_pci_header = (option_rom_pci_header_t*)(biosimage + (uint8_t)biosimage[24] + (uint8_t)biosimage[25]*256);␊ |
361 | ␉␊ |
362 | ␉if (rom_pci_header->signature == 0x52494350)␊ |
363 | ␉␉{␊ |
364 | ␉␉if (rom_pci_header->device_id == ati_dev->device_id)␊ |
365 | ␉␉␉{␊ |
366 | ␉␉␉␉return true;␊ |
367 | ␉␉␉␉printf("Card was POSTed\n");␊ |
368 | ␉␉␉}␊ |
369 | ␉␉}␊ |
370 | ␉}␊ |
371 | ␉return false;␊ |
372 | ␉printf("Card was not POSTed\n");␊ |
373 | ␉*/␊ |
374 | ␉//fails yet␊ |
375 | ␉uint32_t␉␉bar[7];␊ |
376 | ␉uint32_t␉␉val;␊ |
377 | ␉volatile uint32_t␉*regs;␊ |
378 | ␊ |
379 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18);␊ |
380 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
381 | ␊ |
382 | ␉val = REG32R(AVIVO_D1CRTC_CONTROL) | REG32R(AVIVO_D2CRTC_CONTROL);␊ |
383 | ␉if (val & AVIVO_CRTC_EN) {␊ |
384 | ␉␉return true;␊ |
385 | ␉} else {␊ |
386 | ␉␉return false;␊ |
387 | ␉}␊ |
388 | }␊ |
389 | ␊ |
390 | static uint32_t load_ati_bios_file(const char *filename, uint8_t *buf, int bufsize)␊ |
391 | {␊ |
392 | ␉int␉fd;␊ |
393 | ␉int␉size;␊ |
394 | ␊ |
395 | ␉if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) {␊ |
396 | ␉␉return 0;␊ |
397 | ␉}␊ |
398 | ␉size = file_size(fd);␊ |
399 | ␉if (size > bufsize) {␊ |
400 | ␉␉printf("Filesize of %s is bigger than expected! Truncating to 0x%x Bytes!\n", filename, bufsize);␊ |
401 | ␉␉size = bufsize;␊ |
402 | ␉}␊ |
403 | ␉size = read(fd, (char *)buf, size);␊ |
404 | ␉close(fd);␊ |
405 | ␉return size > 0 ? size : 0;␊ |
406 | }␊ |
407 | ␊ |
408 | static char *get_ati_model(uint32_t id)␊ |
409 | {␊ |
410 | ␉int i;␊ |
411 | ␉␊ |
412 | ␉for (i = 0; i < (sizeof(ATIKnownChipsets) / sizeof(ATIKnownChipsets[0])); i++) {␊ |
413 | ␉␉if (ATIKnownChipsets[i].device == id) {␊ |
414 | ␉␉␉return ATIKnownChipsets[i].name;␊ |
415 | ␉␉}␊ |
416 | ␉}␊ |
417 | ␉return ATIKnownChipsets[0].name;␊ |
418 | }␊ |
419 | ␊ |
420 | static char *get_ati_fb(uint32_t id)␊ |
421 | {␊ |
422 | ␉int␉i;␊ |
423 | ␉␊ |
424 | ␉for (i = 0; i < (sizeof(ATIKnownFramebuffers) / sizeof(ATIKnownFramebuffers[0])); i++) {␊ |
425 | ␉␉if (ATIKnownFramebuffers[i].device == id) {␊ |
426 | ␉␉␉return ATIKnownFramebuffers[i].name;␊ |
427 | ␉␉}␊ |
428 | ␉}␊ |
429 | ␉return ATIKnownFramebuffers[0].name;␊ |
430 | }␊ |
431 | ␊ |
432 | static int devprop_add_iopciconfigspace(struct DevPropDevice *device, pci_dt_t *ati_dev)␊ |
433 | {␊ |
434 | ␉int␉i;␊ |
435 | ␉uint8_t␉*config_space;␊ |
436 | ␊ |
437 | ␉if (!device || !ati_dev) {␊ |
438 | ␉␉return 0;␊ |
439 | ␉}␊ |
440 | ␉verbose("dumping pci config space, 256 bytes\n");␊ |
441 | ␉config_space = malloc(256);␊ |
442 | ␉for (i=0; i<=255; i++) {␊ |
443 | ␉␉config_space[i] = pci_config_read8( ati_dev->dev.addr, i);␊ |
444 | ␉}␊ |
445 | ␉devprop_add_value(device, "ATY,PCIConfigSpace", config_space, 256);␊ |
446 | ␉free (config_space);␊ |
447 | ␉return 1;␊ |
448 | }␊ |
449 | ␊ |
450 | static int devprop_add_ati_template_4xxx(struct DevPropDevice *device)␊ |
451 | {␊ |
452 | ␉if(!device)␊ |
453 | ␉␉return 0;␊ |
454 | ␉␊ |
455 | //␉if(!DP_ADD_TEMP_VAL(device, ati_compatible_0))␊ |
456 | //␉␉return 0;␊ |
457 | //␉if(!DP_ADD_TEMP_VAL(device, ati_compatible_1))␊ |
458 | //␉␉return 0;␊ |
459 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))␊ |
460 | ␉␉return 0;␊ |
461 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_1))␊ |
462 | ␉␉return 0;␊ |
463 | //␉if(!DP_ADD_TEMP_VAL(device, ati_device_type))␊ |
464 | //␉␉return 0;␊ |
465 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name_0))␊ |
466 | //␉␉return 0;␊ |
467 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
468 | //␉␉return 0;␊ |
469 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name))␊ |
470 | //␉␉return 0;␊ |
471 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efidisplay_0))␊ |
472 | ␉␉return 0;␊ |
473 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_0))␊ |
474 | ␉␉return 0;␊ |
475 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_1))␊ |
476 | ␉␉return 0;␊ |
477 | //␉if(!DP_ADD_TEMP_VAL(device, ati_slot_name))␊ |
478 | //␉␉return 0;␊ |
479 | ␉if(!DP_ADD_TEMP_VAL(device, ati_card_no))␊ |
480 | ␉␉return 0;␊ |
481 | ␉if(!DP_ADD_TEMP_VAL(device, ati_copyright))␊ |
482 | ␉␉return 0;␊ |
483 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_compile_d))␊ |
484 | ␉␉return 0;␊ |
485 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_version))␊ |
486 | ␉␉return 0;␊ |
487 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionB))␊ |
488 | ␉␉return 0;␊ |
489 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionE))␊ |
490 | ␉␉return 0;␊ |
491 | ␉if(!DP_ADD_TEMP_VAL(device, ati_mrt))␊ |
492 | ␉␉return 0;␊ |
493 | ␉if(!DP_ADD_TEMP_VAL(device, ati_romno))␊ |
494 | ␉␉return 0;␊ |
495 | ␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
496 | ␉␉return 0;␊ |
497 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_0))␊ |
498 | ␉␉return 0;␊ |
499 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_1))␊ |
500 | ␉␉return 0;␊ |
501 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_display_con_fl_type_0))␊ |
502 | ␉␉return 0;␊ |
503 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aux_power_conn))␊ |
504 | ␉␉return 0;␊ |
505 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_backlight_ctrl))␊ |
506 | ␉␉return 0;␊ |
507 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl01_coher))␊ |
508 | ␉␉return 0;␊ |
509 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_disp_conf))␊ |
510 | ␉␉return 0;␊ |
511 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_drv_type))␊ |
512 | ␉␉return 0;␊ |
513 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_enbl_mode))␊ |
514 | ␉␉return 0;␊ |
515 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_init_stat))␊ |
516 | ␉␉return 0;␊ |
517 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation))␊ |
518 | ␉␉return 0;␊ |
519 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mclk))␊ |
520 | ␉␉return 0;␊ |
521 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_rev_id))␊ |
522 | ␉␉return 0;␊ |
523 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_vend_id))␊ |
524 | ␉␉return 0;␊ |
525 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_sclk))␊ |
526 | ␉␉return 0;␊ |
527 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_vendor_id))␊ |
528 | ␉␉return 0;␊ |
529 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))␊ |
530 | ␉␉return 0;␊ |
531 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mvad))␊ |
532 | ␉␉return 0;␊ |
533 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_saved_config))␊ |
534 | ␉␉return 0;␊ |
535 | ␉return 1;␊ |
536 | }␊ |
537 | ␊ |
538 | static int devprop_add_ati_template(struct DevPropDevice *device)␊ |
539 | {␊ |
540 | ␉if(!device)␊ |
541 | ␉␉return 0;␊ |
542 | ␊ |
543 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))␊ |
544 | ␉␉return 0;␉␊ |
545 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))␊ |
546 | ␉␉return 0;␊ |
547 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_1))␊ |
548 | ␉␉return 0;␊ |
549 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efidisplay_0_n4))␊ |
550 | ␉␉return 0;␊ |
551 | //␉if(!DP_ADD_TEMP_VAL(device, ati_slot_name_n4))␊ |
552 | //␉␉return 0;␊ |
553 | ␉if(!DP_ADD_TEMP_VAL(device, ati_card_no))␊ |
554 | ␉␉return 0;␊ |
555 | ␉if(!DP_ADD_TEMP_VAL(device, ati_copyright))␊ |
556 | ␉␉return 0;␊ |
557 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_compile_d))␊ |
558 | ␉␉return 0;␊ |
559 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_version))␊ |
560 | ␉␉return 0;␊ |
561 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionB))␊ |
562 | ␉␉return 0;␊ |
563 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionE))␊ |
564 | ␉␉return 0;␊ |
565 | ␉if(!DP_ADD_TEMP_VAL(device, ati_mrt))␊ |
566 | ␉␉return 0;␊ |
567 | ␉if(!DP_ADD_TEMP_VAL(device, ati_romno))␊ |
568 | ␉␉return 0;␊ |
569 | ␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
570 | ␉␉return 0;␊ |
571 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_0_n4))␊ |
572 | ␉␉return 0;␊ |
573 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_1_n4))␊ |
574 | ␉␉return 0;␊ |
575 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aux_power_conn))␊ |
576 | ␉␉return 0;␊ |
577 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_backlight_ctrl))␊ |
578 | ␉␉return 0;␊ |
579 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl01_coher))␊ |
580 | ␉␉return 0;␊ |
581 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_drv_type))␊ |
582 | ␉␉return 0;␊ |
583 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_enbl_mode))␊ |
584 | ␉␉return 0;␊ |
585 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_rev_id))␊ |
586 | ␉␉return 0;␊ |
587 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_vend_id))␊ |
588 | ␉␉return 0;␊ |
589 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_vendor_id))␊ |
590 | ␉␉return 0;␊ |
591 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_emc_disp_list_n4))␊ |
592 | ␉␉return 0;␊ |
593 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_fb_offset_n4))␊ |
594 | ␉␉return 0;␊ |
595 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_hwgpio_n4))␊ |
596 | ␉␉return 0;␊ |
597 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_iospace_offset_n4))␊ |
598 | ␉␉return 0;␊ |
599 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mclk_n4))␊ |
600 | ␉␉return 0;␊ |
601 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_sclk_n4))␊ |
602 | ␉␉return 0;␊ |
603 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_refclk_n4))␊ |
604 | ␉␉return 0;␊ |
605 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_regspace_offset_n4))␊ |
606 | ␉␉return 0;␊ |
607 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation_n4))␊ |
608 | ␉␉return 0;␊ |
609 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_0_n4))␊ |
610 | ␉␉return 0;␊ |
611 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_1_n4))␊ |
612 | ␉␉return 0;␊ |
613 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_swgpio_info_n4))␊ |
614 | ␉␉return 0;␊ |
615 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation_n4))␊ |
616 | ␉␉return 0;␊ |
617 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mvad_n4))␊ |
618 | ␉␉return 0;␊ |
619 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_saved_config_n4))␊ |
620 | ␉␉return 0;␊ |
621 | ␉return 1;␊ |
622 | }␊ |
623 | ␊ |
624 | ␊ |
625 | bool setup_ati_devprop(pci_dt_t *ati_dev)␊ |
626 | {␊ |
627 | ␉struct DevPropDevice␉*device;␊ |
628 | ␉char␉␉␉␉␉*devicepath;␊ |
629 | ␉char␉␉␉␉␉*model;␊ |
630 | ␉char␉␉␉␉␉*framebuffer;␊ |
631 | ␉char␉␉␉␉␉ tmp[64];␊ |
632 | ␉uint8_t␉␉␉␉␉*rom = NULL;␊ |
633 | ␉uint32_t␉␉␉␉ rom_size = 0;␊ |
634 | ␉option_rom_pci_header_t *rom_pci_header;␊ |
635 | ␉uint8_t␉␉␉␉␉*bios;␊ |
636 | ␉uint32_t␉␉␉␉ bios_size;␊ |
637 | ␉uint32_t␉␉␉␉ vram_size;␊ |
638 | ␉uint32_t␉␉␉␉ boot_display;␊ |
639 | ␉uint8_t␉␉␉␉␉ cmd;␊ |
640 | ␉bool␉␉␉␉␉ doit;␊ |
641 | ␉bool␉␉␉␉␉ toFree;␊ |
642 | ␊ |
643 | ␉devicepath = get_pci_dev_path(ati_dev);␊ |
644 | ␊ |
645 | ␉cmd = pci_config_read8(ati_dev->dev.addr, 4);␊ |
646 | ␉verbose("old pci command - %x\n", cmd); //Azi: 7␊ |
647 | ␉if (cmd == 0) {␊ |
648 | ␉␉pci_config_write8(ati_dev->dev.addr, 4, 6);␉␊ |
649 | ␉␉cmd = pci_config_read8(ati_dev->dev.addr, 4);␊ |
650 | ␉␉verbose("new pci command - %x\n", cmd);␊ |
651 | ␉}␊ |
652 | ␊ |
653 | ␉model = get_ati_model((ati_dev->vendor_id << 16) | ati_dev->device_id); //Azi: Unknown␊ |
654 | ␉framebuffer = get_ati_fb((ati_dev->vendor_id << 16) | ati_dev->device_id); //Azi: Megalodon␊ |
655 | ␉if (!string) {␊ |
656 | ␉␉string = devprop_create_string();␊ |
657 | ␉}␊ |
658 | ␉device = devprop_add_device(string, devicepath);␊ |
659 | ␉if (!device) {␊ |
660 | ␉␉printf("Failed initializing dev-prop string dev-entry, press any key...\n");␊ |
661 | ␉␉getchar();␊ |
662 | ␉␉return false;␊ |
663 | ␉}␊ |
664 | ␊ |
665 | ␉/* FIXME: for primary graphics card only */␊ |
666 | ␉if (radeon_card_posted(ati_dev)) {␊ |
667 | ␉␉boot_display = 1;␊ |
668 | ␉} else {␊ |
669 | ␉␉boot_display = 0;␊ |
670 | ␉}␊ |
671 | ␉verbose("boot display - %x\n", boot_display); //Azi: 1... thus, POSTed!␊ |
672 | ␉devprop_add_value(device, "@0,AAPL,boot-display", (uint8_t*)&boot_display, 4); //Azi: Ok!␊ |
673 | ␊ |
674 | ␉if ((framebuffer[0] == 'M' && framebuffer[1] == 'o' && framebuffer[2] == 't') ||␊ |
675 | ␉␉(framebuffer[0] == 'S' && framebuffer[1] == 'h' && framebuffer[2] == 'r') ||␊ |
676 | ␉␉(framebuffer[0] == 'P' && framebuffer[1] == 'e' && framebuffer[2] == 'r')) //faster than strcmp ;)␊ |
677 | ␉␉//Azi: if framebuffer = Motmot or Shrike (none!) or Peregrine␊ |
678 | ␉␉devprop_add_ati_template_4xxx(device); //Azi: 4000 series (or 4800 ??)␊ |
679 | ␉else {␊ |
680 | ␉␉devprop_add_ati_template(device); //Azi: my scene!!!***␊ |
681 | ␉␉vram_size = getvramsizekb(ati_dev) * 1024;␊ |
682 | ␉␉if ((vram_size > 0x80000000) || (vram_size == 0)) {␊ |
683 | ␉␉␉vram_size = 0x10000000;␉//vram reported wrong, defaulting to 256 mb␊ |
684 | ␉␉}␊ |
685 | ␉␉devprop_add_value(device, "VRAM,totalsize", (uint8_t*)&vram_size, 4); //Azi: 0x20000000␊ |
686 | ␉␉ati_vram_memsize_0.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
687 | ␉␉ati_vram_memsize_0.data[7] = (vram_size >> 24) & 0xFF;␉␉␊ |
688 | ␉␉ati_vram_memsize_1.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
689 | ␉␉ati_vram_memsize_1.data[7] = (vram_size >> 24) & 0xFF;␊ |
690 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_0);␊ |
691 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_1);␊ |
692 | ␉␉devprop_add_iopciconfigspace(device, ati_dev);␉␉␊ |
693 | ␉}␊ |
694 | ␉devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1)); //Azi: Unknown␊ |
695 | ␉devprop_add_value(device, "ATY,DeviceID", (uint8_t*)&ati_dev->device_id, 2); //Azi: Ok! 8171 = (7181)␊ |
696 | ␊ |
697 | ␉//fb setup␊ |
698 | ␉sprintf(tmp, "Slot-%x",devices_number);␊ |
699 | ␉devprop_add_value(device, "AAPL,slot-name", (uint8_t*)tmp, strlen(tmp) + 1); //Azi: OK! Slot-1␊ |
700 | ␉// don't think my card is on slot 1 ??... 0 ??␊ |
701 | ␉devices_number++;␊ |
702 | ␊ |
703 | ␉sprintf(tmp, ati_compatible_0[1], framebuffer);␊ |
704 | ␉devprop_add_value(device, (char *) ati_compatible_0[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
705 | ␊ |
706 | ␉sprintf(tmp, ati_compatible_1[1], framebuffer);␊ |
707 | ␉devprop_add_value(device, (char *) ati_compatible_1[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
708 | ␊ |
709 | ␉sprintf(tmp, ati_device_type[1], framebuffer);␊ |
710 | ␉devprop_add_value(device, (char *) ati_device_type[0], (uint8_t *)tmp, strlen(tmp) + 1); //Azi: OK!␊ |
711 | ␊ |
712 | ␉sprintf(tmp, ati_name[1], framebuffer);␊ |
713 | ␉devprop_add_value(device, (char *) ati_name[0], (uint8_t *)tmp, strlen(tmp) + 1); //Azi: display ??␊ |
714 | ␊ |
715 | ␉sprintf(tmp, ati_name_0[1], framebuffer);␊ |
716 | ␉devprop_add_value(device, (char *) ati_name_0[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
717 | ␊ |
718 | ␉sprintf(tmp, ati_name_1[1], framebuffer);␊ |
719 | ␉devprop_add_value(device, (char *) ati_name_1[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
720 | ␊ |
721 | ␉//Azi: Assemble default path for a custom rom...␊ |
722 | ␉sprintf(tmp, "bt(0,0)/Extra/%04x_%04x.rom", (uint16_t)ati_dev->vendor_id, (uint16_t)ati_dev->device_id);␊ |
723 | ␉␊ |
724 | ␉//Azi: if user enabled use of custom rom...␊ |
725 | ␉if (getBoolForKey(kUseAtiROMKey, &doit, &bootInfo->bootConfig) && doit) {␊ |
726 | ␉␉verbose("Looking for custom ATI rom %s...\n", tmp);␊ |
727 | ␉␉rom = malloc(0x20000);␊ |
728 | ␉␉rom_size = load_ati_bios_file(tmp, rom, 0x20000);␊ |
729 | ␉␉␊ |
730 | ␉␉//Azi: if rom exists␊ |
731 | ␉␉if (rom_size > 0)␊ |
732 | ␉␉{␊ |
733 | ␉␉␉verbose("Using custom rom %s (%d Bytes)\n", tmp, rom_size);␊ |
734 | ␉␉␉if (rom_size > 0x10000) {␊ |
735 | ␉␉␉␉rom_size = 0x10000; // we dont need the rest anyway;␊ |
736 | //Azi:␉␉␉verbose("Trimmed %s to %d Bytes\n", tmp, rom_size);␊ |
737 | ␉␉␉}␊ |
738 | ␉␉}␊ |
739 | ␉␉else␊ |
740 | ␉␉{␊ |
741 | ␉␉␉printf("ERROR: unable to open custom ATI rom %s.\n", tmp);␊ |
742 | ␉␉}␊ |
743 | ␉}␊ |
744 | ␉␊ |
745 | ␉if (rom_size == 0) //Azi: rom_size is still 0, user didn't enabled use of custom rom...␊ |
746 | ␉{␉//Azi: if card posted...␊ |
747 | ␉␉if (boot_display) { // no custom rom␉␊ |
748 | ␉␉␉bios = NULL; // try to dump from legacy space, otherwise can result in 100% fan speed␊ |
749 | //␉␉␉bios = readAtomBIOS(ati_dev); //Azi: Wrong BIOS signature... returns 0 = NULL :-//␊ |
750 | ␉␉}␊ |
751 | ␉␉else␊ |
752 | ␉␉{␊ |
753 | ␉␉␉// readAtomBios result in bug on some cards (100% fan speed and black screen),␊ |
754 | ␉␉␉// not using it for posted card, reading from legacy space instead - Azi: reminder***␊ |
755 | ␉␉␉bios = readAtomBIOS(ati_dev);␊ |
756 | ␉␉}␊ |
757 | ␉}␊ |
758 | ␉else //Azi: rom_size is diff from 0, user enabled use of custom rom...␊ |
759 | ␉{␊ |
760 | ␉␉bios = rom; //going custom rom way //Azi: shouldn't this be bios = rom_size??*****␊ |
761 | ␉␉verbose("Using rom %s\n", tmp); //Azi: print just the path␊ |
762 | ␉}␊ |
763 | ␉␊ |
764 | ␉if (bios == NULL) //Azi: card was posted (boot_display = 1)␊ |
765 | ␉{␊ |
766 | ␉␉bios = (uint8_t *)0x000C0000;␊ |
767 | ␉␉toFree = false;␊ |
768 | ␉␉verbose("Card posted, not going to use custom bios?? rom.\n"); //Azi: what file? custom rom??␊ |
769 | ␉}␊ |
770 | ␉else //Azi: anything but NULL, card wasn't posted (boot_display = 0), bios = readAtomBIOS(ati_dev), bios = rom_size... whatever :P ufff...␊ |
771 | ␉{␊ |
772 | ␉␉toFree = true;␊ |
773 | ␉}␊ |
774 | ␊ |
775 | ␉if (bios[0] == 0x55 && bios[1] == 0xaa) //Azi: check bios for 0xAA55 sig␊ |
776 | ␉{␊ |
777 | ␉␉verbose("Found bios image\n");␊ |
778 | ␉␉bios_size = bios[2] * 512;␊ |
779 | ␊ |
780 | ␉␉rom_pci_header = (option_rom_pci_header_t*)(bios + bios[24] + bios[25]*256);␊ |
781 | ␉␉//Azi: Wrong pci header signature 558a1275 but still works!**** check later...␊ |
782 | ␉␉// ‘rom_header’ is used uninitialized in this function...␊ |
783 | //␉␉rom_pci_header = (option_rom_pci_header_t *)((uint8_t *)rom_header + rom_header->pci_header_offset);␊ |
784 | ␊ |
785 | ␉␉if (rom_pci_header->signature == 0x52494350) //Azi: ati pci header sig␊ |
786 | ␉␉{␊ |
787 | ␉␉␉if (rom_pci_header->device_id != ati_dev->device_id) {␊ |
788 | ␉␉␉␉verbose("Bios image (%x) doesnt match card (%x), ignoring\n", rom_pci_header->device_id, ati_dev->device_id);␊ |
789 | ␉␉␉}␊ |
790 | ␉␉␉else␊ |
791 | ␉␉␉{␊ |
792 | ␉␉␉␉if (toFree) //Azi: card wasn't posted (boot_display = 0)␊ |
793 | ␉␉␉␉{␊ |
794 | ␉␉␉␉␉//Azi: mmio, Memory-mapped I/O - Kabyl's smbios patcher stuff reminder.␊ |
795 | ␉␉␉␉␉verbose("Adding binimage to card %x from mmio space with size %x\n", ati_dev->device_id, bios_size);␊ |
796 | ␉␉␉␉}␊ |
797 | ␉␉␉␉else //Azi: card was posted (boot_display = 1)␊ |
798 | ␉␉␉␉{␊ |
799 | ␉␉␉␉␉//Azi: check "legacy space/mmio" stuff again!!!***␊ |
800 | ␉␉␉␉␉verbose("Adding binimage to card %x from legacy space with size %x\n", ati_dev->device_id, bios_size);␊ |
801 | ␉␉␉␉}␊ |
802 | ␉␉␉␉//Azi: not all Mac's have this..!!␊ |
803 | ␉␉␉␉devprop_add_value(device, "ATY,bin_image", bios, bios_size);␊ |
804 | ␉␉␉}␊ |
805 | ␉␉}␊ |
806 | ␉␉else␊ |
807 | ␉␉{␊ |
808 | ␉␉␉// ATY,bin_image is not added... not all Mac's have this..!!␊ |
809 | ␉␉␉verbose("Wrong pci header signature %x\n", rom_pci_header->signature);␊ |
810 | ␉␉}␊ |
811 | ␉}␊ |
812 | ␉else␊ |
813 | ␉{␊ |
814 | ␉␉verbose("Bios image not found at %x, content %x %x\n", bios, bios[0], bios[1]);␊ |
815 | ␉}␊ |
816 | ␉␊ |
817 | ␉if (toFree) //Azi: card wasn't posted (boot_display = 0)␊ |
818 | ␉{␊ |
819 | ␉␉free(bios);␊ |
820 | ␉}␊ |
821 | ␉␊ |
822 | ␉//Azi: see ati.c AMDge; i have no problems here with xcode 4 compilation ???␊ |
823 | ␉stringdata = malloc(sizeof(uint8_t) * string->length);␊ |
824 | ␉memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);␊ |
825 | ␉stringlength = string->length;␊ |
826 | ␊ |
827 | ␉return true;␊ |
828 | }␊ |
829 |