Work: Write EC memory space through ACPI standard command

;
EC_CTRL_PORT    EQU    066h
EC_STAT_PORT    EQU    066h
EC_DATA_PORT    EQU    062h

EC_S_OBUF    EQU    01h
EC_S_IBUF    EQU    02h
EC_S_CMD    EQU    08h
EC_WAITTIME    EQU    0A000h

ECib_free    PROC NEAR PRIVATE
    in     al, EC_STAT_PORT
    and    al, EC_S_IBUF
    jnz    ECib_free
    ret
ECib_free    ENDP

ECiob_free    PROC NEAR    PRIVATE
    in  al, EC_STAT_PORT
    and al, EC_S_IBUF + EC_S_OBUF
    jnz ECiob_free
    ret
ECiob_free  ENDP

ECib_freeWait    PROC NEAR PRIVATE
    push    cx
    mov    cx, EC_WAITTIME
lp:
    in     al, EC_STAT_PORT
    and    al, EC_S_IBUF
    jz    exit
    dec    cx
    jnz    lp
exit:
    pop    cx
    ret
ECib_freeWait    ENDP

ECiob_freeWait PROC NEAR PRIVATE
    push    cx
    mov    cx, EC_WAITTIME
lp:
    in    al, EC_STAT_PORT
    and    al, EC_S_IBUF + EC_S_OBUF
    jz    exit
    dec    cx
    jnz    lp
exit:
    pop    cx
    ret
ECiob_freeWait ENDP

; ———————————————————
; WR_ECDATA,
; write a byte to ECRAM space through ACPI standard command
; INPUT
;   ah, offset
;   al, data
;
;    Write EC_CMD with 81h (66h=81h)
;    Wait SCI for IBF=0
;    Write address byte to EC_DAT (62h=EC address)
;    Wait SCI for IBF=0
;    Write data byte to EC_DAT (62h = write data)
;    Wait SCI for IBF=0
WR_ECDATA PROC FAR PUBLIC
    push ax
    call ECiob_freeWait

    mov  al, 081h        ; 1. Write Embedded Controller (0x81), ACPI 3.0b 12.3.2
    out  EC_CTRL_PORT, al

    call ECib_freeWait
    xchg ah, al
    out  EC_DATA_PORT, al    ; 2. write offset to EC
    call ECib_freeWait
    pop  ax
    out  EC_DATA_PORT, al    ; 3. write data to EC
    call ECib_freeWait    ; 4. wait EC done
    ret
WR_ECDATA ENDP

; by OEM defined

SET_THERMAL PROC FAR PUBLIC
    mov    ax, Q_TM_COOLING_TRIP_POINT
    call    check_cmos_data_far
    jz    disThermal
    shl    al, 3    ; al *= 8
    add    al, 7    ; al += 7
disThermal:
    mov    ah, 0D1H    ; EC offset, CPUH
    call    WR_ECDATA
    ret
SET_THERMAL ENDP

; by OEM defined

SET_CRITICAL_TRIP PROC FAR PUBLIC
    mov    ax, Q_CRITICAL_TRIP_POINT
    call    check_cmos_data_far
    jz    disCRITICAL
    shl    al, 3    ; al *= 8
    add    al, 7    ; al += 7
disCRITICAL:
    mov    al, 95
    mov    ah, 0D7H   ; EC offset, CSUP
    call    WR_ECDATA
    ret
SET_CRITICAL_TRIP ENDP

 

; by OEM defined

ECOEM_SENSOR_INIT PROC NEAR PRIVATE
    call ECiob_freeWait
    mov  al, 0ADH
    out  EC_CTRL_PORT, al
    call ECib_freeWait
    ret
ECOEM_SENSOR_INIT ENDP

 

; by OEM defined

ECOEM_ACPI_ENA PROC NEAR PRIVATE
    call ECiob_freeWait
    mov  al, 004H ; EC ACPI/SMI enable
    out  EC_CTRL_PORT, al
    call ECib_freeWait
    ret
ECOEM_ACPI_ENA ENDP

 

; by OEM defined

ECOEM_ACPI_DIS PROC NEAR PRIVATE
    call ECiob_freeWait
    mov  al, 005H ; EC ACPI/SMI enable
    out  EC_CTRL_PORT, al
    call ECib_freeWait
    ret
ECOEM_ACPI_DIS ENDP

廣告

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s

%d 位部落客按了讚: