forked from KolibriOS/kolibrios
Mihaylov Iliya Andreevich aka Ghost
Advanced Power Management SYSTEM CALL eax = 49 dx = number of the function APM BIOS (Is similar AX in real mode) Others registers (bx, cx) on the specification (see. docs/apm.zip>apm.txt) Result: on the specification (including CF), the high part 32 bit registers is not defined git-svn-id: svn://kolibrios.org@76 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
17da7e7f7a
commit
c9d4558817
@ -344,6 +344,58 @@ wait_loop: ; variant 2
|
||||
; wait until 8042 controller is ready
|
||||
loopnz wait_loop
|
||||
|
||||
; --------------- APM ---------------------
|
||||
push 0
|
||||
pop es
|
||||
mov word [es : 0x9044], 0 ; ver = 0.0 (APM not found)
|
||||
mov ax, 0x5300
|
||||
xor bx, bx
|
||||
int 0x15
|
||||
jc apm_end ; APM not found
|
||||
test cx, 2
|
||||
jz apm_end ; APM 32-bit protected-mode interface not supported
|
||||
mov [es : 0x9044], ax ; Save APM Version
|
||||
mov [es : 0x9046], cx ; Save APM flags
|
||||
|
||||
; Write APM ver ----
|
||||
jmp @f
|
||||
msg_apm:db ' APM x.x ', 0
|
||||
@@: and ax, 0xf0f
|
||||
add ax, '00'
|
||||
mov [msg_apm - 0x10000 + 5], ah
|
||||
mov [msg_apm - 0x10000 + 7], al
|
||||
_setcursor 0, 3
|
||||
mov si, msg_apm - 0x10000
|
||||
call printplain
|
||||
_setcursor d80x25_top_num,0
|
||||
; ------------------
|
||||
|
||||
mov ax, 0x5304 ; Disconnect interface
|
||||
xor bx, bx
|
||||
int 0x15
|
||||
mov ax, 0x5303 ; Connect 32 bit mode interface
|
||||
xor bx, bx
|
||||
int 0x15
|
||||
; init selectors
|
||||
movzx eax, ax ; real-mode segment base address of protected-mode 32-bit code segment
|
||||
shl eax, 4
|
||||
mov [apm_code_32 - 0x10000 + 2], ax
|
||||
shr eax, 16
|
||||
mov [apm_code_32 - 0x10000 + 4], al
|
||||
movzx ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment
|
||||
shl ecx, 4
|
||||
mov [apm_code_16 - 0x10000 + 2], cx
|
||||
shr ecx, 16
|
||||
mov [apm_code_16 - 0x10000 + 4], cl
|
||||
movzx edx, dx ; real-mode segment base address of protected-mode 16-bit data segment
|
||||
shl edx, 4
|
||||
mov [apm_data_16 - 0x10000 + 2], dx
|
||||
shr edx, 16
|
||||
mov [apm_data_16 - 0x10000 + 4], dl
|
||||
mov [es : 0x9040], ebx ; offset of APM entry point
|
||||
apm_end:
|
||||
; -----------------------------------------
|
||||
|
||||
; DISPLAY VESA INFORMATION
|
||||
|
||||
push 0
|
||||
|
@ -35,6 +35,24 @@ os_data_l:
|
||||
dw 11011111b *256 +10010010b
|
||||
db 0x00
|
||||
|
||||
; --------------- APM ---------------------
|
||||
apm_code_32:
|
||||
dw 0x10 ; limit 64kb
|
||||
db 0, 0, 0
|
||||
dw 11011111b *256 +10011010b
|
||||
db 0x00
|
||||
apm_code_16:
|
||||
dw 0x10
|
||||
db 0, 0, 0
|
||||
dw 10011111b *256 +10011010b
|
||||
db 0x00
|
||||
apm_data_16:
|
||||
dw 0x10
|
||||
db 0, 0, 0
|
||||
dw 10011111b *256 +10010010b
|
||||
db 0x00
|
||||
; -----------------------------------------
|
||||
|
||||
app_code_l:
|
||||
dw ((0x80000000-std_application_base_address) shr 12) and 0xffff
|
||||
dw 0
|
||||
|
@ -120,7 +120,7 @@ iglobal
|
||||
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
|
||||
dd display_number ; 47-WriteNum
|
||||
dd display_settings ; 48-SetRedrawType and SetButtonType
|
||||
dd syscall_appints ; 49-AppInts
|
||||
dd sys_apm ; 49-Advanced Power Management (APM)
|
||||
dd random_shaped_window ; 50-Window shape & scale
|
||||
dd syscall_threads ; 51-Threads
|
||||
dd stack_driver_stat ; 52-Stack driver status
|
||||
|
BIN
kernel/trunk/docs/apm.zip
Normal file
BIN
kernel/trunk/docs/apm.zip
Normal file
Binary file not shown.
@ -283,6 +283,14 @@ B32:
|
||||
rep stosd
|
||||
|
||||
; SAVE REAL MODE VARIABLES
|
||||
; --------------- APM ---------------------
|
||||
mov eax, [0x2f0000 + 0x9040] ; entry point
|
||||
mov dword[apm_entry], eax
|
||||
mov word [apm_entry + 4], apm_code_32 - gdts
|
||||
|
||||
mov eax, [0x2f0000 + 0x9044] ; version & flags
|
||||
mov [apm_vf], eax
|
||||
; -----------------------------------------
|
||||
; movzx eax,byte [0x2f0000+0x9010] ; mouse port
|
||||
; mov [0xF604],byte 1 ;al
|
||||
mov al,[0x2f0000+0x9000] ; bpp
|
||||
@ -4790,12 +4798,6 @@ syscall_reserveportarea: ; ReservePortArea and FreePortArea
|
||||
mov [esp+36],eax
|
||||
ret
|
||||
|
||||
;align 4
|
||||
|
||||
syscall_appints: ; AppInts
|
||||
; mov [esp+36],dword -1
|
||||
ret
|
||||
|
||||
align 4
|
||||
|
||||
syscall_threads: ; CreateThreads
|
||||
@ -4879,6 +4881,42 @@ write_to_hd: ; Write a file to hd
|
||||
; ret
|
||||
;
|
||||
|
||||
; --------------- APM ---------------------
|
||||
apm_entry dp 0
|
||||
apm_vf dd 0
|
||||
align 4
|
||||
sys_apm:
|
||||
cmp word [apm_vf], 0 ; Check APM BIOS enable
|
||||
jne @f
|
||||
or [esp + 40], byte 1 ; error
|
||||
mov [esp + 36], dword 8 ; 32-bit protected-mode interface not supported
|
||||
ret
|
||||
|
||||
@@: xchg eax, ecx
|
||||
xchg ebx, ecx
|
||||
|
||||
cmp al, 3
|
||||
ja @f
|
||||
and [esp + 40], byte 0xfe ; emulate func 0..3 as func 0
|
||||
mov eax, [apm_vf]
|
||||
mov [esp + 36], eax
|
||||
shr eax, 16
|
||||
mov [esp + 32], eax
|
||||
ret
|
||||
|
||||
@@: call pword [apm_entry] ; call APM BIOS
|
||||
mov [esp + 8 ], edi
|
||||
mov [esp + 12], esi
|
||||
mov [esp + 24], ebx
|
||||
mov [esp + 28], edx
|
||||
mov [esp + 32], ecx
|
||||
mov [esp + 36], eax
|
||||
setc al
|
||||
and [esp + 40], byte 0xfe
|
||||
or [esp + 40], al
|
||||
ret
|
||||
; -----------------------------------------
|
||||
|
||||
align 4
|
||||
|
||||
undefined_syscall: ; Undefined system call
|
||||
|
@ -17,7 +17,9 @@
|
||||
; 0:9020 8bytes pci data
|
||||
; 0:9030 byte VRR start enabled 1, 2-no
|
||||
; 0:9031 word IDEContrRegsBaseAddr
|
||||
;
|
||||
; 0x9040 - dword - entry point of APM BIOS
|
||||
; 0x9044 - word - version (BCD)
|
||||
; 0x9046 - word - flags
|
||||
;
|
||||
; Runtime:
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user