From d1ba5a94f470ac380aaee973450cac4be3ef602d Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 28 Dec 2024 19:32:11 -0300 Subject: [PATCH] uacpi: update --- kernel-src/Makefile | 2 +- kernel-src/io/acpi/glue.c | 28 ++++++++++++++++++++++++---- kernel-src/io/acpi/uacpi | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/kernel-src/Makefile b/kernel-src/Makefile index c719053c..1ff59ffe 100644 --- a/kernel-src/Makefile +++ b/kernel-src/Makefile @@ -11,7 +11,7 @@ PRINTFOPTS=-DPRINTF_DISABLE_SUPPORT_FLOAT # flanterm includes break if the headers are moved into the include dir in the tree FLANTERMINCDIR=$(shell pwd)/flanterm UACPIINCDIR=$(shell pwd)/io/acpi/uacpi/include -UACPIOPTS=-DUACPI_OVERRIDE_LIBC -DUACPI_KERNEL_INITIALIZATION +UACPIOPTS=-DUACPI_OVERRIDE_LIBC -DUACPI_KERNEL_INITIALIZATION -DUACPI_NATIVE_ALLOC_ZEROED KERNELCONFIG=#-DX86_64_ENABLE_E9 -DSYSCALL_LOGGING CFLAGS=-g -ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mgeneral-regs-only -mno-mmx -mno-sse -mno-sse2 -nostdlib -Wall -MMD -I "${INCDIR}" -I "$(ARCHINCDIR)" -I "$(FLANTERMINCDIR)" -I "$(UACPIINCDIR)" $(UACPIOPTS) $(PRINTFOPTS) $(KERNELCONFIG) ASFLAGS=-felf64 diff --git a/kernel-src/io/acpi/glue.c b/kernel-src/io/acpi/glue.c index 3049a725..be0934a6 100644 --- a/kernel-src/io/acpi/glue.c +++ b/kernel-src/io/acpi/glue.c @@ -49,8 +49,8 @@ void *uacpi_kernel_alloc(uacpi_size size) { return alloc(size); } -void *uacpi_kernel_calloc(uacpi_size count, uacpi_size size) { - return alloc(count * size); +void *uacpi_kernel_alloc_zeroed(uacpi_size size) { + return alloc(size); } void uacpi_kernel_free(void *ptr) { @@ -207,7 +207,25 @@ uacpi_status uacpi_kernel_io_write(uacpi_handle handle, uacpi_size offset, uacpi return uacpi_kernel_raw_io_write((uacpi_io_addr)handle + offset, width, value); } -uacpi_status uacpi_kernel_pci_read(uacpi_pci_address *address, uacpi_size offset, uacpi_u8 width, uacpi_u64 *out) { +uacpi_status uacpi_kernel_pci_device_open( + uacpi_pci_address address, uacpi_handle *out_handle +) { + uacpi_pci_address *p = alloc(sizeof(uacpi_pci_address)); + if (uacpi_unlikely(p == NULL)) + return UACPI_STATUS_OUT_OF_MEMORY; + + memcpy(p, &address, sizeof(uacpi_pci_address)); + *out_handle = (uacpi_handle)p; + return UACPI_STATUS_OK; +} + +void uacpi_kernel_pci_device_close(uacpi_handle handle) { + free((void *)handle); +} + +uacpi_status uacpi_kernel_pci_read(uacpi_handle handle, uacpi_size offset, uacpi_u8 width, uacpi_u64 *out) { + uacpi_pci_address *address = (uacpi_pci_address *)handle; + if (address->segment != 0) { printf("reading from PCI segment %u is not supported\n", address->segment); return UACPI_STATUS_UNIMPLEMENTED; @@ -233,7 +251,9 @@ uacpi_status uacpi_kernel_pci_read(uacpi_pci_address *address, uacpi_size offset return UACPI_STATUS_OK; } -uacpi_status uacpi_kernel_pci_write(uacpi_pci_address *address, uacpi_size offset, uacpi_u8 width, uacpi_u64 value) { +uacpi_status uacpi_kernel_pci_write(uacpi_handle handle, uacpi_size offset, uacpi_u8 width, uacpi_u64 value) { + uacpi_pci_address *address = (uacpi_pci_address *)handle; + if (address->segment != 0) { printf("writing to PCI segment %u is not supported\n", address->segment); return UACPI_STATUS_UNIMPLEMENTED; diff --git a/kernel-src/io/acpi/uacpi b/kernel-src/io/acpi/uacpi index 1721b8a2..3e1f1a3e 160000 --- a/kernel-src/io/acpi/uacpi +++ b/kernel-src/io/acpi/uacpi @@ -1 +1 @@ -Subproject commit 1721b8a2a35fb60719641adefbdb945006cb673c +Subproject commit 3e1f1a3e5a5064736b532ab20324faf996f02e3c