2014年7月

原来在linux/include/linux/syscalls.h 中定义了如下的宏:

复制代码
#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
复制代码
 

还有:

复制代码
#define SYSCALL_DEFINEx(x, sname, ...)                          \

       __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)

 

#define __SYSCALL_DEFINEx(x, name, ...)                               \

       asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__));        \

       static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__));  \

       asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__))             \

       {                                                      \

              __SC_TEST##x(__VA_ARGS__);                            \

              return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__));  \

       }                                                      \

       SYSCALL_ALIAS(sys##name, SyS##name);                        \

       static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__))
复制代码
 

KXLD doesn’t like us much. He has KPIs to meet and doesn’t have time to help out shifty rootkit developers. KPIs are Kernel Programming Interfaces - lists of symbols in the kernel that KXLD (the kernel extension linker) will allow kexts to be linked against. The KPIs on which your kext depends are specified in the Info.plist file like this:

<key>OSBundleLibraries</key>
<dict>
 <key>com.apple.kpi.bsd</key>
 <string>11.0</string>
 <key>com.apple.kpi.libkern</key>
 <string>11.0</string>
 <key>com.apple.kpi.mach</key>
 <string>11.0</string>
 <key>com.apple.kpi.unsupported</key>
 <string>11.0</string>
 <key>com.apple.kpi.iokit</key>
 <string>11.0</string>
 <key>com.apple.kpi.dsep</key>
 <string>11.0</string>
</dict>Those bundle identifiers correspond to the CFBundleIdentifier key specified in the Info.plist files for “plug-ins” to the System.kext kernel extension. Each KPI has its own plug-in kext - for example, the com.apple.kpi.bsd symbol table lives in BSDKernel.kext. These aren’t exactly complete kexts, they’re just Mach-O binaries with symbol tables full of undefined symbols (they really reside within the kernel image), which you can see if we dump the load commands:

$ otool -l /System/Library/Extensions/System.kext/PlugIns/BSDKernel.kext/BSDKernel
/System/Library/Extensions/System.kext/PlugIns/BSDKernel.kext/BSDKernel:
Load command 0
     cmd LC_SYMTAB
 cmdsize 24
  symoff 80
   nsyms 830
  stroff 13360
 strsize 13324
Load command 1
     cmd LC_UUID
 cmdsize 24
    uuid B171D4B0-AC45-47FC-8098-5B2F89B474E6
That’s it - just the LC_SYMTAB (symbol table). So, how many symbols are there in the kernel image?

$ nm /mach_kernel|wc -l
   16122
Surely all the symbols in all the KPI symbol tables add up to the same number, right?

$ find /System/Library/Extensions/System.kext/PlugIns -type f|grep -v plist|xargs nm|sort|uniq|wc -l
    7677
