device: move is_domain0 and is_dev_on_domain0 to common code

Move is_domain0 and is_dev_on_domain0 from the Intel Xeon SP code to the
common coreboot code so that it can be used elsewhere in coreboot too,
and while moving also implement it as functions instead of macros which
is more in line with the rest of helper functions in that new file.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I954251ebc82802c77bf897dfa2db54aa10bc5ac4
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83642
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Shuo Liu <shuo.liu@intel.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Felix Held 2024-07-24 23:51:05 +02:00
parent b133b7ae23
commit a17d22e51a
3 changed files with 12 additions and 3 deletions

View File

@ -261,6 +261,16 @@ const struct device *dev_get_domain(const struct device *dev)
return NULL;
}
bool is_domain0(const struct device *dev)
{
return dev && dev->path.type == DEVICE_PATH_DOMAIN && dev->path.domain.domain == 0;
}
bool is_dev_on_domain0(const struct device *dev)
{
return is_domain0(dev_get_domain(dev));
}
/**
* Allocate 64 more resources to the free list.
*

View File

@ -194,6 +194,8 @@ bool is_pci(const struct device *pci);
bool is_enabled_pci(const struct device *pci);
bool is_pci_dev_on_bus(const struct device *pci, unsigned int bus);
bool is_pci_bridge(const struct device *pci);
bool is_domain0(const struct device *dev);
bool is_dev_on_domain0(const struct device *dev);
/* Returns whether there is a hotplug port on the path to the given device. */
bool dev_path_hotplug(const struct device *);

View File

@ -83,9 +83,6 @@ bool is_cxl_domain(const struct device *dev);
#define is_dev_on_ubox_domain(dev) is_ubox_domain(dev_get_domain(dev))
#define is_dev_on_cxl_domain(dev) is_cxl_domain(dev_get_domain(dev))
#define is_domain0(dev) (dev && dev->path.type == DEVICE_PATH_DOMAIN &&\
dev->path.domain.domain == 0)
#define is_dev_on_domain0(dev) (is_domain0(dev_get_domain(dev)))
#define is_stack0(socket, stack) (socket == 0 && stack == IioStack0)
void unlock_pam_regions(void);