Chameleon

Chameleon Svn Source Tree

Root/branches/slice/trunkM/i386/modules/KernelPatcher/include/kernel_patcher.h

1/*
2 * Copyright (c) 2009 Evan Lojewski. All rights reserved.
3 *
4 */
5
6#include <mach-o/loader.h>
7#include <mach-o/nlist.h>
8
9#ifndef __BOOT2_KERNEL_PATCHER_H
10#define __BOOT2_KERNEL_PATCHER_H
11
12#define CPUID_MODEL_ANY0x00
13#define CPUID_MODEL_UNKNOWN0x01
14
15#define CPU_MODEL_PENTIUM_M0x0D
16#define CPU_MODEL_YONAH0x0E// Sossaman, Yonah
17#define CPU_MODEL_MEROM0x0F// Allendale, Conroe, Kentsfield, Woodcrest, Clovertown, Tigerton, Merom
18#define CPU_MODEL_PENRYN0x17// Wolfdale, Yorkfield, Harpertown, Penryn
19#define CPU_MODEL_NEHALEM0x1A// Bloomfield. Nehalem-EP, Nehalem-WS, Gainestown
20#define CPU_MODEL_ATOM0x1C// Atom
21#define CPU_MODEL_FIELDS0x1E// Lynnfield, Clarksfield, Jasper Forest
22#define CPU_MODEL_DALES0x1F// Havendale, Auburndale
23#define CPU_MODEL_DALES_32NM0x25// Clarkdale, Arrandale
24#define CPU_MODEL_SANDY0x2A// Sandy Bridge
25#define CPU_MODEL_WESTMERE0x2C// Gulftown, Westmere-EP, Westmere-WS
26#define CPU_MODEL_SANDY_XEON0x2D// Sandy Bridge Xeon
27#define CPU_MODEL_NEHALEM_EX0x2E// Beckton
28#define CPU_MODEL_WESTMERE_EX0x2F
29
30#define KERNEL_ANY0x00
31#define KERNEL_640x01
32#define KERNEL_320x02
33#define KERNEL_ERR0xFF
34
35typedef struct patchRoutine_t
36{
37void(*patchRoutine)(void*);
38int validArchs;
39int validCpu;
40struct patchRoutine_t* next;
41} patchRoutine_t;
42
43
44typedef struct kernSymbols_t
45{
46char* symbol;
47UInt64 addr;
48struct kernSymbols_t* next;
49} kernSymbols_t;
50
51kernSymbols_t* lookup_kernel_symbol(const char* name);
52void register_kernel_symbol(int kernelType, const char* name);
53
54long long symbol_handler(char* symbolName, long long addr, char is64);
55void patch_kernel(void* kernelData, void* arg2, void* arg3, void *arg4);
56void register_kernel_patch(void* patch, int arch, int cpus);
57
58int locate_symbols(void* kernelData);
59
60int determineKernelArchitecture(void* kernelData);
61
62/*
63 * Internal patches provided by this module.
64 */
65void patch_cpuid_set_info_all(void* kernelData);
66void patch_cpuid_set_info_32(void* kernelData, UInt32 impersonateFamily, UInt8 impersonateModel);
67void patch_cpuid_set_info_64(void* kernelData, UInt32 impersonateFamily, UInt8 impersonateModel);
68
69void patch_pmCPUExitHaltToOff(void* kernelData);
70void patch_lapic_init(void* kernelData);
71void patch_commpage_stuff_routine(void* kernelData);
72void patch_lapic_configure(void* kernelData);
73void patch_lapic_interrupt(void* kernelData);
74
75#endif /* !__BOOT2_KERNEL_PATCHER_H */
76

Archive Download this file

Revision: 1207