Nope. Apple doesn’t want us to play with a whole bunch of their toys. 8445 of them. Some of them are pretty fun too :( Like allproc:

$ nm /mach_kernel|grep allproc
ffffff80008d9e40 S _allproc
$ find /System/Library/Extensions/System.kext/PlugIns -type f|grep -v plist|xargs nm|sort|uniq|grep allproc
$
Damn. The allproc symbol is the head of the kernel’s list (the queue(3) kind of list) of running processes. It’s what gets queried when you run ps(1) or top(1). Why do we want to find allproc? If we want to hide processes in a kernel rootkit that’s the best place to start. So, what happens if we build a kernel extension that imports allproc and try to load it?

bash-3.2# kextload AllProcRocks.kext
/Users/admin/AllProcRocks.kext failed to load - (libkern/kext) link error; check the system/kernel logs for errors or try kextutil(8).
Console says:

25/02/12 6:30:47.000 PM kernel: kxld[ax.ho.kext.AllProcRocks]: The following symbols are unresolved for this kext:
25/02/12 6:30:47.000 PM kernel: kxld[ax.ho.kext.AllProcRocks]:  _allproc
OK, whatever.

What do we do?
There are a few steps that we need to take in order to resolve symbols in the kernel (or any other Mach-O binary):

1.Find the __LINKEDIT segment - this contains an array of struct nlist_64’s which represent all the symbols in the symbol table, and an array of symbol name strings.
2.Find the LC_SYMTAB load command - this contains the offsets within the file of the symbol and string tables.
3.Calculate the position of the string table within __LINKEDIT based on the offsets in the LC_SYMTAB load command.
4.Iterate through the struct nlist_64’s in __LINKEDIT, comparing the corresponding string in the string table to the name of the symbol we’re looking for until we find it (or reach the end of the symbol table).
5.Grab the address of the symbol from the struct nlist_64 we’ve found.
Parse the load commands
One easy way to look at the symbol table would be to read the kernel file on disk at /mach_kernel, but we can do better than that if we’re already in the kernel - the kernel image is loaded into memory at a known address. If we have a look at the load commands for the kernel binary:

$ otool -l /mach_kernel
/mach_kernel:
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 472
  segname __TEXT
   vmaddr 0xffffff8000200000
   vmsize 0x000000000052f000
  fileoff 0
 filesize 5435392
  maxprot 0x00000007
 initprot 0x00000005
   nsects 5
    flags 0x0
<snip>
We can see that the vmaddr field of the first segment is 0xffffff8000200000. If we fire up GDB and point it at a VM running Mac OS X (as per my previous posts here and here), we can see the start of the Mach-O header in memory at this address:

gdb$ x/xw 0xffffff8000200000
0xffffff8000200000: 0xfeedfacf0xfeedfacf is the magic number denoting a 64-bit Mach-O image (the 32-bit version is 0xfeedface). We can actually display this as a struct if we’re using the DEBUG kernel with all the DWARF info:

gdb$ print *(struct mach_header_64 *)0xffffff8000200000
$1 = {
  magic = 0xfeedfacf,
  cputype = 0x1000007,
  cpusubtype = 0x3,
  filetype = 0x2,
  ncmds = 0x12,
  sizeofcmds = 0x1010,
  flags = 0x1,
  reserved = 0x0
}The mach_header and mach_header_64 structs (along with the other Mach-O-related structs mentioned in this post) are documented in the Mach-O File Format Reference, but we aren’t particularly interested in the header at the moment. I recommend having a look at the kernel image with MachOView to get the gist of where everything is and how it’s laid out.

Directly following the Mach-O header is the first load command:

gdb$ set $mh=(struct mach_header_64 *)0xffffff8000200000
gdb$ print *(struct load_command*)((void *)$mh + sizeof(struct mach_header_64))
$6 = {
  cmd = 0x19,
  cmdsize = 0x1d8
}This is the load command for the first __TEXT segment we saw with otool. We can cast it as a segment_command_64 in GDB and have a look:

gdb$ set $lc=((void *)$mh + sizeof(struct mach_header_64))
gdb$ print *(struct segment_command_64 *)$lc
$7 = {
  cmd = 0x19,
  cmdsize = 0x1d8,
  segname = "__TEXT\000\000\000\000\000\000\000\000\000",
  vmaddr = 0xffffff8000200000,
  vmsize = 0x8c8000,
  fileoff = 0x0,
  filesize = 0x8c8000,
  maxprot = 0x7,
  initprot = 0x5,
  nsects = 0x5,
  flags = 0x0
}This isn’t the load command we are looking for, so we have to iterate through all of them until we come across a segment with cmd of 0x19 (LC_SEGMENT_64) and segname of __LINKEDIT. In the debug kernel, this happens to be located at 0xffffff8000200e68:

gdb$ set $lc=0xffffff8000200e68
gdb$ print *(struct load_command*)$lc  
$14 = {
  cmd = 0x19,
  cmdsize = 0x48
}
gdb$ print *(struct segment_command_64*)$lc
$16 = {
  cmd = 0x19,
  cmdsize = 0x48,
  segname = "__LINKEDIT\000\000\000\000\000",
  vmaddr = 0xffffff8000d08000,
  vmsize = 0x109468,
  fileoff = 0xaf4698,
  filesize = 0x109468,
  maxprot = 0x7,
  initprot = 0x1,
  nsects = 0x0,
  flags = 0x0
}Then we grab the vmaddr field from the load command, which specifies the address at which the __LINKEDIT segment’s data will be located:

gdb$ set $linkedit=((struct segment_command_64*)$lc)->vmaddr
gdb$ print $linkedit
$19 = 0xffffff8000d08000
gdb$ print *(struct nlist_64 *)$linkedit
$20 = {
  n_un = {
    n_strx = 0x68a29
  },
  n_type = 0xe,
  n_sect = 0x1,
  n_desc = 0x0,
  n_value = 0xffffff800020a870
}And there’s the first struct nlist_64.

As for the LC_SYMTAB load command, we just need to iterate through the load commands until we find one with the cmd field value of 0x02 (LC_SYMTAB). In this case, it’s located at 0xffffff8000200eb0:

gdb$ set $symtab=*(struct symtab_command*)0xffffff8000200eb0
gdb$ print $symtab
$23 = {
  cmd = 0x2,
  cmdsize = 0x18,
  symoff = 0xaf4698,
  nsyms = 0x699d,
  stroff = 0xb5e068,
  strsize = 0x9fa98
}The useful parts here are the symoff field, which specifies the offset in the file to the symbol table (start of the __LINKEDIT segment), and the stroff field, which specifies the offset in the file to the string table (somewhere in the middle of the __LINKEDIT segment). Why, you ask, did we need to find the __LINKEDIT segment as well, since we have the offset here in the LC_SYMTAB command? If we were looking at the file on disk we wouldn’t have needed to, but as the kernel image we’re inspecting has already been loaded into memory, the binary segments have been loaded at the virtual memory addresses specified in their load commands. This means that the symoff and stroff fields are not correct any more. However, they’re still useful, as the difference between the two helps us figure out the offset into the __LINKEDIT segment at which the string table exists:

gdb$ print $linkedit
$24 = 0xffffff8000d08000
gdb$ print $linkedit + ($symtab->stroff - $symtab->symoff)
$25 = 0xffffff8000d719d0
gdb$ set $strtab=$linkedit + ($symtab->stroff - $symtab->symoff)
gdb$ x/16s $strtab
0xffffff8000d719d0:  ""
0xffffff8000d719d1:  ""
0xffffff8000d719d2:  ""
0xffffff8000d719d3:  ""
0xffffff8000d719d4:  ".constructors_used"
0xffffff8000d719e7:  ".destructors_used"
0xffffff8000d719f9:  "_AddFileExtent"
0xffffff8000d71a08:  "_AllocateNode"
0xffffff8000d71a16:  "_Assert"
0xffffff8000d71a1e:  "_BF_decrypt"
0xffffff8000d71a2a:  "_BF_encrypt"
0xffffff8000d71a36:  "_BF_set_key"
0xffffff8000d71a42:  "_BTClosePath"
0xffffff8000d71a4f:  "_BTDeleteRecord"
0xffffff8000d71a5f:  "_BTFlushPath"
0xffffff8000d71a6c:  "_BTGetInformation"Actually finding some symbols
Now that we know where the symbol table and string table live, we can get on to the srs bznz. So, let’s find that damn _allproc symbol we need. Have a look at that first struct nlist_64 again:

gdb$ print *(struct nlist_64 *)$linkedit
$28 = {
  n_un = {
    n_strx = 0x68a29
  },
  n_type = 0xe,
  n_sect = 0x1,
  n_desc = 0x0,
  n_value = 0xffffff800020a870
}The n_un.nstrx field there specifies the offset into the string table at which the string corresponding to this symbol exists. If we add that offset to the address at which the string table starts, we’ll see the symbol name:

gdb$ x/s $strtab + ((struct nlist_64 *)$linkedit)->n_un.n_strx
0xffffff8000dda3f9:  "_ps_vnode_trim_init"Now all we need to do is iterate through all the struct nlist_64’s until we find the one with the matching name. In this case it’s at 0xffffff8000d482a0:

gdb$ set $nlist=0xffffff8000d482a0
gdb$ print *(struct nlist_64*)$nlist
$31 = {
  n_un = {
    n_strx = 0x35a07
  },
  n_type = 0xf,
  n_sect = 0xb,
  n_desc = 0x0,
  n_value = 0xffffff8000cb5ca0
}
gdb$ x/s $strtab + ((struct nlist_64 *)$nlist)->n_un.n_strx
0xffffff8000da73d7:  "_allproc"The n_value field there (0xffffff8000cb5ca0) is the virtual memory address at which the symbol’s data/code exists. _allproc is not a great example as it’s a piece of data, rather than a function, so let’s try it with a function:

gdb$ set $nlist=0xffffff8000d618f0
gdb$ print *(struct nlist_64*)$nlist
$32 = {
  n_un = {
    n_strx = 0x52ed3
  },
  n_type = 0xf,
  n_sect = 0x1,
  n_desc = 0x0,
  n_value = 0xffffff80007cceb0
}
gdb$ x/s $strtab + ((struct nlist_64 *)$nlist)->n_un.n_strx
0xffffff8000dc48a3:  "_proc_lock"If we disassemble a few instructions at that address:

gdb$ x/12i 0xffffff80007cceb0
0xffffff80007cceb0 <proc_lock>: push   rbp
0xffffff80007cceb1 <proc_lock+1>: mov    rbp,rsp
0xffffff80007cceb4 <proc_lock+4>: sub    rsp,0x10
0xffffff80007cceb8 <proc_lock+8>: mov    QWORD PTR [rbp-0x8],rdi
0xffffff80007ccebc <proc_lock+12>: mov    rax,QWORD PTR [rbp-0x8]
0xffffff80007ccec0 <proc_lock+16>: mov    rcx,0x50
0xffffff80007cceca <proc_lock+26>: add    rax,rcx
0xffffff80007ccecd <proc_lock+29>: mov    rdi,rax
0xffffff80007cced0 <proc_lock+32>: call   0xffffff800035d270 <lck_mtx_lock>
0xffffff80007cced5 <proc_lock+37>: add    rsp,0x10
0xffffff80007cced9 <proc_lock+41>: pop    rbp
0xffffff80007cceda <proc_lock+42>: retWe can see that GDB has resolved the symbol for us, and we’re right on the money.

Sample code
I’ve posted an example kernel extension on github to check out. When we load it with kextload KernelResolver.kext, we should see something like this on the console:

25/02/12 8:06:49.000 PM kernel: [+] _allproc @ 0xffffff8000cb5ca0
25/02/12 8:06:49.000 PM kernel: [+] _proc_lock @ 0xffffff80007cceb0
25/02/12 8:06:49.000 PM kernel: [+] _kauth_cred_setuidgid @ 0xffffff80007abbb0
25/02/12 8:06:49.000 PM kernel: [+] __ZN6OSKext13loadFromMkextEjPcjPS0_Pj @ 0xffffff80008f8606
Update: It was brought to my attention that I was using a debug kernel in these examples. Just to be clear - the method described in this post, as well as the sample code, works on a non-debug, default install >=10.7.0 (xnu-1699.22.73) kernel as well, but the GDB inspection probably won’t (unless you load up the struct definitions etc, as they are all stored in the DEBUG kernel). The debug kernel contains every symbol from the source, whereas many symbols are stripped from the distribution kernel (e.g. sLoadedKexts). Previously (before 10.7), the kernel would write out the symbol table to a file on disk and jettison it from memory altogether. I suppose when kernel extensions were loaded, kextd or kextload would resolve symbols from within that on-disk symbol table or from the on-disk kernel image. These days the symbol table memory is just marked as pageable, so it can potentially get paged out if the system is short of memory.

I hope somebody finds this useful. Shoot me an email or get at me on twitter if you have any questions. I’ll probably sort out comments for this blog at some point, but I cbf at the moment.

1.通过AppleHDAFunctionGroupFactory::createAppleHDAFunctionGroup(DevIdStruct *)实际创建相应的
AppleHDAFunctionGroupSTAC9220
AppleHDAFunctionGroup_80862805
AppleHDAFunctionGroupWM8800
AppleHDAFunctionGroupCS4206
AppleHDAFunctionGroupATI_RS730
...
AppleHDAFunctionGroupAD1984
AppleHDAFunctionGroupAD1988
AppleHDAFunctionGroupALC885
...
AppleHDAFunctionGroup这样的对象
10.9.3 : 0x48162
createAppleHDAFunctionGroup由AppleHDACodecGeneric::start(IOService *)调用
AppleHDACodecGeneric::start: 0x478A
call create... : 0x4ceb

var_58 = DevIdStruct*

0x4d26: call qword [r10 + 1F0] ; r10 = AppleHDAFunctionGroup*
eax = (AppleHDAFunctionGroup* var_hf)->

0x4cf0: AppleHDACodecGeneric:
r13(this) + 0xA8 = AppleHDAFunctionGroup*
r13(this) + 88h = IOService *
r13(this) + 90h = 0x480a call return,其0x5d0 -> start

AppleHDACodecGeneric::start中
r13 --> this
r12 --> IOService * 参数

2.AppleHDAFunctionGroup的虚表(0x7c680):
vtable + 0x200 [0x400a6] => initForNodeID(unsigned short, OSObject *, OSObject *, DevIdStruct *, bool)
vtable + 0x130 [0x3fa08] => AppleHDANode::runVerb(unsigned short, unsigned short, unsigned int*)
vtable + 0x1F0 [0x3fd4e] => AppleHDANode::isBitDepthSupported(unsigned int)


3.AppleHDACodec的虚表:
vtable + 0x5d0 => start()

 

X86-64有16个64位寄存器,分别是:%rax,%rbx,%rcx,%rdx,%esi,%edi,%rbp,%rsp,%r8,%r9,%r10,%r11,%r12,%r13,%r14,%r15。其中:

%rax 作为函数返回值使用。
%rsp 栈指针寄存器,指向栈顶
%rdi,%rsi,%rdx,%rcx,%r8,%r9 用作函数参数,依次对应第1参数,第2参数。。。
%rbx,%rbp,%r12,%r13,%14,%15 用作数据存储,遵循被调用者使用规则,简单说就是随便用,调用子函数之前要备份它,以防他被修改
%r10,%r11 用作数据存储,遵循调用者使用规则,简单说就是使用之前要先保存原值
X86-64寄存器和栈帧:
http://www.searchtb.com/2013/03/x86-64_register_and_function_frame.html

 

mac-pro-inside

In this article, I gathered up all the dumps, who found. If you see something new table will be updated.

If you want to replenish the base - write in comments.

 

MODELI / O
REGISTRY
ACPI
DUMP
SYSTEM
PROFILES
SMC
KEYS
LSPCI
OUTPUT
DMESG
OUTPUT
AUDIO
CODEC
DUMP
OTHER
iMac5, 1 ? DL DL           DL
iMac6,1 ? DL DL            
iMac7, 1 ? DL DL     DL     DL
iMac8, 1 ? DL DL DL DL DL DL DL DL
iMac9, 1 ?   DL            
iMac10, 1 ? DL DL   DL       DL
iMac11, 1
Core i5 ?
DL DL DL DL DL      
iMac11, 1
Core i7
DL   DL   DL DL DL DL
iMac11, 2 ? DL DL   DL     DL  
iMac12,1 ?   DL            
iMac12, 2 ? DL DL DL DL       DL
iMac13,1 ? DL DL DL DL       DL
iMac13,2 ? DL DL DL DL       DL
iMac14,1 ? DL   DL          
iMac14,2 ? DL   DL          
MacBook1, 1 ? DL DL           DL
MacBook2, 1 ? DL DL DL DL DL     DL
MacBook3, 1 ? DL DL            
MacBook4, 1 ? DL DL            
MacBook5, 1 ? DL DL DL DL DL     DL
MacBook5, 2 ? DL DL           DL
MacBook6, 1 ? DL DL DL          
MacBookAir1,1 ? DL DL            
MacBookAir2,1 ? DL DL           DL
MacBookAir3,1 ?   DL            
MacBookAir3,2 ? DL DL         DL  
MacBookAir4,1 ?   DL            
MacBookAir4,2 ? DL DL DL          
MacBookAir5, 1? DL DL DL DL        
MacBookAir5, 2? DL DL DL DL       DL
MacBookAir6,1 ? DL              
MacBookAir6,2 ? DL DL DL DL       DL
MacBookPro1, 1?   DL           DL
MacBookPro1, 2?   DL           DL
MacBookPro3, 1? DL DL DL DL DL DL    
MacBookPro4, 1? DL DL   DL     DL  
MacBookPro5, 1? DL DL            
MacBookPro5, 2? DL DL           DL
MacBookPro5, 3? DL DL           DL
MacBookPro5, 4? DL DL DL   DL      
MacBookPro5, 5? DL DL         DL  
MacBookPro6, 1? DL DL            
MacBookPro6, 2? DL DL            
MacBookPro7, 1? DL DL           DL
MacBookPro8, 1? DL DL DL DL DL   DL  
MacBookPro8, 2? DL DL     DL     DL
MacBookPro8, 3? DL   DL          
MacBookPro9,1? DL DL DL DL DL     DL
MacBookPro9,2? DL DL DL DL DL     DL
MacBookPro10,1? DL DL DL DL       DL
MacBookPro10,2? DL DL DL DL        
MacBookPro11,1?                
MacBookPro11,2? DL   DL          
MacMini1, 1 ? DL DL     DL     DL
MacMini2, 1 ? DL DL DL          
MacMini3, 1 ? DL DL   DL     DL DL
MacMini5,1 ? DL DL DL DL DL     DL
MacMini5, 2 ? DL DL DL          
MacMini6,2 ? DL DL DL DL        
MacPro1, 1 ? DL DL DL          
MacPro2, 1 ? DL DL            
MacPro3, 1 ? DL DL            
MacPro4, 1 ? DL DL DL DL       DL
MacPro5, 1 ? DL DL     DL     DL
MacPro6,1 ? DL DL DL DL       DL
Xserve1,1 ?   DL           DL
Xserve2,1 ? DL DL DL          
Xserve3,1 ?   DL            
MODELFIRMWAREBOARDSERIALCPUGPU
iMac4,1 IM41.0055.B08 Mac-F42787C8 W86091M3U2N C2D T2500 2.00 GHz ATI Radeon X1600
iMac4,2 IM42.0071.B03   CK6400FCWD4
W862713PV2H
C2D T2400 Intel GMA 950
iMac5, 1 IM51.88Z.0090.B09.0706270921 Mac-F42786A9 CK6370PWX1A    
iMac5,2 IM52.88Z.0090.B09.0706270913 Mac-F4218EC8
Mac-F4218EA9
W8635046WH5 C2D T5600 1.83GHz  
iMac6,1 IM61.88Z.0093.B07.0706281250 Mac F4218FC8 W86392J7VGP C2D T7400  
iMac7, 1 IM71.88Z.007A.B03.0803051705 Mac-F4238CC8
Mac-F42386C8
W87410PWX87    
iMac8, 1 IM81.88Z.00C1.B00.0802091538 Mac F226BEC8
Mac F227BEC8
QP8190X6ZE3
VM834BJ6ZE7
C2D E8435 3.06GHz nVidia GeForce 8800 GS
iMac9, 1 IM91.88Z.008D.B00.0901142258 Mac-F2218EC8
Mac F2218FC8
Mac-F2218EA9
Mac-F2218FA9
W87552DW2E2    
iMac10, 1 IM101.88Z.00CC.B00.0909031926 Mac-F2268DC8
Mac-F2268CC8
W89412335PE C2D E7600 3.06GHz nVidia
iMac11, 1 IM111.88Z.0034.B00.0910301727 Mac-F2268DAE W89470DZ5RU i7 860 2.80GHz  
iMac11, 2 IM112.88Z.0057.B00.1005031455 Mac-F2238AC8 CK109016HJG i3 550 3.20GHz  
iMac11,3 IM112.88Z.0057.B00.1005031455 Mac-F2238BAE QP051121DNR i3 550 3.20GHz ATI Radeon HD 5670
iMac12,1 IM121.88Z.0047.B00.1102091756 Mac-942B5BF5 8194151B D25G917SDHJT    
iMac12, 2 IM121.88Z.0047.B00.1102091756 Mac-942B59F5 8194171B C02FDDMXDHJQ
C02FDCKYDHJP
DGKGT1KRDHJP
i5 2400 3.10GHz Intel HD Graphics 3000 + AMD Radeon HD 6970M
iMac13,1 IM131.88Z.010A.B00.1209042338 Mac-00BE6ED7 1E35EB86 D25JR0H5DNML
D25JP2GSDNCR
C02JK0CWDNCT
i5-3335S 2.7GHz Intel HD Graphics 4000 + nVidia GeForce GT 650M
iMac13,2 IM131.88Z.00CE.B00.1203281326 Mac-FC02E91D DD3FA6A4 C02JW5PZDNCW i7 3770 3.40GHz nVidia GeForce GTX 675MX
iMac14,1 IM141.88Z.0118.B00.1309031248 Mac-031B6874 CF7F642A C02L74TXF8J2 i5-4570R 2.70GHz Intel Iris Graphics 5200
iMac14,2 IM142.88Z.0118.B00.1309031249 Mac-27ADBB7B 4CEE8E61 C02LM5K4F8J4 i5-4570 3.20GHz nVidia GeForce GT 755M
MacBook1, 1 MB11.88Z.0061.B03.0610121324 Mac-F4208CC8 4H629LYAU9C    
MacBook2, 1 MB21.00A5.B07 Mac-F4208CA9
Mac-F4208CAA
4H70502HWGL C2D 2.00GHz  
MacBook3, 1 MB31.88Z.008E.B02.0803051832 Mac-F22788C8 W874725NZ66 C2D T7500 2.20GHz  
MacBook3,2   Mac-F22788C8      
MacBook4, 1   Mac-F22788A9 W88383T00P5    
MacBook5, 1   Mac-F42D89C8
Mac-F42D89A9
W89118AB7WU    
MacBook5, 2   Mac-F22788AA 459397LY9GU    
MacBook6, 1   Mac-F22C8AC8 WQ947BYS8PW    
MacBook7,1 MB71.88Z.0039.B0B.1006012319 Mac-F22C89C8 45038QTPF5W C2D P8600 2.40GHz nVidia GeForce 320M
MacBookAir1,1   Mac-F42C8CC8 W8811HS3Y51    
MacBookAir2,1   Mac-F42D88C8 W894122U9A7    
MacBookAir3,1   Mac-942452F5 819B1C1B C02FL8F5DDQX    
MacBookAir3,2   Mac-8193131B 942C5DF5 C02DL0MNDDR4    
MacBookAir4,1   Mac-C08A6BB7 0A942AC2 C02G1GX5DJYC    
MacBookAir4,2 MBA41.88Z.0077.B08.1109011050 Mac-742912EF DBEE19B3 C02G753CDJWV i5 2557M 1.70GHz  
MacBookAir5, 1 MBA51.88Z.00EF.B00.1205221442 Mac-66F35F19 FE2A0D05 C02JJ6W3DRV7   Intel HD Graphics 4000
MacBookAir5, 2 MBA51.88Z.00EF.B00.1205221442 Mac-2E6FAB96 566FE58C C02HRJXWDRVC i5-3427U 1.80GHz Intel HD Graphics 4000
MacBookAir6,1 MBA61.88Z.0099.B00.1305241529 Mac-35C1E881 40C3E6CF C17KTAM5F5N7 i5-4250U 1.30GHz Intel HD Graphics 5000
MacBookAir6,2 MBA61.88Z.0099.B00.1305241529 Mac-7DF21CB3 ED6977E5 C02KQ9RMF5V7 i5 4250U 1.30GHz Intel HD Graphics 5000
MacBookPro2,1   Mac-F42187C8
Mac-F42189C8
W864711PW0M    
MacBookPro2,2 MBP22.88Z.00A5.B07.0708131242 Mac-F42187C8 W8651BNEW0G    
MacBookPro3, 1   Mac-F4238BC8
Mac-F42388C8
W8733334X92    
MacBookPro4, 1   Mac-F42C89C8
Mac-F42C86C8
W88302P1YJZ    
MacBookPro5, 1   Mac-F42D86C8 W884094J1GA    
MacBookPro5, 2   Mac-F42D86A9
Mac-F2268EC8
W89430FX8YB    
MacBookPro5, 3 MBP53.88Z.00AC.B03.0906151647 Mac-F22587C8 W89213TF642 C2D P8800 2.66GHz  
MacBookPro5, 4 MBP53.88Z.00AC.B03.0906151647 Mac-F22587A1 W8944B7X7XJ C2D P8700 2.53GHz  
MacBookPro5, 5   Mac-F2268AC8
Mac-F22587A1
W89463W366E    
MacBookPro6, 1 MBP61.88Z.0057.B0F.1112091028 Mac-F22589C8 C02CJ0W8DD6Y    
MacBookPro6, 2 MBP61.88Z.0057.B0C.1007261552 Mac-F22586C8 W80253LDAGZ    
MacBookPro7, 1   Mac F222BEC8 W80140U3ATM    
MacBookPro8, 1 MBP81.88Z.0047.B04.1102071707 Mac-94245B36 40C91C81 C02F9S7GDH2G C02FQ5JADH2L
C1MH7C30DV13
i5 2415M 2.30GHz  
MacBookPro8, 2 MBP81.88Z.0047.B22.1109281426 Mac-94245A39 40C91C80 C02GR1KXDV7L 2.20GHz i7 2675QM Intel HD Graphics 3000 + AMD Radeon HD 6750M
MacBookPro8, 3 MBP81.88Z.0047.B27.1201241646 Mac-942459F5 819B171B C02F917PDF93 2.30GHz i7 2820QM Intel HD Graphics 3000 + AMD Radeon HD 6750M
MacBookPro9,1 MBP91.88Z.00D3.B02.1203281326 Mac-4B7AC7E 43945597E C02JG85RDV33 i7-3720QM 2.60GHz Intel HD Graphics 4000 + NVIDIA GeForce GT 650M
MacBookPro9,2 MBP91.88Z.00D3.B06.1205101904 Mac-6F01561E 16C75D06 C02HMAX6DTY3
C02J21CWDTY4
i5 3210M 2.50GHz Intel HD Graphics 4000
MacBookPro10,1 MBP101.88Z.00EE.B00.1205101839 Mac-C3EC7CD2 2292981F C02J3AZ9DKQ5
C02HWSSBDKQ1
3720QM i7 2.60Ghz Intel HD Graphics 4000 + NVIDIA GeForce GT 650M
MacBookPro10,2 MBP102.88Z.00F2.B00.1206111035 Mac-AFD8A9D9 44EA4843 C02J90NFDR53 i7 3520M 2.90Ghz Intel HD Graphics 4000
MacBookPro11,1 MBP111.88Z.0133.B00.1309220923 Mac-189A3D4F9 75D5FFC   i5-4258U 2.40 GHz
i7-4558U 2.80 GHz
Intel Iris Graphics 5200
MacBookPro11,2 MBP112.88Z.0138.B02.1310181745 Mac-3CBD0023 4E554E41 C02LKAL3FD56 i7-4750HQ 2.00 Ghz Intel Iris Graphics 5200
MacMini1, 1 MM11.88Z.0055.B08.0610121326 Mac-F4208EC8 YM64551AW0A    
MacMini2, 1 MM21.88Z.009A.B00.0706281359 Mac-F4208EAA YM8054BYYL2 C2D T7200 2.00GHz Intel GMA 950
MacMini3, 1   Mac-F22C86C8 YM9384389G5
YM9122XS19X
   
MacMini4,1   Mac-F2208EC8 C07CW258DD6K    
MacMini5,1 MM51.88Z.0077.B0E.1110141154 Mac-8ED6AF5B 48C039E1 C07G3VUFDJD0 i5 2415M 2.30GHz Intel HD Graphics 3000
MacMini5, 2 MM51.88Z.0075.B00.1106271442 Mac-4BC72D62 AD45599E C07G3CWMDJD1 i5 2520M 2.50GHz Intel HD Graphics 3000 + AMD Radeon HD 6630M
MacMini5,3 MM51.88Z.0077.B0E.1110141154 Mac-7BA5B279 4B2CDB12 C07G2F5GDJY7
C07H64P5DJD0
i7 2635QM 2.0GHz Intel HD Graphics 3000
MacMini6,2 MM61.88Z.0106.B00.1208091121 Mac-F65AE981 FFA204ED C07JD0VTDWYN
C07JD6FMDWYN
i7 3720QM 2.6GHz Intel HD Graphics 4000
MacPro1, 1 MP11.88Z.005C.B08.0707021221 Mac-F4208DC8 G87111DJUQ2    
MacPro2, 1 MP21.88Z.007F.B02.0703191612 Mac-F4208DA9
Mac-F221DCC8
C074102FUPZ    
MacPro3, 1 MP31.88Z.006C.B02.0801021250 Mac-F42C88C8 G88014V4XYK    
MacPro4, 1 MP41.88Z.0081.B03.0902231259 Mac-F4208DC8
Mac F221BEC8
CK91601V8Q0 Xeon E5520 2.27GHz  
MacPro5, 1 MP51.88Z.007F.B00.1008031144 Mac F221BEC8 YM0330U7EUH
C07J50F7F4MC
Xeon X5690 3.47GHz ATI Radeon HD 5770
MacPro6,1 MP61.88Z.0116.B02.1311222014 Mac-F60DEB81 FF30ACF6 F5KLT0F4F9VM Xeon E5-2697 v2 2.70 GHz AMD FirePro D300 x2

Materials are collected from all core forums and sites. In particular has benefited from the following sources:

  1. Forum www.projectosx.com, branch Apple Hardware Dumps: System Profiler, IOReg, DSDT, etc..
  2. Forum www.insanelymac.com, branch Decompiled original Apple DSDTs, To be used for new patches, additions, Fixed ...

To collect information about your computer there are various means. Below is a list of necessary tools and instructions for use. The list is not complete and it will be updated.

  1. To collect the SMC keys and their values used utility SMC Utility. By utilities devnull,brushed and brought to mind Michael Belyaev (usr-sse2). Sources are on this address. New version (2) utility can be downloaded from link. If the utility does not start, necessary to make the file executable: chmod x SMC_util. For a complete list of keys with the values needed to execute the following command:
    1
    sudo SMC_util -l > ~/Desktop/SMC_keys.txt
  2. To gather information about pci devices used utility lspci. Utility portirovana around Linux. Specifically, this version is ported to the team EVOSX86. To obtain the required information we need to run the following commands:
    1

    2
    sudo lspci -nnvvxxx > ~/Desktop/lspcinnvvxxx.txt
    sudo lspci -tvnn > ~/Desktop/lspcitvnn.txt
  3. To obtain the ACPI tables, you can use the below given script.
    01

    02

    03

    04

    05

    06

    07

    08

    09

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28
    #!/bin/bash
     
    cdir=`dirname $0`
    dmpdir=acpitbls
     
    # Create a dump directory
    if [[ ! -d $dmpdir ]];then
       mkdir $dmpdir
    fi
     
    # Dump ACPI table data from ioreg
    acpi_tbls=`ioreg -lw0 | grep "ACPI Tables" | cut -f2 -d"{" | tr "," " "`
     
    echo -e "\nDumping the following ACPI tables to folder `pwd`/$dmpdir\n"
     
    # Loop through each table
    for tbl in $acpi_tbls
    do
        tbl_name=`echo $tbl | cut -f1 -d"=" | tr -d "\""`
     
        echo $tbl_name
        tbl_data=`echo $tbl | cut -f2 -d""`
        echo $tbl_data | xxd -r -p > $dmpdir/$tbl_name.aml
        $cdir/iasl -d $dmpdir/$tbl_name.aml 1>/dev/null 2>&1
     
    done
     
    echo -e "\nDone!"

    To use copy-paste the script into a new file named dumpacpitbls and make it executable: chmod x dumpacpitbls. A working tool iasl.

Update 25-07-2012:
There was a small program to gather information about hardware. Is a programDarwinDumper.app. Development and discussion is online ProjectOSX, latest version in the same. Collects information on Apple computers as well as on Hackintosh.

Of the constraints: не делает дамп IORegestry в формате ioreg, so, if you do a dump, сохраните ioreg отдельно с помощью IORegestryExplorer; To remove the device list (lspci) requires you to enter an administrator password.

In any case, place the mirror on the current version of today in his blog: DarwinDumper.app v2.0pre16

Update 12-12-2012:
A version DarwinDumper.app (v2.5.7f) without the interface and without requiring administrative rights (without administrator rights can not read data BIOS ROM dump, dmesg dump, FirmwareMemoryMap и Lspci dump). Now, just copy it to a USB flash drive, insert the USB flash drive into your computer and click on the icon DarwinDumper.app. Within seconds, all the necessary data will be stored on a flash drive and can be removed.

Special version DarwinDumper posted blackosx Online insanelymac.com.

You can download the link: DarwinDumper.app (v2.5.7f)

http://tdev.me/2010/12/apple-hardware-dumps/?lang=en

dsdt解决睡眠唤醒死机

首先,感谢x5115x提供了一个相对比较完整的THINKPAD T410在MAC下的DSDT修改的详细教程!使得很多略有程序代码经验的T410使用者能够自己动手修改DSDT。

在x5115x的帖子中,提到了以下几个修改:
1)添加DGTP;
2)修改LPC,支持原生电源管理;
3)修改RTC,防止CMOS重置;
4)添加显卡代码(我用了少量的代码+变色龙自动侦测,使得机器可以支持VGA的镜像输出);
5)添加关机断电代码;
6)添加声卡代码;

