kos-acpi: framebuffer initialization

git-svn-id: svn://kolibrios.org@6246 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2016-02-18 14:37:40 +00:00
parent 4973638f8d
commit bbc41a6fd1
9 changed files with 384 additions and 198 deletions

View File

@ -359,7 +359,6 @@ free_blocks rd 1
mem_block_mask rd 2
next_memblock rd 1
mst MEM_STATE
pte_valid_mask rd 1
@ -375,6 +374,7 @@ srv.bk rd 1
align 16
_display display_t
bios_fb FRB
LFBAddress dd ?

View File

@ -1048,36 +1048,38 @@ dd 1675
* ebx = 19 - номер подфункции
* ecx = 0 - номер подподфункции
Возвращаемое значение:
* eax = текущая скорость мыши
* eax = текущий делитель скорости
------------ Подподфункция 1 - установить скорость мыши. -------------
Параметры:
* eax = 18 - номер функции
* ebx = 19 - номер подфункции
* ecx = 1 - номер подподфункции
* edx = новое значение скорости
* edx = новое значение делителя скорости
Возвращаемое значение:
* функция не возвращает значения
Замечание: рекомендуемая скорость = 1, 0 = заблокировать курсор.
Замечание: рекомендуемый делитель скорости = 4
------------- Подподфункция 2 - получить ускорение мыши. -------------
---------- Подподфункция 2 - получить чувствительность мыши ----------
Параметры:
* eax = 18 - номер функции
* ebx = 19 - номер подфункции
* ecx = 2 - номер подподфункции
Возвращаемое значение:
* eax = 0 - выключить, 1 - слабое, 2 - среднее, 3 - сильное
* eax = текущий коэффициент чувствительности
------------ Подподфункция 3 - установить ускорение мыши. ------------
--------- Подподфункция 3 - установить чувствительность мыши ---------
Параметры:
* eax = 18 - номер функции
* ebx = 19 - номер подфункции
* ecx = 3 - номер подподфункции
* edx = 0 - выключить, 1 - слабое, 2 - среднее, 3 - сильное
* edx = новое значение коэффициента чувствительности
Возвращаемое значение:
* функция не возвращает значения
Замечание: рекомендуемый коэффициент чувствительности = 3
-------- Подподфункция 4 - установить положение курсора мыши. --------
Параметры:
* eax = 18 - номер функции
@ -4537,7 +4539,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
eax - SF_NETWORK_GET (74)
bl - SSF_LINK_STATUS (10)
======================================================================
======= Функция 75, подфункция 0, Open socket (Открыть сокет). =======
============== Функция 75, подфункция 0, Открыть сокет. ==============
======================================================================
Параметры:
* eax = 75 - номер функции
@ -4553,7 +4555,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
eax - SF_NETWORK_SOCKET (75)
bl - SSF_OPEN (0)
======================================================================
======= Функция 75, подфункция 1, Close socket (Закрыть сокет). ======
============== Функция 75, подфункция 1, Закрыть сокет. ==============
======================================================================
Параметры:
* eax = 75 - номер функции
@ -4664,7 +4666,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
eax - SF_NETWORK_SOCKET (75)
bl - SSF_RECEIVE (7)
======================================================================
= Функция 75, подфункция 8, Set socket options (Задать опции сокета) =
=========== Функция 75, подфункция 8, Задать опции сокета. ===========
======================================================================
Параметры:
* eax = 75 - номер функции
@ -4685,7 +4687,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
eax - SF_NETWORK_SOCKET (75)
bl - SSF_SET_OPTIONS (8)
======================================================================
= Функция 75, подфункция 9, Get socket options(Получить опции сокета)
========== Функция 75, подфункция 9, Получить опции сокета. ==========
======================================================================
Параметры:
* eax = 75 - номер функции
@ -4706,14 +4708,14 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
eax - SF_NETWORK_SOCKET (75)
bl - SSF_GET_OPTIONS (9)
======================================================================
= Функция 75, подфункция 10, Get socketpair (Получить парный сокет). =
========== Функция 75, подфункция 10, Получить парный сокет ==========
======================================================================
Параметры:
* eax = 75 - номер функции
* bl = 10 - номер подфункции
Возвращаемое значение:
* eax = socketnum1, -1 для ошибки
* ebx = socketnum2, код ошибки в случае ошибки
* eax = номер первого сокета / -1 для ошибки
* ebx = номер второго сокета / код ошибки
---------------------- Константы для регистров: ----------------------
eax - SF_NETWORK_SOCKET (75)
@ -4727,12 +4729,16 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
* bh = номер устройства
* bl = номер подфункции
Ethernet (0)
Протоколы и подфункции:
0 - Ethernet:
0 - Read MAC
IPv4 (1)
0 - Read # IP packets sent
1 - Read # IP packets received
общие подфункции:
0 - пакетов послано
1 - пакетов принято
1 - IPv4:
2 - Read IP
3 - Write IP
4 - Read DNS
@ -4742,22 +4748,13 @@ IPv4 (1)
8 - Read gateway
9 - Write gateway
ICMP (2)
0 - Read # ICMP packets sent
1 - Read # ICMP packets received
2 - ICMP:
3 - enable/disable ICMP echo reply
UDP (3)
0 - Read # UDP packets sent
1 - Read # UDP packets received
3 - UDP
4 - TCP
TCP (4)
0 - Read # TCP packets sent
1 - Read # TCP packets received
ARP (5)
0 - Read # ARP packets sent
1 - Read # ARP packets received
5 - ARP:
2 - Read # ARP entry's
3 - Read ARP entry
4 - Add static ARP entry
@ -4768,6 +4765,64 @@ ARP (5)
---------------------- Константы для регистров: ----------------------
eax - SF_NETWORK_PROTOCOL (76)
======================================================================
============= Функция 77, подфункция 0, Создать фьютекс. =============
======================================================================
Параметры:
* eax = 77 - номер функции
* ebx = 0 - номер подфункции
* ecx = указатель на контрольное значение фьютекса (dword)
Возвращаемое значение:
* eax = дескриптор фьютекса, 0 при ошибке
---------------------- Константы для регистров: ----------------------
eax - SF_FUTEX (77)
ebx - SSF_CREATE (0)
======================================================================
============= Функция 77, подфункция 1, Удалить фьютекс. =============
======================================================================
Параметры:
* eax = 77 - номер функции
* ebx = 1 - номер подфункции
* ecx = дескриптор фьютекса
Возвращаемое значение:
* eax = 0 - успешно, -1 при ошибке
Замечания:
* Ядро автоматически удаляет фьютексы при завершении процесса.
---------------------- Константы для регистров: ----------------------
eax - SF_FUTEX (77)
ebx - SSF_DESTROY (1)
======================================================================
================= Функция 77, подфункция 2, Ожидать. =================
======================================================================
Параметры:
* eax = 77 - номер функции
* ebx = 2 - номер подфункции
* ecx = дескриптор фьютекса
* edx = контрольное значение
* esi = таймаут в сотых секунды, 0 - ждать бесконечно
Возвращаемое значение:
* eax = 0 - успешно, -1 - таймаут,
-2 - контрольное значение не соответствует
---------------------- Константы для регистров: ----------------------
eax - SF_FUTEX (77)
ebx - SSF_WAIT (2)
======================================================================
================ Функция 77, подфункция 3, Разбудить. ================
======================================================================
Параметры:
* eax = 77 - номер функции
* ebx = 3 - номер подфункции
* ecx = дескриптор фьютекса
* edx = сколько ожидающих будить (максимум)
Возвращаемое значение:
* eax = количество разбуженых
---------------------- Константы для регистров: ----------------------
eax - SF_FUTEX (77)
ebx - SSF_WAKE (3)
======================================================================
========== Функция -1 - завершить выполнение потока/процесса =========
======================================================================
Параметры:
@ -4821,18 +4876,17 @@ ARP (5)
==================== Коды ошибок файловой системы ====================
======================================================================
* 0 = успешно
* 1 = не определена база и/или раздел жёсткого диска (подфункциями
7, 8 функции 21)
* 2 = функция не поддерживается для данной файловой системы
* 3 = неизвестная файловая система
* 4 = зарезервировано, никогда не возвращается в текущей реализации
* 5 = файл не найден
* 6 = файл закончился
* 7 = указатель вне памяти приложения
* 8 = диск заполнен
* 9 = таблица FAT разрушена
* 9 = ошибка файловой системы
* 10 = доступ запрещён
* 11 = ошибка устройства
* 12 = файловой системе недостаточно оперативной памяти
При запуске программы возможны также следующие коды ошибок:
* 30 = 0x1E = недостаточно памяти
* 31 = 0x1F = файл не является исполнимым

