X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/f044ca812256b421e793c4335ce1ffed74710a70..35a7d633d3f16c1e0539af6ca5d8e7482926cd93:/lunaix-os/includes/lunaix/device_num.h diff --git a/lunaix-os/includes/lunaix/device_num.h b/lunaix-os/includes/lunaix/device_num.h index 58e9122..eef7989 100644 --- a/lunaix-os/includes/lunaix/device_num.h +++ b/lunaix-os/includes/lunaix/device_num.h @@ -1,6 +1,8 @@ #ifndef __LUNAIX_DEVICE_NUM_H #define __LUNAIX_DEVICE_NUM_H +#include + /* Device metadata field (device_def::meta) @@ -24,6 +26,8 @@ I2C: device connected through the IIC protocol + FMW: device is a system board firmware + The function defines the functionality that the device is designated to serve. Lunaix identify the following values: @@ -47,33 +51,62 @@ TTY: a device which can be called as teletypewriter, system can use such device for output into external environment + + CFG: device that provide configuration service to the system or other + devices + + */ -#define DEV_META(if_, function) (((if_)&0xffff) << 16) | ((function)&0xffff) -#define DEV_IF(meta) ((meta) >> 16) -#define DEV_FN(meta) (((meta)&0xffff)) - -#define DEVIF_NON 0x0 -#define DEVIF_SOC 0x1 -#define DEVIF_PCI 0x2 -#define DEVIF_USB 0x3 -#define DEVIF_SPI 0x4 -#define DEVIF_I2C 0x5 - -#define DEVFN_PSEUDO 0x0 -#define DEVFN_CHAR 0x1 -#define DEVFN_STORAGE 0x4 -#define DEVFN_INPUT 0x5 -#define DEVFN_TIME 0x6 -#define DEVFN_BUSIF 0x7 -#define DEVFN_TTY 0x8 - -#define DEV_BUILTIN 0x0 -#define DEV_X86LEGACY 0x1 -#define DEV_RNG 0x2 -#define DEV_RTC 0x3 -#define DEV_SATA 0x4 -#define DEV_NVME 0x5 -#define DEV_BUS 0x5 +#define DEV_FNGRP(vendor, function) \ + (((vendor) & 0xffff) << 16) | ((function) & 0xffff) +#define DEV_UNIQUE(devkind, variant) \ + (((devkind) & 0xffff) << 16) | ((variant) & 0xffff) +#define DEV_KIND_FROM(unique) ((unique) >> 16) +#define DEV_VAR_FROM(unique) ((unique) & 0xffff) + +#define DEV_VN(fngrp) ((fngrp) >> 16) +#define DEV_FN(fngrp) (((fngrp) & 0xffff)) + +#define dev_vn(x) DEVVN_##x +#define dev_fn(x) DEVFN_##x +#define dev_id(x) DEV_##x + +enum devnum_vn +{ + dev_vn(GENERIC), + #include +}; + +enum devnum_fn +{ + dev_fn(NON), + #include +}; + +enum devnum +{ + dev_id(NON), + #include +}; + +struct devident +{ + u32_t fn_grp; + u32_t unique; +}; + +struct devclass +{ + u32_t fn_grp; + u32_t device; + u32_t variant; +}; + +static inline int +devclass_mkvar(struct devclass* class) +{ + return class->variant++; +} #endif /* __LUNAIX_DEVICE_NUM_H */