这些修改对于T410能跑MAC是非常重要和必须的。

经过长达一年多的使用实践,很多朋友都发现目前T410的DSDT虽然可以让机器比较正常地跑,但是确实还有不少毛病(感觉不够完美)。比如:
1)连续多次的睡眠唤醒后,偶尔死机。
2)睡眠唤醒之后,插入U盘死机。

虽然我们可以设置不让机器睡眠,从而避免死机的问题出现。但是,从完美角度来说,毕竟这是一块心病!

从DSDT修改的角度,一方面是尽量向MAC的DSDT靠近。但是从另一方面来说,也得充分考虑到硬件自身的一些特性参数。因此,生搬硬套DSDT的修改代码,的确会造成系统在使用中偶尔出现(甚至频繁出现)的毛病。

MAC OSX系统会在读取DSDT.AML文件之后,加载其中与硬件对应的“设备”。因此,我们可以通过IORegistryExplorer软件来查看加载的“设备”,并从中读取其相应的参数。这就为我们修改DSDT提供了一个非常方便的参考。

经过频繁的试验,发现T410的2个EHCI设备的DSDT参数设置不正确,是造成T410黑苹果睡眠唤醒后死机(包括插入U盘死机)现象的主要原因。

我们分析一下:在Device (EHC1)和Device (EHC2)中,我们在DSDT里面一般会各添加一段Method (_DSM, 4, NotSerialized)代码,俗称“USB内建”。代码如下:

  1.                Method (_DSM, 4, NotSerialized)
  2.                 {
  3.                     Store (Package (0x0F)
  4.                         {
  5.                             “device-id”,
  6.                             Buffer (0×04)
  7.                             {
  8.                                 0×34, 0x3A, 0×00, 0×00
  9.                             },
  10.                             “AAPL,clock-id”,
  11.                             Buffer (One)
  12.                             {
  13.                                 0x0A
  14.                             },
  15.                             “built-in”,
  16.                             Buffer (One)
  17.                             {
  18.                                 0×00
  19.                             },
  20.                             “device_type”,
  21.                             Buffer (0×05)
  22.                             {
  23.                                 ”EHCI”
  24.                             },
  25.                             “AAPL,current-available”,
  26.                             0x04B0,
  27.                             “AAPL,current-extra”,
  28.                             0x02BC,
  29.                             “AAPL,current-in-sleep”,
  30.                             0x03E8,
  31.                             Buffer (One)
  32.                             {
  33.                                 0×00
  34.                             }
  35.                         }, Local0)
  36.                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  37.                     Return (Local0)
  38.                 }

