Beispiel #1
0
ACPI_STATUS
AcpiHwReadPort (
    ACPI_IO_ADDRESS         Address,
    UINT32                  *Value,
    UINT32                  Width)
{
    ACPI_STATUS             Status;
    UINT32                  OneByte;
    UINT32                  i;


    /* Truncate address to 16 bits if requested */

    if (AcpiGbl_TruncateIoAddresses)
    {
        Address &= ACPI_UINT16_MAX;
    }

    /* Validate the entire request and perform the I/O */

    Status = AcpiHwValidateIoRequest (Address, Width);
    if (ACPI_SUCCESS (Status))
    {
        Status = AcpiOsReadPort (Address, Value, Width);
        return (Status);
    }

    if (Status != AE_AML_ILLEGAL_ADDRESS)
    {
        return (Status);
    }

    /*
     * There has been a protection violation within the request. Fall
     * back to byte granularity port I/O and ignore the failing bytes.
     * This provides Windows compatibility.
     */
    for (i = 0, *Value = 0; i < Width; i += 8)
    {
        /* Validate and read one byte */

        if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
        {
            Status = AcpiOsReadPort (Address, &OneByte, 8);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }

            *Value |= (OneByte << i);
        }

        Address++;
    }

    return (AE_OK);
}
Beispiel #2
0
void
AcpiHwGetGpeStatus (
    UINT32                  GpeNumber,
    ACPI_EVENT_STATUS       *EventStatus)
{
    UINT32                  InByte = 0;
    UINT32                  RegisterIndex = 0;
    UINT32                  BitMask = 0;


    FUNCTION_ENTRY ();


    if (!EventStatus)
    {
        return;
    }

    (*EventStatus) = 0;

    /*
     * Translate GPE number to index into global registers array.
     */
    RegisterIndex = AcpiGbl_GpeValid[GpeNumber];

    /*
     * Figure out the bit offset for this GPE within the target register.
     */
    BitMask = AcpiGbl_DecodeTo8bit [MOD_8 (GpeNumber)];

    /*
     * Enabled?:
     */
    InByte = 0;
    AcpiOsReadPort (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, &InByte, 8);
    if (BitMask & InByte)
    {
        (*EventStatus) |= ACPI_EVENT_FLAG_ENABLED;
    }

    /*
     * Set?
     */
    InByte = 0;
    AcpiOsReadPort (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, &InByte, 8);
    if (BitMask & InByte)
    {
        (*EventStatus) |= ACPI_EVENT_FLAG_SET;
    }
}
Beispiel #3
0
void
AcpiHwDisableGpe (
    UINT32                  GpeNumber)
{
    UINT32                  InByte;
    UINT32                  RegisterIndex;
    UINT32                  BitMask;


    FUNCTION_ENTRY ();


    /*
     * Translate GPE number to index into global registers array.
     */
    RegisterIndex = AcpiGbl_GpeValid[GpeNumber];

    /*
     * Figure out the bit offset for this GPE within the target register.
     */
    BitMask = AcpiGbl_DecodeTo8bit [MOD_8 (GpeNumber)];

    /*
     * Read the current value of the register, clear the appropriate bit,
     * and write out the new register value to disable the GPE.
     */
    InByte = 0;
    AcpiOsReadPort (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, &InByte, 8);
    AcpiOsWritePort (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr,
                (InByte & ~BitMask), 8);
}
Beispiel #4
0
static uint8_t
thinkpad_brightness_read(thinkpad_softc_t *sc)
{
	uint32_t val = 0;

	AcpiOsWritePort(IO_RTC, 0x6c, 8);
	AcpiOsReadPort(IO_RTC + 1, &val, 8);

	return val & 7;
}
Beispiel #5
0
ACPI_STATUS
AcpiExSystemIoSpaceHandler (
    UINT32                  Function,
    ACPI_PHYSICAL_ADDRESS   Address,
    UINT32                  BitWidth,
    ACPI_INTEGER            *Value,
    void                    *HandlerContext,
    void                    *RegionContext)
{
    ACPI_STATUS             Status = AE_OK;
    UINT32                  Value32;


    ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler);


    ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
        "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n",
        BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));

    /* Decode the function parameter */

    switch (Function)
    {
    case ACPI_READ:

        Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address,
                    &Value32, BitWidth);
        *Value = Value32;
        break;

    case ACPI_WRITE:

        Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) Address,
                    (UINT32) *Value, BitWidth);
        break;

    default:
        Status = AE_BAD_PARAMETER;
        break;
    }

    return_ACPI_STATUS (Status);
}
static void
acpicpu_cstate_idle_enter(struct acpicpu_softc *sc, int state)
{
	struct acpicpu_cstate *cs = &sc->sc_cstate[state];
	uint32_t end, start, val;

	start = acpitimer_read_fast(NULL);

	switch (cs->cs_method) {

	case ACPICPU_C_STATE_FFH:
	case ACPICPU_C_STATE_HALT:
		acpicpu_md_cstate_enter(cs->cs_method, state);
		break;

	case ACPICPU_C_STATE_SYSIO:
		(void)AcpiOsReadPort(cs->cs_addr, &val, 8);
		break;
	}

	cs->cs_evcnt.ev_count++;
	end = acpitimer_read_fast(NULL);
	sc->sc_cstate_sleep = hztoms(acpitimer_delta(end, start)) * 1000;
}