mirror of
https://github.com/taigrr/gopher-os
synced 2026-04-02 02:48:44 -07:00
acpi: update AML parser to use the new entities
This commit is contained in:
@@ -47,6 +47,7 @@ type Container interface {
|
||||
Last() Entity
|
||||
}
|
||||
|
||||
// FieldAccessTypeProvider is an interface implemented by all field entities.
|
||||
type FieldAccessTypeProvider interface {
|
||||
// DefaultAccessType returns the default FieldAccessType for any field unit
|
||||
// defined by this field.
|
||||
|
||||
@@ -79,6 +79,19 @@ func TestEntityMethods(t *testing.T) {
|
||||
t.Fatalf("expected parent not to have any child nodes; got %d", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("FieldAccessTypeProvider implementers", func(t *testing.T) {
|
||||
for specIndex, spec := range specs {
|
||||
provider, ok := spec.ent.(FieldAccessTypeProvider)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if exp, got := FieldAccessTypeAny, provider.DefaultAccessType(); got != exp {
|
||||
t.Errorf("[spec %d] expected provider to return access type: %d; got %d", specIndex, exp, got)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestEntityArgAssignment(t *testing.T) {
|
||||
@@ -160,6 +173,24 @@ func TestEntityArgAssignment(t *testing.T) {
|
||||
[]interface{}{NewConst(OpDwordPrefix, 2, uint64(42))},
|
||||
false,
|
||||
},
|
||||
{
|
||||
NewField(2),
|
||||
[]interface{}{"REG0", uint64(128)},
|
||||
nil, // Field populates its internal state using the first 2 args
|
||||
true,
|
||||
},
|
||||
{
|
||||
NewIndexField(2),
|
||||
[]interface{}{"REG0", "DAT0", uint64(128)},
|
||||
nil, // IndexField populates its internal state using the first 3 args
|
||||
true,
|
||||
},
|
||||
{
|
||||
NewBankField(2),
|
||||
[]interface{}{"REG0", "BNK0", uint64(0xf00f), uint64(128)},
|
||||
nil, // BankField populates its internal state using the first 4 args
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
nextSpec:
|
||||
|
||||
@@ -6,6 +6,7 @@ package entity
|
||||
// representation of the opcode values.
|
||||
type AMLOpcode uint16
|
||||
|
||||
// List of AML opcodes
|
||||
const (
|
||||
// Regular opcode list
|
||||
OpZero = AMLOpcode(0x00)
|
||||
@@ -427,14 +428,3 @@ func OpIsType2(op AMLOpcode) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// OpIsBufferField returens true if this opcode describes a
|
||||
// buffer field creation operation.
|
||||
func OpIsBufferField(op AMLOpcode) bool {
|
||||
switch op {
|
||||
case OpCreateField, OpCreateBitField, OpCreateByteField, OpCreateWordField, OpCreateDWordField, OpCreateQWordField:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,14 +227,6 @@ func TestOpcodeIsX(t *testing.T) {
|
||||
{OpPackage, OpIsDataObject, true},
|
||||
{OpVarPackage, OpIsDataObject, true},
|
||||
{OpLor, OpIsDataObject, false},
|
||||
// OpIsBufferField
|
||||
{OpCreateField, OpIsBufferField, true},
|
||||
{OpCreateBitField, OpIsBufferField, true},
|
||||
{OpCreateByteField, OpIsBufferField, true},
|
||||
{OpCreateWordField, OpIsBufferField, true},
|
||||
{OpCreateDWordField, OpIsBufferField, true},
|
||||
{OpCreateQWordField, OpIsBufferField, true},
|
||||
{OpRevision, OpIsBufferField, false},
|
||||
}
|
||||
|
||||
for specIndex, spec := range specs {
|
||||
|
||||
@@ -8,7 +8,7 @@ func TestScopeVisit(t *testing.T) {
|
||||
stopRecursing := func(Entity) bool { return false }
|
||||
|
||||
// Append special entities under IDE0
|
||||
root := NewScope(tableHandle, "IDE0")
|
||||
root := NewScope(OpScope, tableHandle, "IDE0")
|
||||
root.Append(NewDevice(tableHandle, "DEV0"))
|
||||
root.Append(NewProcessor(tableHandle, "FOO0"))
|
||||
root.Append(NewProcessor(tableHandle, "FOO0"))
|
||||
|
||||
Reference in New Issue
Block a user