diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 9fbcf9d..c6a18b7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -52,7 +52,7 @@ void pci_config_write32(struct pci_host *host, u8 bus, u8 dev, u8 func, u16 reg, *addr = val; } -size_t pci_find_device(u16 minor, u16 major, list_t *out) +size_t pci_find_device(u16 major, u16 minor, list_t *out) { size_t n = 0; diff --git a/include/drivers/pci.h b/include/drivers/pci.h index 86c287e..951578f 100644 --- a/include/drivers/pci.h +++ b/include/drivers/pci.h @@ -36,6 +36,6 @@ struct pci_device { void pci_register_host(struct pci_host *host); u32 pci_config_read(struct pci_host *host, u32 bus, u32 slot, u32 func, u32 offset); void pci_config_write(struct pci_host *host, u32 bus, u32 slot, u32 func, u32 offset, u32 val); -size_t pci_find_device(u16 minor, u16 major, list_t *out); +size_t pci_find_device(u16 major, u16 minor, list_t *out); #endif /* _PCI_H_ */ diff --git a/include/lib/endian.h b/include/lib/endian.h new file mode 100644 index 0000000..2f28fc1 --- /dev/null +++ b/include/lib/endian.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ENDIAN_H_ +#define _ENDIAN_H_ + +#include + +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define htobe16(x) ((uint16_t)(x)) +#define htobe32(x) ((uint32_t)(x)) +#define htobe64(x) ((uint64_t)(x)) + +#define htole16(x) __builtin_bswap16(x) +#define htole32(x) __builtin_bswap32(x) +#define htole64(x) __builtin_bswap64(x) +#else +#define htobe16(x) __builtin_bswap16(x) +#define htobe32(x) __builtin_bswap32(x) +#define htobe64(x) __builtin_bswap64(x) + +#define htole16(x) ((u16)(x)) +#define htole32(x) ((u32)(x)) +#define htole64(x) ((u64)(x)) +#endif +#define betoh16(x) htobe16(x) +#define betoh32(x) htobe32(x) +#define betoh64(x) htobe64(x) + +#define letoh16(x) htole16(x) +#define letoh32(x) htole32(x) +#define letoh64(x) htole64(x) + +#endif /* _ENDIAN_H_ */