PCIe services: Difference between revisions

No edit summary
No edit summary
Line 12: Line 12:


== RegisterClassDriver ==
== RegisterClassDriver ==
Takes the current process handle (0xFFFF8001).
Takes an input Process handle and an input [[#ClassDriverConfig]]. Returns an output Event handle and an [[#ISession]].
 
Returns an event handle and session handle to a [[#ISession]].


== QueryFunctionsUnregistered ==
== QueryFunctionsUnregistered ==
Takes a type-6 buffer.
Takes a type-0x6 output buffer containing an array of [[#FunctionState]]. Returns an output s32 '''Count'''.
 
Returns a list of connected PCIe endpoint devices.


== ISession ==
== ISession ==
Line 28: Line 24:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || QueryFunctions
| 0 || [[#QueryFunctions]]
|-
|-
| 1 || AcquireFunction
| 1 || [[#AcquireFunction]]
|-
|-
| 2 || ReleaseFunction
| 2 || [[#ReleaseFunction]]
|-
|-
| 3 || GetFunctionState
| 3 || [[#GetFunctionState]]
|-
|-
| 4 || GetBarProfile
| 4 || [[#GetMappedBar]]
|-
|-
| 5 || ReadConfig
| 5 || [[#ReadConfig]]
|-
|-
| 6 || WriteConfig
| 6 || [[#WriteConfig]]
|-
|-
| 7 || ReadBarRegion
| 7 || [[#ReadBarRegion]]
|-
|-
| 8 || WriteBarRegion
| 8 || [[#WriteBarRegion]]
|-
|-
| 9 || FindCapability
| 9 || [[#FindCapability]]
|-
|-
| 10 || FindExtendedCapability
| 10 || [[#FindExtendedCapability]]
|-
|-
| 11 || MapDma
| 11 || [[#MapDma]]
|-
|-
| 12 || UnmapDma
| 12 || [[#UnmapDma]]
|-
|-
| 13 || UnmapDmaBusAddress
| 13 || [[#UnmapDmaBusAddress]]
|-
|-
| 14 || GetDmaBusAddress
| 14 || [[#GetDmaBusAddress]]
|-
|-
| 15 || GetDmaBusAddressRange
| 15 || [[#GetDmaBusAddressRange]]
|-
|-
| 16 || SetDmaEnable
| 16 || [[#SetDmaEnable]]
|-
|-
| 17 || AcquireIrq
| 17 || [[#AcquireIrq]]
|-
|-
| 18 || ReleaseIrq
| 18 || [[#ReleaseIrq]]
|-
|-
| 19 || SetIrqEnable
| 19 || [[#SetIrqEnable]]
|-
|-
| 20 || SetAspmEnable
| 20 || [[#SetAspmEnable]]
|-
|-
| 21 || [3.0.0+] SetResetUponResumeEnable
| 21 || [3.0.0+] [[#SetResetUponResumeEnable]]
|-
|-
| 22 || [4.0.0+] ResetFunction
| 22 || [4.0.0+] [[#ResetFunction]]
|-
|-
| 23 || [7.0.0+]
| 23 || [7.0.0+]
|}
|}


[5.0.0+] The buffer types for ReadBarRegion/WriteBarRegion were changed: 0x6 changed to 0x22, and 0x5 changed to 0x21.
=== QueryFunctions ===
Takes a type-0x6 output buffer containing an array of [[#FunctionState]]. Returns an output s32 '''Count'''.
 
=== AcquireFunction ===
Takes an input u32 '''FunctionHandle'''. Returns an output readable Event handle.
 
=== ReleaseFunction ===
Takes an input u32 '''FunctionHandle'''. No output.
 
=== GetFunctionState ===
Takes an input u32 '''FunctionHandle''' and a type-0x6 output buffer containing a [[#FunctionState]]. No output.
 
=== GetMappedBar ===
Takes two input u32s '''FunctionHandle''' and '''Bar'''. Returns an output u64 '''Address''' and an output [[#BarProfile]].
 
=== ReadConfig ===
Takes two input u32s '''FunctionHandle''', '''Offset''' and an input [[#BusAccessWidth]]. Returns an output u32 '''Config'''.


[7.0.0+] AcquireIrq now takes an additional 4-bytes of input, and no longer returns an output handle. SetAspmEnable now returns an output handle.
=== WriteConfig ===
Takes three input u32s '''FunctionHandle''', '''Offset''', '''Config''' and an input [[#BusAccessWidth]]. No output.
 
=== ReadBarRegion ===
Takes three input u32s '''FunctionHandle''', '''Bar''', '''Offset''', an input [[#BusAccessWidth]] and a type-0x6 output buffer. No output.
 
[5.0.0+] Now takes a type-0x22 output buffer instead.
 
=== WriteBarRegion ===
Takes three input u32s '''FunctionHandle''', '''Bar''', '''Offset''', an input [[#BusAccessWidth]] and a type-0x5 input buffer. No output.
 
[5.0.0+] Now takes a type-0x21 input buffer instead.
 
=== FindCapability ===
Takes an input u32s '''FunctionHandle''' and an input [[#CapabilityId]]. Returns an output u32 '''Capability'''.
 
=== FindExtendedCapability ===
Takes an input u32s '''FunctionHandle''' and an input [[#ExtendedCapabilityId]]. Returns an output u32 '''ExtendedCapability'''.
 
=== MapDma ===
Takes an input u32 '''FunctionHandle''', an input [[#DmaDirection]], an input u64 '''VirtualAddress''' and an input u32 '''Size'''. Returns an output u64 '''PhysicalAddress'''.
 
=== UnmapDma ===
Takes an input u32 '''FunctionHandle''' and an input u64 '''PhysicalAddress'''. No output.
 
=== UnmapDmaBusAddress ===
Takes an input u32 '''FunctionHandle''' and an input u64 '''BusAddress'''. No output.
 
=== GetDmaBusAddress ===
Takes an input u32 '''FunctionHandle''', an input u64 '''VirtualAddress''' and an input u32 '''Size'''. Returns an output u64 '''BusAddress'''.
 
=== GetDmaBusAddressRange ===
Takes an input u32 '''FunctionHandle'''. Returns two output u64s '''BusAddressRangeStart''' and '''BusAddressRangeEnd'''.
 
=== SetDmaEnable ===
Takes an input u32 '''FunctionHandle''' and an input bool '''Enable'''. No output.
 
=== AcquireIrq ===
Takes an input u32s '''FunctionHandle''' and an input [[#IrqType]]. Returns an output Event handle.
 
[7.0.0+] Now takes another input u32 and no longer returns an output Event handle.
 
=== ReleaseIrq ===
Takes an input u32 '''FunctionHandle'''. No output.
 
=== SetIrqEnable ===
Takes an input u32s '''FunctionHandle''', an unknown input u32 and an input bool '''Enable'''. No output.
 
=== SetAspmEnable ===
Takes an input u32 '''FunctionHandle''' and an input bool '''Enable'''. No output.
 
[7.0.0+] Now returns an output Event handle.
 
=== SetResetUponResumeEnable ===
Takes an input u32 '''FunctionHandle''' and an input bool '''Enable'''. No output.
 
=== ResetFunction ===
Takes an input u32 '''FunctionHandle''' and an unknown input u32. No output.


= pcie:log =
= pcie:log =
Line 92: Line 161:
| 1 ||  
| 1 ||  
|}
|}
= ClassDriverConfig =
This is "nn::pcie::ClassDriverConfig".
This is a 0x18-byte struct.
= FunctionState =
This is "nn::pcie::FunctionState".
This is a 0x28-byte struct.
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x00
| 0x04
| Handle
|-
| 0x04
| 0x24
|
|}
= BarProfile =
This is "nn::pcie::BarProfile".
This is a 0xC-byte struct.
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x00
| 0x08
| Size
|-
| 0x08
| 0x04
| Flags
|}
= BusAccessWidth =
This is "nn::pcie::BusAccessWidth".
{| class="wikitable" border="1"
|-
! Value
! Description
|-
| 0 || 8bits
|-
| 1 || 16bits
|-
| 2 || 32bits
|}
= CapabilityId =
This is "nn::pcie::CapabilityId".
= ExtendedCapabilityId =
This is "nn::pcie::ExtendedCapabilityId".
= DmaDirection =
This is "nn::pcie::DmaDirection".
= IrqType =
This is "nn::pcie::IrqType".


[[Category:Services]]
[[Category:Services]]