Skip to content

Commit d537356

Browse files
committed
[ACPI] Test raw pointer to the EC region
1 parent 00cc990 commit d537356

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

drivers/bus/acpi/acpica/events/evhandler.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@ AcpiEvInstallSpaceHandler (
458458
Setup = AcpiEvDataTableRegionSetup;
459459
break;
460460

461+
case ACPI_ADR_SPACE_EC:
462+
463+
Handler = AcpiExEcSpaceHandler;
464+
Setup = AcpiEvEcRegionSetup;
465+
break;
466+
461467
default:
462468

463469
Status = AE_BAD_PARAMETER;

drivers/bus/acpi/acpica/events/evrgnini.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,3 +721,20 @@ AcpiEvInitializeRegion (
721721

722722
return_ACPI_STATUS (AE_OK);
723723
}
724+
725+
ACPI_STATUS
726+
AcpiEvEcRegionSetup(ACPI_HANDLE Handle, UINT32 Function, void *HandlerContext, void **RegionContext)
727+
{
728+
ACPI_FUNCTION_TRACE(EvEcRegionSetup);
729+
730+
if (Function == ACPI_REGION_DEACTIVATE)
731+
{
732+
*RegionContext = NULL;
733+
}
734+
else
735+
{
736+
*RegionContext = HandlerContext;
737+
}
738+
739+
return_ACPI_STATUS(AE_OK);
740+
}

drivers/bus/acpi/acpica/executer/exregion.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,3 +618,44 @@ AcpiExDataTableSpaceHandler (
618618

619619
return_ACPI_STATUS (AE_OK);
620620
}
621+
622+
ACPI_STATUS
623+
AcpiExEcSpaceHandler(
624+
UINT32 Function,
625+
ACPI_PHYSICAL_ADDRESS Address,
626+
UINT32 BitWidth,
627+
UINT64 *Value,
628+
void *HandlerContext,
629+
void *RegionContext)
630+
{
631+
ACPI_DATA_TABLE_MAPPING *Mapping;
632+
char *Pointer;
633+
634+
ACPI_FUNCTION_TRACE(ExEcSpaceHandler);
635+
636+
Mapping = (ACPI_DATA_TABLE_MAPPING *)RegionContext;
637+
Pointer = ACPI_CAST_PTR(char, Mapping->Pointer) + (Address - ACPI_PTR_TO_PHYSADDR(Mapping->Pointer));
638+
639+
/*
640+
* Perform the memory read or write. The BitWidth was already
641+
* validated.
642+
*/
643+
switch (Function)
644+
{
645+
case ACPI_READ:
646+
647+
memcpy(ACPI_CAST_PTR(char, Value), Pointer, ACPI_DIV_8(BitWidth));
648+
break;
649+
650+
case ACPI_WRITE:
651+
652+
memcpy(Pointer, ACPI_CAST_PTR(char, Value), ACPI_DIV_8(BitWidth));
653+
break;
654+
655+
default:
656+
657+
return_ACPI_STATUS(AE_BAD_PARAMETER);
658+
}
659+
660+
return_ACPI_STATUS(AE_OK);
661+
}

drivers/bus/acpi/acpica/include/acevents.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ AcpiEvDataTableRegionSetup (
356356
void *HandlerContext,
357357
void **RegionContext);
358358

359+
ACPI_STATUS
360+
AcpiEvEcRegionSetup(ACPI_HANDLE Handle, UINT32 Function, void *HandlerContext, void **RegionContext);
361+
362+
359363
ACPI_STATUS
360364
AcpiEvDefaultRegionSetup (
361365
ACPI_HANDLE Handle,

drivers/bus/acpi/acpica/include/acinterp.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,4 +781,13 @@ AcpiExDataTableSpaceHandler (
781781
void *HandlerContext,
782782
void *RegionContext);
783783

784+
ACPI_STATUS
785+
AcpiExEcSpaceHandler(
786+
UINT32 Function,
787+
ACPI_PHYSICAL_ADDRESS Address,
788+
UINT32 BitWidth,
789+
UINT64 *Value,
790+
void *HandlerContext,
791+
void *RegionContext);
792+
784793
#endif /* __INTERP_H__ */

0 commit comments

Comments
 (0)