Page MenuHomeFreeBSD

bhyve: save softc of ACPI devices
ClosedPublic

Authored by corvink on Mar 29 2023, 1:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 25, 6:36 AM
Unknown Object (File)
Wed, Dec 25, 6:33 AM
Unknown Object (File)
Wed, Dec 25, 6:13 AM
Unknown Object (File)
Wed, Dec 25, 6:04 AM
Unknown Object (File)
Nov 21 2024, 6:39 AM
Unknown Object (File)
Nov 6 2024, 6:44 PM
Unknown Object (File)
Nov 6 2024, 6:34 PM
Unknown Object (File)
Nov 6 2024, 6:30 PM
Subscribers

Details

Summary

This will be useful for writing device specific ACPI tables or DSDT
methods.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 50652
Build 47543: arc lint + arc unit

Event Timeline

usr.sbin/bhyve/acpi_device.c
44

The comment above needs to be updated.

151

This can be an assertion.

  • update commnent as suggested
  • make use of assert
  • pass fwcfg_sc as parent to acpi_device_create
usr.sbin/bhyve/acpi_device.h
31

But it's not (necessarily) an ACPI device. The type is void * and the one caller passes a device softc.

Is "parent" really the right name? Should it just be an opaque "context" field?

usr.sbin/bhyve/acpi_device.h
31

Renaming this parameter is fine but I don't know which word fits best.

In C++ this would be solved by inheritance. E.g.:

class tpm_device: acpi_device
{ ... };

The tpm_device inherits from acpi_device. So, in C++ the tpm_device is an acpi_device.

My C code uses:

struct tpm_device {
  struct acpi_device *dev,
  ...
};

struct tpm_device tpm_softc;

int
tpm_init() {
  acpi_device_create(&tpm_softc.dev, &tpm_softc, ...);
  ...
}

int
tpm_do_some_stuff(struct acpi_device *dev) {
  sc = acpi_device_get_parent(dev);
  ...
}
usr.sbin/bhyve/acpi_device.h
31

I'd call it softc (software context) or dev_ctx then.

corvink retitled this revision from bhyve: save parent device to bhyve: save softc of ACPI devices.Apr 12 2023, 6:25 AM
corvink edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Apr 12 2023, 2:22 PM
This revision was automatically updated to reflect the committed changes.