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, May 15, 5:35 PM
Unknown Object (File)
Wed, May 15, 5:35 PM
Unknown Object (File)
Wed, May 15, 5:35 PM
Unknown Object (File)
Wed, May 15, 5:35 PM
Unknown Object (File)
Wed, May 15, 5:35 PM
Unknown Object (File)
Wed, May 15, 5:35 PM
Unknown Object (File)
Mon, May 13, 2:53 AM
Unknown Object (File)
May 2 2024, 4:57 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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

usr.sbin/bhyve/acpi_device.c
46

The comment above needs to be updated.

147

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
41

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
41

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
41

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.