📄 gpmlib.inc
字号:
push ax ;
mov al,ami_megakey2_wt_ram_cmd ; (al) = AMI MEGAKEY II write ram command
call write_kb_cntlr_data ;
pop ax ; (al) has data to write to corressponding RAM location
jnz short wt_megakey2_ram_loc_01 ; error...input buffer full
call write_8042_data ;
jz short wt_megakey2_ram_loc_02 ; no error...(cy) = 00
wt_megakey2_ram_loc_01:
stc ; (cy) = 01 for error
wt_megakey2_ram_loc_02:
ret
write_ami_megakey2_ram_loc endp
;---------------------------------------------------------------;
; EMPTY_KB_CNTLR_IBUF ;
;---------------------------------------------------------------;
; Input : NONE ;
; Output: (NZF) error...input buffer full ;
; (ZF) no error...input buffer empty ;
; (CY) 00 always for error/no error ;
; Register destroyed : (CX) ;
; NOTE : Wait for input buffer empty ;
;---------------------------------------------------------------;
empty_kb_cntlr_ibuf proc near
push ax ;
mov cx,16 ;
empty_kb_cntlr_ibuf_01:
push cx ;
xor cx,cx ;
empty_kb_cntlr_ibuf_02:
in al,kb_stat_port ; (al) = read keyboard controller status
test al,kb_input_buf_full ; input buffer full ?
loopnz empty_kb_cntlr_ibuf_02 ; yes...
pop cx ;
loopnz empty_kb_cntlr_ibuf_01 ;
pop ax ;
ret
empty_kb_cntlr_ibuf endp
;---------------------------------------------------------------;
; FULL_KB_CNTLR_OBUF ;
;---------------------------------------------------------------;
; Input : NONE ;
; Output: (NZF) no error...output buffer full ;
; (ZF) error...output buffer empty ;
; (CY) 00 always for error/no error ;
; Register destroyed : (CX) ;
; NOTE : Wait for output buffer full ;
;---------------------------------------------------------------;
full_kb_cntlr_obuf proc near
push ax ;
mov cx,16 ;
full_kb_cntlr_obuf_01:
push cx ;
xor cx,cx ;
full_kb_cntlr_obuf_02:
in al,kb_stat_port ; (al) = read keyboard controller status
test al,kb_output_buf_full ; output buffer full ?
loopz full_kb_cntlr_obuf_02 ; no...
pop cx ;
loopz full_kb_cntlr_obuf_01 ;
pop ax ;
ret
full_kb_cntlr_obuf endp
;---------------------------------------------------------------;
; WRITE_KB_CNTLR_DATA ;
;---------------------------------------------------------------;
; Input : (AL) kb cntlr command ;
; (AH) data for the command ;
; Output: (NZF) error...input buffer full ;
; (ZF) no error ;
; (CY) 00 always for error/no error ;
; Register destroyed : (AL),(CX) ;
; NOTE : This routines sends the command in (AL) to keyboard ;
; controller, then it sends the data byte in (AH) for the;
; command to the keyboard controller. ;
;---------------------------------------------------------------;
write_kb_cntlr_data proc near
call write_kb_cntlr_cmd ;
jnz short write_kb_cntlr_data_01 ; error...input buffer full
mov al,ah ; (al) = data to be sent to keyboard controller
call write_8042_data ; send data to keyboard controller
write_kb_cntlr_data_01:
ret
write_kb_cntlr_data endp
;---------------------------------------------------------------;
; WRITE_8042_DATA ;
; WRITE_KB_MOUSE_DATA ;
;---------------------------------------------------------------;
; Input : (AL) keyboard controller/mouse/keyboard data ;
; Output: (NZF) error...input buffer full ;
; (ZF) no error...input buffer empty ;
; (CY) 00 always for error/no error ;
; Register destroyed : (CX) ;
; NOTE : This routine sends the data byte in (AL) to the ;
; keyboard controller/mouse/keyboard. ;
;---------------------------------------------------------------;
write_8042_data proc near
write_kb_mouse_data proc near
call empty_kb_cntlr_ibuf ; input buffer empty ?
jnz short write_kb_mouse_data_01 ; no...full
out kb_data_port,al ; output the data to keyboard/mouse
call empty_kb_cntlr_ibuf ; wait for input buffer empty
write_kb_mouse_data_01:
ret
write_kb_mouse_data endp
write_8042_data endp
;---------------------------------------------------------------;
; READ_KB_DATA ;
; READ_8042_DATA ;
;---------------------------------------------------------------;
; Input : NONE ;
; Output: (NZF) no error & ;
; (AL) data read from keyboard controller/;
; keyboard ;
; (ZF) error...output buffer empty ;
; (CY) 00 always for error/no error ;
; Register destroyed : (AL),(CX) ;
; NOTE : This routine receives the data byte in (AL) from the ;
; keyboard controller/keyboard. ;
;---------------------------------------------------------------;
read_kb_data proc near
read_8042_data proc near
call full_kb_cntlr_obuf ; keyboard controller output buffer full ?
jz short read_kb_data_01 ; no...
in al,kb_data_port ; (al) = read keyboard data
read_kb_data_01:
ret
read_8042_data endp
read_kb_data endp
;---------------------------------------------------------------;
ENDIF
;---------------------------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;** **;
;** (C)Copyright 1985-1996, American Megatrends Inc. **;
;** **;
;** All Rights Reserved. **;
;** **;
;** 6145-F, Northbelt Parkway, Norcross, **;
;** **;
;** Georgia - 30071, USA. Phone-(770)-246-8600. **;
;** **;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------------------------------;
; CODE TO HANDLE RTC ALARM ;
; CODE TO HANDLE RTC ALARM ;
; CODE TO HANDLE RTC ALARM ;
; CODE TO HANDLE RTC ALARM ;
;---------------------------------------------------------------;
; All the code from here labelled as 'RTC_ALARM_SUPPORT' to ;
; the label 'RTC_ALARM_SUPPORT_ENDS' should be made active if ;
; you need to use RTC ALARM resume. ;
; Following routine needs to be called... ;
; SET_RTC_ALARM_DURING_SUSPEND ;
; RESTORE_RTC_DURING_RESUME ;
;---------------------------------------------------------------;
IF RTC_ALARM_HANDLING_SUPPORT
rtc_alarm_support label byte
;---------------------------------------------------------------;
; SET_RTC_ALARM_DURING_SUSPEND ;
;---------------------------------------------------------------;
; Input : (DS) PM BIOS data segment ;
; (DL) bit 0 set...use USER ALARM as resume ALARM ;
; bit 1 set...use specified ALARM time in ;
; (CH),(CL),(DH) as resume ALARM ;
; bit 6-2...reserved ;
; bit 7 set...valid only when bit 0 also set,;
; but no USER ALARM is set...will;
; do SAVE RTC and clear periodic ;
; interrupt enable bit. ;
; (CH) alarm hour in BCD ;
; (CL) alarm minutes in BCD ;
; (DH) alarm seconds in BCD...set to 00 ;
; Output: (CY) 00 for no error ;
; (CY) 01 for error and any of the following... ;
; ....CMOS inoperational ;
; ....No USER ALARM set for (DL) bit 0 set;
; but RTC will be saved and periodic ;
; interrupt will be disabled if (DL) ;
; bit 7 is set at input. ;
; Register destroyed : (AX),(CX),(DX) ;
; NOTE : ;
; * No error checking done for unspecified bit(s) of (DL) set ;
; * No error checking done for multiple bits of (DL) set ;
; * If no bit of (DL) is set, no ALARM usage for RESUME ;
; * If bit 0 of (DL) is set but no USER ALARM is set, then ;
; if bit 7 of (DL) is set, RTC is saved and periodic ;
; interrupt is disabled. ;
; * If you call this routine during standby/sleep/suspend, ;
; the 'RESTORE_RTC_DURING_RESUME' must be called during ;
; resume. ;
;---------------------------------------------------------------;
set_rtc_alarm_during_suspend proc near
mov byte ptr ds:gpm_alarm_flag,00000000b; clear the FLAG
test dl,00000001b ; use USER ALARM as resume alarm ?
jz short set_rtc_alarm_suspend_10 ; no...
push dx ; save on entry (DL)
call read_rtc_alarm ; get user alarm time if enabled in (CH),(CL),(DH)
pop ax ; (AL) has on entry (DL)
jc short set_rtc_alarm_suspend_02 ; error...CMOS inoperational
jnz short set_rtc_alarm_suspend_14 ; USER ALARM enabled...program USER ALARM as resume alarm
test al,10000000b ; save RTC & disable periodic interrupt ?
jz short set_rtc_alarm_suspend_03 ; no...
or byte ptr ds:gpm_alarm_flag,restore_rtc_on_resume
call save_rtc ; save RTC
set_rtc_alarm_suspend_03:
stc ; (cy) = 01 for error
set_rtc_alarm_suspend_02:
ret
;-----------------------------------------------;
set_rtc_alarm_suspend_10:
test dl,00000010b ; any time specified as resume alarm ?
jz short set_rtc_alarm_suspend_02 ; no...EXIT...(cy) = 00
push cx ;
push dx ;
call read_rtc_alarm ; get user alarm time if enabled in (CH),(CL),(DH)
jc short set_rtc_alarm_suspend_11 ; error...CMOS inoperational
jz short set_rtc_alarm_suspend_12 ; USER ALARM disabled...
or byte ptr ds:gpm_alarm_flag,restore_user_alarm_on_resume
mov ds:user_alarm_save_area,cx ; save USER ALARM HOUR & MINUTE
mov byte ptr ds:user_alarm_save_area+2,dh; save USER ALARM SECOND
set_rtc_alarm_suspend_12:
pop dx ;
pop cx ;
set_rtc_alarm_suspend_14:
cli ; disable interrupts
or byte ptr ds:gpm_alarm_flag,restore_rtc_on_resume
call save_rtc ; save RTC
call reset_rtc_alarm ; clear previous USER ALARM
call set_rtc_alarm ; set new ALARM for resume
push ax
mov ax,word ptr ds:apm_12_resume_day_bcd; get day & month
push ax ;save month (ah)
mov ah,al
mov al,0feh ;CMOS 7eh day of the day alarm
call smi_cmos_data_in
and al,0c0h
or ah,al
mov al,0feh
call smi_cmos_data_out
pop ax ;restor month (ah)
mov al,0ffh ;CMOS 7fh day of the Month alarm
call smi_cmos_data_in
and al,0c0h
or ah,al
mov al,0ffh
call smi_cmos_data_out
pop ax
clc ; (cy) = 00 for no error
ret
set_rtc_alarm_suspend_11:
pop dx ;
pop cx ;
ret
set_rtc_alarm_during_suspend endp
;---------------------------------------------------------------;
; RESTORE_RTC_DURING_RESUME ;
;---------------------------------------------------------------;
; Input : (DS) PM BIOS data segment ;
; Output: (ZF) (ZR) RTC alarm interrupt was not active at ;
; the time of calling this routine ;
; (ZF) (NZ) RTC alarm interrupt was active at the ;
; time of calling this routine ;
; Register destroyed : (AX),(CX),(DX) ;
;---------------------------------------------------------------;
restore_rtc_during_resume proc near
cli ; disable interrupts
call is_it_alarm_resume ; is RTC alarm interrupt active ?
pushf ; (zf) = (nz)/(zr) for RTC alarm interrupt active/not active
test byte ptr ds:gpm_alarm_flag,restore_user_alarm_on_resume; restore USER ALARM on resume ?
jz short restore_rtc_resume_01 ; no...
mov cx,ds:user_alarm_save_area ; (CH) = USER ALARM HOUR, (CL) USER ALARM MINUTE
mov dh, byte ptr ds:user_alarm_save_area+2; (DH) = USER ALARM SECOND
call set_rtc_alarm ; set USER ALARM
restore_rtc_resume_01:
test byte ptr ds:gpm_alarm_flag,restore_rtc_on_resume; restore RTC on resume ?
jz short restore_rtc_resume_02 ; no...
call restore_rtc ; restore RTC
restore_rtc_resume_02:
popf ; (zf) = (nz)/(zr) for RTC alarm interrupt active/not active
ret
restore_rtc_during_resume endp
;---------------------------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;** **;
;** (C)Copyright 1985-1996, American Megatrends Inc. **;
;** **;
;** All Rights Reserved. **;
;** **;
;** 6145-F, Northbelt Parkway, Norcross, **;
;** **;
;** Georgia - 30071, USA. Phone-(770)-246-8600. **;
;** **;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------------------------------;
; SET_RTC_ALARM ;
;---------------------------------------------------------------;
; Input : (CH) alarm hour in BCD ;
; (CL) alarm minut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -