Skip to content

Commit

Permalink
dragonball: init dbs-pci lib with pci bus & pci conf
Browse files Browse the repository at this point in the history
This commit inits dbs-pci lib for Dragonball to use.
It contains several implementation now:

1. PCI configuration space
2. PCI bus

More info of the design & behavior of those two features could be found
in the README of dbs-cli.

fixes: #8479

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
  • Loading branch information
studychao committed Nov 21, 2023
1 parent 4fd2914 commit 24eaa37
Show file tree
Hide file tree
Showing 7 changed files with 2,586 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/dragonball/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
.idea
src/dbs_*/Cargo.lock
22 changes: 22 additions & 0 deletions src/dragonball/src/dbs_pci/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "dbs-pci"
version = "0.1.0"
authors = ["Alibaba Dragonball Team"]
license = "Apache-2.0"
edition = "2018"
description = "dbs-pci is a crate for emulating pci device"
homepage = "https://github.com/openanolis/dragonball-sandbox"
repository = "https://github.com/openanolis/dragonball-sandbox/tree/main/crates/dbs-pci"
keywords = ["dragonball", "secure-sandbox", "devices", "pci"]
readme = "README.md"

[dependencies]
dbs-device = { path = "../dbs_device" }
dbs-interrupt = { path = "../dbs_interrupt", features = ["kvm-irq"] }
dbs-allocator = { path = "../dbs_allocator" }
log = "0.4.14"
downcast-rs = "1.2.0"
byteorder = "1.4.3"
thiserror = "1"

[features]
13 changes: 13 additions & 0 deletions src/dragonball/src/dbs_pci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# dbs-pci

## Introduction

dbs-pci is a crate for emulating pci device.

There are several components in dbs-pci crate building together to emulate pci device behaviour :

1. device mod: mainly provide the trait for `PciDevice`, providing the ability to get id, write PCI configuration space, read PCI configuration space and `as_any` to downcast the trait object to the actual device type.

2. configuration mod: simulate PCI device configuration header and manage PCI Bar configuration. The PCI Specification defines the organization of the 256-byte Configuration Space registers and imposes a specific template for the space. The first 64 byets of configuration space are standardardized as configuration space header.

3. bus mod: simulate PCI buses, to simplify the implementation, PCI hierarchy is not supported. So all PCI devices are directly connected to the PCI root bus. PciBus has bus id, pci devices attached and pci bus ioport, iomem resource use condition.

0 comments on commit 24eaa37

Please sign in to comment.