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_ANY␉␉0x00␊ |
13 | #define CPUID_MODEL_UNKNOWN␉0x01␊ |
14 | ␊ |
15 | #define KERNEL_ANY␉0x00␊ |
16 | #define KERNEL_64␉0x01␊ |
17 | #define KERNEL_32␉0x02␊ |
18 | #define KERNEL_ERR␉0xFF␊ |
19 | ␊ |
20 | typedef struct patchRoutine_t␊ |
21 | {␊ |
22 | ␉void(*patchRoutine)(void*);␊ |
23 | ␉int validArchs;␊ |
24 | ␉int validCpu;␊ |
25 | ␉struct patchRoutine_t* next;␊ |
26 | } patchRoutine_t;␊ |
27 | ␊ |
28 | ␊ |
29 | typedef struct kernSymbols_t␊ |
30 | {␊ |
31 | ␉char* symbol;␊ |
32 | ␉UInt64 addr;␊ |
33 | ␉struct kernSymbols_t* next;␊ |
34 | } kernSymbols_t;␊ |
35 | ␊ |
36 | kernSymbols_t* lookup_kernel_symbol(const char* name);␊ |
37 | void register_kernel_symbol(int kernelType, const char* name);␊ |
38 | ␊ |
39 | long long symbol_handler(char* symbolName, long long addr, char is64);␊ |
40 | void patch_kernel(void* kernelData, void* arg2, void* arg3, void *arg4, void* arg5, void* arg6);␊ |
41 | void register_kernel_patch(void* patch, int arch, int cpus);␊ |
42 | ␊ |
43 | int locate_symbols(void* kernelData);␊ |
44 | ␊ |
45 | int determineKernelArchitecture(void* kernelData);␊ |
46 | ␊ |
47 | /*␊ |
48 | * Internal patches provided by this module.␊ |
49 | */␊ |
50 | void patch_cpuid_set_info_all(void* kernelData);␊ |
51 | void patch_cpuid_set_info_32(void* kernelData, UInt32 impersonateFamily, UInt8 impersonateModel);␊ |
52 | void patch_cpuid_set_info_64(void* kernelData, UInt32 impersonateFamily, UInt8 impersonateModel);␊ |
53 | ␊ |
54 | void patch_pmCPUExitHaltToOff(void* kernelData);␊ |
55 | void patch_lapic_init(void* kernelData);␊ |
56 | void patch_commpage_stuff_routine(void* kernelData);␊ |
57 | void patch_lapic_configure(void* kernelData);␊ |
58 | void patch_lapic_interrupt(void* kernelData);␊ |
59 | ␊ |
60 | #endif /* !__BOOT2_KERNEL_PATCHER_H */␊ |
61 | |