复制代码

很多人就直接复制粘贴而不做任何修改。虽然看起来运行正常,而实际上给睡眠唤醒之后的死机、以及唤醒之后插入U盘的死机造成了很大的隐患!

从IORegistryExplorer软件中,我们实际上可以看到EHC1和EHC2下还有一些未被用到的USB2.0端口(如:EHCI Root Hub Simulation@1D)。这些被红线框起来的参数是系统自动读取的,也就是说端口的参数本来就是这些值。

在上图,可以看到很多参数都是上面的DSDT代码中没有的,如”AAPL,device-internal”,”AAPL,max-port-current-in-sleep”,”AAPL,standard-port-current-in-sleep”。我们还会发现以上DSDT代码中的三个AAPL的值也与之不同,也就是说DSDT中的参数不正确!

同时,在WINDOWS中,我们使用AIDA64软件生成一个硬件的报告,从该报告中可以查到T410的EHC1和EHC2的设备ID分别是0x3B34和0x3B3C。因此,我们需要对以上代码进行修正。

其中EHC1部分修正之后如下:

  1.                 Method (_DSM, 4, NotSerialized)
  2.                 {
  3.                     Store (Package (0×13)
  4.                         {
  5.                             “device-id”,
  6.                             Buffer (0×04)
  7.                             {
  8.                                 0×34, 0x3B, 0×00, 0×00
  9.                             },
  10.                             “AAPL,clock-id”,
  11.                             Buffer (One)
  12.                             {
  13.                                 0×01
  14.                             },
  15.                             “device_type”,
  16.                             Buffer (0×05)
  17.                             {
  18.                                 ”EHCI”
  19.                             },
  20.                             “AAPL,current-available”,
  21.                             0x05DC,
  22.                             “AAPL,current-extra”,
  23.                             0x04B0,
  24.                             “AAPL,current-extra-in-sleep”,
  25.                             0x03E8,
  26.                             “AAPL,device-internal”,
  27.                             0×02,
  28.                             “AAPL,max-port-current-in-sleep”,
  29.                             0x3E8,
  30.                             “AAPL,standard-port-current-in-sleep”,
  31.                             0X1F4,
  32.                             Buffer (One)
  33.                             {
  34.                                 0×00
  35.                             }
  36.                         }, Local0)
  37.                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  38.                     Return (Local0)
  39.                 }

复制代码

而EHC2部分修正之后为:

  1.                 Method (_DSM, 4, NotSerialized)
  2.                 {
  3.                     Store (Package (0×13)
  4.                         {
  5.                             “device-id”,
  6.                             Buffer (0×04)
  7.                             {
  8.                                 0x3C, 0x3B, 0×00, 0×00
  9.                             },
  10.                             “AAPL,clock-id”,
  11.                             Buffer (One)
  12.                             {
  13.                                 0×02
  14.                             },
  15.                             “device_type”,
  16.                             Buffer (0×05)
  17.                             {
  18.                                 ”EHCI”
  19.                             },
  20.                             “AAPL,current-available”,
  21.                             0x05DC,
  22.                             “AAPL,current-extra”,
  23.                             0x04B0,
  24.                             “AAPL,current-extra-in-sleep”,
  25.                             0x03E8,
  26.                             “AAPL,device-internal”,
  27.                             0×02,
  28.                             “AAPL,max-port-current-in-sleep”,
  29.                             0x3E8,
  30.                             “AAPL,standard-port-current-in-sleep”,
  31.                             0X1F4,
  32.                             Buffer (One)
  33.                             {
  34.                                 0×00
  35.                             }
  36.                         }, Local0)
  37.                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  38.                     Return (Local0)
  39.                 }

