Chameleon

Chameleon Svn Source Tree

Root/branches/JrCs/i386/libsaio/ati.c

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

Archive Download this file

Revision: 20