Serial output console (disable by default)

When enabled with current settings,
it will work on com1 using a 115200 baud connection
8 bits words, no parity bit, 1 stop bit

git-svn-id: svn://kolibrios.org@1043 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2009-03-02 21:05:40 +00:00
parent 3141a1036d
commit f6697caafb

View File

@ -17,6 +17,7 @@
;; Sergey Semyonov (Serge) ;; Sergey Semyonov (Serge)
;; Johnny_B ;; Johnny_B
;; SPraid (simba) ;; SPraid (simba)
;; Hidnplayr
;; ;;
;; Data in this file was originally part of MenuetOS project which is ;; Data in this file was originally part of MenuetOS project which is
;; distributed under the terms of GNU GPL. It is modified and redistributed as ;; distributed under the terms of GNU GPL. It is modified and redistributed as
@ -58,7 +59,10 @@ include 'macros.inc'
$Revision$ $Revision$
USE_COM_IRQ equ 1 ;make irq 3 and irq 4 available for PCI devices USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices
; Enabling the next line will enable serial output console
;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
include "proc32.inc" include "proc32.inc"
include "kglobals.inc" include "kglobals.inc"
@ -712,7 +716,7 @@ no_lib_load:
mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address
call init_cursors call init_cursors
mov eax, [def_cursor] mov eax, [def_cursor]
mov [SLOT_BASE+APPDATA.cursor],eax mov [SLOT_BASE+APPDATA.cursor],eax
mov [SLOT_BASE+APPDATA.cursor+256],eax mov [SLOT_BASE+APPDATA.cursor+256],eax
@ -730,8 +734,8 @@ no_lib_load:
sub eax,ecx sub eax,ecx
shl eax,2 shl eax,2
mov [CPU_FREQ],eax ; save tsc / sec mov [CPU_FREQ],eax ; save tsc / sec
; mov ebx, 1000000 ; mov ebx, 1000000
; div ebx ; div ebx
; ¢®®¡é¥-â® ¯à®¨§¢®¤¨â¥«ì­®áâì ¢ ¤ ­­®¬ ª®­ªà¥â­®¬ ¬¥á⥠; ¢®®¡é¥-â® ¯à®¨§¢®¤¨â¥«ì­®áâì ¢ ¤ ­­®¬ ª®­ªà¥â­®¬ ¬¥áâ¥
; ᮢ¥à襭­® ­¥ªà¨â¨ç­ , ­® çâ®¡ë § âª­ãâì «î¡¨â¥«¥© ; ᮢ¥à襭­® ­¥ªà¨â¨ç­ , ­® çâ®¡ë § âª­ãâì «î¡¨â¥«¥©
; ®¯â¨¬¨§¨àãîé¨å ª®¬¯¨«ïâ®à®¢ Ÿ‚“... ; ®¯â¨¬¨§¨àãîé¨å ª®¬¯¨«ïâ®à®¢ Ÿ‚“...
@ -870,6 +874,48 @@ first_app_found:
call set_lights call set_lights
;// mike.dld ] ;// mike.dld ]
; Setup serial output console (if enabled)
if defined debug_com_base
; enable Divisor latch
mov dx, debug_com_base+3
mov al, 1 shl 7
out dx, al
; Set speed to 115200 baud (max speed)
mov dx, debug_com_base
mov al, 0x01
out dx, al
mov dx, debug_com_base+1
mov al, 0x00
out dx, al
; No parity, 8bits words, one stop bit, dlab bit back to 0
mov dx, debug_com_base+3
mov al, 3
out dx, al
; disable interrupts
mov dx, debug_com_base+1
mov al, 0
out dx, al
; clear + enable fifo (64 bits)
mov dx, debug_com_base+2
mov al, 0x7 + 1 shl 5
out dx, al
end if
; START MULTITASKING ; START MULTITASKING
if preboot_blogesc if preboot_blogesc
@ -1118,7 +1164,7 @@ set_variables:
mov [MOUSE_X],eax mov [MOUSE_X],eax
pop eax pop eax
mov [BTN_ADDR],dword BUTTON_INFO ; address of button list mov [BTN_ADDR],dword BUTTON_INFO ; address of button list
;!! IP 04.02.2005: ;!! IP 04.02.2005:
mov [next_usage_update], 100 mov [next_usage_update], 100
@ -1562,7 +1608,7 @@ nsyse8:
ret ret
no_set_lba_read: no_set_lba_read:
cmp eax,12 ; ENABLE PCI ACCESS cmp eax,12 ; ENABLE PCI ACCESS
jne no_set_pci_access jne no_set_pci_access
and ebx,1 and ebx,1
mov [pci_access_enabled],ebx mov [pci_access_enabled],ebx
@ -1635,17 +1681,17 @@ kbnoaltret:
ret ret
ngsyse2: ngsyse2:
cmp eax,3 cmp eax,3
jnz ngsyse3 jnz ngsyse3
movzx eax,[cd_base] movzx eax,[cd_base]
mov [esp+36],eax mov [esp+36],eax
ret ret
ngsyse3: ngsyse3:
cmp eax,5 cmp eax,5
jnz ngsyse5 jnz ngsyse5
mov eax,[syslang] mov eax,[syslang]
mov [esp+36],eax mov [esp+36],eax
ret ret
ngsyse5: ngsyse5:
cmp eax,7 cmp eax,7
jnz ngsyse7 jnz ngsyse7
@ -2300,7 +2346,7 @@ nosb1:
and ebx, -4096 and ebx, -4096
sub ebx, 4 sub ebx, 4
cmp ecx, ebx cmp ecx, ebx
ja @F ja @F
mov eax,[img_background] mov eax,[img_background]
mov ebx,[eax+ecx] mov ebx,[eax+ecx]
@ -2412,9 +2458,9 @@ nosb6:
and dword [page_tabs+eax*4], 0 and dword [page_tabs+eax*4], 0
mov edx, eax mov edx, eax
shl edx, 12 shl edx, 12
push eax push eax
invlpg [edx] invlpg [edx]
pop eax pop eax
inc eax inc eax
loop @b loop @b
pop eax pop eax
@ -2465,7 +2511,7 @@ nogb1:
and ecx, -4096 and ecx, -4096
sub ecx, 4 sub ecx, 4
cmp ebx, ecx cmp ebx, ecx
ja @F ja @F
mov eax,[img_background] mov eax,[img_background]
mov eax,[ebx+eax] mov eax,[ebx+eax]
@ -2545,8 +2591,8 @@ sys_getbutton:
mov eax, [BTN_BUFF] mov eax, [BTN_BUFF]
shl eax, 8 shl eax, 8
; // Alver 22.06.2008 // { ; // Alver 22.06.2008 // {
mov al, byte [btn_down_determ] mov al, byte [btn_down_determ]
and al,0xFE ; delete left button bit and al,0xFE ; delete left button bit
; } \\ Alver \\ ; } \\ Alver \\
mov [BTN_COUNT], byte 0 mov [BTN_COUNT], byte 0
mov [esp + 32], eax mov [esp + 32], eax
@ -2959,8 +3005,8 @@ draw_window_caption:
or ecx, 0x80000000 or ecx, 0x80000000
xor edi,edi xor edi,edi
; // Alver 22.06.2008 // { ; // Alver 22.06.2008 // {
; call dtext ; call dtext
call dtext_asciiz_esi call dtext_asciiz_esi
; } \\ Alver \\ ; } \\ Alver \\
@@: @@:
@ -4225,58 +4271,58 @@ sys_putimage_palette:
add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left]
rol edx, 16 rol edx, 16
.forced: .forced:
cmp esi, 1 cmp esi, 1
jnz @f jnz @f
push edi push edi
mov eax, [edi+4] mov eax, [edi+4]
sub eax, [edi] sub eax, [edi]
push eax push eax
push dword [edi] push dword [edi]
push 0ffffff80h push 0ffffff80h
mov edi, esp mov edi, esp
call put_mono_image call put_mono_image
add esp, 12 add esp, 12
pop edi pop edi
ret ret
@@: @@:
cmp esi, 2 cmp esi, 2
jnz @f jnz @f
push edi push edi
push 0ffffff80h push 0ffffff80h
mov edi, esp mov edi, esp
call put_2bit_image call put_2bit_image
pop eax pop eax
pop edi pop edi
ret ret
@@: @@:
cmp esi, 4 cmp esi, 4
jnz @f jnz @f
push edi push edi
push 0ffffff80h push 0ffffff80h
mov edi, esp mov edi, esp
call put_4bit_image call put_4bit_image
pop eax pop eax
pop edi pop edi
ret ret
@@: @@:
push ebp esi ebp push ebp esi ebp
cmp esi, 8 cmp esi, 8
jnz @f jnz @f
mov ebp, putimage_get8bpp mov ebp, putimage_get8bpp
mov esi, putimage_init8bpp mov esi, putimage_init8bpp
jmp sys_putimage_bpp jmp sys_putimage_bpp
@@: @@:
cmp esi, 15 cmp esi, 15
jnz @f jnz @f
mov ebp, putimage_get15bpp mov ebp, putimage_get15bpp
mov esi, putimage_init15bpp mov esi, putimage_init15bpp
jmp sys_putimage_bpp jmp sys_putimage_bpp
@@: @@:
cmp esi, 16 cmp esi, 16
jnz @f jnz @f
mov ebp, putimage_get16bpp mov ebp, putimage_get16bpp
mov esi, putimage_init16bpp mov esi, putimage_init16bpp
jmp sys_putimage_bpp jmp sys_putimage_bpp
@@: @@:
cmp esi, 24 cmp esi, 24
jnz @f jnz @f
@ -4294,20 +4340,20 @@ sys_putimage_palette:
ret ret
put_mono_image: put_mono_image:
push ebp esi ebp push ebp esi ebp
mov ebp, putimage_get1bpp mov ebp, putimage_get1bpp
mov esi, putimage_init1bpp mov esi, putimage_init1bpp
jmp sys_putimage_bpp jmp sys_putimage_bpp
put_2bit_image: put_2bit_image:
push ebp esi ebp push ebp esi ebp
mov ebp, putimage_get2bpp mov ebp, putimage_get2bpp
mov esi, putimage_init2bpp mov esi, putimage_init2bpp
jmp sys_putimage_bpp jmp sys_putimage_bpp
put_4bit_image: put_4bit_image:
push ebp esi ebp push ebp esi ebp
mov ebp, putimage_get4bpp mov ebp, putimage_get4bpp
mov esi, putimage_init4bpp mov esi, putimage_init4bpp
jmp sys_putimage_bpp jmp sys_putimage_bpp
putimage_init24bpp: putimage_init24bpp:
lea eax, [eax*3] lea eax, [eax*3]
@ -4359,36 +4405,36 @@ putimage_get1bpp:
ret 4 ret 4
putimage_init2bpp: putimage_init2bpp:
add eax, ecx add eax, ecx
push ecx push ecx
add ecx, 3 add ecx, 3
add eax, 3 add eax, 3
shr ecx, 2 shr ecx, 2
shr eax, 2 shr eax, 2
sub eax, ecx sub eax, ecx
pop ecx pop ecx
ret ret
align 16 align 16
putimage_get2bpp: putimage_get2bpp:
push edx push edx
mov edx, [esp+8] mov edx, [esp+8]
mov al, [edx] mov al, [edx]
mov ah, al mov ah, al
shr al, 6 shr al, 6
shl ah, 2 shl ah, 2
jnz .nonewbyte jnz .nonewbyte
lodsb lodsb
mov ah, al mov ah, al
shr al, 6 shr al, 6
shl ah, 2 shl ah, 2
add ah, 1 add ah, 1
.nonewbyte: .nonewbyte:
mov [edx], ah mov [edx], ah
mov edx, [edx+4] mov edx, [edx+4]
movzx eax, al movzx eax, al
mov eax, [edx+eax*4] mov eax, [edx+eax*4]
pop edx pop edx
ret 4 ret 4
putimage_init4bpp: putimage_init4bpp:
add eax, ecx add eax, ecx
@ -4432,45 +4478,45 @@ putimage_get32bpp:
putimage_init15bpp: putimage_init15bpp:
putimage_init16bpp: putimage_init16bpp:
add eax, eax add eax, eax
ret ret
align 16 align 16
putimage_get15bpp: putimage_get15bpp:
; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000
push ecx edx push ecx edx
movzx eax, word [esi] movzx eax, word [esi]
add esi, 2 add esi, 2
mov ecx, eax mov ecx, eax
mov edx, eax mov edx, eax
and eax, 0x1F and eax, 0x1F
and ecx, 0x1F shl 5 and ecx, 0x1F shl 5
and edx, 0x1F shl 10 and edx, 0x1F shl 10
shl eax, 3 shl eax, 3
shl ecx, 6 shl ecx, 6
shl edx, 9 shl edx, 9
or eax, ecx or eax, ecx
or eax, edx or eax, edx
pop edx ecx pop edx ecx
ret 4 ret 4
align 16 align 16
putimage_get16bpp: putimage_get16bpp:
; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000
push ecx edx push ecx edx
movzx eax, word [esi] movzx eax, word [esi]
add esi, 2 add esi, 2
mov ecx, eax mov ecx, eax
mov edx, eax mov edx, eax
and eax, 0x1F and eax, 0x1F
and ecx, 0x3F shl 5 and ecx, 0x3F shl 5
and edx, 0x1F shl 11 and edx, 0x1F shl 11
shl eax, 3 shl eax, 3
shl ecx, 5 shl ecx, 5
shl edx, 8 shl edx, 8
or eax, ecx or eax, ecx
or eax, edx or eax, edx
pop edx ecx pop edx ecx
ret 4 ret 4
; eax x beginning ; eax x beginning
; ebx y beginning ; ebx y beginning
@ -4763,6 +4809,23 @@ sys_msg_board:
cmp eax, 1 cmp eax, 1
jne .smbl1 jne .smbl1
if defined debug_com_base
push dx ax
@@: ; Wait for empty transmit register (yes, this slows down system..)
mov dx, debug_com_base+5
in al, dx
test al, 1 shl 5
jz @r
mov dx, debug_com_base ; Output the byte
mov al, bl
out dx, al
pop ax dx
end if
mov [msg_board_data+ecx],bl mov [msg_board_data+ecx],bl
inc ecx inc ecx
@ -5133,7 +5196,7 @@ syscall_getarea:
mov ebx,edx mov ebx,edx
and ebx,0xffff and ebx,0xffff
dec eax dec eax
dec ebx dec ebx
; eax - x, ebx - y ; eax - x, ebx - y
mov edx,ecx mov edx,ecx