Index: branches/cparm/doc/ModuleHelp.txt =================================================================== --- branches/cparm/doc/ModuleHelp.txt (revision 2009) +++ branches/cparm/doc/ModuleHelp.txt (revision 2010) @@ -17,6 +17,22 @@ 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 + + + Chipset Name + Quadro FX 380 + IOPCIPrimaryMatch + 0x10DE0658 + + . + . + . + . + + Networking module: ----------------- EnableNetworkModule=Yes|No Fully enable/disable the Networking module (Enabled by default, if the module is installed) Index: branches/cparm/Chameleon.xcodeproj/project.pbxproj =================================================================== --- branches/cparm/Chameleon.xcodeproj/project.pbxproj (revision 2009) +++ branches/cparm/Chameleon.xcodeproj/project.pbxproj (revision 2010) @@ -9,6 +9,23 @@ /* Begin PBXFileReference section */ AB0E930C14C6223500F798D7 /* cpu_intel_amd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpu_intel_amd.c; sourceTree = ""; }; AB22095D15334C9E00AA9851 /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = ""; }; + AB30EB4615AD7D3E000ACA09 /* acpi_codec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpi_codec.c; sourceTree = ""; }; + AB30EB4715AD7D3E000ACA09 /* acpi_codec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpi_codec.h; sourceTree = ""; }; + AB30EB4815AD7D3E000ACA09 /* acpicode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpicode.c; sourceTree = ""; }; + AB30EB4915AD7D3E000ACA09 /* acpicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpicode.h; sourceTree = ""; }; + AB30EB4A15AD7D3E000ACA09 /* ACPICodec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ACPICodec.c; sourceTree = ""; }; + AB30EB4B15AD7D3E000ACA09 /* acpidecode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpidecode.c; sourceTree = ""; }; + AB30EB4C15AD7D3E000ACA09 /* acpidecode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpidecode.h; sourceTree = ""; }; + AB30EB4D15AD7D3E000ACA09 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; + AB30EB4E15AD7DC6000ACA09 /* AcpiAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AcpiAdditions.h; sourceTree = ""; }; + AB30EB4F15AD7E77000ACA09 /* portable_efi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = portable_efi.h; sourceTree = ""; }; + AB30EB5815AD8399000ACA09 /* Acpi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi.h; sourceTree = ""; }; + AB30EB5915AD8399000ACA09 /* Acpi10.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi10.h; sourceTree = ""; }; + AB30EB5A15AD8399000ACA09 /* Acpi20.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi20.h; sourceTree = ""; }; + AB30EB5B15AD8399000ACA09 /* Acpi30.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi30.h; sourceTree = ""; }; + AB30EB5C15AD8399000ACA09 /* Acpi40.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi40.h; sourceTree = ""; }; + AB30EB5D15AD8399000ACA09 /* Acpi50.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi50.h; sourceTree = ""; }; + AB30EB5E15AD8399000ACA09 /* AcpiAml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AcpiAml.h; sourceTree = ""; }; AB42D02115187F2C0078E84A /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = ""; }; AB42D02215187F2C0078E84A /* boot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = boot.png; sourceTree = ""; }; AB42D02315187F2C0078E84A /* device_cdrom.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = device_cdrom.png; sourceTree = ""; }; @@ -625,6 +642,38 @@ name = Chameleon; sourceTree = ""; }; + AB30EB4515AD7D3E000ACA09 /* ACPICodecV2 */ = { + isa = PBXGroup; + children = ( + AB30EB5715AD8398000ACA09 /* IndustryStandard */, + AB30EB4E15AD7DC6000ACA09 /* AcpiAdditions.h */, + AB30EB4615AD7D3E000ACA09 /* acpi_codec.c */, + AB30EB4715AD7D3E000ACA09 /* acpi_codec.h */, + AB30EB4815AD7D3E000ACA09 /* acpicode.c */, + AB30EB4915AD7D3E000ACA09 /* acpicode.h */, + AB30EB4A15AD7D3E000ACA09 /* ACPICodec.c */, + AB30EB4B15AD7D3E000ACA09 /* acpidecode.c */, + AB30EB4C15AD7D3E000ACA09 /* acpidecode.h */, + AB30EB4D15AD7D3E000ACA09 /* Makefile */, + AB30EB4F15AD7E77000ACA09 /* portable_efi.h */, + ); + path = ACPICodecV2; + sourceTree = ""; + }; + AB30EB5715AD8398000ACA09 /* IndustryStandard */ = { + isa = PBXGroup; + children = ( + AB30EB5815AD8399000ACA09 /* Acpi.h */, + AB30EB5915AD8399000ACA09 /* Acpi10.h */, + AB30EB5A15AD8399000ACA09 /* Acpi20.h */, + AB30EB5B15AD8399000ACA09 /* Acpi30.h */, + AB30EB5C15AD8399000ACA09 /* Acpi40.h */, + AB30EB5D15AD8399000ACA09 /* Acpi50.h */, + AB30EB5E15AD8399000ACA09 /* AcpiAml.h */, + ); + path = IndustryStandard; + sourceTree = ""; + }; AB42D02015187F2C0078E84A /* embed */ = { isa = PBXGroup; children = ( @@ -1074,6 +1123,7 @@ isa = PBXGroup; children = ( AB43B34914C37E520018D529 /* ACPICodec */, + AB30EB4515AD7D3E000ACA09 /* ACPICodecV2 */, AB43B35214C37E520018D529 /* ACPIPatcher */, AB43B35914C37E520018D529 /* CPUfreq */, ABA02704156CE81A00F8E5F3 /* Ext2fs */, Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 2009) +++ branches/cparm/CHANGES (revision 2010) @@ -1,3 +1,6 @@ +- 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 + - Fixed a bug in the bundle dependency dispatcher - security fixes in printf.c Index: branches/cparm/i386/libsaio/smbios.c =================================================================== --- branches/cparm/i386/libsaio/smbios.c (revision 2009) +++ branches/cparm/i386/libsaio/smbios.c (revision 2010) @@ -1,52 +1,108 @@ +/*- + * Copyright (c) 2005-2009 Jung-uk Kim + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* + * Detect SMBIOS and export information about the SMBIOS into the + * environment. + * + * System Management BIOS Reference Specification, v2.6 Final + * http://www.dmtf.org/standards/published_documents/DSP0134_2.6.0.pdf + */ +/* + * 2.1.1 SMBIOS Structure Table Entry Point + * + * "On non-EFI systems, the SMBIOS Entry Point structure, described below, can + * be located by application software by searching for the anchor-string on + * paragraph (16-byte) boundaries within the physical memory address range + * 000F0000h to 000FFFFFh. This entry point encapsulates an intermediate anchor + * string that is used by some existing DMI browsers." + */ + #include "libsaio.h" #include "SMBIOS.h" #include "Platform.h" -static const char * const SMTAG = "_SM_"; -static const char* const DMITAG= "_DMI_"; -static struct SMBEntryPoint *getAddressOfSmbiosTable(void); +#define SMBIOS_START 0xf0000 +#define SMBIOS_LENGTH 0x10000 +#define SMBIOS_STEP 0x10 +#define SMBIOS_SIG "_SM_" +#define SMBIOS_DMI_SIG "_DMI_" -static struct SMBEntryPoint *getAddressOfSmbiosTable(void) +#define SMBIOS_GET8(base, off) (*(uint8_t *)((base) + (off))) +#define SMBIOS_GET16(base, off) (*(uint16_t *)((base) + (off))) +#define SMBIOS_GET32(base, off) (*(uint32_t *)((base) + (off))) + +#define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01) +#define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base)) + +typedef char* caddr_t; + +static uint8_t +smbios_checksum(const caddr_t addr, const uint8_t len) { - struct SMBEntryPoint *smbios; - /* - * The logic is to start at 0xf0000 and end at 0xfffff iterating 16 bytes at a time looking - * for the SMBIOS entry-point structure anchor (literal ASCII "_SM_"). - */ - smbios = (struct SMBEntryPoint*) SMBIOS_RANGE_START; - while (smbios <= (struct SMBEntryPoint *)SMBIOS_RANGE_END) - { - if (COMPARE_DWORD(smbios->anchor, SMTAG) && - COMPARE_DWORD(smbios->dmi.anchor, DMITAG) && - smbios->dmi.anchor[4]==DMITAG[4] && - checksum8(smbios, sizeof(struct SMBEntryPoint)) == 0) - { - return ((void*)smbios); - } - smbios = (struct SMBEntryPoint*) ( ((char*) smbios) + 16 ); - } - printf("Error: Could not find original SMBIOS !!\n"); - pause(); - return NULL; + uint8_t sum; + int i; + + for (sum = 0, i = 0; i < len; i++) + sum += SMBIOS_GET8(addr, i); + return (sum); } +static caddr_t +smbios_sigsearch(const caddr_t addr, const uint32_t len) +{ + caddr_t cp; + + /* Search on 16-byte boundaries. */ + for (cp = addr; cp < addr + len; cp += SMBIOS_STEP) + if (strncmp(cp, SMBIOS_SIG, 4) == 0 && + smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 && + strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 && + smbios_checksum(cp + 0x10, 0x0f) == 0) + return (cp); + return (NULL); +} + struct SMBEntryPoint *getSmbiosOriginal() { - static struct SMBEntryPoint *orig = NULL; // cached + static caddr_t smbios = NULL; // cached - if (orig == NULL) + if (smbios == NULL) { - orig = getAddressOfSmbiosTable(); + /* Search signatures and validate checksums. */ + smbios = smbios_sigsearch((caddr_t)ptov(SMBIOS_START), SMBIOS_LENGTH); - if (orig) + if (smbios) { verbose("Found System Management BIOS (SMBIOS) table\n"); } } - return orig; + return (struct SMBEntryPoint *)smbios; } /* get product Name from original SMBIOS */ Index: branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.c =================================================================== --- branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.c (revision 2009) +++ branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.c (revision 2010) @@ -57,6 +57,19 @@ #define RSDP_CHECKSUM_LENGTH 20 +/* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */ +static uint8_t checksum8( void * start, unsigned int length ) +{ + uint8_t csum = 0; + uint8_t * cp = (uint8_t *) start; + unsigned int i; + + for ( i = 0; i < length; i++) + csum += *cp++; + + return csum; +} + /*- * FOR biosacpi_search_rsdp AND biosacpi_find_rsdp * Index: branches/cparm/i386/modules/GraphicsEnabler/nvidia.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 2009) +++ branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 2010) @@ -54,6 +54,7 @@ #include "platform.h" #include "device_inject.h" #include "nvidia.h" +#include "xml.h" #ifndef DEBUG_NVIDIA #define DEBUG_NVIDIA 0 @@ -90,7 +91,6 @@ #define NVCAP_LEN ( sizeof(default_NVCAP) / sizeof(uint8_t) ) -//TODO: once the bundles will be implemented, add a plist reader so there will be no need anymore to hardcode the device ids of each cards, each one will be able to add his own device ids in the plist, it willl work great if the card is supported by the apple's drivers struct nv_chipsets_t NVKnownChipsets[] = { { 0x00000000, "Unknown" }, //======================================== @@ -1141,13 +1141,40 @@ } static char *get_nvidia_model(uint32_t id) { - unsigned int i; - + 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) + if ((NVDIATag = XMLCastArray(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"NVIDIA")))) + { + count = XMLTagCount(NVDIATag); + + for (i=0; i