drivers/android/binder/defs.rs

Source file repositories/reference/linux-study-clean/drivers/android/binder/defs.rs

File Facts

System
Linux kernel
Corpus path
drivers/android/binder/defs.rs
Extension
.rs
Size
5498 bytes
Lines
183
Domain
Driver Families
Bucket
drivers/android
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0

// Copyright (C) 2025 Google LLC.

use core::mem::MaybeUninit;
use core::ops::{Deref, DerefMut};
use kernel::{
    transmute::{AsBytes, FromBytes},
    uapi::{self, *},
};

macro_rules! pub_no_prefix {
    ($prefix:ident, $($newname:ident),+ $(,)?) => {
        $(pub(crate) const $newname: u32 = kernel::macros::concat_idents!($prefix, $newname);)+
    };
}

pub_no_prefix!(
    binder_driver_return_protocol_,
    BR_TRANSACTION,
    BR_TRANSACTION_SEC_CTX,
    BR_REPLY,
    BR_DEAD_REPLY,
    BR_FAILED_REPLY,
    BR_FROZEN_REPLY,
    BR_NOOP,
    BR_SPAWN_LOOPER,
    BR_TRANSACTION_COMPLETE,
    BR_TRANSACTION_PENDING_FROZEN,
    BR_ONEWAY_SPAM_SUSPECT,
    BR_OK,
    BR_ERROR,
    BR_INCREFS,
    BR_ACQUIRE,
    BR_RELEASE,
    BR_DECREFS,
    BR_DEAD_BINDER,
    BR_CLEAR_DEATH_NOTIFICATION_DONE,
    BR_FROZEN_BINDER,
    BR_CLEAR_FREEZE_NOTIFICATION_DONE,
);

pub_no_prefix!(
    binder_driver_command_protocol_,
    BC_TRANSACTION,
    BC_TRANSACTION_SG,
    BC_REPLY,
    BC_REPLY_SG,
    BC_FREE_BUFFER,
    BC_ENTER_LOOPER,
    BC_EXIT_LOOPER,
    BC_REGISTER_LOOPER,
    BC_INCREFS,
    BC_ACQUIRE,
    BC_RELEASE,
    BC_DECREFS,
    BC_INCREFS_DONE,
    BC_ACQUIRE_DONE,
    BC_REQUEST_DEATH_NOTIFICATION,
    BC_CLEAR_DEATH_NOTIFICATION,
    BC_DEAD_BINDER_DONE,
    BC_REQUEST_FREEZE_NOTIFICATION,
    BC_CLEAR_FREEZE_NOTIFICATION,
    BC_FREEZE_NOTIFICATION_DONE,
);

pub_no_prefix!(
    flat_binder_object_flags_,
    FLAT_BINDER_FLAG_ACCEPTS_FDS,
    FLAT_BINDER_FLAG_TXN_SECURITY_CTX
);

pub_no_prefix!(
    transaction_flags_,
    TF_ONE_WAY,
    TF_ACCEPT_FDS,
    TF_CLEAR_BUF,
    TF_UPDATE_TXN
);

pub(crate) use uapi::{
    BINDER_TYPE_BINDER, BINDER_TYPE_FD, BINDER_TYPE_FDA, BINDER_TYPE_HANDLE, BINDER_TYPE_PTR,
    BINDER_TYPE_WEAK_BINDER, BINDER_TYPE_WEAK_HANDLE,
};

macro_rules! decl_wrapper {
    ($newname:ident, $wrapped:ty) => {
        // Define a wrapper around the C type. Use `MaybeUninit` to enforce that the value of
        // padding bytes must be preserved.
        #[derive(Copy, Clone)]

Annotation

Implementation Notes