复制代码

至此,我们应该来说比较完美地解决了EHC1和EHC2两个设备的硬件参数在DSDT中的相应代码修改。至少在今天一整天的多次睡眠唤醒后,插入/拔出U盘(有读写动作)、同时使用USB打印机,未发现死机现象。

二楼将补充关于IRQ、FIREWIRE提示、SMBUS、有线网卡内建、SATA内建、Fn键、小太阳、合盖睡眠、按电源键睡眠、关机断电等DSDT修改。

至于新版DSDT,我将继续测试几天之后,如果相对稳定了,就上传。

特别感谢LeoGray坛友提供的“插入U盘死机”信息!!

=====================================
新版T410的DSDT在此下载。此DSDT基于1.44版白名单BIOS,并精简掉了Device (LPT)和Device (ECP),因为即使有这2段代码也加载不了。从理论上来说,不会影响刷其他版本BIOS的机器。请使用后反馈状况!

<ignore_js_op> T410-RT8-DSDT-201301151452-连续睡眠唤醒OK.zip (74.74 KB, 下载次数: 759) 
该DSDT支持变色龙与CLOVER启动!!!

关于CLOVER引导的方法,见http://bbs.pcbeta.com/viewthread-1268481-1-1.html

另,本DSDT无论使用变色龙、或者使用CLOVER引导启动,都需要启动这两个引导的显卡自动侦测功能。即:变色龙的GraphicsEnabler=Yes,CLOVER的GraphicsInjector=Yes,【适用于NVS3100M显卡】。

