Chameleon

Chameleon Commit Details

Date:2015-05-10 14:37:05 (5 years 3 months ago)
Author:ErmaC
Commit:2672
Parents: 2671
Message:Refactored nvidia mem detection.
Changes:
M/trunk/i386/libsaio/nvidia.c

File differences

trunk/i386/libsaio/nvidia.c
19041904
19051905
19061906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
19291907
19301908
19311909
......
19841962
19851963
19861964
1987
1965
19881966
19891967
19901968
19911969
19921970
1993
1971
19941972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
19951995
19961996
19971997
......
20062006
20072007
20082008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
20092027
20102028
20112029
......
20582076
20592077
20602078
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
20812079
20822080
20832081
......
20912089
20922090
20932091
2094
2095
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
20962102
20972103
2098
2099
2100
21012104
2102
2103
2104
21052105
21062106
2107
21082107
2109
21102108
21112109
21122110
return nvidia_card_generic[0].name;
}
static uint32_t load_nvidia_bios_file(const char *filename, uint8_t **buf)
{
int fd;
int size;
if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0)
{
return 0;
}
size = file_size(fd);
if (size)
{
*buf = malloc(size);
size = read(fd, (char *)buf, size);
}
close(fd);
return size > 0 ? size : 0;
}
static int devprop_add_nvidia_template(DevPropDevice *device)
{
char tmp[16];
// Rek : Dont use sprintf return, it does not WORK !! our custom sprintf() always return 0!
// len = sprintf(tmp, "Slot-%x", devices_number);
snprintf(tmp, sizeof(tmp), "Slot-%x",devices_number);
devprop_add_value(device, "AAPL,slot-name", (uint8_t *) tmp, strlen(tmp));
devprop_add_value(device, "AAPL,slot-name", (uint8_t *) tmp, (uint32_t)strlen(tmp));
devices_number++;
return 1;
}
unsigned long long mem_detect(volatile uint8_t *regs, uint8_t nvCardType, pci_dt_t *nvda_dev, uint32_t device_id, uint32_t subsys_id)
static uint32_t load_nvidia_bios_file(const char *filename, uint8_t **buf)
{
int fd;
int size;
if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0)
{
return 0;
}
size = file_size(fd);
if (size)
{
*buf = malloc(size);
size = read(fd, (char *)buf, size);
}
close(fd);
return size > 0 ? size : 0;
}
uint64_t mem_detect(volatile uint8_t *regs, uint16_t nvCardType, pci_dt_t *nvda_dev, uint32_t device_id, uint32_t subsys_id)
{
uint64_t vram_size = 0;
// First check if any value exist in the plist
}
}
// Finally, if vram_size still not set do the calculation with our own method
if (nvCardType < NV_ARCH_50)
{
vram_size = (uint64_t)(REG32( NV04_PFB_FIFO_DATA ));
vram_size &= NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK;
}
else if (nvCardType < NV_ARCH_C0)
{
vram_size = (uint64_t)(REG32( NV04_PFB_FIFO_DATA ));
vram_size |= (vram_size & 0xff) << 32;
vram_size &= 0xffffffff00ll;
}
else
{ // >= NV_ARCH_C0
vram_size = REG32( NVC0_MEM_CTRLR_RAM_AMOUNT ) << 20;
vram_size *= REG32( NVC0_MEM_CTRLR_COUNT );
}
// Then, Workaround for 9600M GT, GT 210/420/430/440/525M/540M & GTX 560M
switch (nvda_dev->device_id)
{
break;
}
if (!vram_size)
{
// Finally, if vram_size still not set do the calculation with our own method
if (nvCardType < NV_ARCH_50)
{
vram_size = (uint64_t)(REG32(NV04_PFB_FIFO_DATA));
vram_size &= NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK;
}
else if (nvCardType < NV_ARCH_C0)
{
vram_size = (uint64_t)(REG32(NV04_PFB_FIFO_DATA));
vram_size |= (vram_size & 0xff) << 32;
vram_size &= 0xffffffff00ll;
}
else
{ // >= NV_ARCH_C0
vram_size = REG32(NVC0_MEM_CTRLR_RAM_AMOUNT) << 20;
vram_size *= REG32(NVC0_MEM_CTRLR_COUNT);
}
}
DBG("mem_detected %ld\n", vram_size);
return vram_size;
}
bool setup_nvidia_devprop(pci_dt_t *nvda_dev)
{
struct DevPropDevice*device= NULL;
char*devicepath= NULL;
DevPropDevice*device= NULL;
char*devicepath= NULL;
uint8_t*rom= NULL;
uint16_tnvCardType= 0;
uint64_tvideoRam= 0;
uint32_tbar[7];
uint32_tboot_display= 0;
intnvPatch= 0;
char*model= NULL;
charnvFilename[64];
option_rom_pci_header_t*rom_pci_header;
volatile uint8_t*regs;
uint8_t*rom= NULL;
uint8_tnvCardType= 0;
uint64_tvideoRam= 0;
uint32_tnvBiosOveride;
uint32_tbar[7];
uint32_tboot_display= 0;
intnvPatch = 0;
intlen;
charbiosVersion[64];
charnvFilename[64];
charkNVCAP[12];
char*model= NULL;
const char*value;
fill_card_list();

Archive Download the corresponding diff file

Revision: 2672