aboutsummaryrefslogtreecommitdiff
path: root/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'acpi')
-rw-r--r--acpi/Makefile13
-rw-r--r--acpi/acpi-ops.c86
-rw-r--r--acpi/acpi.c2
-rw-r--r--acpi/acpifs.h2
-rw-r--r--acpi/func_files.h2
-rw-r--r--acpi/main.c12
-rw-r--r--acpi/mig-mutate.h28
-rw-r--r--acpi/myacpi.h (renamed from acpi/acpi.h)8
8 files changed, 141 insertions, 12 deletions
diff --git a/acpi/Makefile b/acpi/Makefile
index f84f4b35..76f27aef 100644
--- a/acpi/Makefile
+++ b/acpi/Makefile
@@ -21,15 +21,22 @@ makemode = server
PORTDIR = $(srcdir)/port
SRCS = main.c netfs_impl.c acpi.c \
- acpifs.c ncache.c options.c func_files.c
+ acpifs.c ncache.c options.c func_files.c acpi-ops.c \
+ acpiServer.c
+
MIGSRCS =
OBJS = $(patsubst %.S,%.o,$(patsubst %.c,%.o, $(SRCS) $(MIGSRCS)))
HURDLIBS= fshelp ports shouldbeinlibc netfs iohelp ihash
-LDLIBS = -lpthread
+LDLIBS = -lpthread $(libacpica_LIBS)
target = acpi
include ../Makeconf
-CFLAGS += -I$(PORTDIR)/include
+CFLAGS += -I$(PORTDIR)/include $(libacpica_CFLAGS)
+
+acpi-MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
+
+# cpp doesn't automatically make dependencies for -imacros dependencies. argh.
+acpi_S.h acpiServer.c: mig-mutate.h
diff --git a/acpi/acpi-ops.c b/acpi/acpi-ops.c
new file mode 100644
index 00000000..3bc90de7
--- /dev/null
+++ b/acpi/acpi-ops.c
@@ -0,0 +1,86 @@
+/*
+ Copyright (C) 2021 Free Software Foundation, Inc.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* Implementation of ACPI operations */
+
+#include <acpi_S.h>
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/io.h>
+#include <idvec.h>
+
+#include <acpi/acpi_init.h>
+#include "acpifs.h"
+
+static error_t
+check_permissions (struct protid *master, int flags)
+{
+ struct node *node;
+ struct acpifs_dirent *e;
+
+ node = master->po->np;
+ e = node->nn->ln;
+
+ /* Check whether the user has permissions to access this node */
+ return entry_check_perms (master->user, e, flags);
+}
+
+error_t
+S_acpi_sleep (struct protid *master,
+ int sleep_state)
+{
+ error_t err;
+
+ if (!master)
+ return EOPNOTSUPP;
+
+ if (!master->user)
+ return EOPNOTSUPP;
+
+ if (!idvec_contains (master->user->uids, 0))
+ return EOPNOTSUPP;
+
+ /* Perform sleep */
+ acpi_enter_sleep(sleep_state);
+
+ /* Never reached */
+ return err;
+}
+
+error_t
+S_acpi_get_pci_irq (struct protid *master,
+ int bus,
+ int dev,
+ int func,
+ int *irq)
+{
+ error_t err;
+
+ if (!master)
+ return EOPNOTSUPP;
+
+ err = check_permissions (master, O_READ);
+ if (err)
+ return err;
+
+ *irq = acpi_get_irq_number(bus, dev, func);
+ return err;
+}
diff --git a/acpi/acpi.c b/acpi/acpi.c
index 210a229e..9827232a 100644
--- a/acpi/acpi.c
+++ b/acpi/acpi.c
@@ -28,7 +28,7 @@
#include <string.h>
#include <unistd.h>
-#include "acpi.h"
+#include "myacpi.h"
int
mmap_phys_acpi_header(uintptr_t base_addr, struct acpi_header **ptr_to_header,
diff --git a/acpi/acpifs.h b/acpi/acpifs.h
index 8e359efb..4597e1b0 100644
--- a/acpi/acpifs.h
+++ b/acpi/acpifs.h
@@ -27,7 +27,7 @@
#include <maptime.h>
#include <netfs_impl.h>
-#include <acpi.h>
+#include "myacpi.h"
/* Size of a directory entry name */
#ifndef NAME_SIZE
diff --git a/acpi/func_files.h b/acpi/func_files.h
index 90d92cc3..adc81cf7 100644
--- a/acpi/func_files.h
+++ b/acpi/func_files.h
@@ -23,7 +23,7 @@
#define FUNC_FILES_H
#include <acpifs.h>
-#include <acpi.h>
+#include "myacpi.h"
typedef int (*acpi_read_op_t) (struct acpi_table *t, void *data,
off_t offset, size_t *len);
diff --git a/acpi/main.c b/acpi/main.c
index ac325915..fc46f4f2 100644
--- a/acpi/main.c
+++ b/acpi/main.c
@@ -26,12 +26,14 @@
#include <argp.h>
#include <hurd/netfs.h>
+#include "acpi_S.h"
#include "libnetfs/io_S.h"
#include "libnetfs/fs_S.h"
#include "libports/notify_S.h"
#include "libnetfs/fsys_S.h"
#include "libports/interrupt_S.h"
#include "libnetfs/ifsock_S.h"
+#include <acpi/acpi_init.h>
#include <acpifs.h>
/* Libnetfs stuff */
@@ -53,7 +55,8 @@ netfs_demuxer (mach_msg_header_t * inp, mach_msg_header_t * outp)
(routine = ports_notify_server_routine (inp)) ||
(routine = netfs_fsys_server_routine (inp)) ||
(routine = ports_interrupt_server_routine (inp)) ||
- (routine = netfs_ifsock_server_routine (inp)))
+ (routine = netfs_ifsock_server_routine (inp)) ||
+ (routine = acpi_server_routine (inp)))
{
(*routine) (inp, outp);
return TRUE;
@@ -76,11 +79,16 @@ main (int argc, char **argv)
if (bootstrap == MACH_PORT_NULL)
error (1, 0, "must be started as a translator");
+ /* Initialize ACPI */
+ acpi_init();
+
/* Initialize netfs and start the translator. */
netfs_init ();
err = maptime_map (0, 0, &acpifs_maptime);
if (err)
+ err = maptime_map (1, 0, &acpifs_maptime);
+ if (err)
error (1, err, "mapping time");
/* Create the ACPI filesystem */
@@ -98,7 +106,7 @@ main (int argc, char **argv)
if (err)
error (1, err, "setting permissions");
- netfs_server_loop (); /* Never returns. */
+ netfs_server_loop (); /* Never returns. */
return 0;
}
diff --git a/acpi/mig-mutate.h b/acpi/mig-mutate.h
new file mode 100644
index 00000000..1ee33e5f
--- /dev/null
+++ b/acpi/mig-mutate.h
@@ -0,0 +1,28 @@
+/*
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/BSG.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* Only CPP macro definitions should go in this file. */
+
+#define ACPI_IMPORTS \
+ import "../libnetfs/priv.h"; \
+
+#define ACPI_INTRAN protid_t begin_using_protid_port (acpi_t)
+#define ACPI_INTRAN_PAYLOAD protid_t begin_using_protid_payload
+#define ACPI_DESTRUCTOR end_using_protid_port (protid_t)
diff --git a/acpi/acpi.h b/acpi/myacpi.h
index 7c21a442..44925809 100644
--- a/acpi/acpi.h
+++ b/acpi/myacpi.h
@@ -14,13 +14,13 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with the GNU Hurd. If not, see <<a rel="nofollow" href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>>.
+ along with the GNU Hurd. If not, see http://www.gnu.org/licenses
*/
/* ACPI tables basic structure */
-#ifndef ACPI_H
-#define ACPI_H
+#ifndef MYACPI_H
+#define MYACPI_H
#include <stdlib.h>
#include <inttypes.h>
@@ -71,4 +71,4 @@ struct acpi_table
int acpi_get_num_tables(size_t *num_tables);
int acpi_get_tables(struct acpi_table **tables);
-#endif /* ACPI_H */
+#endif /* MYACPI_H */