From c9d4558817a724f591f8edb5c769469a74298dad Mon Sep 17 00:00:00 2001 From: "Marat Zakiyanov (Mario79)" Date: Sat, 6 May 2006 14:34:30 +0000 Subject: [PATCH] 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 --- kernel/trunk/boot/bootcode.inc | 942 +++++++++++++++++---------------- kernel/trunk/core/sys32.inc | 18 + kernel/trunk/core/syscall.inc | 2 +- kernel/trunk/docs/apm.zip | Bin 0 -> 7073 bytes kernel/trunk/kernel.asm | 58 +- kernel/trunk/memmap.inc | 4 +- 6 files changed, 567 insertions(+), 457 deletions(-) create mode 100644 kernel/trunk/docs/apm.zip diff --git a/kernel/trunk/boot/bootcode.inc b/kernel/trunk/boot/bootcode.inc index c478d7c7c7..7f721e8ddc 100644 --- a/kernel/trunk/boot/bootcode.inc +++ b/kernel/trunk/boot/bootcode.inc @@ -17,29 +17,29 @@ putchar: ; in: al=character - mov ah, 0Eh - mov bh, 0 - int 10h - ret + mov ah, 0Eh + mov bh, 0 + int 10h + ret print: ; in: si->string - mov al, 186 - call putchar - mov al, ' ' - call putchar + mov al, 186 + call putchar + mov al, ' ' + call putchar printplain: ; in: si->string - pusha - lodsb + pusha + lodsb @@: - call putchar - lodsb - cmp al, 0 - jnz @b - popa - ret + call putchar + lodsb + cmp al, 0 + jnz @b + popa + ret ; Now int 16 is used for keyboard support. ; This is shorter, simpler and more reliable. @@ -111,55 +111,55 @@ getkey: ; get number in range [bl,bh] (bl,bh in ['0'..'9']) ; in: bx=range ; out: ax=digit (1..9, 10 for 0) - mov ah, 0 - int 16h - cmp al, bl - jb getkey - cmp al, bh - ja getkey - push ax - call putchar - pop ax - and ax, 0Fh - jnz @f - mov al, 10 + mov ah, 0 + int 16h + cmp al, bl + jb getkey + cmp al, bh + ja getkey + push ax + call putchar + pop ax + and ax, 0Fh + jnz @f + mov al, 10 @@: - ret + ret setcursor: ; in: dl=column, dh=row - mov ah, 2 - mov bh, 0 - int 10h - ret + mov ah, 2 + mov bh, 0 + int 10h + ret macro _setcursor row,column { - mov dx, row*256 + column - call setcursor + mov dx, row*256 + column + call setcursor } pagetable_set: - or al, 7 + or al, 7 @@: - stosd - add eax, 1000h - loop @b - ret + stosd + add eax, 1000h + loop @b + ret ; 16-bit data ; videomodes table gr_table: - dw 0x112+0100000000000000b , 640 , 480 ; 1 - dw 0x115+0100000000000000b , 800 , 600 ; 2 - dw 0x118+0100000000000000b , 1024 , 768 ; 3 - dw 0x11B+0100000000000000b , 1280 , 1024 ; 4 - dw 0x112 , 640 , 480 ; 5 - dw 0x115 , 800 , 600 ; 6 - dw 0x118 , 1024 , 768 ; 7 - dw 0x11B , 1280 ,1024 ; 8 - dw 0x13, 320, 200 ; 9 - dw 0x12, 640, 480 ; 0 + dw 0x112+0100000000000000b , 640 , 480 ; 1 + dw 0x115+0100000000000000b , 800 , 600 ; 2 + dw 0x118+0100000000000000b , 1024 , 768 ; 3 + dw 0x11B+0100000000000000b , 1280 , 1024 ; 4 + dw 0x112 , 640 , 480 ; 5 + dw 0x115 , 800 , 600 ; 6 + dw 0x118 , 1024 , 768 ; 7 + dw 0x11B , 1280 ,1024 ; 8 + dw 0x13, 320, 200 ; 9 + dw 0x12, 640, 480 ; 0 ; table for move to extended memory (int 15h, ah=87h) movedesc: @@ -182,27 +182,27 @@ gr_table: start_of_code: - cld + cld ; \begin{diamond}[02.12.2005] - cmp ax, 'KL' - jnz @f - mov word [cs:cfgmanager.loader_block-0x10000], si - mov word [cs:cfgmanager.loader_block+2-0x10000], ds + cmp ax, 'KL' + jnz @f + mov word [cs:cfgmanager.loader_block-0x10000], si + mov word [cs:cfgmanager.loader_block+2-0x10000], ds @@: ; \end{diamond}[02.12.2005] ; set up stack - mov ax, 3000h - mov ss, ax - mov sp, 0EC00h + mov ax, 3000h + mov ss, ax + mov sp, 0EC00h ; set up segment registers - push cs - pop ds - push cs - pop es + push cs + pop ds + push cs + pop es ; set videomode - mov ax, 3 + mov ax, 3 int 0x10 ; Load & set russian VGA font (RU.INC) @@ -222,9 +222,9 @@ start_of_code: ; End set VGA russian font ; draw frames - push 0xb800 - pop es - xor di, di + push 0xb800 + pop es + xor di, di ; mov si,d80x25-0x10000 ; mov cx,80*25 ; mov ah,1*16+15 @@ -232,44 +232,44 @@ start_of_code: ; lodsb ; stosw ; loop dfl1 - mov ah, 1*16+15 + mov ah, 1*16+15 ; draw top - mov si, d80x25_top - 0x10000 - mov cx, d80x25_top_num * 80 + mov si, d80x25_top - 0x10000 + mov cx, d80x25_top_num * 80 @@: - lodsb - stosw - loop @b + lodsb + stosw + loop @b ; draw spaces - mov si, space_msg - 0x10000 - mov cx, 25 - d80x25_top_num - d80x25_bottom_num + mov si, space_msg - 0x10000 + mov cx, 25 - d80x25_top_num - d80x25_bottom_num dfl1: - push cx - push si - mov cx, 80 + push cx + push si + mov cx, 80 @@: - lodsb - stosw - loop @b - pop si - pop cx - loop dfl1 + lodsb + stosw + loop @b + pop si + pop cx + loop dfl1 ; draw bottom - mov si, d80x25_bottom - 0x10000 - mov cx, d80x25_bottom_num * 80 + mov si, d80x25_bottom - 0x10000 + mov cx, d80x25_bottom_num * 80 @@: - lodsb - stosw - loop @b + lodsb + stosw + loop @b - mov byte [space_msg-0x10000+80], 0 ; now space_msg is null terminated + mov byte [space_msg-0x10000+80], 0 ; now space_msg is null terminated - _setcursor d80x25_top_num,0 + _setcursor d80x25_top_num,0 ; TEST FOR 386+ - mov bx, 0x4000 + mov bx, 0x4000 pushf pop ax mov dx,ax @@ -289,7 +289,7 @@ sayerr: cpugood: ; set up esp - movzx esp, sp + movzx esp, sp ; FLUSH 8042 KEYBOARD CONTROLLER @@ -344,19 +344,71 @@ 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 - pop es + push 0 + pop es mov ax,0x4f00 mov di,0xa000 int 0x10 cmp ax,0x004f - mov si, novesa-0x10000 - jnz @f + mov si, novesa-0x10000 + jnz @f mov ax,[es:di+4] add ax,'0'*256+'0' - mov si,vervesa-0x10000 + mov si,vervesa-0x10000 mov [si+vervesa_off], ah mov [si+vervesa_off+2], al @@: call print @@ -369,209 +421,209 @@ cfgmanager: ; b) preboot_mtrr = use hardware acceleration? ; c) preboot_vrrm = use VRR? ; d) preboot_device = from what boot? - mov di, preboot_graph-0x10000 + mov di, preboot_graph-0x10000 ; check bootloader block - cmp [.loader_block-0x10000], 0 - jz .noloaderblock - les bx, [.loader_block-0x10000] - cmp byte [es:bx], 1 - mov si, loader_block_error-0x10000 - jnz sayerr - test byte [es:bx+1], 1 - jz @f + cmp [.loader_block-0x10000], 0 + jz .noloaderblock + les bx, [.loader_block-0x10000] + cmp byte [es:bx], 1 + mov si, loader_block_error-0x10000 + jnz sayerr + test byte [es:bx+1], 1 + jz @f ; image in memory present - cmp [di+preboot_device-preboot_graph], 0 - jnz @f - mov [di+preboot_device-preboot_graph], 3 + cmp [di+preboot_device-preboot_graph], 0 + jnz @f + mov [di+preboot_device-preboot_graph], 3 @@: .noloaderblock: ; determine default settings - mov [.bSettingsChanged-0x10000], 0 - cmp byte [di], 0 - jnz .preboot_gr_end - mov [di+preboot_gprobe-preboot_graph], 0 - mov al, [vervesa+vervesa_off-0x10000] - cmp al, 'x' - jz .novesa - cmp al, '1' - jz .vesa12 - mov [di+preboot_gprobe-preboot_graph], 2 - mov al, 3 - jmp @f + mov [.bSettingsChanged-0x10000], 0 + cmp byte [di], 0 + jnz .preboot_gr_end + mov [di+preboot_gprobe-preboot_graph], 0 + mov al, [vervesa+vervesa_off-0x10000] + cmp al, 'x' + jz .novesa + cmp al, '1' + jz .vesa12 + mov [di+preboot_gprobe-preboot_graph], 2 + mov al, 3 + jmp @f .vesa12: - mov al, 7 - jmp @f + mov al, 7 + jmp @f .novesa: - mov al, 10 + mov al, 10 @@: - mov [di], al + mov [di], al .preboot_gr_end: - cmp [di+preboot_mtrr-preboot_graph], 1 - adc [di+preboot_mtrr-preboot_graph], 0 - cmp [di+preboot_vrrm-preboot_graph], 1 - adc [di+preboot_vrrm-preboot_graph], 0 - cmp [di+preboot_device-preboot_graph], 1 - adc [di+preboot_device-preboot_graph], 0 + cmp [di+preboot_mtrr-preboot_graph], 1 + adc [di+preboot_mtrr-preboot_graph], 0 + cmp [di+preboot_vrrm-preboot_graph], 1 + adc [di+preboot_vrrm-preboot_graph], 0 + cmp [di+preboot_device-preboot_graph], 1 + adc [di+preboot_device-preboot_graph], 0 ; notify user - mov si, linef-0x10000 - call print - mov si, start_msg-0x10000 - call print - mov si, time_msg-0x10000 - call print + mov si, linef-0x10000 + call print + mov si, start_msg-0x10000 + call print + mov si, time_msg-0x10000 + call print ; get start time - call .gettime - mov [.starttime-0x10000], eax - mov word [.timer-0x10000], .newtimer-0x10000 - mov word [.timer-0x10000+2], cs + call .gettime + mov [.starttime-0x10000], eax + mov word [.timer-0x10000], .newtimer-0x10000 + mov word [.timer-0x10000+2], cs .printcfg: - _setcursor 9,0 - mov si, current_cfg_msg-0x10000 - call print - mov si, curvideo_msg-0x10000 - call print - mov al, [preboot_graph-0x10000] - cmp al, 8 - ja .pnovesa - mov dl, al - and eax, 3 - mov si, [modes_msg-0x10000+eax*2] - call printplain - mov si, modevesa20-0x10000 - cmp dl, 4 - jbe @f - mov si, modevesa12-0x10000 + _setcursor 9,0 + mov si, current_cfg_msg-0x10000 + call print + mov si, curvideo_msg-0x10000 + call print + mov al, [preboot_graph-0x10000] + cmp al, 8 + ja .pnovesa + mov dl, al + and eax, 3 + mov si, [modes_msg-0x10000+eax*2] + call printplain + mov si, modevesa20-0x10000 + cmp dl, 4 + jbe @f + mov si, modevesa12-0x10000 @@: - call printplain - cmp dl, 4 - ja .x - mov si, probeno_msg-0x10000 - cmp [preboot_gprobe-0x10000], 2 - jnz @f - mov si, probeok_msg-0x10000 + call printplain + cmp dl, 4 + ja .x + mov si, probeno_msg-0x10000 + cmp [preboot_gprobe-0x10000], 2 + jnz @f + mov si, probeok_msg-0x10000 @@: - call printplain + call printplain .x: - jmp .c + jmp .c .pnovesa: - cmp al, 9 - mov si, mode9-0x10000 - jz @b - mov si, mode10-0x10000 - jmp @b + cmp al, 9 + mov si, mode9-0x10000 + jz @b + mov si, mode10-0x10000 + jmp @b .c: - mov si, linef-0x10000 - call printplain - mov si, mtrr_msg-0x10000 - cmp [preboot_mtrr-0x10000], 1 - call .say_on_off - mov si, vrrm_msg-0x10000 - cmp [preboot_vrrm-0x10000], 1 - call .say_on_off - mov si, preboot_device_msg-0x10000 - call print - mov al, [preboot_device-0x10000] - and eax, 3 - mov si, [preboot_device_msgs-0x10000+eax*2] - call printplain + mov si, linef-0x10000 + call printplain + mov si, mtrr_msg-0x10000 + cmp [preboot_mtrr-0x10000], 1 + call .say_on_off + mov si, vrrm_msg-0x10000 + cmp [preboot_vrrm-0x10000], 1 + call .say_on_off + mov si, preboot_device_msg-0x10000 + call print + mov al, [preboot_device-0x10000] + and eax, 3 + mov si, [preboot_device_msgs-0x10000+eax*2] + call printplain .wait: - _setcursor 25,0 ; out of screen + _setcursor 25,0 ; out of screen ; set timer interrupt handler - cli - push 0 - pop es - mov eax, [es:8*4] - mov [.oldtimer-0x10000], eax - mov eax, [.timer-0x10000] - mov [es:8*4], eax - sti + cli + push 0 + pop es + mov eax, [es:8*4] + mov [.oldtimer-0x10000], eax + mov eax, [.timer-0x10000] + mov [es:8*4], eax + sti ; wait for keypressed - mov ah, 0 - int 16h - push ax + mov ah, 0 + int 16h + push ax ; restore timer interrupt - push 0 - pop es - mov eax, [.oldtimer-0x10000] - mov [es:8*4], eax - mov [.timer-0x10000], eax - _setcursor 7,0 - mov si, space_msg-0x10000 - call printplain - pop ax + push 0 + pop es + mov eax, [.oldtimer-0x10000] + mov [es:8*4], eax + mov [.timer-0x10000], eax + _setcursor 7,0 + mov si, space_msg-0x10000 + call printplain + pop ax ; switch on key - cmp al, 13 - jz .continue - or al, 20h - cmp al, 'a' - jz .change_a - cmp al, 'b' - jz .change_b - cmp al, 'c' - jz .change_c - cmp al, 'd' - jnz .wait - _setcursor 15,0 - mov si,bdev-0x10000 - call print - mov bx,'13' - call getkey - mov [preboot_device-0x10000], al - _setcursor 13,0 + cmp al, 13 + jz .continue + or al, 20h + cmp al, 'a' + jz .change_a + cmp al, 'b' + jz .change_b + cmp al, 'c' + jz .change_c + cmp al, 'd' + jnz .wait + _setcursor 15,0 + mov si,bdev-0x10000 + call print + mov bx,'13' + call getkey + mov [preboot_device-0x10000], al + _setcursor 13,0 .d: - mov [.bSettingsChanged-0x10000], 1 - mov si, space_msg-0x10000 - call printplain - _setcursor 15,0 - mov cx, 6 + mov [.bSettingsChanged-0x10000], 1 + mov si, space_msg-0x10000 + call printplain + _setcursor 15,0 + mov cx, 6 @@: - call printplain - loop @b - jmp .printcfg + call printplain + loop @b + jmp .printcfg .change_a: - _setcursor 15,0 - mov si, gr_mode-0x10000 - call printplain - mov bx, '09' - call getkey - mov [preboot_graph-0x10000], al - cmp al, 4 - ja @f - mov si, probetext-0x10000 - call printplain - mov bx, '12' - call getkey - mov [preboot_gprobe-0x10000], al + _setcursor 15,0 + mov si, gr_mode-0x10000 + call printplain + mov bx, '09' + call getkey + mov [preboot_graph-0x10000], al + cmp al, 4 + ja @f + mov si, probetext-0x10000 + call printplain + mov bx, '12' + call getkey + mov [preboot_gprobe-0x10000], al @@: - _setcursor 10,0 - jmp .d + _setcursor 10,0 + jmp .d .change_b: - _setcursor 15,0 - mov si, gr_acc-0x10000 - call print - mov bx, '12' - call getkey - mov [preboot_mtrr-0x10000], al - _setcursor 11,0 - jmp .d + _setcursor 15,0 + mov si, gr_acc-0x10000 + call print + mov bx, '12' + call getkey + mov [preboot_mtrr-0x10000], al + _setcursor 11,0 + jmp .d .change_c: - _setcursor 15,0 - mov si, vrrmprint-0x10000 - call print - mov bx, '12' - call getkey - mov [preboot_vrrm-0x10000], al - _setcursor 12,0 - jmp .d + _setcursor 15,0 + mov si, vrrmprint-0x10000 + call print + mov bx, '12' + call getkey + mov [preboot_vrrm-0x10000], al + _setcursor 12,0 + jmp .d .say_on_off: - pushf - call print - mov si, on_msg-0x10000 - popf - jz @f - mov si, off_msg-0x10000 -@@: call printplain - ret + pushf + call print + mov si, on_msg-0x10000 + popf + jz @f + mov si, off_msg-0x10000 +@@: call printplain + ret ; novesa and vervesa strings are not used at the moment of executing this code virtual at novesa .oldtimer dd ? @@ -581,168 +633,168 @@ virtual at novesa end virtual .loader_block dd 0 .gettime: - mov ah, 0 - int 1Ah - xchg ax, cx - shl eax, 10h - xchg ax, dx - ret + mov ah, 0 + int 1Ah + xchg ax, cx + shl eax, 10h + xchg ax, dx + ret .newtimer: - push ds - push cs - pop ds - pushf - call [.oldtimer-0x10000] - pushad - call .gettime - sub eax, [.starttime-0x10000] - sub ax, 18*5 - jae .timergo - neg ax - add ax, 18-1 - mov bx, 18 - xor dx, dx - div bx + push ds + push cs + pop ds + pushf + call [.oldtimer-0x10000] + pushad + call .gettime + sub eax, [.starttime-0x10000] + sub ax, 18*5 + jae .timergo + neg ax + add ax, 18-1 + mov bx, 18 + xor dx, dx + div bx if lang eq ru ; подождите 5 секунд, 4/3/2 секунды, 1 секунду - cmp al, 5 - mov cl, ' ' - jae @f - cmp al, 1 - mov cl, 'у' - jz @f - mov cl, 'ы' -@@: mov [time_str+9-0x10000], cl + cmp al, 5 + mov cl, ' ' + jae @f + cmp al, 1 + mov cl, 'у' + jz @f + mov cl, 'ы' +@@: mov [time_str+9-0x10000], cl else ; wait 5/4/3/2 seconds, 1 second - cmp al, 1 - mov cl, 's' - ja @f - mov cl, ' ' -@@: mov [time_str+9-0x10000], cl + cmp al, 1 + mov cl, 's' + ja @f + mov cl, ' ' +@@: mov [time_str+9-0x10000], cl end if - add al, '0' - mov [time_str+1-0x10000], al - mov si, time_msg-0x10000 - _setcursor 7,0 - call print - _setcursor 25,0 - popad - pop ds - iret + add al, '0' + mov [time_str+1-0x10000], al + mov si, time_msg-0x10000 + _setcursor 7,0 + call print + _setcursor 25,0 + popad + pop ds + iret .timergo: - push 0 - pop es - mov eax, [.oldtimer-0x10000] - mov [es:8*4], eax - mov sp, 0EC00h + push 0 + pop es + mov eax, [.oldtimer-0x10000] + mov [es:8*4], eax + mov sp, 0EC00h .continue: - sti - _setcursor 6,0 - mov si, space_msg-0x10000 - call printplain - call printplain - _setcursor 6,0 - mov si, loading_msg-0x10000 - call print - _setcursor 15,0 - cmp [.bSettingsChanged-0x10000], 0 - jz .load - cmp [.loader_block-0x10000], 0 - jz .load - les bx, [.loader_block-0x10000] - mov eax, [es:bx+3] - push ds - pop es - test eax, eax - jz .load - push eax - mov si, save_quest-0x10000 - call print + sti + _setcursor 6,0 + mov si, space_msg-0x10000 + call printplain + call printplain + _setcursor 6,0 + mov si, loading_msg-0x10000 + call print + _setcursor 15,0 + cmp [.bSettingsChanged-0x10000], 0 + jz .load + cmp [.loader_block-0x10000], 0 + jz .load + les bx, [.loader_block-0x10000] + mov eax, [es:bx+3] + push ds + pop es + test eax, eax + jz .load + push eax + mov si, save_quest-0x10000 + call print .waityn: - mov ah, 0 - int 16h - or al, 20h - cmp al, 'n' - jz .loadc - cmp al, 'y' - jnz .waityn - call putchar - mov byte [space_msg-0x10000+80], 186 - pop eax - push cs - push .cont-0x10000 - push eax - retf + mov ah, 0 + int 16h + or al, 20h + cmp al, 'n' + jz .loadc + cmp al, 'y' + jnz .waityn + call putchar + mov byte [space_msg-0x10000+80], 186 + pop eax + push cs + push .cont-0x10000 + push eax + retf .loadc: - pop eax + pop eax .cont: - push cs - pop ds - mov si, space_msg-0x10000 - mov byte [si+80], 0 - _setcursor 15,0 - call printplain - _setcursor 15,0 + push cs + pop ds + mov si, space_msg-0x10000 + mov byte [si+80], 0 + _setcursor 15,0 + call printplain + _setcursor 15,0 .load: ; \end{diamond}[02.12.2005] ; ASK GRAPHICS MODE - movzx ax, [preboot_graph-0x10000] - push 0 - pop es + movzx ax, [preboot_graph-0x10000] + push 0 + pop es ; address is gr_table+6*(ax-1)-0x10000 - add ax, ax - lea si, [gr_table-0x10000 + eax + eax*2 - 6] + add ax, ax + lea si, [gr_table-0x10000 + eax + eax*2 - 6] mov bx,[si+0] mov cx,[si+2] mov dx,[si+4] - cmp al, 9*2 - mov al, 32 ; BPP - jb @f - mov [es:0x9000], al - mov dword [es:0x9018], 0x800000 + cmp al, 9*2 + mov al, 32 ; BPP + jb @f + mov [es:0x9000], al + mov dword [es:0x9018], 0x800000 @@: mov [es:0x9008],bx mov [es:0x900A],cx mov [es:0x900C],dx - test bh, bh - jz nov + test bh, bh + jz nov ; USE DEFAULTS OR PROBE ; bx - mode : cx - x size : dx - y size - cmp [preboot_gprobe-0x10000], 1 - jz noprobe + cmp [preboot_gprobe-0x10000], 1 + jz noprobe mov bx,0x100 newprobe: inc bx cmp bx,0x17f - mov si,prnotfnd-0x10000 - jz sayerr + mov si,prnotfnd-0x10000 + jz sayerr probemore: - push cx + push cx mov ax,0x4f01 mov cx,bx and cx,0xfff mov di,0xa000 int 0x10 - pop cx + pop cx - test byte [es:di], 80h ; lfb? - jz newprobe - cmp [es:di+0x12], cx ; x size? - jnz newprobe - cmp [es:di+0x14], dx ; y size? - jnz newprobe - cmp byte [es:di+0x19], 32 ;24 - jb newprobe + test byte [es:di], 80h ; lfb? + jz newprobe + cmp [es:di+0x12], cx ; x size? + jnz newprobe + cmp [es:di+0x14], dx ; y size? + jnz newprobe + cmp byte [es:di+0x19], 32 ;24 + jb newprobe ; add bx,0100000000000000b - or bh, 40h + or bh, 40h mov [es:0x9008],bx noprobe: @@ -767,22 +819,22 @@ end if mov [es:0x9000],al nov: cmp al,24 - mov si,bt24-0x10000 - jz bppl + mov si,bt24-0x10000 + jz bppl cmp al,32 mov si,bt32-0x10000 jz bppl mov si,btns-0x10000 - jmp sayerr + jmp sayerr bppl: call print ; FIND VESA 1.2 PM BANK SWITCH ADDRESS - push es + push es mov ax,0x4f0A - xor bx, bx + xor bx, bx int 0x10 xor eax,eax mov ax,es @@ -890,7 +942,7 @@ end if ; BOOT DEVICE - mov al, [preboot_device-0x10000] + mov al, [preboot_device-0x10000] dec al mov [boot_dev-0x10000],al @@ -900,11 +952,11 @@ end if jne no_sys_on_floppy mov si,diskload-0x10000 call print - xor ax, ax ; reset drive - xor dx, dx + xor ax, ax ; reset drive + xor dx, dx int 0x13 mov cx,0x0001 ; startcyl,startsector - xor dx, dx ; starthead,drive + xor dx, dx ; starthead,drive push word 80*2 ; read no of sect reads: pusha @@ -913,9 +965,9 @@ end if mov bx,0xa000 ; es:bx -> data area mov ax,0x0200+18 ; read, no of sectors to read int 0x13 - test ah, ah + test ah, ah jz goodread - inc si + inc si cmp si,10 jnz newread mov si,badsect-0x10000 @@ -925,13 +977,13 @@ sayerr_plain: goodread: ; move -> 1mb mov si,movedesc-0x10000 - push es - push ds + push es + push ds pop es mov cx,256*18 mov ah,0x87 int 0x15 - pop es + pop es test ah,ah ; was the move successfull ? je goodmove @@ -939,10 +991,10 @@ sayerr_plain: mov al,0 out dx,al mov si,memmovefailed-0x10000 - jmp sayerr_plain + jmp sayerr_plain goodmove: - add dword [movedesc-0x10000+0x18+2], 512*18 + add dword [movedesc-0x10000+0x18+2], 512*18 popa inc dh cmp dh,2 @@ -951,16 +1003,16 @@ sayerr_plain: inc ch pusha ; print prosentage mov si,pros-0x10000 - shr ch, 2 - mov al, '5' - test ch, 1 - jnz @f - mov al, '0' + shr ch, 2 + mov al, '5' + test ch, 1 + jnz @f + mov al, '0' @@: - mov [si+1], al - shr ch, 1 - add ch, '0' - mov [si], ch + mov [si+1], al + shr ch, 1 + add ch, '0' + mov [si], ch call printplain popa bb2: @@ -975,22 +1027,22 @@ sayerr_plain: mov si,okt-0x10000 call printplain no_sys_on_floppy: - xor ax, ax ; reset drive - xor dx, dx + xor ax, ax ; reset drive + xor dx, dx int 0x13 mov dx,0x3f2 ; floppy motor off mov al,0 out dx,al - push es + push es ; PAGE TABLE - push dword [es:0x9018] + push dword [es:0x9018] map_mem equ 64 ; amount of memory to map - push 0x6000 - pop es ; es:di = 6000:0 + push 0x6000 + pop es ; es:di = 6000:0 xor di,di mov cx,256*map_mem ; Map (mapmem) M ; mov eax,7 @@ -1008,30 +1060,30 @@ sayerr_plain: ; add eax,4096 ; loop pt2 ; initialize as identity mapping - xor eax, eax - call pagetable_set + xor eax, eax + call pagetable_set ; 8M..12M map to LFB - pop eax -; mov cx, 256*4 - mov ch, 4 - mov di, 2000h - call pagetable_set + pop eax +; mov cx, 256*4 + mov ch, 4 + mov di, 2000h + call pagetable_set - push 0x7100 - pop es + push 0x7100 + pop es xor di,di mov eax,8*0x100000 mov cx,256*4 - call pagetable_set + call pagetable_set ; 4 KB PAGE DIRECTORY - push 0x7F00 - pop es ; es:di = 7F00:0 + push 0x7F00 + pop es ; es:di = 7F00:0 xor di, di mov cx, 64 / 4 mov eax, 0x60007 ; for 0 M - call pagetable_set + call pagetable_set mov dword [es:0x800],0x71007 ;map region 0x80000000-0x803FFFFF to 0x800000-0xCFFFFF xor si,si mov di,second_base_address shr 20 @@ -1043,9 +1095,9 @@ sayerr_plain: ; SET GRAPHICS - pop es - mov ax,[es:0x9008] ; vga & 320x200 - mov bx, ax + pop es + mov ax,[es:0x9008] ; vga & 320x200 + mov bx, ax cmp ax,0x13 je setgr cmp ax,0x12 @@ -1053,9 +1105,9 @@ sayerr_plain: mov ax,0x4f02 ; Vesa setgr: int 0x10 - test ah,ah - mov si, fatalsel-0x10000 - jnz sayerr + test ah,ah + mov si, fatalsel-0x10000 + jnz sayerr ; set mode 0x12 graphics registers: cmp bx,0x12 jne gmok2 @@ -1065,21 +1117,21 @@ sayerr_plain: push dx out dx,al ; select GDC mode register mov al,0x02 - inc dx + inc dx out dx,al ; set write mode 2 mov al,0x02 mov dx,0x03c4 out dx,al ; select VGA sequencer map mask register mov al,0x0f - inc dx + inc dx out dx,al ; set mask for all planes 0-3 mov al,0x08 - pop dx + pop dx out dx,al ; select GDC bit mask register ; for writes to 0x03cf gmok2: - push ds - pop es + push ds + pop es diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index b5ed7e1906..9b0079b279 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -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 diff --git a/kernel/trunk/core/syscall.inc b/kernel/trunk/core/syscall.inc index 004cf59700..c0e657bb3e 100644 --- a/kernel/trunk/core/syscall.inc +++ b/kernel/trunk/core/syscall.inc @@ -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 diff --git a/kernel/trunk/docs/apm.zip b/kernel/trunk/docs/apm.zip new file mode 100644 index 0000000000000000000000000000000000000000..89d59d08eeab4216ea99c7b0ca7a556a9347187c GIT binary patch literal 7073 zcmZ{JWl$UdukE4>6o|5&(-*mZtn#UO=tO`gOaMoh?46kq&L- zjfV$@6TN*Aj}tq_9&TJd>6;sM*ABDSn;Si!!t$17!cKXwhLPUu9veG%Y=w>cGo_yC z4~V%lH(9hNLdXwy&a=G9=nDKthd5ep+Cc31h_qFp?}ctVFrn_y-kx=W)i<-@f$>E2`mBw7KW;CzG``64IzYlo>=3p|8 zd?=I+=}vzNXbV~*`90-wasVt7KH|eCisX(b5c2Eb+~VCZuwxL%`-yG=%>k{P@z>#C z#3`&Twbw&aBTom>7A>HiHb(vK#37%mNt|C&Rz=6r)5(7}@$rJrSgHSZ`@%7GT(9is zlGbzCVp>g2vmDEP>|mo6{1SS>9o9|I4753RDnHjl`smI&22JN((c{2FpDsluqT~V@e<8CoQsRsqdr9Lu zQfssXe|Wg#JMvqD4%#HT*UHaeH)3C^JuHk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