fuchsia.hardware.pci

新增:HEAD

通訊協定

偵錯

定義於 fuchsia.hardware.pci/debug.fidl

偵錯通訊協定會提供特定匯流排上的裝置資訊。這項資訊適用於 lspci 等工具,不適用於驅動程式庫作業。

GetDevices

擷取匯流排上的所有裝置。

要求

<EMPTY>

回應

名稱類型
devices vector<PciDevice>:64

GetHostBridgeInfo

擷取匯流排涵蓋的區隔群組和匯流排相關資訊。

要求

<EMPTY>

回應

名稱類型
info HostBridgeInfo

ReadBar

讀取裝置的基準位址暫存器 (BAR)。BAR 必須是 MMIO 類型。

參數 |device|:要讀取的裝置位址。|bar_id|:要讀取的 BAR ID。|offset|:開始讀取的偏移量,以位元組為單位 (預設:0 位元組)。|size|:讀取的大小 (預設:128 位元組)。讀取大小上限為 |READBAR_MAX_SIZE|。

錯誤: |ZX_ERR_NOT_FOUND|:找不到 |device|,或 |device| 中沒有 |bar_id|。 |ZX_ERR_INVALID_ARGS|:|bar_id| 無效,或偏移量 / 大小組合對指定 BAR 的大小無效。 |ZX_ERR_NOT_SUPPORTED|:|bar_id| 指定的 BAR 不是 MMIO BAR。

要求

名稱類型
device Address
bar_id uint8
offset uint64
size uint64

回應

名稱類型
payload Debug_ReadBar_Result

裝置

定義於 fuchsia.hardware.pci/pci.fidl

AckInterrupt

提醒匯流排驅動程式取消已引發的舊版中斷,以便再次等待。只有在呼叫 |SetInterruptMode| 時,才會使用 |PCI_INTERRUPT_MODE_LEGACY|。

錯誤: |ZX_ERR_BAD_STATE|:裝置未設為使用舊版中斷模式。

要求

<EMPTY>

回應

名稱類型
payload Device_AckInterrupt_Result

GetBar

擷取指定基本位址暫存器 (BAR) 的資訊。如果 BAR 包含 MSI-X 能力表,系統會嘗試傳回不含這些資料表的 MMIO 區域 (如果可能的話)。否則會傳回錯誤。

參數: |bar_id|:所要求 BAR 的 ID。有效範圍為 [0, 6)。

錯誤: |ZX_ERR_ACCESS_DENIED|:由於存在 MSI-X 資料表,指定的 BAR 沒有驅動程式庫可存取的區域。如要使用 MSI-X,請參閱 |SetInterruptMode| 方法。|ZX_ERR_INTERNAL|:發生匯流排驅動程式錯誤。|ZX_ERR_INVALID_ARGS|:指定的 |bar_id| 超出可接受的範圍。|ZX_ERR_NOT_FOUND|:這部裝置沒有指定的 |bar_id|。

要求

名稱類型
bar_id uint32

回應

名稱類型
payload Device_GetBar_Result

GetBti

傳回裝置指定索引處的匯流排交易發起端 (BTI)。

參數: |index|:要要求的 BTI。

錯誤: |ZX_ERR_OUT_OF_RANGE|:|index| 不是 0。

要求

名稱類型
index uint32

回應

名稱類型
payload Device_GetBti_Result

GetCapabilities

傳回設定空間中的偏移向量,對應與提供的能力 |id| 相符的功能。如果找不到對應的相符項目,向量會是空白。

參數: |id|:要搜尋的能力 ID。

要求

名稱類型
id CapabilityId

回應

名稱類型
offsets vector<ConfigOffset>:32

GetDeviceInfo

傳回包含設定標頭中裝置資訊的結構。

要求

<EMPTY>

回應

名稱類型
info DeviceInfo

GetExtendedCapabilities

傳回設定空間中的偏移向量,對應與提供的擴充能力 |id| 相符的擴充功能。如果找不到對應的相符項目,向量會是空白。

參數: |id|:要搜尋的能力 ID

要求

名稱類型
id ExtendedCapabilityId

回應

名稱類型
offsets vector<ExtendedConfigOffset>:32

GetInterruptModes

傳回裝置支援的中斷模式。

要求

<EMPTY>

回應

名稱類型
modes InterruptModes

MapInterrupt

將裝置的中斷對應至 zx:interrupt。裝置的中斷模式必須已透過 |SetInterruptMode| 設定,且 |which_irq| 必須大於或等於 |GetInterruptModes| 回報的中斷模式中斷次數。舊版中斷可能會多次對應,但控制代碼會指向同一個中斷物件。MSI 和 MSI-X 中斷每次只能有一個未完成的對應。在後續呼叫 |SetInterruptMode| 嘗試變更中斷模式之前,必須先關閉未完成的 MSI 和 MSI-X 中斷控制代碼。

參數: |which_irq|:要對應的中斷 ID。

錯誤: |ZX_ERR_ALREADY_BOUND|:|which_irq| 指定的中斷已對應至有效控制代碼。|ZX_ERR_BAD_STATE|:裝置目前已停用中斷。|ZX_ERR_INVALID_ARGS|:|which_irq| 對模式無效。

要求

名稱類型
which_irq uint32

回應

名稱類型
payload Device_MapInterrupt_Result

ReadConfig16

從裝置的設定空間讀取兩個位元組。如果是 PCI,|Offset| 必須介於 [0x0, 0xFE] 之間;如果是 PCIe,則必須介於 [0x0, 0xFFE] 之間。在多數情況下,裝置會是 PCIe。

參數: |offset|:要讀取的裝置設定空間偏移量。

錯誤: |ZX_ERR_OUT_OF_RANGE|:|offset| 是無效的位址。

要求

名稱類型
offset ExtendedConfigOffset

回應

名稱類型
payload Device_ReadConfig16_Result

ReadConfig32

從裝置的設定空間讀取四個位元組。如果是 PCI,|Offset| 必須介於 [0x0, 0xFC] 之間;如果是 PCIe,則必須介於 [0x0, 0xFFC] 之間。在大多數情況下,裝置會是 PCIe。

參數: |offset|:要讀取的裝置設定空間偏移量。

錯誤: |ZX_ERR_OUT_OF_RANGE|:|offset| 是無效的位址。

要求

名稱類型
offset ExtendedConfigOffset

回應

名稱類型
payload Device_ReadConfig32_Result

ReadConfig8

從裝置的設定空間讀取位元組。如果是 PCI,|Offset| 必須介於 [0x0, 0xFF] 之間;如果是 PCIe,則必須介於 [0x0, 0xFFF) 之間。在多數情況下,裝置會是 PCIe。

參數: |offset|:要讀取的裝置設定空間偏移量。

錯誤: |ZX_ERR_OUT_OF_RANGE|:|offset| 是無效的位址。

要求

名稱類型
offset ExtendedConfigOffset

回應

名稱類型
payload Device_ReadConfig8_Result

ResetDevice

啟動裝置的函式層級重設。這項同步作業會在重設完成後傳回。必須先停用裝置的中斷作業,才能啟動重設。

錯誤: |ZX_ERR_BAD_STATE|:呼叫 |ResetDevice| 前未停用中斷。 |ZX_ERR_NOT_SUPPORTED|:裝置不支援重設。 |ZX_ERR_TIMED_OUT|:裝置未在預期時間內完成重設,系統判定裝置已無法正常運作。

要求

<EMPTY>

回應

名稱類型
payload Device_ResetDevice_Result

SetBusMastering

啟用或停用裝置的匯流排主控能力。

參數: |enable|:設為 true 可啟用匯流排主控功能,設為 false 則會停用。

錯誤: |ZX_ERR_BAD_STATE|:在裝置停用時呼叫方法。

要求

名稱類型
enabled bool

回應

名稱類型
payload Device_SetBusMastering_Result

SetInterruptMode

設定裝置的中斷模式。從一種中斷模式切換至另一種模式時,驅動程式庫必須確保現有的中斷控制代碼已事先關閉。

參數: |mode|:向匯流排驅動程式要求的 |InterruptMode|。 |requested_irq_count|:要求的中斷次數。

錯誤: |ZX_ERR_BAD_STATE|:驅動程式嘗試變更中斷模式,但對應 MSI 的現有控制代碼存在。|ZX_ERR_INVALID_ARGS|:|requested_irq_count| 為 0。|ZX_ERR_NOT_SUPPORTED|:提供的 |mode| 無效或不受支援。

