Documentation\acpi\method-custonmizing

Chinese translated version of Documentation\acpi\method-custonmizing




If you have any comment or update to the content, please contact the
original document maintainer directly.  However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help.  Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.




Chinese maintainer: biyu tang<tangbiyu17@qq.com>
---------------------------------------------------------------------
DocumentationDocumentation\acpi\method-custonmizing的中文翻译




如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。




中文版维护者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>
中文版翻译者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>
中文版校译者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>




















以下为正文
---------------------------------------------------------------------


Linux ACPI Custom Control Method How To
=======================================


Written by Zhang Rui <rui.zhang@intel.com>


Linux ACPI自定义的控制方法
=======================================


由张瑞<rui.zhang@intel.com>撰写


Linux supports customizing ACPI control methods at runtime.


Linux支持在运行时自定义ACPI控制方法。




Users can use this to
1. override an existing method which may not work correctly,
   or just for debugging purposes.
2. insert a completely new method in order to create a missing
   method such as _OFF, _ON, _STA, _INI, etc.
For these cases, it is far simpler to dynamically install a single
control method rather than override the entire DSDT, because kernel
rebuild/reboot is not needed and test result can be got in minutes.


用户可以利用这一点:
1.覆盖一个现有的可能无法正常工作或者只是用于调试目的路径。
2.插入一个完全新的方法,以创建一个丢失的路径
  如 _ON_OFF,_STA,_INI等方法。
对于这些情况,动态地安装一个单一的控制路径简单得多,而不是覆盖
整个DSDT,因为内核重建/重启是没有必要的,并且测试结果几分钟内就
可以得到。


Note: Only ACPI METHOD can be overridden, any other object types like
      "Device", "OperationRegion", are not recognized.
Note: The same ACPI control method can be overridden for many times,
      and it's always the latest one that used by Linux/kernel.
Note: To get the ACPI debug object output (Store (AAAA, Debug)),
      please run "echo 1 > /sys/module/acpi/parameters/aml_debug_output".
 
注意:只有ACPI方法可以被覆盖,任何其他对象类型,如“设备”,“OperationRegion”,
    都不予确认。
注意:同样的ACPI控制方法可以被覆盖很多次,并且linux/内核使用的总是最后一个。
注意:为了获得ACPI调试目标输出(Store (AAAA, Debug)),请运行"echo 1 > /sys/module/
      acpi/parameters/aml_debug_output".


1. override an existing method
   a) get the ACPI table via ACPI sysfs I/F. e.g. to get the DSDT,
      just run "cat /sys/firmware/acpi/tables/DSDT > /tmp/dsdt.dat"
   b) disassemble the table by running "iasl -d dsdt.dat".
   c) rewrite the ASL code of the method and save it in a new file,
   d) package the new file (psr.asl) to an ACPI table format.
      Here is an example of a customized \_SB._AC._PSR method,
    
DefinitionBlock ("", "SSDT", 1, "", "", 0x20080715)
      {
External (ACON)


Method (\_SB_.AC._PSR, 0, NotSerialized)
{
Store ("In AC _PSR", Debug)
Return (ACON)
}
      }
      Note that the full pathname of the method in ACPI namespace
      should be used.
      And remember to use "External" to declare external objects.
   e) assemble the file to generate the AML code of the method.
      e.g. "iasl psr.asl" (psr.aml is generated as a result)
   f) mount debugfs by "mount -t debugfs none /sys/kernel/debug"
   g) override the old method via the debugfs by running
      "cat /tmp/psr.aml > /sys/kernel/debug/acpi/custom_method"
 
1.覆盖一个已经存在的方法
  a)通过ACPI sysfs中的I / F获得ACPI表。例如要得到DSDT,只需运行
  “cat /sys/firmware/acpi/tables/DSDT > /tmp/dsdt.dat”
  b)通过运行“iasl -d dsdt.dat”分解表。
  c)重写ASL代码的方法,并将其保存在一个新的文件,
  d)打包新的文件(psr.asl)到ACPI表格。下面是一个自定义的\_SB._AC._PSR
    方法的例子,
  DefinitionBlock ("", "SSDT", 1, "", "", 0x20080715)
      {
External (ACON)


Method (\_SB_.AC._PSR, 0, NotSerialized)
{
Store ("In AC _PSR", Debug)
Return (ACON)
}
      }
 需要注意的是ACPI命名空间中的方法的完整路径应该被使用。
      记得使用“External”声明外部对象。
e)组装文件生成AML代码的方法。
    f)通过“mount -t debugfs none /sys/kernel/debug”安装debugfs
g)覆盖旧的方法通过debugfs运行"cat /tmp/psr.aml > /sys/kernel/
 debug/acpi/custom_method"

2. insert a new method
   This is easier than overriding an existing method.
   We just need to create the ASL code of the method we want to
   insert and then follow the step c) ~ g) in section 1.
   
2.插入一个新的方法
  这比覆盖一个已经存在的方法来的简单。我们只需要创建我们想要插入
  的方法的SASl代码然后按照第一节c)~g)的步骤


3. undo your changes
   The "undo" operation is not supported for a new inserted method
   right now, i.e. we can not remove a method currently.
   For an overrided method, in order to undo your changes, please
   save a copy of the method original ASL code in step c) section 1,
   and redo step c) ~ g) to override the method with the original one.
   
3.撤销操作
  对于一个新插入的方法不能立即执行撤销操作。也就是说我们不能移除
  一个当前的方法。对于一个被覆盖的方法,为了撤销操作,请在第一节步
  骤c)中保存一个ASL源代码的备份,并且重做步骤 c) ~ g)用原来的覆盖现
  有的。




Note: We can use a kernel with multiple custom ACPI method running,
      But each individual write to debugfs can implement a SINGLE
      method override. i.e. if we want to insert/override multiple
      ACPI methods, we need to redo step c) ~ g) for multiple times.
 
注:我们可以使用一个具有多个自定义运行ACPI方法的内核,但每一个人写的
    debugfs只可以实现一个单一方法覆盖。即如果我们想插入/覆盖多个ACPI的
方法,我们需要多次重做步骤c)〜G)。


Note: Be aware that root can mis-use this driver to modify arbitrary
      memory and gain additional rights, if root's privileges got
      restricted (for example if root is not allowed to load additional
      modules after boot).
 
注意:请注root可以非正常使用此驱动程序来修改任意内存,并获得额外的权利,
      如果root的权限受限制(例如,如果根还没有加载额外的模块开机后)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值