Index: branches/slice/i386/libsaio/acpi_patcher.c =================================================================== --- branches/slice/i386/libsaio/acpi_patcher.c (revision 0) +++ branches/slice/i386/libsaio/acpi_patcher.c (revision 714) @@ -0,0 +1,1289 @@ +/* + * Copyright 2008 mackerintel + */ + +#include "libsaio.h" +#include "boot.h" +#include "bootstruct.h" +#include "acpi.h" +#include "efi_tables.h" +#include "fake_efi.h" +#include "acpi_patcher.h" +#include "platform.h" +#include "cpu.h" +#include "aml_generator.h" +#include "smbios_patcher.h" + +#ifndef DEBUG_ACPI +#define DEBUG_ACPI 0 +#endif + +#if DEBUG_ACPI==2 +#define DBG(x...) {printf(x); sleep(1);} +#elif DEBUG_ACPI==3 +#define DBG(x...) verbose(x) +#elif DEBUG_ACPI==1 +#define DBG(x...) msglog(x) +#else +#define DBG(x...) +#endif + +bool fix_restart; +uint64_t acpi10_p; +uint64_t acpi20_p; + +int rsdplength; +void *new_dsdt=NULL; + +extern char* gSMBIOSBoardModel; + +// Slice: New signature compare function +boolean_t tableSign(char *table, const char *sgn) +{ + int i; + for (i=0; i<4; i++) { + if ((table[i] &~0x20) != (sgn[i] &~0x20)) { + return false; + } + } + return true; +} + +char st[20]; +char * FourChar(char * s) +{ + int i; + for(i=0; i<4;i++){ + st[i] = (isalpha(s[i])?s[i]:'.'); + } + // strncpy(st, s, 4); + st[4] = '\0'; + return st; +} + + +/* Gets the ACPI 1.0 RSDP address */ +static struct acpi_2_rsdp* getAddressOfAcpiTable() +{ + /* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */ + + void *acpi_addr = (void*)ACPI_RANGE_START; + for(; acpi_addr <= (void*)ACPI_RANGE_END; acpi_addr += 16) + { + if(*(uint64_t *)acpi_addr == ACPI_SIGNATURE_UINT64_LE) + { + uint8_t csum = checksum8(acpi_addr, 20); + if(csum == 0) + { + // Only return the table if it is a true version 1.0 table (Revision 0) + if(((struct acpi_2_rsdp*)acpi_addr)->Revision == 0) + return acpi_addr; + } + } + } + return NULL; +} + +/* Gets the ACPI 2.0 RSDP address */ +static struct acpi_2_rsdp* getAddressOfAcpi20Table() +{ + /* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */ + + void *acpi_addr = (void*)ACPI_RANGE_START; + for(; acpi_addr <= (void*)ACPI_RANGE_END; acpi_addr += 16) + { + if(*(uint64_t *)acpi_addr == ACPI_SIGNATURE_UINT64_LE) + { + uint8_t csum = checksum8(acpi_addr, 20); + + /* Only assume this is a 2.0 or better table if the revision is greater than 0 + * NOTE: ACPI 3.0 spec only seems to say that 1.0 tables have revision 1 + * and that the current revision is 2.. I am going to assume that rev > 0 is 2.0. + */ + + if(csum == 0 && (((struct acpi_2_rsdp*)acpi_addr)->Revision > 0)) + { + uint8_t csum2 = checksum8(acpi_addr, sizeof(struct acpi_2_rsdp)); + if(csum2 == 0) + return acpi_addr; + } + } + } + return NULL; +} +/** The folowing ACPI Table search algo. should be reused anywhere needed:*/ +int search_and_get_acpi_fd(const char * filename, const char ** outDirspec) +{ + int fd = -1; + char dirSpec[512] = ""; + + // Try finding 'filename' in the usual places + // Start searching any potential location for ACPI Table + + if(gSMBIOSBoardModel) + { + sprintf(dirSpec,"%s.%s", gSMBIOSBoardModel, filename); + fd = open(dirSpec, 0); + } + + if (fd < 0) + { + sprintf(dirSpec, "%s", filename); + fd = open(dirSpec, 0); + if (fd < 0) + { + if(gSMBIOSBoardModel) + { + sprintf(dirSpec, "/Extra/%s.%s", gSMBIOSBoardModel, filename); + fd = open(dirSpec, 0); + } + if (fd < 0) + { + sprintf(dirSpec, "/Extra/%s", filename); + fd = open(dirSpec, 0); + if (fd < 0) + { + if(gSMBIOSBoardModel) + { + sprintf(dirSpec, "bt(0,0)/Extra/%s.%s", gSMBIOSBoardModel, filename); + fd = open(dirSpec, 0); + } + if (fd < 0) + { + sprintf(dirSpec, "bt(0,0)/Extra/%s", filename); + fd = open(dirSpec, 0); + } + } + } + } + } + + if (fd < 0) + { + // NOT FOUND: + DBG("ACPI table not found: %s\n", filename); + *dirSpec = '\0'; + } + + if (outDirspec) *outDirspec = dirSpec; + return fd; +} + + +void *loadACPITable (const char * filename) +{ + void *tableAddr; + const char * dirspec=NULL; + + int fd = search_and_get_acpi_fd(filename, &dirspec); + + if (fd>=0) + { + tableAddr=(void*)AllocateKernelMemory(file_size (fd)); + if (tableAddr) + { + if (read (fd, tableAddr, file_size (fd))!=file_size (fd)) + { + verbose("Couldn't read table %s\n",dirspec); + free (tableAddr); + close (fd); + return NULL; + } + + DBG("Table %s read and stored at: %x\n", dirspec, tableAddr); + close (fd); + return tableAddr; + } + close (fd); + verbose("Couldn't allocate memory for table \n", dirspec); + } + //printf("Couldn't find table %s\n", filename); + return NULL; +} + +uint8_t acpi_cpu_count = 0; +char* acpi_cpu_name[32]; + +void get_acpi_cpu_names(unsigned char* dsdt, uint32_t length) +{ + uint32_t i; + + for (i=0; i> 6); + + bool add_name = true; + + uint8_t j; + + for (j=0; j<4; j++) + { + char c = dsdt[offset+j]; + + if (!aml_isvalidchar(c)) + { + add_name = false; + DBG("Invalid character found in ProcessorOP 0x%x!\n", c); + break; + } + } + + if (add_name) + { + acpi_cpu_name[acpi_cpu_count] = malloc(4); + memcpy(acpi_cpu_name[acpi_cpu_count], dsdt+offset, 4); + i = offset + 5; + + DBG("Found ACPI CPU: %c%c%c%c\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]); + + if (++acpi_cpu_count == 32) return; + } + } + } +} + +struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt) +{ + char ssdt_header[] = + { + 0x53, 0x53, 0x44, 0x54, 0xE7, 0x00, 0x00, 0x00, /* SSDT.... */ + 0x01, 0x17, 0x50, 0x6D, 0x52, 0x65, 0x66, 0x41, /* ..PmRefA */ + 0x43, 0x70, 0x75, 0x43, 0x73, 0x74, 0x00, 0x00, /* CpuCst.. */ + 0x00, 0x10, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* ....INTL */ + 0x31, 0x03, 0x10, 0x20 /* 1.._ */ + }; + + char cstate_resource_template[] = + { + 0x11, 0x14, 0x0A, 0x11, 0x82, 0x0C, 0x00, 0x7F, + 0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x79, 0x00 + }; + + if (Platform->CPU.Vendor != 0x756E6547) { + verbose ("Not an Intel platform: C-States will not be generated !!!\n"); + return NULL; + } + + if (fadt == NULL) { + verbose ("FACP not exists: C-States will not be generated !!!\n"); + return NULL; + } + + struct acpi_2_dsdt* dsdt = (void*)fadt->DSDT; + + if (dsdt == NULL) { + verbose ("DSDT not found: C-States will not be generated !!!\n"); + return NULL; + } + + if (acpi_cpu_count == 0) + get_acpi_cpu_names((void*)dsdt, dsdt->Length); + + if (acpi_cpu_count > 0) + { + bool c2_enabled = false; + bool c3_enabled = false; + bool c4_enabled = false; + + getBoolForKey(kEnableC2States, &c2_enabled, &bootInfo->bootConfig); + getBoolForKey(kEnableC3States, &c3_enabled, &bootInfo->bootConfig); + getBoolForKey(kEnableC4States, &c4_enabled, &bootInfo->bootConfig); + + c2_enabled = c2_enabled | (fadt->C2_Latency < 100); + c3_enabled = c3_enabled | (fadt->C3_Latency < 1000); + + unsigned char cstates_count = 1 + (c2_enabled ? 1 : 0) + (c3_enabled ? 1 : 0); + + struct aml_chunk* root = aml_create_node(NULL); + aml_add_buffer(root, ssdt_header, sizeof(ssdt_header)); // SSDT header + struct aml_chunk* scop = aml_add_scope(root, "\\_PR_"); + struct aml_chunk* name = aml_add_name(scop, "CST_"); + struct aml_chunk* pack = aml_add_package(name); + aml_add_byte(pack, cstates_count); + + struct aml_chunk* tmpl = aml_add_package(pack); + cstate_resource_template[11] = 0x00; // C1 + aml_add_buffer(tmpl, cstate_resource_template, sizeof(cstate_resource_template)); + aml_add_byte(tmpl, 0x01); // C1 + aml_add_byte(tmpl, 0x01); // Latency + aml_add_word(tmpl, 0x03e8); // Power + + // C2 + if (c2_enabled) + { + tmpl = aml_add_package(pack); + cstate_resource_template[11] = 0x10; // C2 + aml_add_buffer(tmpl, cstate_resource_template, sizeof(cstate_resource_template)); + aml_add_byte(tmpl, 0x02); // C2 + aml_add_byte(tmpl, fadt->C2_Latency); + aml_add_word(tmpl, 0x01f4); // Power + } + // C4 + if (c4_enabled) + { + tmpl = aml_add_package(pack); + cstate_resource_template[11] = 0x30; // C4 + aml_add_buffer(tmpl, cstate_resource_template, sizeof(cstate_resource_template)); + aml_add_byte(tmpl, 0x04); // C4 + aml_add_word(tmpl, fadt->C3_Latency / 2); // TODO: right latency for C4 + aml_add_byte(tmpl, 0xfa); // Power + } + else + // C3 + if (c3_enabled) + { + tmpl = aml_add_package(pack); + cstate_resource_template[11] = 0x20; // C3 + aml_add_buffer(tmpl, cstate_resource_template, sizeof(cstate_resource_template)); + aml_add_byte(tmpl, 0x03); // C3 + aml_add_word(tmpl, fadt->C3_Latency); + aml_add_word(tmpl, 0x015e); // Power + } + + + // Aliaces + int i; + for (i = 0; i < acpi_cpu_count; i++) + { + char name[9]; + sprintf(name, "_PR_%c%c%c%c", acpi_cpu_name[i][0], acpi_cpu_name[i][1], acpi_cpu_name[i][2], acpi_cpu_name[i][3]); + + scop = aml_add_scope(root, name); + aml_add_alias(scop, "CST_", "_CST"); + } + + aml_calculate_size(root); + + struct acpi_2_ssdt *ssdt = (struct acpi_2_ssdt *)AllocateKernelMemory(root->Size); + + aml_write_node(root, (void*)ssdt, 0); + + ssdt->Length = root->Size; + ssdt->Checksum = 0; + ssdt->Checksum = 256 - checksum8(ssdt, ssdt->Length); + + aml_destroy_node(root); + + //dumpPhysAddr("C-States SSDT content: ", ssdt, ssdt->Length); + + verbose ("SSDT with CPU C-States generated successfully\n"); + + return ssdt; + } + else + { + verbose ("ACPI CPUs not found: C-States not generated !!!\n"); + } + + return NULL; +} + +struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt) +{ + char ssdt_header[] = + { + 0x53, 0x53, 0x44, 0x54, 0x7E, 0x00, 0x00, 0x00, /* SSDT.... */ + 0x01, 0x6A, 0x50, 0x6D, 0x52, 0x65, 0x66, 0x00, /* ..PmRef. */ + 0x43, 0x70, 0x75, 0x50, 0x6D, 0x00, 0x00, 0x00, /* CpuPm... */ + 0x00, 0x30, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* .0..INTL */ + 0x31, 0x03, 0x10, 0x20, /* 1.._ */ + }; + cpuid_update_generic_info(); + if (Platform->CPU.Vendor != 0x756E6547) { + verbose ("Not an Intel platform: P-States will not be generated !!!\n"); + return NULL; + } + + if (!(Platform->CPU.Features & CPU_FEATURE_MSR)) { + verbose ("Unsupported CPU: P-States will not be generated !!!\n"); + return NULL; + } + + if (acpi_cpu_count == 0) + get_acpi_cpu_names((void*)dsdt, dsdt->Length); + + if (acpi_cpu_count > 0) + { + struct p_state initial, maximum, minimum, p_states[32]; + uint8_t p_states_count = 0; + + // Retrieving P-States, ported from code by superhai (c) + switch (Platform->CPU.Family) { + case 0x06: + { + switch (Platform->CPU.Model) + { + case CPU_MODEL_PENTIUM_M: // ? + case CPU_MODEL_YONAH: // Yonah + case CPU_MODEL_MEROM: // Merom + case CPU_MODEL_PENRYN: // Penryn + case CPU_MODEL_ATOM: // Intel Atom (45nm) + { + bool cpu_dynamic_fsb = false; + + if (rdmsr64(MSR_IA32_EXT_CONFIG) & (1 << 27)) + { + wrmsr64(MSR_IA32_EXT_CONFIG, (rdmsr64(MSR_IA32_EXT_CONFIG) | (1 << 28))); + delay(1); + cpu_dynamic_fsb = rdmsr64(MSR_IA32_EXT_CONFIG) & (1 << 28); + } + + bool cpu_noninteger_bus_ratio = (rdmsr64(MSR_IA32_PERF_STATUS) & (1ULL << 46)); + + initial.Control = rdmsr64(MSR_IA32_PERF_STATUS); + + maximum.Control = ((rdmsr64(MSR_IA32_PERF_STATUS) >> 32) & 0x1F3F) | (0x4000 * cpu_noninteger_bus_ratio); + maximum.CID = ((maximum.FID & 0x1F) << 1) | cpu_noninteger_bus_ratio; + + minimum.FID = ((rdmsr64(MSR_IA32_PERF_STATUS) >> 24) & 0x1F) | (0x80 * cpu_dynamic_fsb); + minimum.VID = ((rdmsr64(MSR_IA32_PERF_STATUS) >> 48) & 0x3F); + + if (minimum.FID == 0) + { + uint64_t msr; + uint8_t i; + // Probe for lowest fid + for (i = maximum.FID; i >= 0x6; i--) + { + msr = rdmsr64(MSR_IA32_PERF_CONTROL); + wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (i << 8) | minimum.VID); + intel_waitforsts(); + minimum.FID = (rdmsr64(MSR_IA32_PERF_STATUS) >> 8) & 0x1F; + delay(1); + } + + msr = rdmsr64(MSR_IA32_PERF_CONTROL); + wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (maximum.FID << 8) | maximum.VID); + intel_waitforsts(); + } + + if (minimum.VID == maximum.VID) + { + uint64_t msr; + uint8_t i; + // Probe for lowest vid + for (i = maximum.VID; i > 0xA; i--) + { + msr = rdmsr64(MSR_IA32_PERF_CONTROL); + wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (minimum.FID << 8) | i); + intel_waitforsts(); + minimum.VID = rdmsr64(MSR_IA32_PERF_STATUS) & 0x3F; + delay(1); + } + + msr = rdmsr64(MSR_IA32_PERF_CONTROL); + wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (maximum.FID << 8) | maximum.VID); + intel_waitforsts(); + } + + minimum.CID = ((minimum.FID & 0x1F) << 1) >> cpu_dynamic_fsb; + + // Sanity check + if (maximum.CID < minimum.CID) + { + DBG("Insane FID values!"); + p_states_count = 0; + } + else + { + // Finalize P-States + // Find how many P-States machine supports + p_states_count = maximum.CID - minimum.CID + 1; + + if (p_states_count > 32) + p_states_count = 32; + + uint8_t vidstep; + uint8_t i = 0, u, invalid = 0; + + vidstep = ((maximum.VID << 2) - (minimum.VID << 2)) / (p_states_count - 1); + + for (u = 0; u < p_states_count; u++) + { + i = u - invalid; + + p_states[i].CID = maximum.CID - u; + p_states[i].FID = (p_states[i].CID >> 1); + + if (p_states[i].FID < 0x6) + { + if (cpu_dynamic_fsb) + p_states[i].FID = (p_states[i].FID << 1) | 0x80; + } + else if (cpu_noninteger_bus_ratio) + { + p_states[i].FID = p_states[i].FID | (0x40 * (p_states[i].CID & 0x1)); + } + + if (i && p_states[i].FID == p_states[i-1].FID) + invalid++; + + p_states[i].VID = ((maximum.VID << 2) - (vidstep * u)) >> 2; + + uint32_t multiplier = p_states[i].FID & 0x1f; // = 0x08 + bool half = p_states[i].FID & 0x40; // = 0x01 + bool dfsb = p_states[i].FID & 0x80; // = 0x00 + uint32_t fsb = Platform->CPU.FSBFrequency / 1000000; // = 400 + uint32_t halffsb = (fsb + 1) >> 1; // = 200 + uint32_t frequency = (multiplier * fsb); // = 3200 + + p_states[i].Frequency = (frequency + (half * halffsb)) >> dfsb; // = 3200 + 200 = 3400 + } + + p_states_count -= invalid; + } + } break; + case CPU_MODEL_FIELDS: + case CPU_MODEL_DALES: + case CPU_MODEL_DALES_32NM: + case CPU_MODEL_NEHALEM: + case CPU_MODEL_NEHALEM_EX: + case CPU_MODEL_WESTMERE: + case CPU_MODEL_WESTMERE_EX: + { + maximum.Control = rdmsr64(MSR_IA32_PERF_STATUS) & 0xff; // Seems it always contains maximum multiplier value (with turbo, that's we need)... + minimum.Control = (rdmsr64(MSR_PLATFORM_INFO) >> 40) & 0xff; + + verbose("P-States: min 0x%x, max 0x%x\n", minimum.Control, maximum.Control); + + // Sanity check + if (maximum.Control < minimum.Control) + { + DBG("Insane control values!"); + p_states_count = 0; + } + else + { + uint8_t i; + p_states_count = 0; + + for (i = maximum.Control; i >= minimum.Control; i--) + { + p_states[p_states_count].Control = i; + p_states[p_states_count].CID = p_states[p_states_count].Control << 1; + p_states[p_states_count].Frequency = (Platform->CPU.FSBFrequency / 1000000) * i; + p_states_count++; + } + } + + break; + } + default: + verbose ("Unsupported CPU (0x%X): P-States not generated !!!\n", Platform->CPU.Family); + break; + } + } + } + + // Generating SSDT + if (p_states_count > 0) + { + int i; + + struct aml_chunk* root = aml_create_node(NULL); + aml_add_buffer(root, ssdt_header, sizeof(ssdt_header)); // SSDT header + struct aml_chunk* scop = aml_add_scope(root, "\\_PR_"); + struct aml_chunk* name = aml_add_name(scop, "PSS_"); + struct aml_chunk* pack = aml_add_package(name); + + for (i = 0; i < p_states_count; i++) + { + struct aml_chunk* pstt = aml_add_package(pack); + + aml_add_dword(pstt, p_states[i].Frequency); + aml_add_dword(pstt, 0x00000000); // Power + aml_add_dword(pstt, 0x0000000A); // Latency + aml_add_dword(pstt, 0x0000000A); // Latency + aml_add_dword(pstt, p_states[i].Control); + aml_add_dword(pstt, i+1); // Status + } + + // Add aliaces + for (i = 0; i < acpi_cpu_count; i++) + { + char name[9]; + sprintf(name, "_PR_%c%c%c%c", acpi_cpu_name[i][0], acpi_cpu_name[i][1], acpi_cpu_name[i][2], acpi_cpu_name[i][3]); + + scop = aml_add_scope(root, name); + aml_add_alias(scop, "PSS_", "_PSS"); + } + + aml_calculate_size(root); + + struct acpi_2_ssdt *ssdt = (struct acpi_2_ssdt *)AllocateKernelMemory(root->Size); + + aml_write_node(root, (void*)ssdt, 0); + + ssdt->Length = root->Size; + ssdt->Checksum = 0; + ssdt->Checksum = 256 - checksum8(ssdt, ssdt->Length); + + aml_destroy_node(root); + + //dumpPhysAddr("P-States SSDT content: ", ssdt, ssdt->Length); + + verbose ("SSDT with CPU P-States generated successfully\n"); + + return ssdt; + } + } + else + { + verbose ("ACPI CPUs not found: P-States not generated !!!\n"); + } + + return NULL; +} + +struct acpi_2_fadt *patch_fadt(struct acpi_2_fadt *fadt, struct acpi_2_dsdt *new_dsdt) +{ + extern void setupSystemType(); + + struct acpi_2_fadt *fadt_mod = NULL; + bool fadt_rev2_needed = false; +// bool fix_restart; + const char * value; + + // Restart Fix + if (Platform->CPU.Vendor == 0x756E6547) { /* Intel */ + fix_restart = true; + getBoolForKey(kRestartFix, &fix_restart, &bootInfo->bootConfig); + } else { + DBG ("Not an Intel platform: Restart Fix not applied !!!\n"); + fix_restart = false; + } + + if (fix_restart) fadt_rev2_needed = true; + + // Allocate new fadt table + if (fadt->Length < 0x84 && fadt_rev2_needed) + { + fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(0x84); + memcpy(fadt_mod, fadt, fadt->Length); + fadt_mod->Length = 0x84; + fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions) + } + else + { + fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length); + memcpy(fadt_mod, fadt, fadt->Length); + } + // Determine system type / PM_Model + if (fadt_mod && Platform->Type) { + fadt_mod->PM_Profile = Platform->Type; + } else if(fadt) + Platform->Type = fadt->PM_Profile; + else + Platform->Type = 1; + + //User override default value + if ( (value=getStringForKey(kSystemType, &bootInfo->bootConfig))!=NULL) + { + if (Platform->Type > 6) + { + if(fadt_mod->PM_Profile<=6) + Platform->Type = fadt_mod->PM_Profile; // get the fadt if correct + else + Platform->Type = 1; /* Set a fixed value (Desktop) */ + verbose("Error: system-type must be 0..6. Defaulting to %d !\n", Platform->Type); + } + else + Platform->Type = (unsigned char) strtoul(value, NULL, 10); + } + // Set PM_Profile from System-type if only user wanted this value to be forced + if (fadt_mod->PM_Profile != Platform->Type) + { + if (value) + { // user has overriden the SystemType so take care of it in FACP + DBG("FADT: changing PM_Profile from 0x%02x to 0x%02x\n", fadt_mod->PM_Profile, Platform->Type); + fadt_mod->PM_Profile = Platform->Type; + } + else + { // PM_Profile has a different value and no override has been set, so reflect the user value to ioregs + Platform->Type = fadt_mod->PM_Profile <= 6 ? fadt_mod->PM_Profile : 1; + } + } + // We now have to write the systemm-type in ioregs: we cannot do it before in setupDeviceTree() + // because we need to take care of facp original content, if it is correct. + setupSystemType(); + + // Patch FADT to fix restart + if (fix_restart) + { + fadt_mod->Flags|= 0x400; + fadt_mod->Reset_SpaceID = 0x01; // System I/O + fadt_mod->Reset_BitWidth = 0x08; // 1 byte + fadt_mod->Reset_BitOffset = 0x00; // Offset 0 + fadt_mod->Reset_AccessWidth = 0x01; // Byte access + fadt_mod->Reset_Address = 0x0cf9; // Address of the register + fadt_mod->Reset_Value = 0x06; // Value to write to reset the system + msglog("FADT: Restart Fix applied!\n"); + } + + // Patch DSDT Address if we have loaded DSDT.aml + if(new_dsdt) + { + DBG("DSDT: Old @%x,%x, ",fadt_mod->DSDT,fadt_mod->X_DSDT); + + // Insert old dsdt into the IORegistery + Node* node = DT__FindNode("/dsdt", false); + if(node == NULL) + { + // Only add if not already here + Node* node = DT__FindNode("/", false); + + if(node != NULL) + { + node = DT__AddChild(node, "dsdt"); + + struct acpi_2_dsdt *dsdt; + dsdt = (struct acpi_2_dsdt*) (fadt_mod->DSDT); + DT__AddProperty(node, "originaldsdt", (dsdt->Length + sizeof(struct acpi_2_dsdt) - 1), (void*)dsdt); /// Insert old dsdt. Length is header length (36) + dsdt length + + } + } + + fadt_mod->DSDT=(uint32_t)new_dsdt; + if ((uint32_t)(&(fadt_mod->X_DSDT))-(uint32_t)fadt_mod+8<=fadt_mod->Length) + fadt_mod->X_DSDT=(uint32_t)new_dsdt; + + DBG("New @%x,%x\n",fadt_mod->DSDT,fadt_mod->X_DSDT); + + DBG("FADT: Using custom DSDT!\n"); + } + + // Correct the checksum + fadt_mod->Checksum=0; + fadt_mod->Checksum=256-checksum8(fadt_mod,fadt_mod->Length); + + return fadt_mod; +} + +/* Setup ACPI without replacing DSDT. */ +int setupAcpiNoMod() +{ + // addConfigurationTable(&gEfiAcpiTableGuid, getAddressOfAcpiTable(), "ACPI"); + // addConfigurationTable(&gEfiAcpi20TableGuid, getAddressOfAcpi20Table(), "ACPI_20"); + /* XXX aserebln why uint32 cast if pointer is uint64 ? */ + //Slice (uint64_t) + acpi10_p = (uint64_t)(uint32_t)getAddressOfAcpiTable(); + acpi20_p = (uint64_t)(uint32_t)getAddressOfAcpi20Table(); + addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI"); + if(acpi20_p) addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20"); + else { + DBG("no ACPI 2\n"); + } + return 1; +} + +static struct acpi_2_xsdt* createNewXSDTfromRSDT(struct acpi_2_rsdt * rsdt) +{ + struct acpi_2_xsdt *xsdt; + int xsdt_entries_num, i; + uint32_t xsdt_len; + if (!rsdt) { + return NULL; + } + //Create XSDT in addition to RSDT as a 64bit copy + if((rsdt->Length<0) || (rsdt->Length>1000)){ + DBG(" incorrect RSDT length: %08lx\n", rsdt->Length); +#if DEBUG_DSDT + getc(); +#endif + return NULL; + } + xsdt_entries_num = (rsdt->Length - sizeof(struct acpi_2_rsdt)) >> 2; + xsdt_len = sizeof(struct acpi_2_rsdt) + (xsdt_entries_num << 3); + xsdt = (struct acpi_2_xsdt*)AllocateKernelMemory(xsdt_len); + bcopy(rsdt, xsdt, sizeof(struct acpi_2_rsdt)); + //Change signature from RSDT to XSDT + strncpy(xsdt->Signature, FourChar("XSDT"), 4); + //Now copy address table + uint64_t *table1 = (uint64_t *)(xsdt+1); + uint32_t *table2 = (uint32_t *)(rsdt+1); + if ((xsdt_entries_num>0) && (xsdt_entries_num<20)) { + for(i=0; iLength = xsdt_len; + //Correct checksums + xsdt->Checksum=0; + xsdt->Checksum=256-checksum8(xsdt,xsdt_len); + return xsdt; +} + +static struct acpi_2_rsdp* createNewACPI20(struct acpi_2_rsdp * old_rsdp) +{ + if(!old_rsdp) return NULL; + //Slice I want to copy acpi10 table to create ACPI20 + // uint64_t *xsdt_entries; + if(*(uint64_t *)old_rsdp != ACPI_SIGNATURE_UINT64_LE){ + DBG(" wrong signature %08lx\n", (*(uint64_t *)old_rsdp)); + return NULL; + } + DBG(" old_rsdp = %08lx\n", (uint32_t)old_rsdp); + // if(((int)old_rsdp->Length < 0) || ((int)old_rsdp->Length > 84)) + // return NULL; + //No! ACPI10_rsdp_length=20 and no such field old_rsdp->Length + + struct acpi_2_rsdp * rsdp=(struct acpi_2_rsdp *) AllocateKernelMemory(36); + DBG(" new_rsdp = %08lx\n", (uint32_t)rsdp); + bzero(rsdp, 36); + bcopy(old_rsdp, rsdp, 20); + strncpy(rsdp->OEMID, "Apple ", 6); + rsdp->Revision = 2; + rsdp->Length = 36; + struct acpi_2_rsdt *rsdt = (struct acpi_2_rsdt *)(rsdp->RsdtAddress); //copied from old +// dumpRSDT(rsdt, 0); + rsdp->XsdtAddress = (uint64_t)(uint32_t)createNewXSDTfromRSDT(rsdt); +// dumpRSDT((struct acpi_2_rsdt *)(uint32_t)(rsdp->XsdtAddress), 0); + rsdp->Checksum=0; + rsdp->Checksum=256-checksum8(rsdp,20); + rsdp->ExtendedChecksum=0; + rsdp->ExtendedChecksum=256-checksum8(rsdp,36); + return rsdp; +} + + +/* Setup ACPI. Replace DSDT if DSDT.aml is found */ +int setupAcpi(void) +{ + int version; +// void *new_dsdt; + + const char *filename; + char dirSpec[128]; + int len = 0, old_dsdt_len = 0; + struct acpi_2_rsdp *rsdp, *rsdp_mod, *rsdp1 = 0; + struct acpi_2_rsdt *rsdt, *rsdt_mod = 0; + struct acpi_2_rsdt *xsdt; //, *xsdt_mod = 0; + char* old_dsdt = 0; + + // Try using the file specified with the DSDT option + if (getValueForKey(kDSDT, &filename, &len, &bootInfo->bootConfig)) + { + sprintf(dirSpec, filename); + } + else + { + sprintf(dirSpec, "DSDT.aml"); + } + + // Load replacement DSDT + new_dsdt = loadACPITable(dirSpec); + if(!new_dsdt) + { + sprintf(dirSpec, "DSDT.%s.aml", gSMBIOSBoardModel); + new_dsdt = loadACPITable(dirSpec); + } + + // Mozodojo: going to patch FACP and load SSDT's even if DSDT.aml is not present + /*if (!new_dsdt) + { + return setupAcpiNoMod(); + }*/ + + // Mozodojo: Load additional SSDTs + struct acpi_2_ssdt *new_ssdt[32]; // 30 + 2 additional tables for pss & cst + int ssdt_count=0; + + // SSDT Options + bool drop_ssdt=false, generate_pstates=false, generate_cstates=false; + + getBoolForKey(kDropSSDT, &drop_ssdt, &bootInfo->bootConfig); + getBoolForKey(kGeneratePStates, &generate_pstates, &bootInfo->bootConfig); + getBoolForKey(kGenerateCStates, &generate_cstates, &bootInfo->bootConfig); + + { + int i; + + for (i=0; i<30; i++) + { + char filename[512]; + + sprintf(filename, i>0?"SSDT-%d.aml":"SSDT.aml", i); + + if(new_ssdt[ssdt_count] = loadACPITable(filename)) + { + ssdt_count++; + } + else + { + break; + } + } + } + + // Do the same procedure for both versions of ACPI + for (version=0; version<2; version++) { +// int rsdplength; + //Here version=0 for ACPI 1.0 and version=1 for ACPI 2.0 + // Find original rsdp + rsdp=(struct acpi_2_rsdp *)(version?getAddressOfAcpi20Table():getAddressOfAcpiTable()); + //Slice + if (!rsdp) + { + if (version){ + DBG("No ACPI version 2 found. Creating...\n"); + rsdp=createNewACPI20(rsdp1); + if(!rsdp){ + addConfigurationTable(&gEfiAcpi20TableGuid, NULL, "ACPI_20"); + continue; + } + } else { + DBG("No ACPI version 1 found. Ignoring\n"); + addConfigurationTable(&gEfiAcpiTableGuid, NULL, "ACPI"); + continue; + } + } + if(!version) rsdp1 = rsdp; //save to create new. + rsdplength=version?rsdp->Length:20; + + DBG("RSDP version %d found @%x. Length=%d\n",version+1,rsdp,rsdplength); + + /* FIXME: no check that memory allocation succeeded + * Copy and patch RSDP,RSDT, XSDT and FADT + * For more info see ACPI Specification pages 110 and following + */ + + rsdp_mod=(struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength); + memcpy(rsdp_mod, rsdp, rsdplength); + rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress); + xsdt=(struct acpi_2_rsdt *)(uint32_t)(rsdp->XsdtAddress); + DBG("RSDT @%x, Length %d\n",rsdt, rsdt->Length); + + //if we have RSDT table + if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000) + { + uint32_t *rsdt_entries; + int rsdt_entries_num; + int dropoffset=0, i; + + // mozo: using malloc cos I didn't found how to free already allocated kernel memory + rsdt_mod=(struct acpi_2_rsdt *)malloc(rsdt->Length); + memcpy (rsdt_mod, rsdt, rsdt->Length); + rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod; + rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4; + rsdt_entries=(uint32_t *)(rsdt_mod+1); + for (i=0;iOEMID, "Apple ", 6); + strncpy(t->OEMTableId, MacModel, 8); + t->OEMRevision = ModelRev; + t->Checksum=0; + t->Checksum=256-checksum8(t,t->Length); + + } + if (tableSign(table, "FACP")) + { + struct acpi_2_fadt *fadt, *fadt_mod; + fadt=(struct acpi_2_fadt *)rsdt_entries[i]; + + DBG("FADT found @%x, Length %d\n",fadt, fadt->Length); + + if (!fadt || (uint32_t)fadt == 0xffffffff || fadt->Length>0x10000) + { + printf("FADT incorrect. Not modified\n"); + continue; + } + DBG("Old DSDT @%x, X_DSDT %x from FADT\n",fadt->DSDT,fadt->X_DSDT); + + if(version && fix_restart){ //ACPI 2.0 + fadt_mod = patch_fadt(fadt, new_dsdt); + rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod; + } else { + if (fadt && Platform->Type) + fadt->PM_Profile = Platform->Type; //For ACPI1.0 the only patch + fadt_mod = fadt; + rsdt_entries[i-dropoffset]=(uint32_t)fadt; + } + DBG("FADT_mod table sign: %s\n", fadt_mod->Signature); + //Slice + //Now I want to replace DSDT in place + // it is only way to patch DSDT on some platform + old_dsdt = (char *)fadt->DSDT; + if(!old_dsdt || !tableSign(old_dsdt, "DSDT")){ + if(fadt_mod->Length > 140) old_dsdt = (char *)(uint32_t)fadt_mod->X_DSDT; + if(!old_dsdt || !tableSign(old_dsdt, "DSDT")) old_dsdt = (char *)new_dsdt; + } + DBG("New DSDT @%x, X_DSDT %x after FADT patch\n",fadt_mod->DSDT,fadt_mod->X_DSDT); + + if(tableSign(old_dsdt, "DSDT")) + old_dsdt_len = ((struct acpi_2_rsdt *)old_dsdt)->Length; + int new_dsdt_len = ((struct acpi_2_rsdt *)new_dsdt)->Length; + if(new_dsdt_len > old_dsdt_len) { + old_dsdt = (char *)new_dsdt; + DBG(" New DSDT is longer then old\n"); + len = 0; + } + else len = new_dsdt_len; + + + // Generate _CST SSDT + if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod))) + { + generate_cstates = false; // Generate SSDT only once! + ssdt_count++; + } + + // Generating _PSS SSDT + if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT))) + { + generate_pstates = false; // Generate SSDT only once! + ssdt_count++; + } + + continue; + } + }//for rsdt entries + DBG("\n"); + //Slice - Correct header to MacModel & Vendor, correct chechsum + strncpy(rsdt_mod->OEMID, "Apple ", 6); + strncpy(rsdt_mod->OEMTableId, MacModel, 8); + rsdt_mod->OEMRevision = ModelRev; + + // Allocate rsdt in Kernel memory area + rsdt_mod->Length += 4*ssdt_count - 4*dropoffset; + struct acpi_2_rsdt *rsdt_copy = (struct acpi_2_rsdt *)AllocateKernelMemory(rsdt_mod->Length); + memcpy (rsdt_copy, rsdt_mod, rsdt_mod->Length); + free(rsdt_mod); rsdt_mod = rsdt_copy; + rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod; + rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4; + rsdt_entries=(uint32_t *)(rsdt_mod+1); + + // Mozodojo: Insert additional SSDTs into RSDT + if(ssdt_count>0) + { + int j; + + for (j=0; jChecksum); + + rsdt_mod->Checksum=0; + rsdt_mod->Checksum=256-checksum8(rsdt_mod,rsdt_mod->Length); + +// DBG("New checksum %d at %x\n", rsdt_mod->Checksum,rsdt_mod); + } + else + { + rsdp_mod->RsdtAddress=0; + verbose("RSDT not found or RSDT incorrect\n"); + } + + if (version) + { + struct acpi_2_xsdt *xsdt, *xsdt_mod; + + // FIXME: handle 64-bit address correctly + + xsdt=(struct acpi_2_xsdt*) ((uint32_t)rsdp->XsdtAddress); + DBG("XSDT @%x;%x, Length=%d Sign=%c%c%c%c\n", (uint32_t)(rsdp->XsdtAddress>>32), + (uint32_t)rsdp->XsdtAddress, xsdt->Length, xsdt[0], xsdt[1], xsdt[2], xsdt[3]); + if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000) + { + uint64_t *xsdt_entries; + int xsdt_entries_num, i; + int dropoffset=0; + + // mozo: using malloc cos I didn't found how to free already allocated kernel memory + xsdt_mod=(struct acpi_2_xsdt*)malloc(xsdt->Length); + memcpy(xsdt_mod, xsdt, xsdt->Length); + rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod; + xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8; + xsdt_entries=(uint64_t *)(xsdt_mod+1); + for (i=0;i>32),fadt, + fadt->Length); + + if (!fadt || (uint64_t)xsdt_entries[i] >= 0xffffffff || fadt->Length>0x10000) + { + DBG("FADT incorrect or after 4GB. Dropping XSDT\n"); + goto drop_xsdt; + } + + fadt_mod = patch_fadt(fadt, new_dsdt); + xsdt_entries[i-dropoffset]=(uint32_t)fadt_mod; + + DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]); + + // Generate _CST SSDT + if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod))) + { + generate_cstates = false; // Generate SSDT only once! + ssdt_count++; + } + + // Generating _PSS SSDT + if (generate_pstates && (new_ssdt[ssdt_count] = generate_pss_ssdt((void*)fadt_mod->DSDT))) + { + generate_pstates = false; // Generate SSDT only once! + ssdt_count++; + } + + continue; + } + + DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]); + + } + + // Allocate xsdt in Kernel memory area + xsdt_mod->Length += 8*ssdt_count - 8*dropoffset; + struct acpi_2_xsdt *xsdt_copy = (struct acpi_2_xsdt *)AllocateKernelMemory(xsdt_mod->Length); + memcpy(xsdt_copy, xsdt_mod, xsdt_mod->Length); + free(xsdt_mod); xsdt_mod = xsdt_copy; + rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod; + xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8; + xsdt_entries=(uint64_t *)(xsdt_mod+1); + + // Mozodojo: Insert additional SSDTs into XSDT + if(ssdt_count>0) + { + int j; + + for (j=0; jChecksum=0; + xsdt_mod->Checksum=256-checksum8(xsdt_mod,xsdt_mod->Length); + } + else + { + drop_xsdt: + + DBG("About to drop XSDT\n"); + + /*FIXME: Now we just hope that if MacOS doesn't find XSDT it reverts to RSDT. + * A Better strategy would be to generate + */ + //Slice - it is possible only for ACPI20 + if (version) { + if(rsdp->RsdtAddress){ + rsdp_mod->XsdtAddress = + (uint64_t)(uint32_t)createNewXSDTfromRSDT((struct acpi_2_rsdt*)rsdp->RsdtAddress); + continue; + } + else + DBG(" no sample to create XSDT, dropping\n"); + } + + rsdp_mod->XsdtAddress=0xffffffffffffffffLL; + DBG("XSDT not found or XSDT incorrect\n"); + } + } + //Slice - correct DSDT in place + if(len && old_dsdt && new_dsdt && (old_dsdt != new_dsdt)){ + DBG("old_dsdt=%08x new_dsdt=%08x new_len=%d\n", (unsigned int)old_dsdt, (unsigned int)new_dsdt, len); + bcopy(new_dsdt, old_dsdt, len); + } + + // Correct the checksum of RSDP + + DBG("RSDP: Original checksum %d, ", rsdp_mod->Checksum); + + rsdp_mod->Checksum=0; + rsdp_mod->Checksum=256-checksum8(rsdp_mod,20); + + DBG("New checksum %d\n", rsdp_mod->Checksum); + + if (version) + { + DBG("RSDP: Original extended checksum %d", rsdp_mod->ExtendedChecksum); + + rsdp_mod->ExtendedChecksum=0; + rsdp_mod->ExtendedChecksum=256-checksum8(rsdp_mod,rsdp_mod->Length); + + DBG("New extended checksum %d\n", rsdp_mod->ExtendedChecksum); + + } + + //verbose("Patched ACPI version %d DSDT\n", version+1); + if (version) + { + /* XXX aserebln why uint32 cast if pointer is uint64 ? */ + //Slice because rsdp_mod is a pointer (32bit in i386) to a structure uint64_t* + acpi20_p = (uint64_t)(uint32_t)rsdp_mod; + addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20"); + } + else + { + /* XXX aserebln why uint32 cast if pointer is uint64 ? */ + acpi10_p = (uint64_t)(uint32_t)rsdp_mod; + addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI"); + } + } +#if DEBUG_ACPI + printf("Press a key to continue... (DEBUG_ACPI)\n"); + getc(); +#endif + return 1; +} Index: branches/slice/i386/libsaio/acpi_patcher.h =================================================================== --- branches/slice/i386/libsaio/acpi_patcher.h (revision 0) +++ branches/slice/i386/libsaio/acpi_patcher.h (revision 714) @@ -0,0 +1,39 @@ +/* + * Copyright 2008 mackerintel + */ + +#ifndef __LIBSAIO_ACPI_PATCHER_H +#define __LIBSAIO_ACPI_PATCHER_H + +#include "libsaio.h" +#include "efi.h" +//#include "ACPIPatcher.h" + +extern void *new_dsdt; +extern uint64_t smbios_p; + +extern int setupAcpi(); + +extern EFI_STATUS addConfigurationTable(); +extern int search_and_get_acpi_fd(const char *, const char **); + +extern EFI_GUID gEfiAcpiTableGuid; +extern EFI_GUID gEfiAcpi20TableGuid; + +struct p_state +{ + union + { + uint16_t Control; + struct + { + uint8_t VID; // Voltage ID + uint8_t FID; // Frequency ID + }; + }; + + uint8_t CID; // Compare ID + uint32_t Frequency; +}; + +#endif /* !__LIBSAIO_ACPI_PATCHER_H */ Index: branches/slice/i386/libsaio/aml_generator.c =================================================================== --- branches/slice/i386/libsaio/aml_generator.c (revision 0) +++ branches/slice/i386/libsaio/aml_generator.c (revision 714) @@ -0,0 +1,498 @@ +/* + * aml_generator.c + * Chameleon + * + * Created by Mozodojo on 20/07/10. + * Copyright 2010 mozo. All rights reserved. + * + */ + +#include "aml_generator.h" + +bool aml_add_to_parent(struct aml_chunk* parent, struct aml_chunk* node) +{ + if (parent && node) + { + switch (parent->Type) + { + case AML_CHUNK_NONE: + case AML_CHUNK_BYTE: + case AML_CHUNK_WORD: + case AML_CHUNK_DWORD: + case AML_CHUNK_QWORD: + case AML_CHUNK_ALIAS: + verbose("aml_add_to_parent: node doesn't support child nodes!"); + return false; + case AML_CHUNK_NAME: + if (parent->First) + { + verbose("aml_add_to_parent: name node supports only one child node!"); + return false; + } + break; + + default: + break; + } + + if (!parent->First) + parent->First = node; + + if (parent->Last) + parent->Last->Next = node; + + parent->Last = node; + + return TRUE; + } + + return FALSE; +} + +struct aml_chunk* aml_create_node(struct aml_chunk* parent) +{ + struct aml_chunk* node = (struct aml_chunk*)malloc(sizeof(struct aml_chunk)); + + aml_add_to_parent(parent, node); + + return node; +} + +void aml_destroy_node(struct aml_chunk* node) +{ + // Delete child nodes + struct aml_chunk* child = node->First; + + while (child) + { + struct aml_chunk* next = child->Next; + + if (child->Buffer) + free(child->Buffer); + + free(child); + + child = next; + } + + // Free node + if (node->Buffer) + free(node->Buffer); + + free(node); +} + +struct aml_chunk* aml_add_buffer(struct aml_chunk* parent, const char* buffer, unsigned int size) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_NONE; + node->Length = size; + node->Buffer = malloc(node->Length); + memcpy(node->Buffer, buffer, node->Length); + } + + return node; +} + +struct aml_chunk* aml_add_byte(struct aml_chunk* parent, unsigned char value) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_BYTE; + + node->Length = 1; + node->Buffer = malloc(node->Length); + node->Buffer[0] = value; + } + + return node; +} + +struct aml_chunk* aml_add_word(struct aml_chunk* parent, unsigned int value) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_WORD; + node->Length = 2; + node->Buffer = malloc(node->Length); + node->Buffer[0] = value & 0xff; + node->Buffer[1] = value >> 8; + } + + return node; +} + +struct aml_chunk* aml_add_dword(struct aml_chunk* parent, unsigned long value) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_DWORD; + node->Length = 4; + node->Buffer = malloc(node->Length); + node->Buffer[0] = value & 0xff; + node->Buffer[1] = (value >> 8) & 0xff; + node->Buffer[2] = (value >> 16) & 0xff; + node->Buffer[3] = (value >> 24) & 0xff; + } + + return node; +} + +struct aml_chunk* aml_add_qword(struct aml_chunk* parent, unsigned long long value) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_QWORD; + node->Length = 8; + node->Buffer = malloc(node->Length); + node->Buffer[0] = value & 0xff; + node->Buffer[1] = (value >> 8) & 0xff; + node->Buffer[2] = (value >> 16) & 0xff; + node->Buffer[3] = (value >> 24) & 0xff; + node->Buffer[4] = (value >> 32) & 0xff; + node->Buffer[5] = (value >> 40) & 0xff; + node->Buffer[6] = (value >> 48) & 0xff; + node->Buffer[7] = (value >> 56) & 0xff; + } + + return node; +} + +unsigned int aml_fill_simple_name(char* buffer, const char* name) +{ + if (strlen(name) < 4) + { + verbose("aml_fill_simple_name: simple name %s has incorrect lengh! Must be 4\n", name); + return 0; + } + + memcpy(buffer, name, 4); + return 4; +} + +unsigned int aml_fill_name(struct aml_chunk* node, const char* name) +{ + if (!node) + return 0; + + int len = strlen(name), offset = 0, count = len / 4; + + if ((len % 4) > 1 || count == 0) + { + verbose("aml_fill_name: pathname %s has incorrect length! Must be 4, 8, 12, 16, etc...", name); + return 0; + } + + unsigned int root = 0; + + if ((len % 4) == 1 && name[0] == '\\') + root++; + + if (count == 1) + { + node->Length = 4 + root; + node->Buffer = malloc(node->Length); + memcpy(node->Buffer, name, 4 + root); + return node->Length; + } + + if (count == 2) + { + node->Length = 2 + 8; + node->Buffer = malloc(node->Length); + node->Buffer[offset++] = 0x5c; // Root Char + node->Buffer[offset++] = 0x2e; // Double name + memcpy(node->Buffer+offset, name + root, 8); + return node->Length; + } + + node->Length = 3 + count*4; + node->Buffer = malloc(node->Length); + node->Buffer[offset++] = 0x5c; // Root Char + node->Buffer[offset++] = 0x2f; // Multi name + node->Buffer[offset++] = count; // Names count + memcpy(node->Buffer+offset, name + root, count*4); + + return node->Length; +} + +struct aml_chunk* aml_add_scope(struct aml_chunk* parent, const char* name) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_SCOPE; + + aml_fill_name(node, name); + } + + return node; +} + +struct aml_chunk* aml_add_name(struct aml_chunk* parent, const char* name) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_NAME; + + aml_fill_name(node, name); + } + + return node; +} + +struct aml_chunk* aml_add_package(struct aml_chunk* parent) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_PACKAGE; + + node->Length = 1; + node->Buffer = malloc(node->Length); + } + + return node; +} + +struct aml_chunk* aml_add_alias(struct aml_chunk* parent, const char* name1, const char* name2) +{ + struct aml_chunk* node = aml_create_node(parent); + + if (node) + { + node->Type = AML_CHUNK_ALIAS; + + node->Length = 8; + node->Buffer = malloc(node->Length); + aml_fill_simple_name(node->Buffer, name1); + aml_fill_simple_name(node->Buffer+4, name2); + } + + return node; +} + +unsigned char aml_get_size_length(unsigned int size) +{ + if (size + 1 <= 0x3f) + return 1; + else if (size + 2 <= 0x3fff) + return 2; + else if (size + 3 <= 0x3fffff) + return 3; + + return 4; +} + +unsigned int aml_calculate_size(struct aml_chunk* node) +{ + if (node) + { + node->Size = 0; + + // Calculate child nodes size + struct aml_chunk* child = node->First; + unsigned char child_count = 0; + + while (child) + { + child_count++; + + node->Size += aml_calculate_size(child); + + child = child->Next; + } + + switch (node->Type) + { + case AML_CHUNK_NONE: + node->Size += node->Length; + break; + case AML_CHUNK_SCOPE: + node->Size += 1 + node->Length; + node->Size += aml_get_size_length(node->Size); + break; + case AML_CHUNK_PACKAGE: + node->Buffer[0] = child_count; + node->Size += 1 + node->Length; + node->Size += aml_get_size_length(node->Size); + break; + + case AML_CHUNK_BYTE: + if (node->Buffer[0] == 0x0 || node->Buffer[0] == 0x1) + { + node->Size += node->Length; + } + else + { + node->Size += 1 + node->Length; + } + + break; + + case AML_CHUNK_WORD: + case AML_CHUNK_DWORD: + case AML_CHUNK_QWORD: + case AML_CHUNK_ALIAS: + case AML_CHUNK_NAME: + node->Size += 1 + node->Length; + break; + } + + return node->Size; + } + + return 0; +} + +unsigned int aml_write_byte(unsigned char value, char* buffer, unsigned int offset) +{ + buffer[offset++] = value; + + return offset; +} + +unsigned int aml_write_word(unsigned int value, char* buffer, unsigned int offset) +{ + buffer[offset++] = value & 0xff; + buffer[offset++] = value >> 8; + + return offset; +} + +unsigned int aml_write_dword(unsigned long value, char* buffer, unsigned int offset) +{ + buffer[offset++] = value & 0xff; + buffer[offset++] = (value >> 8) & 0xff; + buffer[offset++] = (value >> 16) & 0xff; + buffer[offset++] = (value >> 24) & 0xff; + + return offset; +} + +unsigned int aml_write_qword(unsigned long long value, char* buffer, unsigned int offset) +{ + buffer[offset++] = value & 0xff; + buffer[offset++] = (value >> 8) & 0xff; + buffer[offset++] = (value >> 16) & 0xff; + buffer[offset++] = (value >> 24) & 0xff; + buffer[offset++] = (value >> 32) & 0xff; + buffer[offset++] = (value >> 40) & 0xff; + buffer[offset++] = (value >> 48) & 0xff; + buffer[offset++] = (value >> 56) & 0xff; + + return offset; +} + +unsigned int aml_write_buffer(const char* value, unsigned int size, char* buffer, unsigned int offset) +{ + if (size > 0) + { + memcpy(buffer + offset, value, size); + } + + return offset + size; +} + +unsigned int aml_write_size(unsigned int size, char* buffer, unsigned int offset) +{ + if (size <= 0x3f) + { + buffer[offset++] = size; + } + else if (size <= 0x3fff) + { + buffer[offset++] = 0x40 | (size & 0xf); + buffer[offset++] = (size >> 4) & 0xff; + } + else if (size <= 0x3fffff) + { + buffer[offset++] = 0x80 | (size & 0xf); + buffer[offset++] = (size >> 4) & 0xff; + buffer[offset++] = (size >> 12) & 0xff; + } + else + { + buffer[offset++] = 0xc0 | (size & 0xf); + buffer[offset++] = (size >> 4) & 0xff; + buffer[offset++] = (size >> 12) & 0xff; + buffer[offset++] = (size >> 20) & 0xff; + } + + return offset; +} + +unsigned int aml_write_node(struct aml_chunk* node, char* buffer, unsigned int offset) +{ + if (node && buffer) + { + unsigned int old = offset; + + switch (node->Type) + { + case AML_CHUNK_NONE: + offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset); + break; + + case AML_CHUNK_SCOPE: + case AML_CHUNK_PACKAGE: + offset = aml_write_byte(node->Type, buffer, offset); + offset = aml_write_size(node->Size-1, buffer, offset); + offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset); + break; + + case AML_CHUNK_BYTE: + if (node->Buffer[0] == 0x0 || node->Buffer[0] == 0x1) + { + offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset); + } + else + { + offset = aml_write_byte(node->Type, buffer, offset); + offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset); + } + break; + + case AML_CHUNK_WORD: + case AML_CHUNK_DWORD: + case AML_CHUNK_QWORD: + case AML_CHUNK_ALIAS: + case AML_CHUNK_NAME: + offset = aml_write_byte(node->Type, buffer, offset); + offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset); + break; + + default: + break; + } + + struct aml_chunk* child = node->First; + + while (child) + { + offset = aml_write_node(child, buffer, offset); + + child = child->Next; + } + + if (offset - old != node->Size) + verbose("Node size incorrect: 0x%x\n", node->Type); + } + + return offset; +} \ No newline at end of file Index: branches/slice/i386/libsaio/aml_generator.h =================================================================== --- branches/slice/i386/libsaio/aml_generator.h (revision 0) +++ branches/slice/i386/libsaio/aml_generator.h (revision 714) @@ -0,0 +1,63 @@ +/* + * aml_generator.h + * Chameleon + * + * Created by Mozodojo on 20/07/10. + * Copyright 2010 mozo. All rights reserved. + * + */ + +#ifndef __LIBSAIO_AML_GENERATOR_H +#define __LIBSAIO_AML_GENERATOR_H + +#include "libsaio.h" +//#include "ACPIPatcher.h" + + +#define AML_CHUNK_NONE 0xff +#define AML_CHUNK_ZERO 0x00 +#define AML_CHUNK_ONE 0x01 +#define AML_CHUNK_ALIAS 0x06 +#define AML_CHUNK_NAME 0x08 +#define AML_CHUNK_BYTE 0x0A +#define AML_CHUNK_WORD 0x0B +#define AML_CHUNK_DWORD 0x0C +#define AML_CHUNK_STRING 0x0D +#define AML_CHUNK_QWORD 0x0E +#define AML_CHUNK_SCOPE 0x10 +#define AML_CHUNK_PACKAGE 0x12 + +struct aml_chunk +{ + unsigned char Type; + unsigned int Length; + char* Buffer; + + unsigned int Size; + + struct aml_chunk* Next; + struct aml_chunk* First; + struct aml_chunk* Last; +}; + +static inline bool aml_isvalidchar(char c) +{ + return isupper(c) || isdigit(c) || c == '_'; +}; + +bool aml_add_to_parent(struct aml_chunk* parent, struct aml_chunk* node); +struct aml_chunk* aml_create_node(struct aml_chunk* parent); +void aml_destroy_node(struct aml_chunk* node); +struct aml_chunk* aml_add_buffer(struct aml_chunk* parent, const char* buffer, unsigned int size); +struct aml_chunk* aml_add_byte(struct aml_chunk* parent, unsigned char value); +struct aml_chunk* aml_add_word(struct aml_chunk* parent, unsigned int value); +struct aml_chunk* aml_add_dword(struct aml_chunk* parent, unsigned long value); +struct aml_chunk* aml_add_qword(struct aml_chunk* parent, unsigned long long value); +struct aml_chunk* aml_add_scope(struct aml_chunk* parent, const char* name); +struct aml_chunk* aml_add_name(struct aml_chunk* parent, const char* name); +struct aml_chunk* aml_add_package(struct aml_chunk* parent); +struct aml_chunk* aml_add_alias(struct aml_chunk* parent, const char* name1, const char* name2); +unsigned int aml_calculate_size(struct aml_chunk* node); +unsigned int aml_write_node(struct aml_chunk* node, char* buffer, unsigned int offset); + +#endif /* !__LIBSAIO_AML_GENERATOR_H */ \ No newline at end of file Index: branches/slice/i386/boot2/boot.c =================================================================== --- branches/slice/i386/boot2/boot.c (revision 713) +++ branches/slice/i386/boot2/boot.c (revision 714) @@ -63,7 +63,7 @@ #include "modules.h" -#define DEBUG 0 +#define DEBUG 1 long gBootMode; /* defaults to 0 == kBootModeNormal */ bool gOverrideKernel; @@ -285,7 +285,7 @@ // Setup VGA text mode. // Not sure if it is safe to call setVideoMode() before the // config table has been loaded. Call video_mode() instead. - // video_mode( 2 ); // 80x25 mono text mode. + video_mode( 2 ); // 80x25 mono text mode. // Scan and record the system's hardware information. scan_platform(); @@ -296,7 +296,7 @@ #if DEBUG printf("get bvChain dev=%02x type=%02x part_no=%d\n", bvChain->biosdev, bvChain->type, bvChain->part_no); //dev=0x80 - flash-stick - getc(); +// getc(); #endif setBootGlobals(bvChain); @@ -344,7 +344,7 @@ { #if DEBUG printf("begin load_all_modules\n"); - pause(); +// pause(); #endif load_all_modules(); @@ -353,7 +353,7 @@ execute_hook("ModulesLoaded", NULL, NULL, NULL, NULL); #if DEBUG printf("ModulesLoaded\n"); - pause(); +// pause(); #endif @@ -530,8 +530,8 @@ /* - but the name is longer .adler32 and more... kernelcache_i386.E102928C.qSs0 - so will opendir and scan for some file - + so will opendir and scan for some files + */ char* name; long flagsC; long timeC; @@ -542,9 +542,10 @@ { //char* tmp = malloc(strlen(name) + 1); //strcpy(tmp, name); + verbose("find kernelcache=%s\n", name); } } - */ + } else //if(gMacOSVersion[3] == '5') sprintf(gBootKernelCacheFile, "%skernelcache", kDefaultCachePath); Index: branches/slice/i386/boot2/modules.c =================================================================== --- branches/slice/i386/boot2/modules.c (revision 713) +++ branches/slice/i386/boot2/modules.c (revision 714) @@ -10,7 +10,7 @@ #include "modules.h" #ifndef DEBUG_MODULES -#define DEBUG_MODULES 0 +#define DEBUG_MODULES 1 #endif #if DEBUG_MODULES Index: branches/slice/i386/modules/GUI/gui.c =================================================================== --- branches/slice/i386/modules/GUI/gui.c (revision 713) +++ branches/slice/i386/modules/GUI/gui.c (revision 714) @@ -14,7 +14,18 @@ #include "modules.h" #include "../Resolution/edid.h" +#ifndef DEBUG_GUI +#define DEBUG_GUI 1 +#endif +#if DEBUG_GUI +#define DBG(x...) verbose(x) //;getc() +#else +#define DBG(x...) msglog(x) +#endif + + + gui_t gui; // gui structure font_t font_small; font_t font_console; @@ -691,7 +702,8 @@ { int val; int len; - char dirspec[256]; + char* dirspec; //[256]; + dirspec = (char*)malloc(256); getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig ); if ((strlen(theme_name) + 27) > sizeof(dirspec)) { @@ -702,13 +714,13 @@ if (loadConfigFile(dirspec, &bootInfo->themeConfig) != 0) { #ifdef EMBED_THEME config_file_t *config; - + DBG("Attention! EMBED_THEME!\n"); config = &bootInfo->themeConfig; if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0) { return 1; } #else - msglog(" GUI from themeConfig\n"); + DBG(" GUI from themeConfig failed\n"); return 1; #endif } @@ -717,7 +729,7 @@ { getResolution(&screen_params[0], &screen_params[1], &screen_params[2]); gDualLink =((screen_params[0] * screen_params[1]) > (1<<20))?1:0; - msglog("GUI module screen width=%d height=%d\n",(int)screen_params[0], (int)screen_params[1]); + DBG("GUI module screen width=%d height=%d\n",(int)screen_params[0], (int)screen_params[1]); } if (((int)screen_params[0]<800) || ((int)screen_params[1]<600)) { @@ -729,13 +741,13 @@ { screen_params[1] = val; } - msglog("GUI theme screen width=%d height=%d\n",screen_params[0], screen_params[1]); + DBG("GUI theme screen width=%d height=%d\n",screen_params[0], screen_params[1]); } if (((int)screen_params[0]<800) || ((int)screen_params[1]<600)) { screen_params[0] = DEFAULT_SCREEN_WIDTH; screen_params[1] = DEFAULT_SCREEN_HEIGHT; - msglog("GUI default screen width=%d height=%d\n",screen_params[0], screen_params[1]); + DBG("GUI default screen width=%d height=%d\n",screen_params[0], screen_params[1]); } /* if (((int)screen_params[0]>1280) || ((int)screen_params[1]>1024)) { @@ -749,7 +761,7 @@ // find best matching vesa mode for our requested width & height int modeV = getGraphicModeParams(screen_params); - verbose("GUI: set mode %d: %dx%dx%d\n", modeV, screen_params[0], screen_params[1], screen_params[2]); + DBG("GUI: set mode %d: %dx%dx%d\n", modeV, screen_params[0], screen_params[1], screen_params[2]); // set our screen structure with the mode width & height gui.screen.width = screen_params[0]; Index: branches/slice/revision =================================================================== --- branches/slice/revision (revision 713) +++ branches/slice/revision (revision 714) @@ -1 +1 @@ -676:711 \ No newline at end of file +676:713 \ No newline at end of file Index: branches/slice/ChamMek/ChamMek.xcodeproj/slice.pbxuser =================================================================== --- branches/slice/ChamMek/ChamMek.xcodeproj/slice.pbxuser (revision 713) +++ branches/slice/ChamMek/ChamMek.xcodeproj/slice.pbxuser (revision 714) @@ -114,8 +114,8 @@ PBXFileDataSource_Target_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 317734509; - PBXWorkspaceStateSaveDate = 317734509; + PBXPerProjectTemplateStateSaveDate = 317739043; + PBXWorkspaceStateSaveDate = 317739043; }; perUserProjectItems = { 120DFB1712BA3A4D00C7EAC8 /* PBXTextBookmark */ = 120DFB1712BA3A4D00C7EAC8 /* PBXTextBookmark */; @@ -124,6 +124,12 @@ 12121ED112B261EA00207E55 /* PBXTextBookmark */ = 12121ED112B261EA00207E55 /* PBXTextBookmark */; 1216139E12B65BB50019961E /* PBXTextBookmark */ = 1216139E12B65BB50019961E /* PBXTextBookmark */; 121613FF12B65D970019961E /* PBXTextBookmark */ = 121613FF12B65D970019961E /* PBXTextBookmark */; + 121E3B3812F04EB9007B7E08 /* PBXTextBookmark */ = 121E3B3812F04EB9007B7E08 /* PBXTextBookmark */; + 121E3B3A12F04EB9007B7E08 /* PBXTextBookmark */ = 121E3B3A12F04EB9007B7E08 /* PBXTextBookmark */; + 121FAA3512F051A200385F21 /* PBXTextBookmark */ = 121FAA3512F051A200385F21 /* PBXTextBookmark */; + 121FAA3612F051A200385F21 /* PBXTextBookmark */ = 121FAA3612F051A200385F21 /* PBXTextBookmark */; + 121FAA3812F051A200385F21 /* PBXTextBookmark */ = 121FAA3812F051A200385F21 /* PBXTextBookmark */; + 121FAA3A12F051A200385F21 /* PBXTextBookmark */ = 121FAA3A12F051A200385F21 /* PBXTextBookmark */; 1223EF9012E5D63A0019EC66 /* PBXTextBookmark */ = 1223EF9012E5D63A0019EC66 /* PBXTextBookmark */; 122A869712EC5429004312F4 /* PBXTextBookmark */ = 122A869712EC5429004312F4 /* PBXTextBookmark */; 122A869812EC5429004312F4 /* PBXTextBookmark */ = 122A869812EC5429004312F4 /* PBXTextBookmark */; @@ -137,9 +143,6 @@ 125437C812EF1E99007175C8 /* PBXTextBookmark */ = 125437C812EF1E99007175C8 /* PBXTextBookmark */; 125437CA12EF1E99007175C8 /* PBXTextBookmark */ = 125437CA12EF1E99007175C8 /* PBXTextBookmark */; 125437CB12EF1E99007175C8 /* PBXTextBookmark */ = 125437CB12EF1E99007175C8 /* PBXTextBookmark */; - 1255F81112F03ED000CE7802 /* PBXTextBookmark */ = 1255F81112F03ED000CE7802 /* PBXTextBookmark */; - 1255F81212F03ED000CE7802 /* PBXTextBookmark */ = 1255F81212F03ED000CE7802 /* PBXTextBookmark */; - 1255F81312F03ED000CE7802 /* PBXTextBookmark */ = 1255F81312F03ED000CE7802 /* PBXTextBookmark */; 12569C8612F0115B005A9113 /* PBXTextBookmark */ = 12569C8612F0115B005A9113 /* PBXTextBookmark */; 1265C97712C7554E0050D02E /* PBXTextBookmark */ = 1265C97712C7554E0050D02E /* PBXTextBookmark */; 1267813012B7B13E00A25CED /* PBXTextBookmark */ = 1267813012B7B13E00A25CED /* PBXTextBookmark */; @@ -167,9 +170,7 @@ 12B9F42612B29A4A00FE287A /* PBXTextBookmark */ = 12B9F42612B29A4A00FE287A /* PBXTextBookmark */; 12BF14DA12B3CF8E00D798FE /* PBXTextBookmark */ = 12BF14DA12B3CF8E00D798FE /* PBXTextBookmark */; 12C246F412C87C7C007E8339 /* PBXTextBookmark */ = 12C246F412C87C7C007E8339 /* PBXTextBookmark */; - 12C2907612C8962900984F8F /* PBXTextBookmark */ = 12C2907612C8962900984F8F /* PBXTextBookmark */; 12C5020712D8B82400EDCC4E /* PBXTextBookmark */ = 12C5020712D8B82400EDCC4E /* PBXTextBookmark */; - 12C672F512C7C6BE0058B09B /* PBXTextBookmark */ = 12C672F512C7C6BE0058B09B /* PBXTextBookmark */; 12C7009812B7BCE7006BD382 /* PBXTextBookmark */ = 12C7009812B7BCE7006BD382 /* PBXTextBookmark */; 12C7009912B7BCE7006BD382 /* PBXTextBookmark */ = 12C7009912B7BCE7006BD382 /* PBXTextBookmark */; 12C704E512B7BD3E006BD382 /* PBXTextBookmark */ = 12C704E512B7BD3E006BD382 /* PBXTextBookmark */; @@ -332,6 +333,45 @@ vrLen = 895; vrLoc = 563; }; + 121E3B3812F04EB9007B7E08 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 121E3B3912F04EB9007B7E08 /* GUI_module.c */; + name = "GUI_module.c: 125"; + rLen = 7; + rLoc = 2919; + rType = 0; + vrLen = 456; + vrLoc = 0; + }; + 121E3B3912F04EB9007B7E08 /* GUI_module.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = GUI_module.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/GUI_module.c; + sourceTree = ""; + }; + 121E3B3A12F04EB9007B7E08 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 123D09BF12F01CAA00D5CB48 /* modules.c */; + name = "modules.c: 127"; + rLen = 6; + rLoc = 2992; + rType = 0; + vrLen = 730; + vrLoc = 2640; + }; + 121E3B3D12F04EB9007B7E08 /* gui.h */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = gui.h; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/gui.h; + sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {752, 1950}}"; + sepNavSelRange = "{572, 16}"; + sepNavVisRange = "{2270, 887}"; + }; + }; 121E9E4112C6A6F9000B6ED3 /* gma.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; @@ -346,6 +386,62 @@ path = /Users/slice/Projects/fakesmc/Chameleon/RC5m/i386/libsaio/smbios_patcher.c; sourceTree = ""; }; + 121FAA3512F051A200385F21 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 121E3B3D12F04EB9007B7E08 /* gui.h */; + name = "gui.h: 28"; + rLen = 16; + rLoc = 572; + rType = 0; + vrLen = 887; + vrLoc = 2270; + }; + 121FAA3612F051A200385F21 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 121FAA3712F051A200385F21 /* boot.c */; + name = "boot.c: 66"; + rLen = 0; + rLoc = 2077; + rType = 0; + vrLen = 639; + vrLoc = 1830; + }; + 121FAA3712F051A200385F21 /* boot.c */ = { + isa = PBXFileReference; + name = boot.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/boot.c; + sourceTree = ""; + }; + 121FAA3812F051A200385F21 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 121FAA3912F051A200385F21 /* graphics.c */; + rLen = 10; + rLoc = 17982; + rType = 0; + }; + 121FAA3912F051A200385F21 /* graphics.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = graphics.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/graphics.c; + sourceTree = ""; + }; + 121FAA3A12F051A200385F21 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 121FAA3B12F051A200385F21 /* graphics.c */; + name = "graphics.c: 633"; + rLen = 10; + rLoc = 17982; + rType = 0; + vrLen = 958; + vrLoc = 17553; + }; + 121FAA3B12F051A200385F21 /* graphics.c */ = { + isa = PBXFileReference; + name = graphics.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/graphics.c; + sourceTree = ""; + }; 1223EF9012E5D63A0019EC66 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 1223EF9112E5D63A0019EC66 /* stringTable.c */; @@ -427,19 +523,7 @@ name = modules.c; path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/modules.c; sourceTree = ""; - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {752, 18122}}"; - sepNavSelRange = "{229, 0}"; - sepNavVisRange = "{97, 721}"; - }; }; - 1243C06412EF16C400CF33C6 /* boot.c */ = { - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = boot.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/boot.c; - sourceTree = ""; - }; 124C492812B8C915005AA276 /* Memory.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; @@ -586,42 +670,6 @@ path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/modules.h; sourceTree = ""; }; - 1255F81112F03ED000CE7802 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 123D09BF12F01CAA00D5CB48 /* modules.c */; - name = "modules.c: 13"; - rLen = 0; - rLoc = 229; - rType = 0; - vrLen = 721; - vrLoc = 97; - }; - 1255F81212F03ED000CE7802 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 1243C06412EF16C400CF33C6 /* boot.c */; - name = "boot.c: 353"; - rLen = 13; - rLoc = 10294; - rType = 0; - vrLen = 678; - vrLoc = 9722; - }; - 1255F81312F03ED000CE7802 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 1255F81412F03ED000CE7802 /* boot.c */; - name = "boot.c: 66"; - rLen = 0; - rLoc = 2077; - rType = 0; - vrLen = 657; - vrLoc = 1639; - }; - 1255F81412F03ED000CE7802 /* boot.c */ = { - isa = PBXFileReference; - name = boot.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/boot.c; - sourceTree = ""; - }; 12569C8612F0115B005A9113 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 120F5CDE12F0087200C64A78 /* CHANGES */; @@ -1122,16 +1170,6 @@ path = /Users/slice/Projects/Chameleons/chameleon/branches/meklort/i386/modules/KernelPatcher/kernel_patcher.h; sourceTree = ""; }; - 12C2907612C8962900984F8F /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 12D2040D12C890B700CE318D /* graphics.c */; - name = "graphics.c: 722"; - rLen = 16; - rLoc = 20617; - rType = 0; - vrLen = 784; - vrLoc = 20063; - }; 12C5020712D8B82400EDCC4E /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12D52EA712D7377E00A23AEF /* resume.c */; @@ -1142,16 +1180,6 @@ vrLen = 698; vrLoc = 2183; }; - 12C672F512C7C6BE0058B09B /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 12D332A912C669090093EEDB /* gui.h */; - name = "gui.h: 28"; - rLen = 16; - rLoc = 572; - rType = 0; - vrLen = 540; - vrLoc = 0; - }; 12C7009812B7BCE7006BD382 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12C7FC5C12B7BCD6006BD382 /* basic_definitions */; @@ -1273,13 +1301,6 @@ path = /Users/slice/Projects/fakesmc/Chameleon/RC5m/i386/libsaio/pci_setup.c; sourceTree = ""; }; - 12D2040D12C890B700CE318D /* graphics.c */ = { - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = graphics.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/graphics.c; - sourceTree = ""; - }; 12D3316C12C61CA80093EEDB /* bootstruct.h */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; @@ -1365,13 +1386,6 @@ path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/graphics.h; sourceTree = ""; }; - 12D332A912C669090093EEDB /* gui.h */ = { - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.h; - name = gui.h; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/gui.h; - sourceTree = ""; - }; 12D332AA12C669090093EEDB /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12D332AB12C669090093EEDB /* gma.h */; Index: branches/slice/ChamMek/ChamMek.xcodeproj/slice.mode1v3 =================================================================== --- branches/slice/ChamMek/ChamMek.xcodeproj/slice.mode1v3 (revision 713) +++ branches/slice/ChamMek/ChamMek.xcodeproj/slice.mode1v3 (revision 714) @@ -269,11 +269,13 @@ 08FB7794FE84155DC02AAC07 08FB7795FE84155DC02AAC07 12C26D3912B0DE0A00AF7F4B + 121FA5E612F0502300385F21 1C37FABC05509CD000000102 PBXSmartGroupTreeModuleOutlineStateSelectionKey + 23 17 2 1 @@ -320,7 +322,7 @@ PBXProjectModuleGUID 1CE0B20306471E060097A5F4 PBXProjectModuleLabel - boot.c + graphics.c PBXSplitModuleInNavigatorKey Split0 @@ -328,11 +330,11 @@ PBXProjectModuleGUID 1CE0B20406471E060097A5F4 PBXProjectModuleLabel - boot.c + graphics.c _historyCapacity 0 bookmark - 1255F81312F03ED000CE7802 + 121FAA3A12F051A200385F21 history 12121ED112B261EA00207E55 @@ -396,13 +398,11 @@ 12D332AA12C669090093EEDB 1265C97712C7554E0050D02E 12F1147112C7A41D0064D7EE - 12C672F512C7C6BE0058B09B 12FE983612C7CEEB001B1702 12FE984A12C7E11C001B1702 12FE987912C7E281001B1702 12FE987A12C7E281001B1702 12C246F412C87C7C007E8339 - 12C2907612C8962900984F8F 12D7EC0512C8C5EA0021414C 12C5020712D8B82400EDCC4E 12D64B9F12D8EA0A00A1FE07 @@ -418,8 +418,11 @@ 125437CA12EF1E99007175C8 125437CB12EF1E99007175C8 12569C8612F0115B005A9113 - 1255F81112F03ED000CE7802 - 1255F81212F03ED000CE7802 + 121E3B3812F04EB9007B7E08 + 121E3B3A12F04EB9007B7E08 + 121FAA3512F051A200385F21 + 121FAA3612F051A200385F21 + 121FAA3812F051A200385F21 SplitCount @@ -431,14 +434,14 @@ GeometryConfiguration Frame - {{0, 0}, {813, 432}} + {{0, 0}, {813, 418}} RubberWindowFrame 257 172 1021 706 0 0 1440 878 Module PBXNavigatorGroup Proportion - 432pt + 418pt ContentConfiguration @@ -451,14 +454,14 @@ GeometryConfiguration Frame - {{0, 437}, {813, 228}} + {{0, 423}, {813, 242}} RubberWindowFrame 257 172 1021 706 0 0 1440 878 Module XCDetailModule Proportion - 228pt + 242pt Proportion @@ -477,9 +480,9 @@ TableOfContents - 1255F81512F03ED000CE7802 + 121FAA3C12F051A200385F21 1CE0B1FE06471DED0097A5F4 - 1255F81612F03ED000CE7802 + 121FAA3D12F051A200385F21 1CE0B20306471E060097A5F4 1CE0B20506471E060097A5F4 @@ -617,7 +620,7 @@ 5 WindowOrderList - 1CD10A99069EF8BA00B06720 + 1C530D57069F1CE1000CFCEE 12C26D3512B0DDFC00AF7F4B /Users/slice/Projects/Chameleons/chameleon/branches/slice/ChamMek/ChamMek.xcodeproj @@ -699,7 +702,7 @@ TableOfContents 12C26D3512B0DDFC00AF7F4B - 1255F81712F03ED000CE7802 + 121FAA2C12F0519B00385F21 1CD0528F0623707200166675 XCMainBuildResultsModuleGUID @@ -821,13 +824,13 @@ TableOfContents 1CD10A99069EF8BA00B06720 - 1255F81812F03ED000CE7802 + 121E3B4012F04EB9007B7E08 1C162984064C10D400B95A72 - 1255F81912F03ED000CE7802 - 1255F81A12F03ED000CE7802 - 1255F81B12F03ED000CE7802 - 1255F81C12F03ED000CE7802 - 1255F81D12F03ED000CE7802 + 121E3B4112F04EB9007B7E08 + 121E3B4212F04EB9007B7E08 + 121E3B4312F04EB9007B7E08 + 121E3B4412F04EB9007B7E08 + 121E3B4512F04EB9007B7E08 ToolbarConfiguration xcode.toolbar.config.debugV3 @@ -854,12 +857,14 @@ Dock + BecomeActive + ContentConfiguration PBXProjectModuleGUID 1CDD528C0622207200134675 PBXProjectModuleLabel - + boot.c StatusBarVisibility @@ -880,8 +885,6 @@ 510pt - BecomeActive - ContentConfiguration PBXProjectModuleGUID @@ -917,8 +920,8 @@ TableOfContents 1C530D57069F1CE1000CFCEE - 123D099F12F015ED00D5CB48 - 123D09A012F015ED00D5CB48 + 121FAA3312F0519B00385F21 + 121FAA3412F0519B00385F21 1CDD528C0622207200134675 1CD0528E0623707200166675