要求

名稱類型
mode InterruptMode
requested_irq_count uint32

回應

名稱類型
payload Device_SetInterruptMode_Result

WriteConfig16

將兩個位元組寫入裝置的設定空間。寫入時,|offset| 的可接受範圍為 [0x40, 0xFE] (PCI) 或 [0x40, 0xFFE] (PCIe)。在大多數情況下,裝置會是 PCIe。

參數 |offset|:要讀取的裝置設定空間偏移量。|value|:要寫入的值。

錯誤: |ZX_ERR_ACCESS_DENIED|:|offset| 位於裝置的設定標頭內。 |ZX_ERR_OUT_OF_RANGE|:|offset| 是無效的位址。

要求

名稱類型
offset ExtendedConfigOffset
value uint16

回應

名稱類型
payload Device_WriteConfig16_Result

WriteConfig32

將四個位元組寫入裝置的設定空間。如果是 PCI,寫入作業的 |offset| 可接受範圍為 [0x40, 0xFC];如果是 PCIe,則為 [0x40, 0xFFC]。在大多數情況下,裝置會是 PCIe。

參數 |offset|:要讀取的裝置設定空間偏移量。|value|:要寫入的值。

錯誤: |ZX_ERR_ACCESS_DENIED|:|offset| 位於裝置的設定標頭內。 |ZX_ERR_OUT_OF_RANGE|:|offset| 是無效的位址。

要求

名稱類型
offset ExtendedConfigOffset
value uint32

回應

名稱類型
payload Device_WriteConfig32_Result

WriteConfig8

將一個位元組寫入裝置的設定空間。如果是 PCI,寫入作業可接受的 |offset| 範圍為 [0x40, 0xFF];如果是 PCIe,則為 [0x40, 0xFFF]。在大多數情況下,裝置會是 PCIe。

參數 |offset|:要讀取的裝置設定空間偏移量。|value|:要寫入的值。

錯誤: |ZX_ERR_ACCESS_DENIED|:|offset| 位於裝置的設定標頭內。 |ZX_ERR_OUT_OF_RANGE|:|offset| 是無效的位址。

要求

名稱類型
offset ExtendedConfigOffset
value uint8

回應

名稱類型
payload Device_WriteConfig8_Result

STRUCTS

地址

定義於 fuchsia.hardware.pci/debug.fidl

PCI 裝置的位址。

欄位類型說明預設
bus uint8 無預設值
device uint8 無預設值
function uint8 無預設值

Bar 資源

定義於 fuchsia.hardware.pci/pci.fidl

說明並提供裝置指定基本位址暫存器的存取權。

欄位類型說明預設
bar_id uint32

BAR ID,[0-5)。

無預設值
size uint64 無預設值
result BarResult 無預設值

BaseAddress

定義於 fuchsia.hardware.pci/debug.fidl

欄位類型說明預設
address uint64 無預設值
size uint64 無預設值
is_memory bool 無預設值
is_prefetchable bool 無預設值
is_64bit bool 無預設值
id uint8 無預設值

Bdf

定義於 fuchsia.hardware.pci/pci.fidl

PCI 根通訊協定使用的匯流排/裝置/函式位址。

欄位類型說明預設
bus_id uint8 無預設值
device_id uint8 無預設值
function_id uint8 無預設值

功能

定義於 fuchsia.hardware.pci/debug.fidl

欄位類型說明預設
id uint8 無預設值
offset uint8 無預設值

Debug_ReadBar_Response

定義於 fuchsia.hardware.pci/debug.fidl

欄位類型說明預設
buffer vector<uint8> 無預設值

DeviceInfo

定義於 fuchsia.hardware.pci/pci.fidl

裝置設定標頭中的裝置專屬資訊。PCI Local Bus Specification v3 第 6.1 章。

欄位類型說明預設
vendor_id uint16

裝置識別資訊。

無預設值
device_id uint16 無預設值
base_class uint8 無預設值
sub_class uint8 無預設值
program_interface uint8 無預設值
revision_id uint8 無預設值
bus_id uint8

匯流排拓撲中裝置位置的相關資訊。

無預設值
dev_id uint8 無預設值
func_id uint8 無預設值
padding Padding 無預設值

Device_AckInterrupt_Response

定義於 fuchsia.hardware.pci/pci.fidl

<EMPTY>

Device_GetBar_Response 資源

定義於 fuchsia.hardware.pci/pci.fidl

欄位類型說明預設
result Bar 無預設值

Device_GetBti_Response 資源

定義於 fuchsia.hardware.pci/pci.fidl

欄位類型說明預設
bti handle<bti> 無預設值

Device_MapInterrupt_Response 資源

定義於 fuchsia.hardware.pci/pci.fidl

欄位類型說明預設
interrupt handle<interrupt> 無預設值

Device_ReadConfig16_Response

定義於 fuchsia.hardware.pci/pci.fidl

欄位類型說明預設
value uint16 無預設值

Device_ReadConfig32_Response

定義於 fuchsia.hardware.pci/pci.fidl

欄位類型說明預設
value uint32 無預設值

Device_ReadConfig8_Response

定義於 fuchsia.hardware.pci/pci.fidl

欄位類型說明預設
value uint8 無預設值

Device_ResetDevice_Response

定義於 fuchsia.hardware.pci/pci.fidl

<EMPTY>

Device_SetBusMastering_Response

定義於 fuchsia.hardware.pci/pci.fidl

<EMPTY>

Device_SetInterruptMode_Response

定義於 fuchsia.hardware.pci/pci.fidl

<EMPTY>

Device_WriteConfig16_Response

定義於 fuchsia.hardware.pci/pci.fidl

<EMPTY>

Device_WriteConfig32_Response

定義於 fuchsia.hardware.pci/pci.fidl

<EMPTY>

Device_WriteConfig8_Response

定義於 fuchsia.hardware.pci/pci.fidl

<EMPTY>

ExtendedCapability

定義於 fuchsia.hardware.pci/debug.fidl

欄位類型說明預設
id uint16 無預設值
offset uint16 無預設值

HostBridgeInfo

定義於 fuchsia.hardware.pci/debug.fidl

欄位類型說明預設
name string:32 無預設值
start_bus_number uint8 無預設值
end_bus_number uint8 無預設值
segment_group uint16 無預設值

InterruptModes

定義於 fuchsia.hardware.pci/pci.fidl

由 |GetInterruptModes| 傳回。包含指定 PCI 裝置中斷模式支援的中斷次數。如果模式不受支援,則會傳回 0。

欄位類型說明預設
has_legacy bool

如果裝置支援舊版中斷,則為 |True|。

無預設值
msi_count uint8

支援的訊息信號中斷數量。範圍為 [0, 0x8),視裝置支援而定。

無預設值
msix_count uint16

支援的 MSI-X 中斷數量。範圍為 [0, 0x800),視裝置和平台支援而定。

無預設值

IoBar 資源

定義於 fuchsia.hardware.pci/pci.fidl

欄位類型說明預設
address uint64 無預設值
resource handle<resource> 無預設值

邊框間距

定義於 fuchsia.hardware.pci/pci.fidl

<EMPTY>

PciDevice

定義於 fuchsia.hardware.pci/debug.fidl

欄位類型說明預設
base_addresses vector<BaseAddress>:6 無預設值
capabilities vector<Capability>:32 無預設值
ext_capabilities vector<ExtendedCapability>:32 無預設值
config vector<uint8>:256 無預設值
bus_id uint8 無預設值
device_id uint8 無預設值
function_id uint8 無預設值

UseIntxWorkaroundType

定義於 fuchsia.hardware.pci/metadata.fidl

新增:HEAD

<EMPTY>

列舉

CapabilityId flexible

類型:uint8

定義於 fuchsia.hardware.pci/pci.fidl

PCI 功能 ID。PCI Local Bus Specification v3, appendex H.

名稱值說明
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

設定彈性

類型:uint16

定義於 fuchsia.hardware.pci/pci.fidl

PCI 設定標頭暫存器。PCI Local Bus Specification v3 第 6.1 章。

名稱值說明
0
2
4
6
8
9
10
11
12
13
14
15
16
40
44
46
48
52
60
61
62
63

ExtendedCapabilityId 彈性

類型:uint16

定義於 fuchsia.hardware.pci/pci.fidl

PCI 擴充功能 ID。PCIe Base Specification rev4 第 7.6 章。

