mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-10 12:09:31 +00:00
aml: Update Field to support LockRule
LockRule indicates whether the Global Lock is to be used when accessing a field, which is crucial for performing certain MMIO. BUG=None TEST=tools/presubmit Change-Id: I2bbabaa87b85ae529878587c810166614383098c Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3876762 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Auto-Submit: Victor Ding <victording@chromium.org> Tested-by: Victor Ding <victording@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
01f4d18488
commit
ef7e9109da
1 changed files with 20 additions and 7 deletions
|
@ -802,7 +802,7 @@ impl<'a> Aml for Return<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FiledAccessType defines the filed accessing types.
|
/// FieldAccessType defines the field accessing types.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub enum FieldAccessType {
|
pub enum FieldAccessType {
|
||||||
Any,
|
Any,
|
||||||
|
@ -813,7 +813,14 @@ pub enum FieldAccessType {
|
||||||
Buffer,
|
Buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FiledUpdateRule defines the rules to update the filed.
|
/// FieldLockRule defines the rules whether to use the Global Lock.
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub enum FieldLockRule {
|
||||||
|
NoLock = 0,
|
||||||
|
Lock = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// FieldUpdateRule defines the rules to update the field.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub enum FieldUpdateRule {
|
pub enum FieldUpdateRule {
|
||||||
Preserve = 0,
|
Preserve = 0,
|
||||||
|
@ -821,18 +828,19 @@ pub enum FieldUpdateRule {
|
||||||
WriteAsZeroes = 2,
|
WriteAsZeroes = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FiledEntry defines the filed entry.
|
/// FieldEntry defines the field entry.
|
||||||
pub enum FieldEntry {
|
pub enum FieldEntry {
|
||||||
Named([u8; 4], usize),
|
Named([u8; 4], usize),
|
||||||
Reserved(usize),
|
Reserved(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Field object with the region name, filed entries, access type and update rules.
|
/// Field object with the region name, field entries, access type and update rules.
|
||||||
pub struct Field {
|
pub struct Field {
|
||||||
path: Path,
|
path: Path,
|
||||||
|
|
||||||
fields: Vec<FieldEntry>,
|
fields: Vec<FieldEntry>,
|
||||||
access_type: FieldAccessType,
|
access_type: FieldAccessType,
|
||||||
|
lock_rule: FieldLockRule,
|
||||||
update_rule: FieldUpdateRule,
|
update_rule: FieldUpdateRule,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,12 +849,14 @@ impl Field {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
path: Path,
|
path: Path,
|
||||||
access_type: FieldAccessType,
|
access_type: FieldAccessType,
|
||||||
|
lock_rule: FieldLockRule,
|
||||||
update_rule: FieldUpdateRule,
|
update_rule: FieldUpdateRule,
|
||||||
fields: Vec<FieldEntry>,
|
fields: Vec<FieldEntry>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Field {
|
Field {
|
||||||
path,
|
path,
|
||||||
access_type,
|
access_type,
|
||||||
|
lock_rule,
|
||||||
update_rule,
|
update_rule,
|
||||||
fields,
|
fields,
|
||||||
}
|
}
|
||||||
|
@ -858,7 +868,8 @@ impl Aml for Field {
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
self.path.to_aml_bytes(&mut bytes);
|
self.path.to_aml_bytes(&mut bytes);
|
||||||
|
|
||||||
let flags: u8 = self.access_type as u8 | (self.update_rule as u8) << 5;
|
let flags: u8 =
|
||||||
|
self.access_type as u8 | (self.lock_rule as u8) << 4 | (self.update_rule as u8) << 5;
|
||||||
bytes.push(flags);
|
bytes.push(flags);
|
||||||
|
|
||||||
for field in self.fields.iter() {
|
for field in self.fields.iter() {
|
||||||
|
@ -1816,6 +1827,7 @@ mod tests {
|
||||||
Field::new(
|
Field::new(
|
||||||
"PRST".into(),
|
"PRST".into(),
|
||||||
FieldAccessType::Byte,
|
FieldAccessType::Byte,
|
||||||
|
FieldLockRule::NoLock,
|
||||||
FieldUpdateRule::WriteAsZeroes,
|
FieldUpdateRule::WriteAsZeroes,
|
||||||
vec![
|
vec![
|
||||||
FieldEntry::Reserved(32),
|
FieldEntry::Reserved(32),
|
||||||
|
@ -1831,7 +1843,7 @@ mod tests {
|
||||||
assert_eq!(aml, &field_data[..]);
|
assert_eq!(aml, &field_data[..]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Field (PRST, DWordAcc, NoLock, Preserve)
|
Field (PRST, DWordAcc, Lock, Preserve)
|
||||||
{
|
{
|
||||||
CSEL, 32,
|
CSEL, 32,
|
||||||
Offset (0x08),
|
Offset (0x08),
|
||||||
|
@ -1840,7 +1852,7 @@ mod tests {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let field_data = [
|
let field_data = [
|
||||||
0x5Bu8, 0x81, 0x12, 0x50, 0x52, 0x53, 0x54, 0x03, 0x43, 0x53, 0x45, 0x4C, 0x20, 0x00,
|
0x5Bu8, 0x81, 0x12, 0x50, 0x52, 0x53, 0x54, 0x13, 0x43, 0x53, 0x45, 0x4C, 0x20, 0x00,
|
||||||
0x20, 0x43, 0x44, 0x41, 0x54, 0x20,
|
0x20, 0x43, 0x44, 0x41, 0x54, 0x20,
|
||||||
];
|
];
|
||||||
aml.clear();
|
aml.clear();
|
||||||
|
@ -1848,6 +1860,7 @@ mod tests {
|
||||||
Field::new(
|
Field::new(
|
||||||
"PRST".into(),
|
"PRST".into(),
|
||||||
FieldAccessType::DWord,
|
FieldAccessType::DWord,
|
||||||
|
FieldLockRule::Lock,
|
||||||
FieldUpdateRule::Preserve,
|
FieldUpdateRule::Preserve,
|
||||||
vec![
|
vec![
|
||||||
FieldEntry::Named(*b"CSEL", 32),
|
FieldEntry::Named(*b"CSEL", 32),
|
||||||
|
|
Loading…
Reference in a new issue