tools/power/acpi/tools/acpidbg/acpidbg.c
Source file repositories/reference/linux-study-clean/tools/power/acpi/tools/acpidbg/acpidbg.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/acpi/tools/acpidbg/acpidbg.c- Extension
.c- Size
- 10728 bytes
- Lines
- 442
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
acpi/acpi.hunistd.hstdio.hstdlib.hstring.herror.hstdbool.hfcntl.hassert.hsys/select.h../../../../../include/linux/circ_buf.h
Detected Declarations
function acpi_aml_set_flfunction acpi_aml_set_fdfunction acpi_aml_readfunction acpi_aml_read_batch_cmdfunction acpi_aml_read_batch_logfunction acpi_aml_writefunction acpi_aml_write_batch_logfunction acpi_aml_write_batch_cmdfunction acpi_aml_loopfunction acpi_aml_readablefunction flushfunction usagefunction main
Annotated Snippet
if (_ret == 0) { \
fprintf(stderr, \
"%s %s pipe closed.\n", #_buf, #_op); \
return; \
} \
} while (0)
#define ACPI_AML_BATCH_DO(_fd, _op, _buf, _ret) \
do { \
_ret = acpi_aml_##_op##_batch_##_buf(_fd, \
&acpi_aml_##_buf##_crc); \
if (_ret == 0) \
return; \
} while (0)
static char acpi_aml_cmd_buf[ACPI_AML_BUF_SIZE];
static char acpi_aml_log_buf[ACPI_AML_BUF_SIZE];
static struct circ_buf acpi_aml_cmd_crc = {
.buf = acpi_aml_cmd_buf,
.head = 0,
.tail = 0,
};
static struct circ_buf acpi_aml_log_crc = {
.buf = acpi_aml_log_buf,
.head = 0,
.tail = 0,
};
static const char *acpi_aml_file_path = ACPI_AML_FILE;
static unsigned long acpi_aml_mode = ACPI_AML_INTERACTIVE;
static bool acpi_aml_exit;
static bool acpi_aml_batch_drain;
static unsigned long acpi_aml_batch_state;
static char acpi_aml_batch_prompt;
static char acpi_aml_batch_roll;
static unsigned long acpi_aml_log_state;
static char *acpi_aml_batch_cmd = NULL;
static char *acpi_aml_batch_pos = NULL;
static int acpi_aml_set_fl(int fd, int flags)
{
int ret;
ret = fcntl(fd, F_GETFL, 0);
if (ret < 0) {
perror("fcntl(F_GETFL)");
return ret;
}
flags |= ret;
ret = fcntl(fd, F_SETFL, flags);
if (ret < 0) {
perror("fcntl(F_SETFL)");
return ret;
}
return ret;
}
static int acpi_aml_set_fd(int fd, int maxfd, fd_set *set)
{
if (fd > maxfd)
maxfd = fd;
FD_SET(fd, set);
return maxfd;
}
static int acpi_aml_read(int fd, struct circ_buf *crc)
{
char *p;
int len;
p = &crc->buf[crc->head];
len = circ_space_to_end(crc);
len = read(fd, p, len);
if (len < 0)
perror("read");
else if (len > 0)
crc->head = (crc->head + len) & (ACPI_AML_BUF_SIZE - 1);
return len;
}
static int acpi_aml_read_batch_cmd(int unused, struct circ_buf *crc)
{
char *p;
int len;
int remained = strlen(acpi_aml_batch_pos);
p = &crc->buf[crc->head];
len = circ_space_to_end(crc);
if (len > remained) {
memcpy(p, acpi_aml_batch_pos, remained);
Annotation
- Immediate include surface: `acpi/acpi.h`, `unistd.h`, `stdio.h`, `stdlib.h`, `string.h`, `error.h`, `stdbool.h`, `fcntl.h`.
- Detected declarations: `function acpi_aml_set_fl`, `function acpi_aml_set_fd`, `function acpi_aml_read`, `function acpi_aml_read_batch_cmd`, `function acpi_aml_read_batch_log`, `function acpi_aml_write`, `function acpi_aml_write_batch_log`, `function acpi_aml_write_batch_cmd`, `function acpi_aml_loop`, `function acpi_aml_readable`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.