include/linux/mfd/macsmc.h

Source file repositories/reference/linux-study-clean/include/linux/mfd/macsmc.h

File Facts

System
Linux kernel
Corpus path
include/linux/mfd/macsmc.h
Extension
.h
Size
9190 bytes
Lines
281
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct apple_smc_key_info {
	u32 type_code;
	u8 size;
	u8 flags;
};

/**
 * enum apple_smc_boot_stage - SMC boot stage
 * @APPLE_SMC_BOOTING: SMC is booting
 * @APPLE_SMC_INITIALIZED: SMC is initialized and ready to use
 * @APPLE_SMC_ERROR_NO_SHMEM: Shared memory could not be initialized during boot
 * @APPLE_SMC_ERROR_CRASHED: SMC has crashed
 */
enum apple_smc_boot_stage {
	APPLE_SMC_BOOTING,
	APPLE_SMC_INITIALIZED,
	APPLE_SMC_ERROR_NO_SHMEM,
	APPLE_SMC_ERROR_CRASHED
};

/**
 * struct apple_smc
 * @dev: Underlying device struct for the physical backend device
 * @key_count: Number of available SMC keys
 * @first_key: First valid SMC key
 * @last_key: Last valid SMC key
 * @event_handlers: Notifier call chain for events received from SMC
 * @rtk: Pointer to Apple RTKit instance
 * @init_done: Completion for initialization
 * @boot_stage: Current boot stage of SMC
 * @sram: Pointer to SRAM resource
 * @sram_base: SRAM base address
 * @shmem: RTKit shared memory structure for SRAM
 * @msg_id: Current message id for commands, will be incremented for each command
 * @atomic_mode: Flag set when atomic mode is entered
 * @atomic_pending: Flag indicating pending atomic command
 * @cmd_done: Completion for command execution in non-atomic mode
 * @cmd_ret: Return value from SMC for last command
 * @mutex: Mutex for non-atomic mode
 * @lock: Spinlock for atomic mode
 */
struct apple_smc {
	struct device *dev;

	u32 key_count;
	smc_key first_key;
	smc_key last_key;

	struct blocking_notifier_head event_handlers;

	struct apple_rtkit *rtk;

	struct completion init_done;
	enum apple_smc_boot_stage boot_stage;

	struct resource *sram;
	void __iomem *sram_base;
	struct apple_rtkit_shmem shmem;

	unsigned int msg_id;

	bool atomic_mode;
	bool atomic_pending;
	struct completion cmd_done;
	u64 cmd_ret;

	struct mutex mutex;
	spinlock_t lock;
};

/**
 * apple_smc_read - Read size bytes from given SMC key into buf
 * @smc: Pointer to apple_smc struct
 * @key: smc_key to be read
 * @buf: Buffer into which size bytes of data will be read from SMC
 * @size: Number of bytes to be read into buf
 *
 * Return: Zero on success, negative errno on error
 */
int apple_smc_read(struct apple_smc *smc, smc_key key, void *buf, size_t size);

/**
 * apple_smc_write - Write size bytes into given SMC key from buf
 * @smc: Pointer to apple_smc struct
 * @key: smc_key data will be written to
 * @buf: Buffer from which size bytes of data will be written to SMC
 * @size: Number of bytes to be written
 *
 * Return: Zero on success, negative errno on error
 */

Annotation

Implementation Notes