include/linux/fwctl.h
Source file repositories/reference/linux-study-clean/include/linux/fwctl.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/fwctl.h- Extension
.h- Size
- 4369 bytes
- Lines
- 136
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/cdev.hlinux/cleanup.huapi/fwctl/fwctl.h
Detected Declarations
struct fwctl_devicestruct fwctl_uctxstruct fwctl_opsstruct fwctl_devicestruct fwctl_uctxfunction fwctl_put
Annotated Snippet
struct fwctl_ops {
/**
* @device_type: The drivers assigned device_type number. This is uABI.
*/
enum fwctl_device_type device_type;
/**
* @uctx_size: The size of the fwctl_uctx struct to allocate. The first
* bytes of this memory will be a fwctl_uctx. The driver can use the
* remaining bytes as its private memory.
*/
size_t uctx_size;
/**
* @open_uctx: Called when a file descriptor is opened before the uctx
* is ever used.
*/
int (*open_uctx)(struct fwctl_uctx *uctx);
/**
* @close_uctx: Called when the uctx is destroyed, usually when the FD
* is closed.
*/
void (*close_uctx)(struct fwctl_uctx *uctx);
/**
* @info: Implement FWCTL_INFO. Return a kmalloc() memory that is copied
* to out_device_data. On input length indicates the size of the user
* buffer on output it indicates the size of the memory. The driver can
* ignore length on input, the core code will handle everything.
*/
void *(*info)(struct fwctl_uctx *uctx, size_t *length);
/**
* @fw_rpc: Implement FWCTL_RPC. Deliver rpc_in/in_len to the FW and
* return the response and set out_len. rpc_in can be returned as the
* response pointer. Otherwise the returned pointer is freed with
* kvfree().
*/
void *(*fw_rpc)(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
void *rpc_in, size_t in_len, size_t *out_len);
};
/**
* struct fwctl_device - Per-driver registration struct
* @dev: The sysfs (class/fwctl/fwctlXX) device
*
* Each driver instance will have one of these structs with the driver private
* data following immediately after. This struct is refcounted, it is freed by
* calling fwctl_put().
*/
struct fwctl_device {
struct device dev;
/* private: */
struct cdev cdev;
/* Protect uctx_list */
struct mutex uctx_list_lock;
struct list_head uctx_list;
/*
* Protect ops, held for write when ops becomes NULL during unregister,
* held for read whenever ops is loaded or an ops function is running.
*/
struct rw_semaphore registration_lock;
const struct fwctl_ops *ops;
};
struct fwctl_device *_fwctl_alloc_device(struct device *parent,
const struct fwctl_ops *ops,
size_t size);
/**
* fwctl_alloc_device - Allocate a fwctl
* @parent: Physical device that provides the FW interface
* @ops: Driver ops to register
* @drv_struct: 'struct driver_fwctl' that holds the struct fwctl_device
* @member: Name of the struct fwctl_device in @drv_struct
*
* This allocates and initializes the fwctl_device embedded in the drv_struct.
* Upon success the pointer must be freed via fwctl_put(). Returns a 'drv_struct
* \*' on success, NULL on error.
*/
#define fwctl_alloc_device(parent, ops, drv_struct, member) \
({ \
static_assert(__same_type(struct fwctl_device, \
((drv_struct *)NULL)->member)); \
static_assert(offsetof(drv_struct, member) == 0); \
(drv_struct *)_fwctl_alloc_device(parent, ops, \
sizeof(drv_struct)); \
})
static inline struct fwctl_device *fwctl_get(struct fwctl_device *fwctl)
{
get_device(&fwctl->dev);
return fwctl;
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/cdev.h`, `linux/cleanup.h`, `uapi/fwctl/fwctl.h`.
- Detected declarations: `struct fwctl_device`, `struct fwctl_uctx`, `struct fwctl_ops`, `struct fwctl_device`, `struct fwctl_uctx`, `function fwctl_put`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.