Chameleon

Chameleon Commit Details

Date:2012-05-08 23:34:26 (11 years 11 months ago)
Author:ErmaC
Commit:1953
Parents: 1952
Message:sync with trunk
Changes:
M/branches/ErmaC/Trunk/i386/libsaio/cpu.c
M/branches/ErmaC/Trunk/i386/libsaio/nvidia.c
M/branches/ErmaC/Trunk/i386/boot2/boot.h
M/branches/ErmaC/Trunk/i386/libsaio/cpu.h
M/branches/ErmaC/Trunk/i386/libsaio/smbios.c
M/branches/ErmaC/Trunk/CREDITS
M/branches/ErmaC/Trunk/doc/BootHelp.txt
M/branches/ErmaC/Trunk/i386/libsaio/saio_types.h

File differences

branches/ErmaC/Trunk/i386/libsaio/nvidia.c
7171
7272
7373
74
75
76
77
78
7479
7580
7681
......
10981103
10991104
11001105
1106
11011107
11021108
1103
1104
1105
1106
1107
11081109
11091110
11101111
......
11871188
11881189
11891190
1191
11901192
11911193
11921194
......
14731475
14741476
14751477
1478
1479
1480
1481
14761482
14771483
14781484
......
15371543
15381544
15391545
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1546
1547
1548
1549
1550
1551
1552
15561553
1557
1558
1559
1554
1555
1556
1557
1558
15601559
1561
1562
1563
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
15641573
15651574
15661575
15671576
1568
1577
15691578
15701579
15711580
15721581
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
15881592
15891593
15901594
......
17231727
17241728
17251729
1726
1727
1728
17291730
17301731
17311732
1732
1733
1734
1735
1736
1737
1733
17381734
17391735
17401736
17411737
17421738
1739
1740
1741
1742
1743
1744
1745
1746
1747
17431748
17441749
17451750
#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;
// 12D0 - 12DF
// 12E0 - 12EF
// 12F0 - 12FF
};
#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))
static int patch_nvidia_rom(uint8_t *rom)
{
{
uint32_t connection;
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 */
continue;
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;
// Otherwise read bios from card
nvBiosOveride = 0;
// TODO: we should really check for the signature before copying the rom, i think.
// PRAMIN first
// 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)
// 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))
{
// PRAMIN first
nvRom = (uint8_t*)&regs[NV_PRAMIN_OFFSET];
bcopy((uint32_t *)nvRom, rom, NVIDIA_ROM_SIZE);
bcopy((uint8_t *)nvRom, rom, NVIDIA_ROM_SIZE);
DBG("PROM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
}
else
{
// Valid Signature ?
if (rom[0] != 0x55 && rom[1] != 0xaa)
{
// 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");
devprop_add_value(device, "VRAM,totalsize", (uint8_t*)&videoRam, 4);
devprop_add_value(device, "model", (uint8_t*)model, strlen(model) + 1);
devprop_add_value(device, "rom-revision", (uint8_t*)biosVersion, strlen(biosVersion) + 1);
//devprop_add_value(device, "@1,connector-type", connector_type_1, 4); // fixme
//devprop_add_value(device, "@0,display-cfg", display_cfg_0, 4);
//devprop_add_value(device, "@1,display-cfg", display_cfg_1, 4);
devprop_add_value(device, "@0,display-cfg", default_dcfg_0, DCFG0_LEN);
devprop_add_value(device, "@1,display-cfg", default_dcfg_1, DCFG1_LEN);
//add HDMI Audio back to nvidia
//http://forge.voodooprojects.org/p/chameleon/issues/67/
//uint8_t connector_type_1[]= {0x00, 0x08, 0x00, 0x00};
//devprop_add_value(device, "@1,connector-type",connector_type_1, 4);
//end Nvidia HDMI Audio
if (getBoolForKey(kVBIOS, &doit, &bootInfo->chameleonConfig) && doit)
{
devprop_add_value(device, "vbios", rom, (nvBiosOveride > 0) ? nvBiosOveride : (rom[2] * 512));
}
//add HDMI Audio back to nvidia
doit = false;
//http://forge.voodooprojects.org/p/chameleon/issues/67/
if(getBoolForKey(kEnableHDMIAudio, &doit, &bootInfo->chameleonConfig) && doit){
uint8_t connector_type_1[]= {0x00, 0x08, 0x00, 0x00};
devprop_add_value(device, "@1,connector-type",connector_type_1, 4);
}
//end Nvidia HDMI Audio
stringdata = malloc(sizeof(uint8_t) * string->length);
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
branches/ErmaC/Trunk/i386/libsaio/cpu.c
5050
5151
5252
53
54
55
53
5654
5755
5856
......
8886
8987
9088
91
9289
9390
9491
95
9692
9793
9894
......
355351
356352
357353
358
359
354
355
360356
361
362
357
363358
364
365
366
367359
368360
369361
......
564556
565557
566558
567
568
569
570559
571560
572561
ROUND64(SAMPLE_MULTIPLIER/(double)(SAMPLE_CLKS_INT-4)),
ROUND64(SAMPLE_MULTIPLIER/(double)(SAMPLE_CLKS_INT-5))
};
//int_enabled = ml_set_interrupts_enabled(FALSE);
restart:
if (attempts >= 9) // increase to up to 9 attempts.
// This will flash-reboot. TODO: Use tscPanic instead.
set_PIT2(0);// reset timer 2 to be zero
disable_PIT2();// turn off PIT 2
//ml_set_interrupts_enabled(int_enabled);
return intermediate;
}
/*
* DFE: Measures the TSC frequency in Hz (64-bit) using the ACPI PM timer
*/
}
tscFrequency = measure_tsc_frequency();
DBG("cpu freq classic = 0x%016llx\n", tscFrequency);
if ( tscFrequency < 1000 )//TEST
/* if usual method failed */
if ( tscFrequency < 1000 )
{
tscFrequency = timeRDTSC() * 20;//measure_tsc_frequency();
// DBG("cpu freq timeRDTSC = 0x%016llx\n", tscFrequency);
tscFrequency = timeRDTSC() * 20;
}
else{
// DBG("cpu freq timeRDTSC = 0x%016llxn", timeRDTSC() * 20);
}
fsbFrequency = 0;
cpuFrequency = 0;
cpuFrequency = tscFrequency;
DBG("0 ! using the default value for FSB !\n");
}
DBG("cpu freq = 0x%016llxn", timeRDTSC() * 20);
#endif
p->CPU.MaxCoef = maxcoef;
branches/ErmaC/Trunk/i386/libsaio/cpu.h
109109
110110
111111
112
113
112
114113
115114
116115
......
121120
122121
123122
124
125
123
126124
127125
128126
......
231229
232230
233231
234
235
236232
* bit 0 gates the clock,
* bit 1 gates output to speaker.
*/
inline static void
enable_PIT2(void)
static inline void enable_PIT2(void)
{
/* Enable gate, disable speaker */
__asm__ volatile(
: : : "%al" );
}
inline static void
disable_PIT2(void)
static inline void disable_PIT2(void)
{
/* Disable gate and output to speaker */
__asm__ volatile(
return result;
}
#endif /* !__LIBSAIO_CPU_H */
branches/ErmaC/Trunk/i386/libsaio/smbios.c
335335
336336
337337
338
339
338
339
340
340341
341342
342343
......
350351
351352
352353
353
354354
355355
356356
defaultSystemInfo.family= kDefaultiMacFamily;
break;
case CPU_MODEL_SANDYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPU_MODEL_IVYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (22nm)
case CPU_MODEL_SANDYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPU_MODEL_JAKETOWN:// Intel Core i7, Xeon E5 LGA2011 (32nm)
case CPU_MODEL_IVYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (22nm)
defaultBIOSInfo.version= kDefaultiMacSandyBIOSVersion;
defaultSystemInfo.productName= kDefaultiMacSandy;
defaultSystemInfo.family= kDefaultiMacFamily;
case CPU_MODEL_WESTMERE:// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core
case CPU_MODEL_WESTMERE_EX:// Intel Xeon E7
case CPU_MODEL_JAKETOWN:// Intel Core i7, Xeon E5 LGA2011 (32nm)
defaultBIOSInfo.version= kDefaultMacProWestmereBIOSVersion;
defaultBIOSInfo.releaseDate= kDefaultMacProWestmereBIOSReleaseDate;
defaultSystemInfo.productName= kDefaultMacProWestmere;
branches/ErmaC/Trunk/i386/libsaio/saio_types.h
6464
6565
6666
67
67
6868
6969
7070
typedef struct Tag Tag, *TagPtr;
typedef struct {
charplist[4096];// buffer for plist
charplist[163840];// buffer for plist
TagPtrdictionary;// buffer for xml dictionary
boolcanOverride;// flag to mark a dictionary can be overriden
} config_file_t;
branches/ErmaC/Trunk/i386/boot2/boot.h
113113
114114
115115
116
117116
118117
119118
120119
121120
121
122122
123123
124124
#define kUseNvidiaROM"UseNvidiaROM"/* nvidia.c */
#define kVBIOS"VBIOS"/* nvidia.c */
#define kHDMI"HDMI"/* nvidia.c */
#define kDcfg0"display_0"/* nvidia.c */
#define kDcfg1"display_1"/* nvidia.c */
#define kEthernetBuiltIn"EthernetBuiltIn"/* pci_setup.c */
#define kGraphicsEnabler"GraphicsEnabler"/* pci_setup.c */
#define kEnableHDMIAudio"EnableHDMIAudio"/*ati.c && nvidia.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kMD0Image"md0"/* ramdisk.h */
branches/ErmaC/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
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:
---------
branches/ErmaC/Trunk/doc/BootHelp.txt
8585
8686
8787
88
8889
8990
9091
VBIOS=Yes|No Inject NVIDIA VBIOS into device-properties.
display_0=<value> Inject alternate value of display-cfg into NVDA,Display-A@0 (HEX).
display_1=<value> Inject alternate value of display-cfg into NVDA,Display-B@1 (HEX).
EnableHDMIAudio=Yes Inject HDMI audio for NVIDIA
EthernetBuiltIn=Yes|No Automatic "built-in"=yes device-properties generation
for ethernet interfaces.

Archive Download the corresponding diff file

Revision: 1953