Chameleon

Chameleon Commit Details

Date:2012-07-15 21:46:28 (6 years 11 months ago)
Author:ErmaC
Commit:2014
Parents: 2013
Message:nVidia: - Add SusbIDs for GTS 250 (0615)
Changes:
M/branches/ErmaC/Trunk/i386/boot2/boot.c
M/branches/ErmaC/Trunk/i386/libsaio/nvidia.c
M/branches/ErmaC/Trunk/i386/libsaio/ati.c
M/branches/ErmaC/Trunk/i386/boot2/options.c
M/branches/ErmaC/Trunk/i386/boot2/resume.c
M/branches/ErmaC/Trunk/i386/libsaio/allocate.c

File differences

branches/ErmaC/Trunk/i386/libsaio/allocate.c
3838
3939
4040
41
41
4242
4343
4444
......
7171
7272
7373
74
74
7575
7676
7777
{
char *nameBuf;
uint32_t *buffer;
nameBuf = malloc(strlen(rangeName) + 1);
if (nameBuf == 0) return -1;
strcpy(nameBuf, rangeName);
{
stop ("AllocateKernelMemory error");
}
bootArgs->ksize = gImageLastKernelAddr - bootArgs->kaddr;
return addr;
branches/ErmaC/Trunk/i386/libsaio/nvidia.c
388388
389389
390390
391
391392
392393
393394
......
453454
454455
455456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
456502
457503
458504
......
22882334
22892335
22902336
2291
2337
22922338
22932339
22942340
......
23082354
23092355
23102356
2311
2357
23122358
23132359
23142360
......
23212367
23222368
23232369
2324
2370
23252371
23262372
23272373
......
23382384
23392385
23402386
2341
2387
23422388
23432389
23442390
23452391
23462392
23472393
2348
2394
23492395
23502396
23512397
......
23622408
23632409
23642410
2411
23652412
23662413
23672414
......
23772424
23782425
23792426
2380
2427
23812428
23822429
23832430
......
23852432
23862433
23872434
2388
2435
23892436
23902437
23912438
......
24112458
24122459
24132460
2414
2461
24152462
24162463
24172464
......
24252472
24262473
24272474
2428
2475
24292476
24302477
24312478
24322479
2433
2480
24342481
24352482
24362483
......
24442491
24452492
24462493
2494
2495
2496
24472497
24482498
24492499
......
24542504
24552505
24562506
2457
2507
24582508
24592509
24602510
......
25162566
25172567
25182568
2519
2569
25202570
25212571
25222572
25232573
2524
2574
25252575
2526
2576
25272577
25282578
25292579
......
25322582
25332583
25342584
2535
2585
25362586
25372587
25382588
25392589
25402590
25412591
2542
2592
25432593
25442594
2545
2595
25462596
25472597
25482598
......
25712621
25722622
25732623
2574
2624
25752625
25762626
25772627
25782628
25792629
25802630
2581
2631
25822632
2583
2633
25842634
25852635
25862636
25872637
2588
2638
25892639
25902640
2591
2641
25922642
25932643
25942644
......
26832733
26842734
26852735
2686
2736
26872737
26882738
26892739
2690
2740
26912741
26922742
26932743
......
26972747
26982748
26992749
2700
2750
27012751
27022752
27032753
27042754
2705
2755
27062756
27072757
27082758
......
27182768
27192769
27202770
2721
2771
27222772
27232773
27242774
......
27622812
27632813
27642814
2765
2815
27662816
27672817
27682818
27692819
27702820
2771
2821
27722822
2773
2823
27742824
27752825
27762826
......
27842834
27852835
27862836
2787
2837
27882838
27892839
27902840
27912841
2792
2842
27932843
27942844
27952845
27962846
27972847
27982848
2799
2849
28002850
28012851
28022852
......
28052855
28062856
28072857
2808
2858
28092859
2810
2860
28112861
28122862
2813
2863
28142864
28152865
28162866
......
28462896
28472897
28482898
2849
2899
28502900
28512901
28522902
......
28572907
28582908
28592909
2860
2910
28612911
28622912
28632913
2864
2914
28652915
28662916
28672917
......
28752925
28762926
28772927
2878
2928
28792929
28802930
28812931
2882
2932
28832933
28842934
28852935
28862936
28872937
2888
2938
28892939
28902940
28912941
......
29232973
29242974
29252975
2926
2976
29272977
29282978
// 05E0 - 05EF
{ 0x10DE05E0,0x10DE064E,"nVidia GeForce GTX 295" },
{ 0x10DE05E0,0x38421291,"EVGA GeForce GTX 295" },
{ 0x10DE05E2,0x10438291,"Asus GeForce GTX 260" },
{ 0x10DE05E2,0x10438298,"Asus GeForce GTX 260" },
{ 0x10DE05E2,0x104382C4,"Asus GeForce GTX 260" },
{ 0x10DE0612,0x3842C875,"EVGA GeForce 9800 GTX+" },
{ 0x10DE0615,0x104382E6,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x104382FB,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x10438303,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x10438305,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x10438312,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x10438338,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x10438339,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x1043833C,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x10438345,"Asus GeForce GTS 250" },
{ 0x10DE0615,0x10480F67,"ELSA GeForce GTS 250" },
{ 0x10DE0615,0x10B00401,"Gainward GeForce GTS 250" },
{ 0x10DE0615,0x10190000,"Elitegroup GeForce GTS 250" },
{ 0x10DE0615,0x107D2723,"Leadteck GeForce GTS 250" },
{ 0x10DE0615,0x10DE0592,"Palit GeForce GTS 250" },
{ 0x10DE0615,0x10DE0593,"Palit GeForce GTS 250" },
{ 0x10DE0615,0x10DE0652,"Palit GeForce GTS 250" },
{ 0x10DE0615,0x10DE0719,"Palit GeForce GTS 250" },
{ 0x10DE0615,0x10DE079E,"Palit GeForce GTS 250" },
{ 0x10DE0615,0x11503842,"TMC GeForce GTS 250" }, // Thinking Machines Corporation
{ 0x10DE0615,0x11513842,"JAE GeForce GTS 250" },
{ 0x10DE0615,0x11553842,"Pine GeForce GTS 250" },
{ 0x10DE0615,0x11563842,"Periscope GeForce GTS 250" },
{ 0x10DE0615,0x145834C7,"Gigabyte GeForce GTS 250" },
{ 0x10DE0615,0x145834CB,"Gigabyte GeForce GTS 250" },
{ 0x10DE0615,0x145834E7,"Gigabyte GeForce GTS 250" },
{ 0x10DE0615,0x145834E9,"Gigabyte GeForce GTS 250" },
{ 0x10DE0615,0x14621542,"MSi GeForce GTS 250" },
{ 0x10DE0615,0x14621543,"MSi GeForce GTS 250" },
{ 0x10DE0615,0x14628090,"MSi GeForce GTS 250" },
{ 0x10DE0615,0x16822600,"XFX GeForce GTS 250" },
{ 0x10DE0615,0x16822601,"XFX GeForce GTS 250" },
{ 0x10DE0615,0x16822605,"XFX GeForce GTS 250" },
//{ 0x10DE0615,0x196E0593," GeForce GTS 250" },
{ 0x10DE0615,0x19DA2103,"Zotac GeForce GTS 250" },
{ 0x10DE0615,0x19DA3056,"Zotac GeForce GTS 250" },
{ 0x10DE0615,0x19DA5103,"Zotac GeForce GTS 250" },
//{ 0x10DE0615,0x19F1,"BFG GeForce GTS 250" },
{ 0x10DE0615,0x1ACC9252,"Point of View GeForce GTS 250" },
{ 0x10DE0615,0x1ACC9253,"Point of View GeForce GTS 250" },
{ 0x10DE0615,0x1ACC925C,"Point of View GeForce GTS 250" },
{ 0x10DE0615,0x1B0A9038,"Pegatron GeForce GTS 250" },
{ 0x10DE0615,0x38421145,"EVGA GeForce GTS 250" },
{ 0x10DE0615,0x38421158,"EVGA GeForce GTS 250" },
//{ 0x10DE0615,0x7377,"Colorful GeForce GTS 250" },
{ 0x10DE0618,0x1025028E,"Acer GeForce GTX 260M" },
{ 0x10DE0618,0x102802A1,"Dell GeForce GTX 260M" },
{ 0x10DE0618,0x102802A2,"Dell GeForce GTX 260M" },
uint8_t *dcbtable = &rom[dcbptr];
uint8_t dcbtable_version = dcbtable[0];
uint8_t headerlength = 0;
uint8_t numentries = 0;
uint8_t numentries = 0;
uint8_t recordlength = 0;
if (dcbtable_version >= 0x20)
sig = READ_LE_INT(dcbtable, 4);
headerlength = 8;
}
if (sig != 0x4edcbdcb)
{
printf("Bad display config block signature (0x%8x)\n", sig); //Azi: issue #48
strncpy(sig, (char *)&dcbtable[-7], 7);
recordlength = 10;
if (strcmp(sig, "DEV_REC"))
{
printf("Bad Display Configuration Block signature (%s)\n", sig);
numentries = MAX_NUM_DCB_ENTRIES;
uint8_t num_outputs = 0, i = 0;
struct dcbentry
{
uint8_t type;
uint8_t index;
uint8_t *heads;
} entries[numentries];
for (i = 0; i < numentries; i++)
{
uint32_t connection;
entries[num_outputs].type = connection & 0xf;
entries[num_outputs].index = num_outputs;
entries[num_outputs++].heads = (uint8_t*)&(dcbtable[(headerlength + recordlength * i) + 1]);
}
int has_lvds = false;
entries[i].type = TYPE_GROUPED;
}
}
// if we have a LVDS output, we group the rest to the second channel
if (has_lvds)
{
{
if (entries[i].type == TYPE_GROUPED)
continue;
channel2 |= ( 0x1 << entries[i].index);
entries[i].type = TYPE_GROUPED;
}
//printf("group channel 1\n");
channel1 |= ( 0x1 << entries[i].index);
entries[i].type = TYPE_GROUPED;
if ((entries[i-1].type == 0x0))
{
channel1 |= ( 0x1 << entries[i-1].index);
entries[i+1].type = TYPE_GROUPED;
}
break;
case 1:
//printf("group channel 2 : %d\n", i);
channel2 |= ( 0x1 << entries[i].index);
entries[i].type = TYPE_GROUPED;
if ((entries[i - 1].type == 0x0))
{
channel2 |= ( 0x1 << entries[i-1].index);
entries[i+1].type = TYPE_GROUPED;
}
break;
default:
break;
}
break;
}
// if we have left ungrouped outputs merge them to the empty channel
uint8_t *togroup;// = (channel1 ? (channel2 ? NULL : &channel2) : &channel1);
togroup = &channel2;
for (i = 0; i < num_outputs; i++)
{
if (entries[i].type != TYPE_GROUPED)
{
int fd;
int size;
if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0)
{
return 0;
}
size = file_size(fd);
if (size > bufsize)
{
printf("Filesize of %s is bigger than expected! Truncating to 0x%x Bytes!\n",
}
size = read(fd, (char *)buf, size);
close(fd);
return size > 0 ? size : 0;
}
static int devprop_add_nvidia_template(struct DevPropDevice *device)
{
char tmp[16];
if (!device)
return 0;
if (!DP_ADD_TEMP_VAL(device, nvidia_compatible_0))
return 0;
if (!DP_ADD_TEMP_VAL(device, nvidia_device_type_0))
sprintf(tmp, "Slot-%x",devices_number);
devprop_add_value(device, "AAPL,slot-name", (uint8_t *) tmp, strlen(tmp));
devices_number++;
return 1;
}
int hex2bin(const char *hex, uint8_t *bin, int len)
{
char*p;
inti;
inti;
charbuf[3];
if (hex == NULL || bin == NULL || len <= 0 || strlen(hex) != len * 2) {
printf("[ERROR] bin2hex input error\n");
return -1;
}
buf[2] = '\0';
p = (char *) hex;
for (i = 0; i < len; i++)
{
if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1])) {
// get card type
nvCardType = (REG32(0) >> 20) & 0x1ff;
// Amount of VRAM in kilobytes
videoRam = mem_detect(regs, nvCardType, nvda_dev);
model = get_nvidia_model(((nvda_dev->vendor_id << 16) | nvda_dev->device_id),((nvda_dev->subsys_id.subsys.vendor_id << 16) | nvda_dev->subsys_id.subsys.device_id));
verbose("%s %dMB NV%02x [%04x:%04x]-[%04x:%04x] :: %s device number: %d\n",
model, (uint32_t)(videoRam / 1024 / 1024),
(REG32(0) >> 20) & 0x1ff, nvda_dev->vendor_id, nvda_dev->device_id,
rom = malloc(NVIDIA_ROM_SIZE);
sprintf(nvFilename, "/Extra/%04x_%04x.rom", (uint16_t)nvda_dev->vendor_id,
(uint16_t)nvda_dev->device_id);
if (getBoolForKey(kUseNvidiaROM, &doit, &bootInfo->chameleonConfig) && doit)
{
verbose("Looking for nvidia video bios file %s\n", nvFilename);
nvBiosOveride = load_nvidia_bios_file(nvFilename, rom, NVIDIA_ROM_SIZE);
if (nvBiosOveride > 0)
{
verbose("Using nVidia Video BIOS File %s (%d Bytes)\n", nvFilename, nvBiosOveride);
{
// Otherwise read bios from card
nvBiosOveride = 0;
// PROM first
// Enable PROM access
(REG32(NV_PBUS_PCI_NV_20)) = NV_PBUS_PCI_NV_20_ROM_SHADOW_DISABLED;
}//end PRAM check
}//end PROM check
}//end load rom from bios
if ((nvPatch = patch_nvidia_rom(rom)) == PATCH_ROM_FAILED)
{
printf("ERROR: nVidia ROM Patching Failed!\n");
//return false;
}
rom_pci_header = (option_rom_pci_header_t*)(rom + *(uint16_t *)&rom[24]);
// check for 'PCIR' sig
if (rom_pci_header->signature == 0x50434952)
{
printf("nVidia incorrect PCI ROM signature: 0x%x\n", rom_pci_header->signature);
}
}
if (!string) {
string = devprop_create_string();
}
device = devprop_add_device(string, devicepath);
/* FIXME: for primary graphics card only */
boot_display = 1;
if (devices_number == 1)
{
devprop_add_value(device, "@0,AAPL,boot-display", (uint8_t*)&boot_display, 4);
}
if (nvPatch == PATCH_ROM_SUCCESS_HAS_LVDS) {
uint8_t built_in = 0x01;
devprop_add_value(device, "@0,built-in", &built_in, 1);
// get bios version
const int MAX_BIOS_VERSION_LENGTH = 32;
char* version_str = (char*)malloc(MAX_BIOS_VERSION_LENGTH);
memset(version_str, 0, MAX_BIOS_VERSION_LENGTH);
int i, version_start;
int crlf_count = 0;
// only search the first 384 bytes
for (i = 0; i < 0x180; i++)
{
sprintf(biosVersion, "%s", (nvBiosOveride > 0) ? nvFilename : version_str);
sprintf(kNVCAP, "NVCAP_%04x", nvda_dev->device_id);
if (getValueForKey(kNVCAP, &value, &len, &bootInfo->chameleonConfig) && len == NVCAP_LEN * 2)
{
uint8_t new_NVCAP[NVCAP_LEN];
memcpy(default_NVCAP, new_NVCAP, NVCAP_LEN);
}
}
if (getValueForKey(kDcfg0, &value, &len, &bootInfo->chameleonConfig) && len == DCFG0_LEN * 2)
{
uint8_t new_dcfg0[DCFG0_LEN];
if (hex2bin(value, new_dcfg0, DCFG0_LEN) == 0)
{
memcpy(default_dcfg_0, new_dcfg0, DCFG0_LEN);
if (getValueForKey(kDcfg1, &value, &len, &bootInfo->chameleonConfig) && len == DCFG1_LEN * 2)
{
uint8_t new_dcfg1[DCFG1_LEN];
if (hex2bin(value, new_dcfg1, DCFG1_LEN) == 0)
{
memcpy(default_dcfg_1, new_dcfg1, DCFG1_LEN);
verbose("Using user supplied @1,display-cfg\n");
printf("@1,display-cfg: %02x%02x%02x%02x\n",
default_dcfg_1[0], default_dcfg_1[1], default_dcfg_1[2], default_dcfg_1[3]);
}
}
#if DEBUG_NVCAP
printf("NVCAP: %02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x\n",
default_NVCAP[0], default_NVCAP[1], default_NVCAP[2], default_NVCAP[3],
stringdata = malloc(sizeof(uint8_t) * string->length);
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
return true;
}
branches/ErmaC/Trunk/i386/libsaio/ati.c
760760
761761
762762
763
763
764764
765765
766766
{ 0x6758,0x00121028, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670", kBulrushes},
{ 0x6758,0x0B0E1028, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670", kBulrushes},
{ 0x6758,0x20121787, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670", kBulrushes},
{ 0x6758,0x20121787, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670", kPithecia},
{ 0x6758,0x22051458, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670", kBulrushes},
{ 0x6758,0x31811682, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670", kBulrushes},
{ 0x6758,0x31831682, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670", kBulrushes},
branches/ErmaC/Trunk/i386/boot2/resume.c
139139
140140
141141
142
142
143143
144144
145145
mem_base = getmemorylimit() - allocSize;//TODO: lower this
printf("mem_base %x\n", mem_base);
if (((long long)mem_base + allocSize) < (1024 * bootInfo->extmem + 0x100000))
if (((long long)mem_base + allocSize) < (1024 * bootInfo->extmem + 0x100000))
{
printf ("Not enough space to restore image. Press any key to proceed with normal boot.\n");
getchar();
branches/ErmaC/Trunk/i386/boot2/boot.c
165165
166166
167167
168
168
169169
170170
171171
}
md0Ramdisk();
verbose("Starting Darwin %s\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64");
verbose("Boot Args: %s\n", bootArgs->CommandLine);
branches/ErmaC/Trunk/i386/boot2/options.c
13511351
13521352
13531353
1354
1354
13551355
13561356
13571357
showInfoBox( "Press q to continue, space for next page.\n",buf_orig );
return;
}
// Create a copy so that we don't mangle the original
buf = malloc(size + 1);
memcpy(buf, buf_orig, size);

Archive Download the corresponding diff file

Revision: 2014