View File

@ -1041,36 +1041,38 @@ Parameters:
* ebx = 19 - subfunction number
* ecx = 0 - subsubfunction number
Returned value:
* eax = current mouse speed
* eax = current speed divider
---------------- Subsubfunction 1 - set mouse speed. -----------------
Parameters:
* eax = 18 - function number
* ebx = 19 - subfunction number
* ecx = 1 - subsubfunction number
* edx = new value for speed
* edx = new value for speed divider
Returned value:
* function does not return value
Remark: recommended speed = 1, 0 = lock the cursor.
Remark: recommended speed divider = 4
------------- Subsubfunction 2 - get mouse acceleration. -------------
-------------- Subsubfunction 2 - get mouse sensitivity --------------
Parameters:
* eax = 18 - function number
* ebx = 19 - subfunction number
* ecx = 2 - subsubfunction number
Returned value:
* eax = 0 - off, 1 - slight, 2 - medium, 3 - intense
* eax = current sensitivity
------------- Subsubfunction 3 - set mouse acceleration. -------------
-------------- Subsubfunction 3 - set mouse sensitivity --------------
Parameters:
* eax = 18 - function number
* ebx = 19 - subfunction number
* ecx = 3 - subsubfunction number
* edx = 0 - off, 1 - slight, 2 - medium, 3 - intense
* edx = new value for sensitivity
Returned value:
* function does not return value
Remark: recommended sensitivity = 3
----------- Subsubfunction 4 - set mouse pointer position. -----------
Parameters:
* eax = 18 - function number
@ -4667,7 +4669,7 @@ Remarks:
eax - SF_NETWORK_SOCKET (75)
bl - SSF_GET_OPTIONS (9)
======================================================================
============ Function 75, Subfunction 10, Get socketpair. ===========
============ Function 75, Subfunction 10, Get socketpair. ============
======================================================================
Parameters:
* eax = 75 - function number
@ -4688,12 +4690,16 @@ Parameters:
* bh = device number
* bl = subfunction number
Ethernet (0)
Protocols and subfunctions:
0 - Ethernet:
0 - Read MAC
IPv4 (1)
0 - Read # IP packets sent
1 - Read # IP packets received
common subfunctions:
0 - Read # packets sent
1 - Read # packets received
1 - IPv4:
2 - Read IP
3 - Write IP
4 - Read DNS
@ -4703,22 +4709,13 @@ IPv4 (1)
8 - Read gateway
9 - Write gateway
ICMP (2)
0 - Read # ICMP packets sent
1 - Read # ICMP packets received
2 - ICMP:
3 - enable/disable ICMP echo reply
UDP (3)
0 - Read # UDP packets sent
1 - Read # UDP packets received
3 - UDP
4 - TCP
TCP (4)
0 - Read # TCP packets sent
1 - Read # TCP packets received
ARP (5)
0 - Read # ARP packets sent
1 - Read # ARP packets received
5 - ARP:
2 - Read # ARP entry's
3 - Read ARP entry
4 - Add static ARP entry
@ -4728,7 +4725,6 @@ ARP (5)
---------------------- Constants for registers: ----------------------
eax - SF_NETWORK_PROTOCOL (76)
======================================================================
========== Function 77, Subfunction 0, Create futex object ===========
======================================================================
@ -4742,6 +4738,10 @@ Remarks:
* Use subfunction 1 to destroy the futex.
The kernel destroys the futexes automatically when the process
terminates.
---------------------- Constants for registers: ----------------------
eax - SF_FUTEX (77)
ebx - SSF_CREATE (0)
======================================================================
========= Function 77, Subfunction 1, Destroy futex object ===========
======================================================================
@ -4754,6 +4754,9 @@ Returned value:
Remarks:
* The futex handle must have been created by subfunction 0
---------------------- Constants for registers: ----------------------
eax - SF_FUTEX (77)
ebx - SSF_DESTROY (1)
======================================================================
=============== Function 77, Subfunction 2, Futex wait ===============
======================================================================
@ -4773,6 +4776,9 @@ Remarks:
waiting for a wake operation on the futex.
* The futex handle must have been created by subfunction 0
---------------------- Constants for registers: ----------------------
eax - SF_FUTEX (77)
ebx - SSF_WAIT (2)
======================================================================
=============== Function 77, Subfunction 3, Futex wake ===============
======================================================================
@ -4789,6 +4795,9 @@ Remarks:
waiting (e.g., inside futex wait) on the futex dword
* The futex handle must have been created by subfunction 0
---------------------- Constants for registers: ----------------------
eax - SF_FUTEX (77)
ebx - SSF_WAKE (3)
======================================================================
=============== Function -1 - terminate thread/process ===============
======================================================================
@ -4804,6 +4813,8 @@ Remarks:
* This function terminates the current thread. Other thread can be
killed by call to subfunction 2 of function 18.
---------------------- Constants for registers: ----------------------
eax - SF_TERMINATE_PROCESS (-1)
======================================================================
=========================== List of events ===========================
======================================================================
@ -4841,18 +4852,17 @@ Codes of events:
=================== Error codes of the file system ===================
======================================================================
* 0 = success
* 1 = base and/or partition of a hard disk is not defined
(by subfunctions 7, 8 of function 21)
* 2 = function is not supported for the given file system
* 3 = unknown file system
* 4 = reserved, is never returned in the current implementation
* 5 = file not found
* 6 = end of file, EOF
* 7 = pointer lies outside of application memory
* 8 = disk is full
* 9 = FAT table is destroyed
* 9 = file system error
* 10 = access denied
* 11 = device error
* 12 = file system requires more memory
Application start functions can return also following errors:
* 30 = 0x1E = not enough memory
* 31 = 0x1F = file is not executable

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -35,8 +35,8 @@ endg
iglobal
;--------------------------------------
align 4
mouse_speed_factor dw 1
mouse_delay db 1
mouse_speed_factor dw 4
mouse_delay db 3
mouse_doubleclick_delay db 64
endg
@ -480,7 +480,7 @@ redrawmouse:
;-----------------------------------------------------------------------------
align 4
proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
proc set_mouse_data stdcall uses ecx edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
mov eax, [BtnState]
and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements
@ -551,35 +551,17 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
endp
;-----------------------------------------------------------------------------
; 3 = (x+1)^2 /4
; 2 = (x+2)^2 /8
; 1 = (x+3)^2 /16
align 4
mouse_acceleration:
cmp [mouse_delay], 0
jz .end
push eax
@@:
neg eax
jl @b
inc eax
cmp [mouse_delay], 3
adc eax, 0
cmp [mouse_delay], 2
adc eax, 0
neg ax
jl mouse_acceleration
add al, [mouse_delay]
mul al
shr eax, 2
cmp [mouse_delay], 2
jz .2
jnc .3
shr eax, 1
.2:
shr eax, 1
.3:
pop edx
test edx, edx
jns .end
neg eax
.end:
imul [mouse_speed_factor]
mov cx, [mouse_speed_factor]
dec ax
shr ax, cl
inc ax
test eax, eax
jns @f
neg ax
@@:
ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved.
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved.
;; PROGRAMMING:
;; Ivan Poddubny
;; Marat Zakiyanov (Mario79)
@ -440,44 +440,12 @@ high_code:
; -----------------------------------------
mov al, [BOOT_VARS+BOOT_DMA] ; DMA access
mov [allow_dma_access], al
movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp
mov [_display.bits_per_pixel], eax
mov [_display.vrefresh], 60
mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen
mov [debug_direct_print], al
mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded?
mov [launcher_start], al
movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max
mov [_display.width], eax
mov [display_width_standard], eax
dec eax
mov [screen_workarea.right], eax
movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max
mov [_display.height], eax
mov [display_height_standard], eax
dec eax
mov [screen_workarea.bottom], eax
movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode
mov dword [SCR_MODE], eax
; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add
; mov [BANK_SWITCH], eax
mov eax, 640 *4 ; Bytes PerScanLine
cmp [SCR_MODE], word 0x13 ; 320x200
je @f
cmp [SCR_MODE], word 0x12 ; VGA 640x480
je @f
movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes
@@:
mov [_display.lfb_pitch], eax
mov eax, [_display.width]
mul [_display.height]
mov [_display.win_map_size], eax
call calculate_fast_getting_offset_for_WinMapAddress
; for Qemu or non standart video cards
; Unfortunately [BytesPerScanLine] does not always
; equal to [_display.width] * [ScreenBPP] / 8
call calculate_fast_getting_offset_for_LFB
mov esi, BOOT_VARS+0x9080
movzx ecx, byte [esi-1]
@ -485,59 +453,6 @@ high_code:
mov edi, BiosDisksData
rep movsd
setvideomode:
mov eax, [BOOT_VARS+BOOT_LFB]
mov [LFBAddress], eax
cmp word [SCR_MODE], 0x0012 ; VGA (640x480 16 colors)
je .vga
cmp word [SCR_MODE], 0x0013 ; MCGA (320*200 256 colors)
je .32bpp
cmp byte [_display.bits_per_pixel], 32
je .32bpp
cmp byte [_display.bits_per_pixel], 24
je .24bpp
cmp byte [_display.bits_per_pixel], 16
je .16bpp
; cmp byte [_display.bits_per_pixel], 15
; je .15bpp
.vga:
mov [PUTPIXEL], VGA_putpixel
mov [GETPIXEL], Vesa20_getpixel32 ; Conversion buffer is 32 bpp
mov [_display.bytes_per_pixel], 4 ; Conversion buffer is 32 bpp
jmp .finish
; .15bpp:
; mov [PUTPIXEL], Vesa20_putpixel15
; mov [GETPIXEL], Vesa20_getpixel15
; mov [_display.bytes_per_pixel], 2
; jmp .finish
.16bpp:
mov [PUTPIXEL], Vesa20_putpixel16
mov [GETPIXEL], Vesa20_getpixel16
mov [_display.bytes_per_pixel], 2
jmp .finish
.24bpp:
mov [PUTPIXEL], Vesa20_putpixel24
mov [GETPIXEL], Vesa20_getpixel24
mov [_display.bytes_per_pixel], 3
jmp .finish
.32bpp:
mov [PUTPIXEL], Vesa20_putpixel32
mov [GETPIXEL], Vesa20_getpixel32
mov [_display.bytes_per_pixel], 4
; jmp .finish
.finish:
mov [MOUSE_PICTURE], mousepointer
mov [_display.check_mouse], check_mouse_area_for_putpixel
mov [_display.check_m_pixel], check_mouse_area_for_getpixel
; -------- Fast System Call init ----------
; Intel SYSENTER/SYSEXIT (AMD CPU support it too)
bt [cpu_caps], CAPS_SEP
@ -619,8 +534,11 @@ setvideomode:
mov ax, tss0
ltr ax
mov [LFBSize], 0xC00000
call init_LFB
call init_video
call init_mtrr
mov [LFBAddress], LFB_BASE
mov ecx, bios_fb
call set_framebuffer
call init_fpu
call init_malloc

View File

@ -64,9 +64,10 @@ include "sound/playnote.inc" ; player Note for Speaker PC
;include "video/vesa12.inc" ; Vesa 1.2 functions
include "video/vesa20.inc" ; Vesa 2.0 functions
include "video/blitter.inc" ;
include "video/blitter.inc"
include "video/vga.inc" ; VGA 16 color functions
include "video/cursors.inc" ; cursors functions
include "video/framebuffer.inc" ; framebuffer functions
; Network Interface & TCPIP Stack

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; IPv4.INC ;;
@ -939,6 +939,7 @@ ipv4_route:
test ebx, ebx
jnz .got_device
; Broadcast does not need gateway
cmp eax, 0xffffffff
je .broadcast
@ -976,6 +977,10 @@ ipv4_route:
mov edx, [IP_LIST + edi] ; Source IP
; Broadcast does not need gateway
cmp eax, 0xffffffff
je @f
; Check if we should route to gateway or not
mov ebx, [IP_LIST + edi]
and ebx, [SUBNET_LIST + edi]

View File

@ -0,0 +1,216 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Synhronization for MenuetOS. ;;
;; Author: Halyavin Andrey, halyavin@land.ru ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 6240 $
struct FRB
list LHEAD
magic rd 1
handle rd 1
destroy rd 1
width rd 1
height rd 1
pitch rd 1
format rd 1
private rd 1
pde rd 8
ends
align 4
create_framebuffer:
mov ecx, sizeof.FRB
call create_object
test eax, eax
jz .fail
mov [eax+FRB.magic], 'FRMB'
mov [eax+FRB.destroy], 0
.fail:
ret
align 4
init_video:
mov ebp, bios_fb
movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp
mov [_display.bits_per_pixel], eax
mov [_display.vrefresh], 60
movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max
mov [_display.width], eax
mov [ebp+FRB.width], eax
mov [display_width_standard], eax
dec eax
mov [screen_workarea.right], eax
movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max
mov [_display.height], eax
mov [ebp+FRB.height], eax
mov [display_height_standard], eax
dec eax
mov [screen_workarea.bottom], eax
movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode
mov dword [SCR_MODE], eax
mov eax, 640 *4 ; Bytes PerScanLine
cmp [SCR_MODE], word 0x13 ; 320x200
je @f
cmp [SCR_MODE], word 0x12 ; VGA 640x480
je @f
movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes
@@:
mov [_display.lfb_pitch], eax
mov [ebp+FRB.pitch], eax
mov eax, [BOOT_VARS+BOOT_LFB]
mov [LFBAddress], eax
mov eax, [_display.width]
mul [_display.height]
mov [_display.win_map_size], eax
cmp word [SCR_MODE], 0x0012 ; VGA (640x480 16 colors)
je .vga
cmp word [SCR_MODE], 0x0013 ; MCGA (320*200 256 colors)
je .32bpp
cmp byte [_display.bits_per_pixel], 32
je .32bpp
cmp byte [_display.bits_per_pixel], 24
je .24bpp
cmp byte [_display.bits_per_pixel], 16
je .16bpp
.vga:
mov [PUTPIXEL], VGA_putpixel
mov [GETPIXEL], Vesa20_getpixel32 ; Conversion buffer is 32 bpp
mov [_display.bytes_per_pixel], 4 ; Conversion buffer is 32 bpp
jmp .finish
.16bpp:
mov [PUTPIXEL], Vesa20_putpixel16
mov [GETPIXEL], Vesa20_getpixel16
mov [_display.bytes_per_pixel], 2
jmp .finish
.24bpp:
mov [PUTPIXEL], Vesa20_putpixel24
mov [GETPIXEL], Vesa20_getpixel24
mov [_display.bytes_per_pixel], 3
jmp .finish
.32bpp:
mov [PUTPIXEL], Vesa20_putpixel32
mov [GETPIXEL], Vesa20_getpixel32
mov [_display.bytes_per_pixel], 4
.finish:
mov [MOUSE_PICTURE], mousepointer
mov [_display.check_mouse], check_mouse_area_for_putpixel
mov [_display.check_m_pixel], check_mouse_area_for_getpixel
mov ax, word [SCR_MODE]
cmp ax, 0x0012
je .fake
cmp ax, 0x0013
je .fake
mov esi, [LFBAddress]
bt [cpu_caps], CAPS_PSE
jnc .create_page_tables
mov edx, 0x00400000
or esi, PG_GLOBAL+PDE_LARGE+PAT_WC+PG_UWR
and esi, [pte_valid_mask]
mov [ebp+FRB.pde], esi
add esi, edx
mov [ebp+FRB.pde+4], esi
add esi, edx
mov [ebp+FRB.pde+8], esi
add esi, edx
mov [ebp+FRB.pde+12], esi
add esi, edx
.ok:
call calculate_fast_getting_offset_for_WinMapAddress
; for Qemu or non standart video cards
; Unfortunately [BytesPerScanLine] does not always
; equal to [_display.width] * [ScreenBPP] / 8
call calculate_fast_getting_offset_for_LFB
ret
.create_page_tables:
add ebp, FRB.pde
or esi, PG_GLOBAL+PAT_WC+PG_UWR
and esi, [pte_valid_mask]
stdcall alloc_kernel_space, 0x1000
mov edi, eax
mov ebx, 4
.new_pd:
call alloc_page
lea edx, [eax+PG_UWR]
mov [ebp], edx
stdcall map_page, edi, eax, PG_SWR
mov eax, esi
mov ecx, 1024
@@:
stosd
add eax, 0x1000
loop @B
add esi, 0x400000
add ebp, 4
sub edi, 4096
dec ebx
jnz .new_pd
stdcall free_kernel_space, edi
jmp .ok
.fake:
mov [BOOT_VARS+BOOT_MTRR], byte 2
stdcall alloc_kernel_space, 0x1000
push eax ;store in stack for subsequent
mov edi, eax ;free_kernel_space call
call alloc_page
lea edx, [eax+PG_UWR]
mov [ebp+FRB.pde], edx
; max VGA=640*480*4=1228800 bytes
; + 32*640*4=81920 bytes for mouse pointer
stdcall alloc_pages, ((1228800+81920)/4096)
or eax, PG_GLOBAL+PG_UWR
and eax, [pte_valid_mask]
mov ecx, (1228800+81920)/4096
@@:
stosd
add eax, 0x1000
loop @B
call free_kernel_space
jmp .ok
align 4
set_framebuffer:
mov edx, LFB_BASE shr 22
mov eax, [ecx+FRB.pde]
mov dword [master_tab+edx*4], eax
mov eax, [ecx+FRB.pde+4]
mov dword [master_tab+edx*4+4], eax
mov eax, [ecx+FRB.pde+8]
mov dword [master_tab+edx*4+8], eax
mov eax, [ecx+FRB.pde+12]
mov dword [master_tab+edx*4+12], eax
ret