diff options
author | Mike Gerdts <mike.gerdts@joyent.com> | 2018-01-18 15:37:09 +0000 |
---|---|---|
committer | Mike Gerdts <mike.gerdts@joyent.com> | 2018-02-13 16:56:03 +0000 |
commit | ed0e03ac24c4a80fc1dca6c059801da8356cd81a (patch) | |
tree | 9b520f8bd6948b706dd7363726f44942659fa74c /usr/src/cmd/acpi/common/osl.c | |
parent | 59e5084aaf2a76c156e349393b383154de8f2e16 (diff) | |
download | illumos-joyent-ed0e03ac24c4a80fc1dca6c059801da8356cd81a.tar.gz |
OS-6465 add iasl
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approvced by: Jerry Jelinek <jerry.jelinek@joyent.com>
Diffstat (limited to 'usr/src/cmd/acpi/common/osl.c')
-rw-r--r-- | usr/src/cmd/acpi/common/osl.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/usr/src/cmd/acpi/common/osl.c b/usr/src/cmd/acpi/common/osl.c index 599592b6de..f7e00ad757 100644 --- a/usr/src/cmd/acpi/common/osl.c +++ b/usr/src/cmd/acpi/common/osl.c @@ -10,55 +10,60 @@ */ /* - * Copyright 2016 Joyent, Inc. + * Copyright (c) 2018, Joyent, Inc. */ -#include <stdio.h> +#include <fcntl.h> #include <stdarg.h> +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> + #include "acpi.h" #include "accommon.h" -ACPI_STATUS -AcpiOsInitialize(void) +UINT32 +CmGetFileSize(ACPI_FILE File) { - return (AE_OK); -} + int fd; + struct stat sb; -/* - * The locking functions are no-ops because the application tools that use - * these are all single threaded. However, due to the common code base that we - * pull in from Intel, these functions are also called when the software is - * compiled into the kernel, where it does need to do locking. - */ -ACPI_CPU_FLAGS -AcpiOsAcquireLock(ACPI_HANDLE Handle) -{ - return (AE_OK); + fd = fileno(File); + if (fstat(fd, &sb) != 0) + return (ACPI_UINT32_MAX); + return ((UINT32)sb.st_size); } -void -AcpiOsReleaseLock(ACPI_HANDLE Handle, ACPI_CPU_FLAGS Flags) +int +AcpiOsWriteFile(ACPI_FILE File, void *Buffer, ACPI_SIZE Size, ACPI_SIZE Count) { + return (fwrite(Buffer, Size, Count, File)); } -void -AcpiOsVprintf(const char *Format, va_list Args) +ACPI_FILE +AcpiOsOpenFile(const char *Path, UINT8 Modes) { - vprintf(Format, Args); + char mode[3]; + + bzero(mode, sizeof (mode)); + if ((Modes & ACPI_FILE_READING) != 0) + (void) strlcat(mode, "r", sizeof (mode)); + + if ((Modes & ACPI_FILE_WRITING) != 0) + (void) strlcat(mode, "w", sizeof (mode)); + + return (fopen(Path, mode)); } -void ACPI_INTERNAL_VAR_XFACE -AcpiOsPrintf(const char *Format, ...) +void +AcpiOsCloseFile(ACPI_FILE File) { - va_list ap; - - va_start(ap, Format); - AcpiOsVprintf(Format, ap); - va_end(ap); + fclose(File); } int -AcpiOsWriteFile(ACPI_FILE File, void *Buffer, ACPI_SIZE Size, ACPI_SIZE Count) +AcpiOsReadFile(ACPI_FILE File, void *Buffer, ACPI_SIZE Size, ACPI_SIZE Count) { - return (fwrite(Buffer, Size, Count, File)); + return (fread(Buffer, Size, Count, File)); } |