Index: branches/cparm/doc/com.apple.Boot.example.plist =================================================================== --- branches/cparm/doc/com.apple.Boot.example.plist (revision 0) +++ branches/cparm/doc/com.apple.Boot.example.plist (revision 2016) @@ -0,0 +1,66 @@ + + + + + ACPIDropTables + + SSDT + + TAMG + + + Default Partition + Snow Leopard + DropSSDT + Yes + EHCIhard + No + EnableC4State + Yes + EnableSpeedStep + Yes + GenerateCStates + No + GeneratePStates + No + GraphicsEnabler + Yes + Kernel + mach_kernel + Kernel Flags + + Kernel Flags debug + -v acpi_debug=0xfffffff io=0xfffffffe trace=4096 keepsyms=1 + KeyboardType + AZERTY + Legacy Logo + Yes + NVIDIA + + + Chipset Name + Lenovo Quadro FX 380 + IOPCIPrimaryMatch + 0x10DE0658 + VRam Size + 256 + + + Quiet Boot + No + RandomTheme + Yes + ResetType + 0 + TDP + 80 + Theme + graphite + Timeout + 5 + UpdateACPI + Yes + quickSSDTsearch + Yes + + Property changes on: branches/cparm/doc/com.apple.Boot.example.plist ___________________________________________________________________ Added: svn:executable + * Index: branches/cparm/doc/ModuleHelp.txt =================================================================== --- branches/cparm/doc/ModuleHelp.txt (revision 2015) +++ branches/cparm/doc/ModuleHelp.txt (revision 2016) @@ -17,7 +17,7 @@ VBIOS=Yes|No Inject VBIOS to device-properties. - NVIDIA card injection usage e.g: // TODO : add memory info for each card to this structure + NVIDIA card injection usage e.g: see doc/com.apple.Boot.example.plist for an example NVIDIA @@ -26,7 +26,25 @@ Quadro FX 380 IOPCIPrimaryMatch 0x10DE0658 + VRam Size + 256 + + Chipset Name + YOUR_CARD_NAME + IOPCIPrimaryMatch + YOUR_CARD_ID + VRam Size + YOUR_CARD_VRAM_SIZE + + + Chipset Name + YOUR_SECOND_CARD_NAME + IOPCIPrimaryMatch + YOUR_SECOND_CARD_ID + VRam Size + YOUR_SECOND_CARD_VRAM_SIZE + . . . Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 2015) +++ branches/cparm/CHANGES (revision 2016) @@ -1,3 +1,4 @@ +- Added memory info to the nvidia plist structure, so now one can add several cards to the plist and set a customized name and memory info for each cards - Implemented a method to inject new graphics cards from a plist, no need to hardcode device ids anymore !! (for now, only nvidia cards are supported, see doc/ModuleHelp.txt for usage) - Moved the smbios detection code to the freebsd one Index: branches/cparm/i386/libsaio/Makefile =================================================================== --- branches/cparm/i386/libsaio/Makefile (revision 2015) +++ branches/cparm/i386/libsaio/Makefile (revision 2016) @@ -36,7 +36,7 @@ xml.o md5.o device_tree.o modules.o \ cpu.o platform.o \ fake_efi.o \ - device_inject.o pci_root.o \ + device_inject.o \ convert.o acpi_tools.o smbios.o uterror.o lzss.o lib.o rtc.o time.o # Options enabled by default: Index: branches/cparm/i386/libsaio/device_inject.c =================================================================== --- branches/cparm/i386/libsaio/device_inject.c (revision 2015) +++ branches/cparm/i386/libsaio/device_inject.c (revision 2016) @@ -8,7 +8,6 @@ #include "libsaio.h" #include "bootstruct.h" #include "pci.h" -#include "pci_root.h" #include "device_inject.h" #include "convert.h" #include "platform.h" @@ -32,7 +31,6 @@ *len = string->length; return devprop_generate_string(string); } - verbose("efi_inject_get_devprop_string NULL trying stringdata\n"); return NULL; } @@ -42,7 +40,7 @@ uint8_t *binStr; uint8_t *kbinStr; - int cnt, cnt2; + int cnt = 0, cnt2 = 0; static char DEVICE_PROPERTIES_PROP[] = "device-properties"; @@ -50,11 +48,14 @@ */ uint32_t strlength; char *string = efi_inject_get_devprop_string(&strlength); - + if (string == NULL) { + verbose("efi_inject_get_devprop_string NULL trying stringdata\n"); + return; + } /* Use the static "device-properties" boot config key contents if available, * otheriwse use the generated one. */ - if (!getValueForKey(kDeviceProperties, &val, &cnt, DEFAULT_BOOT_CONFIG) && string) + if (!getValueForKey(kDeviceProperties, &val, &cnt, DEFAULT_BOOT_CONFIG)) { val = (const char*)string; cnt = strlength * 2; Index: branches/cparm/i386/libsaio/pci.c =================================================================== --- branches/cparm/i386/libsaio/pci.c (revision 2015) +++ branches/cparm/i386/libsaio/pci.c (revision 2016) @@ -7,7 +7,6 @@ #include "libsaio.h" #include "bootstruct.h" #include "pci.h" -#include "pci_root.h" #include "modules.h" #include "device_inject.h" @@ -232,3 +231,40 @@ } } #endif + +static int rootuid = 10; //value means function wasnt ran yet + +/* + * getPciRootUID: Copyright 2009 netkas + */ +int getPciRootUID(void) +{ + const char *val; + int len; + + if (rootuid < 10) return rootuid; + rootuid = 0; /* default uid = 0 */ + + if (getValueForKey(kPCIRootUID, &val, &len, DEFAULT_BOOT_CONFIG)) + { + if (isdigit(val[0])) rootuid = val[0] - '0'; + + if ( (rootuid >= 0) && (rootuid < 10) ) + goto out; + else + rootuid = 0; + } + + /* PCEFI compatibility */ + if (getValueForKey("-pci0", &val, &len, DEFAULT_BOOT_CONFIG)) + { + rootuid = 0; + } + else if (getValueForKey("-pci1", &val, &len, DEFAULT_BOOT_CONFIG)) + { + rootuid = 1; + } +out: + verbose("Using PCI-Root-UID value: %d\n", rootuid); + return rootuid; +} \ No newline at end of file Index: branches/cparm/i386/libsaio/pci.h =================================================================== --- branches/cparm/i386/libsaio/pci.h (revision 2015) +++ branches/cparm/i386/libsaio/pci.h (revision 2016) @@ -64,6 +64,8 @@ extern void build_pci_dt(void); extern void dump_pci_dt(pci_dt_t *); extern void setup_pci_devs(pci_dt_t *pci_dt); +extern int getPciRootUID(void); + //----------------------------------------------------------------------------- // added by iNDi Index: branches/cparm/i386/libsaio/saio_internal.h =================================================================== --- branches/cparm/i386/libsaio/saio_internal.h (revision 2015) +++ branches/cparm/i386/libsaio/saio_internal.h (revision 2016) @@ -183,6 +183,8 @@ extern BVRef nbpScanBootVolumes(int biosdev, int *count); #endif + + /* platform.c */ extern void scan_platform(void); extern void SetgRootDevice(const char * str); Index: branches/cparm/i386/modules/ACPIPatcher/AcpiPatcher.c =================================================================== --- branches/cparm/i386/modules/ACPIPatcher/AcpiPatcher.c (revision 2015) +++ branches/cparm/i386/modules/ACPIPatcher/AcpiPatcher.c (revision 2016) @@ -11,7 +11,6 @@ #include "libsaio.h" #include "modules.h" #include "bootstruct.h" -#include "pci_root.h" #include "acpi_patcher.h" void AcpiPatcher_start(void); Index: branches/cparm/i386/modules/GraphicsEnabler/nvidia.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 2015) +++ branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 2016) @@ -921,7 +921,7 @@ static uint32_t load_nvidia_bios_file(const char *filename, uint8_t *buf, int bufsize); static int devprop_add_nvidia_template(struct DevPropDevice *device); static int hex2bin(const char *hex, uint8_t *bin, int len); -static unsigned long long mem_detect(volatile uint8_t *regs, uint8_t nvCardType, pci_dt_t *nvda_dev); +static unsigned long long mem_detect(volatile uint8_t *regs, uint8_t nvCardType, pci_dt_t *nvda_dev, uint32_t id); static uint16_t swap16(uint16_t x) @@ -959,6 +959,50 @@ } #endif +typedef struct cardList_t +{ + char* model; + uint32_t id; + uint64_t videoRam; + struct cardList_t* next; +} cardList_t; + +cardList_t* cardList = NULL; + +static void add_card(char* model, uint32_t id, uint64_t videoRam) +{ + + cardList_t* new_card = malloc(sizeof(cardList_t)); + if (new_card) + { + new_card->next = cardList; + + cardList = new_card; + + new_card->id = id; + new_card->videoRam = videoRam; + new_card->model = model; + } +} + +static cardList_t* FindCardWithId(uint32_t id) +{ + cardList_t* entry = cardList; + while(entry) + { + if(entry->id == id) + { + return entry; + } + else + { + entry = entry->next; + } + + } + return NULL; +} + static int patch_nvidia_rom(uint8_t *rom) { if (!rom || (rom[0] != 0x55 && rom[1] != 0xaa)) { @@ -1140,33 +1184,41 @@ return (has_lvds ? PATCH_ROM_SUCCESS_HAS_LVDS : PATCH_ROM_SUCCESS); } -static char *get_nvidia_model(uint32_t id) { +static void fill_card_list(void) +{ unsigned int i, count; TagPtr NVDIATag; - char *model_name = NULL, *match_id = NULL; - - // First check in the plist, (for e.g this can override any hardcoded devices) + char *model_name = NULL, *match_id = NULL, *vram_size = NULL; + if ((NVDIATag = XMLCastArray(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"NVIDIA")))) { count = XMLTagCount(NVDIATag); - + for (i=0; imodel) + { + return nvcard->model; + } } for (i=1; i< (sizeof(NVKnownChipsets) / sizeof(NVKnownChipsets[0])); i++) { @@ -1259,26 +1311,20 @@ return 0; } -unsigned long long mem_detect(volatile uint8_t *regs, uint8_t nvCardType, pci_dt_t *nvda_dev) +unsigned long long mem_detect(volatile uint8_t *regs, uint8_t nvCardType, pci_dt_t *nvda_dev, uint32_t id) { unsigned long long vram_size = 0; - if (nvCardType < NV_ARCH_50) + cardList_t * nvcard = FindCardWithId(id); + if (nvcard) { - vram_size = REG32(NV04_PFB_FIFO_DATA); - vram_size &= NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK; + if (nvcard->videoRam > 0) + { + vram_size = nvcard->videoRam * 1024 * 1024; + + return vram_size; + } } - else if (nvCardType < NV_ARCH_C0) - { - vram_size = 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); - } // Workaround for GT 420/430 & 9600M GT switch (nvda_dev->device_id) @@ -1294,6 +1340,25 @@ break; } + if (!vram_size) { + if (nvCardType < NV_ARCH_50) + { + vram_size = REG32(NV04_PFB_FIFO_DATA); + vram_size &= NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK; + } + else if (nvCardType < NV_ARCH_C0) + { + vram_size = 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); + } + } + return vram_size; } @@ -1327,6 +1392,8 @@ struct DevPropString *string = (struct DevPropString *)(uint32_t)get_env(envEFIString); + fill_card_list(); + static const dcfg_t default_dcfg [] = { {0xff,0xff,0xff,0xff}, }; @@ -1343,18 +1410,14 @@ delay(50); // get card type - nvCardType = (REG32(0) >> 20) & 0x1ff; - + nvCardType = (REG32(0) >> 20) & 0x1ff; + + model = get_nvidia_model((nvda_dev->vendor_id << 16) | nvda_dev->device_id); + // Amount of VRAM in kilobytes - videoRam = mem_detect(regs, nvCardType, nvda_dev); - - model = get_nvidia_model((nvda_dev->vendor_id << 16) | nvda_dev->device_id); - - verbose("nVidia %s %dMB NV%02x [%04x:%04x]\n", - model, (uint32_t)(videoRam / 1024 / 1024), - (REG32(0) >> 20) & 0x1ff, nvda_dev->vendor_id, nvda_dev->device_id); - + videoRam = mem_detect(regs, nvCardType, nvda_dev, (nvda_dev->vendor_id << 16) | nvda_dev->device_id); + rom = malloc(NVIDIA_ROM_SIZE); if (!rom) { printf("Couldn't allocate momory for device rom\n"); @@ -1429,6 +1492,11 @@ if (rom_pci_header->device != nvda_dev->device_id) { // Get Model from the OpROM model = get_nvidia_model((rom_pci_header->vendor << 16) | rom_pci_header->device); + + // Amount of VRAM in kilobytes + + videoRam = mem_detect(regs, nvCardType, nvda_dev, (rom_pci_header->vendor << 16) | rom_pci_header->device); + } else { printf("nVidia incorrect PCI ROM signature: 0x%x\n", rom_pci_header->signature); // ?? @@ -1436,7 +1504,9 @@ //return false; } } - DBG("nvidia model : %s\n",model); + verbose("nVidia %s %dMB NV%02x [%04x:%04x]\n", + model, (uint32_t)(videoRam / 1024 / 1024), + (REG32(0) >> 20) & 0x1ff, nvda_dev->vendor_id, nvda_dev->device_id); if (!string) { Index: branches/cparm/i386/modules/ACPICodec/acpi_codec.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 2015) +++ branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 2016) @@ -46,10 +46,10 @@ #include "platform.h" #include "cpu.h" #include "xml.h" -#include "pci_root.h" #include "sl.h" #include "convert.h" #include "modules.h" +#include "pci.h" U64 rsd_p; ACPI_TABLES acpi_tables; Index: branches/cparm/i386/modules/ACPICodec/ACPICodec.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/ACPICodec.c (revision 2015) +++ branches/cparm/i386/modules/ACPICodec/ACPICodec.c (revision 2016) @@ -6,7 +6,6 @@ #include "libsaio.h" #include "modules.h" #include "bootstruct.h" -#include "pci_root.h" #include "acpi_codec.h" void ACPICodec_start(void); Index: branches/cparm/xcode3_sym.zip =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream