ACPI 中文文档ACPI 中文文档
首页
第 1 章
第 2 章
第 3 章
第 4 章
第 5 章
第 6 章
第 7 章
第 8 章
第 9 章
第 10 章
第 11 章
第 12 章
第 13 章
第 14 章
第 15 章
第 16 章
第 17 章
第 18 章
第 19 章
第 20 章
第 21 章
附录 A
首页
第 1 章
第 2 章
第 3 章
第 4 章
第 5 章
第 6 章
第 7 章
第 8 章
第 9 章
第 10 章
第 11 章
第 12 章
第 13 章
第 14 章
第 15 章
第 16 章
第 17 章
第 18 章
第 19 章
第 20 章
第 21 章
附录 A
  • 第 20 章

    • 总览
    • 20.1. 记号约定
    • 20.2. AML 语法定义
    • 20.3. AML 字节流字节值
    • 20.4. 命名空间中名称的 AML 编码

20.2. AML 语法定义

本节定义构成 AML 字节流的字节值。

说明:本节给出 AML 的形式语法。为便于与原始规范、ASL/AML 标识符、编译器输出以及后续章节交叉对照,语法中的非终结符、关键字名和对象名保留英文原名;说明性文字与注释译为中文。

AML 编码可分为以下几组:

> * 表和表头编码 > > * 名称对象编码 > > * 数据对象编码 > > * 包长度编码 > > * 项对象编码 > > * 杂项对象编码 > >

20.2.1. 表和表头编码

> AMLCode > > > := DefBlockHeader TermList

> DefBlockHeader := > > > TableSignature TableLength SpecCompliance CheckSum OemID OemTableID OemRevision CreatorID CreatorRevision

> TableSignature := > > > DWordData // 如第 5.2.3 节中所定义。

> TableLength := > > > DWordData // 表的长度(以字节为单位),包括块头。

> SpecCompliance := > > > ByteData // 结构的修订版本。

> CheckSum := > > > ByteData // 整个表的字节校验和。

> OemID := > > > ByteData(6) // 最多 6 个字符的 OEM ID。如果 OEM ID 少于 6 个字符, > > 则可以用 NULL 字符终止。

> OemTableID := > > > ByteData(8) // 最多 8 个字符的 OEM 表 ID。如果 OEM 表 ID 少于 8 个字符, > > 则可以用 NULL 字符终止。

> OemRevision := > > > DWordData // OEM 表修订版本。

> CreatorID := > > > DWordData // ASL 编译器的供应商 ID。

> CreatorRevision := > > > DWordData // ASL 编译器的修订版本。

20.2.2. 名称对象编码

> LeadNameChar := ‘A’-‘Z’ | ‘_’

> DigitChar := ‘0’ - ‘9’

> NameChar := DigitChar | LeadNameChar

> RootChar := ‘'

> ParentPrefixChar := ‘^’ > > ‘A’-‘Z’ := 0x41 - 0x5A > > ‘_’ := 0x5F > > ‘0’-‘9’ := 0x30 - 0x39 > > ‘' := 0x5C > > ‘^’ := 0x5E

> NameSeg := > > > <leadnamechar namechar namechar namechar> > > // 注意,长度不足 4 个字符的 NameSeg 会以下划线(‘_’)填充尾部。

> NameString := <rootchar namepath> | <prefixpath namepath>

> PrefixPath := Nothing | <’^’ prefixpath>

> NamePath := NameSeg | DualNamePath | MultiNamePath | NullName

> DualNamePath := DualNamePrefix NameSeg NameSeg

> DualNamePrefix := 0x2E

> MultiNamePath := MultiNamePrefix SegCount NameSeg(SegCount)

> MultiNamePrefix := 0x2F

> SegCount := ByteData > > > // SegCount 可以是 1 到 255。例如:MultiNamePrefix(35) 的 > > // 编码为 0x2f 0x23,后跟 35 个 NameSeg。因此,总 > > // 编码长度将为 1 + 1 + 35*4 = 142。请注意: > > // DualNamePrefix NameSeg NameSeg 的编码比 > > // MultiNamePrefix(2) NameSeg NameSeg 的编码更小

> SimpleName := NameString | ArgObj | LocalObj

> SuperName := SimpleName | DebugObj | ReferenceTypeOpcode

> NullName := 0x00

> Target := SuperName | NullName

20.2.3. 数据对象编码

> ComputationalData := ByteConst | WordConst | DWordConst | QWordConst | String | ConstObj | RevisionOp | DefBuffer

> DataObject := ComputationalData | DefPackage | DefVarPackage

> DataRefObject := DataObject | ObjectReference

> ByteConst := BytePrefix ByteData

> BytePrefix := 0x0A

> WordConst := WordPrefix WordData

> WordPrefix := 0x0B

> DWordConst := DWordPrefix DWordData

> DWordPrefix := 0x0C

> QWordConst := QWordPrefix QWordData

> QWordPrefix := 0x0E

> String := StringPrefix AsciiCharList NullChar

> StringPrefix := 0x0D

> ConstObj := ZeroOp | OneOp | OnesOp

> ByteList := Nothing | <bytedata bytelist>

> ByteData := 0x00 - 0xFF

> WordData := ByteData[0:7] ByteData[8:15] > > > // 0x0000-0xFFFF

> DWordData := WordData[0:15] WordData[16:31] > > > // 0x00000000-0xFFFFFFFF

> QWordData := DWordData[0:31] DWordData[32:63] > > > // 0x0000000000000000-0xFFFFFFFFFFFFFFFF

> AsciiCharList := Nothing | <asciichar asciicharlist>

> AsciiChar := 0x01 - 0x7F

> NullChar := 0x00

> ZeroOp := 0x00

> OneOp := 0x01

> OnesOp := 0xFF

> RevisionOp := ExtOpPrefix 0x30

> ExtOpPrefix := 0x5B

20.2.4. 包长度编码

> PkgLength := > > > PkgLeadByte | > > <pkgleadbyte bytedata> | > > <pkgleadbyte bytedata bytedata> | > > <pkgleadbyte bytedata bytedata bytedata>

> PkgLeadByte := > > > <位 7-6:后续 bytedata 的计数(0-3)> > > <位 5-4:仅当 pkglength < 63 时使用> > > <位 3-0:最低有效的包长度半字节>

注意

第一个字节的高 2 位指出 PkgLength 中后续字节的数量。如果 PkgLength 只有一个字节,则使用位 0 到位 5 对包长度进行编码,也就是可表示 0 到 63。如果包长度大于 63,则编码时必须使用多于一个字节;此时,PkgLeadByte 的位 4 和位 5 保留并且必须为 0。如果使用多字节编码,则 PkgLeadByte 的位 0-3 成为结果包长度值的最低有效 4 位。后续的每个 ByteData 依次提供再高 8 位,最多可跟随 3 个 ByteData 字节。因此,最大包长度为 2^28。

20.2.5. 术语对象编码

> Object := NameSpaceModifierObj | NamedObj

> TermObj := Object | StatementOpcode | ExpressionOpcode

> TermList := Nothing | <termobj termlist>

> TermArg := ExpressionOpcode | DataObject | ArgObj | LocalObj

> MethodInvocation := NameString TermArgList

> TermArgList := Nothing | <termarg termarglist>

20.2.5.1. 命名空间修饰符对象编码

> NameSpaceModifierObj := DefAlias | DefName | DefScope

> DefAlias := AliasOp NameString NameString

> AliasOp := 0x06

> DefName := NameOp NameString DataRefObject

> NameOp := 0x08

> DefScope := ScopeOp PkgLength NameString TermList

> ScopeOp := 0x10

20.2.5.2. 命名对象编码

> NamedObj := > > > DefBankField | DefCreateBitField | DefCreateByteField | DefCreateDWordField | DefCreateField | DefCreateQWordField | DefCreateWordField | DefDataRegion | DefExternal | DefOpRegion | DefPowerRes | DefThermalZone

> DefBankField := > > > BankFieldOp PkgLength NameString NameString BankValue FieldFlags FieldList

> BankFieldOp := > > > ExtOpPrefix 0x87

> BankValue := > > > TermArg => Integer

> FieldFlags := > > > ByteData // bit 0-3: AccessType > > // 0 AnyAcc > > // 1 ByteAcc > > // 2 WordAcc > > // 3 DWordAcc > > // 4 QWordAcc > > // 5 BufferAcc > > // 6 Reserved > > // 7-15 Reserved > > // bit 4: LockRule > > // 0 NoLock > > // 1 Lock > > // bit 5-6: UpdateRule > > // 0 Preserve > > // 1 WriteAsOnes > > // 2 WriteAsZeros > > // bit 7: 保留(必须为 0)

> FieldList := Nothing | <fieldelement fieldlist>

> NamedField := NameSeg PkgLength

> ReservedField := 0x00 PkgLength

> AccessField := > > > 0x01 AccessType AccessAttrib

AccessType :=

ByteData // 位 0:3 - 与 FieldFlags 的 AccessType 位相同。

// 位 4:5 - 保留

// 位 7:6 - 0 = AccessAttrib = 正常访问属性

// 1 = AccessAttrib = AttribBytes (x)

// 2 = AccessAttrib = AttribRawBytes (x)

// 3 = AccessAttrib = AttribRawProcessBytes (x)

//

//

// x’ 编码为 AccessAttrib 字节的位 0:7。

> AccessAttrib := > > > ByteData // 如果 AccessType 是用于 SMB 或 > > // GPIO OpRegions 的 BufferAcc,则 AccessAttrib 可以是 > > // 以下值之一: > > // 0x02 AttribQuick > > // 0x04 AttribSendReceive > > // 0x06 AttribByte > > // 0x08 AttribWord > > // 0x0A AttribBlock > > // 0x0C AttribProcessCall > > // 0x0D AttribBlockProcessCall

> ConnectField := > > > <0x02 NameString> | <0x02 BufferData

> DefCreateBitField := > > > CreateBitFieldOp SourceBuff BitIndex NameString

> CreateBitFieldOp := 0x8D

> SourceBuff := > > > TermArg => Buffer

> BitIndex := > > > TermArg => Integer

> DefCreateByteField := > > > CreateByteFieldOp SourceBuff ByteIndex NameString

> CreateByteFieldOp := 0x8C

> ByteIndex := > > > TermArg => Integer

> DefCreateDWordField := > > > CreateDWordFieldOp SourceBuff ByteIndex NameString

> CreateDWordFieldOp := 0x8A

> DefCreateField := > > > CreateFieldOp SourceBuff BitIndex NumBits NameString

> CreateFieldOp := > > > ExtOpPrefix 0x13

> NumBits := > > > TermArg => Integer

> DefCreateQWordField := > > > CreateQWordFieldOp SourceBuff ByteIndex NameString

> CreateQWordFieldOp := 0x8F

> DefCreateWordField := CreateWordFieldOp SourceBuff ByteIndex NameString

> CreateWordFieldOp := 0x8B

> DefDataRegion := DataRegionOp NameString TermArg TermArg TermArg

> DataRegionOp := ExtOpPrefix 0x88

> DefDevice := DeviceOp PkgLength NameString TermList

> DeviceOp := ExtOpPrefix 0x82

> DefEvent := EventOp NameString

> EventOp := ExtOpPrefix 0x02

> DefExternal := ExternalOp NameString ObjectType ArgumentCount

> ExternalOp := 0x15

> ObjectType := ByteData

> ArgumentCount := ByteData (0 - 7)

> DefField := FieldOp PkgLength NameString FieldFlags FieldList

> FieldOp := ExtOpPrefix 0x81

> DefIndexField := IndexFieldOp PkgLength NameString NameString FieldFlags FieldList

> IndexFieldOp := ExtOpPrefix 0x86

> DefMethod := MethodOp PkgLength NameString MethodFlags TermList

> MethodOp := 0x14

> MethodFlags := > > > ByteData // 位 0-2: 参数个数 (0-7) > > // 位 3: 序列化标志 > > // 0 不序列化 > > // 1 已序列化 > > // 位 4-7: SyncLevel (0x00-0x0f)

> DefMutex := MutexOp NameString SyncFlags

> MutexOp := ExtOpPrefix 0x01

> SyncFlags := ByteData // 位 0-3: SyncLevel (0x00-0x0f), 位 4-7: 保留(必须为 0)

> DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset RegionLen

> OpRegionOp := ExtOpPrefix 0x80

> RegionSpace := > > > ByteData // 0x00 系统内存 > > // 0x01 系统 I/O > > // 0x02 PCI_Config > > // 0x03 嵌入式控制器 > > // 0x04 SMBus > > // 0x05 系统 CMOS > > // 0x06 PciBarTarget > > // 0x07 IPMI > > // 0x08 通用 GPIO > > // 0x09 通用串行总线 > > // 0x0A PCC > > // 0x80-0xFF: OEM 定义

> RegionOffset := TermArg => Integer

> RegionLen := TermArg => Integer

> DefPowerRes := PowerResOp PkgLength NameString SystemLevel ResourceOrder TermList

> PowerResOp := ExtOpPrefix 0x84

> SystemLevel := ByteData

> ResourceOrder := WordData

> ProcID := ByteData

> PblkAddr := DWordData

> PblkLen := ByteData

> DefThermalZone := ThermalZoneOp PkgLength NameString TermList

> ThermalZoneOp := ExtOpPrefix 0x85

> ExtendedAccessField := 0x03 AccessType ExtendedAccessAttrib AccessLength

> ExtendedAccessAttrib := > > > ByteData // 0x0B AttribBytes, 0x0E AttribRawBytes, 0x0F AttribRawProcess

> FieldElement := NamedField | ReservedField | AccessField | ExtendedAccessField | ConnectField

20.2.5.3. 语句操作码编码

> StatementOpcode := > > > DefBreak | DefBreakPoint | DefContinue | DefFatal | DefIfElse | DefNoop | DefNotify | DefRelease | DefReset | DefReturn | DefSignal | DefSleep | DefStall | DefWhile

> DefBreak := BreakOp

> BreakOp := 0xA5

> DefBreakPoint := BreakPointOp

> BreakPointOp := 0xCC

> DefContinue := ContinueOp

> ContinueOp := 0x9F

> DefElse := Nothing | <ElseOp PkgLength TermList>

> ElseOp := 0xA1

> DefFatal := FatalOp FatalType FatalCode FatalArg

> FatalOp := ExtOpPrefix 0x32

> FatalType := ByteData

> FatalCode := DWordData

> FatalArg := TermArg => Integer

> DefIfElse := IfOp PkgLength Predicate TermList DefElse

> IfOp := 0xA0

> Predicate := TermArg => Integer

> DefNoop := NoopOp

> NoopOp := 0xA3

> DefNotify := NotifyOp NotifyObject NotifyValue

> NotifyOp := 0x86

> NotifyObject := SuperName => ThermalZone | Processor | Device

> NotifyValue := TermArg => Integer

> DefRelease := ReleaseOp MutexObject

> ReleaseOp := ExtOpPrefix 0x27

> MutexObject := SuperName

> DefReset := ResetOp EventObject

> ResetOp := ExtOpPrefix 0x26

> EventObject := SuperName

> DefReturn := ReturnOp ArgObject

> ReturnOp := 0xA4

> ArgObject := TermArg => DataRefObject

> DefSignal := SignalOp EventObject

> SignalOp := ExtOpPrefix 0x24

> DefSleep := SleepOp MsecTime

> SleepOp := ExtOpPrefix 0x22

> MsecTime := TermArg => Integer

> DefStall := StallOp UsecTime

> StallOp := ExtOpPrefix 0x21

> UsecTime := TermArg => ByteData

> DefWhile := WhileOp PkgLength Predicate TermList

> WhileOp := 0xA2

20.2.5.4. 表达式操作码编码

> ExpressionOpcode := > > > DefAcquire | DefAdd | DefAnd | DefBuffer | DefConcat | DefConcatRes | DefCondRefOf | DefCopyObject | DefDecrement | DefDerefOf | DefDivide | DefFindSetLeftBit | DefFindSetRightBit | DefFromBCD | DefIncrement | DefIndex | DefLAnd | DefLEqual | DefLGreater | DefLGreaterEqual | DefLLess | DefLLessEqual | DefMid | DefLNot | DefLNotEqual | DefLoadTable | DefLOr | DefMatch | DefMod | DefMultiply | DefNAnd | DefNOr | DefNot | DefObjectType | DefOr | DefPackage | DefVarPackage | DefRefOf | DefShiftLeft | DefShiftRight | DefSizeOf | DefStore | DefSubtract | DefTimer | DefToBCD | DefToBuffer | DefToDecimalString | DefToHexString | DefToInteger | DefToString | DefWait | DefXOr | MethodInvocation

> ReferenceTypeOpcode := DefRefOf | DefDerefOf | DefIndex | UserTermObj

> DefAcquire := AcquireOp MutexObject Timeout

> AcquireOp := ExtOpPrefix 0x23

> Timeout := WordData

> DefAdd := AddOp Operand Operand Target

> AddOp := 0x72

> Operand := TermArg => Integer

> DefAnd := AndOp Operand Operand Target

> AndOp := 0x7B

> DefBuffer := BufferOp PkgLength BufferSize ByteList

> BufferOp := 0x11

> BufferSize := TermArg => Integer

> DefConcat := ConcatOp Data Data Target

> ConcatOp := 0x73

> Data := TermArg => ComputationalData

> DefConcatRes := ConcatResOp BufData BufData Target

> ConcatResOp := 0x84

> BufData := TermArg => Buffer

> DefCondRefOf := CondRefOfOp SuperName Target

> CondRefOfOp := ExtOpPrefix 0x12

> DefCopyObject := CopyObjectOp TermArg SimpleName

> CopyObjectOp := 0x9D

> DefDecrement := DecrementOp SuperName

> DecrementOp := 0x76

> DefDerefOf := DerefOfOp ObjReference

> DerefOfOp := 0x83

> ObjReference := TermArg => ObjectReference | String

> DefDivide := DivideOp Dividend Divisor Remainder Quotient

> DivideOp := 0x78

> Dividend := TermArg => Integer

> Divisor := TermArg => Integer

> Remainder := Target

> Quotient := Target

> DefFindSetLeftBit := FindSetLeftBitOp Operand Target

> FindSetLeftBitOp := 0x81

> DefFindSetRightBit := FindSetRightBitOp Operand Target

> FindSetRightBitOp := 0x82

> DefFromBCD := FromBCDOp BCDValue Target

> FromBCDOp := ExtOpPrefix 0x28

> BCDValue := TermArg => Integer

> DefIncrement := IncrementOp SuperName

> IncrementOp := 0x75

> DefIndex := IndexOp BuffPkgStrObj IndexValue Target

> IndexOp := 0x88

> BuffPkgStrObj := TermArg => Buffer、Package 或 String

> IndexValue := TermArg => Integer

> DefLAnd := LandOp Operand Operand

> LandOp := 0x90

> DefLEqual := LequalOp Operand Operand

> LequalOp := 0x93

> DefLGreater := LgreaterOp Operand Operand

> LgreaterOp := 0x94

> DefLGreaterEqual := LgreaterEqualOp Operand Operand

> LgreaterEqualOp := LnotOp LlessOp

> DefLLess := LlessOp Operand Operand

> LlessOp := 0x95

> DefLLessEqual := LlessEqualOp Operand Operand

> LlessEqualOp := LnotOp LgreaterOp

> DefLNot := LnotOp Operand

> LnotOp := 0x92

> DefLNotEqual := LnotEqualOp Operand Operand

> LnotEqualOp := LnotOp LequalOp

> DefLoad := LoadOp NameString Target

> LoadOp := ExtOpPrefix 0x20

> DefLoadTable := LoadTableOp TermArg TermArg TermArg TermArg TermArg TermArg

> LoadTableOp := ExtOpPrefix 0x1F

> DefLOr := LorOp Operand Operand

> LorOp := 0x91

> DefMatch := MatchOp SearchPkg MatchOpcode Operand MatchOpcode Operand StartIndex

> MatchOp := 0x89

> SearchPkg := TermArg => Package

> MatchOpcode := > > > ByteData // 0 MTR > > // 1 MEQ > > // 2 MLE > > // 3 MLT > > // 4 MGE > > // 5 MGT

> StartIndex := TermArg => Integer

> DefMid := MidOp MidObj TermArg TermArg Target

> MidOp := 0x9E

> MidObj := TermArg => Buffer | String

> DefMod := ModOp Dividend Divisor Target

> ModOp := 0x85

> DefMultiply := MultiplyOp Operand Operand Target

> MultiplyOp := 0x77

> DefNAnd := NandOp Operand Operand Target

> NandOp := 0x7C

> DefNOr := NorOp Operand Operand Target

> NorOp := 0x7E

> DefNot := NotOp Operand Target

> NotOp := 0x80

> DefObjectType := ObjectTypeOp <SimpleName | DebugObj | DefRefOf | DefDerefOf | DefIndex>

> ObjectTypeOp := 0x8E

> DefOr := OrOp Operand Operand Target

> OrOp := 0x7D

> DefPackage := PackageOp PkgLength NumElements PackageElementList

> PackageOp := 0x12

> DefVarPackage := VarPackageOp PkgLength VarNumElements PackageElementList

> VarPackageOp := 0x13

> NumElements := ByteData

> VarNumElements := TermArg => Integer

> PackageElementList := Nothing | <PackageElement PackageElementList>

> PackageElement := DataRefObject | NameString

> DefRefOf := RefOfOp SuperName

> RefOfOp := 0x71

> DefShiftLeft := ShiftLeftOp Operand ShiftCount Target

> ShiftLeftOp := 0x79

> ShiftCount := TermArg => Integer

> DefShiftRight := ShiftRightOp Operand ShiftCount Target

> ShiftRightOp := 0x7A

> DefSizeOf := SizeOfOp SuperName

> SizeOfOp := 0x87

> DefStore := StoreOp TermArg SuperName

> StoreOp := 0x70

> DefSubtract := SubtractOp Operand Operand Target

> SubtractOp := 0x74

> DefTimer := TimerOp

> TimerOp := 0x5B 0x33

> DefToBCD := ToBCDOp Operand Target

> ToBCDOp := ExtOpPrefix 0x29

> DefToBuffer := ToBufferOp Operand Target

> ToBufferOp := 0x96

> DefToDecimalString := ToDecimalStringOp Operand Target

> ToDecimalStringOp := 0x97

> DefToHexString := ToHexStringOp Operand Target

> ToHexStringOp := 0x98

> DefToInteger := ToIntegerOp Operand Target

> ToIntegerOp := 0x99

> DefToString := ToStringOp TermArg LengthArg Target

> LengthArg := TermArg => Integer

> ToStringOp := 0x9C

> DefWait := WaitOp EventObject Operand

> WaitOp := ExtOpPrefix 0x25

> DefXOr := XorOp Operand Operand Target

> XorOp := 0x7F

20.2.6. 杂项对象编码

杂项对象包括:

> * Arg 对象 > > * Local 对象 > > * Debug 对象 > >

20.2.6.1. Arg 对象编码

> ArgObj := Arg0Op | Arg1Op | Arg2Op | Arg3Op | Arg4Op | Arg5Op | Arg6Op > > Arg0Op := 0x68 > > Arg1Op := 0x69 > > Arg2Op := 0x6A > > Arg3Op := 0x6B > > Arg4Op := 0x6C > > Arg5Op := 0x6D > > Arg6Op := 0x6E

20.2.6.2. Local 对象编码

> LocalObj := Local0Op | Local1Op | Local2Op | Local3Op | Local4Op | Local5Op | Local6Op | Local7Op > > Local0Op := 0x60 > > Local1Op := 0x61 > > Local2Op := 0x62 > > Local3Op := 0x63 > > Local4Op := 0x64 > > Local5Op := 0x65 > > Local6Op := 0x66 > > Local7Op := 0x67

20.2.6.3. Debug 对象编码

> DebugObj := DebugOp

> DebugOp := ExtOpPrefix 0x31

Prev
20.1. 记号约定
Next
20.3. AML 字节流字节值