Chameleon

Chameleon Commit Details

Date:2010-02-05 06:04:10 (14 years 2 months ago)
Author:Pradeesh
Commit:65
Parents: 64
Message:Updated ati stuff from netkas' PC_EFI 10.6 (merged his changes of adding support for Radeon 4300 , 4600 series )
Changes:
M/branches/prasys/i386/libsaio/ati.h
M/branches/prasys/revision
M/branches/prasys/i386/libsaio/ati.c

File differences

branches/prasys/i386/libsaio/ati.c
114114
115115
116116
117
118
119
120
121
122
123
124
125
126
127
128
117129
118130
119131
......
160172
161173
162174
163
164
175
176
165177
166178
167179
......
171183
172184
173185
186
187
188
189
190
191
174192
175193
176194
......
218236
219237
220238
221
222
223
224
225
226
227
228
229
230
231
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
232256
233257
234258
......
307331
308332
309333
310
334
311335
312336
313337
......
401425
402426
403427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
404449
405450
406451
......
418463
419464
420465
421
422466
423467
424468
......
528572
529573
530574
531
532575
533576
534577
......
613656
614657
615658
616
659
617660
618
619
661
662
620663
621664
622665
......
635678
636679
637680
638
681
639682
640683
641684
642
685
643686
644687
645688
......
662705
663706
664707
665
708
666709
667710
668
711
669712
670713
671714
......
688731
689732
690733
691
734
692735
693736
694737
......
712755
713756
714757
715
758
716759
717760
718761
......
724767
725768
726769
727
770
728771
729772
730773
731
774
732775
733776
734777
735
778
736779
737
780
738781
739782
740783
......
749792
750793
751794
752
795
753796
754797
755
798
756799
757
800
758801
759802
760
803
761804
762
805
763806
764807
765808
uint16_t devid;
};
static uint16_t swap16(uint16_t toswap) {
return (((toswap & 0x00FF) << 8) | ((toswap & 0xFF00) >> 8));
}
static uint32_t swap32(uint32_t toswap) {
return ((toswap & 0x000000FF) << 24) |
((toswap & 0x0000FF00) << 8 ) |
((toswap & 0x00FF0000) >> 8 ) |
((toswap & 0xFF000000) >> 24);
}
// Known cards as of 2008/08/26
static struct ati_chipsets_t ATIKnownChipsets[] = {
{ 0x00000000, "Unknown" },
{ 0x1002945A, "ATI Radeon 4800 Mobility Series"} ,
{ 0x1002945B, "ATI Radeon 4800 Mobility Series"} ,
{ 0x1002944B, "ATI Radeon 4800 Mobility Series"} ,
{ 0x10029490, "ATI Radeon 4600 Series"} ,
{ 0x10029498, "ATI Radeon 4600 Series"} ,
{ 0x10029490, "ATI Radeon 4670 Series"} ,
{ 0x10029498, "ATI Radeon 4650 Series"} ,
{ 0x1002949E, "ATI Radeon 4600 Series"} ,
{ 0x10029480, "ATI Radeon 4600 Series"} ,
{ 0x10029488, "ATI Radeon 4600 Series"} ,
{ 0x10029552, "ATI Radeon 4300 Mobility Series"} ,
{ 0x10029553, "ATI Radeon 4500 Mobility Series"} ,
{ 0x1002954F, "ATI Radeon 4300 Series"},
{ 0x100294B3, "ATI Radeon 4770 Series"},
{ 0x100294B5, "ATI Radeon 4770 Series"},
{ 0x100268B8, "ATI Radeon 5700 Series"},
{ 0x100268BE, "ATI Radeon 5700 Series"},
{ 0x10026898, "ATI Radeon 5800 Series"},
{ 0x10026899, "ATI Radeon 5800 Series"},
};
static struct ati_chipsets_t ATIKnownFramebuffers[] = {
{ 0x1002945A, "Motmot"} ,
{ 0x1002945B, "Motmot"} ,
{ 0x1002944B, "Motmot"} ,
{ 0x10029490, "Motmot"} ,
{ 0x10029498, "Motmot"} ,
{ 0x1002949E, "Motmot"} ,
{ 0x10029480, "Motmot"} ,
{ 0x10029488, "Motmot"} ,
{ 0x10029540, "Motmot"} ,
{ 0x10029541, "Motmot"} ,
{ 0x1002954E, "Motmot"} ,
{ 0x10029552, "Motmot"} ,
{ 0x10029553, "Motmot"} ,
{ 0x1002954F, "Motmot"} ,
{ 0x10029490, "Peregrine"} ,
{ 0x10029498, "Peregrine"} ,
{ 0x1002949E, "Peregrine"} ,
{ 0x10029480, "Peregrine"} ,
{ 0x10029488, "Peregrine"} ,
{ 0x10029540, "Peregrine"} ,
{ 0x10029541, "Peregrine"} ,
{ 0x1002954E, "Peregrine"} ,
{ 0x10029552, "Peregrine"} ,
{ 0x10029553, "Peregrine"} ,
{ 0x1002954F, "Peregrine"} ,
{ 0x100294B3, "Peregrine"},
{ 0x100294B5, "Peregrine"},
{ 0x100268B8, "Motmot"},
{ 0x100268BE, "Motmot"},
{ 0x10026898, "Motmot"},
{ 0x10026899, "Motmot"},
};
unsigned int accessROM(pci_dt_t *ati_dev, unsigned int mode)
}
while(counter != 0x10000);
}
accessROM((pci_dt_t *)regs, 1);
accessROM(regs, 1);
if ((* (UInt16 *)BIOSBase) != 0xAA55) {
printf("Wrong BIOS signature: %04x\n", (* (UInt16 *)BIOSBase));
return size;
}
static uint8_t read8(uint8_t *ptr, uint16_t offset) {
return ptr[offset];
}
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);
}
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);
}
char *get_ati_model(uint32_t id) {
int i=0;
for(i = 0; i < (sizeof(ATIKnownChipsets) / sizeof(ATIKnownChipsets[0])); i++) {
}
return ATIKnownFramebuffers[0].name;
}
int devprop_add_iopciconfigspace(struct DevPropDevice *device, pci_dt_t *ati_dev)
{
if(!device)
{
if(!device)
return 0;
if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))
return 0;
if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))
bool setup_ati_devprop(pci_dt_t *ati_dev)
{
//intlen;
intlen;
char*devicepath;
//volatile uint8_t *regs;
//uint32_tbar[7];
volatile uint8_t *regs;
uint32_tbar[7];
char*model;
char*framebuffer;
devicepath = get_pci_dev_path(ati_dev);
cmd = pci_config_read8( ati_dev->dev.addr, 4);
verbose("old pci command - %x\n", cmd);
printf("old pci command - %x\n", cmd);
if( cmd == 0) {
pci_config_write8(ati_dev->dev.addr, 4, 6);
cmd = pci_config_read8( ati_dev->dev.addr, 4);
verbose("new pci command - %x\n", cmd);
printf("new pci command - %x\n", cmd);
};
model = get_ati_model((ati_dev->vendor_id << 16) | ati_dev->device_id);
uint32_t boot_display = 0x00000001;
if(radeon_card_posted(ati_dev)) boot_display=0x01;
else boot_display=0x00;
verbose("boot display - %x\n", boot_display);
printf("boot display - %x\n", boot_display);
devprop_add_value(device, "@0,AAPL,boot-display", (uint8_t*)&boot_display, 4);
if(framebuffer[0] == 'M' && framebuffer[1] == 'o' && framebuffer[2] == 't') //faster than strcmp ;)
if((framebuffer[0] == 'M' && framebuffer[1] == 'o' && framebuffer[2] == 't') || (framebuffer[0] == 'S' && framebuffer[1] == 'h' && framebuffer[2] == 'r') || (framebuffer[0] == 'P' && framebuffer[1] == 'e' && framebuffer[2] == 'r')) //faster than strcmp ;)
devprop_add_ati_template_4xxx(device);
else
{
char tmp[10];
sprintf(tmp, "Slot-%x",devices_number);
devprop_add_value(device, "AAPL,slot-name", (uint8_t*)tmp, strlen(tmp));
devprop_add_value(device, "AAPL,slot-name", tmp, strlen(tmp));
devices_number++;
sprintf(tmpString, ati_compatible_0[1], framebuffer);
if (getValueForKey("-useatirom", &val, &len1, &bootInfo->bootConfig))
{
sprintf(romfilename, "ati_%04x_%04x.rom", (uint16_t)ati_dev->device_id, (uint16_t)ati_dev->vendor_id);
verbose("looking for file /Extra/%s\n", romfilename);
printf("looking for file /Extra/%s\n", romfilename);
rom = malloc(0x20000);
rom_size = load_ati_bios_file((char *)romfilename, (char *)rom);
if(rom_size > 0x10000) rom_size = 0x10000; //we dont need rest anyway;
if(boot_display) // no custom rom
biosimage = 0; //try to dump from legacy space, otherwise can result in 100% fan speed
else
biosimage = (char *)readAtomBIOS(ati_dev); //readAtomBios result in bug on some cards (100% fan speed and black screen),
biosimage = readAtomBIOS(ati_dev); //readAtomBios result in bug on some cards (100% fan speed and black screen),
//not using it for posted card, rading from legacy space instead
} else {
biosimage = rom; //going custom rom way
verbose("Using rom %s\n", romfilename);
printf("Using rom %s\n", romfilename);
}
if(biosimage == 0)
{
biosimage = (char *)0xC0000;
biosimage = 0xC0000;
toFree = 0;
verbose("Not going to use bios image file\n");
printf("Not going to use bios image file\n");
} else toFree = 1;
if ((uint8_t)biosimage[0] == 0x55 && (uint8_t)biosimage[1] == 0xaa)
{
if (rom_pci_header->device != ati_dev->device_id)
{
verbose("Bios image (%x) doesnt match card (%x), ignoring\n", rom_pci_header->device, ati_dev->device_id);
printf("Bios image (%x) doesnt match card (%x), ignoring\n", rom_pci_header->device, ati_dev->device_id);
} else {
if(toFree)
verbose("Adding binimage to card %x from mmio space with size %x\n", ati_dev->device_id, biosimage_size);
printf("Adding binimage to card %x from mmio space with size %x\n", ati_dev->device_id, biosimage_size);
else
verbose("Adding binimage to card %x from legacy space with size %x\n", ati_dev->device_id, biosimage_size);
printf("Adding binimage to card %x from legacy space with size %x\n", ati_dev->device_id, biosimage_size);
devprop_add_value(device, "ATY,bin_image", (uint8_t*) biosimage, biosimage_size);
}
} else verbose("Wrong pci header signature %x\n", rom_pci_header->signature);
} else printf("Wrong pci header signature %x\n", rom_pci_header->signature);
} else verbose("Bios image not found at %x, content %x %x\n", biosimage, (uint8_t)biosimage[0], (uint8_t)biosimage[1]);
} else printf("Bios image not found at %x, content %x %x\n", biosimage, (uint8_t)biosimage[0], (uint8_t)biosimage[1]);
if(toFree) free(biosimage);
}
stringdata = malloc(sizeof(uint8_t) * string->length);
branches/prasys/i386/libsaio/ati.h
3737
3838
3939
40
41
42
43
44
45
4046
4147
4248
uint8_t data[];
};
#define DCB_MAX_NUM_ENTRIES 16
#define DCB_MAX_NUM_I2C_ENTRIES 16
#define DCB_LOC_ON_CHIP 0
struct bios {
uint16_tsignature;/* 0x55AA */
uint8_tsize;/* Size in multiples of 512 */
branches/prasys/revision
1
1
49
52:53

Archive Download the corresponding diff file

Revision: 65