我的使用情况:
1)启动运行正常;
2)自动睡眠唤醒正常;
3)合盖睡眠唤醒正常;
4)Fn+F4睡眠唤醒正常;
5)唤醒后插入U盘读写正常;
6)连续多种睡眠唤醒正常;
7)长时间睡眠唤醒正常;

注:我的机器型号是T410-2522-RT8,NVS3100M独显。若是集显或者双显卡的T410,建议参考本贴为主。

补充关于IRQ、FIREWIRE提示、SMBUS、有线网卡内建、SATA内建、Fn键、小太阳、睡眠等

本帖最后由 gcafrk 于 2013-1-27 23:27 编辑

 

补充关于IRQ、FIREWIRE提示、SMBUS、有线网卡内建、SATA内建、Fn键、小太阳、按电源键睡眠、关机断电、指纹驱动等DSDT修改。 


一、关于IRQ
1)HPET的IRQ。由于i5-520m是双核四线程CPU,它需要4个IRQ。我们参考DSDTSE或者DSDT Editor中的说明,添加2个IRQ(0和8),同时也参考其他帖子,再为其增加2个IRQ(11和15),则代码变成:


  1.                Device (HPET)
  2.                 {
  3.                     Name (_HID, EisaId (“PNP0103″))
  4.                     Method (_STA, 0, NotSerialized)
  5.                     {
  6.                         Return (0x0F)
  7.                     }
  8.                     Name (_CRS, ResourceTemplate ()
  9.                     {
  10.                         IRQNoFlags ()
  11.                             {0}
  12.                         IRQNoFlags ()
  13.                             {8}
  14.                         IRQNoFlags ()
  15.                             {11}
  16.                         IRQNoFlags ()
  17.                             {15}
  18.                         Memory32Fixed (ReadOnly,
  19.                             0xFED00000,         // Address Base
  20.                             0×00000400,         // Address Length
  21.                             )
  22.                     })
  23.                 }

复制代码


2)RTC的IRQ,需要删除。删除之后的代码如下:


  1.                Device (RTC)
  2.                 {
  3.                     Name (_HID, EisaId (“PNP0B00″))
  4.                     Name (_CRS, ResourceTemplate ()
  5.                     {
  6.                         IO (Decode16,
  7.                             0×0070,             // Range Minimum
  8.                             0×0070,             // Range Maximum
  9.                             0×01,               // Alignment
  10.                             0×02,               // Length
  11.                             )
  12.                     })
  13.                 }

复制代码


3)TIMR的IRQ,需要删除。删除之后的代码如下:


  1.                 Device (TIMR)
  2.                 {
  3.                     Name (_HID, EisaId (“PNP0100″))
  4.                     Name (_CRS, ResourceTemplate ()
  5.                     {
  6.                         IO (Decode16,
  7.                             0×0040,             // Range Minimum
  8.                             0×0040,             // Range Maximum
  9.                             0×01,               // Alignment
  10.                             0×04,               // Length
  11.                             )
  12.                     })
  13.                 }

复制代码


二、Firewire(火线)启动日志FireWire runtime power conservation disabled去除:

1)在IORegistryExplorer中查询到火线Firewire的位置:在EXP5。因此,在DSDT的Device (EXP5)的Method (_PRT, 0, NotSerialized)之前,添加以下代码:


  1.                 Device (FRWR)
  2.                 {
  3.                     Name (_ADR, 0×03)
  4.                     Name (_GPE, 0x1A)
  5.                     Method (_DSM, 4, NotSerialized)
  6.                     {
  7.                         Store (Package (0×02)
  8.                             {
  9.                                 ”fwhub”,
  10.                                 Buffer (0×04)
  11.                                 {
  12.                                     0×00, 0×00, 0×00, 0×00
  13.                                 }
  14.                             }, Local0)
  15.                         DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  16.                         Return (Local0)
  17.                     }
  18.                 }

复制代码


2)在Scope (_GPE)中添加以下代码:


  1.         Method (_L1A, 0, NotSerialized)
  2.         {
  3.             Notify (\_SB.PCI0.EXP5.FRWR, Zero)
  4.         }

复制代码


三、SMBUS:在T410的DSDT原始代码中,SMBUS只有以下这些:


  1.             Device (SMBU)
  2.             {
  3.                 Name (_ADR, 0x001F0003)
  4.                 Name (_S3D, 0×03)
  5.                 Name (RID, 0×00)
  6.             }

复制代码


我们需要将其改成:


  1.             Device (SMBU)
  2.             {
  3.                 Name (_ADR, 0x001F0003)
  4.                 Name (_S3D, 0×03)
  5.                 Name (RID, Zero)
  6.                 Device (BUS0)
  7.                 {
  8.                     Name (_CID, “smbus”)
  9.                     Name (_ADR, Zero)
  10.                     Device (DVL0)
  11.                     {
  12.                         Name (_ADR, 0×57)
  13.                         Name (_CID, “diagsvault”)
  14.                     }
  15.                 }
  16.                 Method (_DSM, 4, NotSerialized)
  17.                 {
  18.                     Store (Package (0×04)
  19.                         {
  20.                             “name”,
  21.                             Buffer (0x0D)
  22.                             {
  23.                                 ”pci8086,3a30″
  24.                             },
  25.                             “device-id”,
  26.                             Buffer (0×04)
  27.                             {
  28.                                 0×30, 0x3A, 0×00, 0×00
  29.                             }
  30.                         }, Local0)
  31.                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  32.                     Return (Local0)
  33.                 }
  34.             }

