Chameleon

Chameleon Commit Details

Date:2013-05-10 18:52:59 (6 years 5 months ago)
Author:ErmaC
Commit:2213
Parents: 2212
Message:Fix Bug in the loop that look for an ATI card. Credits to Jief Luce
Changes:
M/trunk/i386/libsaio/ati.c

File differences

trunk/i386/libsaio/ati.c
15971597
15981598
15991599
1600
1600
16011601
1602
1603
1604
16051602
16061603
16071604
......
17031700
17041701
17051702
1706
1703
17071704
17081705
17091706
......
17121709
17131710
17141711
1715
1712
17161713
17171714
17181715
......
18401837
18411838
18421839
1843
1840
18441841
18451842
18461843
......
18571854
18581855
18591856
1860
1857
18611858
18621859
18631860
1864
1861
18651862
18661863
18671864
1868
1865
18691866
18701867
18711868
18721869
1873
1870
18741871
1875
1872
18761873
18771874
18781875
......
18811878
18821879
18831880
1884
1881
18851882
1886
1883
18871884
18881885
18891886
......
18921889
18931890
18941891
1895
1892
18961893
18971894
18981895
......
19731970
19741971
19751972
1976
1973
19771974
19781975
19791976
......
20952092
20962093
20972094
2098
2095
20992096
21002097
21012098
21022099
21032100
21042101
2105
2106
2107
2102
2103
2104
21082105
21092106
21102107
2111
2112
2113
2114
2115
2116
2117
2108
2109
2110
2111
2112
21182113
21192114
21202115
......
21242119
21252120
21262121
2127
2122
21282123
21292124
21302125
......
21472142
21482143
21492144
2150
2151
2145
2146
21522147
21532148
21542149
21552150
2156
2157
2151
2152
21582153
21592154
21602155
......
21722167
21732168
21742169
2175
2170
21762171
21772172
21782173
......
21802175
21812176
21822177
2183
2178
21842179
21852180
21862181
21872182
21882183
21892184
2190
2185
21912186
21922187
21932188
2194
2189
21952190
21962191
21972192
......
22082203
22092204
22102205
2211
2206
22122207
22132208
2214
2209
22152210
22162211
22172212
......
22242219
22252220
22262221
2227
2222
22282223
2229
2224
22302225
22312226
22322227
22332228
22342229
22352230
2236
2231
22372232
22382233
22392234
val->type = kStr;
val->size = strlen("onboard-1") + 1;
val->data = (uint8_t *)"onboard-1";
return true;
}
return false;
}
uint8_t *rev;
if (!card->rom)
return false;
rev = card->rom + *(uint8_t *)(card->rom + OFFSET_TO_GET_ATOMBIOS_STRINGS_START);
val->type = kPtr;
if (!val->data)
return false;
memcpy(val->data, rev, val->size);
return true;
if (rom_header->signature != 0xaa55)
return false;
rom_pci_header = (option_rom_pci_header_t *)((uint8_t *)rom_header + rom_header->pci_header_offset);
if (rom_pci_header->signature != 0x52494350)
int fd;
char file_name[24];
bool do_load = false;
getBoolForKey(key, &do_load, &bootInfo->chameleonConfig);
if (!do_load)
return false;
sprintf(file_name, "/Extra/%04x_%04x_%08x.rom", vendor_id, device_id, subsys_id);
if ((fd = open_bvdev("bt(0,0)", file_name, 0)) < 0)
return false;
card->rom_size = file_size(fd);
card->rom = malloc(card->rom_size);
if (!card->rom)
return false;
read(fd, (char *)card->rom, card->rom_size);
if (!validate_rom((option_rom_header_t *)card->rom, card->pci_dev))
{
card->rom_size = 0;
}
card->rom_size = ((option_rom_header_t *)card->rom)->rom_size * 512;
close(fd);
return true;
}
ati_chip_family_t chip_family = card->info->chip_family;
card->vram_size = 0;
if (chip_family >= CHIP_FAMILY_CEDAR)
// size in MB on evergreen
// XXX watch for overflow!!!
}
else
RegWrite32(R600_ROM_CNTL, (rom_cntl | R600_SCK_OVERWRITE));
ret = read_vbios(true);
// restore regs
if (!card)
return false;
bzero(card, sizeof(card_t));
card->pci_dev = pci_dev;
for (i = 0; radeon_cards[i].device_id ; i++)
{
if (radeon_cards[i].device_id == pci_dev->device_id)
{
card->info = &radeon_cards[i];
if ((radeon_cards[i].subsys_id == 0x00000000) ||
(radeon_cards[i].subsys_id == pci_dev->subsys_id.subsys_id))
//card->info = &radeon_cards[i]; // Jief
if ((radeon_cards[i].subsys_id == 0x00000000) || (radeon_cards[i].subsys_id == pci_dev->subsys_id.subsys_id))
card->info = &radeon_cards[i];
break;
}
}
//why can't this check go down to 1411?
//If we move it down we would still allow the cfg_name check
//if (!card->info->device_id || !card->info->cfg_name)
if (!card->info->device_id)
//why can't this check go down to 1411?
//If we move it down we would still allow the cfg_name check
if (card->info == NULL) // Jief
{
verbose("Unsupported ATI card! Device ID: [%04x:%04x] Subsystem ID: [%08x] \n",
pci_dev->vendor_id, pci_dev->device_id, pci_dev->subsys_id);
card->fb= (uint8_t *)(pci_config_read32(pci_dev->dev.addr, PCI_BASE_ADDRESS_0) & ~0x0f);
card->mmio= (uint8_t *)(pci_config_read32(pci_dev->dev.addr, PCI_BASE_ADDRESS_2) & ~0x0f);
card->io= (uint8_t *)(pci_config_read32(pci_dev->dev.addr, PCI_BASE_ADDRESS_4) & ~0x03);
verbose("Framebuffer @0x%08X MMIO @0x%08XI/O Port @0x%08X ROM Addr @0x%08X\n",
card->fb, card->mmio, card->io, pci_config_read32(pci_dev->dev.addr, PCI_ROM_ADDRESS));
verbose("\n");
}
}
if (card->info->chip_family >= CHIP_FAMILY_CEDAR)
{
card->flags |= EVERGREEN;
}
// Check AtiConfig key for a framebuffer name,
card->cfg_name = getStringForKey(kAtiConfig, &bootInfo->chameleonConfig);
// else, use the fb name returned by AtiConfig.
verbose("(AtiConfig) Framebuffer set to: %s\n", card->cfg_name);
}
// Check AtiPorts key for nr of ports,
card->ports = getIntForKey(kAtiPorts, &n_ports, &bootInfo->chameleonConfig);
// if a value bigger than 0 ?? is found, (do we need >= 0 ?? that's null FB on card_configs)
{
card->ports = n_ports; // use it.
verbose("(AtiPorts) # of ports set to: %d\n", card->ports);
}
}
else
{
// else, match cfg_name with card_configs list and retrive default nr of ports.
for (i = 0; i < kCfgEnd; i++)
if (strcmp(card->cfg_name, card_configs[i].name) == 0)
card->ports = card_configs[i].ports; // default
verbose("# of ports set to framebuffer's default: %d\n", card->ports);
}
sprintf(name, "ATY,%s", card->cfg_name);
aty_name.type = kStr;
aty_name.size = strlen(name) + 1;
bool setup_ati_devprop(pci_dt_t *ati_dev)
{
char *devicepath;
if (!init_card(ati_dev))
return false;
// -------------------------------------------------
// Find a better way to do this (in device_inject.c)
if (!string)
// -------------------------------------------------
#if 0
uint64_t fb= (uint32_t)card->fb;
uint64_t fb= (uint32_t)card->fb;
uint64_t mmio= (uint32_t)card->mmio;
uint64_t io= (uint32_t)card->io;
uint64_t io= (uint32_t)card->io;
devprop_add_value(card->device, "ATY,FrameBufferOffset", &fb, 8);
devprop_add_value(card->device, "ATY,RegisterSpaceOffset", &mmio, 8);
devprop_add_value(card->device, "ATY,IOSpaceOffset", &io, 8);
#endif
devprop_add_list(ati_devprop_list);
// -------------------------------------------------
// Find a better way to do this (in device_inject.c)
//Azi: XXX tried to fix a malloc error in vain; this is related to XCode 4 compilation!

Archive Download the corresponding diff file

Revision: 2213