Kernel: Fix 32 bit compilation

This commit is contained in:
Bananymous 2024-04-18 01:35:56 +03:00
parent 687fa44eff
commit 30d12a76bc
2 changed files with 37 additions and 2 deletions

View File

@ -43,7 +43,7 @@ namespace Kernel::ACPI::AML
if (!buffer_size.has_value())
return ParseResult::Failure;
uint32_t actual_buffer_size = BAN::Math::max(buffer_size.value(), buffer_context.aml_data.size());
uint32_t actual_buffer_size = BAN::Math::max<uint32_t>(buffer_size.value(), buffer_context.aml_data.size());
auto buffer = MUST(BAN::RefPtr<Buffer>::create());
MUST(buffer->buffer.resize(actual_buffer_size, 0));

View File

@ -19,10 +19,10 @@
namespace Kernel::ACPI
{
static uint32_t* s_global_lock { nullptr };
// https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#global-lock
#if ARCH(x86_64)
asm(R"(
.global acpi_acquire_global_lock
acpi_acquire_global_lock:
@ -54,6 +54,41 @@ acpi_release_global_lock:
ret
)");
#elif ARCH(i686)
asm(R"(
.global acpi_acquire_global_lock
acpi_acquire_global_lock:
movl 4(%esp), %ecx
movl (%ecx), %edx
andl $(~1), %edx
btsl $1, %edx
adcl $0, %edx
lock cmpxchgl %edx, (%ecx)
jnz acpi_acquire_global_lock
cmpb $3, %dl
sbbl %eax, %eax
negl %eax
ret
.global acpi_release_global_lock
acpi_release_global_lock:
movl 4(%esp), %ecx
movl (%ecx), %eax
movl %eax, %edx
andl $(~3), %edx
lock cmpxchgl %edx, (%ecx)
jnz acpi_release_global_lock
andl $1, %eax
ret
)");
#endif
// returns true if lock was acquired successfully
extern "C" bool acpi_acquire_global_lock(uint32_t* lock);