复制代码


四、有线网卡内建:
在Device (IGBE)中添加有线网卡内建代码,最终Device (IGBE)如下:


  1.             Device (IGBE)
  2.             {
  3.                 Name (_ADR, 0×00190000)
  4.                 Name (_S3D, 0×03)
  5.                 Name (RID, Zero)
  6.                 Name (_PRW, Package (0×02)
  7.                 {
  8.                     0x0D,
  9.                     0×04
  10.                 })
  11.                 Method (_DSM, 4, NotSerialized)
  12.                 {
  13.                     Store (Package (0×06)
  14.                         {
  15.                             “built-in”,
  16.                             Buffer (One)
  17.                             {
  18.                                 0×01
  19.                             },
  20.                             “device_type”,
  21.                             Buffer (0×09)
  22.                             {
  23.                                 ”ethernet”
  24.                             },
  25.                             “name”,
  26.                             Buffer (0×16)
  27.                             {
  28.                                 ”Intel 82577LM Gigabit”
  29.                             }
  30.                         }, Local0)
  31.                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  32.                     Return (Local0)
  33.                 }
  34.             }

复制代码


五、SATA内建:
* T410原始DSDT的SATA代码并未带有内建代码,因此,为Device (SAT1)和Device (SAT2)其添加以下部分:


  1.                 Method (_DSM, 4, NotSerialized)
  2.                 {
  3.                     Store (Package (0×02)
  4.                         {
  5.                             “device-id”,
  6.                             Buffer (0×04)
  7.                             {
  8.                                 0x2F, 0x3B, 0×00, 0×00
  9.                             }
  10.                         }, Local0)
  11.                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  12.                     Return (Local0)
  13.                 }

复制代码


六、添加Fn键功能:
* 找到Device (KBD),在其中添加:


  1.                     Method (_DSM, 4, NotSerialized)
  2.                     {
  3.                         Store (Package (0×02)
  4.                             {
  5.                                 ”AAPL,has-embedded-fn-keys”,
  6.                                 Buffer (0×04)
  7.                                 {
  8.                                     0×01, 0×00, 0×00, 0×00
  9.                                 }
  10.                             }, Local0)
  11.                         DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  12.                         Return (Local0)
  13.                     }

复制代码


七、关于小太阳:

*T410用的是ScrLk和Pause两个按键来调节显示器的亮度。需要在Scope (_SB)中添加以下代码,我添加的位置是在Method (_INI, 0, NotSerialized)之后,在Device (LNKA)之前:


  1.         Device (PNLF)
  2.         {
  3.             Name (_HID, EisaId (“APP0002″))
  4.             Name (_CID, “backlight”)
  5.             Name (_UID, 0x0A)
  6.             Name (_STA, 0x0B)
  7.         }

复制代码


八、按电源键睡眠:

* 在Device (SLPB)之前添加:


  1.         Device (PWRB)
  2.         {
  3.             Name (_CID, EisaId (“PNP0C0C”))
  4.             Name (_UID, 0xAA)
  5.             Method (_STA, 0, NotSerialized)
  6.             {
  7.                 Return (0x0B)
  8.             }
  9.         }

复制代码


九、关机断电:

在Method (_PTS, 1, NotSerialized)之前,添加以下代码:【注意第一行的0×1030是T410专用的,相关资料看我的日志】


  1.     OperationRegion (PMRS, SystemIO, 0×1030, 0×13)
  2.     Field (PMRS, ByteAcc, NoLock, Preserve)
  3.     {
  4.             ,   4,
  5.         SLPE,   1
  6.     }

复制代码


同时,在Method (_PTS, 1, NotSerialized)中的If (LEqual (Arg0, 0×05))里面添加非常关键的两行:


  1.                 Store (Zero, SLPE)
  2.                 Sleep (0×10)

复制代码


之后,完整的代码如下:


  1.             If (LEqual (Arg0, 0×05))
  2.             {
  3.                 TRAP ()
  4.                 TPHY (0×02)
  5.                 AWON (0×05)
  6.                 Store (Zero, SLPE)
  7.                 Sleep (0×10)
  8.             }

复制代码


十、添加指纹设备:搜索:FPU,在代码:


  1.                     Name (_HID, EisaId (“PNP0C04″))
  2.                     Name (_CRS, ResourceTemplate ()
  3.                     {
  4.                         IO (Decode16,
  5.                             0x00F0,             // Range Minimum
  6.                             0x00F0,             // Range Maximum
  7.                             0×02,               // Alignment
  8.                             0×02,               // Length
  9.                             )
  10.                         IRQNoFlags ()
  11.                             {13}
  12.                     })

复制代码


下面加入内建USB代码:


  1.                Method (_DSM, 4, NotSerialized)
  2.                 {
  3.                     Store (Package (0×02)
  4.                         {
  5.                             “device-id”,
  6.                             Buffer (0×04)
  7.                             {
  8.                                 0×16, 0×20, 0×00, 0×00
  9.                             }
  10.                         }, Local0)
  11.                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  12.                     Return (Local0)
  13.                 }

IORegistryExplorer中看不到LPT和ECP设备,果断删除DSDT中的Device (LPT)和Device (ECP)。试验效果不错,不影响。决定T410的新版DSDT可以删除这两个Device。

* 关于显卡代码,我只在Device (PEG)设备下的Device (VID)中添加了以下代码,然后启用变色龙的GraphicsEnabler=yes。

  1.                    Method (_DSM, 4, NotSerialized)
  2.                     {
  3.                         Store (Package (0×06)
  4.                             {
  5.                                 ”@0,built-in”,
  6.                                 Buffer (0×04)
  7.                                 {
  8.                                     0×01, 0×00, 0×00, 0×00
  9.                                 },
  10.                                 ”@0,backlight-control”,
  11.                                 Buffer (0×04)
  12.                                 {
  13.                                     0×01, 0×00, 0×00, 0×00
  14.                                 },
  15.                                 ”@0,pwm-info”,
  16.                                 Buffer (0×14)
  17.                                 {
  18.                                     /* 0000 */    0×01, 0×14, 0×00, 0×64, 0xA8, 0×61, 0×00, 0×00,
  19.                                     /* 0008 */    0×08, 0×52, 0×00, 0×00, 0×01, 0×00, 0×00, 0×00,
  20.                                     /* 0010 */    0×00, 0×04, 0×00, 0×00
  21.                                 }
  22.                             }, Local0)
  23.                         DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  24.                         Return (Local0)
  25.                     }

复制代码

有人可能需要更多更长的显卡代码,这里就暂时不做更多讨论了。

* 关于原生CPU电源管理AppleLPC,正确代码如下:

  1.             Device (LPC)
  2.             {
  3.                 Name (_ADR, 0x001F0000)
  4.                 Method (_DSM, 4, NotSerialized)
  5.                 {
  6.                     Store (Package (0×02)
  7.                         {
  8.                             “device-id”,
  9.                             Buffer (0×04)
  10.                             {
  11.                                 0×07, 0x3B, 0×00, 0×00     //3B07是Intel mobile 5/3400
  12.                             }
  13.                         }, Local0)
  14.                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
  15.                     Return (Local0)
  16.                 }

复制代码

 

原链接:

http://www.91know.com/wordpress/?p=209