Chameleon

Chameleon Commit Details

Date:2014-11-02 18:33:44 (4 years 7 months ago)
Author:MacMan
Commit:2463
Parents: 2462
Message:Changed hexkey2devprop to hex2devprop and moved to device_inject.c to fix injecting ig_platform_id using key.
Changes:
M/branches/Chimera/Make.rules
M/branches/Chimera/i386/libsaio/device_inject.c
M/branches/Chimera/i386/libsaio/device_inject.h
M/branches/Chimera/i386/libsaio/console.c
M/branches/Chimera/i386/libsaio/gma.c

File differences

branches/Chimera/i386/libsaio/console.c
9292
9393
9494
95
95
9696
9797
9898
bzero(msgbuf, BOOTER_LOG_SIZE);
cursor = msgbuf;
//msglog("%s\n", "Chimera 4.0.0 Branch of " "Chameleon " I386BOOT_CHAMELEONVERSION " (svn-r" I386BOOT_CHAMELEONREVISION ")" " [" I386BOOT_BUILDDATE "]");
msglog("%s\n", "Chimera 4.0.0 Branch of Chameleon" " [" I386BOOT_BUILDDATE "]");
msglog("%s\n", "Chimera 4.0.1 Branch of Chameleon" " [" I386BOOT_BUILDDATE "]");
}
void msglog(const char * fmt, ...)
branches/Chimera/i386/libsaio/gma.c
358358
359359
360360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386361
387362
388
389
390
391
392
393
394
395
396
397
363
364
365
366
367
368
369
370
371
372
398373
399
400
401
402
403
404
374
375
376
377
378
379
405380
406381
407382
......
508483
509484
510485
511
486
512487
513488
514489
......
541516
542517
543518
544
519
545520
546521
547522
......
561536
562537
563538
564
539
565540
566541
567542
......
572547
573548
574549
575
550
576551
577552
578553
......
606581
607582
608583
609
584
610585
611586
612587
......
629604
630605
631606
632
607
633608
634609
635610
......
652627
653628
654629
655
630
656631
657632
658633
......
677652
678653
679654
680
655
681656
682657
683658
......
688663
689664
690665
691
666
692667
693668
694669
......
711686
712687
713688
714
689
715690
716691
717692
......
740715
741716
742717
743
718
744719
745720
746721
......
797772
798773
799774
800
775
801776
802777
803778
......
808783
809784
810785
811
786
812787
813788
814789
......
825800
826801
827802
828
803
829804
830805
831806
......
836811
837812
838813
839
814
840815
841816
842817
......
860835
861836
862837
863
838
864839
865840
866841
......
871846
872847
873848
874
849
875850
876851
877852
return desc;
}
/*************************************************************************************
* Converts hexadecimal character string 'key' into a binary property for injection *
* with correct byte order. Base on hex2bin function from device_inject.c *
************************************************************************************/
static int hexkey2devprop(const char *key, uint8_t *prop, int length)
{
char*p;
int i, x;
charbuf[length+1];
int len;
buf[length-1] = '\0';
p = (char *) key;
x = length-1;
len = (length*2)+1;
for (i = 0; i < len; i++) {
buf[0] = *p++;
buf[1] = *p++;
prop[x] = (unsigned char) strtoul(buf, NULL, 16);
x--;
}
return 0;
}
bool setup_gma_devprop(pci_dt_t *gma_dev)
{
char*devicepath = NULL;
volatile uint8_t*regs;
uint32_tbar[7];
char*model = NULL;
uint8_t BuiltIn =0x00;
int len;
const char*value;
uint16_tvendor_id = gma_dev->vendor_id;
uint16_tdevice_id = gma_dev->device_id;
uint8_t ClassFix[4] = { 0x00, 0x00, 0x03, 0x00 };
char *devicepath = NULL;
volatile uint8_t *regs;
uint32_t bar[7];
char *model = NULL;
uint8_t BuiltIn = 0x00;
int len;
const char *value;
uint16_t vendor_id = gma_dev->vendor_id;
uint16_t device_id = gma_dev->device_id;
uint8_t ClassFix[4] = { 0x00, 0x00, 0x03, 0x00 };
uint8_t hd3k_kmobile_device_id[4] = { 0x26, 0x01, 0x00 }; // MacMan
uint8_t hd4k_device_id[4] = { 0x62, 0x01, 0x00 }; // MacMan
uint8_t hd4400_mobile_device_id[4] = { 0x26, 0x0A, 0x00 }; // MacMan
uint8_t hd4600_device_id[4] = { 0x12, 0x04, 0x00 }; // MacMan
uint8_t hd4600_mobile_device_id[4] = { 0x16, 0x04, 0x00 }; // MacMan
uint8_t igp_device_id[4] = { 0x00, 0x00, 0x00 }; // MacMan
uint8_t hd3k_kmobile_device_id[4] = { 0x26, 0x01, 0x00, 0x00 }; // MacMan
uint8_t hd4k_device_id[4] = { 0x62, 0x01, 0x00, 0x00 }; // MacMan
uint8_t hd4400_mobile_device_id[4] = { 0x26, 0x0A, 0x00, 0x00 }; // MacMan
uint8_t hd4600_device_id[4] = { 0x12, 0x04, 0x00, 0x00 }; // MacMan
uint8_t hd4600_mobile_device_id[4] = { 0x16, 0x04, 0x00, 0x00 }; // MacMan
uint8_t igp_device_id[4] = { 0x00, 0x00, 0x00, 0x00 }; // MacMan
uint8_t snb_id_3k[4] = { 0x10, 0x00, 0x03, 0x00 }; // MacMan
uint8_t snb_id_3k_mobile[4] = { 0x00, 0x00, 0x01, 0x00 }; // MacMan
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Setting %s for snb-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,snb-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Setting %s for snb-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,snb-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPDeviceID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Using %s for unsupported device id injection.\n", value);
hexkey2devprop(value, igp_device_id, 2);
hex2devprop(value, igp_device_id, 2);
devprop_add_value(device, "device-id",igp_device_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Using %s for snb-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,snb-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Setting %s for snb-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,snb-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Using %s for ig-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,ig-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Using %s for ig-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,ig-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPDeviceID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Using %s for unsupported device id injection.\n", value);
hexkey2devprop(value, igp_device_id, 2);
hex2devprop(value, igp_device_id, 2);
devprop_add_value(device, "device-id",igp_device_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig))
{
verbose("Using %s for ig-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,ig-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig))
{
verbose("Using %s for ig-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,ig-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig))
{
verbose("Using %s for ig-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,ig-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPDeviceID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Using %s for unsupported device id injection.\n", value);
hexkey2devprop(value, igp_device_id, 2);
hex2devprop(value, igp_device_id, 2);
devprop_add_value(device, "device-id",igp_device_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig))
{
verbose("Using %s for ig-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,ig-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPDeviceID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Using %s for unsupported device id injection.\n", value);
hexkey2devprop(value, igp_device_id, 2);
hex2devprop(value, igp_device_id, 2);
devprop_add_value(device, "device-id",igp_device_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig))
{
verbose("Using %s for ig-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,ig-platform-id", ig_platform_id, 4);
}
else
if (getValueForKey(kIGPDeviceID, &value, &len, &bootInfo->chameleonConfig)) // MacMan
{
verbose("Using %s for unsupported device id injection.\n", value);
hexkey2devprop(value, igp_device_id, 2);
hex2devprop(value, igp_device_id, 2);
devprop_add_value(device, "device-id",igp_device_id, 4);
}
else
if (getValueForKey(kIGPlatformID, &value, &len, &bootInfo->chameleonConfig))
{
verbose("Using %s for ig-platform-id\n", value);
hexkey2devprop(value, ig_platform_id, 4);
hex2devprop(value, ig_platform_id, 4);
devprop_add_value(device, "AAPL,ig-platform-id", ig_platform_id, 4);
}
else
branches/Chimera/i386/libsaio/device_inject.c
361361
362362
363363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
364394
365395
366396
return 0;
}
/*************************************************************************************
* Converts hexadecimal character string 'hex' into a binary property for injection *
* with correct byte order. Base on hex2bin function *
************************************************************************************/
int hex2devprop(const char *hex, uint8_t *prop, int length)
{
char*p;
int i, x;
charbuf[3];
int len;
if (hex == NULL || prop == NULL || length <= 0 || strlen(hex) != length * 2) {
printf("[ERROR] hexkey2devprop input error\n");
return -1;
}
buf[2] = '\0';
p = (char *) hex;
x = length-1;
len = (length*2)+1;
for (i = 0; i < len; i++) {
buf[0] = *p++;
buf[1] = *p++;
prop[x] = (unsigned char) strtoul(buf, NULL, 16);
x--;
}
return 0;
}
/* ======================================================= */
/* a fine place for this code */
branches/Chimera/i386/libsaio/device_inject.h
8080
8181
8282
83
8384
8485
intdevprop_add_network_template(DevPropDevice *device, uint16_t vendor_id);
inthex2bin(const char *hex, uint8_t *bin, int len);
int hex2devprop(const char *key, uint8_t *prop, int length);
#endif /* !__LIBSAIO_DEVICE_INJECT_H */
branches/Chimera/Make.rules
1818
1919
2020
21
21
2222
2323
2424
CFLAGS= $(CONFIG_OPTIMIZATION_LEVEL) -g -Wmost -Werror -Wno-unused-function -Wno-int-conversion
CPPFLAGS = $(MORECPP) -g -Wmost -Werror -fno-exceptions -fno-rtti -ffreestanding
CPPFLAGS = $(MORECPP) -g -Wmost -Werror -fno-exceptions -fno-rtti
DEFINES=
DIST_SUBDIRS += $(SUBDIRS)

Archive Download the corresponding diff file

Revision: 2463