summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCXSforHPU <[email protected]>2026-11-07 17:16:10 +0800
committerRbb666 <[email protected]>2026-11-18 09:11:48 +0800
commit629a7970ebb0902383db6cbc003e5bc248ff76d6 (patch)
tree222a4396ec34b3a15a0e158809f2ddbb469f791c /include
parent265116d74d753d5605546f798a9a8f54c571b22b (diff)
[components][dfs]Class-encode RT_DEVICE_CTRL_* commands to fix POSIX/dev command collisions: class in high byte, index low byte.
Diffstat (limited to 'include')
-rw-r--r--include/rtdef.h50
1 files changed, 34 insertions, 16 deletions
diff --git a/include/rtdef.h b/include/rtdef.h
index 5e243a9766..d2cda86508 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -63,6 +63,7 @@
* 2025-11-10 Rbb666 update version number to v5.3.0
* 2026-09-10 CYFS update version number to v5.3.1
* 2026-10-17 Rbb666 update version number to v5.4.0
+ * 2026-11-07 CXSforHPU class-encode RT_DEVICE_CTRL_* commands
*/
#ifndef __RT_DEF_H__
@@ -1316,26 +1317,43 @@ enum rt_device_class_type
#define RT_DEVICE_OFLAG_MASK 0xf0f /**< mask of open flag */
/**
- * general device commands
- * 0x01 - 0x1F general device control commands
- * 0x20 - 0x3F udevice control commands
- * 0x40 - special device control commands
+ * device control base command
*/
-#define RT_DEVICE_CTRL_RESUME 0x01 /**< resume device */
-#define RT_DEVICE_CTRL_SUSPEND 0x02 /**< suspend device */
-#define RT_DEVICE_CTRL_CONFIG 0x03 /**< configure device */
-#define RT_DEVICE_CTRL_CLOSE 0x04 /**< close device */
-#define RT_DEVICE_CTRL_NOTIFY_SET 0x05 /**< set notify func */
-#define RT_DEVICE_CTRL_SET_INT 0x06 /**< set interrupt */
-#define RT_DEVICE_CTRL_CLR_INT 0x07 /**< clear interrupt */
-#define RT_DEVICE_CTRL_GET_INT 0x08 /**< get interrupt status */
-#define RT_DEVICE_CTRL_CONSOLE_OFLAG 0x09 /**< get console open flag */
-#define RT_DEVICE_CTRL_MASK 0x1f /**< mask for contrl commands */
+#define RT_DEVICE_CTRL_BASE(Type) ((RT_Device_Class_##Type + 1) * 0x100)
+#define RT_DEVICE_CTRL_CLASS_MASK 0xff00 /* High byte: class */
+#define RT_DEVICE_CTRL_INDEX_MASK 0x00ff /* Low byte: index within class */
/**
- * device control
+ * device control commands
+ *
+ * Layout:
+ * \code{.c}
+ * RT_DEVICE_CTRL_BASE(Type) = (RT_Device_Class_##Type + 1) * 0x100
+ * \endcode
+ * high byte : class id (RT_DEVICE_CTRL_CLASS_MASK = 0xff00)
+ * low byte : index within class (RT_DEVICE_CTRL_INDEX_MASK = 0x00ff)
+ *
+ * The general-purpose commands below live in the Unknown class
+ * (Class_Unknown is the last entry in rt_device_class_t, so
+ * BASE(Unknown) = 0x2000), giving RESUME = 0x2001 .. CONSOLE_OFLAG = 0x2009.
+ * Class-specific commands should use BASE(Char), BASE(Block), ... instead
+ * of reusing these indices.
+ * 0x01 - 0x1F general device control commands
+ * 0x20 - 0x3F udevice control commands
+ * 0x40 - special device control commands
*/
-#define RT_DEVICE_CTRL_BASE(Type) ((RT_Device_Class_##Type + 1) * 0x100)
+typedef enum
+{
+ RT_DEVICE_CTRL_RESUME = RT_DEVICE_CTRL_BASE(Unknown) + 1, /**< resume device */
+ RT_DEVICE_CTRL_SUSPEND, /**< suspend device */
+ RT_DEVICE_CTRL_CONFIG, /**< configure device */
+ RT_DEVICE_CTRL_CLOSE, /**< close device */
+ RT_DEVICE_CTRL_NOTIFY_SET, /**< set notify func */
+ RT_DEVICE_CTRL_SET_INT, /**< set interrupt */
+ RT_DEVICE_CTRL_CLR_INT, /**< clear interrupt */
+ RT_DEVICE_CTRL_GET_INT, /**< get interrupt status */
+ RT_DEVICE_CTRL_CONSOLE_OFLAG, /**< get console open flag */
+} rt_device_cmd_t;
typedef struct rt_driver *rt_driver_t;
typedef struct rt_device *rt_device_t;