名稱值說明
0
1
2
3
4
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
38
39
40
41
42
43
44

彈性標頭類型

類型:uint8

定義於 fuchsia.hardware.pci/pci.fidl

名稱值說明
0
1
2
127
128

InterruptMode strict

類型:uint8

定義於 fuchsia.hardware.pci/pci.fidl

與 ||SetInterruptMode| 搭配使用,為裝置設定中斷模式。如果裝置設為使用舊版 Irq 模式,則必須在服務後呼叫 |AckInterrupt|,確認中斷。

名稱值說明
0
1

舊版中斷模式。

2

MSI (訊息信號中斷) 模式。

3

MSI-X 模式。

TABLES

BoardConfiguration

定義於 fuchsia.hardware.pci/metadata.fidl

新增:HEAD

序數欄位類型說明
use_intx_workaround UseIntxWorkaroundType

如果設定,請針對未在裝置設定空間中正確實作 InterruptPin 和/或 InterruptStatus 位元的系統,使用舊版中斷解決方法。匯流排驅動程式會假設 INTA 並依賴中斷對應,並喚醒共用舊版中斷的任何裝置,即使其 InterruptStatus 位元未設定。

devicetree_bdfs vector<Address>

UNIONS

彈性 資源 BarResult

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
io IoBar
vmo handle<vmo>

Debug_ReadBar_Result strict

定義於 fuchsia.hardware.pci/debug.fidl

序數Variant類型說明
response Debug_ReadBar_Response
err zx/Status

Device_AckInterrupt_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_AckInterrupt_Response
err zx/Status

Device_GetBar_Result strict resource

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_GetBar_Response
err zx/Status

Device_GetBti_Result strict resource

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_GetBti_Response
err zx/Status

Device_MapInterrupt_Result strict resource

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_MapInterrupt_Response
err zx/Status

Device_ReadConfig16_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_ReadConfig16_Response
err zx/Status

Device_ReadConfig32_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_ReadConfig32_Response
err zx/Status

Device_ReadConfig8_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_ReadConfig8_Response
err zx/Status

Device_ResetDevice_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_ResetDevice_Response
err zx/Status

Device_SetBusMastering_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_SetBusMastering_Response
err zx/Status

Device_SetInterruptMode_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_SetInterruptMode_Response
err zx/Status

Device_WriteConfig16_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_WriteConfig16_Response
err zx/Status

Device_WriteConfig32_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_WriteConfig32_Response
err zx/Status

Device_WriteConfig8_Result strict

定義於 fuchsia.hardware.pci/pci.fidl

序數Variant類型說明
response Device_WriteConfig8_Response
err zx/Status

BITS

靈活運用

類型:uint16

定義於 fuchsia.hardware.pci/pci.fidl

名稱值說明
1
2
4
8
16
32
64
128
256
512

狀態:彈性

類型:uint16

定義於 fuchsia.hardware.pci/pci.fidl

名稱值說明
8
16
32
128
256
512
1024
2048
4096
8192
16384
32768

常數

名稱值類型說明
BASE_ADDRESS_COUNT 6 uint32
BASE_CONFIG_SIZE 256 uint32

根據 PCI 規格。

EXTENDED_CONFIG_SIZE 4096 uint32
LEGACY_INTERRUPT_COUNT 4 uint8

舊版中斷接腳 INTA 到 INTD。

MAX_BAR_COUNT 6 uint8
MAX_CAPABILITIES 32 uint32
MAX_DEVICES 64 uint32

撰寫本文時,Device 為 571 位元組。

MAX_EXT_CAPABILITIES 32 uint32
MAX_NAME_LEN 32 uint32
READBAR_MAX_SIZE 1024 uint32
STATUS_DEVSEL_MASK

別名

名稱值說明
ConfigOffset uint8

裝置 PCI 設定空間開頭的偏移量。[0, 0x100) 為有效值。

ExtendedConfigOffset uint16

裝置 PCIe 設定空間開頭的偏移量。[0, 0x800) 為有效。

服務

DebugService

定義於 fuchsia.hardware.pci/debug.fidl

名稱類型傳輸
debug fuchsia.hardware.pci/Debug 版本

服務

定義於 fuchsia.hardware.pci/pci.fidl

名稱類型傳輸
device fuchsia.hardware.pci/Device 版本