Chameleon

Chameleon Commit Details

Date:2015-02-12 22:25:29 (9 years 1 month ago)
Author:ErmaC
Commit:2573
Parents: 2572
Message:Typo.
Changes:
M/trunk/i386/boot2/drivers.c
M/trunk/i386/libsaio/cpu.c
M/trunk/i386/boot2/modules.c
M/trunk/i386/libsaio/pci_setup.c
M/trunk/i386/modules/Resolution/915resolution.c
M/trunk/i386/util/dyldsymboltool.c
M/trunk/i386/boot2/options.c
M/trunk/i386/modules/Resolution/edid.c
M/trunk/i386/libsaio/smbios_decode.c
M/trunk/i386/boot2/modules.h
M/trunk/i386/libsaio/hpet.c
M/trunk/i386/libsaio/pci.h
M/trunk/i386/modules/Resolution/915resolution.h

File differences

trunk/i386/libsaio/cpu.c
124124
125125
126126
127
127
128
128129
129130
130131
131132
132133
133134
134
135
136
135137
136138
137139
138
140
141
139142
140143
141144
......
152155
153156
154157
155
158
159
156160
157
161
162
163
158164
159165
160166
......
236242
237243
238244
239
240
241
242
243
245
246
247
248
249
244250
245
246
251
252
247253
248254
249
250
251
252
253
254
255
256
257
258
259
260
255261
256262
257263
258264
259
260
265
266
261267
262268
263269
......
521527
522528
523529
524
525
526
527
528
529
530
531
530
531
532
533
534
535
536
537
532538
533539
534
540
535541
536542
537
543
538544
539545
540546
......
592598
593599
594600
595
601
596602
597603
598604
......
606612
607613
608614
609
615
610616
611
617
612618
613619
614620
......
619625
620626
621627
622
623
628
629
624630
625631
626632
......
753759
754760
755761
762
756763
757
758764
759765
760766
pollCount = poll_PIT2_gate();
tscEnd = rdtsc64();
/* The poll loop must have run at least a few times for accuracy */
if (pollCount <= 1) {
if (pollCount <= 1)
{
continue;
}
/* The TSC must increment at LEAST once every millisecond.
* We should have waited exactly 30 msec so the TSC delta should
* be >= 30. Anything less and the processor is way too slow.
*/
if ((tscEnd - tscStart) <= CALIBRATE_TIME_MSEC) {
if ((tscEnd - tscStart) <= CALIBRATE_TIME_MSEC)
{
continue;
}
// tscDelta = MIN(tscDelta, (tscEnd - tscStart))
if ( (tscEnd - tscStart) < tscDelta ) {
if ( (tscEnd - tscStart) < tscDelta )
{
tscDelta = tscEnd - tscStart;
}
}
* arithmetic headroom. For now, 32-bit should be enough.
* Also unlike Linux, our compiler can do 64-bit integer arithmetic.
*/
if (tscDelta > (1ULL<<32)) {
if (tscDelta > (1ULL<<32))
{
retval = 0;
} else {
}
else
{
retval = tscDelta * 1000 / 30;
}
disable_PIT2();
*/
void scan_cpu(PlatformInfo_t *p)
{
uint64_ttscFrequency= 0;
uint64_tfsbFrequency= 0;
uint64_tcpuFrequency= 0;
uint64_tmsr= 0;
uint64_tflex_ratio= 0;
uint64_ttscFrequency= 0;
uint64_tfsbFrequency= 0;
uint64_tcpuFrequency= 0;
uint64_tmsr= 0;
uint64_tflex_ratio= 0;
uint32_tmax_ratio= 0;
uint32_tmin_ratio= 0;
uint32_tmax_ratio= 0;
uint32_tmin_ratio= 0;
uint32_treg[4];
uint8_tbus_ratio_max= 0;
uint8_tbus_ratio_min= 0;
uint8_tcurrdiv= 0;
uint8_tcurrcoef= 0;
uint8_tmaxdiv= 0;
uint8_tmaxcoef= 0;
uint8_tbus_ratio_max= 0;
uint8_tbus_ratio_min= 0;
uint8_tcurrdiv= 0;
uint8_tcurrcoef= 0;
uint8_tmaxdiv= 0;
uint8_tmaxcoef= 0;
const char*newratio;
charstr[128];
intlen = 0;
intmyfsb = 0;
intlen= 0;
intmyfsb= 0;
/* get cpuid values */
do_cpuid(0x00000000, p->CPU.CPUID[CPUID_0]);
if (bitfield(msr, 16, 16))
{
flex_ratio = bitfield(msr, 15, 8);
/* bcc9: at least on the gigabyte h67ma-ud2h,
where the cpu multipler can't be changed to
allow overclocking, the flex_ratio msr has unexpected (to OSX)
contents.These contents cause mach_kernel to
fail to compute the bus ratio correctly, instead
causing the system to crash since tscGranularity
is inadvertently set to 0.
*/
// bcc9: at least on the gigabyte h67ma-ud2h,
// where the cpu multipler can't be changed to
// allow overclocking, the flex_ratio msr has unexpected (to OSX)
// contents.These contents cause mach_kernel to
// fail to compute the bus ratio correctly, instead
// causing the system to crash since tscGranularity
// is inadvertently set to 0.
if (flex_ratio == 0)
{
/* Clear bit 16 (evidently the presence bit) */
// Clear bit 16 (evidently the presence bit)
wrmsr64(MSR_FLEX_RATIO, (msr & 0xFFFFFFFFFFFEFFFFULL));
msr = rdmsr64(MSR_FLEX_RATIO);
DBG("Unusable flex ratio detected. Patched MSR now %08x\n", bitfield(msr, 31, 0));
DBG("CPU: Unusable flex ratio detected. Patched MSR now %08x\n", bitfield(msr, 31, 0));
}
else
{
}
}
//valv: to be uncommented if Remarq.1 didn't stick
/*if (bus_ratio_max > 0) bus_ratio = flex_ratio;*/
//if (bus_ratio_max > 0) bus_ratio = flex_ratio;
p->CPU.MaxRatio = max_ratio;
p->CPU.MinRatio = min_ratio;
msr = rdmsr64(MSR_IA32_PERF_STATUS);
DBG("msr(%d): ia32_perf_stat 0x%08x\n", __LINE__, bitfield(msr, 31, 0));
currcoef = bitfield(msr, 12, 8); // Bungo: reverted to 2263 state because of wrong old CPUs freq. calculating
/* Non-integer bus ratio for the max-multi*/
// Non-integer bus ratio for the max-multi
maxdiv = bitfield(msr, 46, 46);
/* Non-integer bus ratio for the current-multi (undocumented)*/
// Non-integer bus ratio for the current-multi (undocumented)
currdiv = bitfield(msr, 14, 14);
// This will always be model >= 3
}
else
{
/* On lower models, currcoef defines TSC freq */
/* XXX */
// On lower models, currcoef defines TSC freq
// XXX
maxcoef = currcoef;
}
if (!fsbFrequency)
{
fsbFrequency = (DEFAULT_FSB * 1000);
DBG("CPU: fsbFrequency = 0! using the default value for FSB!\n");
cpuFrequency = tscFrequency;
DBG("0 ! using the default value for FSB !\n");
}
DBG("cpu freq = 0x%016llxn", timeRDTSC() * 20);
trunk/i386/libsaio/pci_setup.c
4444
4545
4646
47
47
4848
4949
5050
}
break;
case PCI_CLASS_NETWORK_ETHERNET:
case PCI_CLASS_NETWORK_ETHERNET:
if (do_eth_devprop)
{
set_eth_builtin(current);
trunk/i386/libsaio/smbios_decode.c
192192
193193
194194
195
196
195
197196
198197
199198
......
220219
221220
222221
223
222
223
224224
225225
226226
......
240240
241241
242242
243
243
244244
245245
246246
......
534534
535535
536536
537
538
539
537540
538541
539542
/*=====
7.18.2
====*/
static const char *
SMBMemoryDeviceTypes[] =
static const char *SMBMemoryDeviceTypes[] =
{
"RAM", /* 00h Undefined */
"RAM", /* 01h Other */
"RAM",/* 16h unused */
"RAM",/* 17h unused */
"DDR3",/* 18h DDR3, chosen in [5776134] */
"FBD2"/* 19h FBD2 */
"FBD2",/* 19h FBD2 */
"DDR4"/* 1Ah DDR4 */
};
static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) / sizeof(SMBMemoryDeviceTypes[0]);
}
return str;
};
}
void printHeader(SMBStructHeader *structHeader)
{
DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->partNumber, neverMask));
// Rank:
// Configured Clock Speed:
// Minimum Voltage:
// Maximum Voltage:
// Configured Voltage:
DBG("\n");
}
trunk/i386/libsaio/hpet.c
6868
6969
7070
71
7172
73
7274
7375
7476
......
9193
9294
9395
96
9497
98
9599
96100
97101
lpc_controllers[i].name, lpc_dev->vendor_id, lpc_dev->device_id, rcba);
if (rcba == 0)
{
printf(" RCBA disabled; cannot force enable HPET\n");
}
else
{
val = REG32(rcba, 0x3404);
// verify if the job is done
val = REG32(rcba, 0x3404);
if (!(val & 0x80))
{
printf(" Failed to force enable HPET\n");
}
}
break;
}
trunk/i386/libsaio/pci.h
201201
202202
203203
204
205
204
205
206206
207207
208208
......
211211
212212
213213
214
214
215215
216216
217217
#define PCI_BASE_ADDRESS_MEM_TYPE_1M0x02/* Below 1M [obsolete] */
#define PCI_BASE_ADDRESS_MEM_TYPE_640x04/* 64 bit address */
#define PCI_BASE_ADDRESS_MEM_PREFETCH0x08/* prefetchable? */
#define PCI_BASE_ADDRESS_MEM_MASK(~(pciaddr_t)0x0f)
#define PCI_BASE_ADDRESS_IO_MASK(~(pciaddr_t)0x03)
#define PCI_BASE_ADDRESS_MEM_MASK(~(uint32_t)0x0f)
#define PCI_BASE_ADDRESS_IO_MASK(~(uint32_t)0x03)
/* bit 1 is reserved if address_space = 1 */
/* Header type 0 (normal devices) */
#define PCI_SUBSYSTEM_ID0x2e
#define PCI_ROM_ADDRESS0x30/* Bits 31..11 are address, 10..1 reserved */
#define PCI_ROM_ADDRESS_ENABLE0x01
#define PCI_ROM_ADDRESS_MASK(~(pciaddr_t)0x7ff)
#define PCI_ROM_ADDRESS_MASK(~(uint32_t)0x7ff)
#define PCI_CAPABILITY_LIST0x34/* Offset of first capability list entry */
trunk/i386/boot2/drivers.c
159159
160160
161161
162
162
163
163164
164165
165166
......
499500
500501
501502
502
503
504
503505
504
506
507
508
505509
506510
507511
......
512516
513517
514518
515
519
520
516521
517
522
523
524
518525
519526
520527
521528
522529
523
530
531
524532
525533
526534
......
528536
529537
530538
531
539
540
532541
533
542
543
544
534545
535546
536547
537548
538
549
550
539551
540552
541553
542554
543
555
556
544557
545558
546559
......
566579
567580
568581
569
582
583
570584
571585
572586
gTempSpec = malloc( 4096 );
gFileName = malloc( 4096 );
if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName ) {
if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName )
{
stop("InitDriverSupport error");
}
do{
// Save the driver path.
if(name) {
if(name)
{
snprintf(gFileSpec, 4096, "%s/%s/%s", dirSpec, name, (bundleType == kCFBundleType2) ? "Contents/MacOS/" : "");
} else {
}
else
{
snprintf(gFileSpec, 4096, "%s/%s", dirSpec, (bundleType == kCFBundleType2) ? "Contents/MacOS/" : "");
}
executablePathLength = strlen(gFileSpec) + 1;
}
strcpy(tmpExecutablePath, gFileSpec);
if(name) {
if(name)
{
snprintf(gFileSpec, 4096, "%s/%s", dirSpec, name);
} else {
}
else
{
snprintf(gFileSpec, 4096, "%s", dirSpec);
}
bundlePathLength = strlen(gFileSpec) + 1;
tmpBundlePath = malloc(bundlePathLength);
if (tmpBundlePath == 0) {
if (tmpBundlePath == 0)
{
break;
}
// Construct the file spec to the plist, then load it.
if(name) {
if(name)
{
snprintf(gFileSpec, 4096, "%s/%s/%sInfo.plist", dirSpec, name, (bundleType == kCFBundleType2) ? "Contents/" : "");
} else {
}
else
{
snprintf(gFileSpec, 4096, "%s/%sInfo.plist", dirSpec, (bundleType == kCFBundleType2) ? "Contents/" : "");
}
length = LoadFile(gFileSpec);
if (length == -1) {
if (length == -1)
{
break;
}
length = length + 1;
buffer = malloc(length);
if (buffer == 0) {
if (buffer == 0)
{
break;
}
strlcpy(buffer, (char *)kLoadAddr, length);
module->bundlePathLength = bundlePathLength;
module->plistAddr = malloc(length);
if ((module->executablePath == 0) || (module->bundlePath == 0) || (module->plistAddr == 0)) {
if ((module->executablePath == 0) || (module->bundlePath == 0) || (module->plistAddr == 0))
{
break;
}
trunk/i386/boot2/modules.c
11
2
2
33
44
55
......
3333
3434
3535
36
37
38
36
37
38
3939
4040
4141
......
142142
143143
144144
145
146
147
145
146
147
148148
149149
150150
/*
* Copyright 2010 Evan Lojewski. All rights reserved.
* Copyright 2010-2015 Evan Lojewski. All rights reserved.
*
*/
#include "boot.h"
static UInt64 textSection = 0;
/** Internal symbols, however there are accessor methods **/
moduleHook_t* moduleCallbacks = NULL;
moduleList_t* loadedModules = NULL;
symbolList_t* moduleSymbols = NULL;
moduleHook_t *moduleCallbacks = NULL;
moduleList_t *loadedModules = NULL;
symbolList_t *moduleSymbols = NULL;
unsigned int (*lookup_symbol)(const char*) = NULL;
char *strrchr(const char *s, int c)
return retVal;
}
void start_built_in_module(const char* name,
const char* author,
const char* description,
void start_built_in_module(const char *name,
const char *author,
const char *description,
UInt32 version,
UInt32 compat,
void(*start_function)(void))
trunk/i386/boot2/modules.h
11
22
3
3
44
55
66
......
1414
1515
1616
17
18
19
20
21
17
18
19
20
21
2222
2323
2424
......
2626
2727
2828
29
30
31
29
30
31
3232
3333
3434
......
4646
4747
4848
49
50
51
52
53
54
49
50
51
52
53
54
5555
5656
5757
......
5959
6060
6161
62
63
64
65
66
62
63
64
65
66
6767
6868
6969
/*
* Module Loading functionality
* Copyright 2009 Evan Lojewski. All rights reserved.
* Copyright 2009-2015 Evan Lojewski. All rights reserved.
*
*/
#define MODULE_PATH"/Extra/modules/"
#define SYMBOLS_MODULE "Symbols.dylib"
#define SYMBOLS_AUTHOR "Chameleon"
#define SYMBOLS_DESCRIPTION "Chameleon symbols for linking"
#define SYMBOLS_VERSION 0
#define SYMBOLS_COMPAT 0
#define SYMBOLS_MODULE"Symbols.dylib"
#define SYMBOLS_AUTHOR"Chameleon"
#define SYMBOLS_DESCRIPTION"Chameleon symbols for linking"
#define SYMBOLS_VERSION0
#define SYMBOLS_COMPAT0
#define VOID_SYMBOL"dyld_void_start"
typedef struct symbolList_t
{
char* symbol;
UInt64 addr;
struct symbolList_t* next;
char*symbol;
UInt64addr;
struct symbolList_t*next;
} symbolList_t;
typedef struct callbackList_t
typedef struct modulesList_t
{
const char*name;
const char* author;
const char* description;
UInt32version;
UInt32compat;
struct modulesList_t* next;
const char*name;
const char*author;
const char*description;
UInt32version;
UInt32compat;
struct modulesList_t*next;
} moduleList_t;
int init_module_system();
void load_all_modules();
void start_built_in_module(const char* name,
const char* author,
const char* description,
UInt32 version,
UInt32 compat,
void start_built_in_module(const char*name,
const char*author,
const char*description,
UInt32version,
UInt32compat,
void(*start_function)(void));
int load_module(char* module);
trunk/i386/boot2/options.c
11041104
11051105
11061106
1107
1108
1107
1108
1109
1110
11091111
11101112
11111113
......
11211123
11221124
11231125
1124
1126
1127
11251128
11261129
11271130
......
11301133
11311134
11321135
1133
1136
1137
1138
11341139
11351140
11361141
......
15181523
15191524
15201525
1521
1526
15221527
15231528
15241529
// New behavior:
// Switch between text & graphic interfaces
// Only Permitted if started in graphics interface
if (useGUI) {
if (bootArgs->Video.v_display != VGA_TEXT_MODE) {
if (useGUI)
{
if (bootArgs->Video.v_display != VGA_TEXT_MODE)
{
setVideoMode(VGA_TEXT_MODE, 0);
setCursorPosition(0, 0, 0);
nextRow = kMenuTopRow;
showPrompt = true;
if (gDeviceCount) {
if (gDeviceCount)
{
printf("Use \30\31 keys to select the startup volume.");
showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);
nextRow += MIN(gDeviceCount, kMenuMaxItems) + 3;
showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
showBootPrompt(nextRow, showPrompt);
//changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );
} else {
}
else
{
gui.redraw = true;
setVideoMode(GRAPHICS_MODE, 0);
updateVRAM();
void showTextBuffer(char *buf_orig, int size)
{
char*bp;
char* buf;
char*buf;
intline;
intline_offset;
intc;
trunk/i386/modules/Resolution/915resolution.c
1717
1818
1919
20
20
2121
2222
2323
2424
2525
26
27
28
26
2927
3028
3129
......
3331
3432
3533
36
34
3735
38
36
3937
40
38
4139
4240
4341
......
190188
191189
192190
193
191
194192
195193
196194
......
199197
200198
201199
202
203200
204201
205202
......
215212
216213
217214
215
218216
219217
220218
......
236234
237235
238236
237
239238
240239
241240
......
256255
257256
258257
259
260
258
259
261260
262261
263262
......
275274
276275
277276
277
278
279
280
278281
279282
280283
......
336339
337340
338341
339
340
341
342
343
344
345
346
347
348
342349
343350
344351
345352
346353
347
354
355
348356
349357
350358
......
365373
366374
367375
368
376
369377
370378
371379
......
400408
401409
402410
403
411
404412
405413
406414
407
415
408416
409417
410
418
411419
412
420
413421
414
422
415423
416424
417425
418
426
419427
420428
421429
422430
423
424
425431
426432
427433
......
443449
444450
445451
446
447
452
453
448454
449455
450456
......
503509
504510
505511
506
512
507513
508514
509515
......
557563
558564
559565
566
567
560568
561569
562570
......
614622
615623
616624
625
617626
618627
619628
......
647656
648657
649658
650
659
651660
652661
653662
......
666675
667676
668677
669
678
670679
671680
672681
......
694703
695704
696705
697
698
706
707
708
699709
700710
701711
......
704714
705715
706716
717
707718
708
719
709720
721
710722
711
723
712724
713725
714726
715727
716728
717729
718
719
730
731
720732
721733
722734
723735
724736
725737
726
727
728
738
739
740
741
729742
730743
731744
......
733746
734747
735748
736
749
750
751
737752
753
738754
739
755
740756
741
757
758
759
742760
761
743762
763
744764
745765
746766
......
753773
754774
755775
756
776
777
757778
758779
759
760
761
780
781
782
783
762784
763785
764786
765787
766788
767789
768
790
791
792
769793
794
770795
796
771797
772
798
799
800
773801
802
774803
775
776
777
804
805
806
778807
779808
780809
......
787816
788817
789818
790
791
819
820
821
792822
793823
794824
......
801831
802832
803833
804
834
835
836
805837
806838
807839
......
825857
826858
827859
828
860
829861
830862
831863
......
836868
837869
838870
839
871
872
840873
841874
842875
......
849882
850883
851884
852
885
886
887
853888
854889
855890
......
862897
863898
864899
865
866
867
868
869
870
871
872
873
874
875
876
877
900
901
902
903
904
905
906
907
908
909
910
911
878912
879913
880914
881915
882916
883917
884
885918
886919
887920
888
921
922
889923
890924
891925
......
898932
899933
900934
901
935
936
937
902938
903939
904940
905941
906942
907
908943
909944
910945
911946
912
947
913948
914949
915950
916951
917
952
918953
919954
920955
921956
922
957
923958
924959
925960
......
929964
930965
931966
967
968
932969
933970
934971
935972
936973
937
974
void patchVideoBios()
{
{
UInt32 x = 0, y = 0, bp = 0;
verbose("Resolution:\n");
getResolution(&x, &y, &bp);
if (x != 0 &&
y != 0 &&
bp != 0)
if (x != 0 && y != 0 && bp != 0)
{
vbios_map * map;
if(map)
{
unlock_vbios(map);
set_mode(map, x, y, bp, 0, 0);
relock_vbios(map);
close_vbios(map);
}
}
case 0x01048086: // 2nd Generation Core Processor Family DRAM Controller
case 0x01088086: // Xeon E3-1200 2nd Generation Core Processor Family DRAM Controller
case 0x010c8086: // Xeon E3-1200 2nd Generation Core Processor Family DRAM Controller
case 0x01508086: // 3rd Generation Core Processor Family DRAM Controller
case 0x01548086: // 3rd Generation Core Processor Family DRAM Controller
case 0x01588086: // 3rd Generation Core Processor Family DRAM Controller
type = CT_CORE_PROC;
break;
default:
if((id & 0x0000FFFF) == 0x00008086) // Intel chipset
{
}
break;
}
return type;
}
return ptr;
}
char detect_bios_type(vbios_map * map, char modeline, int entry_size);
char detect_bios_type(vbios_map * map, char modeline, int entry_size)
{
UInt32 i;
r2 = map->mode_table[i].resolution;
}
}
/*printf("r1 = %d r2 = %d\n", r1, r2);*/
//printf("r1 = %d r2 = %d\n", r1, r2);
}
return (r2-r1-6) % entry_size == 0;
{
UInt32 z;
vbios_map * map = malloc(sizeof(vbios_map));
if (!map)
{
return 0;
}
for(z=0; z<sizeof(vbios_map); z++) ((char*)map)[z]=0;
/*
* Determine chipset
}
map->mode_table_size = std_vesa->sHeader.usStructureSize - sizeof(ATOM_COMMON_TABLE_HEADER);
if (!detect_ati_bios_type(map)) map->bios = BT_ATI_2;
if (map->bios == BT_ATI_1) {
if (!detect_ati_bios_type(map))
{
map->bios = BT_ATI_2;
}
if (map->bios == BT_ATI_1)
{
verbose(", BT_ATI_1\n");
} else {
verbose(", BT_ATI_2\n");
}
}
else {
else
{
/*
* check if we have NVIDIA
NV_VESA_TABLE * std_vesa;
int i = 0;
while (i < 0x300)
{ //We don't need to look for the table in the whole bios, the 768 first bytes only
if ((map->bios_ptr[i] == 0x44)
}
}
/*
* check if we have Intel
*/
/*if (map->chipset == CT_UNKNOWN && memmem(map->bios_ptr, VBIOS_SIZE, INTEL_SIGNATURE, strlen(INTEL_SIGNATURE))) {
printf( "Intel chipset detected. However, 915resolution was unable to determine the chipset type.\n");
printf("Chipset Id: %x\n", map->chipset_id);
printf("Please report this problem to stomljen@yahoo.com\n");
close_vbios(map);
return 0;
}*/
/*
* check for others
*/
/*
* Figure out where the mode table is
*/
p++;
}
if (map->mode_table == 0)
if (map->mode_table == 0)
{
close_vbios(map);
return 0;
void unlock_vbios(vbios_map * map)
{
map->unlocked = TRUE;
switch (map->chipset) {
outb(CONFIG_MECH_ONE_DATA + 1, 0x33);
outb(CONFIG_MECH_ONE_DATA + 2, 0x33);
break;
default:
break;
}
#if DEBUG
outl(CONFIG_MECH_ONE_ADDR, 0x80000080);
outb(CONFIG_MECH_ONE_DATA + 1, map->b1);
outb(CONFIG_MECH_ONE_DATA + 2, map->b2);
default:
break;
}
mode->v_sync_offset = (edidInfo[65] & 0x0C) | ((edidInfo[64] & 0x0C) >> 2);
mode->v_sync_width = ((edidInfo[65] & 0x3) << 2) | (edidInfo[64] & 0x03);
*/
free( edidInfo );
return 0;
vfreq = vbl * freq;
hbl = 16 * (int)(x * (30.0 - 300000.0 / vfreq) /
+ (70.0 + 300000.0 / vfreq) / 16.0 + 0.5);
*vsyncstart = y;
*vsyncend = y + 3;
*vblank = vbl - 1;
verbose("BT_1 patched.\n");
vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);
if (bp) {
map->mode_table[i].bits_per_pixel = bp;
if (bp)
{
map->mode_table[i].bits_per_pixel = (uint8_t)bp;
}
res->x2 = (htotal?(((htotal-x) >> 8) & 0x0f) : (res->x2 & 0x0f)) | ((x >> 4) & 0xf0);
res->y2 = (vtotal?(((vtotal-y) >> 8) & 0x0f) : (res->y2 & 0x0f)) | ((y >> 4) & 0xf0);
res->y1 = (y & 0xff);
if (htotal)
{
res->x_total = ((htotal-x) & 0xff);
}
if (vtotal)
{
res->y_total = ((vtotal-y) & 0xff);
}
break;
}
case BT_2:
{
vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);
res->xchars = x / 8;
res->ychars = y / 16 - 1;
res->xchars = (uint8_t)(x / 8);
res->ychars = (uint8_t)(y / 16 - 1);
xprev = res->modelines[0].x1;
yprev = res->modelines[0].y1;
for(j=0; j < 3; j++) {
vbios_modeline_type2 * modeline = &res->modelines[j];
if (modeline->x1 == xprev && modeline->y1 == yprev) {
modeline->x1 = modeline->x2 = x-1;
modeline->y1 = modeline->y2 = y-1;
if (modeline->x1 == xprev && modeline->y1 == yprev)
{
modeline->x1 = modeline->x2 = (uint16_t)(x-1);
modeline->y1 = modeline->y2 = (uint16_t)(y-1);
gtf_timings(x, y, freqs[j], &modeline->clock,
&modeline->hsyncstart, &modeline->hsyncend,
&modeline->vsyncend, &modeline->vblank);
if (htotal)
modeline->htotal = htotal;
{
modeline->htotal = (uint16_t)htotal;
}
else
{
modeline->htotal = modeline->hblank;
}
if (vtotal)
modeline->vtotal = vtotal;
{
modeline->vtotal = (uint16_t)vtotal;
}
else
{
modeline->vtotal = modeline->vblank;
}
}
}
verbose("BT_1 patched.\n");
xprev = res->modelines[0].x1;
yprev = res->modelines[0].y1;
for (j=0; j < 3; j++) {
for (j=0; j < 3; j++)
{
vbios_modeline_type3 * modeline = &res->modelines[j];
if (modeline->x1 == xprev && modeline->y1 == yprev) {
modeline->x1 = modeline->x2 = x-1;
modeline->y1 = modeline->y2 = y-1;
if (modeline->x1 == xprev && modeline->y1 == yprev)
{
modeline->x1 = modeline->x2 = (uint16_t)(x-1);
modeline->y1 = modeline->y2 = (uint16_t)(y-1);
gtf_timings(x, y, freqs[j], &modeline->clock,
&modeline->hsyncstart, &modeline->hsyncend,
&modeline->hblank, &modeline->vsyncstart,
&modeline->vsyncend, &modeline->vblank);
if (htotal)
modeline->htotal = htotal;
{
modeline->htotal = (uint16_t)htotal;
}
else
{
modeline->htotal = modeline->hblank;
}
if (vtotal)
modeline->vtotal = vtotal;
{
modeline->vtotal = (uint16_t)vtotal;
}
else
{
modeline->vtotal = modeline->vblank;
modeline->timing_h = y-1;
modeline->timing_v = x-1;
}
modeline->timing_h = (uint16_t)(y-1);
modeline->timing_v = (uint16_t)(x-1);
}
}
verbose("BT_3 patched.\n");
ATOM_MODE_TIMING *mode_timing = (ATOM_MODE_TIMING *) map->ati_mode_table;
//if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force) {
if (!getMode(&mode)) {
//if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force){
if (!getMode(&mode))
{
verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode 0 patched!\n", mode.h_active, mode.v_active);
mode_timing->usCRTC_H_Total = mode.h_active + mode.h_blanking;
mode_timing->usCRTC_H_Disp = mode.h_active;
mode_timing->usCRTC_V_SyncWidth = mode.v_sync_width;
mode_timing->usPixelClock = mode.pixel_clock;
} else {
}
else
{
verbose(" Edid not found or invalid - vbios not patched!\n");
}
/*else
mode_timing->usPixelClock = modeline.clock;
}*/
break;
}
case BT_ATI_2:
ATOM_DTD_FORMAT *mode_timing = (ATOM_DTD_FORMAT *) map->ati_mode_table;
/*if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force) {*/
if (!getMode(&mode)) {
if (!getMode(&mode))
{
verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode 0 patched!\n", mode.h_active, mode.v_active);
mode_timing->usHBlanking_Time = mode.h_blanking;
mode_timing->usHActive = mode.h_active;
mode_timing->usVSyncWidth = mode.v_sync_width;
mode_timing->usPixClk = mode.pixel_clock;
} else {
}
else
{
verbose(" Edid not found or invalid - vbios not patched!\n");
}
/*else
&modeline.vsyncend, &modeline.vblank, 0);
mode_timing->usHBlanking_Time = modeline.hblank;
+mode_timing->usHActive = x;
+mode_timing->usHSyncOffset = modeline.hsyncstart - x;
+mode_timing->usHSyncWidth = modeline.hsyncend - modeline.hsyncstart;
+
+mode_timing->usVBlanking_Time = modeline.vblank;
+mode_timing->usVActive = y;
+mode_timing->usVSyncOffset = modeline.vsyncstart - y;
+mode_timing->usVSyncWidth = modeline.hsyncend - modeline.hsyncstart;
+
+mode_timing->usPixClk = modeline.clock;
+}*/
mode_timing->usHActive = x;
mode_timing->usHSyncOffset = modeline.hsyncstart - x;
mode_timing->usHSyncWidth = modeline.hsyncend - modeline.hsyncstart;
mode_timing->usVBlanking_Time = modeline.vblank;
mode_timing->usVActive = y;
mode_timing->usVSyncOffset = modeline.vsyncstart - y;
mode_timing->usVSyncWidth = modeline.hsyncend - modeline.hsyncstart;
mode_timing->usPixClk = modeline.clock;
}*/
break;
}
case BT_NVDA:
{
verbose("BT_NVDA");
edid_mode mode;
NV_MODELINE *mode_timing = (NV_MODELINE *) map->nv_mode_table;
/*if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force) {*/
if (!getMode(&mode)) {
if (!getMode(&mode))
{
verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode %d patched!\n", mode.h_active, mode.v_active, i);
mode_timing[i].usH_Total = mode.h_active + mode.h_blanking;
mode_timing[i].usH_Active = mode.h_active;
mode_timing[i].usV_SyncEnd = mode.v_active + mode.v_sync_offset + mode.v_sync_width;
mode_timing[i].usPixel_Clock = mode.pixel_clock;
} else {
}
else
{
verbose(" Edid not found or invalid - vbios not patched!\n");
}
/*else
{
vbios_modeline_type2 modeline;
cvt_timings(x, y, freqs[0], &modeline.clock,
&modeline.hsyncstart, &modeline.hsyncend,
&modeline.hblank, &modeline.vsyncstart,
&modeline.vsyncend, &modeline.vblank, 0);
mode_timing[i].usH_Total = x + modeline.hblank - 1;
mode_timing[i].usH_Active = x;
mode_timing[i].usH_SyncStart = modeline.hsyncstart - 1;
mode_timing[i].usH_SyncEnd = modeline.hsyncend - 1;
mode_timing[i].usV_Total = y + modeline.vblank - 1;
mode_timing[i].usV_Active = y;
mode_timing[i].usV_SyncStart = modeline.vsyncstart - 1;
mode_timing[i].usV_SyncEnd = modeline.vsyncend - 1;
mode_timing[i].usPixel_Clock = modeline.clock;
}*/
break;
verbose(" Unknown - vbios not patched\n");
break;
}
default:
break;
}
//}
//}
}
#endif // _RESOLUTION_H_
#endif // _RESOLUTION_H_
trunk/i386/modules/Resolution/edid.c
147147
148148
149149
150
151
152
153
150154
151155
152156
......
165169
166170
167171
172
173
174
175
176
168177
169178
170179
......
179188
180189
181190
182
183
191
192
184193
185
194
186195
196
187197
188198
189199
......
191201
192202
193203
204
205
206
207
208
209
210
194211
195
196
197212
198213
199214
200215
216
201217
202218
203219
......
237253
238254
239255
240
256
241257
242258
243259
......
249265
250266
251267
252
253
254
255268
256269
257
258270
259271
260
261
272
273
274
275
276
262277
263278
264279
......
270285
271286
272287
273
288
289
274290
275291
276292
......
306322
307323
308324
325
309326
310327
311328
......
326343
327344
328345
329
346
330347
331348
332
349
333350
334
351
352
335353
336354
337355
338356
339
340
357
341358
342359
343360
......
346363
347364
348365
349
366
350367
351368
352
353369
354370
355371
......
382398
383399
384400
385
401
386402
387403
388404
405
406
407
408
389409
390410
391411
392412
393
394413
395414
396415
397
398416
399
400
417
418
401419
402420
403
404
405
406
407
408
421
422
423
424
409425
/* checksum passed, everything's good */
err = 1;
}
else
{
msglog(" edid_checksum error ");
}
return err;
}
err = 0;
}
if (err == 0)
{
msglog(" edid_check_header error ");
}
return err;
}
//------------------------------------------------------------------------
int edid_is_timing_block(unsigned char *block)
{
if ((block[0] != 0x00) || (block[1] != 0x00) ||
(block[2] != 0x00) || (block[4] != 0x00))
if ((block[0] != 0x00) || (block[1] != 0x00) || (block[2] != 0x00) || (block[4] != 0x00))
{
return 1;
else
} else {
return 0;
}
}
//----------------------------------------------------------------------------------
{
int i;
unsigned char *block;
msglog(" Parse Edid:");
if(!verifyEDID((unsigned char *)edid))
{
msglog(" error\n");
return 0;
}
if(!verifyEDID((unsigned char *)edid)) return 0;
block = (unsigned char *)edid + DETAILED_TIMING_DESCRIPTIONS_START; //54
for (i = 0; i < 4; i++, block += DETAILED_TIMING_DESCRIPTION_SIZE) {
if (edid_is_timing_block(block)) {
msglog(" descriptor block %d is timing descriptor ", i);
var->h_active = H_ACTIVE;
var->v_active = V_ACTIVE;
var->h_sync_offset = H_SYNC_OFFSET;
void getResolution(UInt32* x, UInt32* y, UInt32* bp)
{
//int val;
static UInt32 xResolution, yResolution, bpResolution;
static UInt32 xResolution, yResolution, bpResolution = 32;// assume 32bits
/*
if(getIntForKey(kScreenWidth, &val, &bootInfo->chameleonConfig))
{
yResolution = val;
}
*/
bpResolution = 32;// assume 32bits
if(!xResolution || !yResolution || !bpResolution)
{
char* edidInfo = readEDID();
if(!edidInfo) return;
if(!edidInfo)
{
return;
}
edid_mode mode;
// TODO: check *all* resolutions reported and either use the highest, or the native resolution (if there is a flag for that)
//xResolution = edidInfo[56] | ((edidInfo[58] & 0xF0) << 4);
xResolution = DEFAULT_SCREEN_WIDTH;
yResolution = DEFAULT_SCREEN_HEIGHT;
}
else {
else
{
xResolution = mode.h_active;
yResolution = mode.v_active;
}
*y = yResolution;
*bp = bpResolution;
msglog("Best mode: %dx%dx%d\n", *x, *y, *bp);
}
char* readEDID()
bzero( edidInfo, EDID_BLOCK_SIZE);
status = getEDID(edidInfo, blocks_left);
/*
msglog("Buffer location: 0x%X status: %d\n", SEG(edidInfo) << 16 | OFF(edidInfo), status);
int j, i;
for (j = 0; j < 8; j++) {
for (j = 0; j < 8; j++)
{
for(i = 0; i < 16; i++) msglog(" 0x%02X", edidInfo[((i+1) * (j + 1)) - 1]);
msglog("\n");
}
*/
if(status == 0)
{
//if( edidInfo[0] == 0x00 || edidInfo[0] == 0xFF)
{
blocks_left--;
int reported = edidInfo[ EDID_V1_BLOCKS_TO_GO_OFFSET ];
if ( reported > blocks_left )
{
msglog("EDID claims %d more blocks left\n", reported);
}
return 0;
}
}
blocks_left = 0;
blocks_left = 0;
} while(blocks_left);
char* ret = malloc(sizeof(edidInfo));
if (!ret)
{
return 0;
}
memcpy(ret, edidInfo, sizeof(edidInfo));
return ret;
}
int getEDID( void * edidBlock, UInt8 block)
{
biosBuf_t bb;
bzero(&bb, sizeof(bb));
bb.intno = 0x10;
bb.eax.rr = 0x4F15;
bb.intno = 0x10;
bb.eax.rr = 0x4F15;
bb.ebx.r.l= 0x01;
bb.edx.rr = block;
bb.es = SEG( edidBlock );
bb.edi.rr = OFF( edidBlock );
bios( &bb );
return(bb.eax.r.h);
bb.es = SEG( edidBlock );
bb.edi.rr = OFF( edidBlock );
bios( &bb );
return(bb.eax.r.h);
}
trunk/i386/modules/Resolution/915resolution.h
124124
125125
126126
127
128
129
130
127
128
129
130
131131
132132
133133
......
157157
158158
159159
160
161
160
161
162162
163163
164164
......
198198
199199
200200
201
201
202202
203203
204204
......
222222
223223
224224
225
226
227225
228226
229227
typedef struct {
char *base;
ATOM_ROM_HEADER *AtomRomHeader;
unsigned short *MasterCommandTables;
unsigned short *MasterDataTables;
char*base;
ATOM_ROM_HEADER*AtomRomHeader;
unsigned short*MasterCommandTables;
unsigned short*MasterDataTables;
} bios_tables_t;
typedef struct {
UInt16 hsyncstart;
UInt16 hsyncend;
UInt16 y1;
UInt16 vtotal;
UInt16 y2;
UInt16 vtotal;
UInt16 y2;
UInt16 vblank;
UInt16 vsyncstart;
UInt16 vsyncend;
typedef struct {
unsigned char unknown[6];
vbios_modeline_type3 modelines[];
vbios_modeline_type3 modelines[];
} __attribute__((packed)) vbios_resolution_type3;
typedef struct {
UInt8 unlocked;
} vbios_map;
vbios_map * open_vbios(chipset_type);
void close_vbios (vbios_map*);
void unlock_vbios(vbios_map*);
trunk/i386/util/dyldsymboltool.c
11
2
2
33
44
55
......
2222
2323
2424
25
25
2626
27
27
2828
2929
3030
3131
3232
3333
34
35
36
34
35
36
3737
3838
3939
......
116116
117117
118118
119
120
121
119
120
121
122122
123123
124124
......
136136
137137
138138
139
139
140140
141141
142142
......
153153
154154
155155
156
157
158
156
157
159158
160159
161160
......
183182
184183
185184
186
185
187186
188187
189188
......
193192
194193
195194
196
195
197196
198197
199198
......
204203
205204
206205
207
206
208207
209208
210209
......
216215
217216
218217
219
218
220219
221220
222221
/*
* Copyright (c) 2010 Evan Lojewski. All rights reserved.
* Copyright (c) 2010-2015 Evan Lojewski. All rights reserved.
*
*dyldsymboltool
*
typedef struct symbols_dylib
{
struct mach_headerheader;
struct mach_headerheader;
struct dylib_commanddylib_info;
charmodule_name[sizeof(DYLIB_NAME)];
charmodule_name[sizeof(DYLIB_NAME)];
struct symtab_commandsymtab;
} symbols_dylib_t;
typedef struct symbolList_t
{
char*name;
uint32_taddr;
intpos;
char*name;
uint32_taddr;
intpos;
struct symbolList_t*next;
} symbolList_t;
//exit(1);
}
else
{
add_symbol(&symbols, START_SYMBOL, start_addr);
else
{
add_symbol(&symbols, START_SYMBOL, start_addr);
}
/* Header command info */
dylib.dylib_info.cmdsize = sizeof(struct dylib_command) + sizeof(dylib.module_name);// todo: verify
dylib.dylib_info.dylib.name.offset = sizeof(struct dylib_command);
dylib.dylib_info.dylib.timestamp = 0;// TODO: populate with time
dylib.dylib_info.dylib.current_version = 0;// TODO
dylib.dylib_info.dylib.current_version = 0;// TODO
dylib.dylib_info.dylib.compatibility_version = 0;// TODO
dylib.symtab.stroff = sizeof(dylib) + dylib.symtab.nsyms * sizeof(struct nlist);
dylib.symtab.strsize = string_size(symbols);
dylib.symtab.cmdsize = sizeof(struct symtab_command);
FILE* outfile = fopen(argv[argc-1], "w");
fwrite(&dylib,sizeof(dylib)/* Sizeof header + module name */
, 1, outfile);
}
fwrite(orig,
dylib.symtab.stroff+// Sizeof symbol nlists
dylib.symtab.stroff+// Sizeof symbol nlists
dylib.symtab.strsize - sizeof(dylib) + 1// sizeof symbol strings
, 1, outfile);
exit(0);
}
int num_symbols(symbolList_t* list)
int num_symbols(symbolList_t *list)
{
int retVal = 0;
while(list)
return retVal;
}
int string_size(symbolList_t* list)
int string_size(symbolList_t *list)
{
int retVal = 0;
while(list)
}
void add_symbol(symbolList_t** list, char* name, uint32_t addr)
void add_symbol(symbolList_t **list, char *name, uint32_t addr)
{
symbolList_t* entry = malloc(sizeof(symbolList_t));
entry->next = (*list);

Archive Download the corresponding diff file

Revision: 2573