Chameleon

Chameleon Commit Details

Date:2011-10-03 13:36:29 (9 years 2 months ago)
Author:armel cadet-petit
Commit:1595
Parents: 1594
Message:fixed a bug in acpicodec
Changes:
A/branches/cparm/i386/modules/Keymapper/Keylayout.h
A/branches/cparm/i386/modules/Keymapper/term.h
A/branches/cparm/i386/modules/Keymapper/Keylayout.c
M/branches/cparm/i386/libsaio/bootstruct.h
M/branches/cparm/i386/libsaio/stringTable.c
M/branches/cparm/i386/libsaio/sys.c
M/branches/cparm/i386/modules/SMBiosGetters/smbios_getters.h
M/branches/cparm/i386/modules/Keymapper/Makefile
M/branches/cparm/i386/modules/Keymapper/Keymapper.c
M/branches/cparm/i386/modules/ACPICodec/acpidecode.c
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
M/branches/cparm/i386/modules/ACPICodec/acpidecode.h
M/branches/cparm/i386/libsaio/cpu.c
M/branches/cparm/i386/libsaio/acpi_tools.c
M/branches/cparm/i386/libsaio/saio_internal.h
M/branches/cparm/i386/boot2/options.c
M/branches/cparm/i386/libsaio/ppm.h
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c
M/branches/cparm/i386/modules/ACPICodec/acpi_codec.c
M/branches/cparm/CHANGES

File differences

