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)
Sep 17 2024, 11:17 AM
Unknown Object (File)
Sep 16 2024, 9:46 AM
Unknown Object (File)
Sep 12 2024, 9:40 PM
Unknown Object (File)
Sep 11 2024, 4:40 PM
Unknown Object (File)
Sep 11 2024, 4:40 PM
Unknown Object (File)
Sep 11 2024, 4:40 PM
Unknown Object (File)
Sep 4 2024, 5:40 AM
Unknown Object (File)
Sep 3 2024, 4:08 AM
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 50845
Build 47736: arc lint + arc unit

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.