Index: branches/cparm/i386/libsaio/convert.c =================================================================== --- branches/cparm/i386/libsaio/convert.c (revision 1703) +++ branches/cparm/i386/libsaio/convert.c (revision 1704) @@ -10,7 +10,7 @@ /** Transform a 16 bytes hexadecimal value UUID to a string */ const char * getStringFromUUID(const EFI_CHAR8* eUUID) { - static char msg[UUID_LEN*2 + 8] = ""; + static char msg[UUID_STR_LEN] = ""; if (!eUUID) return ""; const unsigned char * uuid = (unsigned char*) eUUID; sprintf(msg, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", Index: branches/cparm/i386/libsaio/convert.h =================================================================== --- branches/cparm/i386/libsaio/convert.h (revision 1703) +++ branches/cparm/i386/libsaio/convert.h (revision 1704) @@ -11,6 +11,8 @@ #define UUID_LEN 16 +#define UUID_STR_LEN UUID_LEN*2 + 8 + const char * getStringFromUUID(const EFI_CHAR8* uuid); EFI_CHAR8* getUUIDFromString(const char *source); void *convertHexStr2Binary(const char *hexStr, int *outLength); Index: branches/cparm/i386/boot2/boot.c =================================================================== --- branches/cparm/i386/boot2/boot.c (revision 1703) +++ branches/cparm/i386/boot2/boot.c (revision 1704) @@ -162,6 +162,14 @@ } #endif +#if 0 +static inline void exception_error(char *msg, int nb) +{ + printf("\r\nException number = %d\r\nmessage = %s\r\n\r\n", nb, msg); + asm volatile ("hlt"); +} +#endif + //========================================================================== //Initializes the runtime. Right now this means zeroing the BSS and initializing malloc. // @@ -169,6 +177,9 @@ { zeroBSS(); malloc_init(0, 0, 0, malloc_error); +#if 0 + exception_init(exception_error); +#endif } //========================================================================== @@ -178,7 +189,7 @@ { entry_t kernelEntry; int ret; - + bootArgs->kaddr = bootArgs->ksize = 0; if(gMacOSVersion[3] <= '6') Index: branches/cparm/i386/modules/ACPICodec/acpi_codec.h =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpi_codec.h (revision 1703) +++ branches/cparm/i386/modules/ACPICodec/acpi_codec.h (revision 1704) @@ -49,6 +49,8 @@ #define kUpdateACPI "UpdateACPI" /* acpi_codec.c */ #define kUnsafeACPI "UnsafeACPI" /* acpi_codec.c */ //desactive some safe checks that may stop the boot process on some configurations( temporary option ) +#define kOnlySignedAml "LoadSignedAmlOnly" /* acpi_codec.c */ + #if UNUSED #define kGenerateFACS "GenerateFACS" /* acpi_codec.c */ #define kOEMFACS "oemFACS" /* acpi_codec.c */ Index: branches/cparm/i386/modules/ACPICodec/acpi_codec.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 1703) +++ branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 1704) @@ -49,9 +49,12 @@ #include "xml.h" #include "pci_root.h" #include "sl.h" +#include "convert.h" U64 rsd_p; ACPI_TABLES acpi_tables; +U32 uuid32; +bool checkOem = false; #ifndef DEBUG_ACPI #define DEBUG_ACPI 0 @@ -93,6 +96,7 @@ 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 int generate_cpu_map_from_acpi(ACPI_TABLE_DSDT * DsdtPointer); static ACPI_GENERIC_ADDRESS FillGASStruct(U32 Address, U8 Length); @@ -536,6 +540,19 @@ return xsdt_conv; } +static void MakeUuidAdler32(void) +{ + uuid32 = 0; + + const char *uuidStr = getStringFromUUID(Platform->sysid); + + if (strlen(uuidStr)) + { + uuid32 = OSSwapHostToBigInt32(adler32( (unsigned char *) uuidStr, UUID_STR_LEN )); + } + +} + static void *loadACPITable(char *dirspec, char *filename ) { int fd = -1; @@ -568,8 +585,15 @@ close (fd); - ACPI_TABLE_HEADER * header = (ACPI_TABLE_HEADER *)tableAddr; + ACPI_TABLE_HEADER * header = (ACPI_TABLE_HEADER *)tableAddr; + if ((checkOem == true) && (header->OemRevision != uuid32) ) + { + 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); + free(tableAddr); + return (void*)0ul; + } + if (GetChecksum(header, header->Length) == 0) { DBG("Found valid AML file : %s", filename); @@ -5277,6 +5301,7 @@ #if BUILD_ACPI_TSS gen_tsta=(U32)getBoolForKey(kGenerateTStates, &tmpval, &bootInfo->bootConfig)&&tmpval; #endif + checkOem=getBoolForKey(kOnlySignedAml, &tmpval, &bootInfo->bootConfig)&&tmpval; } { @@ -5319,10 +5344,15 @@ if (acpidir_found == true) { + if (checkOem == true) + { + MakeUuidAdler32(); + } + struct dirstuff* moduleDir = opendir(dirspec); while(readdir(moduleDir, (const char**)&name, &flags, &time) >= 0) { - if((strcmp(&name[strlen(name) - sizeof("aml")], ".aml") == 0) && ((strlen(dirspec)+strlen(name)) < 512)) + if((strstr(name, ".aml")) && ((strlen(dirspec)+strlen(name)) < 512)) { // Some simple verifications to save time in case of those tables simply named as follow: if ((strncmp(name, "RSDT", 4) == 0) || (strncmp(name, "rsdt", 4) == 0) || @@ -5346,6 +5376,7 @@ } else { + DBG("Max nb of allowed aml files reached, exiting ."); break; } } @@ -5354,7 +5385,8 @@ #if DEBUG_ACPI else { - DBG("Ignoring %s\n", name); + + printf("Ignoring %s\n", name); } #endif Index: branches/cparm/i386/libsa/libsa.h =================================================================== --- branches/cparm/i386/libsa/libsa.h (revision 1703) +++ branches/cparm/i386/libsa/libsa.h (revision 1704) @@ -31,6 +31,9 @@ #include #include #include +#if 0 +#include "C_Exception.h" +#endif /* * ctype stuff (aserebln) @@ -165,6 +168,11 @@ extern void srand (unsigned int seed); +/* + * C_Exception.c + * + */ +extern void exception_init (void (*exception_err_fn)(char *, int)); /* * getsegbyname.c Index: branches/cparm/i386/libsa/Makefile =================================================================== --- branches/cparm/i386/libsa/Makefile (revision 1703) +++ branches/cparm/i386/libsa/Makefile (revision 1704) @@ -26,7 +26,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -SA_OBJS = prf.o printf.o zalloc.o \ +SA_OBJS = prf.o printf.o zalloc.o\ string.o strtol.o error.o \ setjmp.o qsort.o efi_tables.o