You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm implementing the LowLevelHardwareInterfaces interface and noticed that many of the functions don't seem to be strictly necessary. The most blatant example are PCIReadConfig* and PCIWriteConfig* as well as PCIReadVendorID and PCIReadDeviceID. If the interface would defined PCIReadConfig(address uint64) ([]byte, error) and PCIWriteConfig(address uint64, buf []byte) error all other functions could be implemented as free functions using the interface e.g.
Same applies IMO to ReadMSR vs. ReadMSRAllCores, all CPUID and SMBIOS functions, ReadPhys vs. ReadPhysBuf and both ACPI retrieval functions. In the latter case I don't see how the means of getting them matters to the consumer of the interface.
The second issue I have with the interface is performance. Especially the ReadPhysBuf function forces the implementation to copy the requested data into a user provided buffer. In my case the data is read ahead of time and it would improve memory and CPU consumption a lot if the function could just return a byte slice.
Hi,
I'm implementing the
LowLevelHardwareInterfaces
interface and noticed that many of the functions don't seem to be strictly necessary. The most blatant example are PCIReadConfig* and PCIWriteConfig* as well asPCIReadVendorID
andPCIReadDeviceID
. If the interface would definedPCIReadConfig(address uint64) ([]byte, error)
andPCIWriteConfig(address uint64, buf []byte) error
all other functions could be implemented as free functions using the interface e.g.Same applies IMO to
ReadMSR
vs.ReadMSRAllCores
, all CPUID and SMBIOS functions,ReadPhys
vs.ReadPhysBuf
and both ACPI retrieval functions. In the latter case I don't see how the means of getting them matters to the consumer of the interface.The second issue I have with the interface is performance. Especially the
ReadPhysBuf
function forces the implementation to copy the requested data into a user provided buffer. In my case the data is read ahead of time and it would improve memory and CPU consumption a lot if the function could just return a byte slice.I think the following interface would suffice:
What do you guys think? I'm willing to implement most of that as well as fix the CSS code depending on it.
The text was updated successfully, but these errors were encountered: