summaryrefslogtreecommitdiff
path: root/usr/src/cmd/acpi/common/osl.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/acpi/common/osl.c')
-rw-r--r--usr/src/cmd/acpi/common/osl.c65
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));
}