Chameleon

Chameleon Commit Details

Date:2012-05-08 14:44:50 (11 years 10 months ago)
Author:Cosmosis Jones
Commit:1945
Parents: 1944
Message:fixed duplicate turbo credits applied mingys changes (and modified that 1 section of code that loads PRAM/PROM/ROM)
Changes:
M/trunk/CREDITS
M/trunk/i386/libsaio/nvidia.c

File differences

trunk/i386/libsaio/nvidia.c
7171
7272
7373
74
75
76
77
78
7479
7580
7681
......
872877
873878
874879
875
876
877
878
879880
880
881
882
883881
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914882
915883
916884
......
918886
919887
920888
921
889
922890
923891
924892
......
943911
944912
945913
946
914
947915
948916
949917
950
918
951919
952920
953921
......
991959
992960
993961
994
962
995963
996964
997965
......
11721140
11731141
11741142
1143
11751144
11761145
11771146
......
12741243
12751244
12761245
1246
1247
1248
1249
12771250
12781251
12791252
......
13071280
13081281
13091282
1310
1311
1312
1313
1283
1284
1285
1286
13141287
13151288
13161289
......
13371310
13381311
13391312
1340
1341
1342
1343
1344
1345
1346
1347
1313
1314
1315
1316
1317
1318
1319
13481320
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
13621340
13631341
13641342
13651343
1366
1344
13671345
13681346
13691347
13701348
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
13861359
13871360
13881361
#define PATCH_ROM_FAILED0
#define MAX_NUM_DCB_ENTRIES16
#define TYPE_GROUPED0xff
#define READ_BYTE(rom, offset) (*(u_char *)(rom + offset))
#define READ_LE_SHORT(rom, offset) (READ_BYTE(rom, offset+1) << 8 | READ_BYTE(rom, offset))
#define READ_LE_INT(rom, offset) (READ_LE_SHORT(rom, offset+2) << 16 | READ_LE_SHORT(rom, offset))
#define WRITE_LE_SHORT(data) (((data) << 8 & 0xff00) | ((data) >> 8 & 0x00ff ))
#define WRITE_LE_INT(data) (WRITE_LE_SHORT(data) << 16 | WRITE_LE_SHORT(data >> 16))
extern uint32_t devices_number;
{ 0x10DE1251, "GeForce GTX 560M" },
};
static uint16_t swap16(uint16_t x)
{
return (((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8));
}
static uint16_t read16(uint8_t *ptr, uint16_t offset)
{
uint8_t ret[2];
ret[0] = ptr[offset+1];
ret[1] = ptr[offset];
return *((uint16_t*)&ret);
}
#if 0
static uint32_t swap32(uint32_t x)
{
return ((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8 ) | ((x & 0x00FF0000) >> 8 ) | ((x & 0xFF000000) >> 24);
}
static uint8_tread8(uint8_t *ptr, uint16_t offset)
{
return ptr[offset];
}
static uint32_t read32(uint8_t *ptr, uint16_t offset)
{
uint8_t ret[4];
ret[0] = ptr[offset+3];
ret[1] = ptr[offset+2];
ret[2] = ptr[offset+1];
ret[3] = ptr[offset];
return *((uint32_t*)&ret);
}
#endif
static int patch_nvidia_rom(uint8_t *rom)
{
if (!rom || (rom[0] != 0x55 && rom[1] != 0xaa)) {
return PATCH_ROM_FAILED;
}
uint16_t dcbptr = swap16(read16(rom, 0x36));
uint16_t dcbptr = READ_LE_SHORT(rom, 0x36);
if (!dcbptr) {
printf("no dcb table found\n");
numentries = dcbtable[2];
recordlength = dcbtable[3];
sig = *(uint32_t *)&dcbtable[6];
sig = READ_LE_INT(dcbtable, 6);
}
else
{
sig = *(uint32_t *)&dcbtable[4];
sig = READ_LE_INT(dcbtable, 4);
headerlength = 8;
}
for (i = 0; i < numentries; i++)
{
uint32_t connection;
connection = *(uint32_t *)&dcbtable[headerlength + recordlength * i];
connection = READ_LE_INT(dcbtable,headerlength + recordlength * i);
/* Should we allow discontinuous DCBs? Certainly DCB I2C tables can be discontinuous */
if ((connection & 0x0000000f) == 0x0000000f) /* end of records */
return size > 0 ? size : 0;
}
static int devprop_add_nvidia_template(struct DevPropDevice *device)
{
char tmp[16];
return vram_size;
}
static bool checkNvRomSig(uint8_t * aRom){
return aRom != NULL && (aRom[0] == 0x55 && aRom[1] == 0xaa);
}
bool setup_nvidia_devprop(pci_dt_t *nvda_dev)
{
struct DevPropDevice*device;
videoRam = mem_detect(regs, nvCardType, nvda_dev);
model = get_nvidia_model((nvda_dev->vendor_id << 16) | nvda_dev->device_id);
verbose("nVidia %s %dMB NV%02x [%04x:%04x] :: %s\n",
model, (uint32_t)(videoRam / 1024 / 1024),
(REG32(0) >> 20) & 0x1ff, nvda_dev->vendor_id, nvda_dev->device_id,
devicepath);
verbose("nVidia %s %dMB NV%02x [%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,
devicepath, devices_number);
rom = malloc(NVIDIA_ROM_SIZE);
sprintf(nvFilename, "/Extra/%04x_%04x.rom", (uint16_t)nvda_dev->vendor_id,
// Otherwise read bios from card
nvBiosOveride = 0;
// TODO: we should really check for the signature before copying the rom, i think.
// PRAMIN first
nvRom = (uint8_t*)&regs[NV_PRAMIN_OFFSET];
bcopy((uint32_t *)nvRom, rom, NVIDIA_ROM_SIZE);
// Valid Signature ?
if (rom[0] != 0x55 && rom[1] != 0xaa)
// PROM first
// Enable PROM access
(REG32(NV_PBUS_PCI_NV_20)) = NV_PBUS_PCI_NV_20_ROM_SHADOW_DISABLED;
nvRom = (uint8_t*)&regs[NV_PROM_OFFSET];
// Valid Signature ?
if (checkNvRomSig(nvRom))
{
// PROM next
// Enable PROM access
(REG32(NV_PBUS_PCI_NV_20)) = NV_PBUS_PCI_NV_20_ROM_SHADOW_DISABLED;
nvRom = (uint8_t*)&regs[NV_PROM_OFFSET];
bcopy((uint8_t *)nvRom, rom, NVIDIA_ROM_SIZE);
// disable PROM access
(REG32(NV_PBUS_PCI_NV_20)) = NV_PBUS_PCI_NV_20_ROM_SHADOW_ENABLED;
// Valid Signature ?
if (rom[0] != 0x55 && rom[1] != 0xaa)
{
bcopy((uint8_t *)nvRom, rom, NVIDIA_ROM_SIZE);
DBG("PROM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
}
else
{
// disable PROM access
(REG32(NV_PBUS_PCI_NV_20)) = NV_PBUS_PCI_NV_20_ROM_SHADOW_ENABLED;
//PRAM next
nvRom = (uint8_t*)&regs[NV_PRAMIN_OFFSET];
if(checkNvRomSig(nvRom))
{
bcopy((uint32_t *)nvRom, rom, NVIDIA_ROM_SIZE);
DBG("PRAM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
}
else
{
// 0xC0000 last
bcopy((char *)0xc0000, rom, NVIDIA_ROM_SIZE);
// Valid Signature ?
if (rom[0] != 0x55 && rom[1] != 0xaa)
if (!checkNvRomSig(rom))
{
printf("ERROR: Unable to locate nVidia Video BIOS\n");
return false;
}
else
{
DBG("ROM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
}
}
else
{
DBG("PROM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
}
}
else
{
DBG("PRAM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
}
}
else
{
DBG("ROM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
}
}//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");
trunk/CREDITS
33
44
55
6
6
77
88
99
Developers:
----------
zef, Turbo, dfe, netkas, mackerintel, mercurysquad, fassl, Kabyl, Crazor, Dense, Turbo, kaitek, iNDi, munky, JrCs, asereBLN, rekursor, mozodojo, meklort, AnV, valv, AzimutZ, Slice, cosmo1t, cparm, Conti
zef, Turbo, dfe, netkas, mackerintel, mercurysquad, fassl, Kabyl, Crazor, Dense, kaitek, iNDi, munky, JrCs, asereBLN, rekursor, mozodojo, meklort, AnV, valv, AzimutZ, Slice, cosmo1t, cparm, Conti
Thanks to:
---------

Archive Download the corresponding diff file

Revision: 1945