From a20b1c888dd4be6aa7c3d93ee4328dc6acca17dc Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Tue, 4 Sep 2012 22:16:57 +0000 Subject: [PATCH] kolibri_pe: the latest 32-bit version git-svn-id: svn://kolibrios.org@2971 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/kolibri_pe/blkdev/cd_drv.inc | 17 +- kernel/branches/kolibri_pe/blkdev/rd.inc | 5 +- kernel/branches/kolibri_pe/blkdev/rdsave.inc | 2 +- kernel/branches/kolibri_pe/boot/booteng.inc | 2 +- kernel/branches/kolibri_pe/boot/bootet.inc | 2 +- kernel/branches/kolibri_pe/boot/bootge.inc | 2 +- kernel/branches/kolibri_pe/boot/bootru.inc | 2 +- kernel/branches/kolibri_pe/boot/bootvesa.inc | 49 +- kernel/branches/kolibri_pe/const.inc | 99 ++- kernel/branches/kolibri_pe/core/dll.c | 3 + kernel/branches/kolibri_pe/core/dll.inc | 6 + kernel/branches/kolibri_pe/core/export.asm | 6 +- kernel/branches/kolibri_pe/core/fpu.inc | 2 +- kernel/branches/kolibri_pe/core/frame.c | 11 +- kernel/branches/kolibri_pe/core/heap.c | 29 +- kernel/branches/kolibri_pe/core/heap.inc | 2 +- kernel/branches/kolibri_pe/core/init.asm | 1 - kernel/branches/kolibri_pe/core/memory.inc | 1 + kernel/branches/kolibri_pe/core/pe.c | 19 +- kernel/branches/kolibri_pe/core/slab.c | 158 ++--- kernel/branches/kolibri_pe/core/sys32.inc | 23 +- kernel/branches/kolibri_pe/core/syscall.asm | 86 +++ kernel/branches/kolibri_pe/core/syscall.inc | 183 ++--- kernel/branches/kolibri_pe/core/taskman.inc | 42 +- kernel/branches/kolibri_pe/data32.inc | 30 +- kernel/branches/kolibri_pe/docs/sysfuncr.txt | 431 +++++++----- kernel/branches/kolibri_pe/docs/sysfuncs.txt | 444 ++++++------ .../kolibri_pe/drivers/sb16/CONFIG.INC | 4 +- kernel/branches/kolibri_pe/fdo.inc | 2 - kernel/branches/kolibri_pe/fs/fat32.inc | 21 +- kernel/branches/kolibri_pe/fs/fs.inc | 12 +- kernel/branches/kolibri_pe/fs/iso9660.inc | 2 +- kernel/branches/kolibri_pe/fs/ntfs.inc | 2 +- kernel/branches/kolibri_pe/gui/button.inc | 4 +- kernel/branches/kolibri_pe/gui/font.inc | 2 +- kernel/branches/kolibri_pe/gui/win.c | 204 ++++++ kernel/branches/kolibri_pe/gui/window.inc | 652 +++++++++++++++--- kernel/branches/kolibri_pe/include/core.h | 43 +- kernel/branches/kolibri_pe/include/mm.h | 38 +- kernel/branches/kolibri_pe/include/pe.h | 2 +- kernel/branches/kolibri_pe/include/slab.h | 30 + kernel/branches/kolibri_pe/kernel.asm | 110 +-- kernel/branches/kolibri_pe/kernel32.inc | 22 +- kernel/branches/kolibri_pe/makefile | 1 + .../kolibri_pe/network/eth_drv/arp.inc | 4 +- .../kolibri_pe/network/eth_drv/ethernet.inc | 10 +- kernel/branches/kolibri_pe/network/ip.inc | 2 +- kernel/branches/kolibri_pe/network/queue.inc | 22 +- kernel/branches/kolibri_pe/network/socket.inc | 571 +++++++-------- kernel/branches/kolibri_pe/network/stack.inc | 6 +- kernel/branches/kolibri_pe/network/tcp.inc | 95 +-- kernel/branches/kolibri_pe/network/udp.inc | 10 +- kernel/branches/kolibri_pe/sound/playnote.inc | 2 +- kernel/branches/kolibri_pe/video/cursors.inc | 6 +- kernel/branches/kolibri_pe/video/vesa12.inc | 6 +- kernel/branches/kolibri_pe/video/vesa20.inc | 6 +- 56 files changed, 2145 insertions(+), 1403 deletions(-) create mode 100644 kernel/branches/kolibri_pe/gui/win.c diff --git a/kernel/branches/kolibri_pe/blkdev/cd_drv.inc b/kernel/branches/kolibri_pe/blkdev/cd_drv.inc index 1747b045d0..5516e0b5ab 100644 --- a/kernel/branches/kolibri_pe/blkdev/cd_drv.inc +++ b/kernel/branches/kolibri_pe/blkdev/cd_drv.inc @@ -14,7 +14,7 @@ $Revision$ ; └тЄюЁ ўрёЄш шёїюфэюую ЄхъёЄр ╩єыръют ┬ырфшьшЁ ├хээрф№хтшў ; └фряЄрЎш , фюЁрсюЄър ш ЁрчЁрсюЄър Mario79 -; ╠ръёшьры№эюх ъюышўхёЄтю яютЄюЁхэшщ юяхЁрЎшш ўЄхэш +; ╠ръёшьры№эюх ъюышўхёЄтю яютЄюЁхэшщ юяхЁрЎшш ўЄхэш  MaxRetr equ 10 ; ╧Ёхфхы№эюх тЁхь  юцшфрэш  уюЄютэюёЄш ъ яЁшхьє ъюьрэф√ ; (т Єшърї) @@ -38,7 +38,7 @@ ReadCD: mov [CDBlockSize],2048 ;2352 ; ╬ўшёЄшЄ№ сєЇхЁ яръхЄэющ ъюьрэф√ call clear_packet_buffer -; ╤ЇюЁьшЁютрЄ№ яръхЄэє■ ъюьрэфє фы  ёўшЄ√трэш +; ╤ЇюЁьшЁютрЄ№ яръхЄэє■ ъюьрэфє фы  ёўшЄ√трэш  ; ёхъЄюЁр фрээ√ї ; ╟рфрЄ№ ъюф ъюьрэф√ Read CD mov [PacketCommand],byte 0x28 ;0xBE @@ -168,6 +168,7 @@ MaxCDWaitTime equ 1000 ;200 ;10 ; ╬сырёЄ№ ярь Єш фы  ЇюЁьшЁютрэш  яръхЄэющ ъюьрэф√ PacketCommand: rb 12 ;DB 12 DUP (?) ; ╬сырёЄ№ ярь Єш фы  яЁшхьр фрээ√ї юЄ фшёъютюфр +;CDDataBuf DB 4096 DUP (0) ; ╨рчьхЁ яЁшэшьрхьюую сыюър фрээ√ї т срщЄрї CDBlockSize DW ? ; └фЁхё ёўшЄ√трхьюую ёхъЄюЁр фрээ√ї @@ -176,7 +177,7 @@ CDSectorAddress: DD ? TickCounter_1 DD 0 ; ┬Ёхь  эрўрыр юцшфрэш  уюЄютэюёЄш єёЄЁющёЄтр WURStartTime DD 0 -; єърчрЄхы№ сєЇхЁр фы  ёўшЄ√трэш +; єърчрЄхы№ сєЇхЁр фы  ёўшЄ√трэш  CDDataBuf_pointer dd 0 ;**************************************************** @@ -341,7 +342,7 @@ SendPacketNoDatCommand: add DX,7 ;яюЁЄ 1ї7h @@WaitDevice0_1: call change_task - ; ╧ЁютхЁшЄ№ тЁхь  юцшфрэш + ; ╧ЁютхЁшЄ№ тЁхь  юцшфрэш  mov EAX,[timer_ticks] sub EAX,[TickCounter_1] cmp EAX,BSYWaitTime @@ -463,12 +464,12 @@ SendCommandToHDD_1: jmp .test @@: call change_task - ; ╧ЁютхЁшЄ№ тЁхь  юцшфрэш + ; ╧ЁютхЁшЄ№ тЁхь  юцшфрэш  mov eax,[timer_ticks] sub eax,[TickCounter_1] cmp eax,BSYWaitTime ;300 ;юцшфрЄ№ 3 ёхъ. ja @@Err1_4 ;ю°шсър Єрщь-рєЄр - ; ╧ЁюўшЄрЄ№ ЁхушёЄЁ ёюёЄю эш + ; ╧ЁюўшЄрЄ№ ЁхушёЄЁ ёюёЄю эш  .test: in AL,DX ; ╧ЁютхЁшЄ№ ёюёЄю эшх ёшуэрыр BSY @@ -644,7 +645,7 @@ LoadMedium: ; ╤ЇюЁьшЁютрЄ№ ъюьрэфє START/STOP UNIT ; ╟рфрЄ№ ъюф ъюьрэф√ mov [PacketCommand],word 1Bh - ; ╟рфрЄ№ юяхЁрЎш■ чруЁєчъш эюёшЄхы + ; ╟рфрЄ№ юяхЁрЎш■ чруЁєчъш эюёшЄхы  mov [PacketCommand+4],word 00000011b ; ╧юфрЄ№ ъюьрэфє call SendPacketNoDatCommand @@ -665,7 +666,7 @@ EjectMedium: ; ╤ЇюЁьшЁютрЄ№ ъюьрэфє START/STOP UNIT ; ╟рфрЄ№ ъюф ъюьрэф√ mov [PacketCommand],word 1Bh - ; ╟рфрЄ№ юяхЁрЎш■ шчтыхўхэш  эюёшЄхы + ; ╟рфрЄ№ юяхЁрЎш■ шчтыхўхэш  эюёшЄхы  mov [PacketCommand+4],word 00000010b ; ╧юфрЄ№ ъюьрэфє call SendPacketNoDatCommand diff --git a/kernel/branches/kolibri_pe/blkdev/rd.inc b/kernel/branches/kolibri_pe/blkdev/rd.inc index c692c516e3..e26c9d4a72 100644 --- a/kernel/branches/kolibri_pe/blkdev/rd.inc +++ b/kernel/branches/kolibri_pe/blkdev/rd.inc @@ -858,6 +858,10 @@ rd_find_lfn: mov [esp+8], eax mov dword [esp+4], ramdisk_notroot_first mov dword [esp], ramdisk_notroot_next + test eax, eax + jnz .loop + mov dword [esp+4], ramdisk_root_first + mov dword [esp], ramdisk_notroot_next jmp .loop .notfound: add esp, 12 @@ -891,7 +895,6 @@ rd_find_lfn: ; ;-------------------------------------------------------------- fs_RamdiskRead: - cmp byte [esi], 0 jnz @f or ebx, -1 diff --git a/kernel/branches/kolibri_pe/blkdev/rdsave.inc b/kernel/branches/kolibri_pe/blkdev/rdsave.inc index a7d8ac10e4..1949130fd4 100644 --- a/kernel/branches/kolibri_pe/blkdev/rdsave.inc +++ b/kernel/branches/kolibri_pe/blkdev/rdsave.inc @@ -22,7 +22,7 @@ endg sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only) call restorefatchain mov eax, [_rd_base] - mov [saverd_fileinfo+4], eax + mov [saverd_fileinfo+4*4], eax mov eax, saverd_fileinfo mov [saverd_fileinfo.name], ecx pushad diff --git a/kernel/branches/kolibri_pe/boot/booteng.inc b/kernel/branches/kolibri_pe/boot/booteng.inc index b9771dfdd6..c3e436934d 100644 --- a/kernel/branches/kolibri_pe/boot/booteng.inc +++ b/kernel/branches/kolibri_pe/boot/booteng.inc @@ -107,7 +107,7 @@ _rs db 186,' _bt db 186,' └───────────────────────────────┴─┘',13,10,0 remark1 db "Default values were selected to match most of configurations, but not all.",0 -remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0 +remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0 remark3 db "If the system does not boot, try to disable the item [b].",0 remarks dw remark1, remark2, remark3 num_remarks = 3 diff --git a/kernel/branches/kolibri_pe/boot/bootet.inc b/kernel/branches/kolibri_pe/boot/bootet.inc index ea6d5f1a26..414efdf381 100644 --- a/kernel/branches/kolibri_pe/boot/bootet.inc +++ b/kernel/branches/kolibri_pe/boot/bootet.inc @@ -109,7 +109,7 @@ save_quest db "J loader_block_error db "Alglaaduri andmed vigased, ei saa jфtkata. Peatatud.",0 remark1 db "Default values were selected to match most of configurations, but not all.",0 -remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0 +remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0 remark3 db "If the system does not boot, try to disable the item [b].",0 remarks dw remark1, remark2, remark3 num_remarks = 3 diff --git a/kernel/branches/kolibri_pe/boot/bootge.inc b/kernel/branches/kolibri_pe/boot/bootge.inc index 6867aa7dfb..2ea4959f19 100644 --- a/kernel/branches/kolibri_pe/boot/bootge.inc +++ b/kernel/branches/kolibri_pe/boot/bootge.inc @@ -114,7 +114,7 @@ save_quest db "Aktuelle Einstellungen speichern? [y/n]: ",0 loader_block_error db "Bootloader Daten ungueltig, Kann nicht fortfahren. Angehalten.",0 remark1 db "Default values were selected to match most of configurations, but not all.",0 -remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0 +remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0 remark3 db "If the system does not boot, try to disable the item [b].",0 remarks dw remark1, remark2, remark3 num_remarks = 3 diff --git a/kernel/branches/kolibri_pe/boot/bootru.inc b/kernel/branches/kolibri_pe/boot/bootru.inc index 444deb1042..529f7a5662 100644 --- a/kernel/branches/kolibri_pe/boot/bootru.inc +++ b/kernel/branches/kolibri_pe/boot/bootru.inc @@ -84,7 +84,7 @@ _bt db 186,' remark1 db "Значения по умолчанию выбраны для удобства большинства, но не всех.",0 -remark2 db "Если у Вас LCD-монитор, отключите VRR в пункте [c] - он Вам не нужен.",0 +remark2 db "Если у Вас ЭЛТ-монитор, включите VRR в пункте [c].",0 remark3 db "Если у Вас не грузится система, попробуйте отключить пункт [b].",0 remarks dw remark1, remark2, remark3 num_remarks = 3 diff --git a/kernel/branches/kolibri_pe/boot/bootvesa.inc b/kernel/branches/kolibri_pe/boot/bootvesa.inc index a07732491a..cb7c2b47de 100644 --- a/kernel/branches/kolibri_pe/boot/bootvesa.inc +++ b/kernel/branches/kolibri_pe/boot/bootvesa.inc @@ -217,14 +217,14 @@ calc_vmodes_table: ; cmp [es:mi.BitsPerPixel], 24 ; jb @f - cmp [es:mi.BitsPerPixel],16 - jne .l0 - cmp [es:mi.GreenMaskSize],5 - jne .l0 - mov [es:mi.BitsPerPixel],15 +; cmp [es:mi.BitsPerPixel],16 +; jne .l0 +; cmp [es:mi.GreenMaskSize],5 +; jne .l0 +; mov [es:mi.BitsPerPixel],15 - .l0: +.l0: cmp [es:mi.XRes],640 jb @f cmp [es:mi.YRes],480 @@ -243,10 +243,10 @@ calc_vmodes_table: jb .lp1 or cx,0x4000 ; use LFB - .lp1: mov [es:bx+6],cx ; +6 : mode number +.lp1: mov [es:bx+6],cx ; +6 : mode number movzx ax,byte [es:mi.BitsPerPixel] mov word [es:bx+8],ax ; +8 : bits per pixel - add bx,size_of_step + add bx,size_of_step ; size of record @@: add si,2 @@ -413,9 +413,17 @@ check_first_parm: mov ax,modes_table @@: - mov word[home_cursor],ax - push word [preboot_graph] - pop word [cursor_pos] + mov word [home_cursor],ax + mov si,[preboot_graph] + mov word [cursor_pos],si + + push word [es:si] + pop word [x_save] + push word [es:si+2] + pop word [y_save] + push word [es:si+6] + pop word [number_vm] + ret ;;;;;;;;;;;;;;;;;;;;;;;;;;; .loops: @@ -432,7 +440,9 @@ check_first_parm: je .exit jmp .loops .ok: xor ax,ax -.exit: ret + ret +.exit: or ax,-1 + ret ;----------------------------------------------------------------------------- @@ -531,14 +541,15 @@ draw_vmodes_table: mov bp,long_v_table ;show rows .@@_next_bit: ;clear cursor - mov word[ds:_r1+21],' ' - mov word[ds:_r1+50],' ' + mov ax,' ' + mov word[ds:_r1+21],ax + mov word[ds:_r1+50],ax - mov word[ds:_r2+21],' ' - mov word[ds:_r2+45],' ' + mov word[ds:_r2+21],ax + mov word[ds:_r2+45],ax - mov word[ds:_rs+21],' ' - mov word[ds:_rs+46],' ' + mov word[ds:_rs+21],ax + mov word[ds:_rs+46],ax ; draw string cmp word [es:si+6],0x12 je .show_0x12 @@ -649,7 +660,7 @@ clear_vmodes_table: rep stosw mov cx,70 add di,20 - dec bp ; уменьшить DX, + dec bp jns .loop_start pop es popa diff --git a/kernel/branches/kolibri_pe/const.inc b/kernel/branches/kolibri_pe/const.inc index 5c78489384..4c4869f47d 100644 --- a/kernel/branches/kolibri_pe/const.inc +++ b/kernel/branches/kolibri_pe/const.inc @@ -187,57 +187,22 @@ end virtual TSS_SIZE equ (128+8192) -HEAP_BASE equ 0x80000000 +page_tabs equ 0xFF800000 +;app_page_tabs equ 0xDD800000 -HEAP_MIN_SIZE equ 0x01000000 +;shared_tabs equ 0xDDC00000 -page_tabs equ 0xDD800000 -app_page_tabs equ 0xDD800000 - -shared_tabs equ 0xDDC00000 - -heap_tabs equ (page_tabs+ (HEAP_BASE shr 10)) -kernel_tabs equ (page_tabs+ (OS_BASE shr 10)) -master_tab equ (page_tabs+ (page_tabs shr 10)) - -LFB_BASE equ 0xDE000000 -SHADOWFB equ 0 ;0xDE800000 - -TEXT_BASE equ 0xDFC00000 +;heap_tabs equ (page_tabs+ (HEAP_BASE shr 9)) +kernel_tabs equ page_tabs) +master_tab equ (page_tabs+ (page_tabs shr 9)) _16BIT_BASE equ 0x00010000 LOAD_BASE equ 0x00100000 -OS_BASE equ 0xE0000000 -IMAGE_BASE equ (OS_BASE+LOAD_BASE) - -BOOT_VAR equ OS_BASE - -SB16Buffer equ (OS_BASE+0x10000) - -TASK_COUNT equ (CURRENT_TASK+0x04) -TASK_BASE equ (CURRENT_TASK+0x10) -TASK_DATA equ (CURRENT_TASK+0x20) -TASK_EVENT equ (CURRENT_TASK+0x20) - -FDD_BUFF equ (OS_BASE+0x000D000) - -VGABasePtr equ (OS_BASE+0x00A0000) - -IRQ_SAVE equ (OS_BASE+0x0190000) - -stack_data_start equ (OS_BASE+0x01A0000) -eth_data_start equ (OS_BASE+0x01A0000) -stack_data equ (OS_BASE+0x01A4000) -stack_data_end equ (OS_BASE+0x01Bffff) -resendQ equ (OS_BASE+0x01C0000) - -virtual at (OS_BASE+0x01C8F80) - tss TSS -end virtual +IMAGE_BASE equ LOAD_BASE LAST_PAGE equ 0x01CB000 -twdw equ (CURRENT_TASK-window_data) +NCPU equ 8 RING0_STACK_SIZE equ (0x2000 - 512) ;512 срщЄ фы  ъюэЄхъёЄр FPU @@ -386,6 +351,40 @@ virtual at 0 end virtual +struc SMEM +{ + .bk dd ? + .fd dd ? ;+4 + .base dd ? ;+8 + .size dd ? ;+12 + .access dd ? ;+16 + .refcount dd ? ;+20 + .name rb 32 ;+24 + .sizeof: +} + +struc SMAP +{ + .magic dd ? ; SMAP + .destroy dd ? ;internal destructor + .fd dd ? ;next object in list + .bk dd ? ;prev object in list + .pid dd ? ;owner id + + .base dd ? ;mapped base + .parent dd ? ;SMEM + .sizeof: +} + +virtual at 0 + SMEM SMEM +end virtual + +virtual at 0 + SMAP SMAP +end virtual + + struc HEAP_DATA { .mutex rd 1 @@ -438,13 +437,13 @@ virtual at 0 end virtual struc MEM_STATE -{ .mutex rd 1 - .smallmap rd 1 - .treemap rd 1 - .topsize rd 1 - .top rd 1 - .smallbins rd 4*32 - .treebins rd 32 +{ .mutex rd 1 + .smallmap rd 1 + .treemap rd 1 + .topsize rd 1 + .top rd 1 + .smallbins rd 4*32 + .treebins rd 32 } struc PG_DATA diff --git a/kernel/branches/kolibri_pe/core/dll.c b/kernel/branches/kolibri_pe/core/dll.c index 4e013e478b..05cd296f6a 100644 --- a/kernel/branches/kolibri_pe/core/dll.c +++ b/kernel/branches/kolibri_pe/core/dll.c @@ -235,12 +235,14 @@ int __stdcall pe_app_param(char *path, void *raw, addr_t ex_pg_dir, int sys_exec(char *path, char *cmdline, u32_t flags) { + PIMAGE_DOS_HEADER dos; PIMAGE_NT_HEADERS32 nt; size_t img_size; count_t img_pages; count_t img_tabs; + addr_t ex_pg_dir; addr_t ex_stack_page; addr_t ex_pl0_stack; @@ -588,6 +590,7 @@ bool link_pe(addr_t img_base) exp_dll = find_dll(&core_dll.link, libname); if(exp_dll == NULL) { + exp_dll = find_dll(¤t_slot->dll_list, libname); if(exp_dll == NULL) { diff --git a/kernel/branches/kolibri_pe/core/dll.inc b/kernel/branches/kolibri_pe/core/dll.inc index d5631f242f..d3cda5841d 100644 --- a/kernel/branches/kolibri_pe/core/dll.inc +++ b/kernel/branches/kolibri_pe/core/dll.inc @@ -17,6 +17,8 @@ PID_KERNEL equ 1 ;os_idle thread align 4 proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword + push ebx + mov ebx, [irq] ;irq num test ebx, ebx jz .err @@ -41,9 +43,11 @@ proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword mov [irq_owner + 4 * ebx], PID_KERNEL ; all handlers belong to a kernel stdcall enable_irq, [irq] + pop ebx mov eax, 1 ret .err: + pop ebx xor eax, eax ret endp @@ -824,6 +828,8 @@ proc load_driver stdcall, driver_name:dword mov dword [edx+8], 'vers' mov byte [edx+12], '/' mov esi, [driver_name] +.redo: + lea edx, [file_name] lea edi, [edx+13] mov ecx, 16 @@: diff --git a/kernel/branches/kolibri_pe/core/export.asm b/kernel/branches/kolibri_pe/core/export.asm index d940c1ba7a..0c9d21e1d5 100644 --- a/kernel/branches/kolibri_pe/core/export.asm +++ b/kernel/branches/kolibri_pe/core/export.asm @@ -17,6 +17,7 @@ .ascii " -export:CreateRingBuffer" # stdcall .ascii " -export:CommitPages" # eax, ebx, ecx FIXME .ascii " -export:UnmapPages" # eax, ecx FIXME + .ascii " -export:CreateObject" # eax, ebx FIXME .ascii " -export:DestroyObject" # eax @@ -24,7 +25,6 @@ .ascii " -export:SysMsgBoardStr" # .ascii " -export:SetScreen" # - .ascii " -export:PciApi" # .ascii " -export:PciRead8" # stdcall .ascii " -export:PciRead16" # stdcall @@ -38,6 +38,10 @@ .ascii " -export:HwCursorRestore" # .ascii " -export:HwCursorCreate" # + .ascii " -export:create_window" # cdecl + .ascii " -export:show_window" # cdecl + .ascii " -export:get_event" # cdecl + .ascii " -export:def_window_proc" # cdecl diff --git a/kernel/branches/kolibri_pe/core/fpu.inc b/kernel/branches/kolibri_pe/core/fpu.inc index 9a3594f298..884e514276 100644 --- a/kernel/branches/kolibri_pe/core/fpu.inc +++ b/kernel/branches/kolibri_pe/core/fpu.inc @@ -180,7 +180,7 @@ e7: ;#NM exception handler iglobal fpu_owner dd 0 - endg +endg reg_eip equ ebp+4 reg_cs equ ebp+8 diff --git a/kernel/branches/kolibri_pe/core/frame.c b/kernel/branches/kolibri_pe/core/frame.c index 3c5cec8886..734db68399 100644 --- a/kernel/branches/kolibri_pe/core/frame.c +++ b/kernel/branches/kolibri_pe/core/frame.c @@ -300,7 +300,7 @@ addr_t alloc_page(void) list_remove(&slab->link); list_prepend(&slab->link, &page_cache.full_slabs); page_cache.partial_count--; - DBG("%s insert empty page slab\n"); + DBG("%s insert empty page slab\n", __FUNCTION__); }; spinlock_unlock(&page_cache.lock); @@ -396,9 +396,9 @@ size_t __fastcall frame_free(addr_t addr) (slab->avail >= 4)) { slab->state = 1; - // list_remove(&slab->link); - // list_prepend(&slab->link, &page_cache.partial_slabs); - // page_cache.partial_count++; + list_remove(&slab->link); + list_prepend(&slab->link, &page_cache.partial_slabs); + page_cache.partial_count++; DBG("%s: insert partial page slab\n", __FUNCTION__); } @@ -440,3 +440,6 @@ count_t get_free_mem() return z_core.free_count; } + + + diff --git a/kernel/branches/kolibri_pe/core/heap.c b/kernel/branches/kolibri_pe/core/heap.c index 292b2036d0..1b2d553dae 100644 --- a/kernel/branches/kolibri_pe/core/heap.c +++ b/kernel/branches/kolibri_pe/core/heap.c @@ -1,4 +1,6 @@ +#define ALLOC_FAST + #include #include #include @@ -294,10 +296,10 @@ addr_t __fastcall mem_alloc(size_t size, u32_t flags) map = (mmap_t*)PA2KA(frame_alloc( (sizeof(mmap_t) + sizeof(addr_t) * pages) >> PAGE_WIDTH)); - map->size = size; - if ( map ) { + map->size = size; + order = size >> HF_WIDTH; if( order ) @@ -313,7 +315,6 @@ addr_t __fastcall mem_alloc(size_t size, u32_t flags) if( frame ) { - addr_t page = 0; addr_t mem; z_heap.free_count -= (1 << order); @@ -342,36 +343,37 @@ addr_t __fastcall mem_alloc(size_t size, u32_t flags) if( flags & PG_MAP ) { + addr_t page_frame; -#ifdef ALLOC_IMM +#ifdef ALLOC_FAST while( pages ) { u32_t order; - addr_t page_frame; - asm volatile ("bsr %0, %1":"=&r"(order):"r"(tmp):"cc"); - asm volatile ("btr %0, %1" :"=r"(tmp):"r"(order):"cc"); + asm volatile ("bsrl %1, %0":"=&r"(order):"r"(pages):"cc"); + asm volatile ("btrl %1, %0" :"=&r"(pages):"r"(order):"cc"); - page_frame = frame_alloc(1 << order) | (flags & 0xFFF); + page_frame = frame_alloc(1 << order) | (flags & 0xFFF); /* FIXME check */ for(i = 0; i < 1 << order; i++) { - *pte++ = 0; //page; - *mpte++ = page; + *pte++ = 0; + *mpte++ = page_frame; asm volatile ( "invlpg (%0)" ::"r" (mem) ); mem+= 4096; + page_frame+= 4096; }; } #else - page = PG_DEMAND | (flags & 0xFFF); + page_frame = PG_DEMAND | (flags & 0xFFF); while(pages--) { *pte++ = 0; - *mpte++ = page; + *mpte++ = page_frame; asm volatile ( "invlpg (%0)" ::"r" (mem) ); mem+= 4096; }; @@ -381,7 +383,7 @@ addr_t __fastcall mem_alloc(size_t size, u32_t flags) { while(pages--) { - *pte++ = 0; //page; + *pte++ = 0; *mpte++ = 0; asm volatile ( "invlpg (%0)" ::"r" (mem) ); @@ -389,7 +391,6 @@ addr_t __fastcall mem_alloc(size_t size, u32_t flags) }; } -#endif DBG("%s %x size %d order %d\n", __FUNCTION__, heap, size, order); return heap; diff --git a/kernel/branches/kolibri_pe/core/heap.inc b/kernel/branches/kolibri_pe/core/heap.inc index bd64cbda01..c5100a44bb 100644 --- a/kernel/branches/kolibri_pe/core/heap.inc +++ b/kernel/branches/kolibri_pe/core/heap.inc @@ -23,7 +23,6 @@ HEAP_TOP equ 0x7FC00000 align 4 _init_user_heap: init_heap: - mov ebx,[current_slot] mov eax, [ebx+APPDATA.heap_top] test eax, eax @@ -46,6 +45,7 @@ init_heap: sub eax, 4096 or ecx, FREE_BLOCK mov [page_tabs+edx], ecx + ret align 4 diff --git a/kernel/branches/kolibri_pe/core/init.asm b/kernel/branches/kolibri_pe/core/init.asm index fea1473f75..f8ab277822 100644 --- a/kernel/branches/kolibri_pe/core/init.asm +++ b/kernel/branches/kolibri_pe/core/init.asm @@ -230,7 +230,6 @@ core_init: mov eax, cr3 mov cr3, eax - jmp system_init if 0 diff --git a/kernel/branches/kolibri_pe/core/memory.inc b/kernel/branches/kolibri_pe/core/memory.inc index 1076621d5e..3d655660c7 100644 --- a/kernel/branches/kolibri_pe/core/memory.inc +++ b/kernel/branches/kolibri_pe/core/memory.inc @@ -265,6 +265,7 @@ proc new_mem_resize stdcall, new_size:dword pop edi pop esi @@: + call _alloc_page test eax, eax jz .exit diff --git a/kernel/branches/kolibri_pe/core/pe.c b/kernel/branches/kolibri_pe/core/pe.c index 07d39b59bc..df694a4790 100644 --- a/kernel/branches/kolibri_pe/core/pe.c +++ b/kernel/branches/kolibri_pe/core/pe.c @@ -135,11 +135,11 @@ addr_t __fastcall load_image(const char *path) }; if( ! validate_pe(raw, raw_size, false) ) - { + { DBG("invalid pe file %s\n", path); mem_free(raw); - return NULL; - } + return NULL; + } dos = (PIMAGE_DOS_HEADER)raw; nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); @@ -207,7 +207,6 @@ void create_image(addr_t img_base, addr_t raw, bool force_clear) u32_t sec_align; int i; - /* assumed that image is valid */ dos = (PIMAGE_DOS_HEADER)raw; @@ -233,11 +232,11 @@ void create_image(addr_t img_base, addr_t raw, bool force_clear) if(force_clear) { - sec_size = (img_sec->Misc.VirtualSize + sec_align -1) & -sec_align; + sec_size = (img_sec->Misc.VirtualSize + sec_align -1) & -sec_align; - if(sec_size > img_sec->SizeOfRawData) - sec_clear(dest_ptr + img_sec->SizeOfRawData, - sec_size - img_sec->SizeOfRawData); + if(sec_size > img_sec->SizeOfRawData) + sec_clear(dest_ptr + img_sec->SizeOfRawData, + sec_size - img_sec->SizeOfRawData); }; img_sec++; }; @@ -314,8 +313,6 @@ bool link_image(addr_t img_base) imp = MakePtr(PIMAGE_IMPORT_DESCRIPTOR, img_base, nt->OptionalHeader.DataDirectory[1].VirtualAddress); - - while ( 1 ) { PIMAGE_THUNK_DATA32 thunk; @@ -420,7 +417,7 @@ bool link_image(addr_t img_base) if ( !warn ) return true; - else + else return false; } diff --git a/kernel/branches/kolibri_pe/core/slab.c b/kernel/branches/kolibri_pe/core/slab.c index f785096a27..e2715bcc78 100644 --- a/kernel/branches/kolibri_pe/core/slab.c +++ b/kernel/branches/kolibri_pe/core/slab.c @@ -27,40 +27,40 @@ static slab_cache_t * slab_cache_alloc(); */ static slab_t * slab_space_alloc(slab_cache_t *cache, int flags) { - void *data; - slab_t *slab; - size_t fsize; - unsigned int i; - u32_t p; + void *data; + slab_t *slab; + size_t fsize; + unsigned int i; + u32_t p; DBG("%s order %d\n", __FUNCTION__, cache->order); data = (void*)PA2KA(frame_alloc(1 << cache->order)); - if (!data) { - return NULL; - } - slab = (slab_t*)slab_create(); - if (!slab) { + if (!data) { + return NULL; + } + slab = (slab_t*)slab_create(); + if (!slab) { frame_free(KA2PA(data)); - return NULL; - } + return NULL; + } /* Fill in slab structures */ - for (i = 0; i < ((u32_t) 1 << cache->order); i++) - frame_set_parent(ADDR2PFN(KA2PA(data)) + i, slab); + for (i = 0; i < ((u32_t) 1 << cache->order); i++) + frame_set_parent(ADDR2PFN(KA2PA(data)) + i, slab); - slab->start = data; - slab->available = cache->objects; - slab->nextavail = (void*)data; - slab->cache = cache; + slab->start = data; + slab->available = cache->objects; + slab->nextavail = (void*)data; + slab->cache = cache; - for (i = 0, p = (u32_t)slab->start; i < cache->objects; i++) - { - *(addr_t *)p = p+cache->size; - p = p+cache->size; - }; - atomic_inc(&cache->allocated_slabs); - return slab; + for (i = 0, p = (u32_t)slab->start; i < cache->objects; i++) + { + *(addr_t *)p = p+cache->size; + p = p+cache->size; + }; + atomic_inc(&cache->allocated_slabs); + return slab; } /** @@ -178,7 +178,7 @@ _slab_cache_create(slab_cache_t *cache, int (*destructor)(void *obj), int flags) { - int pages; + int pages; // ipl_t ipl; // memsetb((uintptr_t)cache, sizeof(*cache), 0); @@ -188,15 +188,15 @@ _slab_cache_create(slab_cache_t *cache, // align = sizeof(unative_t); // size = ALIGN_UP(size, align); - cache->size = size; + cache->size = size; // cache->constructor = constructor; // cache->destructor = destructor; - cache->flags = flags; + cache->flags = flags; - list_initialize(&cache->full_slabs); - list_initialize(&cache->partial_slabs); - list_initialize(&cache->magazines); + list_initialize(&cache->full_slabs); + list_initialize(&cache->partial_slabs); + list_initialize(&cache->magazines); // spinlock_initialize(&cache->slablock, "slab_lock"); // spinlock_initialize(&cache->maglock, "slab_maglock"); // if (! (cache->flags & SLAB_CACHE_NOMAGAZINE)) @@ -205,23 +205,23 @@ _slab_cache_create(slab_cache_t *cache, /* Compute slab sizes, object counts in slabs etc. */ /* Minimum slab order */ - pages = SIZE2FRAMES(cache->size); + pages = SIZE2FRAMES(cache->size); /* We need the 2^order >= pages */ - if (pages <= 1) - cache->order = 0; - else - cache->order = fnzb(pages-1)+1; + if (pages <= 1) + cache->order = 0; + else + cache->order = fnzb(pages-1)+1; - while (badness(cache) > SLAB_MAX_BADNESS(cache)) { - cache->order += 1; - } - cache->objects = comp_objects(cache); + while (badness(cache) > SLAB_MAX_BADNESS(cache)) { + cache->order += 1; + } + cache->objects = comp_objects(cache); /* Add cache to cache list */ // ipl = interrupts_disable(); // spinlock_lock(&slab_cache_lock); - list_append(&cache->link, &slab_cache_list); + list_append(&cache->link, &slab_cache_list); // spinlock_unlock(&slab_cache_lock); // interrupts_restore(ipl); @@ -240,7 +240,9 @@ slab_cache_t * slab_cache_create( DBG("%s\n", __FUNCTION__); cache = (slab_cache_t*)slab_cache_alloc(); - _slab_cache_create(cache, size, align, constructor, destructor, flags); + + _slab_cache_create(cache, size, align, constructor, destructor, flags); + return cache; } @@ -331,9 +333,9 @@ void __fastcall slab_free(slab_cache_t *cache, void *obj) static slab_t *slab_create() { - slab_t *slab; - void *obj; - u32_t p; + slab_t *slab; + void *obj; + u32_t p; DBG("%s\n", __FUNCTION__); @@ -390,9 +392,9 @@ static slab_t *slab_create() static slab_cache_t * slab_cache_alloc() { - slab_t *slab; - void *obj; - u32_t *p; + slab_t *slab; + void *obj; + u32_t *p; DBG("%s\n", __FUNCTION__); @@ -401,62 +403,62 @@ static slab_cache_t * slab_cache_alloc() // spinlock_unlock(&cache->slablock); // slab = slab_create(); - void *data; - unsigned int i; + void *data; + unsigned int i; data = (void*)(PA2KA(alloc_page())); - if (!data) { - return NULL; - } + if (!data) { + return NULL; + } - slab = (slab_t*)((u32_t)data + PAGE_SIZE - sizeof(slab_t)); + slab = (slab_t*)((u32_t)data + PAGE_SIZE - sizeof(slab_t)); /* Fill in slab structures */ - frame_set_parent(ADDR2PFN(KA2PA(data)), slab); + frame_set_parent(ADDR2PFN(KA2PA(data)), slab); - slab->start = data; - slab->available = slab_cache_cache.objects; - slab->nextavail = (void*)data; - slab->cache = &slab_cache_cache; + slab->start = data; + slab->available = slab_cache_cache.objects; + slab->nextavail = (void*)data; + slab->cache = &slab_cache_cache; - for (i = 0,p = (u32_t*)slab->start;i < slab_cache_cache.objects; i++) - { - *p = (u32_t)p+slab_cache_cache.size; - p = (u32_t*)((u32_t)p+slab_cache_cache.size); - }; + for (i = 0,p = (u32_t*)slab->start;i < slab_cache_cache.objects; i++) + { + *p = (u32_t)p+slab_cache_cache.size; + p = (u32_t*)((u32_t)p+slab_cache_cache.size); + }; - atomic_inc(&slab_cache_cache.allocated_slabs); + atomic_inc(&slab_cache_cache.allocated_slabs); // spinlock_lock(&cache->slablock); } else { - slab = list_get_instance(slab_cache_cache.partial_slabs.next, slab_t, link); - list_remove(&slab->link); - } - obj = slab->nextavail; - slab->nextavail = *((void**)obj); - slab->available--; + slab = list_get_instance(slab_cache_cache.partial_slabs.next, slab_t, link); + list_remove(&slab->link); + } + obj = slab->nextavail; + slab->nextavail = *((void**)obj); + slab->available--; - if (!slab->available) - list_prepend(&slab->link, &slab_cache_cache.full_slabs); - else - list_prepend(&slab->link, &slab_cache_cache.partial_slabs); + if (!slab->available) + list_prepend(&slab->link, &slab_cache_cache.full_slabs); + else + list_prepend(&slab->link, &slab_cache_cache.partial_slabs); // spinlock_unlock(&cache->slablock); - return (slab_cache_t*)obj; + return (slab_cache_t*)obj; } void slab_cache_init(void) { DBG("%s\n", __FUNCTION__); - _slab_cache_create(&slab_cache_cache, sizeof(slab_cache_t), + _slab_cache_create(&slab_cache_cache, sizeof(slab_cache_t), sizeof(void *), NULL, NULL, SLAB_CACHE_NOMAGAZINE | SLAB_CACHE_SLINSIDE); /* Initialize external slab cache */ - slab_cache = slab_cache_create(sizeof(slab_t), + slab_cache = slab_cache_create(sizeof(slab_t), 0, NULL, NULL,SLAB_CACHE_MAGDEFERRED); }; diff --git a/kernel/branches/kolibri_pe/core/sys32.inc b/kernel/branches/kolibri_pe/core/sys32.inc index 00015e459e..17324e0aaa 100644 --- a/kernel/branches/kolibri_pe/core/sys32.inc +++ b/kernel/branches/kolibri_pe/core/sys32.inc @@ -291,22 +291,13 @@ ready_for_next_irq_1: ret irqD: - save_ring3_context - mov ax, sel_app_data - mov ds, ax - mov es, ax - - mov dx,0xf0 + push eax mov al,0 - out dx,al - - mov dx,0xa0 + out 0xf0,al mov al,0x20 - out dx,al - mov dx,0x20 - out dx,al - - restore_ring3_context + out 0xa0,al + out 0x20,al + pop eax iret @@ -459,7 +450,6 @@ terminate: ; terminate application @@: ;mov esi,process_terminating ;call sys_msg_board_str - DEBUGF 1,"%s",process_terminating @@: cli cmp [application_table_status],0 @@ -603,11 +593,13 @@ term9: xor eax, eax mov [window_data+esi+WDATA.box.left],eax + mov [window_data+esi+WDATA.box.width],eax mov [window_data+esi+WDATA.box.top],eax mov [window_data+esi+WDATA.box.height],eax mov [window_data+esi+WDATA.cl_workarea],eax mov [window_data+esi+WDATA.cl_titlebar],eax + mov [window_data+esi+WDATA.cl_frames],eax mov dword [window_data+esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn lea edi, [esi+draw_data] @@ -814,7 +806,6 @@ term9: mov [application_table_status],0 ;mov esi,process_terminated ;call sys_msg_board_str - DEBUGF 1,"%s",process_terminated add esp, 4 ret restore .slot diff --git a/kernel/branches/kolibri_pe/core/syscall.asm b/kernel/branches/kolibri_pe/core/syscall.asm index 0e7f01a3cb..04b464f047 100644 --- a/kernel/branches/kolibri_pe/core/syscall.asm +++ b/kernel/branches/kolibri_pe/core/syscall.asm @@ -4,6 +4,21 @@ format MS COFF public _i40 +public _create_window +public _show_window +public _get_event +public _def_window_proc + +public stb_create_window +public stb_show_window +public stb_get_event +public stb_def_window_proc + +extrn _sys_create_window +extrn _sys_show_window +extrn _sys_get_event +extrn _sys_def_window_proc + section '.text' code readable align 16 align 16 @@ -14,3 +29,74 @@ _i40: int 0x41 iretd +align 4 +stb_create_window: + + pushd [ecx+20] + pushd [ecx+16] + pushd [ecx+12] + pushd [ecx+8] + pushd [ecx+4] + pushd [ecx] + + call _sys_create_window + + add esp, 24 + mov [esp + 32], eax + ret + +align 4 +stb_show_window: + pushd [ecx] + call _sys_show_window + add esp, 4 + mov [esp + 32], eax + ret + +align 4 +stb_get_event: + pushd [ecx] + call _sys_get_event + add esp, 4 + mov [esp + 32], eax + ret + +align 4 +stb_def_window_proc: + pushd [ecx] + call _sys_def_window_proc + add esp, 4 + mov [esp + 32], eax + ret + +align 4 +_create_window: + + lea ecx, [esp+4] + mov eax, 73 + int 0x41 + ret + +align 4 +_show_window: + + lea ecx, [esp+4] + mov eax, 74 + int 0x41 + ret + +align 4 +_get_event: + lea ecx, [esp+4] + mov eax, 75 + int 0x41 + ret + +align 4 +_def_window_proc: + + lea ecx, [esp+4] + mov eax, 76 + int 0x41 + ret + diff --git a/kernel/branches/kolibri_pe/core/syscall.inc b/kernel/branches/kolibri_pe/core/syscall.inc index 5fd71cfc41..1e0b88e899 100644 --- a/kernel/branches/kolibri_pe/core/syscall.inc +++ b/kernel/branches/kolibri_pe/core/syscall.inc @@ -16,27 +16,11 @@ cross_order: mov ecx, edx mov edx, esi mov esi, edi - mov edi, [esp+28 + 4] - and edi,0xff + movzx edi, byte[esp+28 + 4] call dword [servetable+edi*4] ret -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; SYSTEM CALL ENTRY ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -align 16 -i41: - pushad - cld - movzx eax, al - call dword [servetable2 + eax * 4] - popad - iretd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; SYSENTER ENTRY ;; @@ -68,6 +52,21 @@ sysenter_entry: pop edx sysexit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; SYSTEM CALL ENTRY ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +align 16 +i40: + pushad + cld + movzx eax, al + call dword [servetable2 + eax * 4] + popad + iretd + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; SYSCALL ENTRY ;; @@ -183,79 +182,83 @@ iglobal align 4 servetable2: - dd sys_drawwindow ; 0-DrawWindow - dd syscall_setpixel ; 1-SetPixel - dd sys_getkey ; 2-GetKey - dd sys_clock ; 3-GetTime - dd syscall_writetext ; 4-WriteText - dd delay_hs ; 5-DelayHs - dd syscall_openramdiskfile ; 6-OpenRamdiskFile - dd syscall_putimage ; 7-PutImage - dd sys_button ; 8-DefineButton - dd sys_cpuusage ; 9-GetProcessInfo - dd sys_waitforevent ; 10-WaitForEvent - dd sys_getevent ; 11-CheckForEvent - dd sys_redrawstat ; 12-BeginDraw and EndDraw - dd syscall_drawrect ; 13-DrawRect - dd syscall_getscreensize ; 14-GetScreenSize - dd sys_background ; 15-bgr - dd sys_cachetodiskette ; 16-FlushFloppyCache - dd sys_getbutton ; 17-GetButton - dd sys_system ; 18-System Services - dd paleholder ; 19-reserved - dd cross_order ; 20-ResetMidi and OutputMidi - dd cross_order ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,. - dd cross_order ; 22-setting date,time,clock and alarm-clock - dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent - dd cross_order ; 24-PlayCdTrack,StopCd and GetCdPlaylist - dd undefined_syscall ; 25-reserved - dd cross_order ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,. - dd undefined_syscall ; 27-reserved - dd undefined_syscall ; 28-reserved - dd sys_date ; 29-GetDate - dd cross_order ; 30-Get/SetCurrentDirectory - dd undefined_syscall ; 31-reserved - dd undefined_syscall ; 32-reserved - dd undefined_syscall ; 33-reserved - dd undefined_syscall ; 34-reserved - dd syscall_getpixel ; 35-GetPixel - dd undefined_syscall ; 36-reserved - dd cross_order ; 37-GetMousePosition_ScreenRelative,. - dd syscall_drawline ; 38-DrawLine - dd cross_order ; 39-GetBackgroundSize,ReadBgrData,. - dd set_app_param ; 40-WantEvents - dd syscall_getirqowner ; 41-GetIrqOwner - dd get_irq_data ; 42-ReadIrqData - dd cross_order ; 43-SendDeviceData - dd sys_programirq ; 44-ProgramIrqs - dd reserve_free_irq ; 45-ReserveIrq and FreeIrq - dd cross_order ; 46-ReservePortArea and FreePortArea - dd cross_order ; 47-WriteNum - dd cross_order ; 48-SetRedrawType and SetButtonType - dd cross_order ; 49-Advanced Power Management (APM) - dd cross_order ; 50-Window shape & scale - dd cross_order ; 51-Threads - dd cross_order ; 52-Stack driver status - dd cross_order ; 53-Socket interface - dd undefined_syscall ; 54-reserved - dd cross_order ; 55-Sound interface - dd undefined_syscall ; 56-reserved - dd cross_order ; 57-PCI BIOS32 - dd cross_order ; 58-Common file system interface - dd undefined_syscall ; 59-reserved - dd cross_order ; 60-Inter Process Communication - dd cross_order ; 61-Direct graphics access - dd cross_order ; 62-PCI functions - dd cross_order ; 63-System message board - dd cross_order ; 64-Resize application memory usage - dd cross_order ; 65-PutImagePalette - dd cross_order ; 66-Process definitions - keyboard - dd cross_order ; 67-Window move or resize - dd cross_order ; 68-Some internal services - dd cross_order ; 69-Debug - dd cross_order ; 70-Common file system interface, version 2 - dd cross_order ; 71-Window settings - dd cross_order ; 72-Send window message + dd sys_drawwindow ; 0-DrawWindow + dd syscall_setpixel ; 1-SetPixel + dd sys_getkey ; 2-GetKey + dd sys_clock ; 3-GetTime + dd syscall_writetext ; 4-WriteText + dd delay_hs ; 5-DelayHs + dd syscall_openramdiskfile ; 6-OpenRamdiskFile + dd syscall_putimage ; 7-PutImage + dd sys_button ; 8-DefineButton + dd sys_cpuusage ; 9-GetProcessInfo + dd sys_waitforevent ; 10-WaitForEvent + dd sys_getevent ; 11-CheckForEvent + dd sys_redrawstat ; 12-BeginDraw and EndDraw + dd syscall_drawrect ; 13-DrawRect + dd syscall_getscreensize ; 14-GetScreenSize + dd sys_background ; 15-bgr + dd sys_cachetodiskette ; 16-FlushFloppyCache + dd sys_getbutton ; 17-GetButton + dd sys_system ; 18-System Services + dd paleholder ; 19-reserved + dd cross_order ; 20-ResetMidi and OutputMidi + dd cross_order ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,. + dd cross_order ; 22-setting date,time,clock and alarm-clock + dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent + dd cross_order ; 24-PlayCdTrack,StopCd and GetCdPlaylist + dd undefined_syscall ; 25-reserved + dd cross_order ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,. + dd undefined_syscall ; 27-reserved + dd undefined_syscall ; 28-reserved + dd sys_date ; 29-GetDate + dd cross_order ; 30-Get/SetCurrentDirectory + dd undefined_syscall ; 31-reserved + dd undefined_syscall ; 32-reserved + dd undefined_syscall ; 33-reserved + dd undefined_syscall ; 34-reserved + dd syscall_getpixel ; 35-GetPixel + dd undefined_syscall ; 36-reserved + dd cross_order ; 37-GetMousePosition_ScreenRelative,. + dd syscall_drawline ; 38-DrawLine + dd cross_order ; 39-GetBackgroundSize,ReadBgrData,. + dd set_app_param ; 40-WantEvents + dd syscall_getirqowner ; 41-GetIrqOwner + dd get_irq_data ; 42-ReadIrqData + dd cross_order ; 43-SendDeviceData + dd sys_programirq ; 44-ProgramIrqs + dd reserve_free_irq ; 45-ReserveIrq and FreeIrq + dd cross_order ; 46-ReservePortArea and FreePortArea + dd cross_order ; 47-WriteNum + dd cross_order ; 48-SetRedrawType and SetButtonType + dd cross_order ; 49-Advanced Power Management (APM) + dd cross_order ; 50-Window shape & scale + dd cross_order ; 51-Threads + dd cross_order ; 52-Stack driver status + dd cross_order ; 53-Socket interface + dd undefined_syscall ; 54-reserved + dd cross_order ; 55-Sound interface + dd undefined_syscall ; 56-reserved + dd cross_order ; 57-PCI BIOS32 + dd cross_order ; 58-Common file system interface + dd undefined_syscall ; 59-reserved + dd cross_order ; 60-Inter Process Communication + dd cross_order ; 61-Direct graphics access + dd cross_order ; 62-PCI functions + dd cross_order ; 63-System message board + dd cross_order ; 64-Resize application memory usage + dd cross_order ; 65-PutImagePalette + dd cross_order ; 66-Process definitions - keyboard + dd cross_order ; 67-Window move or resize + dd cross_order ; 68-Some internal services + dd cross_order ; 69-Debug + dd cross_order ; 70-Common file system interface, version 2 + dd cross_order ; 71-Window settings + dd cross_order ; 72-Send window message + dd stb_create_window ; 73-create window + dd stb_show_window ; 74-show window + dd stb_get_event ; 75-get event + dd stb_def_window_proc times 255 - ( ($-servetable2) /4 ) dd undefined_syscall dd sys_end ; -1-end application diff --git a/kernel/branches/kolibri_pe/core/taskman.inc b/kernel/branches/kolibri_pe/core/taskman.inc index 383f264390..4b7b92d9bb 100644 --- a/kernel/branches/kolibri_pe/core/taskman.inc +++ b/kernel/branches/kolibri_pe/core/taskman.inc @@ -119,7 +119,7 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \ filename rb 1024 save_cr3 dd ? - slot dd ? + slot dd ? slot_base dd ? ;app header data @@ -141,6 +141,7 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \ @@: cmp edi, ecx jae .bigfilename + lodsb stosb test al, al @@ -172,7 +173,7 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \ test eax, eax jz .err_hdr - DEBUGF 1,"%s",new_process_loading + ; DEBUGF 1,"%s",new_process_loading lea ebx, [application_table_status] call wait_mutex @@ -226,8 +227,8 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \ mov [ebx+APPDATA.mem_size],ecx mov edi, [file_size] - ; add edi, 4095 - ; and edi, not 4095 + add edi, 4095 + and edi, not 4095 sub ecx, edi jna @F @@ -261,6 +262,7 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \ pop ebx mov eax, -ERROR_FILE_NOT_FOUND ret + .failed: mov eax, [save_cr3] call set_cr3 @@ -279,6 +281,7 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \ ret endp + align 4 proc pe_app_param stdcall path:dword, raw:dword, ex_pg_dir:dword, ex_stack:dword @@ -417,7 +420,7 @@ proc pe_app_param stdcall path:dword, raw:dword, ex_pg_dir:dword, ex_stack:dword lea ecx, [ebx+REG_EDI] mov edx, [ex_stack] - mov [ebx+REG_ENTRY], dword _sys_app_entry + mov [ebx+REG_ENTRY], dword _sys_app_entry mov [ebx+REG_RESTART], dword _pe_restart mov [ebx+REG_RAW], eax mov [ebx+REG_CSTACK], ecx @@ -439,7 +442,7 @@ proc pe_app_param stdcall path:dword, raw:dword, ex_pg_dir:dword, ex_stack:dword pop esi pop ebx - ret + ret endp align 4 @@ -448,7 +451,6 @@ _pe_restart: popad iretd - align 4 proc get_new_process_place ;input: @@ -674,9 +676,10 @@ align 4 add esp, 16 ret + + align 4 set_cr3: - mov ebx, [current_slot] mov [ebx+APPDATA.dir_table], eax mov cr3, eax @@ -1045,9 +1048,8 @@ proc new_sys_threads mov [app_eip], ebx mov [app_esp], ecx - ;mov esi,new_process_loading - ;call sys_msg_board_str - DEBUGF 1,"%s",new_process_loading + ;DEBUGF 1,"%s",new_process_loading + .wait_lock: cmp [application_table_status],0 je .get_lock @@ -1101,9 +1103,7 @@ proc new_sys_threads stdcall set_app_params ,[slot],eax,dword 0,\ dword 0,dword 0 - ;mov esi,new_process_running - ;call sys_msg_board_str ;output information about succefull startup - DEBUGF 1,"%s",new_process_running + ; DEBUGF 1,"%s",new_process_running mov [application_table_status],0 ;unlock application_table_status mutex mov eax,[process_number] ;set result @@ -1207,7 +1207,7 @@ proc set_app_params stdcall,slot:dword, params:dword,\ mov edx,[params] mov edx,[edx] ;app_cmdline test edx,edx - jz @f ;application doesn't need parameters + jz @f ;application doesn't need parameters mov eax, edx add eax, 256 @@ -1225,7 +1225,7 @@ proc set_app_params stdcall,slot:dword, params:dword,\ mov edx,[params] mov edx, [edx+4] ;app_path test edx,edx - jz @F ;application don't need path of file + jz @F ;application don't need path of file mov eax, edx add eax, 1024 jc @f @@ -1274,13 +1274,13 @@ proc set_app_params stdcall,slot:dword, params:dword,\ mov [ebx+REG_ECX], eax mov [ebx+REG_EAX], eax - mov eax, [esi+0x08] ;app_eip - mov [ebx+REG_EIP], eax ;app_entry + mov eax, [esi+0x08] ;app_eip + mov [ebx+REG_EIP], eax ;app_entry mov [ebx+REG_CS], dword sel_app_code - mov [ebx+REG_EFLAGS], dword EFL_IOPL3+EFL_IF + mov [ebx+REG_EFLAGS], dword EFL_IOPL3+EFL_IF - mov eax, [esi+0x0C] ;app_esp - mov [ebx+REG_APP_ESP], eax ;app_stack + mov eax, [esi+0x0C] ;app_esp + mov [ebx+REG_APP_ESP], eax ;app_stack mov [ebx+REG_SS], dword sel_app_data lea ecx, [ebx+REG_RET] diff --git a/kernel/branches/kolibri_pe/data32.inc b/kernel/branches/kolibri_pe/data32.inc index 46ac99067b..08b81644a4 100644 --- a/kernel/branches/kolibri_pe/data32.inc +++ b/kernel/branches/kolibri_pe/data32.inc @@ -63,6 +63,7 @@ keymap_alt: boot_setostask db 'Setting OS task',0 boot_allirqs db 'Unmasking all IRQs',0 boot_tsc db 'Reading TSC',0 + boot_cpufreq db 'CPU frequency is ',' ',' MHz',0 boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0 boot_pal_vga db 'Setting VGA 640x480 palette',0 boot_failed db 'Failed to start first app',0 @@ -71,8 +72,8 @@ keymap_alt: ; boot_tasking db 'All set - press ESC to start',0 ;end if -new_process_loading db 'K : New Process - loading',13,10,0 -new_process_running db 'K : New Process - done',13,10,0 +;new_process_loading db 'K : New Process - loading',13,10,0 +;new_process_running db 'K : New Process - done',13,10,0 start_not_enough_memory db 'K : New Process - not enough memory',13,10,0 msg_unresolved db 'unresolved ',0 @@ -80,7 +81,10 @@ msg_module db 'in module ',0 msg_version db 'incompatible driver version',13,10,0 msg_www db 'please visit www.kolibrios.org',13,10,0 msg_CR db 13,10,0 +aSis db 'SIS',0 +intel_str db "GenuineIntel",0 +AMD_str db "AuthenticAMD",0 ;szSound db 'SOUND',0 ;szInfinity db 'INFINITY',0 @@ -92,6 +96,8 @@ szAtiHW db '/rd/1/drivers/ati2d.drv',0 szSTART db 'START',0 szEXPORTS db 'EXPORTS',0 +sz_EXPORTS db '_EXPORTS',0 + szIMPORTS db 'IMPORTS',0 read_firstapp db '/sys/' @@ -107,7 +113,13 @@ vrr_m db 'VRR_M',0 kernel_file db 'KERNEL MNT' - ;supported videomodes +align 4 + +shmem_list: + .bk dd shmem_list + .fd dd shmem_list + +; supported videomodes mode_1280_1024_32: dw 1280,1024,32,60 mode_1280_1024_24: @@ -129,13 +141,6 @@ mode_640_480_16: mode_320_240_8: dw 320,240,8,60 - -;bx_from_load: dw 'r1' ; ёЄЁєъЄєЁр фы  їЁрэхэш  ярЁрьхЄЁют- юЄъєфр ур°Ёєчшышё№, схЁхЄё  эшцх шч bx ; {SPraid}[13.03.2007] -; ; a,b,c,d - тшэўхёЄхЁ√, r - Ёрь фшёъ -; ; # фшёър... ёшьтюы, р эх срщЄ. '1', р эх 1 - - - ; mike.dld { db 0 dd servetable-0x10000 @@ -513,6 +518,11 @@ hdpos rd 1 ; for boot 0x1 fat32part rd 1 ; for boot 0x1 cdpos rd 1 +;CPUID information +cpu_vendor rd 3 +cpu_sign rd 1 +cpu_info rd 1 +cpu_caps rd 4 pg_data PG_DATA diff --git a/kernel/branches/kolibri_pe/docs/sysfuncr.txt b/kernel/branches/kolibri_pe/docs/sysfuncr.txt index 841cbabef2..4428e219e5 100644 --- a/kernel/branches/kolibri_pe/docs/sysfuncr.txt +++ b/kernel/branches/kolibri_pe/docs/sysfuncr.txt @@ -1,4 +1,4 @@ -СИСТЕМНЫЕ ФУНКЦИИ ОПЕРАЦИОННОЙ СИСТЕМЫ Kolibri 0.7.1.0 +СИСТЕМНЫЕ ФУНКЦИИ ОПЕРАЦИОННОЙ СИСТЕМЫ Kolibri 0.7.5.0 Номер функции помещается в регистр eax. Вызов системной функции осуществляется командой "int 0x40". @@ -67,7 +67,7 @@ координата (или, возможно, обе) считается нулем, а если и это не помогает, то соответствующий размер (или, возможно, оба) устанавливается в размер экрана. - + Далее обозначим xpos,ypos,xsize,ysize - значения, передаваемые в ebx,ecx. Координаты приводятся относительно левого верхнего угла окна, который, таким образом, задается как (0,0), координаты @@ -223,9 +223,6 @@ требуется передать управление следующему процессу (закончить текущий квант времени), используйте подфункцию 1 функции 68. - * При текущей реализации произойдет немедленный возврат из функции, - если сложение ebx с текущим значением счетчика времени вызовет - 32-битное переполнение. ====================================================================== =============== Функция 6 - прочитать файл с рамдиска. =============== @@ -621,16 +618,22 @@ * eax = 17 - номер функции Возвращаемое значение: * если буфер пуст, возвращается eax=1 - * если буфер не пуст, тогда возвращается: старшие 24 бита eax - содержат идентификатор кнопки (в частности, в ah оказывается - младший байт идентификатора; если все кнопки имеют идентификатор, - меньший 256, то для различения достаточно ah), - а в al возвращается 0 - если использовалась левая кнопка мыши, или бит той кнопки мыши, которая использовалась. + * если буфер непуст: + * старшие 24 бита eax содержат идентификатор кнопки + (в частности, в ah оказывается младший байт идентификатора; + если все кнопки имеют идентификатор, меньший 256, + то для различения достаточно ah) + * al = 0 - кнопка была нажата левой кнопкой мыши + * al = бит, соответствующий нажавшей кнопке мыши, если не левой Замечания: * "Буфер" хранит только одну кнопку, при нажатии новой кнопки информация о старой теряется. * При вызове этой функции приложением с неактивным окном возвращается ответ "буфер пуст". + * Возвращаемое значение al соответствует состоянию кнопок мыши + в формате подфункции 2 функции 37 в момент начала нажатия + на кнопку, за исключением младшего бита (соответствующего левой + кнопке мыши), который сбрасывается. ====================================================================== ==== Функция 18, подфункция 2 - завершить процесс/поток по слоту. ==== @@ -735,7 +738,7 @@ * функция не возвращает значения ====================================================================== -======= Функция 18, подфункция 9 - завершение работы системы ======== += Функция 18, подфункция 9 - завершение работы системы с параметром. = ====================================================================== Параметры: * eax = 18 - номер функции @@ -750,8 +753,7 @@ Замечания: * Не следует полагаться на возвращаемое значение при неверном вызове, оно может измениться в последующих версиях ядра. - * Можно использовать подфункцию 1, чтобы на последнем шаге - завершения работы пользователь сам решал, что ему нужно. + ====================================================================== ======== Функция 18, подфункция 10 - свернуть окно приложения. ======= ====================================================================== @@ -1131,11 +1133,6 @@ dd 638 * Получить установленную базу CD можно вызовом подфункции 3 функции 26. -====================================================================== -== Функция 21, подфункция 4 - установить базовый порт Sound Blaster. = -====================================================================== -Удалена - ====================================================================== ========= Функция 21, подфункция 5 - установить язык системы. ======== ====================================================================== @@ -1199,11 +1196,6 @@ dd 638 * Следует также определить используемую базу жёсткого диска подфункцией 7. -====================================================================== -===== Функция 21, подфункция 10 - установить канал DMA для звука. ==== -====================================================================== -Удалена: - ====================================================================== ====================== Функция 21, подфункция 11 ===================== =========== Разрешить/запретить низкоуровневый доступ к HD. ========== @@ -1497,11 +1489,6 @@ dd 638 * Функция поддерживается только для ATAPI-устройств (CD и DVD). * Примером использования функции является приложение CD_tray. -====================================================================== -============== Функция 25 - установить громкость SBPro. ============== -====================================================================== -Удалена - ====================================================================== ===== Функция 26, подфункция 1 - получить базовый порт MPU MIDI. ===== ====================================================================== @@ -1564,11 +1551,6 @@ dd 638 * База CD используется функцией 24. * Установить базу CD можно вызовом подфункции 3 функции 21. -====================================================================== -=== Функция 26, подфункция 4 - получить базовый порт Sound Blaster. == -====================================================================== -Удалена - ====================================================================== ========== Функция 26, подфункция 5 - получить язык системы. ========= ====================================================================== @@ -1633,11 +1615,6 @@ dd 638 497 суток. * Системное время можно получить функцией 3. -====================================================================== -====== Функция 26, подфункция 10 - получить канал DMA для звука. ===== -====================================================================== -Удалена - ====================================================================== ====================== Функция 26, подфункция 11 ===================== =========== Узнать, разрешён ли низкоуровневый доступ к HD. ========== @@ -1667,11 +1644,6 @@ dd 638 * Установить текущее состояние можно вызовом подфункции 12 функции 21. -====================================================================== -=============== Функция 28 - установить громкость SB16. ============== -====================================================================== -Удалена - ====================================================================== ================ Функция 29 - получить системную дату. =============== ====================================================================== @@ -1711,6 +1683,56 @@ dd 638 копируются только первые (edx-1) байт и в конце ставится завершающий 0. +====================================================================== +================ Функция 32 - удалить файл с рамдиска. =============== +====================================================================== +Параметры: + * eax = 32 - номер функции + * ebx = указатель на имя файла +Возвращаемое значение: + * eax = 0 - успешно; иначе код ошибки файловой системы +Замечания: + * Эта функция устарела; функция 58 позволяет выполнять + те же действия с расширенными возможностями. + * Текущая реализация возвращает только значения 0(успех) и + 5(файл не найден). + * Имя файла должно быть либо в формате 8+3 символов (первые + 8 символов - собственно имя, последние 3 - расширение, + короткие имена и расширения дополняются пробелами), + либо в формате 8.3 символов "FILE.EXT"/"FILE.EX " + (имя не более 8 символов, точка, расширение 3 символа, + дополненное при необходимости пробелами). + Имя файла должно быть записано заглавными буквами. + Завершающий символ с кодом 0 не нужен (не ASCIIZ-строка). + * Эта функция не поддерживает папок на рамдиске. + +====================================================================== +=============== Функция 33 - записать файл на рамдиск. =============== +====================================================================== +Параметры: + * eax = 33 - номер функции + * ebx = указатель на имя файла + * ecx = указатель на данные для записи + * edx = число байт для записи + * следует устанавливать esi=0 +Возвращаемое значение: + * eax = 0 - успешно, иначе код ошибки файловой системы +Замечания: + * Эта функция устарела; функция 70 позволяет выполнять + те же действия с расширенными возможностями. + * Если указать ненулевое значение в esi и на рамдиске уже есть + указанный файл, то будет создан ещё один файл с тем же именем. + * В противном случае файл перезаписывается. + * Имя файла должно быть либо в формате 8+3 символов + (первые 8 символов - собственно имя, последние 3 - расширение, + короткие имена и расширения дополняются пробелами), + либо в формате 8.3 символов "FILE.EXT"/"FILE.EX " + (имя не более 8 символов, точка, расширение 3 символа, + дополненное при необходимости пробелами). + Имя файла должно быть записано заглавными буквами. + Завершающий символ с кодом 0 не нужен (не ASCIIZ-строка). + * Эта функция не поддерживает папок на рамдиске. + ====================================================================== ============ Функция 35 - прочитать цвет точки на экране. ============ ====================================================================== @@ -1728,6 +1750,22 @@ dd 638 функций) через селектор gs. Параметры текущего видеорежима можно получить функцией 61. +====================================================================== +=============== Функция 36 - прочитать область экрана. =============== +====================================================================== +Параметры: + * eax = 36 - номер функции + * ebx = указатель на предварительно выделенную область памяти, + куда будет помещено изображение в формате BBGGRRBBGGRR... + * ecx = [размер по оси x]*65536 + [размер по оси y] + * edx = [координата по оси x]*65536 + [координата по оси y] +Возвращаемое значение: + * функция не возвращает значения +Замечания: + * Координаты области - это координаты верхнего левого угла + области относительно экрана. + * Размер изображения в байтах есть 3*xsize*ysize. + ====================================================================== ==================== Функция 37 - работа с мышью. ==================== ====================================================================== @@ -1921,43 +1959,35 @@ dd 638 * eax = -1 для некорректного ebx ====================================================================== -========== Функция 42 - работа с данными, полученными по IRQ. ======= +========= Функция 42 - работа с данными, полученными по IRQ. ========= ====================================================================== - ------------------------- Чтение данных ------------------------------- При возникновении IRQ система может считывать данные из указанных ранее функцией 44 портов и записывать эти данные в буфер. -Описываемая функция считывает данные из этого буфера в буфер -указанный в качестве параметра. + +-------------------- Подфункция 0 - чтение данных -------------------- Параметры: * eax = 42 - номер функции - * bl = номер IRQ, 0..15 - * bh = номер подфункции, 0 -Остальная часть регистра ebx должна быть обнулена. - * ecx = указатель на буфер, куда будут приниматься данные + * bl = номер IRQ, 0..15 + * bh = 0 - номер подфункции + * остальная часть регистра ebx должна быть обнулена + * ecx = указатель на буфер размером не менее 4000 байт Возвращаемое значение: (ситуацию можно различить по значению eax) * если поток не является владельцем IRQ - (или номер IRQ задан неверно): - * eax = -1 - * если данных нет: - * eax = 0 + (или номер IRQ задан неверно): eax = -1 + * если данных нет: eax = 0 * если всё в порядке и данные были: - * eax = размер данных, прочитанных из буфера (в байтах) + eax = размер данных, прочитанных из буфера (в байтах) -Смотрите замечания ниже. - ------------------------- Узнать размер данных в буфере --------------- +------------ Подфункция 1 - узнать размер данных в буфере ------------ Параметры: * eax = 42 - номер функции - * bl = номер IRQ, 0..15 - * bh = номер подфункции, 1 -Остальная часть регистра ebx должна быть обнулена. -Возвращаемое значение: (ситуацию можно различить по значению eax) + * bl = номер IRQ, 0..15 + * bh = 1 - номер подфункции + * остальная часть регистра ebx должна быть обнулена +Возвращаемое значение: * если поток не является владельцем IRQ - (или номер IRQ задан неверно): - * eax = -1 - * если всё в порядке, в eax размер данных - + (или номер IRQ задан неверно): eax = -1 + * иначе eax = размер данных в буфере Замечания: * Предварительно поток должен зарезервировать для себя указанный IRQ функцией 45. @@ -2188,11 +2218,11 @@ dword- Замечания: * Структура таблицы цветов описана в стандартном включаемом файле macros.inc под названием system_colors; например, можно писать: - sc system_colors ; объявление переменной - ... ; где-то надо вызвать - ; описываемую функцию с ecx=sc - mov ecx, [sc.work_button_text] ; читаем цвет текста - ; на кнопке в рабочей области + sc system_colors ; объявление переменной + ... ; где-то надо вызвать + ; описываемую функцию с ecx=sc + mov ecx, [sc.work_button_text] ; читаем цвет текста + ; на кнопке в рабочей области * Использование/неиспользование этих цветов - дело исключительно самой программы. Для использования нужно просто при вызове функций рисования указывать цвет, взятый из этой таблицы. @@ -2581,9 +2611,6 @@ dword- * Текущая реализация не закрывает автоматически все сокеты потока при его завершении. В частности, не следует прибивать поток с кучей открытых сокетов - будет утечка ресурсов. - * Текущая реализация не делает проверок на корректность - (единственное, на что возвращается ошибка, - попытка закрыть - неоткрытый сокет с корректным хэндлом). ====================================================================== ============== Функция 53, подфункция 2 - опрос сокета. ============== @@ -2593,10 +2620,8 @@ dword- * ebx = 2 - номер подфункции * ecx = хэндл сокета Возвращаемое значение: - * eax = число полученных байт + * eax = число полученных байт, 0 для неверного хэндла * ebx разрушается -Замечания: - * Проверки корректности не делается. ====================================================================== ======== Функция 53, подфункция 3 - прочитать байт из сокета. ======== @@ -2606,12 +2631,10 @@ dword- * ebx = 3 - номер подфункции * ecx = хэндл сокета Возвращаемое значение: - * если нет принятых данных: eax=0, bl=0, - прочие байты ebx разрушаются + * если нет принятых данных или указан неверный хэндл: + eax=0, bl=0, прочие байты ebx разрушаются * если были принятые данные: eax=число оставшихся байт (возможно, 0), bl=прочитанный байт, прочие байты ebx разрушаются -Замечания: - * Проверки корректности не производится. ====================================================================== ========== Функция 53, подфункция 4 - записать в UDP-сокет. ========== @@ -2623,13 +2646,10 @@ dword- * edx = число байт для записи * esi = указатель на данные для записи Возвращаемое значение: - * eax = 0xffffffff - неверный хэндл - * eax = 0xffff - недостаточно памяти + * eax = 0xffffffff - ошибка (неверный хэндл или недостаточно памяти) * eax = 0 - успешно * ebx разрушается Замечания: - * Проверка на правильность хэндла минимальна - исключаются только - не очень неправильные неоткрытые хэндлы. * Число байт для записи не может превышать 1500-28, хотя соответствующей проверки не делается. @@ -2657,7 +2677,7 @@ dword- * ebx = 6 - номер подфункции * ecx = хэндл сокета Возвращаемое значение: - * eax = статус сокета: одно из + * eax = 0 для неверного сокета или статус: одно из * TCB_LISTEN = 1 * TCB_SYN_SENT = 2 * TCB_SYN_RECEIVED = 3 @@ -2670,8 +2690,6 @@ dword- * TCB_TIME_WAIT = 10 * TCB_CLOSED = 11 * ebx разрушается -Замечания: - * Проверок корректности не производится. ====================================================================== ========== Функция 53, подфункция 7 - записать в TCP-сокет. ========== @@ -2683,13 +2701,10 @@ dword- * edx = число байт для записи * esi = указатель на данные для записи Возвращаемое значение: - * eax = 0xffffffff - ошибка - * eax = 0xffff - недостаточно памяти + * eax = 0xffffffff - ошибка (неверный хэндл или недостаточно памяти) * eax = 0 - успешно * ebx разрушается Замечания: - * Проверка на правильность хэндла минимальна - исключаются только - не очень неправильные неоткрытые хэндлы. * Число байт для записи не может превышать 1500-40, хотя соответствующей проверки не делается. @@ -2701,19 +2716,14 @@ dword- * ebx = 8 - номер подфункции * ecx = хэндл сокета Возвращаемое значение: - * eax = -1 - неверный хэндл - * eax = 0xffff - недостаточно памяти для пакета закрытия сокета + * eax = -1 - ошибка (неверный хэндл или + недостаточно памяти для пакета закрытия сокета) * eax = 0 - успешно - * во многих случаях eax разрушается (возвращается результат функции - queue) - видимо, это баг, который будет исправлен * ebx разрушается Замечания: * Текущая реализация не закрывает автоматически все сокеты потока при его завершении. В частности, не следует прибивать поток с кучей открытых сокетов - будет утечка ресурсов. - * Текущая реализация не делает проверок на корректность - (единственное, на что возвращается ошибка, - попытка закрыть - неоткрытый сокет с корректным хэндлом). ====================================================================== == Функция 53, подфункция 9 - проверить, свободен ли локальный порт. = @@ -2754,10 +2764,8 @@ dword- * esi = число байт для чтения; * esi = 0 - читать все данные (максимум 4096 байт) Возвращаемое значение: - * eax = число прочитанных байт + * eax = число прочитанных байт (0 при неверном хэндле) * ebx разрушается -Замечания: - * Проверки на правильность хэндла не делается. ====================================================================== Функция 53, подфункция 255 - отладочная информация сетевого драйвера. @@ -2791,59 +2799,6 @@ dword- * 6: статус драйвера пакетов, 0=неактивен, ненулевое значение=активен -====================================================================== -======== Функция 55, подфункция 0 - загрузить данные для SB16. ======= -====================================================================== -Параметры: - * eax = 55 - номер функции - * ebx = 0 - номер подфункции - * ecx = указатель на данные (копируется 64 килобайта, используется - столько, сколько установлено подфункцией 2) -Возвращаемое значение: - * функция не возвращает значения -Замечания: - * Формат и размер данных устанавливаются подфункцией 2. - -====================================================================== -==== Функция 55, подфункция 1 - начать проигрывать данные на SB16. === -====================================================================== -Параметры: - * eax = 55 - номер функции - * ebx = 1 - номер подфункции -Возвращаемое значение: - * функция не возвращает значения -Замечания: - * Предварительно данные должны быть загружены подфункцией 0 и - определён их формат подфункцией 2. - * Функция возвращает управление, когда началось проигрывание данных; - после этого проигрывание идёт независимо от приложения (и вообще - не требует загрузки процессора). - * Предварительно должны быть определены базовый порт SB16 - (подфункцией 4 функции 21) и канал DMA - (подфункцией 10 функции 21). - -====================================================================== -====== Функция 55, подфункция 2 - установить формат данных SB16. ===== -====================================================================== -Параметры: - * eax = 55 - номер функции - * ebx = 2 - номер подфункции - * ecx = 0 - установить разрядность - * edx = 1 - 8бит моно - * edx = 2 - 8бит стерео - * ecx = 1 - установить размер данных - * edx = размер в байтах - * ecx = 2 - установить частоту проигрывания - * edx = частота -Возвращаемое значение: - * функция не возвращает значения -Замечания: - * При загрузке системы устанавливаются следующие параметры - по умолчанию: разрядность - 8 бит моно, размер - 64 Кб, - частота 44100 Гц. Тем не менее рекомендуется явно устанавливать - необходимые значения, поскольку они могли быть переустановлены - какой-нибудь программой. - ====================================================================== ====================== Функция 55, подфункция 55 ===================== ========== Начать проигрывать данные на встроенном спикере. ========== @@ -3167,10 +3122,10 @@ IPC Программе доступны данные графического экрана (область памяти, которая собственно и отображает содержимое экрана) напрямую без вызовов системных функций через селектор gs: - mov eax, [gs:0] + mov eax, [gs:0] поместит в eax первый dword буфера, содержащий информацию о цвете левой верхней точки (и, возможно, цвета нескольких следующих). - mov [gs:0], eax + mov [gs:0], eax при работе в режимах VESA c LFB установит цвет левой верхней точки (и возможно, цвета нескольких следующих). @@ -3402,7 +3357,7 @@ IPC * ebx = указатель на изображение * ecx = [размер по оси x]*65536 + [размер по оси y] * edx = [координата по оси x]*65536 + [координата по оси y] - * esi = число бит на пиксель, должно быть 1, 4, 8, 15, 16, 24 или 32 + * esi = число бит на пиксель, должно быть 1,2,4,8,15,16,24 или 32 * edi = указатель на палитру (2 в степени esi цветов 0x00RRGGBB); игнорируется при esi > 8 * ebp = смещение данных каждой следующей строки изображения @@ -3412,27 +3367,28 @@ IPC Замечания: * Координаты изображения - это координаты верхнего левого угла изображения относительно окна. - * Размер изображения в байтах есть xsize*ysize. * Формат изображения с 1 битом на пиксель: каждый байт изображения, за исключением, быть может, последних байтов строк, содержит информацию о цвете 8 пикселей, старший бит соответствует первому пикселю. + * Формат изображения с 2 битами на пиксель: каждый байт изображения, + за исключением, быть может, последних байтов строк, содержит + информацию о цвете 4 пикселей, старшие два бита соответствуют + первому пикселю. * Формат изображения с 4 битами на пиксель: каждый байт изображения, за исключением последних байтов строк (если ширина изображения нечётна), содержит информацию о цвете 2 пикселей, старшая тетрада соответствует первому пикселю. * Формат изображения с 8 битами на пиксель: каждый байт изображения рассматривается как индекс в палитре. - * Если изображение использует не все 256 цветов, а меньше, - размер палитры может быть меньше 256. * Формат изображения с 15 битами на пиксель: цвет каждого пикселя кодируется как (в битовом представлении) 0RRRRRGGGGGBBBBB - по 5 пикселей на каждый цвет. * Формат изображения с 16 битами на пиксель: цвет каждого пикселя кодируется как RRRRRGGGGGGBBBBB (схема 5+6+5). * Формат изображения с 24 битами на пиксель: цвет каждого пикселя - кодируется тремя байтами - последовательно синяя, зелёная, - красная составляющие цвета. + кодируется тремя байтами - последовательно синяя, зелёная, красная + составляющие цвета. * Формат изображения с 32 битами на пиксель: аналогично 24, только есть ещё игнорируемый четвёртый байт. * Вызов функции 7 эквивалентен вызову этой функции с параметрами @@ -3685,30 +3641,24 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); или подфункцией 20. ====================================================================== -===== Функция 68, подфункция 14 - ожидать извещения от драйвера. ===== +==================== Функция 68, подфункция 14 ======================= +===== Ожидать получения сигнала, от других приложений/драйверов. ===== ====================================================================== Параметры: * eax = 68 - номер функции * ebx = 14 - номер подфункции - * ecx = указатель на буфер для информации (8 байт) + * ecx = указатель на буфер для информации (24 байта) Возвращаемое значение: * буфер, на который указывает ecx, содержит следующую информацию: - * +0: dword: константа EV_INTR = 1 - * +4: dword: данные драйвера -Замечания: - * Текущая реализация во время ожидания требует довольно "тяжёлых" - операций переключения контекста. + * +0: dword: идентификатор последующих данных сигнала + * +4: данные принятого сигнала (20 байт), формат которых + определяется первым dword-ом ====================================================================== == Функция 68, подфункция 15 - установить обработчик исключений FPU. = ====================================================================== -Параметры: - * eax = 68 - номер функции - * ebx = 15 - номер подфункции - * ecx = адрес нового обработчика исключений -Возвращаемое значение: - * eax = адрес старого обработчика исключений - (0, если он не был установлен) +Удалена (в текущей реализации просто возвращает 0) +Использовать подфункции 24, 25 ====================================================================== =========== Функция 68, подфункция 16 - загрузить драйвер. =========== @@ -3751,13 +3701,8 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); ====================================================================== == Функция 68, подфункция 18 - установить обработчик исключений SSE. = ====================================================================== -Параметры: - * eax = 68 - номер функции - * ebx = 18 - номер подфункции - * ecx = адрес нового обработчика исключений -Возвращаемое значение: - * eax = адрес старого обработчика исключений - (0, если он не был установлен) +Удалена (в текущей реализации просто возвращает 0) +Использовать подфункции 24, 25 ====================================================================== ============= Функция 68, подфункция 19 - загрузить DLL. ============= @@ -3798,6 +3743,104 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * Содержимое памяти вплоть до наименьшего из старого и нового размеров сохраняется. +====================================================================== +=== Функция 68, подфункция 22 - открыть именованную область памяти. == +====================================================================== +Параметры: + * eax = 68 - номер функции + * ebx = 22 - номер подфункции + * ecx = имя области. Максимум 31 символ, включая завершающий ноль + * edx = размер области в байтах для SHM_CREATE и SHM_OPEN_ALWAYS + * esi = флаги открытия и доступа: + * SHM_OPEN = 0x00 - открыть существующую область памяти. + Если область с таким именем не существует, + функция вернёт код ошибки 5. + * SHM_OPEN_ALWAYS = 0x04 - открыть существующую или создать новую + область памяти. + * SHM_CREATE = 0x08 - создать новую область памяти. + Если область с таким именем уже существует, + функция вернёт код ошибки 10. + * SHM_READ = 0x00 - доступ только на чтение + * SHM_WRITE = 0x01 - доступ на чтение и запись +Возвращаемое значение: + * eax = указатель на область памяти, 0 при ошибке + * при создании новой области (SHM_CREATE или SHM_OPEN_ALWAYS): + edx = 0 - успех, иначе - код ошибки + * при открытии существующей области (SHM_OPEN или SHM_OPEN_ALWAYS): + edx = код ошибки (при eax=0) или размер области в байтах +Коды ошибок: + * E_NOTFOUND = 5 + * E_ACCESS = 10 + * E_NOMEM = 30 + * E_PARAM = 33 +Замечания: + * Если создаётся новая область, то флаги доступа устанавливают + максимальные права доступа для остальных процессов. Попытка + открытия другим потоком с неразрешёнными правами провалится + с кодом ошибки E_ACCESS. + * Процесс, создавший область, всегда имеет доступ на запись. + +====================================================================== +=== Функция 68, подфункция 23 - закрыть именованную область памяти. == +====================================================================== +Параметры: + * eax = 68 - номер функции + * ebx = 23 - номер подфункции + * ecx = имя области. Максимум 31 символ, включая завершающий ноль +Возвращаемое значение: + * eax разрушается +Замечания: + * Область памяти физически освобождается (с забыванием всех данных + и высвобождением физической памяти), когда её закроют + все открывшие потоки. + * При завершении потока освобождаются все открытые им + области памяти. + +====================================================================== +==== Функция 68, подфункция 24 - установить обработчик исключений === +====================================================================== +Параметры: + * eax = 68 - номер функции + * ebx = 24 - номер подфункции + * ecx = адрес нового обработчика исключений + * edx = маска обрабатываемых исключений +Возвращаемое значение: + * eax = адрес старого обработчика исключений (0, если не установлен) + * ebx = маска старого обработчика исключений +Замечания: + * Номер бита в маске исключений соответствуют номеру исключения по + спецификации на процессор (Intel-PC). Так например, исключения FPU + имеют номер 16 (#MF), а SSE - 19 (#XF). + * В данной реализации игнорируется запрос на перехват исключения 7 + - система обрабатывает #NM самостоятельно. + * Пользовательский обработчик получает номер исключения параметром + в стеке. Поэтому правильный выход из обработчика: RET 4. Возврат + при этом производится на команду, вызвавшую исключение. + * При передаче управления обработчику исключений, сбрасывается + соответствующий бит в маске исключений. Возникновение этого же + исключения в последствии - приведет к default-обработке такового. + А именно: к завершению работы приложения, или приостановке с + нотификацией отлаживающему приложению. + * После завершения критических действий в обработчике пользователя, + восстановление бита маски данного исключения можно сделать + подфункцией 25. Сброс флагов исключений в модулях FPU и XMM - + также возлагается на обработчик пользователя. + +====================================================================== += Функция 68, подфункция 25 - изменение состояния активности сигнала = +====================================================================== +Параметры: + * eax = 68 - номер функции + * ebx = 25 - номер подфункции + * ecx = номер сигнала + * edx = значение устанавливаемой активности (0/1) +Возвращаемое значение: + * eax = старое значение активности сигнала (0/1) +Замечания: + * В текущей реализации изменяется только маска пользовательского + обработчика исключений, установленного подфункцией 24. При этом, + номер сигнала соответствует номеру исключения. + ====================================================================== ======================== Функция 69 - отладка. ======================= ====================================================================== @@ -3831,8 +3874,8 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); Если отладчик этого не хочет, он должен предварительно отключиться подфункцией 3. -Все подфункции, кроме 4 и 5, применимы только к процессам/потокам, -запущенным из текущего функцией 70 с установленным флагом отладки. +Все подфункции применимы только к процессам/потокам, запущенным +из текущего функцией 70 с установленным флагом отладки. Отладка многопоточных программ пока не поддерживается. Полный список подфункций: * подфункция 0 - определить область данных для отладочных сообщений @@ -3865,7 +3908,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); и при поступлении нового сообщения система будет ждать. Для синхронизации обрамляйте всю работу с буфером операциями блокировки/разблокировки - neg [bufsize] + neg [bufsize] * Данные в буфере трактуются как массив элементов переменной длины - сообщений. Формат сообщения указан в общем описании. @@ -3930,7 +3973,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * Если процесс был приостановлен, он возобновляет выполнение. ====================================================================== -=========== Функция 69, подфункция 4 - приостановить поток. ========== +==== Функция 69, подфункция 4 - приостановить отлаживаемый поток. ==== ====================================================================== Параметры: * eax = 69 - номер процесса @@ -3938,10 +3981,13 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * ecx = идентификатор Возвращаемое значение: * функция не возвращает значения +Замечания: + * Процесс должен быть загружен для отладки (как указано в + общем описании). ====================================================================== ====================== Функция 69, подфункция 5 ====================== -=================== Возобновить выполнение потока. =================== +============ Возобновить выполнение отлаживаемого потока. ============ ====================================================================== Параметры: * eax = 69 - номер функции @@ -3949,6 +3995,9 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * ecx = идентификатор Возвращаемое значение: * функция не возвращает значения +Замечания: + * Процесс должен быть загружен для отладки (как указано в + общем описании). ====================================================================== ====================== Функция 69, подфункция 6 ====================== diff --git a/kernel/branches/kolibri_pe/docs/sysfuncs.txt b/kernel/branches/kolibri_pe/docs/sysfuncs.txt index 92a1ac9d62..238974fcf9 100644 --- a/kernel/branches/kolibri_pe/docs/sysfuncs.txt +++ b/kernel/branches/kolibri_pe/docs/sysfuncs.txt @@ -1,4 +1,4 @@ -SYSTEM FUNCTIONS of OS Kolibri 0.7.1.0 +SYSTEM FUNCTIONS of OS Kolibri 0.7.5.0 Number of the function is located in the register eax. The call of the system function is executed by "int 0x40" command. @@ -219,9 +219,6 @@ Remarks: and does not make any operations at all. If it is really required to transfer control to the next process (to complete a current time slice), use subfunction 1 of function 68. - * At current implementation there will be an immediate return from - the function, if the addition of ebx with current value of - time counter will call 32-bit overflow. ====================================================================== ============== Function 6 - read the file from ramdisk. ============== @@ -613,16 +610,20 @@ Parameters: * eax = 17 - function number Returned value: * if the buffer is empty, function returns eax=1 - * if the buffer is not empty, function returns: - high 24 bits of eax contain button identifier (in particular, ah - contains low byte of the identifier; if all buttons have - the identifier less than 256, ah is enough to distinguish), - and al contain 0 - if used left mouse button or bit of the used another mouse button + * if the buffer is not empty: + * high 24 bits of eax contain button identifier (in particular, + ah contains low byte of the identifier; if all buttons have + the identifier less than 256, ah is enough to distinguish) + * al = 0 - the button was pressed with left mouse button + * al = bit corresponding to used mouse button otherwise Remarks: * "Buffer" keeps only one button, at pressing the new button the information about old is lost. * The call of this function by an application with inactive window will return answer "buffer is empty". + * Returned value for al corresponds to the state of mouse buttons + as in subfunction 2 of function 37 at the beginning + of button press, excluding lower bit, which is cleared. ====================================================================== = Function 18, subfunction 2 - terminate process/thread by the slot. = @@ -678,7 +679,7 @@ Returned value: * eax = clock rate (modulo 2^32 clock ticks = 4GHz) ====================================================================== - Function 18, subfunction 6 - save ramdisk to the file on hard drive. + Function 18, subfunction 6 - save ramdisk to the file on hard drive. ====================================================================== Parameters: * eax = 18 - function number @@ -731,7 +732,7 @@ Returned value: * function does not return value ====================================================================== -============ Function 18, subfunction 9 - system shutdown. =========== +== Function 18, subfunction 9 - system shutdown with the parameter. == ====================================================================== Parameters: * eax = 18 - function number @@ -747,8 +748,7 @@ Returned value: Remarks: * Do not rely on returned value by incorrect call, it can be changed in future versions of the kernel. - * It is possible to use subfunction 1, that on the last step - the user makes choice himself. + ====================================================================== ===== Function 18, subfunction 10 - minimize application window. ===== ====================================================================== @@ -761,7 +761,7 @@ Returned value: Remarks: * The minimized window from the point of view of function 9 keeps position and sizes. - * Restoring of an application window occurs at its activation by + * Restoring of an application window occurs at its activation by subfunction 3. * Usually there is no necessity to minimize/restire a window obviously: minimization of a window is carried out by the system @@ -771,7 +771,7 @@ Remarks: restore of a window is done by the application '@panel'. ====================================================================== - Function 18, subfunction 11 - get information on the disk subsystem. + Function 18, subfunction 11 - get information on the disk subsystem. ====================================================================== Parameters: * eax = 18 - function number @@ -1062,7 +1062,7 @@ Returned value (is the same for both subfunctions): * eax = 0 - success * eax = 1 - base port is not defined Remarks: - * Previously the base port must be defined by + * Previously the base port must be defined by subfunction 1 of function 21. ====================================================================== @@ -1106,7 +1106,7 @@ Remarks: if Alt and Shift are not pressed, but Ctrl is pressed, the normal layout is used and then from the code is subtracted 0x60; if no control key is pressed, the normal layout is used. - * To get layout and country identifier use + * To get layout and country identifier use subfunction 2 of function 26. * Country identifier is global system variable, which is not used by the kernel itself; however the application '@panel' displays @@ -1126,11 +1126,6 @@ Remarks: * CD base is used by function 24. * To get CD base use subfunction 3 of function 26. -====================================================================== -====== Function 21, subfunction 4 - set Sound Blaster base port. ===== -====================================================================== -Removed - ====================================================================== ========== Function 21, subfunction 5 - set system language. ========= ====================================================================== @@ -1165,7 +1160,7 @@ Remarks: * Do not change base, when any application works with hard disk. If you do not want system bugs. * To get HD base use subfunction 7 of function 26. - * It is also necessary to define used partition of hard disk by + * It is also necessary to define used partition of hard disk by subfunction 8. ====================================================================== @@ -1187,17 +1182,12 @@ Remarks: If you do not want system bugs. * To get used partition use subfunction 8 of function 26. * There is no correctness checks. - * To get the number of partitions of a hard disk use + * To get the number of partitions of a hard disk use subfunction 11 of function 18. * It is also necessary to define used HD base by subfunction 7. ====================================================================== -======== Function 21, subfunction 10 - set sound DMA channel. ======== -====================================================================== -Removed - -====================================================================== - Function 21, subfunction 11 - enable/disable low-level access to HD. + Function 21, subfunction 11 - enable/disable low-level access to HD. ====================================================================== Parameters: * eax = 21 - function number @@ -1211,7 +1201,7 @@ Remarks: * To get current status use subfunction 11 of function 26. ====================================================================== - Function 21, subfunction 12 - enable/disable low-level access to PCI. + Function 21, subfunction 12 - enable/disable low-level access to PCI. ====================================================================== Parameters: * eax = 21 - function number @@ -1278,7 +1268,7 @@ Returned value: * ebx = frequency of the vertical scanning (in Hz) * ecx = number of current videomode Remarks: - * Driver must be initialized by call to + * Driver must be initialized by call to driver function 1. * If only screen sizes are required, it is more expedient to use function 14 taking into account that it @@ -1413,7 +1403,7 @@ Returned value: * eax = 0 - success * eax = 1 - CD base is not defined Remarks: - * Previously CD base must be defined by the call to + * Previously CD base must be defined by the call to subfunction 3 of function 21. * One second includes 75 frames, one minute includes 60 seconds. * The function is asynchronous (returns control, when play begins). @@ -1433,7 +1423,7 @@ Remarks: * The format of the table with tracks information is the same as for ATAPI-CD command 43h (READ TOC), usual table (subcommand 00h). Function returns addresses in MSF. - * Previously CD base port must be set by call to + * Previously CD base port must be set by call to subfunction 3 of function 21. * Function returns information only about no more than 100 first tracks. In most cases it is enough. @@ -1448,7 +1438,7 @@ Returned value: * eax = 0 - success * eax = 1 - CD base is not defined Remarks: - * Previously CD base port must be defined by call to + * Previously CD base port must be defined by call to subfunction 3 of function 21. ====================================================================== @@ -1483,11 +1473,6 @@ Remarks: * The function is supported only for ATAPI devices (CD and DVD). * An example of usage of the function is the application CD_tray. -====================================================================== -=================== Function 25 - set SBPro volume. ================== -====================================================================== -Removed - ====================================================================== ======== Function 26, subfunction 1 - get MPU MIDI base port. ======== ====================================================================== @@ -1528,7 +1513,7 @@ Remarks: if Alt and Shift are not pressed, but Ctrl is pressed, the normal layout is used and then from the code is subtracted 0x60; if no control key is pressed, the normal layout is used. - * To set layout and country identifier use + * To set layout and country identifier use subfunction 2 of function 21. * Country identifier is global system variable, which is not used by the kernel itself; however the application '@panel' displays @@ -1547,11 +1532,6 @@ Remarks: * CD base is used by function 24. * To set CD base use subfunction 3 of function 21. -====================================================================== -====== Function 26, subfunction 4 - get Sound Blaster base port. ===== -====================================================================== -Removed - ====================================================================== ========== Function 26, subfunction 5 - get system language. ========= ====================================================================== @@ -1614,11 +1594,6 @@ Remarks: than 497 days. * To get system time use function 3. -====================================================================== -======== Function 26, subfunction 10 - get sound DMA channel. ======== -====================================================================== -Removed - ====================================================================== ===================== Function 26, subfunction 11 ==================== ========== Find out whether low-level HD access is enabled. ========== @@ -1646,11 +1621,6 @@ Remarks: * The current implementation uses only low bit of ecx. * To set the current state use subfunction 12 of function 21. -====================================================================== -=================== Function 28 - set SB16 volume. =================== -====================================================================== -Removed - ====================================================================== =================== Function 29 - get system date. =================== ====================================================================== @@ -1689,6 +1659,56 @@ Remarks: * If the buffer is too small to hold all data, only first (edx-1) bytes are copied and than terminating 0 is inserted. +====================================================================== +=============== Function 32 - delete file from ramdisk. ============== +====================================================================== +Parameters: + * eax = 32 - function number + * ebx = pointer to the filename +Returned value: + * eax = 0 - success; otherwise file system error code +Remarks: + * This function is obsolete; function 58 allows to fulfill + the same operations with the extended possibilities. + * The current implementation returns only values 0(success) and + 5(file not found). + * The filename must be either in the format 8+3 characters + (first 8 characters - name itself, last 3 - extension, + the short names and extensions are supplemented with spaces), + or in the format 8.3 characters "FILE.EXT"/"FILE.EX " + (name no more than 8 characters, dot, extension 3 characters + supplemented if necessary by spaces). + The filename must be written with capital letters. The terminating + character with code 0 is not necessary (not ASCIIZ-string). + * This function does not support folders on the ramdisk. + +====================================================================== +================ Function 33 - write file to ramdisk. ================ +====================================================================== +Parameters: + * eax = 33 - function number + * ebx = pointer to the filename + * ecx = pointer to data for writing + * edx = number of bytes for writing + * should be set esi=0 +Returned value: + * eax = 0 - success, otherwise file system error code +Remarks: + * This function is obsolete; function 70 allows to fulfil + the same operations with extended possibilities. + * If esi contains non-zero value and selected file already exists, + one more file with the same name will be created. + * Otherwise file will be overwritten. + * The filename must be either in the format 8+3 characters + (first 8 characters - name itself, last 3 - extension, + the short names and extensions are supplemented with spaces), + or in the format 8.3 characters "FILE.EXT"/"FILE.EX " + (name no more than 8 characters, dot, extension 3 characters + supplemented if necessary by spaces). + The filename must be written with capital letters. The terminating + character with code 0 is not necessary (not ASCIIZ-string). + * This function does not support folders on the ramdisk. + ====================================================================== ======= Function 35 - read the color of a pixel on the screen. ======= ====================================================================== @@ -1706,6 +1726,22 @@ Remarks: to videomemory through the selector gs. To get parameters of the current videomode, use function 61. +====================================================================== +=================== Function 36 - read screen area. ================== +====================================================================== +Paramters: + * eax = 36 - function number + * ebx = pointer to the previously allocated memory area, + where will be placed the image in the format BBGGRRBBGGRR... + * ecx = [size on axis x]*65536 + [size on axis y] + * edx = [coordinate on axis x]*65536 + [coordinate on axis y] +Returned value: + * function does not return value +Remarks: + * Coordinates of the image are coordinates of the upper left corner + of the image relative to the screen. + * Size of the image in bytes is 3*xsize*ysize. + ====================================================================== =================== Function 37 - work with mouse. =================== ====================================================================== @@ -1852,7 +1888,7 @@ Remarks: changed in future kernel versions. * Offset for pixel with coordinates (x,y) is calculated as (x+y*xsize)*3. - * There is a pair function to set pixel on the background image - + * There is a pair function to set pixel on the background image - subfunction 2 of function 15. ====================================================================== @@ -1865,7 +1901,7 @@ Returned value: * eax = 1 - tile * eax = 2 - stretch Remarks: - * There is a pair function to set drawing mode - + * There is a pair function to set drawing mode - subfunction 4 of function 15. ====================================================================== @@ -1899,45 +1935,36 @@ Returned value: * eax = -1 for incorrect ebx ====================================================================== -==================== Function 42 - work with IRQ data. =============== +================== Function 42 - work with IRQ data. ================= ====================================================================== - ------------------------- Reading data -------------------------------- - When an IRQ occurs, the system reads data from ports indicated earlier by function 44 and writes this data to -internal buffer. This function reads out data from that buffer -to the buffer specified as parameter. +internal buffer. This function reads out data from that buffer. + +--------------------- Subfunction 0 - read data ---------------------- Parameters: * eax = 42 - function number * bl = IRQ number, 0..15 - * bh = subfunction number, 0 -Other part of register ebx, must be zero. - * ecx = pointer to the receive buffer + * bh = 0 - subfunction number + * rest of ebx must be zeroed + * ecx = pointer to a buffer with size not less than 4000 bytes Returned value: (use value of eax to distinguish) - * if the thread is not IRQ owner (or IRQ number is incorrect): - * eax = -1 - * if there is no data: - * eax = 0 + * if the thread is not IRQ owner + (or IRQ number is incorrect): eax = -1 + * if there is no data: eax = 0 * if all is ok: - * eax = byte size of data, read from buffer - -See remarks below. - ------------------------- Get data size ------------------------------- + eax = size of data read (in bytes) +------------- Subfunction 1 - get size of data in buffer ------------- Parameters: * eax = 42 - function number * bl = IRQ number, 0..15 - * bh = subfunction number, 0 -Other part of register ebx, must be zero. - * ecx = pointer to receive buffer -Returned value: (use value of eax to distinguish) - * if the thread is not IRQ owner (or IRQ number is incorrect): - * eax = -1 - * if all is ok: - * eax = byte size of data in buffer - + * bh = 0 - subfunction number + * rest of ebx must be zeroed +Returned value: + * if the thread is not IRQ owner + (or IRQ number is incorrect): eax = -1 + * otherwise eax = size of data in buffer Remarks: * Previously the thread must reserve indicated IRQ for itself by function 45. @@ -2166,11 +2193,11 @@ Remarks: * Structure of the color table is described in the standard include file 'macros.inc' as 'system_colors'; for example, it is possible to write: - sc system_colors ; variable declaration - ... ; somewhere one must call - ; this function with ecx=sc - mov ecx, [sc.work_button_text] ; read text color on - ; buttin in working area + sc system_colors ; variable declaration + ... ; somewhere one must call + ; this function with ecx=sc + mov ecx, [sc.work_button_text] ; read text color on + ; buttin in working area * A program itself desides to use or not to use color table. For usage program must simply at calls to drawing functions select color taken from the table. @@ -2365,7 +2392,7 @@ Parameters: Returned value: * eax = -1 - error (there is too many threads) * otherwise eax = TID - thread identifier - + ====================================================================== === Function 52, subfunction 0 - get network driver configuration. === @@ -2443,7 +2470,7 @@ Remarks: performs no checks on correctness. ====================================================================== - Function 52, subfunction 8 - read data from the network output queue. + Function 52, subfunction 8 - read data from the network output queue. ====================================================================== Parameters: * eax = 52 - function number @@ -2562,9 +2589,6 @@ Remarks: sockets of a thread at termination. In particular, one should not kill a thread with many opened sockets - there will be an outflow of resources. - * The current implementation does no checks on correctness - (function returns error only if thread tries to close not opened - socket with correct handle). ====================================================================== ============== Function 53, subfunction 2 - poll socket. ============= @@ -2574,10 +2598,8 @@ Parameters: * ebx = 2 - subfunction number * ecx = socket handle Returned value: - * eax = number of read bytes + * eax = number of read bytes, 0 for incorrect handle * ebx destroyed -Remarks: - * There is no checks for correctness. ====================================================================== ========= Function 53, subfunction 3 - read byte from socket. ======== @@ -2587,12 +2609,10 @@ Parameters: * ebx = 3 - subfunction number * ecx = socket handle Returned value: - * if there is no read data: eax=0, bl=0, + * if there is no read data or handle is incorrect: eax=0, bl=0, other bytes of ebx are destroyed * if there are read data: eax=number of rest bytes (possibly 0), bl=read byte, other bytes of ebx are destroyed -Remarks: - * There is no checks for correctness. ====================================================================== ========== Function 53, subfunction 4 - write to UDP-socket. ========= @@ -2604,13 +2624,10 @@ Parameters: * edx = number of bytes to write * esi = pointer to data to write Returned value: - * eax = 0xffffffff - invalid handle - * eax = 0xffff - not enough memory + * eax = 0xffffffff - error (invalid handle or not enough memory) * eax = 0 - success * ebx destroyed Remarks: - * Check on validity of handle is minimal - only not very incorrect - not opened handles are eliminated. * Number of bytes to write must not exceed 1500-28, though the appropriate check is not made. @@ -2638,7 +2655,7 @@ Parameters: * ebx = 6 - subfunction number * ecx = socket handle Returned value: - * eax = socket status: one of + * eax = 0 for incorrect handle or socket status: one of * TCB_LISTEN = 1 * TCB_SYN_SENT = 2 * TCB_SYN_RECEIVED = 3 @@ -2650,9 +2667,7 @@ Returned value: * TCB_LAST_ASK = 9 * TCB_TIME_WAIT = 10 * TCB_CLOSED = 11 - * ebx destroys -Remarks: - * There is no checks for correctness. + * ebx destroyed ====================================================================== ========== Function 53, subfunction 7 - write to TCP-socket. ========= @@ -2664,13 +2679,10 @@ Parameters: * edx = number of bytes to write * esi = pointer to data to write Returned value: - * eax = 0xffffffff - error - * eax = 0xffff - not enough memory + * eax = 0xffffffff - error (invalid handle or not enough memory) * eax = 0 - success * ebx destroyed Remarks: - * Check on validity of handle is minimal - only not very incorrect - not opened handles are eliminated. * Number of bytes to write must not exceed 1500-40, though the appropriate check is not made. @@ -2682,20 +2694,15 @@ Parameters: * ebx = 8 - subfunction number * ecx = socket handle Returned value: - * eax = -1 - invalid handle - * eax = 0xffff - not enough memory for socket close packet + * eax = -1 - error (invalid handle or + not enough memory for socket close packet) * eax = 0 - success - * in many cases eax is destroyed (the result of function 'queue' - is returned) - probably this is bug, which will be corrected * ebx destroyed Remarks: * The current implementation does not close automatically all sockets of a thread at termination. In particular, one should not kill a thread with many opened sockets - there will be an outflow of resources. - * The current implementation does no checks on correctness - (function returns error only if thread tries to close not opened - socket with correct handle). ====================================================================== === Function 53, subfunction 9 - check whether local port is free. === @@ -2736,13 +2743,11 @@ Paramters: * esi = number of bytes to read; * esi = 0 - read all data (maximum 4096 bytes) Returned value: - * eax = number of bytes read + * eax = number of bytes read (0 for incorrect handle) * ebx destroyed -Remakrs: - * There is no check on handle correctness. ====================================================================== -= Function 53, subfunction 255 - debug information of network driver. += Function 53, subfunction 255 - debug information of network driver. ====================================================================== Parameters: * eax = 53 - function number @@ -2773,59 +2778,7 @@ Possible values for ecx: * 6: status of packet driver, 0=inactive, nonzero=active ====================================================================== -========== Function 55, subfunction 0 - load data for SB16. ========== -====================================================================== -Parameters: - * eax = 55 - function number - * ebx = 0 - subfunction number - * ecx = pointer to data (is copied 64 kilobytes, is used as much as - set by subfunction 2) -Returned value: - * function does not return value -Remarks: - * Format and size of data are set by subfunction 2. - -====================================================================== -======== Function 55, subfunction 1 - begin play data on SB16. ======= -====================================================================== -Parameters: - * eax = 55 - function number - * ebx = 1 - subfunction number -Returned value: - * function does not return value -Remarks: - * Previously data must be loaded by subfunction 0 and - their format must be defined by subfunction 2. - * Function returns control, when playing of data began; after that - play goes independently from application (and does not use - processor time at all). - * Previously must be defined SB16 base port - (by subfunction 4 of function 21) and DMA channel - (by subfunction 10 of function 21). - -====================================================================== -======== Function 55, subfunction 2 - set format of SB16 data. ======= -====================================================================== -Parameters: - * eax = 55 - function number - * ebx = 2 - subfunction number - * ecx = 0 - set digit capacity - * edx = 1 - 8bit mono - * edx = 2 - 8bit stereo - * ecx = 1 - set data size - * edx = size in bytes - * ecx = 2 - set play frequency - * edx = frequency -Returned value: - * function does not return value -Remarks: - * When the system boots, it sets following default parameters: - digit capacity - 8bit mono, size - 64 Kb, frequency - 44100 Hz. - Nevertheless it is recommended to set necessary values obviously - as they could be reset by some application. - -====================================================================== - Function 55, subfunction 55 - begin to play data on built-in speaker. + Function 55, subfunction 55 - begin to play data on built-in speaker. ====================================================================== Parameters: * eax = 55 - function number @@ -2970,7 +2923,7 @@ Remarks: that he requested 1; * if one requests more than 14 blocks or starting block is not less than 14, function returns eax=5 (not found) ш ebx=-1; - * size of ramdisk root folder is 14 blocks, + * size of ramdisk root folder is 14 blocks, 0x1C00=7168 срщЄ; but function returns ebx=0 (except of the case of previous item); * strangely enough, it is possible to read 14th block (which @@ -3032,8 +2985,8 @@ Remarks: * Block size is 512 bytes; function reads one block. * Do not depend on returned value, it can be changed in future versions. - * Function requires that LBA-access to devices is enabled by - subfunction 11 of function 21. To check this one can use + * Function requires that LBA-access to devices is enabled by + subfunction 11 of function 21. To check this one can use subfunction 11 of function 26. * LBA-read of floppy is not supported. * Function reads data on physical hard drive; if for any reason @@ -3143,11 +3096,11 @@ Remarks: The data of the graphics screen (the memory area which displays screen contents) are accessible to a program directly, without any system calls, through the selector gs: - mov eax, [gs:0] + mov eax, [gs:0] places in eax the first dword of the buffer, which contains information on color of the left upper point (and, possibly, colors of several following). - mov [gs:0], eax + mov [gs:0], eax by work in VESA modes with LFB sets color of the left upper point (and, possibly, colors of several following). To interpret the data of graphics screen program needs to know @@ -3375,19 +3328,36 @@ Parameters: * ebx = pointer to the image * ecx = [size on axis x]*65536 + [size on axis y] * edx = [coordinate on axis x]*65536 + [coordinate on axis y] - * esi = number of bits per pixel, must be 8, 24 or 32 - * edi = pointer to palette (256 colors 0x00RRGGBB); - ignored when esi = 24 and 32 + * esi = number of bits per pixel, must be 1,2,4,8,15,16,24 or 32 + * edi = pointer to palette (2 to the power esi colors 0x00RRGGBB); + ignored when esi > 8 * ebp = offset of next row data relative to previous row data Returned value: * function does not return value Remarks: * Coordinates of the image are coordinates of the upper left corner of the image relative to the window. - * Size of the image in bytes is xsize*ysize. - * Each byte of image is index in the palette. - * If the image uses less than 256 colors, palette size may be - less than 256 too. + * Format of image with 1 bit per pixel: each byte of image + (possibly excluding last bytes in rows), contains information on + the color of 8 pixels, MSB corresponds to first pixel. + * Format of image with 2 bits per pixel: each byte of image + (possibly excluding last bytes in rows), contains information on + the color of 4 pixels, two MSBs correspond to first pixel. + * Format of image with 4 bits per pixel: each byte of image + excluding last bytes in rows (if width is odd) contains + information on the color of 2 pixels, high-order tetrad + corresponds to first pixel. + * Format of image with 8 bits per pixel: each byte of image is + index in the palette. + * Format of image with 15 bits per pixel: the color of each pixel + is coded as (bit representation) 0RRRRRGGGGGBBBBB - 5 bits per + each color. + * Format of image with 16 bits per pixel: the color of each pixel + is coded as RRRRRGGGGGGBBBBB (5+6+5). + * Format of image with 24 bits per pixel: the color of each pixel + is coded as 3 bytes - sequentially blue, green, red components. + * Format of image with 32 bits per pixel: similar to 24, but + one additional ignored byte is present. * The call to function 7 is equivalent to call to this function with esi=24, ebp=0. @@ -3643,29 +3613,24 @@ Remarks: or subfunction 20. ====================================================================== -======== Function 68, subfunction 14 - wait for driver notify. ======= +===================== Function 68, subfunction 14 ==================== +====== Waiting delivering of signal from another program/driver ====== ====================================================================== Parameters: * eax = 68 - function number * ebx = 14 - subfunction number - * ecx = pointer to the buffer for information (8 bytes) + * ecx = pointer to the buffer for information (24 bytes) Returned value: * buffer pointed to by ecx contains the following information: - * +0: dword: constant EV_INTR = 1 - * +4: dword: driver data -Remarks: - * The current implementation at wait time uses "heavy" operations - of task switch. + * +0: dword: identifier for underlying data of signal + * +4: data of signal (20 bytes), format of which is defining by + first dword ====================================================================== ====== Function 68, subfunction 15 - set FPU exception handler. ====== ====================================================================== -Parameters: - * eax = 68 - function number - * ebx = 15 - subfunction number - * ecx = address of the new exception handler -Returned value: - * eax = address of the old exception handler (0, if it was not set) +Deleted (in current implementation only 0 is returned). +Using subfunctions 24, 25 is true. ====================================================================== ============= Function 68, subfunction 16 - load driver. ============= @@ -3699,7 +3664,11 @@ Parameters: * +16 = +0x10: dword: pointer to output data * +20 = +0x14: dword: size of output data Returned value: - * eax = determined by driver + * eax = error code + 0 - successful call + -1 - any error. + -2, -3, -4, etc. reserved for kernel error codes + 1, 2, 3, etc driver specific error codes Remarks: * Function codes and the structure of input/output data are defined by driver. @@ -3708,12 +3677,8 @@ Remarks: ====================================================================== ====== Function 68, subfunction 18 - set SSE exception handler. ====== ====================================================================== -Parameters: - * eax = 68 - function number - * ebx = 15 - subfunction number - * ecx = address of the new exception handler -Returned value: - * eax = address of the old exception handler (0, if it was not set) +Deleted (in current implementation only 0 is returned). +Using subfunctions 24, 25 is true. ====================================================================== =============== Function 68, subfunction 19 - load DLL. ============== @@ -3753,6 +3718,50 @@ Remarks: * The contents of the block are unchanged up to the shorter of the new and old sizes. +====================================================================== +====== Function 68, subfunction 24 - set new exceptions handler ====== +====================================================================== +Parameters: + * eax = 68 - function number + * ebx = 24 - subfunction number + * ecx = address of the new exception handler + * edx = the mask of processing exceptions +Returned value: + * eax = address of the old exception handler (0, if it was not set) + * ebx = the old mask of exception handler +Remarks: + * Bit number in mask of exceptions is correspond to exception number + by CPU-specification (Intel-PC). For example, FPU-exception have + number 16 (#MF), and SSE-exception - 19 (#XF) + * The current implementation ignore the inquiry for hook of 7 + exception - system process #NM by one's own. + * User handler get exception number in stack parameter. So, correct + exit from handler is: RET 4. Return from handler is to the same + instruction, that was cause the exception + * When control is transfering to user handler, corresponding bit in + exception mask is clearing. Rising this exception in consequence + - reduce to default-handling. Exactly: terminating the application, + or suspending with debug-notify to owner. + * After completion of critical operations in user handler, it may be + rising corresponding bit in exception mask by using subfunction 25 + Clearing exceptions flags in FPU and/or XMM modules - is + responsibility of user handler too. + +====================================================================== +==== Function 68, subfunction 25 - change state of signal activity === +====================================================================== +Parameters: + * eax = 68 - function number + * ebx = 25 - subfunction number + * ecx = signal number + * edx = value of activity (0/1) +Returned value: + * eax = value of old activity for this signal (0/1) +Remarks: + * In current implementation, it is changed only exception mask for + user exception handler, wich was previously set by subfunction 24. + At that, number of signal correspond to exception number. + ====================================================================== ====================== Fucntion 69 - debugging. ====================== ====================================================================== @@ -3784,9 +3793,8 @@ When debugger terminates, all debugged processes are killed. If debugger does not want this, it must previously detach by subfunction 3. -All subfunctions except 4 and 5 are applicable only to -processes/threads started from the current by function 70 -with set debugging flag. +All subfunctions are applicable only to processes/threads started +from the current by function 70 with set debugging flag. Debugging of multithreaded programs is not supported yet. The full list of subfunctions: * subfunction 0 - define data area for debug messages @@ -3818,7 +3826,7 @@ Remarks: and at arrival of new message the system will wait. For synchronization frame all work with the buffer by operations lock/unlock - neg [bufsize] + neg [bufsize] * Data in the buffer are considered as array of items with variable length - messages. Format of a message is explained in general description. @@ -3884,7 +3892,7 @@ Remarks: * If the process was suspended, it resumes execution. ====================================================================== -============= Function 69, subfunction 4 - suspend thread. =========== +======== Function 69, subfunction 4 - suspend debugged thread. ======= ====================================================================== Parameters: * eax = 69 - function number @@ -3892,9 +3900,12 @@ Parameters: * ecx = thread identifier Returned value: * function does not return value +Remarks: + * Process must be loaded for debugging (as is shown in + general description). ====================================================================== -============= Function 69, subfunction 5 - resume thread. ============ +======== Function 69, subfunction 5 - resume debugged thread. ======== ====================================================================== Parameters: * eax = 69 - function number @@ -3902,6 +3913,9 @@ Parameters: * ecx = thread identifier Returned value: * function does not return value +Remarks: + * Process must be loaded for debugging (as is shown in + general description). ====================================================================== = Fucntion 69, subfunction 6 - read from memory of debugged process. = diff --git a/kernel/branches/kolibri_pe/drivers/sb16/CONFIG.INC b/kernel/branches/kolibri_pe/drivers/sb16/CONFIG.INC index f3aec7ac88..07962a0e74 100644 --- a/kernel/branches/kolibri_pe/drivers/sb16/CONFIG.INC +++ b/kernel/branches/kolibri_pe/drivers/sb16/CONFIG.INC @@ -8,7 +8,7 @@ API_VERSION equ 0 ;debug OS_BASE equ 0xE0000000 ;PROC_BASE equ (OS_BASE+0x080000) SB16Buffer equ (OS_BASE+0x10000) -DMAPage equ ((SB16Buffer-OS_BASE) shr 16) +DMAPage equ ((SB16Buffer-OS_BASE) shr 16) SB16Buffer0 equ SB16Buffer SB16Buffer1 equ (SB16Buffer+16384) @@ -20,7 +20,7 @@ sb_dma_num equ 5 ;default values for SB16, may be overrided by autodetect small_buffer equ 32768 full_buffer equ 65536 -sb_buffer_size equ full_buffer +sb_buffer_size equ small_buffer ; FIX ring buffer overlapped events issue; full_buffer __supported_buffer_sizes fix diff --git a/kernel/branches/kolibri_pe/fdo.inc b/kernel/branches/kolibri_pe/fdo.inc index c36be1e81f..ca9055b563 100644 --- a/kernel/branches/kolibri_pe/fdo.inc +++ b/kernel/branches/kolibri_pe/fdo.inc @@ -201,7 +201,6 @@ macro DEBUGH_N _sign,_num,_hex { if ~_hex eq ax movzx eax,_hex end if - shl eax,16 if (_num eq) mov edx,4 end if @@ -209,7 +208,6 @@ macro DEBUGH_N _sign,_num,_hex { if ~_hex eq al movzx eax,_hex end if - shl eax,24 if (_num eq) mov edx,2 end if diff --git a/kernel/branches/kolibri_pe/fs/fat32.inc b/kernel/branches/kolibri_pe/fs/fat32.inc index 7888314651..f6a2e8e085 100644 --- a/kernel/branches/kolibri_pe/fs/fat32.inc +++ b/kernel/branches/kolibri_pe/fs/fat32.inc @@ -1069,14 +1069,6 @@ fs_HdRead: mov eax, ERROR_ACCESS_DENIED ret -.noaccess_3: - add esp,4 -.noaccess_1: - add esp,4 -.noaccess_4: - add esp,4*5 - jmp .noaccess_2 - @@: call hd_find_lfn jnc .found @@ -1140,9 +1132,9 @@ fs_HdRead: push ebx mov ebx, edx call hd_read + pop ebx cmp [hd_error],0 jne .noaccess_1 - pop ebx add edx, 512 sub ecx, 512 jmp .skip @@ -1151,11 +1143,11 @@ fs_HdRead: push eax ebx mov ebx, buffer call hd_read - cmp [hd_error],0 - jne .noaccess_3 mov eax, ebx pop ebx + cmp [hd_error],0 + jne .noaccess_3 add eax, ebx push ecx add ecx, ebx @@ -1178,9 +1170,14 @@ fs_HdRead: mov eax, [cluster_tmp] call get_FAT cmp [hd_error],0 - jne .noaccess_4 + jne .noaccess_1 jmp .new_cluster +.noaccess_3: + pop eax +.noaccess_1: + pop eax + push 11 .done: mov ebx, edx pop eax edx ecx edi diff --git a/kernel/branches/kolibri_pe/fs/fs.inc b/kernel/branches/kolibri_pe/fs/fs.inc index 23c18b5aae..1e2d4a8124 100644 --- a/kernel/branches/kolibri_pe/fs/fs.inc +++ b/kernel/branches/kolibri_pe/fs/fs.inc @@ -764,17 +764,17 @@ i1: ; ja err sub al,48 shl cx,1 - jc err + jc error mov bx,cx shl cx,1 - jc err + jc error shl cx,1 - jc err + jc error add cx,bx - jc err + jc error cbw add cx,ax - jc err + jc error i3: inc edi jmp i1 @@ -789,7 +789,7 @@ i4: pop bx ret -err: +error: stc jmp i4 diff --git a/kernel/branches/kolibri_pe/fs/iso9660.inc b/kernel/branches/kolibri_pe/fs/iso9660.inc index 1112a1dc68..8f0555e29c 100644 --- a/kernel/branches/kolibri_pe/fs/iso9660.inc +++ b/kernel/branches/kolibri_pe/fs/iso9660.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/kernel/branches/kolibri_pe/fs/ntfs.inc b/kernel/branches/kolibri_pe/fs/ntfs.inc index 96fa54f6a1..d0cd132b74 100644 --- a/kernel/branches/kolibri_pe/fs/ntfs.inc +++ b/kernel/branches/kolibri_pe/fs/ntfs.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/kernel/branches/kolibri_pe/gui/button.inc b/kernel/branches/kolibri_pe/gui/button.inc index c3d42ef3e7..d74064a977 100644 --- a/kernel/branches/kolibri_pe/gui/button.inc +++ b/kernel/branches/kolibri_pe/gui/button.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -589,7 +589,7 @@ checkbuttons: iglobal mx dw 0x0 ; keeps the x mouse's position when it was clicked my dw 0x0 ; keeps the y mouse's position when it was clicked - bPressedMouseXY_B db 0x0 + bPressedMouseXY_B db 0x0 btn_down_determ db 0x0 ; << // Alver 22.06.2008// << endg diff --git a/kernel/branches/kolibri_pe/gui/font.inc b/kernel/branches/kolibri_pe/gui/font.inc index 997acef26d..e693361153 100644 --- a/kernel/branches/kolibri_pe/gui/font.inc +++ b/kernel/branches/kolibri_pe/gui/font.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/kernel/branches/kolibri_pe/gui/win.c b/kernel/branches/kolibri_pe/gui/win.c new file mode 100644 index 0000000000..c64ea7de81 --- /dev/null +++ b/kernel/branches/kolibri_pe/gui/win.c @@ -0,0 +1,204 @@ + +#include +#include +#include +#include +#include +#include + + +slab_cache_t *win_slab; + +link_t win_list; + +window_t *win_slot[256]; + +extern int current_task; + +void fill_disp_data(int left, int top, int right, + int bottom, int slot); + +void update_disp_data(window_t *win) +{ + do{ +// fill_disp_data(win->wrect.left, win->wrect.top, +// win->wrect.right,win->wrect.bottom, +// win->slot); + + + __asm__ __volatile__ ( + "call _set_screen \n\t" + : + :"b" (win->wrect.left), + "a" (win->wrect.top), + "c" (win->wrect.right-win->wrect.left+1), + "d" (win->wrect.bottom-win->wrect.top+1), + "S" (win->slot) + :"edi"); + + __asm__ __volatile__ ( + "" + :::"eax", "ebx", "ecx", "edx", "esi"); + + win = (window_t*)win->link.prev; + } while(&win->link != &win_list); +} + +void insert_window(window_t *win) +{ + if( list_empty(&win_list)) + list_prepend(&win->link, &win_list); + else + { + window_t *tmp; + tmp = (window_t*)win_list.next; + + while( &tmp->link != &win_list) + { + if(win->style <= tmp->style) + break; + tmp = (window_t*)tmp->link.next; + } + list_insert(&win->link, &tmp->link); + }; + update_disp_data(win); +}; + +u32_t sys_create_window(char *caption, u32_t style, + int x, int y, int width, int height) +{ + window_t *win; + int r, b; + + DBG("\ncreate window %s, x %d y %d\n" + "width %d height %d\n",caption, x,y, width, height); + + win = (window_t*)slab_alloc(win_slab,0); + + link_initialize(&win->link); + + r = x+width-1; + b = y+height-1; + + win->wrect.left = x; + win->wrect.top = y; + win->wrect.right = r; + win->wrect.bottom = b; + + win->crect.left = x; + win->crect.top = y; + win->crect.right = r; + win->crect.bottom = b; + + win->style = style; + win->slot = current_task; + + list_initialize(&win->queue); + win->qflags = 0; + + win->caption = caption; + + win_slot[current_task] = win; + return current_task; +} + +#define QS_PAINT 1 + +bool sys_show_window(u32_t handle) +{ + window_t *win; + + win = win_slot[current_task]; + + insert_window(win); + win->qflags |= QS_PAINT; + + return true; +}; + +void sys_get_event(event_t *ev) +{ + window_t *win; + + win = win_slot[current_task]; + + if(win->qflags & QS_PAINT) + { + ev->code = 1; + ev->win = win->slot; + ev->val1 = 0; + ev->val2 = 0; + ev->x = 0; + ev->y = 0; + win->qflags&= ~QS_PAINT; + }; +} + +static inline draw_bar(int x, int y, int w, int h, u32_t color) +{ + int_draw_bar(x, y, w, h, color); + __asm__ __volatile__ ( + "" + :::"ebx", "esi", "edi"); +}; + +static inline hline(int x, int y, int w, color_t color) +{ + int_hline(x, y, w, color); + __asm__ __volatile__ ( + "" + :::"esi", "edi"); +}; + +static inline vline(int x, int y, int h, color_t color) +{ + int_vline(x, y, h, color); + __asm__ __volatile__ ( + "" + :::"esi", "edi"); +}; + +static inline rectangle(int x, int y, int w, int h, color_t color) +{ + int_rectangle(x, y, w, h, color); + __asm__ __volatile__ ( + "" + :::"esi", "edi"); +}; + +extern color_t skin_active; + +void sys_def_window_proc(event_t *ev) +{ + window_t *win; + + win = win_slot[current_task]; + + if(ev->code =1) + { + int w, h; + color_t *skin = &skin_active; + + w = win->wrect.right-win->wrect.left+1; + h = win->wrect.bottom - win->wrect.top+1; + + rectangle(win->wrect.left, win->wrect.top, + w, h, skin[1]); + + rectangle(win->wrect.left+1, win->wrect.top+1, + w-2, h-2, skin[2]); + + rectangle(win->wrect.left+2, win->wrect.top+2, + w-4, h-4, skin[2]); + + rectangle(win->wrect.left+3, win->wrect.top+3, + w-6, h-6, skin[2]); + + rectangle(win->wrect.left+4, win->wrect.top+4, + w-8, h-8, skin[0]); + + // draw_bar(win->wrect.left+4, win->wrect.top+4, + // w-8, h-8, skin[1]); + + }; +}; diff --git a/kernel/branches/kolibri_pe/gui/window.inc b/kernel/branches/kolibri_pe/gui/window.inc index 4b8adf5dd0..137b52c55f 100644 --- a/kernel/branches/kolibri_pe/gui/window.inc +++ b/kernel/branches/kolibri_pe/gui/window.inc @@ -22,7 +22,7 @@ get_rolledup_height: ; edi = window draw_data pointer mov al,[edi+WDATA.fl_wstyle] and al,0x0F cmp al,0x03 - jne @f + jb @f mov eax,[_skinh] add eax,3 ret @@ -61,78 +61,78 @@ setwindowdefaults: ; ўрёЄхщ юъюэ т√чтрЄ№ setscreen align 4 calculatescreen: - pushad - pushfd - cli + pushad + pushfd + cli - push edx ecx ebx eax + push edx ecx ebx eax - mov esi, 1 - call setscreen + mov esi, 1 + call setscreen - mov ebp, [TASK_COUNT] ; number of processes - cmp ebp, 1 - jbe .finish + mov ebp, [TASK_COUNT] ; number of processes + cmp ebp, 1 + jbe .finish align 4 .new_wnd: - movzx edi, word [WIN_POS + esi * 2] - shl edi, 5 + movzx edi, word [WIN_POS + esi * 2] + shl edi, 5 - cmp [CURRENT_TASK+edi+TASKDATA.state], byte 9 - je .not_wnd + cmp [CURRENT_TASK+edi+TASKDATA.state], byte 9 + je .not_wnd - add edi, window_data - test [edi+WDATA.fl_wstate], WSTATE_MINIMIZED - jnz .not_wnd + add edi, window_data + test [edi+WDATA.fl_wstate], WSTATE_MINIMIZED + jnz .not_wnd - mov eax,[edi+WDATA.box.left] - cmp eax, [esp+RECT.right] - ja .out_of_bounds - mov ebx,[edi+WDATA.box.top] - cmp ebx, [esp+RECT.bottom] - ja .out_of_bounds - mov ecx,[edi+WDATA.box.width] - add ecx, eax - cmp ecx, [esp+RECT.left] - jb .out_of_bounds - mov edx,[edi+WDATA.box.height] - add edx, ebx - cmp edx, [esp+RECT.top] - jb .out_of_bounds + mov eax,[edi+WDATA.box.left] + cmp eax, [esp+RECT.right] + ja .out_of_bounds + mov ebx,[edi+WDATA.box.top] + cmp ebx, [esp+RECT.bottom] + ja .out_of_bounds + mov ecx,[edi+WDATA.box.width] + add ecx, eax + cmp ecx, [esp+RECT.left] + jb .out_of_bounds + mov edx,[edi+WDATA.box.height] + add edx, ebx + cmp edx, [esp+RECT.top] + jb .out_of_bounds - cmp eax, [esp+RECT.left] - jae @f - mov eax, [esp+RECT.left] + cmp eax, [esp+RECT.left] + jae @f + mov eax, [esp+RECT.left] @@: - cmp ebx, [esp+RECT.top] - jae @f - mov ebx, [esp+RECT.top] + cmp ebx, [esp+RECT.top] + jae @f + mov ebx, [esp+RECT.top] @@: - cmp ecx, [esp+RECT.right] - jbe @f - mov ecx, [esp+RECT.right] + cmp ecx, [esp+RECT.right] + jbe @f + mov ecx, [esp+RECT.right] @@: - cmp edx, [esp+RECT.bottom] - jbe @f - mov edx, [esp+RECT.bottom] + cmp edx, [esp+RECT.bottom] + jbe @f + mov edx, [esp+RECT.bottom] @@: - push esi - movzx esi, word [WIN_POS + esi * 2] - call setscreen - pop esi + push esi + movzx esi, word [WIN_POS + esi * 2] + call setscreen + pop esi .not_wnd: .out_of_bounds: - inc esi - dec ebp - jnz .new_wnd + inc esi + dec ebp + jnz .new_wnd .finish: - pop eax ebx ecx edx + pop eax ebx ecx edx - popfd - popad + popfd + popad ret @@ -173,40 +173,40 @@ pushad jne .free_form ; get x&y size - sub ecx, eax - sub edx, ebx - inc ecx - inc edx + sub ecx, eax + sub edx, ebx + inc ecx + inc edx ; get WinMap start mov edi, [Screen_Max_X] ; screen_sx - inc edi - imul edi, ebx - add edi, eax + inc edi + imul edi, ebx + add edi, eax add edi, [_display_data] .new_y: - push ecx ; sx - push edx + push ecx ; sx + push edx - mov edx, esi + mov edx, esi align 4 .new_x: - mov byte [edi], dl - inc edi - dec ecx - jnz .new_x + mov byte [edi], dl + inc edi + dec ecx + jnz .new_x - pop edx - pop ecx + pop edx + pop ecx add edi, [Screen_Max_X] - inc edi - sub edi, ecx - dec edx - jnz .new_y + inc edi + sub edi, ecx + dec edx + jnz .new_y .ret: - popad - ret + popad + ret .read_byte: ;eax - address ;esi - slot @@ -557,7 +557,6 @@ endg - check_window_position: pushad ; window inside screen ? @@ -862,7 +861,6 @@ dw3l: jnz noinside2 call [drawbar] noinside2: - popad ret @@ -1130,12 +1128,10 @@ restore_minimized_window: ret -iglobal - window_moving db 'K : Window - move/resize',13,10,0 - window_moved db 'K : Window - done',13,10,0 -endg - -bPressedMouseXY_W db 0x0 +;iglobal +; window_moving db 'K : Window - move/resize',13,10,0 +; window_moved db 'K : Window - done',13,10,0 +;endg ; check window touch align 4 @@ -1164,44 +1160,74 @@ checkwindows: popad ret .mouse_buttons_pressed: +;..................................... start 2/4 : modified by vhanla ................. +uglobal + bPressedMouseXY_W db 0x0 +endg +;..................................... end 2/4 : modified by vhanla ................... mov esi,[TASK_COUNT] inc esi ;..................................... start 3/4 : modified by vhanla ................. - cmp [bPressedMouseXY_W],0 - jnz @f - mov [bPressedMouseXY_W],1 -@@: + cmp [bPressedMouseXY_W],1 + ja @f + inc [bPressedMouseXY_W] + jnc @f + ;mov ax,[MOUSE_X] + ;mov [mx],ax + ;mov ax,[MOUSE_Y] + ;mov [my],ax + mov eax,dword[MOUSE_X] + mov dword[mx],eax + @@: ;..................................... end 3/4 : modified by vhanla ................... - movzx eax,word [MOUSE_Y] - movzx ebx,word [MOUSE_X] - mov ecx, [Screen_Max_X] - add ebx, [_display_data] - inc ecx - mul ecx - movzx edi, byte [ebx+eax] - -cwloop: - - movzx esi, word [WIN_STACK + edi * 2] + cwloop: + cmp esi,2 + jb .exit + dec esi + movzx edi, word [WIN_POS + esi * 2] ; ebx shl edi, 5 add edi, window_data +; mov edi, ebx + mov ecx, [edi + WDATA.box.left] + mov edx, [edi + WDATA.box.top] - movzx eax,word [MOUSE_X] - movzx ebx,word [MOUSE_Y] + mov eax,ecx + mov ebx,edx + test [edi+WDATA.fl_wstate],WSTATE_MINIMIZED + jnz cwloop + +;..................................... start 4/4 : modified by vhanla ................. + movzx eax, word [mx]; movzx eax,word[MOUSE_X] + movzx ebx, word [my]; movzx ebx,word[MOUSE_Y] +;..................................... endt 4/4 : modified by vhanla .................. + cmp ecx, eax + jae cwloop + cmp edx, ebx + jae cwloop + add ecx, [edi + WDATA.box.width] + add edx, [edi + WDATA.box.height] + cmp eax, ecx + jae cwloop + cmp ebx, edx + jae cwloop pushad - mov eax, esi + mov eax, esi mov ebx, [TASK_COUNT] cmp eax, ebx ; is this window active? jz .move_resize_window + cmp [bPressedMouseXY_W], 1 + ja .exit_popa + ; eax = position in windowing stack ; redraw must ? lea esi, [WIN_POS + esi * 2] call waredraw +.exit_popa: add esp, 32 .exit: @@ -1252,10 +1278,10 @@ cwloop: .continue: - push esi - mov esi, window_moving - call sys_msg_board_str - pop esi +; push esi +; mov esi, window_moving +; call sys_msg_board_str +; pop esi mov ecx, [timer_ticks] ; double-click ? mov edx, ecx @@ -1311,6 +1337,7 @@ cwloop: call drawwindowframes mov [reposition],0 + mov [MOUSE_DOWN],byte 1 ; no reaction to mouse up/down ; move window @@ -1320,6 +1347,7 @@ newchm: call checkVga_N13 + mov [MOUSE_BACKGROUND],byte 0 call [draw_pointer] @@ -1328,7 +1356,7 @@ newchm: popad mov esi,[WIN_TEMP_XY] - cmp esi, dword [MOUSE_X] + cmp esi,[MOUSE_X] je cwb mov cx,[MOUSE_X] @@ -1409,7 +1437,7 @@ newchm: mov [reposition],1 popad -norepos_size: + norepos_size: pop bx pop ax @@ -1608,8 +1636,8 @@ waitre2: retwm: - mov esi,window_moved - call sys_msg_board_str +; mov esi,window_moved +; call sys_msg_board_str popad @@ -1617,9 +1645,9 @@ retwm: uglobal - add_window_data dd 0 + add_window_data dd 0 do_resize_from_corner db 0x0 - reposition db 0x0 + reposition db 0x0 latest_window_touch dd 0x0 latest_window_touch_delta dd 0x0 @@ -1745,3 +1773,405 @@ rsw_no_scale: ret +;ebx x +;eax y +;ecx width +;edx height +;esi slot + +align 4 +_set_screen: + push edx + add ebx, [_display_data] + mul [_screen_width] + lea ebx, [eax+ebx] + + mov eax, esi + mov ah, al + mov esi, eax + shl eax, 16 + or eax, esi + + pop edx + mov esi, ecx +.row: + + mov edi, ebx + add ebx, [_screen_width] + + mov ecx, esi + + dec edx + js .done +.16: + cmp ecx, 16 + jb .8 + + mov [edi], eax + mov [edi+4], eax + mov [edi+8], eax + mov [edi+12], eax + add edi, 16 + sub ecx, 16 + jmp .16 +.8: + shr ecx, 2 + rep stosd + mov ecx, esi + and ecx, 3 + rep stosb + jmp .row +.done: + ret + +;[esp+4] ebp +;[esp+8] x +;[esp+12] y +;[esp+16] w +;[esp+20] h +;[esp+24] color + +;ebx disp data +;edx dest + +public _int_draw_bar +align 4 +_int_draw_bar: + + lea ecx, [esp+4] + call lock_cursor + + sub esp, 4 + mov [esp], ebp + + mov ebx, [esp+8] + mov eax, [esp+12] + mul [_screen_width] + add ebx, [_display_data] + lea ebx, [eax+ebx] + + mov edi, [esp+8] + mov eax, [esp+12] + mul [BytesPerScanLine] + + cmp byte [ScreenBPP], 24 + je .24 + + lea ecx, [LFB_BASE+eax+edi*4] + + mov eax, [esp+24] + mov edx, [CURRENT_TASK] +.row32: + mov edi, ecx + mov esi, ebx + + add ecx, [BytesPerScanLine] + add ebx, [_screen_width] + + dec dword [esp+20] + js .done + + mov ebp, [esp+16] + +align 16 +.draw32: + cmp dl, byte [esi] + jne @f + + stosd +@@: + inc esi + dec ebp + jnz .draw32 + jmp .row32 +.done: + call unlock_cursor + + mov ebp, [esp] + add esp, 4 + ret + +.24: + lea ecx, [LFB_BASE+edi*3] + add ecx, eax + + mov eax, [esp+24] + mov edx, eax + shr edx, 8 + mov dl, [CURRENT_TASK] +.row24: + mov edi, ecx + mov esi, ebx + + add ecx, [BytesPerScanLine] + add ebx, [_screen_width] + + dec dword [esp+20] + js .done + + mov ebp, [esp+16] + +align 16 +.draw24: + cmp dl, byte [esi] + jne @f + + mov [edi], ax + mov [edi+2], dh +@@: + add edi, 3 + inc esi + dec ebp + jnz .draw24 + jmp .row24 + + + +;[esp+4] x +;[esp+8] y +;[esp+12] w +;[esp+16] color + +;esi disp data +;edi dest + + +public _int_hline +align 4 +_int_hline: + + mov esi, [esp+4] + mov eax, [esp+8] + mov ecx, [esp+12] + + mul [_screen_width] + add esi, [_display_data] + add esi, eax + + mov edi, [esp+4] + mov eax, [esp+8] + mul [BytesPerScanLine] + + cmp byte [ScreenBPP], 24 + je .24 + + lea edi, [LFB_BASE+eax+edi*4] + + mov eax, [esp+16] + +.32_kernel: + mov edx, [CURRENT_TASK] + +align 16 +.draw32: + cmp dl, byte [esi] + jne @f + + stosd +@@: + inc esi + dec ecx + jnz .draw32 + + ret +.24: + lea edi, [LFB_BASE+edi*3] + add edi, eax + + mov eax, [esp+16] + +.24_kernel: + mov edx, eax + shr edx, 8 + mov dl, [CURRENT_TASK] + +align 16 +.draw24: + cmp dl, byte [esi] + jne @f + + mov [edi], ax + mov [edi+2], dh +@@: + add edi, 3 + inc esi + dec ecx + jnz .draw24 + + ret + + +;[esp+4] x +;[esp+8] y +;[esp+12] h +;[esp+16] color + +;esi disp data +;edi dest + +public _int_vline +align 4 +_int_vline: + + mov esi, [esp+4] + mov eax, [esp+8] + mov ecx, [esp+12] + + mul [_screen_width] + add esi, [_display_data] + add esi, eax + + mov edi, [esp+4] + mov eax, [esp+8] + mul [BytesPerScanLine] + + cmp byte [ScreenBPP], 24 + je .24 + + lea edi, [LFB_BASE+eax+edi*4] + + mov eax, [esp+16] + +.32_kernel: + mov edx, [CURRENT_TASK] + +align 16 +.draw32: + cmp dl, byte [esi] + jne @f + + mov [edi], eax +@@: + add esi, [_screen_width] + add edi, [BytesPerScanLine] + dec ecx + jnz .draw32 + + ret +.24: + lea edi, [LFB_BASE+edi*3] + add edi, eax + + mov eax, [esp+16] + +.24_kernel: + mov edx, eax + shr edx, 8 + mov dl, [CURRENT_TASK] + +align 16 +.draw24: + cmp dl, byte [esi] + jne @f + + mov [edi], ax + mov [edi+2], dh +@@: + add esi, [_screen_width] + add edi, [BytesPerScanLine] + dec ecx + jnz .draw24 + + ret + +;[esp] dst +;[esp+4] mask + +;[esp+12] x +;[esp+16] y +;[esp+20] w +;[esp+24] h +;[esp+32] color + +public _int_rectangle +align 4 +_int_rectangle: + +.dst equ (esp) +.mask equ (esp+4) + +.x equ (esp+12) +.y equ (esp+16) +.w equ (esp+20) +.h equ (esp+24) +.color equ (esp+28) + + sub esp, 8 + + mov esi, [.x] + mov eax, [.y] + mul [_screen_width] + add esi, [_display_data] + add esi, eax + mov [.mask], esi + + mov edi, [.x] + mov eax, [.y] + mul [BytesPerScanLine] + + cmp byte [ScreenBPP], 24 + je .24 + + lea edi, [LFB_BASE+eax+edi*4] + + mov [.dst], edi + + mov ecx, [.w] + mov eax, [.color] + call _int_hline.32_kernel + + sub edi, 4 + dec esi + + mov ecx, [.h] + call _int_vline.32_kernel + + mov edi, [.dst] + mov esi, [.mask] + mov ecx, [.h] + call _int_vline.32_kernel + + mov ecx, [.w] + sub esi, [_screen_width] + sub edi, [BytesPerScanLine] + call _int_hline.32_kernel + + add esp, 8 + ret +.24: + lea edi, [LFB_BASE+edi*3] + add edi, eax + + mov [.dst], edi + + mov ecx, [.w] + mov eax, [.color] + call _int_hline.24_kernel + + sub edi, 3 + dec esi + + mov ecx, [.h] + call _int_vline.24_kernel + + mov edi, [.dst] + mov esi, [.mask] + mov ecx, [.h] + call _int_vline.24_kernel + + mov ecx, [.w] + sub esi, [_screen_width] + sub edi, [BytesPerScanLine] + call _int_hline.24_kernel + +restore .dst +restore .mask + +restore .x +restore .y +restore .w +restore .h +restore .color + + add esp, 8 + ret diff --git a/kernel/branches/kolibri_pe/include/core.h b/kernel/branches/kolibri_pe/include/core.h index 4e96b07b74..964f30ec05 100644 --- a/kernel/branches/kolibri_pe/include/core.h +++ b/kernel/branches/kolibri_pe/include/core.h @@ -1,7 +1,8 @@ -#define OS_BASE 0xE0000000 -#define IMAGE_BASE 0xE0100000 -#define LOAD_BASE 0x00100000 + +#define OS_BASE 0xE0000000 +#define IMAGE_BASE 0xE0100000 +#define LOAD_BASE 0x00100000 #define page_tabs 0xDD800000 @@ -64,13 +65,13 @@ extern void panic_printf(char *fmt, ...) __attribute__((noreturn)); static inline eflags_t safe_cli(void) { - eflags_t tmp; + eflags_t tmp; asm volatile ( "pushfl\n\t" "popl %0\n\t" - "cli\n" + "cli\n" : "=r" (tmp)); - return tmp; + return tmp; } static inline void safe_sti(eflags_t efl) @@ -83,20 +84,20 @@ static inline void safe_sti(eflags_t efl) static inline index_t fnzb(u32_t arg) { - count_t n; + count_t n; asm volatile ( "xorl %0, %0 \n\t" - "bsr %1, %0" + "bsr %1, %0" :"=&r"(n) :"r"(arg) ); return n; } static inline index_t _bsf(u32_t arg) { - count_t n; + count_t n; asm volatile ( "xorl %0, %0 \n\t" - "bsf %1, %0" + "bsf %1, %0" :"=&r" (n) :"r"(arg)); return n; } @@ -211,25 +212,25 @@ typedef struct __attribute__ ((packed)) { struct /* window event */ { - u32_t win; /* window handle */ - u32_t val1; - u32_t val2; - u16_t x; /* cursor x */ - u16_t y; /* cursor y */ - u32_t unused; + u32_t win; /* window handle */ + u32_t val1; + u32_t val2; + u16_t x; /* cursor x */ + u16_t y; /* cursor y */ + u32_t unused; }; struct /* realtime io */ { - u32_t sender; /* service handler */ - u32_t stream; /* io stream id, if present */ - addr_t offset; - size_t size; + u32_t sender; /* service handler */ + u32_t stream; /* io stream id, if present */ + addr_t offset; + size_t size; }; struct /* ipc event */ { - u32_t sender; + u32_t sender; u32_t io_code; addr_t *input; size_t inp_size; diff --git a/kernel/branches/kolibri_pe/include/mm.h b/kernel/branches/kolibri_pe/include/mm.h index cad5ed15cd..108b321e9b 100644 --- a/kernel/branches/kolibri_pe/include/mm.h +++ b/kernel/branches/kolibri_pe/include/mm.h @@ -11,26 +11,27 @@ typedef struct typedef struct { - link_t buddy_link; /**< link to the next free block inside one order */ + link_t buddy_link; /**< link to the next free block inside one order */ u16_t refcount; /**< tracking of shared frames */ u16_t buddy_order; /**< buddy system block order */ - void *parent; /**< If allocated by slab, this points there */ + void *parent; /**< If allocated by slab, this points there */ } frame_t; + typedef struct { - SPINLOCK_DECLARE(lock); /**< this lock protects everything below */ - pfn_t base; /**< frame_no of the first frame in the frames array */ - count_t count; /**< Size of zone */ + SPINLOCK_DECLARE(lock); /**< this lock protects everything below */ + pfn_t base; /**< frame_no of the first frame in the frames array */ + count_t count; /**< Size of zone */ - frame_t *frames; /**< array of frame_t structures in this zone */ - count_t free_count; /**< number of free frame_t structures */ - count_t busy_count; /**< number of busy frame_t structures */ + frame_t *frames; /**< array of frame_t structures in this zone */ + count_t free_count; /**< number of free frame_t structures */ + count_t busy_count; /**< number of busy frame_t structures */ - u32_t max_order; - link_t order[21]; + u32_t max_order; + link_t order[21]; - int flags; + int flags; } zone_t; @@ -45,13 +46,12 @@ typedef struct }md_t; -#define PG_MAP 1 -#define PG_WRITE 2 -#define PG_USER 4 - -#define PG_SW 3 -#define PG_UW 7 +#define PG_MAP 1 +#define PG_WRITE 2 +#define PG_USER 4 +#define PG_SW 3 +#define PG_UW 7 #define PAGE_SIZE 4096 @@ -63,8 +63,8 @@ typedef struct static inline count_t SIZE2FRAMES(size_t size) { - if (!size) - return 0; + if (!size) + return 0; return (count_t) ((size - 1) >> PAGE_WIDTH) + 1; } diff --git a/kernel/branches/kolibri_pe/include/pe.h b/kernel/branches/kolibri_pe/include/pe.h index 108355dba9..1feac23f98 100644 --- a/kernel/branches/kolibri_pe/include/pe.h +++ b/kernel/branches/kolibri_pe/include/pe.h @@ -198,8 +198,8 @@ extern dll_t core_dll; bool validate_pe(void *raw, size_t raw_size, bool is_exec); -dll_t * find_dll(link_t *list, const char *name); +dll_t * find_dll(link_t *list, const char *name); addr_t __fastcall load_image(const char *path); diff --git a/kernel/branches/kolibri_pe/include/slab.h b/kernel/branches/kolibri_pe/include/slab.h index f1f36dcc22..8c5d5895e7 100644 --- a/kernel/branches/kolibri_pe/include/slab.h +++ b/kernel/branches/kolibri_pe/include/slab.h @@ -80,3 +80,33 @@ slab_cache_t * slab_cache_create( void* __fastcall slab_alloc(slab_cache_t *cache, int flags); void __fastcall slab_free(slab_cache_t *cache, void *obj); + +typedef struct +{ + int left; + int top; + int right; + int bottom; +}rect_t; + +typedef struct +{ + link_t link; + rect_t wrect; + rect_t crect; + rect_t hrect; + + color_t clr_workarea; + color_t clr_titlebar; + color_t clr_frames; + + u32_t style; + u32_t state; + + int slot; + + link_t queue; + u32_t qflags; + + char *caption; +}window_t; diff --git a/kernel/branches/kolibri_pe/kernel.asm b/kernel/branches/kolibri_pe/kernel.asm index 6f429fff49..6ebf2bc2d7 100644 --- a/kernel/branches/kolibri_pe/kernel.asm +++ b/kernel/branches/kolibri_pe/kernel.asm @@ -20,6 +20,7 @@ format MS COFF ;; Sergey Semyonov (Serge) ;; Johnny_B ;; SPraid (simba) +;; Hidnplayr ;; ;; 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 @@ -246,6 +247,8 @@ extrn _bx_from_load extrn _sys_app_entry +public _set_screen + extrn _i40 extrn test_cpu @@ -255,7 +258,10 @@ extrn cpu_sign extrn cpu_info extrn cpu_caps:dword - +extrn stb_create_window +extrn stb_show_window +extrn stb_get_event +extrn stb_def_window_proc section '.flat' code readable align 4096 @@ -339,9 +345,9 @@ init_apm: align 16 system_init: - mov [pg_data.pg_mutex], 0 + mov [pg_data.pg_mutex], 0 - call init_apm + call init_apm ; SAVE REAL MODE VARIABLES mov ax, [OS_BASE + 0x9031] @@ -414,8 +420,9 @@ no_mode_0x12: call @mem_alloc@8 mov [_display_data], eax - mov ecx, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ + mov ecx, 4096 + (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ (unpack.lc+unpack.lp)))*4 + mov edx, PG_SW call @mem_alloc@8 mov [unpack.p], eax @@ -570,80 +577,80 @@ include 'detect/disks.inc' ; SET PRELIMINARY WINDOW STACK AND POSITIONS - mov esi,boot_windefs - call boot_log - call setwindowdefaults + mov esi,boot_windefs + call boot_log + call setwindowdefaults ; SET BACKGROUND DEFAULTS - mov esi,boot_bgr - call boot_log - call init_background - call calculatebackground + mov esi,boot_bgr + call boot_log + call init_background + call calculatebackground ; RESERVE SYSTEM IRQ'S JA PORT'S - mov esi,boot_resirqports - call boot_log - call reserve_irqs_ports + mov esi,boot_resirqports + call boot_log + call reserve_irqs_ports ; SET PORTS FOR IRQ HANDLERS - mov esi,boot_setrports - call boot_log + mov esi,boot_setrports + call boot_log ;call setirqreadports ; SETUP OS TASK - mov esi,boot_setostask - call boot_log + mov esi,boot_setostask + call boot_log - xor eax, eax - mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data - mov dword [SLOT_BASE+APPDATA.fpu_handler], eax - mov dword [SLOT_BASE+APPDATA.sse_handler], eax + xor eax, eax + mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data + mov dword [SLOT_BASE+APPDATA.fpu_handler], eax + mov dword [SLOT_BASE+APPDATA.sse_handler], eax ; name for OS/IDLE process - mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' - mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' + mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' + mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' mov edi, __os_stack-8192+512 - mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi - add edi, 0x2000-512 - mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi - mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case - mov dword [SLOT_BASE+256+APPDATA.io_map],\ - (tss._io_map_0-OS_BASE+PG_MAP) - mov dword [SLOT_BASE+256+APPDATA.io_map+4],\ - (tss._io_map_1-OS_BASE+PG_MAP) + mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi + add edi, 0x2000-512 + mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi + mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case + mov dword [SLOT_BASE+256+APPDATA.io_map],\ + (tss._io_map_0-OS_BASE+PG_MAP) + mov dword [SLOT_BASE+256+APPDATA.io_map+4],\ + (tss._io_map_1-OS_BASE+PG_MAP) - mov esi, fpu_data - mov ecx, 512/4 - cld - rep movsd + mov esi, fpu_data + mov ecx, 512/4 + cld + rep movsd mov dword [SLOT_BASE+256+APPDATA.fpu_handler], eax - mov dword [SLOT_BASE+256+APPDATA.sse_handler], eax + mov dword [SLOT_BASE+256+APPDATA.sse_handler], eax - mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET - mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx - mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx + mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET + mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx + mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx - mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path + mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path - ; task list - mov [CURRENT_TASK],dword 1 - mov [TASK_COUNT],dword 1 - mov [current_slot], SLOT_BASE+256 - mov [TASK_BASE],dword TASK_DATA - mov [TASK_DATA+TASKDATA.wnd_number], 1 ; on screen number - mov [TASK_DATA+TASKDATA.pid], 1 ; process id number - mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address + ; task list + mov [CURRENT_TASK],dword 1 + mov [TASK_COUNT],dword 1 + mov [current_slot], SLOT_BASE+256 + mov [TASK_BASE],dword TASK_DATA + mov [TASK_DATA+TASKDATA.wnd_number], 1 ; on screen number + mov [TASK_DATA+TASKDATA.pid], 1 ; process id number + mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address call init_cursors mov eax, [def_cursor] - mov [SLOT_BASE+APPDATA.cursor],eax - mov [SLOT_BASE+APPDATA.cursor+256],eax + mov [SLOT_BASE+APPDATA.cursor],eax + mov [SLOT_BASE+APPDATA.cursor+256],eax ; mov ecx, szAtiHW ; call @load_pe_driver@4 @@ -799,6 +806,7 @@ first_app_found: setnz [dma_hdd] mov [timer_ticks_enable],1 ; for cd driver +;xchg bx, bx sti call change_task diff --git a/kernel/branches/kolibri_pe/kernel32.inc b/kernel/branches/kolibri_pe/kernel32.inc index 0ec2dce509..24094c0273 100644 --- a/kernel/branches/kolibri_pe/kernel32.inc +++ b/kernel/branches/kolibri_pe/kernel32.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; KERNEL32.INC ;; @@ -84,12 +84,12 @@ struc TASKDATA { .event_mask dd ? .pid dd ? - dw ? + dw ? .state db ? db ? - dw ? + dw ? .wnd_number db ? - db ? + db ? .mem_start dd ? .counter_sum dd ? .counter_add dd ? @@ -101,11 +101,11 @@ end virtual ; structures definition struc WDATA { - .box BOX + .box BOX .cl_workarea dd ? .cl_titlebar dd ? .cl_frames dd ? - .reserved db ? + .reserved db ? .fl_wstate db ? .fl_wdrawn db ? .fl_redraw db ? @@ -117,8 +117,8 @@ label WDATA.fl_wstyle byte at 0x13 struc APPDATA { - .app_name db 11 dup(?) - db 5 dup(?) + .app_name db 11 dup(?) + db 5 dup(?) .fpu_state dd ? ;+16 .ev_count dd ? ;+20 @@ -147,12 +147,12 @@ struc APPDATA .mem_size dd ? ;+140 .saved_box BOX .ipc_start dd ? - .ipc_size dd ? + .ipc_size dd ? .event_mask dd ? .debugger_slot dd ? - dd ? + dd ? .keyboard_mode db ? - db 3 dup(?) + db 3 dup(?) .dir_table dd ? .dbg_event_mem dd ? .dbg_regs: diff --git a/kernel/branches/kolibri_pe/makefile b/kernel/branches/kolibri_pe/makefile index 481846248b..c8a0d293cd 100644 --- a/kernel/branches/kolibri_pe/makefile +++ b/kernel/branches/kolibri_pe/makefile @@ -40,6 +40,7 @@ PE_SRC:= \ dll.c \ spinlock.c \ thread.c \ + win.c \ syscall.asm \ boot/boot.asm \ boot/start.asm diff --git a/kernel/branches/kolibri_pe/network/eth_drv/arp.inc b/kernel/branches/kolibri_pe/network/eth_drv/arp.inc index dee6457cca..e98734d963 100644 --- a/kernel/branches/kolibri_pe/network/eth_drv/arp.inc +++ b/kernel/branches/kolibri_pe/network/eth_drv/arp.inc @@ -1,14 +1,12 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; ARP.INC ;; ;; ;; ;; Address Resolution Protocol ;; ;; ;; -;; Last revision: 10.11.2006 ;; -;; ;; ;; This file contains the following: ;; ;; arp_table_manager - Manages an ARPTable ;; ;; arp_request - Sends an ARP request on the ethernet ;; diff --git a/kernel/branches/kolibri_pe/network/eth_drv/ethernet.inc b/kernel/branches/kolibri_pe/network/eth_drv/ethernet.inc index 74df50176d..e85c0b69b2 100644 --- a/kernel/branches/kolibri_pe/network/eth_drv/ethernet.inc +++ b/kernel/branches/kolibri_pe/network/eth_drv/ethernet.inc @@ -1,14 +1,12 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; ETHERNET.INC ;; ;; ;; ;; Ethernet network layer for Menuet OS ;; ;; ;; -;; Version 0.4 22 September 2003 ;; -;; ;; ;; This file contains the following: ;; ;; PCI bus scanning for valid devices ;; ;; Table of supported ethernet drivers ;; @@ -353,9 +351,9 @@ endp ; All registers may be destroyed ; ;*************************************************************************** -uglobal - ether_IP_handler_cnt dd ? -endg +;uglobal +; ether_IP_handler_cnt dd ? +;endg ether_IP_handler: mov eax, EMPTY_QUEUE call dequeue diff --git a/kernel/branches/kolibri_pe/network/ip.inc b/kernel/branches/kolibri_pe/network/ip.inc index e1b5b4882b..bd063cd5f1 100644 --- a/kernel/branches/kolibri_pe/network/ip.inc +++ b/kernel/branches/kolibri_pe/network/ip.inc @@ -223,7 +223,7 @@ local buffer_number dd ? jmp .dump.x .dump.4: - DEBUGF 1, "K : ip_rx - dumped (ihl: %u)\n", [ebx + IP_PACKET.TimeToLive] + DEBUGF 1, "K : ip_rx - dumped (ttl: %u)\n", [ebx + IP_PACKET.TimeToLive] jmp .dump.x .dump.5: diff --git a/kernel/branches/kolibri_pe/network/queue.inc b/kernel/branches/kolibri_pe/network/queue.inc index 01da8ea3ad..1986f50ec7 100644 --- a/kernel/branches/kolibri_pe/network/queue.inc +++ b/kernel/branches/kolibri_pe/network/queue.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; ;; @@ -8,8 +8,6 @@ ;; ;; ;; Buffer queue management for Menuet OS TCP/IP Stack ;; ;; ;; -;; Version 0.3 29 August 2002 ;; -;; ;; ;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;; ;; ;; ;; See file COPYING for details ;; @@ -43,9 +41,9 @@ $Revision$ ; all other registers preserved ; This always works, so no error returned ;*************************************************************************** -uglobal - freeBuff_cnt dd ? -endg +;uglobal +; freeBuff_cnt dd ? +;endg freeBuff: ; inc [freeBuff_cnt] ; DEBUGF 1, "K : freeBuff (%u)\n", [freeBuff_cnt] @@ -106,9 +104,9 @@ qs_exit: ; all other registers preserved ; This always works, so no error returned ;*************************************************************************** -uglobal - queue_cnt dd ? -endg +;uglobal +; queue_cnt dd ? +;endg queue: ; inc [queue_cnt] ; DEBUGF 1, "K : queue (%u)\n", [queue_cnt] @@ -161,9 +159,9 @@ qu_exit: ; all other registers preserved ; ;*************************************************************************** -uglobal - dequeue_cnt dd ? -endg +;uglobal +; dequeue_cnt dd ? +;endg dequeue: push ebx shl eax, 1 diff --git a/kernel/branches/kolibri_pe/network/socket.inc b/kernel/branches/kolibri_pe/network/socket.inc index e0f2be12bf..38d5b09a51 100644 --- a/kernel/branches/kolibri_pe/network/socket.inc +++ b/kernel/branches/kolibri_pe/network/socket.inc @@ -1,14 +1,12 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; SOCKET.INC ;; ;; ;; ;; Sockets constants, structures and functions ;; ;; ;; -;; Last revision: 11.11.2006 ;; -;; ;; ;; This file contains the following: ;; ;; is_localport_unused ;; ;; get_free_socket ;; @@ -31,113 +29,59 @@ $Revision$ - -; -; Socket Descriptor + Buffer -; -; 0 1 2 3 -; 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -; -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 0| Status ( of this buffer ) | -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 4| Application Process ID | -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 8| Local IP Address | -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 12| Local IP Port | Unused ( set to 0 ) | -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 16| Remote IP Address | -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 20| Remote IP Port | Unused ( set to 0 ) | -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 24| Rx Data Count INTEL format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 28| TCB STATE INTEL format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 32| TCB Timer (seconds) INTEL format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 36| ISS (Inital Sequence # used by this connection ) INET format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 40| IRS ( Inital Receive Sequence # ) INET format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 44| SND.UNA Seq # of unack'ed sent packets INET format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 48| SND.NXT Next send seq # to use INET format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 52| SND.WND Send window INET format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 56| RCV.NXT Next expected receive sequence # INET format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 60| RCV.WND Receive window INET format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 64| SEG.LEN Segment length INTEL format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 68| SEG.WND Segment window INTEL format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 72| Retransmit queue # NOW WINDOW SIZE TIMER INTEL format| -; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -; 76| RX Data Buffer | -; +-+-+-.......... -+ - - -; so, define struct -struc SOCKET -{ - .PrevPtr dd ? - .NextPtr dd ? - .Status dd ? ;+00 - Status ( of this buffer ) - .PID dd ? ;+04 - Application Process ID - .LocalIP dd ? ;+08 - Local IP Address - .LocalPort dw ? ;+12 - Local Port - .RemoteIP dd ? ;+16 - Remote IP Address - .RemotePort dw ? ;+20 - Remote Port - .OrigRemoteIP dd ? - .OrigRemotePort dw ? - .rxDataCount dd ? ;+24 - Rx Data Count - .TCBState dd ? ;+28 - TCB STATE - .TCBTimer dd ? ;+32 - TCB Timer (seconds) - .ISS dd ? ;+36 - Initial Send Sequence - .IRS dd ? ;+40 - Initial Receive Sequence - .SND_UNA dd ? ;+44 - Sequence number of unack'ed sent packets - .SND_NXT dd ? ;+48 - Next send sequence number to use - .SND_WND dd ? ;+52 - Send window - .RCV_NXT dd ? ;+56 - Next receive sequence number to use - .RCV_WND dd ? ;+60 - Receive window - .SEG_LEN dd ? ;+64 - Segment length - .SEG_WND dd ? ;+68 - Segment window - .wndsizeTimer dd ? ;+72 - Retransmit queue # NOW WINDOW SIZE TIMER - .rxData dd ? ;+76 - receive data buffer here -} - -virtual at 0 - SOCKET SOCKET -end virtual - -; simple macro calcing real memory address of SOCKET struct by socket's -;macro Index2RealAddr reg -;{ -; shl reg, 12 -; add reg, sockets -;} - -;Constants -; current socket statuses -SOCK_EMPTY = 0 ; socket not in use -SOCK_OPEN = 1 ; open issued, but no data sent +; socket data structure +struct SOCKET + .PrevPtr dd ? ; pointer to previous socket in list + .NextPtr dd ? ; pointer to next socket in list + .Number dd ? ; socket number (unique within single process) + .PID dd ? ; application process id + .LocalIP dd ? ; local IP address + .LocalPort dw ? ; local port + .RemoteIP dd ? ; remote IP address + .RemotePort dw ? ; remote port + .OrigRemoteIP dd ? ; original remote IP address (used to reset to LISTEN state) + .OrigRemotePort dw ? ; original remote port (used to reset to LISTEN state) + .rxDataCount dd ? ; rx data count + .TCBState dd ? ; TCB state + .TCBTimer dd ? ; TCB timer (seconds) + .ISS dd ? ; initial send sequence + .IRS dd ? ; initial receive sequence + .SND_UNA dd ? ; sequence number of unack'ed sent packets + .SND_NXT dd ? ; bext send sequence number to use + .SND_WND dd ? ; send window + .RCV_NXT dd ? ; next receive sequence number to use + .RCV_WND dd ? ; receive window + .SEG_LEN dd ? ; segment length + .SEG_WND dd ? ; segment window + .wndsizeTimer dd ? ; window size timer + .lock dd ? ; lock mutex + .rxData dd ? ; receive data buffer here +ends ; TCP opening modes -SOCKET_PASSIVE equ 0 -SOCKET_ACTIVE equ 1 +SOCKET_PASSIVE = 0 +SOCKET_ACTIVE = 1 +; socket types +SOCK_STREAM = 1 +SOCK_DGRAM = 2 + +;; Allocate memory for socket data and put new socket into the list +; Newly created socket is initialized with calling PID and number and +; put into beginning of list (which is a fastest way). +; +; @return socket structure address in EAX +;; proc net_socket_alloc stdcall uses ebx ecx edx edi mov ecx, SOCKETBUFFSIZE mov edx, PG_SW call @mem_alloc@8 DEBUGF 1, "K : net_socket_alloc (0x%x)\n", eax + ; check if we can allocate needed amount of memory or eax, eax jz .exit + ; zero-initialize allocated memory push eax mov edi, eax mov ecx, SOCKETBUFFSIZE / 4 @@ -146,6 +90,7 @@ proc net_socket_alloc stdcall uses ebx ecx edx edi rep stosd pop eax + ; add socket to the list by changing pointers mov ebx, net_sockets push [ebx + SOCKET.NextPtr] mov [ebx + SOCKET.NextPtr], eax @@ -156,23 +101,50 @@ proc net_socket_alloc stdcall uses ebx ecx edx edi jz @f mov [ebx + SOCKET.PrevPtr], eax - @@: mov ebx, [TASK_BASE] + @@: ; set socket owner PID to the one of calling process + mov ebx, [TASK_BASE] mov ebx, [ebx + TASKDATA.pid] mov [eax + SOCKET.PID], ebx + ; find first free socket number and use it + ;mov edx, ebx + mov ebx, net_sockets + xor ecx, ecx + .next_socket_number: + inc ecx + .next_socket: + mov ebx, [ebx + SOCKET.NextPtr] + or ebx, ebx + jz .last_socket_number + cmp [ebx + SOCKET.Number], ecx + jne .next_socket + ;cmp [ebx + SOCKET.PID], edx + ;jne .next_socket + mov ebx, net_sockets + jmp .next_socket_number + + .last_socket_number: + mov [eax + SOCKET.Number], ecx + .exit: ret endp -proc net_socket_free stdcall uses ebx ecx edx, sock:DWORD - mov eax, [sock] +;; Free socket data memory and pop socket off the list +; +; @param sockAddr is a socket structure address +;; +proc net_socket_free stdcall uses ebx ecx edx, sockAddr:DWORD + mov eax, [sockAddr] DEBUGF 1, "K : net_socket_free (0x%x)\n", eax + ; check if we got something similar to socket structure address or eax, eax jz .error + ; make sure sockAddr is one of the socket addresses in the list mov ebx, net_sockets - mov ecx, [TASK_BASE] - mov ecx, [ecx + TASKDATA.pid] + ;mov ecx, [TASK_BASE] + ;mov ecx, [ecx + TASKDATA.pid] .next_socket: mov ebx, [ebx + SOCKET.NextPtr] or ebx, ebx @@ -182,6 +154,8 @@ proc net_socket_free stdcall uses ebx ecx edx, sock:DWORD ;cmp [ebx + SOCKET.PID], ecx ;jne .next_socket + ; okay, we found the correct one + ; remove it from the list first, changing pointers mov ebx, [eax + SOCKET.NextPtr] mov eax, [eax + SOCKET.PrevPtr] mov [eax + SOCKET.NextPtr], ebx @@ -199,12 +173,60 @@ proc net_socket_free stdcall uses ebx ecx edx, sock:DWORD ret endp -proc net_socket_num_to_addr stdcall uses ebx ecx, x:DWORD -; FIXME: do real transform - mov eax, [x] +;; Get socket structure address by its number +; Scan through sockets list to find the socket with specified number. +; This proc uses SOCKET.PID indirectly to check if socket is owned by +; calling process. +; +; @param sockNum is a socket number +; @return socket structure address or 0 (not found) in EAX +;; +proc net_socket_num_to_addr stdcall uses ebx ecx, sockNum:DWORD + mov eax, [sockNum] + ; check if we got something similar to socket number + or eax, eax + jz .error + + ; scan through sockets list mov ebx, net_sockets - mov ecx, [TASK_BASE] - mov ecx, [ecx + TASKDATA.pid] + ;mov ecx, [TASK_BASE] + ;mov ecx, [ecx + TASKDATA.pid] + .next_socket: + mov ebx, [ebx + SOCKET.NextPtr] + or ebx, ebx + jz .error + cmp [ebx + SOCKET.Number], eax + jne .next_socket + ;cmp [ebx + SOCKET.PID], ecx + ;jne .next_socket + + ; okay, we found the correct one + mov eax, ebx + ret + + .error: + xor eax, eax + ret +endp + +;; Get socket number by its structure address +; Scan through sockets list to find the socket with specified address. +; This proc uses SOCKET.PID indirectly to check if socket is owned by +; calling process. +; +; @param sockAddr is a socket structure address +; @return socket number (SOCKET.Number) or 0 (not found) in EAX +;; +proc net_socket_addr_to_num stdcall uses ebx ecx, sockAddr:DWORD + mov eax, [sockAddr] + ; check if we got something similar to socket structure address + or eax, eax + jz .error + + ; scan through sockets list + mov ebx, net_sockets + ;mov ecx, [TASK_BASE] + ;mov ecx, [ecx + TASKDATA.pid] .next_socket: mov ebx, [ebx + SOCKET.NextPtr] or ebx, ebx @@ -213,6 +235,9 @@ proc net_socket_num_to_addr stdcall uses ebx ecx, x:DWORD jne .next_socket ;cmp [ebx + SOCKET.PID], ecx ;jne .next_socket + + ; okay, we found the correct one + mov eax, [ebx + SOCKET.Number] ret .error: @@ -220,44 +245,22 @@ proc net_socket_num_to_addr stdcall uses ebx ecx, x:DWORD ret endp -proc net_socket_addr_to_num stdcall uses ebx ecx, x:DWORD -; FIXME: do real transform - mov eax, [x] - mov ebx, net_sockets - mov ecx, [TASK_BASE] - mov ecx, [ecx + TASKDATA.pid] - .next_socket: - mov ebx, [ebx + SOCKET.NextPtr] - or ebx, ebx - jz .error - cmp ebx, eax - jne .next_socket - ;cmp [ebx + SOCKET.PID], ecx - ;jne .next_socket - ret - - .error: - xor eax, eax - ret -endp - -;*************************************************************************** -; Function -; is_localport_unused +;; [53.9] Check if local port is used by any socket in the system. +; Scan through sockets list, checking SOCKET.LocalPort. +; Useful when you want a to generate a unique local port number. +; This proc doesn't guarantee that after calling it and trying to use +; the port reported being free in calls to socket_open/socket_open_tcp it'll +; still be free or otherwise it'll still be used if reported being in use. ; -; Description -; scans through all the active sockets , looking to see if the -; port number specified in bx is in use as a localport number. -; This is useful when you want a to generate a unique local port -; number. -; On return, eax = 1 for free, 0 for in use -; -;*************************************************************************** +; @param BX is a port number +; @return 1 (port is free) or 0 (port is in use) in EAX +;; proc is_localport_unused stdcall xchg bl, bh - xor eax, eax ; Assume the return value is 'free' + ; assume the return value is 'free' + xor eax, eax inc al mov edx, net_sockets @@ -266,27 +269,22 @@ proc is_localport_unused stdcall or edx, edx jz .exit cmp [edx + SOCKET.LocalPort], bx - jne .next_socket ; Return back if the port is not occupied + jne .next_socket - dec al ; return 'in use' + ; return 'in use' + dec al .exit: ret endp - -;*************************************************************************** -; Function -; socket_open +;; [53.0] Open DGRAM socket (connectionless, unreliable) ; -; Description -; find a free socket -; local port in ebx -; remote port in ecx -; remote ip in edx -; return socket # in eax, -1 if none available -; -;*************************************************************************** +; @param BX is local port number +; @param CX is remote port number +; @param EDX is remote IP address +; @return socket number or -1 (error) in EAX +;; proc socket_open stdcall call net_socket_alloc or eax, eax @@ -296,7 +294,6 @@ proc socket_open stdcall push eax - mov [eax + SOCKET.Status], SOCK_OPEN xchg bh, bl mov [eax + SOCKET.LocalPort], bx xchg ch, cl @@ -308,7 +305,7 @@ proc socket_open stdcall ;pop eax ; Get the socket number back, so we can return it stdcall net_socket_addr_to_num - ret + ret .error: DEBUGF 1, "K : socket_open (fail)\n" @@ -316,21 +313,14 @@ proc socket_open stdcall ret endp - -;*************************************************************************** -; Function -; socket_open_tcp +;; [53.5] Open STREAM socket (connection-based, sequenced, reliable, two-way) ; -; Description -; Opens a TCP socket in PASSIVE or ACTIVE mode -; find a free socket -; local port in ebx ( intel format ) -; remote port in ecx ( intel format ) -; remote ip in edx ( in Internet byte order ) -; Socket open mode in esi ( SOCKET_PASSIVE or SOCKET_ACTIVE ) -; return socket # in eax, -1 if none available -; -;*************************************************************************** +; @param BX is local port number +; @param CX is remote port number +; @param EDX is remote IP address +; @param ESI is open mode (SOCKET_ACTIVE, SOCKET_PASSIVE) +; @return socket number or -1 (error) in EAX +;; proc socket_open_tcp stdcall local sockAddr dd ? @@ -369,7 +359,6 @@ local sockAddr dd ? mov [sockAddr], eax ; TODO - check this works! - ;xxx: already 0 (intialized by net_socket_alloc) ;mov [eax + SOCKET.wndsizeTimer], 0 ; Reset the window timer. xchg bh, bl @@ -423,11 +412,9 @@ local sockAddr dd ? call inc_inet_esi .exit: - mov ebx, [sockAddr] - mov [ebx + SOCKET.Status], SOCK_OPEN - ;pop eax ; Get the socket number back, so we can return it - stdcall net_socket_addr_to_num, ebx - ret + ; Get the socket number back, so we can return it + stdcall net_socket_addr_to_num, [sockAddr] + ret .error: DEBUGF 1, "K : socket_open_tcp (fail)\n" @@ -435,35 +422,21 @@ local sockAddr dd ? ret endp - -;*************************************************************************** -; Function -; socket_close +;; [53.1] Close DGRAM socket ; -; Description -; socket # in ebx -; returns 0 for ok, -1 for socket not open (fail) -; -;*************************************************************************** +; @param EBX is socket number +; @return 0 (closed successfully) or -1 (error) in EAX +;; proc socket_close stdcall DEBUGF 1, "K : socket_close (0x%x)\n", ebx stdcall net_socket_num_to_addr, ebx or eax, eax jz .error - cmp [eax + SOCKET.Status], dword SOCK_EMPTY - jz .error - - ; Clear the socket varaibles stdcall net_socket_free, eax -; mov edi, eax -; xor eax, eax -; mov ecx, SOCKETHEADERSIZE -; cld -; rep stosb xor eax, eax - ret + ret .error: DEBUGF 1, "K : socket_close (fail)\n" @@ -471,16 +444,13 @@ proc socket_close stdcall ret endp - -;*************************************************************************** -; Function -; socket_close_tcp +;; [53.8] Close STREAM socket +; Closing TCP sockets takes time, so when you get successful return code +; from this function doesn't always mean that socket is actually closed. ; -; Description -; socket # in ebx -; returns 0 for ok, -1 for socket not open (fail) -; -;*************************************************************************** +; @param EBX is socket number +; @return 0 (closed successfully) or -1 (error) in EAX +;; proc socket_close_tcp stdcall local sockAddr dd ? DEBUGF 1, "K : socket_close_tcp (0x%x)\n", ebx @@ -493,21 +463,19 @@ local sockAddr dd ? .next_resendq: cmp ecx, NUMRESENDENTRIES je .last_resendq ; None left - ;cmp [esi], bl ; XTODO: bl -> ebx cmp [esi + 4], ebx je @f ; found one inc ecx add esi, 8 jmp .next_resendq - ;@@: mov byte[esi], 0xff ; XTODO: 0xff -> 0 @@: mov dword[esi + 4], 0 inc ecx add esi, 8 jmp .next_resendq .last_resendq: - popa + popa stdcall net_socket_num_to_addr, ebx or eax, eax @@ -515,13 +483,11 @@ local sockAddr dd ? mov ebx, eax mov [sockAddr], eax - cmp [ebx + SOCKET.Status], SOCK_EMPTY - je .error - cmp [ebx + SOCKET.TCBState], TCB_LISTEN ;xxx - je .destroy_tcb ;xxx - cmp [ebx + SOCKET.TCBState], TCB_SYN_SENT ;xxx - je .destroy_tcb ;xxx + cmp [ebx + SOCKET.TCBState], TCB_LISTEN + je .destroy_tcb + cmp [ebx + SOCKET.TCBState], TCB_SYN_SENT + je .destroy_tcb ; Now construct the response, and queue for sending by IP mov eax, EMPTY_QUEUE @@ -531,8 +497,7 @@ local sockAddr dd ? push eax -;xxx mov bl, TH_FIN + TH_ACK - mov bl, TH_FIN ;xxx + mov bl, TH_FIN xor ecx, ecx xor esi, esi stdcall build_tcp_packet, [sockAddr] @@ -545,10 +510,6 @@ local sockAddr dd ? ; Get the socket state mov eax, [ebx + SOCKET.TCBState] -;xxx cmp eax, TCB_LISTEN -;xxx je .destroy_tcb -;xxx cmp eax, TCB_SYN_SENT -;xxx je .destroy_tcb cmp eax, TCB_SYN_RECEIVED je .fin_wait_1 cmp eax, TCB_ESTABLISHED @@ -556,7 +517,6 @@ local sockAddr dd ? ; assume CLOSE WAIT ; Send a fin, then enter last-ack state - ; TODO: check if it's really a TCB_CLOSE_WAIT mov [ebx + SOCKET.TCBState], TCB_LAST_ACK jmp .send @@ -580,15 +540,13 @@ local sockAddr dd ? jmp .exit .destroy_tcb: -;xxx pop eax ; Clear the socket variables -;xxx stdcall net_socket_free, [sockAddr] stdcall net_socket_free, ebx .exit: xor eax, eax - ret + ret .error: DEBUGF 1, "K : socket_close_tcp (fail)\n" @@ -596,16 +554,11 @@ local sockAddr dd ? ret endp - -;*************************************************************************** -; Function -; socket_poll +;; [53.2] Poll socket ; -; Description -; socket # in ebx -; returns count in eax. -; -;*************************************************************************** +; @param EBX is socket number +; @return count or bytes in rx buffer or 0 (error) in EAX +;; proc socket_poll stdcall ; DEBUGF 1, "socket_poll(0x%x)\n", ebx stdcall net_socket_num_to_addr, ebx @@ -616,21 +569,15 @@ proc socket_poll stdcall ret .error: - ;or eax, -1 xor eax, eax ret endp - -;*************************************************************************** -; Function -; socket_status +;; [53.6] Get socket TCB state ; -; Description -; socket # in ebx -; returns TCB state in eax. -; -;*************************************************************************** +; @param EBX is socket number +; @return socket TCB state or 0 (error) in EAX +;; proc socket_status stdcall ;; DEBUGF 1, "socket_status(0x%x)\n", ebx stdcall net_socket_num_to_addr, ebx @@ -638,82 +585,84 @@ proc socket_status stdcall jz .error mov eax, [eax + SOCKET.TCBState] - ret + ret .error: - ;or eax, -1 xor eax, eax ret endp -; Index2RealAddr ebx -; mov eax, [ebx + SOCKET.TCBState] +;; [53.3] Get one byte from rx buffer +; This function can return 0 in two cases: if there's one byte read and +; non left, and if an error occured. Behavior should be changed and function +; shouldn't be used for now. Consider using [53.11] instead. ; -; ret - - -;*************************************************************************** -; Function -; socket_read -; -; Description -; socket # in ebx -; returns # of bytes remaining in eax, data in bl -; -;*************************************************************************** +; @param EBX is socket number +; @return number of bytes left in rx buffer or 0 (error) in EAX +; @return byte read in BL +;; proc socket_read stdcall ; DEBUGF 1, "socket_read(0x%x)\n", ebx stdcall net_socket_num_to_addr, ebx or eax, eax jz .error + lea ebx, [eax + SOCKET.lock] + call wait_mutex + mov ebx, eax mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes test eax, eax - jz .error + jz .error_release dec eax mov esi, ebx ; esi is address of socket mov [ebx + SOCKET.rxDataCount], eax ; store new count - ;movzx ebx, byte[ebx + SOCKET.rxData] ; get the byte - movzx ebx, byte[ebx + SOCKETHEADERSIZE] ; get the byte - add esi, SOCKETHEADERSIZE - mov edi, esi - inc esi + movzx eax, byte[ebx + SOCKET.rxData] ; get the byte - mov ecx, (SOCKETBUFFSIZE - SOCKETHEADERSIZE) / 4 - lea edi, [ebx + SOCKETHEADERSIZE] + mov ecx, SOCKETBUFFSIZE - SOCKET.rxData - 1 + lea edi, [esi + SOCKET.rxData] lea esi, [edi + 1] cld + push ecx + shr ecx, 2 rep movsd + pop ecx + and ecx, 3 + rep movsb + + mov [ebx + SOCKET.lock], 0 + mov ebx, eax ret + .error_release: + mov [ebx + SOCKET.lock], 0 .error: - ;or eax, -1 - xor eax, eax xor ebx, ebx ret endp - -;*************************************************************************** -; Function -; socket_read_packet +;; [53.11] Get specified number of bytes from rx buffer +; Number of bytes in rx buffer can be less than requested size. In this case, +; only available number of bytes is read. +; This function can return 0 in two cases: if there's no data to read, and if +; an error occured. Behavior should be changed. ; -; Description -; socket # in ebx -; datapointer # in ecx -; buffer size in edx -; returns # of bytes copied in eax -; -;*************************************************************************** +; @param EBX is socket number +; @param ECX is pointer to application buffer +; @param EDX is application buffer size (number of bytes to read) +; @return number of bytes read or 0 (error) in EAX +;; proc socket_read_packet stdcall ; DEBUGF 1, "socket_read_packet(0x%x)\n", ebx stdcall net_socket_num_to_addr, ebx ; get real socket address or eax, eax jz .error + lea ebx, [eax + SOCKET.lock] + call wait_mutex + mov ebx, eax mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes test eax, eax ; if count of bytes is zero.. @@ -731,7 +680,7 @@ proc socket_read_packet stdcall call .start_copy ; copy to the application mov esi, ebx ; now we're going to copy the remaining bytes to the beginning - add esi, SOCKETHEADERSIZE ; we dont need to copy the header + add esi, SOCKET.rxData ; we dont need to copy the header mov edi, esi ; edi is where we're going to copy to add esi, edx ; esi is from where we copy pop ecx ; count of bytes we have left @@ -744,10 +693,10 @@ proc socket_read_packet stdcall rep movsb ; copy remaining bytes .exit: + mov [ebx + SOCKET.lock], 0 ret ; at last, exit .error: - ;or eax, -1 xor eax, eax ret @@ -755,12 +704,13 @@ proc socket_read_packet stdcall xor esi, esi mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero) call .start_copy + mov [ebx + SOCKET.lock], 0 ret .start_copy: mov edi, ecx mov esi, ebx - add esi, SOCKETHEADERSIZE ; we dont need to copy the header + add esi, SOCKET.rxData ; we dont need to copy the header mov ecx, eax ; eax is count of bytes push ecx shr ecx, 2 ; divide eax by 4 @@ -772,19 +722,13 @@ proc socket_read_packet stdcall retn ; exit, or go back to shift remaining bytes if any endp - -;*************************************************************************** -; Function -; socket_write +;; [53.4] Send data through DGRAM socket ; -; Description -; socket in ebx -; # of bytes to write in ecx -; pointer to data in edx -; returns 0 in eax ok, -1 == failed ( invalid socket, or -; could not queue IP packet ) -; -;*************************************************************************** +; @param EBX is socket number +; @param ECX is application data size (number of bytes to send) +; @param EDX is pointer to application data buffer +; @return 0 (sent successfully) or -1 (error) in EAX +;; proc socket_write stdcall ; DEBUGF 1, "socket_write(0x%x)\n", ebx stdcall net_socket_num_to_addr, ebx ; get real socket address @@ -793,10 +737,6 @@ proc socket_write stdcall mov ebx, eax - ; If the socket is invalid, return with an error code - cmp [ebx + SOCKET.Status], SOCK_EMPTY - je .error - mov eax, EMPTY_QUEUE call dequeue cmp ax, NO_BUFFER @@ -933,26 +873,20 @@ proc socket_write stdcall call queue xor eax, eax - ret + ret .error: or eax, -1 ret endp - -;*************************************************************************** -; Function -; socket_write_tcp +;; [53.7] Send data through STREAM socket ; -; Description -; socket in ebx -; # of bytes to write in ecx -; pointer to data in edx -; returns 0 in eax ok, -1 == failed ( invalid socket, or -; could not queue IP packet ) -; -;*************************************************************************** +; @param EBX is socket number +; @param ECX is application data size (number of bytes to send) +; @param EDX is pointer to application data buffer +; @return 0 (sent successfully) or -1 (error) in EAX +;; proc socket_write_tcp stdcall local sockAddr dd ? @@ -964,12 +898,7 @@ local sockAddr dd ? mov ebx, eax mov [sockAddr], ebx - ; If the socket is invalid, return with an error code - cmp [ebx + SOCKET.Status], SOCK_EMPTY - je .error - ; If the sockets window timer is nonzero, do not queue packet - ; TODO - done cmp [ebx + SOCKET.wndsizeTimer], 0 jne .error @@ -999,8 +928,8 @@ local sockAddr dd ? pop ebx push ecx - mov eax, NET1OUT_QUEUE + mov eax, NET1OUT_QUEUE mov edx, [stack_ip] mov ecx, [sockAddr] cmp edx, [ecx + SOCKET.RemoteIP] @@ -1031,7 +960,6 @@ local sockAddr dd ? .next_resendq: cmp ecx, NUMRESENDENTRIES je .exit ; None found - ;cmp byte[esi], 0xff ; XTODO: 0xff -> 0 cmp dword[esi + 4], 0 je @f ; found one inc ecx @@ -1049,7 +977,6 @@ local sockAddr dd ? ; fill IP buffer associated with this descriptor stdcall net_socket_addr_to_num, [sockAddr] - ;mov [esi], al ; XTODO: al -> eax mov [esi + 4], eax mov byte[esi + 1], TCP_RETRIES mov word[esi + 2], TCP_TIMEOUT @@ -1076,7 +1003,7 @@ local sockAddr dd ? .exit: xor eax, eax - ret + ret .error: or eax, -1 diff --git a/kernel/branches/kolibri_pe/network/stack.inc b/kernel/branches/kolibri_pe/network/stack.inc index f5cd8a1343..63414a2895 100644 --- a/kernel/branches/kolibri_pe/network/stack.inc +++ b/kernel/branches/kolibri_pe/network/stack.inc @@ -1,14 +1,12 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; STACK.INC ;; ;; ;; ;; TCP/IP stack for Menuet OS ;; ;; ;; -;; Version 0.7 4th July 2004 ;; -;; ;; ;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;; ;; ;; ;; See file COPYING for details ;; @@ -46,7 +44,7 @@ endg ; socket buffers SOCKETBUFFSIZE equ 4096 ; state + config + buffer. -SOCKETHEADERSIZE equ 76+8+8 ; thus 4096 - SOCKETHEADERSIZE bytes data +SOCKETHEADERSIZE equ SOCKET.rxData ; thus 4096 - SOCKETHEADERSIZE bytes data ;NUM_SOCKETS equ 16 ; Number of open sockets supported. Was 20 diff --git a/kernel/branches/kolibri_pe/network/tcp.inc b/kernel/branches/kolibri_pe/network/tcp.inc index f27b5ffd04..8c441a9c60 100644 --- a/kernel/branches/kolibri_pe/network/tcp.inc +++ b/kernel/branches/kolibri_pe/network/tcp.inc @@ -1,14 +1,12 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; TCP.INC ;; ;; ;; ;; TCP Processes for Menuet OS TCP/IP stack ;; ;; ;; -;; Version 0.6 4th July 2004 ;; -;; ;; ;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;; ;; ;; ;; See file COPYING for details ;; @@ -118,14 +116,14 @@ proc tcp_tcb_handler stdcall uses ebx cmp [ebx + SOCKET.NextPtr], 0 je .exit - DEBUGF 1, "K : sockets:\n" + ;DEBUGF 1, "K : sockets:\n" .next_socket: mov ebx, [ebx + SOCKET.NextPtr] or ebx, ebx jz .exit - DEBUGF 1, "K : %x: %x-%x-%x-%u\n", ebx, [ebx + SOCKET.LocalPort]:4, [ebx + SOCKET.RemoteIP], [ebx + SOCKET.RemotePort]:4, [ebx + SOCKET.TCBState] + ;DEBUGF 1, "K : %x-%x: %x-%x-%x-%u\n", [ebx + SOCKET.PID]:2, [ebx + SOCKET.Number]:2, [ebx + SOCKET.LocalPort]:4, [ebx + SOCKET.RemoteIP], [ebx + SOCKET.RemotePort]:4, [ebx + SOCKET.TCBState] cmp [ebx + SOCKET.TCBTimer], 0 jne .decrement_tcb @@ -177,7 +175,6 @@ proc tcp_tx_handler stdcall .next_resendq: cmp ecx, NUMRESENDENTRIES je .exit ; None left - ;cmp [esi], byte 0xFF ; XTODO: 0xff -> 0 cmp dword[esi + 4], 0 jne @f ; found one inc ecx @@ -192,7 +189,6 @@ proc tcp_tx_handler stdcall jmp .next_resendq ; Timer not zero, so move on @@: - ;mov bl, 0xff ; XTODO: bl -> ebx, 0xff -> 0 xor ebx, ebx ; restart timer, and decrement retries ; After the first resend, back of on next, by a factor of 5 @@ -201,7 +197,6 @@ proc tcp_tx_handler stdcall jnz @f ; retries now 0, so delete from queue - ;xchg [esi], bl ; XTODO: bl -> ebx xchg [esi + 4], ebx @@: ; resend packet @@ -213,10 +208,8 @@ proc tcp_tx_handler stdcall jne .tth004z ; TODO - try again in 10ms. - ;cmp bl, 0xff ; XTODO: 0xff -> 0 test ebx, ebx jnz @f - ;mov [esi], bl ; XTODO: bl -> ebx mov [esi + 4], ebx @@: ; Mark it to expire in 10ms - 1 tick @@ -316,9 +309,6 @@ proc tcp_rx stdcall uses ebx or ebx, ebx jz .next_socket.1.exit - cmp [ebx + SOCKET.Status], SOCK_OPEN - jne .next_socket.1 - ; DEBUGF 1, "K : tcp_rx - 1.dport: %x - %x\n", [edx + 20 + TCP_PACKET.DestinationPort]:4, [ebx + SOCKET.LocalPort]:4 mov ax, [edx + 20 + TCP_PACKET.DestinationPort] ; get the dest. port from the TCP hdr @@ -355,9 +345,6 @@ proc tcp_rx stdcall uses ebx or ebx, ebx jz .next_socket.2.exit - cmp [ebx + SOCKET.Status], SOCK_OPEN - jne .next_socket.2 - ; DEBUGF 1, "K : tcp_rx - 2.dport: %x - %x\n", [edx + 20 + TCP_PACKET.DestinationPort]:4, [ebx + SOCKET.LocalPort]:4 mov ax, [edx + 20 + TCP_PACKET.DestinationPort] ; get the dest. port from the TCP hdr @@ -393,9 +380,6 @@ proc tcp_rx stdcall uses ebx or ebx, ebx jz .next_socket.3.exit - cmp [ebx + SOCKET.Status], SOCK_OPEN - jne .next_socket.3 - ; DEBUGF 1, "K : tcp_rx - 3.dport: %x - %x\n", [edx + 20 + TCP_PACKET.DestinationPort]:4, [ebx + SOCKET.LocalPort]:4 mov ax, [edx + 20 + TCP_PACKET.DestinationPort] ; get destination port from the TCP hdr @@ -421,16 +405,7 @@ proc tcp_rx stdcall uses ebx DEBUGF 1, "K : tcp_rx - dumped\n" DEBUGF 1, "K : --------: %x-%x-%x (flags: %x)\n", [edx + 20 + TCP_PACKET.DestinationPort]:4, [edx + IP_PACKET.SourceAddress], [edx + 20 + TCP_PACKET.SourcePort]:4, [edx + 20 + TCP_PACKET.Flags]:2 -; mov ebx, net_sockets -; -; .next_socket.4: -; mov ebx, [ebx + SOCKET.NextPtr] -; or ebx, ebx -; jz .next_socket.4.exit -; DEBUGF 1, "K : %x: %x-%x-%x-%u\n", ebx, [ebx + SOCKET.LocalPort]:4, [ebx + SOCKET.RemoteIP], [ebx + SOCKET.RemotePort]:4, [ebx + SOCKET.TCBState] -; jne .next_socket.4 -; -; .next_socket.4.exit: + inc [dumped_rx_count] jmp .exit @@ -661,7 +636,6 @@ proc tcpStateMachine stdcall, sockAddr:DWORD .next_resendq: cmp ecx, NUMRESENDENTRIES je .call_handler ; None left - ;cmp [esi], al ; XTODO: al -> eax cmp [esi + 4], eax je @f ; found one inc ecx @@ -702,7 +676,6 @@ proc tcpStateMachine stdcall, sockAddr:DWORD add esi, 8 jmp .next_resendq - ;@@: mov byte[esi], 0xff ; XTODO: 0xff -> 0 @@: mov dword[esi + 4], 0 inc ecx add esi, 8 @@ -711,7 +684,7 @@ proc tcpStateMachine stdcall, sockAddr:DWORD .call_handler: popad - ; Call handler for given TCB state + ; Call handler for given TCB state mov eax, [ebx + SOCKET.TCBState] cmp eax, TCB_LISTEN @@ -852,16 +825,16 @@ proc stateTCB_SYN_RECEIVED stdcall, sockAddr:DWORD ; For now, if the packet is an ACK, process it, ; If not, ignore it - test [edx + 20 + TCP_PACKET.Flags], TH_RST ;xxx - jz .check_ack ;xxx + test [edx + 20 + TCP_PACKET.Flags], TH_RST + jz .check_ack push [ebx + SOCKET.OrigRemotePort] [ebx + SOCKET.OrigRemoteIP] pop [ebx + SOCKET.RemoteIP] [ebx + SOCKET.RemotePort] - mov [ebx + SOCKET.TCBState], TCB_LISTEN ;xxx - jmp .exit ;xxx + mov [ebx + SOCKET.TCBState], TCB_LISTEN + jmp .exit - .check_ack: ;xxx + .check_ack: ; Look at control flags - expecting an ACK test [edx + 20 + TCP_PACKET.Flags], TH_ACK jz .exit @@ -878,10 +851,8 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD ; OR both... ; Did we receive a FIN or RST? -;xxx test [edx + 20 + TCP_PACKET.Flags], TH_FIN + TH_RST -;xxx jz .check_ack - test [edx + 20 + TCP_PACKET.Flags], TH_FIN ;xxx - jz .check_ack ;xxx + test [edx + 20 + TCP_PACKET.Flags], TH_FIN + jz .check_ack ; It was a fin or reset. @@ -897,14 +868,12 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD .next_resendq: cmp ecx, NUMRESENDENTRIES je .last_resendq ; None left - ;cmp [esi], al ; XTODO: al -> eax cmp [esi + 4], eax je @f ; found one inc ecx add esi, 8 jmp .next_resendq - ;@@: mov byte[esi], 0xff ; XTODO: 0xff -> 0 @@: mov dword[esi + 4], 0 inc ecx add esi, 8 @@ -913,13 +882,6 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD .last_resendq: popad -;xxx ; was it a reset? -;xxx test [edx + 20 + TCP_PACKET.Flags], TH_RST -;xxx jz @f - -;xxx mov [ebx + SOCKET.TCBState], TCB_CLOSED -;xxx jmp .exit - @@: ; Send an ACK to that fin, and enter closewait state mov [ebx + SOCKET.TCBState], TCB_CLOSE_WAIT @@ -966,7 +928,7 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD movzx ecx, [edx + IP_PACKET.TotalLength] xchg cl, ch sub ecx, 40 ; Discard 40 bytes of header - jnz .data ; Read data, if any + ja .data ; Read data, if any ; If we had received a fin, we need to ACK it. cmp [ebx + SOCKET.TCBState], TCB_CLOSE_WAIT @@ -974,14 +936,19 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD jmp .exit .data: - push ecx + push ebx + add ebx, SOCKET.lock + call wait_mutex + pop ebx - add [ebx + SOCKET.rxDataCount], ecx ; increment the count of bytes in buffer + push ecx + push [ebx + SOCKET.PID] ; get socket owner PID + mov eax, [ebx + SOCKET.rxDataCount] + add eax, ecx + cmp eax, SOCKETBUFFSIZE - SOCKETHEADERSIZE + ja .overflow - mov eax, [ebx + SOCKET.PID] ; get socket owner PID - push eax - - mov eax, [ebx + SOCKET.rxDataCount] ; get # of bytes already in buffer + mov [ebx + SOCKET.rxDataCount], eax ; increment the count of bytes in buffer ; point to the location to store the data lea edi, [ebx + eax + SOCKETHEADERSIZE] @@ -992,6 +959,7 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD cld rep movsb ; copy the data across + mov [ebx + SOCKET.lock], 0 ; release mutex ; flag an event to the application pop eax @@ -1046,11 +1014,17 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD .exit: ret + .overflow: + ; no place in buffer + ; so simply restore stack and exit + pop eax ecx + mov [ebx + SOCKET.lock], 0 + ret endp proc stateTCB_FIN_WAIT_1 stdcall, sockAddr:DWORD - ; We can either receive an ACK of a fin, or a fin + ; We can either receive an ACK of a fin, or a fin mov al, [edx + 20 + TCP_PACKET.Flags] and al, TH_FIN + TH_ACK @@ -1167,11 +1141,6 @@ proc stateTCB_LAST_ACK stdcall, sockAddr:DWORD ; delete the socket stdcall net_socket_free, ebx -; mov edi, ebx -; xor eax, eax -; mov ecx, SOCKETHEADERSIZE -; cld -; rep stosb .exit: ret diff --git a/kernel/branches/kolibri_pe/network/udp.inc b/kernel/branches/kolibri_pe/network/udp.inc index b0939df3b3..2a842afecb 100644 --- a/kernel/branches/kolibri_pe/network/udp.inc +++ b/kernel/branches/kolibri_pe/network/udp.inc @@ -1,10 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; ;; @@ -12,8 +8,6 @@ ;; ;; ;; UDP Processes for Menuet OS TCP/IP stack ;; ;; ;; -;; Version 0.3 29 August 2002 ;; -;; ;; ;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;; ;; ;; ;; See file COPYING for details ;; @@ -102,7 +96,7 @@ proc udp_rx stdcall je @f mov eax, [edx + IP_PACKET.SourceAddress] ; get the Source address from the IP packet - cmp [ebx + SOCKET.RemoteIP], ebx + cmp [ebx + SOCKET.RemoteIP], eax jne .exit ; Quit if the source IP is not valid @@: ; OK - we have a valid UDP packet for this socket. diff --git a/kernel/branches/kolibri_pe/sound/playnote.inc b/kernel/branches/kolibri_pe/sound/playnote.inc index 6cc0d3c269..b4204f1db2 100644 --- a/kernel/branches/kolibri_pe/sound/playnote.inc +++ b/kernel/branches/kolibri_pe/sound/playnote.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; PLAYNOTE.INC version 1.1 22 November 2003 ;; diff --git a/kernel/branches/kolibri_pe/video/cursors.inc b/kernel/branches/kolibri_pe/video/cursors.inc index 9176a21ef3..8fc6157eb8 100644 --- a/kernel/branches/kolibri_pe/video/cursors.inc +++ b/kernel/branches/kolibri_pe/video/cursors.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -489,7 +489,6 @@ proc init_cursors cmp ebx, 32 jne @F - mov dword [select_hw_cursor], select_cursor mov dword [set_hw_cursor], cursor_32 mov dword [hw_restore], restore_32 @@ -642,7 +641,6 @@ proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword lodsd test eax, 0xFF000000 jz @F - mov [edi], ax shr eax, 16 mov [edi+2], al @@ -656,6 +654,7 @@ proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword ret endp + align 4 proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword locals @@ -756,6 +755,7 @@ proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword ret endp + align 4 def_arrow: file 'arrow.cur' diff --git a/kernel/branches/kolibri_pe/video/vesa12.inc b/kernel/branches/kolibri_pe/video/vesa12.inc index 0904f7458f..dceb46b8c2 100644 --- a/kernel/branches/kolibri_pe/video/vesa12.inc +++ b/kernel/branches/kolibri_pe/video/vesa12.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; VESA12.INC ;; @@ -884,6 +884,8 @@ vesa12_putimage: add esi,[esp+32] cmp ebp,putimage_get1bpp jz .correct + cmp ebp,putimage_get2bpp + jz .correct cmp ebp,putimage_get4bpp jnz @f .correct: @@ -957,6 +959,8 @@ vesa12_putimage: add edi,[BytesPerScanLine] cmp ebp,putimage_get1bpp jz .correct + cmp ebp,putimage_get2bpp + jz .correct cmp ebp,putimage_get4bpp jnz @f .correct: diff --git a/kernel/branches/kolibri_pe/video/vesa20.inc b/kernel/branches/kolibri_pe/video/vesa20.inc index 43a9b37f83..90f4463196 100644 --- a/kernel/branches/kolibri_pe/video/vesa20.inc +++ b/kernel/branches/kolibri_pe/video/vesa20.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; VESA20.INC ;; @@ -239,6 +239,8 @@ end if ; inc ebp cmp [putimg.ebp], putimage_get1bpp jz .correct + cmp [putimg.ebp], putimage_get2bpp + jz .correct cmp [putimg.ebp], putimage_get4bpp jnz @f .correct: @@ -283,6 +285,8 @@ end if ; inc ebp cmp [putimg.ebp], putimage_get1bpp jz .correct + cmp [putimg.ebp], putimage_get2bpp + jz .correct cmp [putimg.ebp], putimage_get4bpp jnz @f .correct: