Skip to content

Commit 40e43b4

Browse files
committed
Fix all warnings for now
1 parent e02ab2a commit 40e43b4

File tree

4 files changed

+44
-26
lines changed

4 files changed

+44
-26
lines changed

src/address.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ impl<H> MappedGas<H>
129129
where
130130
H: Handler,
131131
{
132+
/// Map the given `GenericAddress`, giving a `MappedGas` that can be read from and written to.
133+
///
134+
/// ### Safety
135+
/// The supplied `GenericAddress` must be a valid GAS and all subsequent reads and writes must
136+
/// be valid.
132137
pub unsafe fn map_gas(gas: GenericAddress, handler: &H) -> Result<MappedGas<H>, AcpiError> {
133138
match gas.address_space {
134139
AddressSpace::SystemMemory => {
@@ -183,7 +188,7 @@ where
183188
let mapping = self.mapping.as_ref().unwrap();
184189
match access_size_bits {
185190
8 => unsafe {
186-
core::ptr::write_volatile(mapping.virtual_start.as_ptr() as *mut u8, value as u8);
191+
core::ptr::write_volatile(mapping.virtual_start.as_ptr(), value as u8);
187192
},
188193
16 => unsafe {
189194
core::ptr::write_volatile(mapping.virtual_start.as_ptr() as *mut u16, value as u16);

src/aml/mod.rs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ where
737737
}
738738
Opcode::Acquire => {
739739
let [Argument::Object(mutex)] = &op.arguments[..] else { panic!() };
740-
let Object::Mutex { mutex, sync_level } = **mutex else {
740+
let Object::Mutex { mutex, sync_level: _ } = **mutex else {
741741
Err(AmlError::InvalidOperationOnObject { op: Operation::Acquire, typ: mutex.typ() })?
742742
};
743743
let timeout = context.next_u16()?;
@@ -753,7 +753,7 @@ where
753753
}
754754
Opcode::Release => {
755755
let [Argument::Object(mutex)] = &op.arguments[..] else { panic!() };
756-
let Object::Mutex { mutex, sync_level } = **mutex else {
756+
let Object::Mutex { mutex, sync_level: _ } = **mutex else {
757757
Err(AmlError::InvalidOperationOnObject { op: Operation::Release, typ: mutex.typ() })?
758758
};
759759

@@ -1348,7 +1348,7 @@ where
13481348
let behaviour = if context.current_block.kind == BlockKind::Package {
13491349
ResolveBehaviour::PackageElement
13501350
} else if context.current_block.kind == BlockKind::VarPackage {
1351-
if context.last_op()?.arguments.len() == 0 {
1351+
if context.last_op()?.arguments.is_empty() {
13521352
ResolveBehaviour::ResolveToObject
13531353
} else {
13541354
ResolveBehaviour::PackageElement
@@ -2146,7 +2146,7 @@ where
21462146
match kind {
21472147
ReferenceKind::RefOf => todo!(),
21482148
ReferenceKind::LocalOrArg => {
2149-
if let Object::Reference { kind: inner_kind, inner: inner_inner } = &**inner {
2149+
if let Object::Reference { kind: _inner_kind, inner: inner_inner } = &**inner {
21502150
// TODO: this should store into the reference, potentially doing an
21512151
// implicit cast
21522152
unsafe {
@@ -2205,15 +2205,15 @@ where
22052205

22062206
let read_region = match field.kind {
22072207
FieldUnitKind::Normal { ref region } => region,
2208-
FieldUnitKind::Bank { ref region, ref bank, bank_value } => {
2208+
// FieldUnitKind::Bank { ref region, ref bank, bank_value } => {
2209+
FieldUnitKind::Bank { .. } => {
22092210
// TODO: put the bank_value in the bank
22102211
todo!();
2211-
region
22122212
}
2213-
FieldUnitKind::Index { ref index, ref data } => {
2213+
// FieldUnitKind::Index { ref index, ref data } => {
2214+
FieldUnitKind::Index { .. } => {
22142215
// TODO: configure the correct index
22152216
todo!();
2216-
data
22172217
}
22182218
};
22192219
let Object::OpRegion(ref read_region) = **read_region else { panic!() };
@@ -2265,15 +2265,15 @@ where
22652265

22662266
let write_region = match field.kind {
22672267
FieldUnitKind::Normal { ref region } => region,
2268-
FieldUnitKind::Bank { ref region, ref bank, bank_value } => {
2268+
// FieldUnitKind::Bank { ref region, ref bank, bank_value } => {
2269+
FieldUnitKind::Bank { .. } => {
22692270
// TODO: put the bank_value in the bank
22702271
todo!();
2271-
region
22722272
}
2273-
FieldUnitKind::Index { ref index, ref data } => {
2273+
// FieldUnitKind::Index { ref index, ref data } => {
2274+
FieldUnitKind::Index { .. } => {
22742275
// TODO: configure the correct index
22752276
todo!();
2276-
data
22772277
}
22782278
};
22792279
let Object::OpRegion(ref write_region) = **write_region else { panic!() };
@@ -2373,8 +2373,9 @@ where
23732373
| RegionSpace::GenericSerialBus
23742374
| RegionSpace::Pcc
23752375
| RegionSpace::Oem(_) => {
2376-
if let Some(handler) = self.region_handlers.lock().get(&region.space) {
2377-
todo!("Utilise handler");
2376+
if let Some(_handler) = self.region_handlers.lock().get(&region.space) {
2377+
warn!("Custom region handlers aren't actually supported yet.");
2378+
Err(AmlError::LibUnimplemented)
23782379
} else {
23792380
Err(AmlError::NoHandlerForRegionAccess(region.space))
23802381
}
@@ -2439,8 +2440,9 @@ where
24392440
| RegionSpace::GenericSerialBus
24402441
| RegionSpace::Pcc
24412442
| RegionSpace::Oem(_) => {
2442-
if let Some(handler) = self.region_handlers.lock().get(&region.space) {
2443-
todo!("Utilise handler");
2443+
if let Some(_handler) = self.region_handlers.lock().get(&region.space) {
2444+
warn!("Custom region handlers aren't actually supported yet.");
2445+
Err(AmlError::LibUnimplemented)
24442446
} else {
24452447
Err(AmlError::NoHandlerForRegionAccess(region.space))
24462448
}
@@ -3057,9 +3059,15 @@ pub enum AmlError {
30573059

30583060
MethodArgCountIncorrect,
30593061

3060-
InvalidOperationOnObject { op: Operation, typ: ObjectType },
3062+
InvalidOperationOnObject {
3063+
op: Operation,
3064+
typ: ObjectType,
3065+
},
30613066
IndexOutOfBounds,
3062-
ObjectNotOfExpectedType { expected: ObjectType, got: ObjectType },
3067+
ObjectNotOfExpectedType {
3068+
expected: ObjectType,
3069+
got: ObjectType,
3070+
},
30633071

30643072
InvalidResourceDescriptor,
30653073
UnexpectedResourceType,
@@ -3072,4 +3080,8 @@ pub enum AmlError {
30723080
PrtInvalidGsi,
30733081
PrtInvalidSource,
30743082
PrtNoEntry,
3083+
3084+
/// This is emitted to signal that the library does not support the requested behaviour. This
3085+
/// should eventually never be emitted.
3086+
LibUnimplemented,
30753087
}

src/aml/object.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,18 @@ impl fmt::Display for Object {
4444
match self {
4545
Object::Uninitialized => write!(f, "[Uninitialized]"),
4646
Object::Buffer(bytes) => write!(f, "Buffer({bytes:x?})"),
47-
// TODO: include fields here
48-
Object::BufferField { buffer, offset, length } => write!(f, "BufferField {{ .. }}"),
47+
Object::BufferField { offset, length, .. } => {
48+
write!(f, "BufferField {{ offset: {offset}, length: {length} }}")
49+
}
4950
Object::Device => write!(f, "Device"),
5051
Object::Event => write!(f, "Event"),
5152
// TODO: include fields
5253
Object::FieldUnit(_) => write!(f, "FieldUnit"),
5354
Object::Integer(value) => write!(f, "Integer({value})"),
5455
// TODO: decode flags here
55-
Object::Method { code, flags } => write!(f, "Method"),
56+
Object::Method { .. } => write!(f, "Method"),
5657
Object::NativeMethod { .. } => write!(f, "NativeMethod"),
57-
Object::Mutex { mutex, sync_level } => write!(f, "Mutex"),
58+
Object::Mutex { .. } => write!(f, "Mutex"),
5859
Object::Reference { kind, inner } => write!(f, "Reference({:?} -> {})", kind, **inner),
5960
Object::OpRegion(region) => write!(f, "{region:?}"),
6061
Object::Package(elements) => {
@@ -70,9 +71,9 @@ impl fmt::Display for Object {
7071
Ok(())
7172
}
7273
// TODO: include fields
73-
Object::PowerResource { system_level, resource_order } => write!(f, "PowerResource"),
74+
Object::PowerResource { .. } => write!(f, "PowerResource"),
7475
// TODO: include fields
75-
Object::Processor { proc_id, pblk_address, pblk_length } => write!(f, "Processor"),
76+
Object::Processor { .. } => write!(f, "Processor"),
7677
Object::RawDataBuffer => write!(f, "RawDataBuffer"),
7778
Object::String(value) => write!(f, "String({value:?})"),
7879
Object::ThermalZone => write!(f, "ThermalZone"),

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
//! interfaces, such as [`PlatformInfo`], [`PciConfigRegions`], or [`HpetInfo`].
3333
3434
#![no_std]
35-
#![feature(allocator_api, let_chains)]
35+
#![feature(allocator_api)]
3636

3737
#[cfg_attr(test, macro_use)]
3838
#[cfg(test)]

0 commit comments

Comments
 (0)