branches/cparm/CHANGES
1
2
13
24
35
- 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,
branches/cparm/i386/libsaio/bootstruct.h
123123
124124
125125
126
126
127127
128
129
130
131
128132
129133
130134
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
branches/cparm/i386/libsaio/sys.c
657657
658658
659659
660
660661
661662
662663
......
672673
673674
674675
675
676
676677
677678
678679
return fdesc;
}
#endif
//==========================================================================
// lseek() - Reposition the byte offset of the file descriptor from the
// beginning of the file. Returns the relocated offset.
return offset;
}
#if UNUSED
//==========================================================================
// tell() - Returns the byte offset of the file descriptor.
branches/cparm/i386/libsaio/cpu.c
813813
814814
815815
816
817
816818
817819
818820
......
918920
919921
920922
921
923
924
922925
923926
924927
DBG("Sticking with [BCLK: %dMhz, Bus-Ratio: %d]\n", fsbFrequency / 1000000, max_ratio);
#endif
currcoef = bus_ratio_max;
tscFrequency = cpuFrequency;
}
else
{
}
#endif
if (!cpuFrequency) cpuFrequency = tscFrequency;
if (!tscFrequency) tscFrequency = cpuFrequency;
p->CPU.MaxCoef = maxcoef;
p->CPU.MaxDiv = maxdiv;
p->CPU.CurrCoef = currcoef;
branches/cparm/i386/libsaio/acpi_tools.c
4949
5050
5151
52
52
5353
5454
55
55
5656
5757
5858
......
7272
7373
7474
75
7675
7776
7877
// 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)
//
//-------------------------------------------------------------------------------
acpi_tables->RsdtPointer = null;
acpi_tables->MadtPointer = null;
acpi_tables->MadtPointer64 = null;
acpi_tables->SsdtPointer = null;
acpi_tables->XsdtPointer = null;
acpi_tables->FacpPointer64 = null;
}
branches/cparm/i386/libsaio/ppm.h
9898
9999
100100
101
102101
103102
104103
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;
branches/cparm/i386/libsaio/stringTable.c
477477
478478
479479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
480
481
482
483
484
485
486
487
488
489
490
491
492
493
496494
497
498
499
500
501
502
503
504
505
506
507
508
509
510
495
496
497
498
499
500
501
502
503
504
505
506
511507
512
513
514
508
509
515510
516511
517512
......
581576
582577
583578
584
579
585580
586581
587582
......
594589
595590
596591
597
592
598593
599594
600595
601596
602
597
603598
604599
605600
......
607602
608603
609604
610
611
605
606
612607
613608
614
609
615610
616611
617612
......
627622
628623
629624
630
625
631626
632627
633628
......
649644
650645
651646
652
653647
654
655
656
657
658
648
659649
660
650
661651
662
652
663653
664654
665655
......
681671
682672
683673
674
675
676
684677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
685711
686712
687713
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;
}
int loadConfigFile (const char *configFile, config_file_t *config)
{
int fd, count;
if ((fd = open(configFile)) < 0) {
return -1;
}
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",
"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)
// enable canOverride flag
config->canOverride = true;
break;
}
}
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)
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;
}
branches/cparm/i386/libsaio/saio_internal.h
169169
170170
171171
172
172173
173174
174175
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);
branches/cparm/i386/boot2/boot.c
102102
103103
104104
105
105106
106107
107108
......
417418
418419
419420
420
421
421
422
422423
423424
424425
......
576577
577578
578579
579
580
580581
581582
582583
......
618619
619620
620621
621
622
622623
623624
624625
......
635636
636637
637638
638
639
639640
640641
641642
......
817818
818819
819820
821
820822
821823
822824
......
955957
956958
957959
958
959
960
961
960962
961963
962964
BVRef bvr;
BVRef menuBVR;
BVRef bvChain;
static bool forcecache = false;
static void zeroBSS(void);
#ifdef SAFE_MALLOC
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
}
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();
}
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);
{
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;
}
}
}
strlcpy(gBootKernelCacheFile, buffer, sizeof(gBootKernelCacheFile)+1);
forcecache = true;
}
else
{
{
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);
branches/cparm/i386/boot2/options.c
955955
956956
957957
958
958
959
960
961
962
963
964
965
959966
960967
961968
// 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
branches/cparm/i386/modules/SMBiosGetters/smbios_getters.h
2727
2828
2929
30
3031
3132
3233
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);
branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
4949
5050
5151
52
5253
5354
5455
......
222223
223224
224225
226
227
228
225229
226230
227231
/* Processor Information */
#define kSMBProcessorInformationExternalClockKey"SMexternalclock"
#define kSMBProcessorInformationMaximumClockKey"SMmaximalclock"
#define kSMBProcessorInformationCurrentClockKey"SMcurrentclock"
/* Memory Device */
#define kSMBMemoryDeviceDeviceLocatorKey"SMmemdevloc"
{kSMBTypeProcessorInformation,kSMBWord,getFieldOffset(SMBProcessorInformation, maximumClock),kSMBProcessorInformationMaximumClockKey,
getProcessorInformationMaximumClock,NULL},
{kSMBTypeProcessorInformation,kSMBWord,getFieldOffset(SMBProcessorInformation, currentClock),kSMBProcessorInformationCurrentClockKey,
getProcessorInformationCurrentClock,NULL},
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, serialNumber),NULL,NULL,NULL},
branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c
2828
2929
3030
31
32
33
34
35
3136
3237
3338
3439
40
41
42
43
44
45
3546
3647
3748
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
branches/cparm/i386/modules/Keymapper/Keylayout.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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;
intlen;
#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();
}
branches/cparm/i386/modules/Keymapper/Keylayout.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
branches/cparm/i386/modules/Keymapper/Makefile
4545
4646
4747
48
48
4949
5050
5151
......
7171
7272
7373
74
7475
7576
7677
VPATH = $(OBJROOT):$(SYMROOT)
KEY_MAPPER_OBJS = Keymapper.o
KEY_MAPPER_OBJS = Keymapper.o Keylayout.o
SFILES =
CFILES =
-final_output $(MODULE_NAME) \
-macosx_version_min 10.6 \
$(OBJROOT)/Keymapper.o \
$(OBJROOT)/Keylayout.o \
-o $(SYMROOT)/$(MODULE_NAME).dylib
branches/cparm/i386/modules/Keymapper/term.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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 */
branches/cparm/i386/modules/Keymapper/Keymapper.c
1111
1212
1313
14
1415
1516
1617
......
2122
2223
2324
24
2525
2626
2727
......
195195
196196
197197
198
198199
199200
200201
201202
202203
203
204
204205
205206
206207
......
217218
218219
219220
221
220222
221223
222224
......
237239
238240
239241
242
243
244
245
246
247
240248
241
249
242250
243251
244252
245
246
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
247271
248272
#include "bootstruct.h"
#include "xml.h"
#include "modules.h"
#include "Keylayout.h"
#define kEnableKeyMap "EnableKeyMapper"
static int AZERTY_switch(int c);
{
int c = bgetc();
//execute_hook("Keymapper", &c, NULL, NULL, NULL, NULL, NULL);
Keymapper_hook(&c, NULL, NULL, NULL, NULL, NULL);
if ((c & 0xff) == 0)
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");
}
}
// Check for built-in map
if (map_kb_type == NULL)
{
TagPtr match_type;
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
}
}
branches/cparm/i386/modules/ACPICodec/acpidecode.c
9292
9393
9494
95
9596
9697
9798
9899
99100
100
101
101102
102103
103104
104
105
105106
106107
107108
108109
110
109111
110112
111113
......
183185
184186
185187
188
186189
187190
188
191
189192
190193
191194
192195
193196
194197
198
195199
196200
197201
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)
{
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;
}
branches/cparm/i386/modules/ACPICodec/acpidecode.h
5959
6060
6161
62
6263
6364
65
6466
6567
6668
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;
branches/cparm/i386/modules/ACPICodec/acpi_codec.c
429429
430430
431431
432
432
433433
434434
435435
......
713713
714714
715715
716
716
717717
718718
719
719
720720
721721
722
722
723723
724724
725
725
726726
727727
728
728
729729
730730
731
731
732732
733733
734
734
735735
736736
737
737
738738
739739
740
740
741741
742742
743
743
744744
745745
746
746
747747
748748
749
749
750750
751751
752
752
753753
754754
755
755
756756
757757
758758
......
17641764
17651765
17661766
1767
1768
1769
17671770
1768
1771
17691772
1773
17701774
17711775
17721776
17731777
1774
1775
1776
1777
17781778
17791779
17801780
......
22392239
22402240
22412241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
22422261
22432262
22442263
......
33123331
33133332
33143333
3315
3334
33163335
33173336
33183337
33193338
33203339
33213340
3341
3342
33223343
33233344
33243345
33253346
33263347
33273348
3349
33283350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
33293366
33303367
33313368
......
49885025
49895026
49905027
4991
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
49925073
49935074
49945075
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;
}
{
/* 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);
#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())
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;
}
//-----------------------------------------------------------------------------
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[] = {
}
}
#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;

Archive Download the corresponding diff file

Revision: 1595