Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 1713) +++ branches/cparm/CHANGES (revision 1714) @@ -1,3 +1,4 @@ +- Added an option to the check Oem revision of aml files (by adler32 of unique machine id or adler32 of motherboard model), can be useful with multiple machines (a command line tool able to patch the aml files will be available soon) - Improved smbios support for some Intel Xeon models - BETA : Sync'd ati engine with the trunk Index: branches/cparm/i386/libsaio/hfs.c =================================================================== --- branches/cparm/i386/libsaio/hfs.c (revision 1713) +++ branches/cparm/i386/libsaio/hfs.c (revision 1714) @@ -76,6 +76,9 @@ #endif /* !__i386__ */ +unsigned long HFSLoadVerbose = 1; + + static long ReadFile(void *file, uint64_t *length, void *base, uint64_t offset); static long GetCatalogEntryInfo(void *entry, long *flags, long *time, FinderInfo *finderInfo, long *infoValid); @@ -300,9 +303,14 @@ } getDeviceDescription(ih, devStr); - verbose("Read HFS%s file: [%s/%s] %d bytes.\n", - (gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length); + if (HFSLoadVerbose) { + verbose("Read HFS%s file: [%s/%s] %d bytes.\n", + (gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length); + } else if (HFSLoadVerbose == 0) { + HFSLoadVerbose = 1; + } + return length; } Index: branches/cparm/i386/libsaio/Makefile =================================================================== --- branches/cparm/i386/libsaio/Makefile (revision 1713) +++ branches/cparm/i386/libsaio/Makefile (revision 1714) @@ -43,14 +43,20 @@ device_inject.o pci_root.o \ convert.o acpi_tools.o smbios.o smp-imps.o -# example for acpicodec -#CFLAGS += acpi_codec.o acpicode.o ACPICodec.o acpidecode.o +# example for AcpiCodec +#SAIO_OBJS += acpi_codec.o acpicode.o ACPICodec.o acpidecode.o +# example for AcpiPatcher +#SAIO_OBJS += aml_generator.o acpi_patcher.o AcpiPatcher.o + +# example for GE +#SAIO_OBJS += nvidia.o ati.o gma.o GraphicsEnabler.o + # example for SMBiosGetters -#CFLAGS += mysmbios.o smbios_decode.o smbios_getters.o SMBiosGetters.o +#SAIO_OBJS += mysmbios.o smbios_decode.o smbios_getters.o SMBiosGetters.o # example for GUI -#CFLAGS += graphic_utils.o gui.o rand.o picopng.o GUI_module.o +#SAIO_OBJS += graphic_utils.o gui.o picopng.o GUI_module.o # Options enabled by default: #CFLAGS += -DNO_WIN_SUPPORT # -7200 bytes @@ -94,7 +100,7 @@ #SIG = $(SYMROOT)/sig -all embedtheme: $(DIRS_NEEDED) libsaio.h $(LIBS) +all embedtheme: $(DIRS_NEEDED) libsaio.h embedded.h $(LIBS) #libsaio_static.a: $(SAIO_OBJS) # rm -f $(SYMROOT)/$@ @@ -114,6 +120,9 @@ ar q $(SYMROOT)/$(@F) $^ ranlib $(SYMROOT)/$(@F) +embedded.h: + @cd $(SYMROOT)/../../doc && xxd -i BootHelp.txt > $(SYMROOT)/embedded.h + #saio_internal.h: saio_external.h #saio_table.c: saio_external.h #saio_defs.h: saio_external.h Index: branches/cparm/i386/libsaio/SMBIOS.h =================================================================== --- branches/cparm/i386/libsaio/SMBIOS.h (revision 1713) +++ branches/cparm/i386/libsaio/SMBIOS.h (revision 1714) @@ -37,6 +37,7 @@ #define thePlatformName 1 #define theProducBoard 2 extern int readSMBIOS(int value); // value copied into the platform structure +extern char* readDefaultPlatformName(void); #define SMBIOS_RANGE_START 0x000F0000 #define SMBIOS_RANGE_END 0x000FFFFF Index: branches/cparm/i386/libsaio/sl.h =================================================================== --- branches/cparm/i386/libsaio/sl.h (revision 1713) +++ branches/cparm/i386/libsaio/sl.h (revision 1714) @@ -62,6 +62,7 @@ extern void * gFSLoadAddress; extern cpu_type_t archCpuType; +extern unsigned long HFSLoadVerbose; cpu_type_t detectCpuType (); #endif /* !__LIBSAIO_SL_H */ Index: branches/cparm/i386/libsaio/smbios.c =================================================================== --- branches/cparm/i386/libsaio/smbios.c (revision 1713) +++ branches/cparm/i386/libsaio/smbios.c (revision 1714) @@ -49,6 +49,55 @@ return orig; } +/* get product Name from original SMBIOS */ +char* readDefaultPlatformName(void) +{ + + SMBEntryPoint *eps = getSmbiosOriginal(); + if (eps == NULL) return NULL; + + uint8_t *structPtr = (uint8_t *)eps->dmi.tableAddress; + SMBStructHeader *structHeader = (SMBStructHeader *)structPtr; + + for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));) + { + switch (structHeader->type) + { + case kSMBTypeSystemInformation: + { + uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length; + uint8_t field = ((SMBSystemInformation *)structHeader)->productName; + + if (!field) + return NULL; + + for (field--; field != 0 && strlen((char *)stringPtr) > 0; + field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1)); + + //DBG("original SMBIOS Product name: %s\n",(char *)stringPtr); + if (stringPtr) + return (char *)stringPtr; + else + return NULL; + + break; + } + default: + break; + + } + + structPtr = (uint8_t *)((uint32_t)structHeader + structHeader->length); + for (; ((uint16_t *)structPtr)[0] != 0; structPtr++); + + if (((uint16_t *)structPtr)[0] == 0) + structPtr += 2; + + structHeader = (SMBStructHeader *)structPtr; + } + return NULL; +} + /* get UUID or product Name from original SMBIOS, stripped version of kabyl's readSMBIOSInfo */ int readSMBIOS(int value) { Index: branches/cparm/i386/libsaio/fake_efi.c =================================================================== --- branches/cparm/i386/libsaio/fake_efi.c (revision 1713) +++ branches/cparm/i386/libsaio/fake_efi.c (revision 1714) @@ -511,12 +511,14 @@ static const char const FIRMWARE_DEV_PROP[] = "firmware-maintener"; static const char const FIRMWARE_PUBLISH_PROP[] = "firmware-publisher"; + static const char const FIRMWARE_ABI_32_PROP_VALUE[] = "EFI32"; static const char const FIRMWARE_ABI_64_PROP_VALUE[] = "EFI64"; static const char const SYSTEM_ID_PROP[] = "system-id"; static const char const SYSTEM_SERIAL_PROP[] = "SystemSerialNumber"; static const char const SYSTEM_TYPE_PROP[] = "system-type"; static const char const MODEL_PROP[] = "Model"; +static const char const MOTHERBOARD_NAME_PROP[] = "motherboard-name"; /* @@ -788,6 +790,16 @@ DT__AddProperty(efiNode, FIRMWARE_DEV_PROP, strlen(FIRMWARE_MAINTENER)+1, FIRMWARE_MAINTENER); DT__AddProperty(efiNode, FIRMWARE_PUBLISH_PROP, strlen(FIRMWARE_PUBLISHER)+1, FIRMWARE_PUBLISHER); + { + // Export it for later use + char * DefaultPlatform = readDefaultPlatformName(); + if (DefaultPlatform) + { + DT__AddProperty(efiNode, MOTHERBOARD_NAME_PROP, strlen(DefaultPlatform)+1, DefaultPlatform); + } + + } + // Set up the /efi/configuration-table node which will eventually have several child nodes for // all of the configuration tables needed by various kernel extensions. gEfiConfigurationTableNode = DT__AddChild(efiNode, "configuration-table"); Index: branches/cparm/i386/modules/ACPICodec/acpi_codec.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 1713) +++ branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 1714) @@ -54,6 +54,7 @@ U64 rsd_p; ACPI_TABLES acpi_tables; U32 uuid32; +U32 Model32; bool checkOem = false; #ifndef DEBUG_ACPI @@ -90,14 +91,15 @@ #endif static ACPI_TABLE_HEADER * get_new_table_in_list(U32 *new_table_list, U32 Signature, U8 *retIndex ); +static U8 get_number_of_tables_in_list(U32 *new_table_list, U32 Signature ); static U8 get_0ul_index_in_list(U32 *new_table_list, bool reserved ); static void sanitize_new_table_list(U32 *new_table_list ); static void move_table_list_to_kmem(U32 *new_table_list ); static ACPI_TABLE_RSDP * gen_alloc_rsdp_v2_from_v1(ACPI_TABLE_RSDP *rsdp ); static ACPI_TABLE_RSDT * gen_alloc_rsdt_from_xsdt(ACPI_TABLE_XSDT *xsdt); static ACPI_TABLE_XSDT * gen_alloc_xsdt_from_rsdt(ACPI_TABLE_RSDT *rsdt); -static void MakeUuidAdler32(void); -static void *loadACPITable(char *dirspec, char *filename ); +static void MakeAcpiSgn(void); +static void *loadACPITable(U32 *new_table_list, char *dirspec, char *filename ); static int generate_cpu_map_from_acpi(ACPI_TABLE_DSDT * DsdtPointer); static ACPI_GENERIC_ADDRESS FillGASStruct(U32 Address, U8 Length); static U32 process_xsdt (ACPI_TABLE_RSDP *rsdp_mod , U32 *new_table_list); @@ -248,6 +250,22 @@ return (void*)0ul; } +static U8 get_number_of_tables_in_list(U32 *new_table_list, U32 Signature ) +{ + ACPI_TABLE_HEADER **table_array = (ACPI_TABLE_HEADER **) new_table_list; + U8 index ; + U8 InstalledTables = 0; + + for (index = 0; index < (MAX_ACPI_TABLE + RESERVED_AERA); index++) + { + if (*(U32 *) (table_array[index]->Signature) == Signature) + { + InstalledTables++ ; + } + } + return InstalledTables; +} + static U8 get_0ul_index_in_list(U32 *new_table_list, bool reserved ) { U8 index ; @@ -540,8 +558,17 @@ return xsdt_conv; } -static void MakeUuidAdler32(void) +static void MakeAcpiSgn(void) { + + char * DefaultplatformName = NULL; + Model32 = 0; + + if (DefaultplatformName = readDefaultPlatformName()) + { + Model32 = OSSwapHostToBigInt32(adler32( (unsigned char *) DefaultplatformName, strlen(DefaultplatformName))); + } + uuid32 = 0; const char *uuidStr = getStringFromUUID(Platform->sysid); @@ -553,7 +580,7 @@ } -static void *loadACPITable(char *dirspec, char *filename ) +static void *loadACPITable(U32 *new_table_list, char *dirspec, char *filename ) { int fd = -1; char acpi_file[512]; @@ -563,6 +590,7 @@ sprintf(acpi_file, "%s%s",dirspec, filename); + HFSLoadVerbose = 0; fd=open(acpi_file); if (fd<0) @@ -587,18 +615,57 @@ ACPI_TABLE_HEADER * header = (ACPI_TABLE_HEADER *)tableAddr; - if ((checkOem == true) && (header->OemRevision != uuid32) ) + if (*(U32*)(header->Signature) != NAMESEG("SSDT")) { - DBG("Bad signature aka Oem Revision (0x%08lx) for Aml file (%s), it should be 0x%08lx, file skipped !!\n", header->OemRevision, acpi_file, uuid32); + U8 dummy = 0; + if (get_new_table_in_list(new_table_list, *(U32*)(header->Signature), &dummy)) + { +#if DEBUG_ACPI + printf("Warning: A "); + print_nameseg(*(U32*) (header->Signature)); + printf(" Aml file is already loaded and registred, file skipped !!\n"); +#endif + free(tableAddr); + return (void*)0ul; + } + } + else + { + if (get_number_of_tables_in_list(new_table_list, NAMESEG("SSDT")) >= MAX_SSDT_TABLE) + { + DBG("Warning: Max number of SSDT aml files reached, file skipped !!\n"); + free(tableAddr); + return (void*)0ul; + } + } + + + if (checkOem == true) + { + if (header->OemRevision == Model32) + { + goto continue_loading; + } + + if (header->OemRevision == uuid32) + { + goto continue_loading; + } + + DBG("Bad signature aka Oem Revision (0x%08lx) for Aml file (%s), file skipped !!\n", header->OemRevision, acpi_file); + DBG("uuid32 (0x%08lx) , model32 (0x%08lx)\n", uuid32, Model32); + free(tableAddr); - return (void*)0ul; + return (void*)0ul; } +continue_loading: + if (GetChecksum(header, header->Length) == 0) { - DBG("Found valid AML file : %s", filename); - DBG(" ( %s ) read and stored at: %x", acpi_file, tableAddr); - DBG("\n"); + DBG("Found valid AML file : %s ", filename); + printf("[ %s ] read and stored at: %x", acpi_file, tableAddr); + printf("\n"); return tableAddr; } else @@ -609,10 +676,12 @@ return (void*)0ul; } } + else + { + printf("Couldn't allocate memory for table %s\n", acpi_file); + close (fd); + } - printf("Couldn't allocate memory for table %s\n", acpi_file); - close (fd); - return (void *)0ul ; } @@ -2105,7 +2174,7 @@ } */ - bool sta = BuildCoreIPstateInfo(cpu); + U32 sta = BuildCoreIPstateInfo(cpu); if (sta) { DBG("_PSS PGK generated successfully\n"); @@ -2892,9 +2961,9 @@ ACPI_MADT_LOCAL_APIC_NMI *nmi = current; current = nmi + 1; /* - if (!(nmi->IntiFlags & ACPI_MADT_ENABLED)) - continue; - */ + if (!(nmi->IntiFlags & ACPI_MADT_ENABLED)) + continue; + */ if (LOCAL_APIC_NMI_CNT >= nb_cpu) continue; @@ -2927,9 +2996,9 @@ ACPI_MADT_LOCAL_SAPIC *sapic = current; current = sapic + 1; /* - if (!(sapic->LapicFlags & ACPI_MADT_ENABLED)) - continue; - */ + if (!(sapic->LapicFlags & ACPI_MADT_ENABLED)) + continue; + */ if (LOCAL_SAPIC_CNT >= nb_cpu) continue; @@ -2962,9 +3031,9 @@ ACPI_MADT_INTERRUPT_SOURCE *intsrc = current; current = intsrc + 1; /* - if (!(intsrc->IntiFlags & ACPI_MADT_ENABLED)) - continue; - */ + if (!(intsrc->IntiFlags & ACPI_MADT_ENABLED)) + continue; + */ if (INT_SRC_CNT >= nb_cpu) continue; @@ -5346,7 +5415,7 @@ { if (checkOem == true) { - MakeUuidAdler32(); + MakeAcpiSgn(); } struct dirstuff* moduleDir = opendir(dirspec); @@ -5368,7 +5437,7 @@ } DBG("* Attempting to load acpi table: %s\n", name); - if ( (new_table_list[i]=(U32)loadACPITable(dirspec,name))) + if ( (new_table_list[i]=(U32)loadACPITable(new_table_list,dirspec,name))) { if (i < MAX_ACPI_TABLE) {