Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 1594) +++ branches/cparm/CHANGES (revision 1595) @@ -1,3 +1,5 @@ +- Added JrCs's Keylayout support in Keymapper +- Fixed an issue in AcpiCodec where the highest cpu frequency may not be added in the pstate package on some configurations - Improved detection of nb of core(s) and thread(s) for AMD processors - Updated keymapper ... - Applied scorpius's patch (to get an unstretched boot screen for nVidia cards on DVI) in boot0.s , disabled by default, Index: branches/cparm/i386/libsaio/bootstruct.h =================================================================== --- branches/cparm/i386/libsaio/bootstruct.h (revision 1594) +++ branches/cparm/i386/libsaio/bootstruct.h (revision 1595) @@ -123,8 +123,12 @@ char config[CONFIG_SIZE]; #endif - config_file_t bootConfig; // boot.plist + config_file_t bootConfig; // the booter boot.plist config_file_t overrideConfig; // additional boot.plist which can override bootConfig keys + + config_file_t SystemConfig; // system confing found in /Library/Preferences/SystemConfiguration/com.apple.Boot.plist + + config_file_t themeConfig; // theme.plist config_file_t smbiosConfig; // smbios.plist config_file_t helperConfig; // boot helper partition's boot.plist Index: branches/cparm/i386/libsaio/sys.c =================================================================== --- branches/cparm/i386/libsaio/sys.c (revision 1594) +++ branches/cparm/i386/libsaio/sys.c (revision 1595) @@ -657,6 +657,7 @@ return fdesc; } +#endif //========================================================================== // lseek() - Reposition the byte offset of the file descriptor from the // beginning of the file. Returns the relocated offset. @@ -672,7 +673,7 @@ return offset; } - +#if UNUSED //========================================================================== // tell() - Returns the byte offset of the file descriptor. Index: branches/cparm/i386/libsaio/cpu.c =================================================================== --- branches/cparm/i386/libsaio/cpu.c (revision 1594) +++ branches/cparm/i386/libsaio/cpu.c (revision 1595) @@ -813,6 +813,8 @@ DBG("Sticking with [BCLK: %dMhz, Bus-Ratio: %d]\n", fsbFrequency / 1000000, max_ratio); #endif currcoef = bus_ratio_max; + + tscFrequency = cpuFrequency; } else { @@ -918,7 +920,8 @@ } #endif if (!cpuFrequency) cpuFrequency = tscFrequency; - + if (!tscFrequency) tscFrequency = cpuFrequency; + p->CPU.MaxCoef = maxcoef; p->CPU.MaxDiv = maxdiv; p->CPU.CurrCoef = currcoef; Index: branches/cparm/i386/libsaio/acpi_tools.c =================================================================== --- branches/cparm/i386/libsaio/acpi_tools.c (revision 1594) +++ branches/cparm/i386/libsaio/acpi_tools.c (revision 1595) @@ -49,10 +49,10 @@ // 4) FACP Pointer in FacpPointer Variable (RSDP->RSDT->FACP) // 5) FACP(64) Pointer in FacpPointer64 Variable (RSDP->XSDT->FACP) // 6) DSDT Pointer in DsdtPointer Variable (RSDP->RSDT->FACP->DSDT) -// 7) DSDT(64) Pointer in DsdtPointer64 Variable (RSDP->RSDT->FACP->XDSDT) +// 7) DSDT(64) Pointer in DsdtPointer64 Variable (RSDP->XSDT->FACP->XDSDT) // 8) FACS Pointer in FacsPointer Variable (RSDP->RSDT->FACP->FACS) // 9) FACS(64) Pointer in FacsPointer64 Variable (RSDP->XSDT->FACP->XFACS) -// A) MADT Pointer in FacsPointer Variable (RSDP->RSDT->FACP->APIC) +// A) MADT Pointer in FacsPointer Variable (RSDP->RSDT->APIC) // B) MADT(64) Pointer in MadtPointer64 Variable (RSDP->XSDT->APIC) // //------------------------------------------------------------------------------- @@ -72,7 +72,6 @@ acpi_tables->RsdtPointer = null; acpi_tables->MadtPointer = null; acpi_tables->MadtPointer64 = null; - acpi_tables->SsdtPointer = null; acpi_tables->XsdtPointer = null; acpi_tables->FacpPointer64 = null; } Index: branches/cparm/i386/libsaio/ppm.h =================================================================== --- branches/cparm/i386/libsaio/ppm.h (revision 1594) +++ branches/cparm/i386/libsaio/ppm.h (revision 1595) @@ -98,7 +98,6 @@ ACPI_TABLE_RSDT *RsdtPointer; // Root System Description Table (RSDP->RSDT) ACPI_TABLE_MADT *MadtPointer; // Multiple APIC Description Table (RSDP->RSDT->APIC) ACPI_TABLE_MADT *MadtPointer64; // Multiple APIC Description Table (RSDP->XSDT->APIC) - ACPI_TABLE_SSDT *SsdtPointer; // Secondary System Description Table (RSDP->RSDT->SSDT) ACPI_TABLE_XSDT *XsdtPointer; // Extended Root System Description Table (RSDP->XSDT) ACPI_TABLE_FADT *FacpPointer64; // Fixed ACPI Description Table (RSDP->XSDT->FACP) } ACPI_TABLES; Index: branches/cparm/i386/libsaio/stringTable.c =================================================================== --- branches/cparm/i386/libsaio/stringTable.c (revision 1594) +++ branches/cparm/i386/libsaio/stringTable.c (revision 1595) @@ -477,41 +477,36 @@ bool getValueForKey( const char *key, const char **val, int *size, config_file_t *config ) { - const char *overrideVal; - int overrideSize; - bool override, ret; - - if (getValueForBootKey(bootArgs->CommandLine, key, val, size)) - return true; - - ret = getValueForConfigTableKey(config, key, val, size); - - // Try to find alternate keys in bootInfo->overrideConfig - // and prefer its values with the exceptions for - // "Kernel"="mach_kernel" and "Kernel Flags"="". - - if (config->canOverride) - { - if (getValueForConfigTableKey(&bootInfo->overrideConfig, key, &overrideVal, &overrideSize)) + const char *overrideVal; + int overrideSize; + bool ret; + + if (getValueForBootKey(bootArgs->CommandLine, key, val, size)) + return true; + + ret = getValueForConfigTableKey(config, key, val, size); + + // Try to find alternate keys in bootInfo->overrideConfig + // and prefer its values with the exceptions for + // "Kernel"="mach_kernel" and "Kernel Flags"="". + + if (config->canOverride) { - override = true; - - if (ret && (strcmp(key, "Kernel") == 0) && (strcmp(overrideVal, "mach_kernel") == 0)) - override = false; - - if (ret && (strcmp(key, "Kernel Flags") == 0) && (overrideSize == 0)) - override = false; - - if (override) - { - *val = overrideVal; - *size = overrideSize; - return true; - } + if (getValueForConfigTableKey(&bootInfo->overrideConfig, key, &overrideVal, &overrideSize) && overrideSize) + { + *val = overrideVal; + *size = overrideSize; + return true; + } + else if (getValueForConfigTableKey(&bootInfo->SystemConfig, key, &overrideVal, &overrideSize) && overrideSize) + { + *val = overrideVal; + *size = overrideSize; + return true; + } } - } - - return ret; + + return ret; } @@ -581,7 +576,7 @@ int loadConfigFile (const char *configFile, config_file_t *config) { int fd, count; - + if ((fd = open(configFile)) < 0) { return -1; } @@ -594,12 +589,12 @@ return ParseXMLFile(config->plist, &config->dictionary); } -/* loadSystemConfig +/* loadBooterConfig * * Returns 0 - successful. * -1 - unsuccesful. */ -int loadSystemConfig(config_file_t *config) +int loadBooterConfig(config_file_t *config) { char *dirspec[] = { "rd(0,0)/Extra/com.apple.Boot.plist", @@ -607,11 +602,11 @@ "bt(0,0)/Extra/com.apple.Boot.plist", "rd(0,0)/Extra/org.chameleon.Boot.plist", // Add compatibility with the trunk "/Extra/org.chameleon.Boot.plist", // Add compatibility with the trunk - "bt(0,0)/Extra/org.chameleon.Boot.plist", // Add compatibility with the trunk - "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" + "bt(0,0)/Extra/org.chameleon.Boot.plist" // Add compatibility with the trunk + }; int i,fd, count, ret=-1; - + for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++) { if ((fd = open(dirspec[i])) >= 0) @@ -627,7 +622,7 @@ // enable canOverride flag config->canOverride = true; - + break; } } @@ -649,17 +644,12 @@ int loadOverrideConfig(config_file_t *config) { char *dirspec[] = { - "rd(0,0)/Extra/com.apple.Boot.plist", "/Extra/com.apple.Boot.plist", - "bt(0,0)/Extra/com.apple.Boot.plist", - "rd(0,0)/Extra/org.chameleon.Boot.plist", // Add compatibility with the trunk - "/Extra/org.chameleon.Boot.plist", // Add compatibility with the trunk - "bt(0,0)/Extra/org.chameleon.Boot.plist", // Add compatibility with the trunk - "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" + "/Extra/org.chameleon.Boot.plist" }; - + int i,fd, count, ret=-1; - + for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++) { if ((fd = open(dirspec[i])) >= 0) @@ -681,7 +671,43 @@ ret = loadHelperConfig(config); } #endif + + return ret; +} +/* loadSystemConfig + * + * Returns 0 - successful. + * -1 - unsuccesful. + */ +int loadSystemConfig(config_file_t *config) +{ + char *dirspec[] = { + "rd(0,0)/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", + "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", + "bt(0,0)/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", + "rd(0,0)/Mac OS X Install Data/com.apple.Boot.plist", + "/Mac OS X Install Data/com.apple.Boot.plist", + "bt(0,0)/Mac OS X Install Data/com.apple.Boot.plist" + }; + int i,fd, count, ret=-1; + + for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++) + { + if ((fd = open(dirspec[i])) >= 0) + { + // read file + count = read(fd, config->plist, IO_CONFIG_DATA_SIZE); + close(fd); + + // build xml dictionary + ParseXMLFile(config->plist, &config->dictionary); + sysConfigValid = true; + ret=0; + break; + } + } + return ret; } Index: branches/cparm/i386/libsaio/saio_internal.h =================================================================== --- branches/cparm/i386/libsaio/saio_internal.h (revision 1594) +++ branches/cparm/i386/libsaio/saio_internal.h (revision 1595) @@ -169,6 +169,7 @@ extern bool getColorForKey(const char *key, unsigned int *val, config_file_t *configBuff); extern bool getDimensionForKey( const char *key, unsigned int *value, config_file_t *config, unsigned int dimension_max, unsigned int object_size ); extern int loadConfigFile(const char *configFile, config_file_t *configBuff); +extern int loadBooterConfig(config_file_t *configBuff); extern int loadSystemConfig(config_file_t *configBuff); #ifdef BOOT_HELPER_SUPPORT extern int loadHelperConfig(config_file_t *configBuff); Index: branches/cparm/i386/boot2/boot.c =================================================================== --- branches/cparm/i386/boot2/boot.c (revision 1594) +++ branches/cparm/i386/boot2/boot.c (revision 1595) @@ -102,6 +102,7 @@ BVRef bvr; BVRef menuBVR; BVRef bvChain; +static bool forcecache = false; static void zeroBSS(void); #ifdef SAFE_MALLOC @@ -417,8 +418,8 @@ bvChain = getBVChainForBIOSDev(gBIOSDev); setBootGlobals(bvChain); - // Load boot.plist config file - status = loadSystemConfig(&bootInfo->bootConfig); + // Load Booter boot.plist config file + status = loadBooterConfig(&bootInfo->bootConfig); Platform->CPU.isServer = false; getBoolForKey(kIsServer, &Platform->CPU.isServer, &bootInfo->bootConfig); // set this as soon as possible @@ -576,7 +577,7 @@ } else { - DBG("Incorrect parameter for option 'arch =' , please use x86_64 or i386\n") + DBG("Incorrect parameter for option 'arch =' , please use x86_64 or i386\n"); determineCpuArch(); } @@ -618,7 +619,7 @@ verbose("Loading Darwin %s\n", gMacOSVersion); { long cachetime, kerneltime, exttime; - if (trycache ) do { + if (trycache && !forcecache) do { // if we haven't found the kernel yet, don't use the cache ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime); @@ -635,7 +636,7 @@ { trycache = 0; bootInfo->adler32 = 0; - DBG("Warning: kernelcache too old, timestamp of the kernel > timestamp of the cache, kernelcache disabled !!!\n"); + DBG("Warning: No kernelcache found or kernelcache too old (timestamp of the kernel > timestamp of the cache), kernelcache disabled !!!\n"); break; } @@ -817,6 +818,7 @@ } } strlcpy(gBootKernelCacheFile, buffer, sizeof(gBootKernelCacheFile)+1); + forcecache = true; } else { @@ -955,8 +957,8 @@ { cnt = VALUE_SIZE; } - cnt++; - strlcpy(valueBuffer + 1, val, cnt); + //cnt++; + strlcpy(valueBuffer + 1, val, cnt+1); if (!copyArgument( kRootDeviceKey, valueBuffer, cnt, &argP, &ArgCntRemaining)) { free(valueBuffer); Index: branches/cparm/i386/boot2/options.c =================================================================== --- branches/cparm/i386/boot2/options.c (revision 1594) +++ branches/cparm/i386/boot2/options.c (revision 1595) @@ -955,7 +955,14 @@ // This is not a mandatory opeartion anymore. loadOverrideConfig(&bootInfo->overrideConfig); - + + // Load System com.apple.boot.plist config file + loadSystemConfig(&bootInfo->SystemConfig); + +#if virtualM || PCI_FIX // we can simply make an option for this fix + addBootArg("npci=0x2000"); +#endif + // Use the kernel name specified by the user, or fetch the name // in the config table, or use the default if not specified. // Specifying a kernel name on the command line, or specifying Index: branches/cparm/i386/modules/SMBiosGetters/smbios_getters.h =================================================================== --- branches/cparm/i386/modules/SMBiosGetters/smbios_getters.h (revision 1594) +++ branches/cparm/i386/modules/SMBiosGetters/smbios_getters.h (revision 1595) @@ -27,6 +27,7 @@ extern bool getProcessorInformationExternalClock(returnType *value); extern bool getProcessorInformationMaximumClock(returnType *value); +extern bool getProcessorInformationCurrentClock(returnType *value); extern bool getSMBOemProcessorBusSpeed(returnType *value); extern bool getSMBOemProcessorType(returnType *value); extern bool getSMBMemoryDeviceMemoryType(returnType *value); Index: branches/cparm/i386/modules/SMBiosGetters/mysmbios.c =================================================================== --- branches/cparm/i386/modules/SMBiosGetters/mysmbios.c (revision 1594) +++ branches/cparm/i386/modules/SMBiosGetters/mysmbios.c (revision 1595) @@ -49,6 +49,7 @@ /* Processor Information */ #define kSMBProcessorInformationExternalClockKey "SMexternalclock" #define kSMBProcessorInformationMaximumClockKey "SMmaximalclock" +#define kSMBProcessorInformationCurrentClockKey "SMcurrentclock" /* Memory Device */ #define kSMBMemoryDeviceDeviceLocatorKey "SMmemdevloc" @@ -222,6 +223,9 @@ {kSMBTypeProcessorInformation, kSMBWord, getFieldOffset(SMBProcessorInformation, maximumClock), kSMBProcessorInformationMaximumClockKey, getProcessorInformationMaximumClock, NULL}, + + {kSMBTypeProcessorInformation, kSMBWord, getFieldOffset(SMBProcessorInformation, currentClock), kSMBProcessorInformationCurrentClockKey, + getProcessorInformationCurrentClock, NULL}, {kSMBTypeProcessorInformation, kSMBString, getFieldOffset(SMBProcessorInformation, serialNumber), NULL, NULL, NULL}, Index: branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c =================================================================== --- branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c (revision 1594) +++ branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c (revision 1595) @@ -28,10 +28,21 @@ bool getProcessorInformationMaximumClock(returnType *value) { + // Note: it seems that AppleSMBIOS use the maximum clock to set the cpu clock + // that is showed in "About this mac" or in the System Information. + // in my opinion the current clock should be used for this. + // value->word = Platform->CPU.TSCFrequency/1000000; + value->word = Platform->CPU.CPUFrequency/1000000; return true; } +bool getProcessorInformationCurrentClock(returnType *value) +{ + value->word = Platform->CPU.CPUFrequency/1000000; + return true; +} + bool getSMBOemProcessorBusSpeed(returnType *value) { if (Platform->CPU.Vendor == 0x756E6547) // Intel Index: branches/cparm/i386/modules/Keymapper/Keylayout.c =================================================================== --- branches/cparm/i386/modules/Keymapper/Keylayout.c (revision 0) +++ branches/cparm/i386/modules/Keymapper/Keylayout.c (revision 1595) @@ -0,0 +1,176 @@ +/* + * Keymapper.c + * Chameleon + * + * Created by JrCs on 28/08/11. + * Copyright 2011. All rights reserved. + * + */ + +#include "libsaio.h" +#include "term.h" +#include "modules.h" +#include "Keylayout.h" +#include "bootstruct.h" + +#ifndef DEBUG_KLAYOUT +#define DEBUG_KLAYOUT 0 +#endif + +#if DEBUG_KLAYOUT +#define DBG(x...) printf(x) +#else +#define DBG(x...) +#endif + +#define kKeyboardLayout "KeyboardLayout" + +struct keyboard_layout *current_layout = NULL; + +int getchar_replacement() { + int code = bgetc(); + int status = readKeyboardShiftFlags(); + uint8_t scancode = code >> 8; + + // Special scancode sent when alt + some keys are pressed + if (scancode >= 0x78 && scancode <= 0x83) + scancode -= 0x76; + + if (scancode < KEYBOARD_MAP_SIZE && !(status & (STATUS_LCTRL| STATUS_RCTRL))) { + int key; + if ((status & (STATUS_LALT|STATUS_RALT)) && + (status & (STATUS_LSHIFT|STATUS_RSHIFT|STATUS_CAPS))) { + key=current_layout->keyboard_map_shift_alt[scancode]; + } + else if (status & (STATUS_LSHIFT|STATUS_RSHIFT|STATUS_CAPS)) + key=current_layout->keyboard_map_shift[scancode]; + else if (status & (STATUS_LALT|STATUS_RALT)) + key=current_layout->keyboard_map_alt[scancode]; + else + key=current_layout->keyboard_map[scancode]; + + if (key != 0) // do the mapping + code = key; + } + + if (ASCII_KEY(code) != 0) // if ascii not null return it + code = ASCII_KEY(code); + + //printf("Code: %04x\n",code); + return (code); +} + +static uint32_t load_keyboard_layout_file(const char *filename) { + int fd; + char magic[KEYBOARD_LAYOUTS_MAGIC_SIZE]; + uint32_t version; + +#if UNUSED + if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) { +#else + if ((fd = open_bvdev("bt(0,0)", filename)) < 0) { +#endif + goto fail; // fail + } + + if (read(fd, magic, sizeof(magic)) != sizeof(magic)) { + printf("Can't find magic in keyboard layout file: %s\n", filename); + goto fail; + } + + if (memcmp (magic, KEYBOARD_LAYOUTS_MAGIC, KEYBOARD_LAYOUTS_MAGIC_SIZE) != 0) { + printf("Invalid magic code in keyboard layout file: %s\n", filename); + goto fail; + } + + if (read(fd, (char*) &version, sizeof(version)) != sizeof(version)) { + printf("Can't get version of keyboard layout file: %s\n", filename); + goto fail; + } + + if (version != KEYBOARD_LAYOUTS_VERSION) { + verbose("Bad version for keyboard layout file %s expected v%d found v%d\n", + filename, KEYBOARD_LAYOUTS_VERSION, version); + goto fail; + } + + if (current_layout) + free(current_layout); + + current_layout = malloc(sizeof(*current_layout)); + if (!current_layout) + goto fail; + + b_lseek(fd, KEYBOARD_LAYOUTS_MAP_OFFSET, 0); + + if (read(fd, (char*) current_layout, sizeof(*current_layout)) != sizeof(*current_layout)) { + printf("Wrong keyboard layout file %s size\n", filename); + goto fail; + } + + close(fd); + + return 1; + + fail: + + if (current_layout) { + free(current_layout); + current_layout = NULL; + } + return 0; +} + +uint32_t Keylayout_real_start() +{ + char layoutPath[512]; + const char *val; + int len; + +#ifdef TRUNK +#define Config chameleonConfig +#else +#define Config bootConfig +#endif + + if (getValueForKey("KeyLayout", &val, &len, &bootInfo->Config)) + { + sprintf(layoutPath, "/Extra/Keymaps/%s", val); + // Add the extension if needed + if (len <= 4 || strcmp(val+len-4,".lyt") != 0) + strncat(layoutPath, ".lyt", sizeof(layoutPath)); + + if (!load_keyboard_layout_file(layoutPath)) + { + DBG("Can't load %s keyboard layout file. Keylayout will not be used !\n", + layoutPath); + return 0; + } + +#ifdef TRUNK + if (!replace_function("_getchar", &getchar_replacement)) + { + printf("no function getchar() to replace. Keylayout will not be used ! \n"); + + return 0; + } + +#else + if (replace_function("_getc", &getchar_replacement) != EFI_SUCCESS ) + { + printf("no function getc() to replace. Keylayout will not be used ! \n"); + return 0; + } +#endif + + return 1; + + } + return 0; +} + + +void Keylayout_start() +{ + Keylayout_real_start(); +} \ No newline at end of file Index: branches/cparm/i386/modules/Keymapper/Keylayout.h =================================================================== --- branches/cparm/i386/modules/Keymapper/Keylayout.h (revision 0) +++ branches/cparm/i386/modules/Keymapper/Keylayout.h (revision 1595) @@ -0,0 +1,31 @@ +/* + * Keylayout.h + * Chameleon + * + * Created by JrCs on 28/8/11. + * Copyright 2011. All rights reserved. + * + */ + + +#ifndef __KEYLAYOUT_H +#define __KEYLAYOUT_H + +#define KEYBOARD_LAYOUTS_MAGIC "CHAMLAYT" +#define KEYBOARD_LAYOUTS_MAGIC_SIZE (sizeof(KEYBOARD_LAYOUTS_MAGIC) - 1) +#define KEYBOARD_LAYOUTS_VERSION 3 +#define KEYBOARD_LAYOUTS_MAP_OFFSET 0x10 // 0x10 offset of the map in layout file + +#define KEYBOARD_MAP_SIZE 0x38 + +struct keyboard_layout +{ + uint16_t keyboard_map[KEYBOARD_MAP_SIZE]; + uint16_t keyboard_map_shift[KEYBOARD_MAP_SIZE]; + uint16_t keyboard_map_alt[KEYBOARD_MAP_SIZE]; + uint16_t keyboard_map_shift_alt[KEYBOARD_MAP_SIZE]; +}; + +extern uint32_t Keylayout_real_start(); + +#endif Index: branches/cparm/i386/modules/Keymapper/Makefile =================================================================== --- branches/cparm/i386/modules/Keymapper/Makefile (revision 1594) +++ branches/cparm/i386/modules/Keymapper/Makefile (revision 1595) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -KEY_MAPPER_OBJS = Keymapper.o +KEY_MAPPER_OBJS = Keymapper.o Keylayout.o SFILES = CFILES = @@ -71,6 +71,7 @@ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ $(OBJROOT)/Keymapper.o \ + $(OBJROOT)/Keylayout.o \ -o $(SYMROOT)/$(MODULE_NAME).dylib Index: branches/cparm/i386/modules/Keymapper/term.h =================================================================== --- branches/cparm/i386/modules/Keymapper/term.h (revision 0) +++ branches/cparm/i386/modules/Keymapper/term.h (revision 1595) @@ -0,0 +1,59 @@ +/* + * term.h + * Chameleon + * + * Created by JrCs on 30/08/11. + * Copyright 2011. All rights reserved. + * + */ + +#ifndef __LIBSAIO_TERM_H +#define __LIBSAIO_TERM_H + +#define ASCII_KEY_MASK 0x7f +#define ASCII_KEY(x) ((x & ASCII_KEY_MASK)) + +#define KEY_BKSP 0x0008 +#define KEY_TAB 0x0009 +#define KEY_ENTER 0x000d +#define KEY_ESC 0x001b +#define KEY_PRTSC 0x002a +#define KEY_LEFT 0x4b00 +#define KEY_RIGHT 0x4d00 +#define KEY_UP 0x4800 +#define KEY_DOWN 0x5000 +#define KEY_HOME 0x4700 +#define KEY_END 0x4f00 +#define KEY_CENTER 0x4c00 +#define KEY_INS 0x5200 +#define KEY_DEL 0x5300 +#define KEY_PGUP 0x4900 +#define KEY_PGDN 0x5100 +#define KEY_F1 0x3b00 +#define KEY_F2 0x3c00 +#define KEY_F3 0x3d00 +#define KEY_F4 0x3e00 +#define KEY_F5 0x3f00 +#define KEY_F6 0x4000 +#define KEY_F7 0x4100 +#define KEY_F8 0x4200 +#define KEY_F9 0x4300 +#define KEY_F10 0x4400 +#define KEY_F11 0x5700 +#define KEY_F12 0x5800 + +// Key code for input that shouldn't echoed back +#define KEY_NOECHO 0xff00 + +/* Bitmasks for modifier keys */ +#define STATUS_RSHIFT (1 << 0) +#define STATUS_LSHIFT (1 << 1) +#define STATUS_RCTRL (1 << 2) +#define STATUS_RALT (1 << 3) +#define STATUS_SCROLL (1 << 4) +#define STATUS_NUM (1 << 5) +#define STATUS_CAPS (1 << 6) +#define STATUS_LCTRL (1 << 8) +#define STATUS_LALT (1 << 9) + +#endif /* !__LIBSAIO_TERM_H */ Index: branches/cparm/i386/modules/Keymapper/Keymapper.c =================================================================== --- branches/cparm/i386/modules/Keymapper/Keymapper.c (revision 1594) +++ branches/cparm/i386/modules/Keymapper/Keymapper.c (revision 1595) @@ -11,6 +11,7 @@ #include "bootstruct.h" #include "xml.h" #include "modules.h" +#include "Keylayout.h" #define kEnableKeyMap "EnableKeyMapper" static int AZERTY_switch(int c); @@ -21,7 +22,6 @@ { int c = bgetc(); - //execute_hook("Keymapper", &c, NULL, NULL, NULL, NULL, NULL); Keymapper_hook(&c, NULL, NULL, NULL, NULL, NULL); if ((c & 0xff) == 0) @@ -195,12 +195,13 @@ static char *map_kb_type = NULL; static TagPtr match_map = NULL; +// Faster method and no need to (re-)compile the map, everything is done with xml (i have a keymap maker made in cocoa and with a gui that i have don't released yet) void Keymapper_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) { int *ret = (int *)arg1; int c = *(int *)ret; - + // Check for xml map in the config file if (match_map == NULL) match_map = XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"KeyboardMap"); @@ -217,6 +218,7 @@ } } + // Check for built-in map if (map_kb_type == NULL) { TagPtr match_type; @@ -237,12 +239,34 @@ void Keymapper_start() { +#ifdef TRUNK +#define Config chameleonConfig +#else +#define Config bootConfig +#endif + bool enable = true; - getBoolForKey(kEnableKeyMap, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableKeyMap, &enable, &bootInfo->Config) ; if (enable) { - //register_hook_callback("Keymapper", &Keymapper_hook); - replace_function("_getc", &Keymapper_getc); + if (Keylayout_real_start()) + { + return; + } + +#ifdef TRUNK + if (!replace_function("_getchar", &Keymapper_getc)) + { + printf("no function getchar() to replace. Keymapper will not be used ! \n"); + + } +#else + if (replace_function("_getc", &Keymapper_getc) != EFI_SUCCESS) + { + printf("no function getc() to replace. Keymapper will not be used ! \n"); + } +#endif + } } \ No newline at end of file Index: branches/cparm/i386/modules/ACPICodec/acpidecode.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpidecode.c (revision 1594) +++ branches/cparm/i386/modules/ACPICodec/acpidecode.c (revision 1595) @@ -92,20 +92,22 @@ DBG("Package length=0x%02x\n", *length); } +#if UNUSED static bool ns_match(struct acpi_namespace *ns1, struct acpi_namespace *ns2) { U32 i; if (ns1->depth != ns2->depth) return false; - + for (i = 0; i < ns1->depth; i++) if (ns1->nameseg[i] != ns2->nameseg[i]) return false; - + return true; } U32 acpi_ns_found; +#endif static U8 *parse_acpi_namestring(const struct acpi_namespace *ns_context, struct acpi_namespace *ns, U8 * current, U8 * end) { @@ -183,15 +185,17 @@ UIDPointer = current; } +#if UNUSED if (!acpi_ns_found) { U32 index; - + for (index = 0; index < acpi_processor_count; index++) if (ns_match(ns, &acpi_processors[index].ns)) { acpi_ns_found = 1; break; } } +#endif return current; } Index: branches/cparm/i386/modules/ACPICodec/acpidecode.h =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpidecode.h (revision 1594) +++ branches/cparm/i386/modules/ACPICodec/acpidecode.h (revision 1595) @@ -59,8 +59,10 @@ extern U32 acpi_processor_count; extern struct acpi_processor acpi_processors[CPU_MAP_LIMIT]; +#if UNUSED /* If 0, look for a processor namespace and set to 1 if found. */ extern U32 acpi_ns_found; +#endif extern U8* UIDPointer; Index: branches/cparm/i386/modules/ACPICodec/acpi_codec.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 1594) +++ branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 1595) @@ -429,7 +429,7 @@ ACPI_TABLE_FADT *fadt_mod = patch_fadt(fadt_conv, ((ACPI_TABLE_DSDT*)((U32)fadt->XDsdt)), false); if (fadt_mod == (void*)0ul) { - printf("Error: Failed to patch FADT Table, fallback to fadt original pointer\n"); + printf("Error: Failed to patch FADT Table, trying wiht the original fadt pointer\n"); fadt_mod = fadt; } @@ -713,46 +713,46 @@ { /* aml_generator symbols */ aml_create_node = (void*)lookup_all_symbols("_aml_create_node"); - if (aml_create_node == NULL) goto Failed; + if (aml_create_node == (void*)0xFFFFFFFF) goto Failed; aml_add_buffer = (void*)lookup_all_symbols("_aml_add_buffer"); - if (aml_add_buffer == NULL) goto Failed; + if (aml_add_buffer == (void*)0xFFFFFFFF) goto Failed; aml_add_byte = (void*)lookup_all_symbols("_aml_add_byte"); - if (aml_add_byte == NULL) goto Failed; + if (aml_add_byte == (void*)0xFFFFFFFF) goto Failed; aml_add_word = (void*)lookup_all_symbols("_aml_add_word"); - if (aml_add_word == NULL) goto Failed; + if (aml_add_word == (void*)0xFFFFFFFF) goto Failed; aml_add_dword = (void*)lookup_all_symbols("_aml_add_dword"); - if (aml_add_dword == NULL) goto Failed; + if (aml_add_dword == (void*)0xFFFFFFFF) goto Failed; aml_add_qword = (void*)lookup_all_symbols("_aml_add_qword"); - if (aml_add_qword == NULL) goto Failed; + if (aml_add_qword == (void*)0xFFFFFFFF) goto Failed; aml_add_scope = (void*)lookup_all_symbols("_aml_add_scope"); - if (aml_add_scope == NULL) goto Failed; + if (aml_add_scope == (void*)0xFFFFFFFF) goto Failed; aml_add_name = (void*)lookup_all_symbols("_aml_add_name"); - if (aml_add_name == NULL) goto Failed; + if (aml_add_name == (void*)0xFFFFFFFF) goto Failed; aml_add_package = (void*)lookup_all_symbols("_aml_add_package"); - if (aml_add_package == NULL) goto Failed; + if (aml_add_package == (void*)0xFFFFFFFF) goto Failed; aml_add_alias = (void*)lookup_all_symbols("_aml_add_alias"); - if (aml_add_alias == NULL) goto Failed; + if (aml_add_alias == (void*)0xFFFFFFFF) goto Failed; aml_destroy_node = (void*)lookup_all_symbols("_aml_destroy_node"); - if (aml_destroy_node == NULL) goto Failed; + if (aml_destroy_node == (void*)0xFFFFFFFF) goto Failed; aml_calculate_size = (void*)lookup_all_symbols("_aml_calculate_size"); - if (aml_calculate_size == NULL) goto Failed; + if (aml_calculate_size == (void*)0xFFFFFFFF) goto Failed; aml_write_node = (void*)lookup_all_symbols("_aml_write_node"); - if (aml_write_node == NULL) goto Failed; + if (aml_write_node == (void*)0xFFFFFFFF) goto Failed; aml_add_to_parent = (void*)lookup_all_symbols("_aml_add_to_parent"); - if (aml_add_to_parent == NULL) goto Failed; + if (aml_add_to_parent == (void*)0xFFFFFFFF) goto Failed; DBG("struct aml_chunk* _aml_create_node: 0x%x\n",(UInt32)aml_create_node); DBG("struct aml_chunk* _aml_add_buffer: 0x%x\n",(UInt32)aml_add_buffer); @@ -1764,17 +1764,17 @@ #if BETA printf("min_ratio : %d\n", cpu->min_ratio); #endif + printf("max_ratio_as_cfg : %d\n", cpu->max_ratio_as_cfg); + printf("max_ratio_as_mfg : %d\n", cpu->max_ratio_as_mfg); + printf("turbo_available : %d\n",cpu->turbo_available); - + printf("core_c1_supported : %d\n",cpu->core_c1_supported); + printf("core_c2_supported : %d\n",cpu->core_c1_supported); printf("core_c3_supported : %d\n",cpu->core_c3_supported); printf("core_c6_supported : %d\n",cpu->core_c6_supported); printf("core_c7_supported : %d\n",cpu->core_c7_supported); printf("mwait_supported : %d\n",cpu->mwait_supported); - - printf("turbo_available : %d\n",cpu->turbo_available); - - printf("core_c1_supported : %d\n",cpu->core_c1_supported); #if BUILD_ACPI_TSS || pstate_power_support if (is_sandybridge() || is_jaketown()) @@ -2239,6 +2239,25 @@ if (!Frequency || Frequency > p_states[0].Frequency ) continue; U8 curr_ratio = (Frequency / (Platform->CPU.FSBFrequency / 10000000 )); + + + { + U8 fixed_ratio = (Frequency / (Platform->CPU.FSBFrequency / 1000000 ))*10; + U8 diff = curr_ratio - fixed_ratio ; + + if (diff) + { + if (diff < 5) + { + curr_ratio = fixed_ratio; + } + else + { + curr_ratio = fixed_ratio + 5; + } + } + + } if (curr_ratio > maxPSratio || minPSratio > curr_ratio) goto dropPstate; @@ -3312,20 +3331,38 @@ } //----------------------------------------------------------------------------- -static void * buildPPC(void * current) +static void * buildPPC(void * current/*, U8 valueToReturn*/) { ACPI_SMALL_METHOD * ppc = current; current = buildSmallMethod(current, NAMESEG("_PPC"), 0); current = buildReturnZero(current); + //current = buildReturnOpcode(current, valueToReturn); + // Update package length in PPC object ppc->packageLength = (U8) ( (U8 *)current - (U8 *)&ppc->packageLength ); return(current); } +#if UNUSED //----------------------------------------------------------------------------- +static void * buildPDL(void * current, U8 valueToReturn) +{ + ACPI_SMALL_METHOD * pdl = current; + current = buildSmallMethod(current, NAMESEG("_PDL"), 0); + + current = buildReturnOpcode(current, valueToReturn); + + // Update package length in PDL object + pdl->packageLength = (U8) ( (U8 *)current - (U8 *)&pdl->packageLength ); + + return(current); +} +#endif + +//----------------------------------------------------------------------------- static void * buildPCT(void * current) { static const ACPI_GENERIC_ADDRESS pct_gas[] = { @@ -4988,7 +5025,51 @@ } } - +#if HARDCODED_DSDT + do { +#include "dsdt_PRLSACPI.h" + + U8 index = 0; + + if ((get_new_table_in_list(new_table_list, NAMESEG("DSDT"), &new_table_index)) != (void*)0ul ) + { + index = new_table_index; + } + else + { + U8 empty = get_0ul_index_in_list(new_table_list, false); + if (empty != ACPI_TABLE_LIST_FULL_NON_RESERVED) + { + index = empty; + } + else + { + printf("Error: not enought reserved space in the new acpi list for the Harcoded DSDT table,\n "); + printf(" please increase the RESERVED_AERA\n"); + + break; + } + } + + if (index) + { + + ACPI_TABLE_DSDT *tmp = (ACPI_TABLE_DSDT *)DsdtAmlCode; + ACPI_TABLE_DSDT *hardcoded_dsdt = (void *)0ul; + + hardcoded_dsdt = (ACPI_TABLE_DSDT *)AllocateKernelMemory(tmp->Header.Length); + memcpy(hardcoded_dsdt, tmp, tmp->Header.Length); + new_table_list[index] = (U32)hardcoded_dsdt; // add the patched table to the list + } + else + { + printf("Error: not enought reserved space in the new acpi list for the Harcoded DSDT table,\n "); + printf(" please increase the RESERVED_AERA\n"); + + break; + } + } while (0); +#endif if (speed_step) { gen_psta= true;