Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

dbs-legacy-devices: arm add rtc device #157

Merged
merged 2 commits into from
Jun 27, 2022

Conversation

jingshan-lx
Copy link
Collaborator

This modification mainly involves two aspects:

  1. Expose the fdt address for building vcpu.
  2. Add rtc clock to provide clock information for guest kernel.

@studychao
Copy link
Member

please do rust fmt

@jingshan-lx
Copy link
Collaborator Author

please do rust fmt

done

Copy link
Contributor

@wllenyj wllenyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jingshan-lx
Copy link
Collaborator Author

Can we use this directly? https://github.com/rust-vmm/vm-superio/blob/main/crates/vm-superio/src/rtc_pl031.rs

This seems to work, I'll try it

@@ -16,6 +16,7 @@ log = "0.4.14"
serde = { version = "1.0.27", features = ["derive", "rc"] }
vm-superio = "0.5.0"
vmm-sys-util = "0.9.0"
byteorder = "1.4.3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only introduce the dependency for aarch64?

[target.'cfg(target_arch = "aarch64")'.dependencies]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I have remove byteorder.

}
};
}
if read_ok && data.len() <= 4 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it "<= 4" instead of "== 4"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "== 4" and we will use the vm_superio crate to refactor this file.

@jingshan-lx
Copy link
Collaborator Author

Can we use this directly? https://github.com/rust-vmm/vm-superio/blob/main/crates/vm-superio/src/rtc_pl031.rs

Done, I have use the vm_superio crate to refactor this file

Arm export fdt address for building vcpu information.

Signed-off-by: jingshan <jingshan@linux.alibaba.com>
arm adds rtc device to provide guest kernel clock related information.

Signed-off-by: jingshan <jingshan@linux.alibaba.com>
@codecov
Copy link

codecov bot commented Jun 22, 2022

Codecov Report

Merging #157 (7115a2e) into main (127621d) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #157   +/-   ##
=======================================
  Coverage   85.91%   85.91%           
=======================================
  Files          79       79           
  Lines       20254    20254           
=======================================
  Hits        17401    17401           
  Misses       2853     2853           
Flag Coverage Δ
dbs-address-space 68.36% <ø> (ø)
dbs-allocator 81.99% <ø> (ø)
dbs-arch 96.34% <ø> (ø)
dbs-boot 65.41% <ø> (ø)
dbs-device 91.84% <ø> (ø)
dbs-interrupt 90.40% <ø> (ø)
dbs-legacy-devices 92.77% <ø> (ø)
dbs-utils 91.25% <ø> (ø)
dbs-virtio-devices 86.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
crates/dbs-legacy-devices/src/lib.rs 100.00% <ø> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

fn read(&mut self, _base: IoAddress, offset: IoAddress, data: &mut [u8]) {
if data.len() == 4 {
self.rtc
.read(offset.raw_value() as u16, data.try_into().unwrap())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using try_into().unwrap() here?
How about directly passing data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was my mistake, I answered the question but forgot to submit it.

Since the input parameters of the read() and write() functions of rtc in vm-superio crate are &[u8; 4], we need to use try_into() to convert &[u8] to &[u8; 4].

}
}

fn write(&mut self, _base: IoAddress, offset: IoAddress, data: &[u8]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why read use &mut [u8] (which I don't see the usage in read function) and write use &[u8]?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's read to the buffer and write from the buffer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got that

Copy link
Contributor

@wllenyj wllenyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase it again?

LGTM others.

@studychao studychao merged commit 7a8e832 into openanolis:main Jun 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants