From f59df34e1723485eb0fc06a111dd611ac5e8f5b9 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Fri, 22 Jul 2011 18:08:47 +0000 Subject: [PATCH] merge trunk git-svn-id: svn://kolibrios.org@2010 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../branches/Kolibri-acpi/blkdev/cd_drv.inc | 8 +- .../branches/Kolibri-acpi/blkdev/hd_drv.inc | 19 + .../branches/Kolibri-acpi/boot/bootcode.inc | 181 +++- kernel/branches/Kolibri-acpi/boot/booteng.inc | 12 + kernel/branches/Kolibri-acpi/boot/bootet.inc | 12 + kernel/branches/Kolibri-acpi/boot/bootge.inc | 12 + kernel/branches/Kolibri-acpi/boot/bootru.inc | 12 + .../branches/Kolibri-acpi/boot/bootvesa.inc | 35 + kernel/branches/Kolibri-acpi/boot/parsers.inc | 170 ++++ kernel/branches/Kolibri-acpi/boot/preboot.inc | 3 + .../branches/Kolibri-acpi/boot/shutdown.inc | 5 +- .../Kolibri-acpi/bootloader/boot_fat12.asm | 18 +- .../branches/Kolibri-acpi/bus/pci/pci32.inc | 6 +- kernel/branches/Kolibri-acpi/const.inc | 8 +- kernel/branches/Kolibri-acpi/core/apic.inc | 38 +- kernel/branches/Kolibri-acpi/core/dll.inc | 27 +- kernel/branches/Kolibri-acpi/core/exports.inc | 6 + kernel/branches/Kolibri-acpi/core/memory.inc | 2 +- kernel/branches/Kolibri-acpi/core/peload.inc | 4 +- kernel/branches/Kolibri-acpi/core/sys32.inc | 14 +- kernel/branches/Kolibri-acpi/core/syscall.inc | 1 + kernel/branches/Kolibri-acpi/core/taskman.inc | 10 + kernel/branches/Kolibri-acpi/data16.inc | 35 + kernel/branches/Kolibri-acpi/data32.inc | 20 +- .../branches/Kolibri-acpi/docs/sysfuncr.txt | 275 ++---- .../branches/Kolibri-acpi/docs/sysfuncs.txt | 323 +++---- .../branches/Kolibri-acpi/drivers/imports.inc | 4 +- .../Kolibri-acpi/drivers/infinity.asm | 329 ++++--- kernel/branches/Kolibri-acpi/drivers/main.inc | 31 +- .../branches/Kolibri-acpi/drivers/mixer.asm | 8 +- .../Kolibri-acpi/drivers/sb16/sb16.asm | 4 +- .../Kolibri-acpi/drivers/sceletone.asm | 4 - .../branches/Kolibri-acpi/drivers/sound.asm | 91 +- kernel/branches/Kolibri-acpi/fs/iso9660.inc | 2 + kernel/branches/Kolibri-acpi/hid/keyboard.inc | 40 +- kernel/branches/Kolibri-acpi/hid/mousedrv.inc | 15 +- kernel/branches/Kolibri-acpi/kernel.asm | 37 +- kernel/branches/Kolibri-acpi/kernel32.inc | 5 +- .../network/eth_drv/drivers/r6040.inc | 813 ++++++++++++++++++ .../network/eth_drv/drivers/rtl8139.inc | 8 +- .../Kolibri-acpi/network/eth_drv/ethernet.inc | 129 ++- .../branches/Kolibri-acpi/video/blitter.inc | 444 ++++++++++ 42 files changed, 2527 insertions(+), 693 deletions(-) create mode 100644 kernel/branches/Kolibri-acpi/boot/parsers.inc create mode 100644 kernel/branches/Kolibri-acpi/network/eth_drv/drivers/r6040.inc create mode 100644 kernel/branches/Kolibri-acpi/video/blitter.inc diff --git a/kernel/branches/Kolibri-acpi/blkdev/cd_drv.inc b/kernel/branches/Kolibri-acpi/blkdev/cd_drv.inc index 38f7c90684..bcc184d528 100644 --- a/kernel/branches/Kolibri-acpi/blkdev/cd_drv.inc +++ b/kernel/branches/Kolibri-acpi/blkdev/cd_drv.inc @@ -239,10 +239,10 @@ SendPacketDatCommand: in AL,DX test AL,80h ;ёюёЄю эшх ёшуэрыр BSY jnz @@WaitDevice0 - test AL,08h ;ёюёЄю эшх ёшуэрыр DRQ - jz @@WaitDevice0 test AL,1 ;ёюёЄю эшх ёшуэрыр ERR jnz @@Err6 + test AL,08h ;ёюёЄю эшх ёшуэрыр DRQ + jz @@WaitDevice0 ; ╧юёырЄ№ яръхЄэє■ ъюьрэфє cli mov DX,[ATABasePortAddr] @@ -282,10 +282,10 @@ SendPacketDatCommand: in AL,DX test AL,80h ;ёюёЄю эшх ёшуэрыр BSY jnz @@WaitDevice1 - test AL,08h ;ёюёЄю эшх ёшуэрыр DRQ - jz @@WaitDevice1 test AL,1 ;ёюёЄю эшх ёшуэрыр ERR jnz @@Err6_temp + test AL,08h ;ёюёЄю эшх ёшуэрыр DRQ + jz @@WaitDevice1 ; ╧Ёшэ Є№ сыюъ фрээ√ї юЄ ъюэЄЁюыыхЁр mov EDI,[CDDataBuf_pointer] ;0x7000 ;CDDataBuf ; ╟руЁєчшЄ№ рфЁхё ЁхушёЄЁр фрээ√ї ъюэЄЁюыыхЁр diff --git a/kernel/branches/Kolibri-acpi/blkdev/hd_drv.inc b/kernel/branches/Kolibri-acpi/blkdev/hd_drv.inc index 3bd0c0b9fe..ab5af9362a 100644 --- a/kernel/branches/Kolibri-acpi/blkdev/hd_drv.inc +++ b/kernel/branches/Kolibri-acpi/blkdev/hd_drv.inc @@ -49,6 +49,12 @@ hd_read: ; Read through BIOS? cmp [hdpos], 0x80 jae .bios +; hd_read_{dma,pio} use old ATA with 28 bit for sector number + cmp eax, 0x10000000 + jb @f + inc [hd_error] + jmp return_01 +@@: ; DMA read is permitted if [allow_dma_access]=1 or 2 cmp [allow_dma_access], 2 ja .nodma @@ -235,6 +241,8 @@ hd_write: align 4 cache_write_pio: + cmp dword[esi],0x10000000 + jae .bad ; call disable_ide_int call wait_for_hd_idle @@ -295,6 +303,9 @@ cache_write_pio: pop esi ecx ret +.bad: + inc [hd_error] + ret save_hd_wait_timeout: @@ -686,6 +697,9 @@ write_cache_sector: write_cache_chain: cmp [hdpos], 0x80 jae bd_write_cache_chain + mov eax,[cache_chain_ptr] + cmp dword[eax],0x10000000 + jae .bad push esi mov eax, IDE_descriptor_table mov edx,eax @@ -779,6 +793,9 @@ write_cache_chain: jnz hd_write_error_dma pop esi ret +.bad: + inc [hd_error] + ret uglobal IDEContrRegsBaseAddr dw ? @@ -916,7 +933,9 @@ int13_call: mov [ebx+v86_regs.eflags], 20200h mov esi, [sys_v86_machine] mov ecx, 0x502 + push fs call v86_start + pop fs and [bios_hdpos], 0 pop edi esi ecx ebx movzx edx, byte [OS_BASE + 512h] diff --git a/kernel/branches/Kolibri-acpi/boot/bootcode.inc b/kernel/branches/Kolibri-acpi/boot/bootcode.inc index 4cb0dd3d9d..7b5ad14f9d 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootcode.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootcode.inc @@ -91,6 +91,7 @@ boot_read_floppy: inc si cmp si, 10 jb @b +sayerr_badsect: mov si, badsect sayerr_plain: call printplain @@ -145,8 +146,119 @@ FirstDataSector dw 0 ; begin of data ;========================================================================= include 'bootvesa.inc' ;Include source for boot vesa +if defined extended_primary_loader +include 'parsers.inc' +end if start_of_code: + +if defined extended_primary_loader +; save data from primary loader + mov word [cs:bootcallback], si + mov word [cs:bootcallback+2], ds + push cs + pop ds + mov [bootdevice], ax + mov [bootfs], bx + +; set up stack + mov ax, 3000h + mov ss, ax + mov sp, 0EC00h + +; try to load configuration file + mov ax, 1 + mov di, config_file_struct + call [bootcallback] + cld + push cs + pop es +; bx=0 - ok, bx=1 - part of file loaded, assume this is ok + cmp bx, 1 + ja .config_bad +; configuration file was loaded, parse +; if length is too big, use first 0FFFFh bytes + test dx, dx + jz @f + mov ax, 0FFFFh +@@: +; ds:si will be pointer to current data, dx = limit + xchg ax, dx + push 4000h + pop ds + xor si, si +.parse_loop: +; skip spaces + cmp si, dx + jae .parse_done + lodsb + cmp al, ' ' + jbe .parse_loop + dec si +; loop over all possible configuration values + mov bx, config_file_variables +.find_variant: +; get length + mov cx, [es:bx] +; zero length = end of list + jecxz .find_newline +; skip over length + inc bx + inc bx + mov di, bx +; skip over string + add bx, cx +; test whether we have at least cx symbols left + mov ax, cx + add ax, si + jc .next_variant1 + cmp ax, dx + jae .next_variant1 +; save current position + push si +; compare strings + repz cmpsb + jnz .next_variant2 +; strings are equal; look for "=" with possible spaces before and after +@@: + cmp si, dx + jae .next_variant2 + lodsb + cmp al, ' ' + jbe @b + cmp al, '=' + jnz .next_variant2 +; ok, we found the true variant +; ignore saved position on the stack + pop ax +; call the parser + call word [es:bx] +; line parsed, find next +.find_newline: + cmp si, dx + jae .parse_done + lodsb + cmp al, 13 + jz .parse_loop + cmp al, 10 + jz .parse_loop + jmp .find_newline +.next_variant2: +; continue to the next variant, restoring current position + pop si +.next_variant1: +; continue to the next variant +; skip over the parser + inc bx + inc bx + jmp .find_variant +.parse_done: +.config_bad: + +; set up segment registers + push cs + pop ds +else cld ; \begin{diamond}[02.12.2005] ; if bootloader sets ax = 'KL', then ds:si points to loader block @@ -175,6 +287,7 @@ no_hd_load: pop ds push cs pop es +end if ; set videomode mov ax, 3 @@ -378,6 +491,7 @@ wait_loop: ; variant 2 apm_end: _setcursor d80x25_top_num, 0 +if ~ defined extended_primary_loader ;CHECK current of code cmp [cfgmanager.loader_block], -1 jz noloaderblock @@ -387,6 +501,7 @@ apm_end: jnz sayerr push 0 pop es +end if noloaderblock: ; DISPLAY VESA INFORMATION @@ -404,7 +519,9 @@ cfgmanager: ; d) preboot_device = from what boot? ; determine default settings +if ~ defined extended_primary_loader mov [.bSettingsChanged], 0 +end if ;.preboot_gr_end: mov di, preboot_device @@ -412,6 +529,12 @@ cfgmanager: ; set it to use this preloaded image cmp byte [di], 0 jnz .preboot_device_inited +if defined extended_primary_loader + inc byte [di] + cmp byte [bootdevice], 'f' ; floppy? + jz .preboot_device_inited + inc byte [di] +else cmp [.loader_block], -1 jz @f les bx, [.loader_block] @@ -422,6 +545,7 @@ cfgmanager: @@: ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) mov byte [di], 1 +end if .preboot_device_inited: ; following 4 lines set variables to 1 if its current value is 0 cmp byte [di+preboot_dma-preboot_device], 1 @@ -466,7 +590,11 @@ cfgmanager: mov si, preboot_device_msg call print mov al, [preboot_device] +if defined extended_primary_loader + and eax, 3 +else and eax, 7 +end if mov si, [preboot_device_msgs+eax*2] call printplain .show_remarks: @@ -553,12 +681,18 @@ cfgmanager: _setcursor 15,0 mov si, bdev call print +if defined extended_primary_loader + mov bx, '12' +else mov bx, '14' +end if call getkey mov [preboot_device], al _setcursor 13,0 .d: +if ~ defined extended_primary_loader mov [.bSettingsChanged], 1 +end if call clear_vmodes_table ;clear vmodes_table jmp .printcfg .change_a: @@ -672,10 +806,14 @@ cfgmanager: virtual at novesa .oldtimer dd ? .starttime dd ? +if ~ defined extended_primary_loader .bSettingsChanged db ? +end if .timer dd ? end virtual +if ~ defined extended_primary_loader .loader_block dd -1 +end if .gettime: mov ah, 0 int 1Ah @@ -692,7 +830,11 @@ end virtual pushad call .gettime sub eax, [.starttime] +if defined extended_primary_loader + sub ax, [preboot_timeout] +else sub ax, 18*5 +end if jae .timergo neg ax add ax, 18-1 @@ -748,6 +890,7 @@ end if mov si, loading_msg call print _setcursor 15,0 +if ~ defined extended_primary_loader cmp [.bSettingsChanged], 0 jz .load cmp [.loader_block], -1 @@ -788,6 +931,7 @@ end if call printplain _setcursor 15,0 .load: +end if ; \end{diamond}[02.12.2005] ; ASK GRAPHICS MODE @@ -816,7 +960,7 @@ end if mov [boot_dev], al ; GET MEMORY MAP -include 'detect/biosmem.inc' +include '../detect/biosmem.inc' ; READ DISKETTE TO MEMORY @@ -967,6 +1111,7 @@ sayerr_floppy: mov dx, 0x3f2 mov al, 0 out dx, al +sayerr_memmove: mov si, memmovefailed jmp sayerr_plain @@: @@ -1145,6 +1290,40 @@ no_sys_on_floppy: mov al, 0 out dx, al +if defined extended_primary_loader + cmp [boot_dev], 1 + jne no_sys_from_primary +; load kolibri.img using callback from primary loader + and word [movedesc + 24 + 2], 0 + mov byte [movedesc + 24 + 4], 10h +; read in blocks of 64K until file is fully loaded + mov ax, 1 +.repeat: + mov di, image_file_struct + call [bootcallback] + push cs + pop ds + push cs + pop es + cmp bx, 1 + ja sayerr_badsect + push bx + mov si, movedesc + and word [si + 16 + 2], 0 + mov byte [si + 16 + 4], 4 + mov ah, 87h + mov cx, 8000h + int 15h + pop bx + test ah, ah + jnz sayerr_memmove + inc byte [si + 24 + 4] + test bx, bx + jz no_sys_from_primary + mov ax, 2 + jmp .repeat +no_sys_from_primary: +end if ; SET GRAPHICS diff --git a/kernel/branches/Kolibri-acpi/boot/booteng.inc b/kernel/branches/Kolibri-acpi/boot/booteng.inc index 4c14a2d2e3..833cdacdda 100644 --- a/kernel/branches/Kolibri-acpi/boot/booteng.inc +++ b/kernel/branches/Kolibri-acpi/boot/booteng.inc @@ -40,11 +40,15 @@ vrrmprint db "Apply VRR? (picture frequency greater than 60Hz" ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0 +if defined extended_primary_loader bdev db "Load ramdisk from [1-floppy; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "3-use preloaded ram-image from kernel restart;" db 13,10,186," " db "4-create blank image]: ",0 +else +bdev db "Load ramdisk from [1-floppy; 2-kolibri.img]: ",0 +end if probetext db 13,10,13,10,186," Use standart graphics mode? [1-yes, " db "2-probe bios (Vesa 3.0)]: ",0 ;memokz256 db 13,10,186," RAM 256 Mb",0 @@ -88,14 +92,22 @@ off_msg db " off",13,10,0 ;readonly_msg db " only for reading",13,10,0 vrrm_msg db " [c] Use VRR:",0 preboot_device_msg db " [d] Floppy image: ",0 +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "real floppy",13,10,0 +pdm2 db "C:\kolibri.img (FAT32)",13,10,0 +else preboot_device_msgs dw 0,pdm1,pdm2,pdm3 pdm1 db "real floppy",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm3 db "use already loaded image",13,10,0 pdm4 db "create blank image",13,10,0 +end if loading_msg db "Loading KolibriOS...",0 +if ~ defined extended_primary_loader save_quest db "Remember current settings? [y/n]: ",0 loader_block_error db "Bootloader data invalid, I cannot continue. Stopped.",0 +end if _st db 186,' ┌───────────────────────────────┬─┐',13,10,0 _r1 db 186,' │ 320x200 EGA/CGA 256 colors │ │',13,10,0 diff --git a/kernel/branches/Kolibri-acpi/boot/bootet.inc b/kernel/branches/Kolibri-acpi/boot/bootet.inc index 414efdf381..532b6841b2 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootet.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootet.inc @@ -50,11 +50,15 @@ ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no ;mem_model db 13,10,186," Motherboard memory [1-16 Mb / 2-32 Mb / " ; db "3-64Mb / 4-128 Mb / 5-256 Mb] ? ",0 ;bootlog db 13,10,186," After bootlog display [1-continue/2-pause] ? ",0 +if defined extended_primary_loader +bdev db "Paigalda mфluketas [1-diskett; 2-kolibri.img]: ",0 +else bdev db "Paigalda mфluketas [1-diskett; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "3-kasuta eellaaditud mфluketast kerneli restardist;" db 13,10,186," " db "4-loo t№hi pilt]: ",0 +end if probetext db 13,10,13,10,186," Kasuta standartset graafika reziimi? [1-jah, " db "2-leia biosist (Vesa 3.0)]: ",0 ;memokz256 db 13,10,186," RAM 256 Mb",0 @@ -99,14 +103,22 @@ off_msg db " v ;readonly_msg db " ainult lugemiseks",13,10,0 vrrm_msg db " [c] Kasuta VRR:",0 preboot_device_msg db " [d] Disketi kujutis: ",0 +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "reaalne diskett",13,10,0 +pdm2 db "kolibri.img",13,10,0 +else preboot_device_msgs dw 0,pdm1,pdm2,pdm3 pdm1 db "reaalne diskett",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm3 db "kasuta juba laaditud kujutist",13,10,0 pdm4 db "loo t№hi pilt",13,10,0 +end if loading_msg db "Laadin KolibriOS...",0 +if ~ defined extended_primary_loader save_quest db "Jфta meelde praegused seaded? [y/n]: ",0 loader_block_error db "Alglaaduri andmed vigased, ei saa jфtkata. Peatatud.",0 +end if remark1 db "Default values were selected to match most of configurations, but not all.",0 remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0 diff --git a/kernel/branches/Kolibri-acpi/boot/bootge.inc b/kernel/branches/Kolibri-acpi/boot/bootge.inc index 2ea4959f19..93d24f0f13 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootge.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootge.inc @@ -55,11 +55,15 @@ ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no ;mem_model db 13,10,186," Hauptspeicher [1-16 Mb / 2-32 Mb / " ; db "3-64Mb / 4-128 Mb / 5-256 Mb] ? ",0 ;bootlog db 13,10,186," After bootlog display [1-continue/2-pause] ? ",0 +if defined extended_primary_loader +bdev db "Lade die Ramdisk von [1-Diskette; 2-kolibri.img]: ",0 +else bdev db "Lade die Ramdisk von [1-Diskette; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "3-benutze ein bereits geladenes Kernel image;" db 13,10,186," " db "4-create blank image]: ",0 +end if probetext db 13,10,13,10,186," Nutze Standardgrafikmodi? [1-ja, " db "2-BIOS Test (Vesa 3.0)]: ",0 ;memokz256 db 13,10,186," RAM 256 Mb",0 @@ -104,14 +108,22 @@ off_msg db " aus",13,10,0 ;readonly_msg db " fur Lesen",13,10,0 vrrm_msg db " [c] Nutze VRR:",0 preboot_device_msg db " [d] Diskettenimage: ",0 +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "Echte Diskette",13,10,0 +pdm2 db "kolibri.img",13,10,0 +else preboot_device_msgs dw 0,pdm1,pdm2,pdm3 pdm1 db "Echte Diskette",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm3 db "Nutze bereits geladenes Image",13,10,0 pdm4 db "create blank image",13,10,0 +end if loading_msg db "Lade KolibriOS...",0 +if ~ defined extended_primary_loader save_quest db "Aktuelle Einstellungen speichern? [y/n]: ",0 loader_block_error db "Bootloader Daten ungueltig, Kann nicht fortfahren. Angehalten.",0 +end if remark1 db "Default values were selected to match most of configurations, but not all.",0 remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0 diff --git a/kernel/branches/Kolibri-acpi/boot/bootru.inc b/kernel/branches/Kolibri-acpi/boot/bootru.inc index 4e85269a6a..548a71912e 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootru.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootru.inc @@ -33,11 +33,15 @@ vrrmprint db " db 186," 1024*768>800*600 и 800*600>640*480) [1-да, 2-нет]: ",0 ;ask_dma db "Использовать DMA для доступа к HDD? [1-да, 2-только чтение, 3-нет]: ",0 ask_bd db "Добавить диски, видимые через BIOS в режиме V86? [1-да, 2-нет]: ",0 +if defined extended_primary_loader +bdev db "Загрузить образ из [1-дискета; 2-kolibri.img из папки загрузки]: ",0 +else bdev db "Загрузить образ из [1-дискета; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "3-использовать уже загруженный образ;" db 13,10,186," " db "4-создать чистый образ]: ",0 +end if prnotfnd db "Ошибка - Видеорежим не найден.",0 not386 db "Ошибка - Требуется процессор 386+.",0 fatalsel db "Ошибка - Выбранный видеорежим не поддерживается.",0 @@ -67,14 +71,22 @@ off_msg db " readonly_msg db " только чтение",13,10,0 vrrm_msg db " [c] Использование VRR:",0 preboot_device_msg db " [d] Образ дискеты: ",0 +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "настоящая дискета",13,10,0 +pdm2 db "kolibri.img из папки загрузки",13,10,0 +else preboot_device_msgs dw 0,pdm1,pdm2,pdm3,pdm4 pdm1 db "настоящая дискета",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm3 db "использовать уже загруженный образ",13,10,0 pdm4 db "создать чистый образ",13,10,0 +end if loading_msg db "Идёт загрузка KolibriOS...",0 +if ~ defined extended_primary_loader ; saving not supported in this case save_quest db "Запомнить текущие настройки? [y/n]: ",0 loader_block_error db "Ошибка в данных начального загрузчика, продолжение невозможно.",0 +end if _st db 186,' ┌───────────────────────────────┬─┐ ',13,10,0 diff --git a/kernel/branches/Kolibri-acpi/boot/bootvesa.inc b/kernel/branches/Kolibri-acpi/boot/bootvesa.inc index aaef71888b..16e856e5b2 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootvesa.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootvesa.inc @@ -314,7 +314,11 @@ draw_current_vmode: cmp word [es:si+6],0x13 je .no_vesa_0x13 +if defined extended_primary_loader + mov di,config_file_variables +else mov di,loader_block_error +end if movzx eax,word[es:si+0] mov ecx,10 call int2strnz @@ -327,7 +331,11 @@ draw_current_vmode: movzx eax,word[es:si+8] call int2strnz mov dword[es:di],0x00000d0a +if defined extended_primary_loader + mov si,config_file_variables +else mov si,loader_block_error +end if push ds push es pop ds @@ -344,9 +352,34 @@ draw_current_vmode: ret ;----------------------------------------------------------------------------- check_first_parm: +if defined extended_primary_loader + mov cx, [number_vm] + jcxz .novbemode + mov si, modes_table +.findvbemode: + cmp [es:si+6], cx + jnz @f + cmp word [es:si+8],32 + je .ok_found_mode + cmp word [es:si+8],24 + je .ok_found_mode +@@: add si,size_of_step + cmp word [es:si],-1 + jnz .findvbemode +.novbemode: + mov ax, [x_save] + test ax, ax + jz .zerro + mov bx, [y_save] + mov si, modes_table + call .loops + test ax, ax + jz .ok_found_mode +else mov si,word [preboot_graph] test si,si jnz .no_zero ;if no zero +end if .zerro: ; mov ax,modes_table ; mov word [cursor_pos],ax @@ -374,6 +407,7 @@ check_first_parm: jz .ok_found_mode mov si,modes_table +if ~ defined extended_primary_loader jmp .ok_found_mode @@ -394,6 +428,7 @@ check_first_parm: ; jb .zerro ;check on correct if bellow ; cmp ax,word [end_cursor] ; ja .zerro ;check on correct if anymore +end if .ok_found_mode: mov word [home_cursor],si diff --git a/kernel/branches/Kolibri-acpi/boot/parsers.inc b/kernel/branches/Kolibri-acpi/boot/parsers.inc new file mode 100644 index 0000000000..ea29218e7f --- /dev/null +++ b/kernel/branches/Kolibri-acpi/boot/parsers.inc @@ -0,0 +1,170 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +$Revision: 1962 $ + +; All parsers are called with ds:si -> value of the variable, +; possibly with spaces before, and dx = limit of config file. + +; Three subroutines parse_char, parse_number and parse_bool set CF +; if something has failed, otherwise return the value in al/ax. + +parse_timeout: +; timeout is a number not greater than 9 + call parse_number + jc .nothing + cmp ax, 9 + jbe @f + mov ax, 9 +@@: + imul ax, 18 + mov [es:preboot_timeout], ax +.nothing: + ret + +parse_resolution: +; resolution is *, 'x' can be used instead of '*' +; parse width + call parse_number + jc .nothing +; save width + xchg ax, bx +; test for 'x' or '*' + call parse_char + cmp al, 'x' + jz @f + cmp al, '*' + jnz .nothing +@@: +; parse height + call parse_number + jc .nothing +; write width and height + mov [es:x_save], bx + mov [es:y_save], ax +.nothing: + ret + +parse_vbemode: +; vbemode is a number + call parse_number + jc .nothing + mov [es:number_vm], ax +.nothing: + ret + +parse_vrr: +; vrr is a boolean setting + call parse_bool + jc .nothing +; convert 0 to 2, 1 to 1 + inc ax + xor al, 3 + mov [es:preboot_vrrm], al +.nothing: + ret + +parse_biosdisks: +; using biosdisks is a boolean setting + call parse_bool + jc .nothing +; convert 0 to 2, 1 to 1 + inc ax + xor al, 3 + mov [es:preboot_biosdisk], al +.nothing: + ret + +parse_imgfrom: +; boot device (1-floppy 2-kolibri.img using primary loader) + call parse_number + jc .nothing + cmp al, 1 + jb .nothing + cmp al, 2 + ja .nothing + mov [es:preboot_device], al +.nothing: + ret + +parse_char: +; skip spaces and return the next character or CF if EOF. + cmp si, dx + jae .eof + lodsb + cmp al, ' ' + jbe parse_char + ret +.eof: + stc + ret + +parse_number: +; initialize high part of ax to zero + xor ax, ax +; skip spaces + call parse_char + jc .bad +; al should be a digit + sub al, '0' + cmp al, 9 + ja .bad +; accumulate the value in cx + xchg cx, ax +@@: + cmp si, dx + jae .eof + lodsb + sub al, '0' + cmp al, 9 + ja .end + imul cx, 10 + add cx, ax + jmp @b +; if the end is caused by non-digit, unwind the last character +.end: + dec si +.eof: + xchg cx, ax + clc + ret +.bad: + stc + ret + +parse_bool: +; skip spaces + call parse_char + jc .bad +; Boolean false can be represented as 0=no=off, +; boolean true can be represented as 1=yes=on. + cmp al, '0' + jz .false + cmp al, '1' + jz .true + mov ah, al + cmp si, dx + jae .bad + lodsb + cmp ax, 'n'*256 + 'o' + jz .false + cmp ax, 'o'*256 + 'f' + jz .false + cmp ax, 'y'*256 + 'e' + jz .true + cmp ax, 'o'*256 + 'n' + jz .true +.bad: + stc + ret +.true: + xor ax, ax + inc ax + ret +.false: + xor ax, ax + ret diff --git a/kernel/branches/Kolibri-acpi/boot/preboot.inc b/kernel/branches/Kolibri-acpi/boot/preboot.inc index 036ba51c18..04b3d2da8a 100644 --- a/kernel/branches/Kolibri-acpi/boot/preboot.inc +++ b/kernel/branches/Kolibri-acpi/boot/preboot.inc @@ -30,6 +30,9 @@ preboot_device db 0 ; boot device ;!!!! 0 - autodetect !!!! preboot_blogesc = 0 ; start immediately after bootlog preboot_biosdisk db 0 ; use V86 to access disks through BIOS (1-yes, 2-no) +if defined extended_primary_loader +preboot_timeout dw 5*18 ; timeout in 1/18th of second for config settings screen +end if if $>0x200 ERROR: prebooting parameters must fit in first sector!!! diff --git a/kernel/branches/Kolibri-acpi/boot/shutdown.inc b/kernel/branches/Kolibri-acpi/boot/shutdown.inc index 3e3679cafd..1fbed56b8a 100644 --- a/kernel/branches/Kolibri-acpi/boot/shutdown.inc +++ b/kernel/branches/Kolibri-acpi/boot/shutdown.inc @@ -98,8 +98,10 @@ nbw32: jmp $ no_apm_off: +if ~ defined extended_primary_loader ; kernel restarting is not supported dec ax ; 3 = reboot jnz restart_kernel ; 4 = restart kernel +end if push 0x40 pop ds mov word[0x0072],0x1234 @@ -150,6 +152,7 @@ APM_PowerOff: ;!!!!!!!!!!!!!!!!!!!!!!!! ret +if ~ defined extended_primary_loader restart_kernel: mov ax,0x0003 ; set text mode for screen @@ -205,5 +208,5 @@ restart_kernel_4000: mov si, kernel_restart_bootblock mov ax, 'KL' jmp 0x1000:0000 - +end if diff --git a/kernel/branches/Kolibri-acpi/bootloader/boot_fat12.asm b/kernel/branches/Kolibri-acpi/bootloader/boot_fat12.asm index 1c01e8e97d..9f31e383b1 100644 --- a/kernel/branches/Kolibri-acpi/bootloader/boot_fat12.asm +++ b/kernel/branches/Kolibri-acpi/bootloader/boot_fat12.asm @@ -194,17 +194,17 @@ obtain_cluster: mov ax,0e2eh ; ah=0eh (teletype), al='.' xor bh,bh int 10h - - ; convert cluster number to sector number - mov ax,bp ; data cluster to read - sub ax,2 - xor bx,bx - mov bl,byte [BPB_SecPerClus+boot_program] - mul bx - add ax,word [data_start+boot_program] pop bx writesec: + ; convert cluster number to sector number + mov ax,bp ; data cluster to read + sub ax,2 + xor dx,dx + mov dl,byte [BPB_SecPerClus+boot_program] + mul dx + add ax,word [data_start+boot_program] + call conv_abs_to_THS ; convert abs sector (AX) to BIOS T:H:S (track:head:sector) patchhere: mov ah,2 ; ah=2 (read) @@ -267,7 +267,7 @@ write1st: push cs pop ds mov byte [patchhere+1+boot_program], 3 ; change ah=2 to ah=3 - mov ax,[cluster1st+boot_program] + mov bp,[cluster1st+boot_program] push 1000h pop es xor bx,bx diff --git a/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc b/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc index d639c89c4b..e67afcea92 100644 --- a/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc +++ b/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc @@ -569,9 +569,9 @@ sys_pcibios: cmp ebp, 1 ; PCI_FUNCTION_ID jnz .not_PCI_BIOS_PRESENT mov edx, 'PCI ' - mov al, [OS_BASE+0x2F0000 + 0x9020] - mov bx, [OS_BASE+0x2F0000 + 0x9022] - mov cl, [OS_BASE+0x2F0000 + 0x9021] + mov al, [BOOT_VAR + 0x9020] + mov bx, [BOOT_VAR + 0x9022] + mov cl, [BOOT_VAR + 0x9021] xor ah, ah jmp .return_abcd diff --git a/kernel/branches/Kolibri-acpi/const.inc b/kernel/branches/Kolibri-acpi/const.inc index b6f4a6590c..731bea00ff 100644 --- a/kernel/branches/Kolibri-acpi/const.inc +++ b/kernel/branches/Kolibri-acpi/const.inc @@ -203,6 +203,9 @@ WIN_STACK equ (OS_BASE+0x000C000) WIN_POS equ (OS_BASE+0x000C400) FDD_BUFF equ (OS_BASE+0x000D000) +;unused ? only one reference +ENABLE_TASKSWITCH equ (OS_BASE+0x000E000) + PUTPIXEL equ (OS_BASE+0x000E020) GETPIXEL equ (OS_BASE+0x000E024) @@ -283,6 +286,7 @@ RAMDISK equ (OS_BASE+0x0100000) RAMDISK_FAT equ (OS_BASE+0x0280000) FLOPPY_FAT equ (OS_BASE+0x0282000) +CLEAN_ZONE equ 0x284000 IDE_DMA equ 0x284000 BgrAuxTable equ (OS_BASE+0x0298000) @@ -308,7 +312,9 @@ BgrDrawMode equ (OS_BASE+0x033BFF4) BgrDataWidth equ (OS_BASE+0x033BFF8) BgrDataHeight equ (OS_BASE+0x033BFFC) -sys_pgmap equ (OS_BASE+0x033C000) +BOOT_VAR equ (OS_BASE+0x0340000) + +sys_pgmap equ (OS_BASE+0x0350000) UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000) diff --git a/kernel/branches/Kolibri-acpi/core/apic.inc b/kernel/branches/Kolibri-acpi/core/apic.inc index fb901d04e6..996bb84cf0 100644 --- a/kernel/branches/Kolibri-acpi/core/apic.inc +++ b/kernel/branches/Kolibri-acpi/core/apic.inc @@ -8,7 +8,7 @@ IRQ_RESERVE = 24 ; 16 or 24 iglobal -IRQ_COUNT dd 16 +IRQ_COUNT dd 24 endg uglobal @@ -45,18 +45,18 @@ IOAPIC_REDTBL equ 0x10 APIC_init: mov dword[APIC], 0 ; jmp .no_apic ; NO APIC - bt [cpu_caps], CAPS_APIC - jnc .no_apic +; bt [cpu_caps], CAPS_APIC +; jnc .no_apic ; Check for MP table ;..... - + call IRQ_mask_all - + ; IOAPIC init ; 0xfec00000 - may be relocated, see chip reference... & MP table stdcall map_io_mem, 0xfec00000, 0x20, PG_SW mov [IOAPIC_base], eax - + mov eax, IOAPIC_VER call IOAPIC_read shr eax, 16 @@ -94,12 +94,18 @@ APIC_init: jb @b call LAPIC_init - + mov dword[APIC], 0xffffffff + + mov al, 0x70 + out 0x22, al + mov al, 1 + out 0x23, al + ; mov dword[irq_type_to_set], IRQ_TYPE_APIC .no_apic: ret - + ;=========================================================== align 4 LAPIC_init: @@ -109,24 +115,24 @@ LAPIC_init: mov ecx, 0x1b rdmsr ; it may be replaced to and ax, 0xf000 ; mov eax, 0xfee00000 - + stdcall map_io_mem, eax, 0x1000, PG_SW mov [LAPIC_BASE], eax mov esi, eax - + ; Program Destination Format Register for Flat mode. mov eax, [esi + APIC_DFR] or eax, 0xf0000000 mov [esi + APIC_DFR], eax - - + + ; Program Logical Destination Register. mov eax, [esi + APIC_LDR] ;and eax, 0xff000000 and eax, 0x00ffffff or eax, 0x01000000 ;!!!!!!!!!!!! mov [esi + APIC_LDR], eax - + ; Task Priority Register initialization. mov eax, [esi + APIC_TPR] and eax, 0xffffff00 @@ -163,7 +169,7 @@ LAPIC_init: mov eax, [esi + APIC_LVT_err] or eax, 0x10000 ; bit 16 mov [esi + APIC_LVT_err], eax - + ; LAPIC timer ; pre init mov dword[esi + APIC_timer_div], 1011b ; 1 @@ -175,11 +181,11 @@ LAPIC_init: mov eax, [esi + APIC_timer_cur] ; read current tick couner xor eax, 0xffffffff ; eax = 0xffffffff - eax shr eax, 6 ; eax /= 64; APIC ticks per 0.01 sec - + ; Start (every 0.01 sec) mov dword[esi + APIC_LVT_timer], 0x30020 ; periodic int 0x20 mov dword[esi + APIC_timer_init], eax - + ret ;=========================================================== ; IOAPIC implementation diff --git a/kernel/branches/Kolibri-acpi/core/dll.inc b/kernel/branches/Kolibri-acpi/core/dll.inc index a4d2ee3737..9b04c2fcd3 100644 --- a/kernel/branches/Kolibri-acpi/core/dll.inc +++ b/kernel/branches/Kolibri-acpi/core/dll.inc @@ -17,6 +17,9 @@ PID_KERNEL equ 1 ;os_idle thread align 4 proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword + pushfd + cli + push ebx mov ebx, [irq] ;irq num @@ -46,10 +49,12 @@ proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword stdcall enable_irq, [irq] pop ebx mov eax, 1 + popfd ret .err: pop ebx xor eax, eax + popfd ret endp @@ -100,7 +105,7 @@ align 4 jmp .main } -irq_serv_h 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12 +irq_serv_h 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15 ; I don`t known how to use IRQ_RESERVE if IRQ_RESERVE > 16 @@ -118,6 +123,26 @@ align 16 cmp [v86_irqhooks+eax*8], 0 jnz v86_irq + cmp al, 6 + jnz @f + push eax + call [fdc_irq_func] + pop eax +@@: + + cmp al, 14 + jnz @f + push eax + call [irq14_func] + pop eax +@@: + cmp al, 15 + jnz @f + push eax + call [irq15_func] + pop eax +@@: + mov ebx, [irq_tab+eax*4] test ebx, ebx jz .exit diff --git a/kernel/branches/Kolibri-acpi/core/exports.inc b/kernel/branches/Kolibri-acpi/core/exports.inc index b2c6a06de2..ebcd6ca845 100644 --- a/kernel/branches/Kolibri-acpi/core/exports.inc +++ b/kernel/branches/Kolibri-acpi/core/exports.inc @@ -75,6 +75,9 @@ iglobal szSleep db 'Sleep',0 szGetTimerTicks db 'GetTimerTicks',0 + szGetDisplay db 'GetDisplay',0 + szSetScreen db 'SetScreen',0 + szStrncat db 'strncat',0 szStrncpy db 'strncpy',0 szstrncmp db 'strncmp',0 @@ -147,6 +150,9 @@ kernel_export: dd szSleep , delay_ms dd szGetTimerTicks , get_timer_ticks + dd szGetDisplay , get_display + dd szSetScreen , set_screen + dd szStrncat , strncat dd szStrncpy , strncpy dd szstrncmp , strncmp diff --git a/kernel/branches/Kolibri-acpi/core/memory.inc b/kernel/branches/Kolibri-acpi/core/memory.inc index 6eb3bd331a..79dc7406f8 100644 --- a/kernel/branches/Kolibri-acpi/core/memory.inc +++ b/kernel/branches/Kolibri-acpi/core/memory.inc @@ -1426,7 +1426,7 @@ proc set_mtrr stdcall, base:dword,size:dword,mem_type:dword mov ebx, [size] dec ebx mov eax, 0xFFFFFFFF - mov edx, 0x0000000F + mov edx, 0x00000000 sub eax, ebx sbb edx, 0 or eax, 0x800 diff --git a/kernel/branches/Kolibri-acpi/core/peload.inc b/kernel/branches/Kolibri-acpi/core/peload.inc index 85fede96b6..809926d93f 100644 --- a/kernel/branches/Kolibri-acpi/core/peload.inc +++ b/kernel/branches/Kolibri-acpi/core/peload.inc @@ -322,8 +322,10 @@ __exports: unmap_pages, 'UnmapPages', \ ; eax, ecx sys_msg_board_str, 'SysMsgBoardStr', \ get_timer_ticks, 'GetTimerTicks', \ + get_stack_base, 'GetStackBase', \ delay_hs, 'Delay', \ ; ebx - set_mouse_data, 'SetMouseData' + set_mouse_data, 'SetMouseData', \ ; + set_keyboard_data, 'SetKeyboardData' ; gcc fastcall diff --git a/kernel/branches/Kolibri-acpi/core/sys32.inc b/kernel/branches/Kolibri-acpi/core/sys32.inc index ecb16188c3..0f38c608c2 100644 --- a/kernel/branches/Kolibri-acpi/core/sys32.inc +++ b/kernel/branches/Kolibri-acpi/core/sys32.inc @@ -46,11 +46,9 @@ iglobal else dd p_irq3, p_irq4 ;??? эхёЄ√ъютър end if - dd irq_serv.irq_5, p_irq6, irq_serv.irq_7 + dd irq_serv.irq_5, irq_serv.irq_6, irq_serv.irq_7 dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 - dd irq_serv.irq_11, irq_serv.irq_12 - dd irq13 - dd p_irq14,p_irq15 + dd irq_serv.irq_11, irq_serv.irq_12, irqD, irq_serv.irq_14, irq_serv.irq_15 ; I don`t known how to use IRQ_RESERVE if IRQ_RESERVE > 16 dd irq_serv.irq_16 @@ -208,6 +206,14 @@ unknown_interrupt: ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; bl - error vector show_error_parameters: + cmp bl, 0x06 + jnz .no_ud + push ebx + mov ebx, ud_user_message + mov ebp, notifyapp + call fs_execute_from_sysdir_param + pop ebx +.no_ud: mov edx,[TASK_BASE] ;not scratched below DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] cmp bl, 0x08 diff --git a/kernel/branches/Kolibri-acpi/core/syscall.inc b/kernel/branches/Kolibri-acpi/core/syscall.inc index 2966c3d2bd..c7bea7beac 100644 --- a/kernel/branches/Kolibri-acpi/core/syscall.inc +++ b/kernel/branches/Kolibri-acpi/core/syscall.inc @@ -193,6 +193,7 @@ iglobal dd file_system_lfn ; 70-Common file system interface, version 2 dd syscall_window_settings ; 71-Window settings dd sys_sendwindowmsg ; 72-Send window message + dd blit_32 ; blitter; times 255 - ( ($-servetable2) /4 ) dd undefined_syscall dd sys_end ; -1-end application diff --git a/kernel/branches/Kolibri-acpi/core/taskman.inc b/kernel/branches/Kolibri-acpi/core/taskman.inc index 02a35f70f2..49ca4631f3 100644 --- a/kernel/branches/Kolibri-acpi/core/taskman.inc +++ b/kernel/branches/Kolibri-acpi/core/taskman.inc @@ -48,6 +48,7 @@ macro _clear_ op fs_execute_from_sysdir: xor ebx, ebx +fs_execute_from_sysdir_param: xor edx, edx mov esi, sysdir_path @@ -1166,4 +1167,13 @@ proc set_app_params stdcall,slot:dword, params:dword,\ ret endp + +align 4 + +get_stack_base: + mov eax,[current_slot] + mov eax,[eax+APPDATA.pl0_stack] + ret + + include "debug.inc" diff --git a/kernel/branches/Kolibri-acpi/data16.inc b/kernel/branches/Kolibri-acpi/data16.inc index e6e2e1348d..4fbed262ea 100644 --- a/kernel/branches/Kolibri-acpi/data16.inc +++ b/kernel/branches/Kolibri-acpi/data16.inc @@ -22,10 +22,12 @@ old_ints_h: dd 0 dw 0 +if ~ defined extended_primary_loader ; restart from memory is not supported in extended primary loader cfg kernel_restart_bootblock: db 1 ; version dw 1 ; floppy image is in memory dd 0 ; cannot save parameters +end if ; table for move to extended memory (int 15h, ah=87h) align 8 @@ -53,3 +55,36 @@ fwmovedesc: db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 +if defined extended_primary_loader +; look in PrimaryLoader.txt for the description +bootdevice dw 0 ; ax from primary loader +bootfs dw 0 ; bx from primary loader +bootcallback dd 0 ; ds:si from primary loader +; data for configuration file loading, look in PrimaryLoader.txt +config_file_struct: + dw 0, 4000h ; load to 4000:0000 + dw 16 ; read no more than 16*4K = 64K + db 'config.ini',0 +; data for configuration file parsing +macro config_variable string,parser +{ +local len +len dw 0 + db string +store word $ - len - 2 at len + dw parser +} +config_file_variables: + config_variable 'timeout', parse_timeout + config_variable 'resolution', parse_resolution + config_variable 'vbemode', parse_vbemode + config_variable 'vrr', parse_vrr + config_variable 'biosdisks', parse_biosdisks + config_variable 'imgfrom', parse_imgfrom + dw 0 +; data for image file loading, look in PrimaryLoader.txt +image_file_struct: + dw 0, 4000h ; load to 4000:0000 + dw 16 ; read no more than 16*4K = 64K + db 'kolibri.img',0 +end if diff --git a/kernel/branches/Kolibri-acpi/data32.inc b/kernel/branches/Kolibri-acpi/data32.inc index 1eee040298..e89f2c1946 100644 --- a/kernel/branches/Kolibri-acpi/data32.inc +++ b/kernel/branches/Kolibri-acpi/data32.inc @@ -55,15 +55,15 @@ keymap_alt: boot_bgr db 'Calculating background',0 boot_resirqports db 'Reserving IRQs & ports',0 boot_setostask db 'Setting OS task',0 - boot_allirqs db 'Unmasking IRQs',0 + boot_allirqs db 'Unmasking 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 - boot_APIC_found db 'APIC enabled', 0 - boot_APIC_nfound db 'APIC not found', 0 - + boot_APIC_found db 'APIC enabled', 0 + boot_APIC_nfound db 'APIC not found', 0 + if preboot_blogesc boot_tasking db 'All set - press ESC to start',0 end if @@ -98,6 +98,12 @@ szIMPORTS db 'IMPORTS',0 read_firstapp db '/sys/' firstapp db 'LAUNCHER',0 +notifyapp db '@notify',0 +if lang eq ru +ud_user_message db 'Ошибка: неподдерживаемая инструкция процессора',0 +else +ud_user_message db 'Error: unsupported processor instruction',0 +end if char db '/sys/FONTS/CHAR.MT',0 char2 db '/sys/FONTS/CHAR2.MT',0 @@ -259,10 +265,10 @@ cur_saved_data rb 4096 fpu_data: rb 512 ; device irq owners -irq_owner rd IRQ_RESERVE ; process id +irq_owner rd IRQ_RESERVE ; process id ; on irq read ports -irq00read rd 16 * IRQ_RESERVE -irq_tab rd IRQ_RESERVE +irq00read rd 16 * IRQ_RESERVE +irq_tab rd IRQ_RESERVE mem_block_map rb 512 mem_block_list rd 64 diff --git a/kernel/branches/Kolibri-acpi/docs/sysfuncr.txt b/kernel/branches/Kolibri-acpi/docs/sysfuncr.txt index a29435d407..b7d8e8dfaf 100644 --- a/kernel/branches/Kolibri-acpi/docs/sysfuncr.txt +++ b/kernel/branches/Kolibri-acpi/docs/sysfuncr.txt @@ -1,4 +1,4 @@ -СИСТЕМНЫЕ ФУНКЦИИ ОПЕРАЦИОННОЙ СИСТЕМЫ Kolibri 0.7.5.0+ +СИСТЕМНЫЕ ФУНКЦИИ ОПЕРАЦИОННОЙ СИСТЕМЫ Kolibri 0.7.7.0 Номер функции помещается в регистр eax. Вызов системной функции осуществляется командой "int 0x40". @@ -41,7 +41,7 @@ * esi = 0xXYRRGGBB - цвет заголовка * RR, GG, BB определяют сам цвет * Y=0 - обычное окно, Y=1 - неперемещаемое окно - * X определяет градиент заголовка: X=0 - нет градиента, + * X определяет градиент заголовка: X=0 - нет градиента, X=8 - обычный градиент, для окон типа II X=4 - негативный градиент * прочие значения X и Y зарезервированы @@ -354,6 +354,7 @@ * бит 0 (маска 1): окно максимизировано * бит 1 (маска 2): окно минимизировано в панель задач * бит 2 (маска 4): окно свёрнуто в заголовок + * +71 = +0x47: dword: маска событий Замечания: * Слоты нумеруются с 1. * Возвращаемое значение не есть общее число потоков, поскольку @@ -383,7 +384,7 @@ собственно работу, и времени простоя в ожидании прерывания (которое можно получить вызовом подфункции 4 функции 18). * Начиная со слота 2, размещаются обычные приложения. - * Обычные приложения размещаются в памяти по адресу 0x0 + * Обычные приложения размещаются в памяти по адресу 0 (константа ядра std_application_base_address). Наложения не происходит, поскольку у каждого процесса своя таблица страниц. @@ -665,7 +666,7 @@ * Узнать, какое окно является активным, можно вызовом подфункции 7. ====================================================================== - Функция 18, подфункция 4 - получить счётчик пустых тактов в секунду. + Функция 18, подфункция 4 - получить счётчик пустых тактов в секунду. ====================================================================== Под пустыми тактами понимается время, в которое процессор простаивает в ожидании прерывания (в инструкции hlt). @@ -686,7 +687,7 @@ * eax = тактовая частота (по модулю 2^32 тактов = 4ГГц) ====================================================================== - Функция 18, подфункция 6 - сохранить рамдиск в файл на жёстком диске. + Функция 18, подфункция 6 - сохранить рамдиск в файл на жёстком диске. ====================================================================== Параметры: * eax = 18 - номер функции @@ -766,7 +767,7 @@ Замечания: * Минимизированное окно с точки зрения функции 9 сохраняет положение и размеры. - * Восстановление окна приложения происходит при активизировании + * Восстановление окна приложения происходит при активизировании подфункцией 3. * Обычно нет необходимости явно сворачивать/разворачивать своё окно: сворачивание окна осуществляется системой при нажатии на кнопку @@ -847,12 +848,12 @@ * функция не возвращает значения Структура буфера: db a,b,c,d для версии a.b.c.d -db UID_xxx: одно из UID_NONE=0, UID_MENUET=1, UID_KOLIBRI=2 +db 0: зарезервировано dd REV - номер svn-ревизии ядра -Для ядра Kolibri 0.7.1.0: -db 0,7,1,0 -db 2 -dd 638 +Для ядра Kolibri 0.7.7.0+: +db 0,7,7,0 +db 0 +dd 1675 ====================================================================== ====================== Функция 18, подфункция 14 ===================== @@ -1029,7 +1030,7 @@ dd 638 * иначе eax = номер слота ====================================================================== - Функция 18, подфункция 22 - операции с окном другого процесса/потока. + Функция 18, подфункция 22 - операции с окном другого процесса/потока. ====================================================================== Параметры: * eax = 18 - номер функции @@ -1066,7 +1067,7 @@ dd 638 * eax = 0 - успешно * eax = 1 - не определён базовый порт Замечания: - * Предварительно должен быть определён базовый порт вызовом + * Предварительно должен быть определён базовый порт вызовом подфункции 1 функции 21. ====================================================================== @@ -1082,7 +1083,7 @@ dd 638 Замечания: * Номер порта должен удовлетворять условиям 0x100<=ecx<=0xFFFF. * Установка базы нужна для работы функции 20. - * Получить установленный базовый порт можно вызовом + * Получить установленный базовый порт можно вызовом подфункции 1 функции 26. ====================================================================== @@ -1112,7 +1113,7 @@ dd 638 нормальная раскладка, после чего из кода вычитается 0x60; если не нажата ни одна из управляющих клавиш, то используется нормальная раскладка. - * Получить раскладки и идентификатор страны можно с помощью + * Получить раскладки и идентификатор страны можно с помощью подфункции 2 функции 26. * Идентификатор страны - глобальная системная переменная, которая самим ядром не используется; однако приложение @panel отображает @@ -1130,7 +1131,7 @@ dd 638 * eax = 0 Замечания: * База CD используется функцией 24. - * Получить установленную базу CD можно вызовом + * Получить установленную базу CD можно вызовом подфункции 3 функции 26. ====================================================================== @@ -1168,7 +1169,7 @@ dd 638 * Не следует изменять базу, когда какое-нибудь приложение работает с жёстким диском. Если не хотите глюков системы. * Получить установленную базу можно вызовом подфункции 7 функции 26. - * Следует также определить используемый раздел жёсткого диска + * Следует также определить используемый раздел жёсткого диска подфункцией 8. ====================================================================== @@ -1191,9 +1192,9 @@ dd 638 * Получить установленный раздел можно вызовом подфункции 8 функции 26. * Проверок на корректность не делается. - * Узнать число разделов на жёстком диске можно вызовом + * Узнать число разделов на жёстком диске можно вызовом подфункции 11 функции 18. - * Следует также определить используемую базу жёсткого диска + * Следует также определить используемую базу жёсткого диска подфункцией 7. ====================================================================== @@ -1279,13 +1280,13 @@ dd 638 * ebx = частота вертикальной развёртки (в Гц) * ecx = номер текущего видеорежима Замечания: - * Драйвер предварительно должен быть инициализирован вызовом + * Драйвер предварительно должен быть инициализирован вызовом функции драйвера 1. * Если нужны только размеры экрана, целесообразней использовать функцию 14 с учётом того, что она возвращает размеры на 1 меньше. ====================================================================== -= Функция 21, подфункция 13, подподфункция 3 - установить видеорежим. += Функция 21, подфункция 13, подподфункция 3 - установить видеорежим. ====================================================================== Параметры: * eax = 21 - номер функции @@ -1298,7 +1299,7 @@ dd 638 * eax = 0 - успешно * ebx, ecx разрушаются Замечания: - * Драйвер предварительно должен быть инициализирован вызовом + * Драйвер предварительно должен быть инициализирован вызовом функции драйвера 1. * Номер видеорежима и частота должны быть в таблице, возвращаемой функцией драйвера 1. @@ -1317,7 +1318,7 @@ dd 638 * eax = 0 - успешно * ebx, ecx разрушаются Замечания: - * Драйвер предварительно должен быть инициализирован вызовом + * Драйвер предварительно должен быть инициализирован вызовом функции драйвера 1. ====================================================================== @@ -1337,7 +1338,7 @@ dd 638 * eax = 0 - успешно * ebx, ecx разрушаются Замечания: - * Драйвер предварительно должен быть инициализирован вызовом + * Драйвер предварительно должен быть инициализирован вызовом функции драйвера 1. * Функция влияет только на физический размер изображения на мониторе; логический размер (число пикселей) не меняется. @@ -1418,7 +1419,7 @@ dd 638 * eax = 0 - успешно * eax = 1 - не определена база CD Замечания: - * Предварительно нужно определить базовый порт CD вызовом + * Предварительно нужно определить базовый порт CD вызовом подфункции 3 функции 21. * В секунде 75 фреймов, в минуте 60 секунд. * Функция асинхронна (возвращает управление, когда началось @@ -1439,7 +1440,7 @@ dd 638 * Формат таблицы с информацией о дорожках такой же, как и для ATAPI-CD команды 43h (READ TOC), обычной таблицы (подкоманда 00h). Адреса возвращаются в формате MSF. - * Предварительно нужно определить базовый порт CD вызовом + * Предварительно нужно определить базовый порт CD вызовом подфункции 3 функции 21. * Функция возвращает информацию только о не более чем 100 первых дорожках. В большинстве случаев этого достаточно. @@ -1454,7 +1455,7 @@ dd 638 * eax = 0 - успешно * eax = 1 - не определена база CD Замечания: - * Предварительно нужно определить базовый порт CD вызовом + * Предварительно нужно определить базовый порт CD вызовом подфункции 3 функции 21. ====================================================================== @@ -1498,7 +1499,7 @@ dd 638 Возвращаемое значение: * eax = номер порта Замечания: - * Установить базовый порт можно вызовом + * Установить базовый порт можно вызовом подфункции 1 функции 21. ====================================================================== @@ -1531,7 +1532,7 @@ dd 638 нормальная раскладка, после чего из кода вычитается 0x60; если не нажата ни одна из управляющих клавиш, то используется нормальная раскладка. - * Установить раскладки и идентификатор страны можно с помощью + * Установить раскладки и идентификатор страны можно с помощью подфункции 2 функции 21. * Идентификатор страны - глобальная системная переменная, которая самим ядром не используется; однако приложение @panel отображает @@ -1626,7 +1627,7 @@ dd 638 * eax = 0/1 - запрещён/разрешён Замечания: * Используется при LBA-чтении (подфункция 8 функции 58). - * Установить текущее состояние можно вызовом + * Установить текущее состояние можно вызовом подфункции 11 функции 21. ====================================================================== @@ -1641,7 +1642,7 @@ dd 638 Замечания: * Используется при работе с шиной PCI (функция 62). * Текущая реализация использует только младший бит ecx. - * Установить текущее состояние можно вызовом + * Установить текущее состояние можно вызовом подфункции 12 функции 21. ====================================================================== @@ -1677,62 +1678,14 @@ dd 638 * ecx = указатель на буфер * edx = размер буфера Возвращаемое значение: - * eax = - 1 ощибка, папка текущего потока имеет длинну более чем 4096 символов. * eax = длина имени текущей папки (включая завершающий 0) Замечания: * Если размера буфера недостаточно для копирования всего имени, - копируются только первые (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-строка). - * Эта функция не поддерживает папок на рамдиске. + копируются только первые (edx-1) байт и в конце ставится + завершающий 0. + * По умолчанию, текущая папка для потока - "/rd/1". + * При создании процесса/потока текущая папка наследуется от + родителя. ====================================================================== ============ Функция 35 - прочитать цвет точки на экране. ============ @@ -1858,7 +1811,7 @@ dd 638 ------------------ Подфункция 7 - данные прокрутки ------------------- Параметры: * eax = 37 - номер функции - * ebx = 6 - номер подфункции + * ebx = 7 - номер подфункции Возвращаемое значение: * eax = [horizontal offset]*65536 + [vertical offset] Замечания: @@ -1893,7 +1846,7 @@ dd 638 Возвращаемое значение: * eax = [ширина]*65536 + [высота] Замечания: - * Есть парная команда установки размеров фонового изображения - + * Есть парная команда установки размеров фонового изображения - подфункция 1 функции 15. После которой, разумеется, следует заново определить само изображение. @@ -1912,7 +1865,7 @@ dd 638 * Не следует полагаться на возвращаемое значение в случае неверного смещения, оно может измениться в следующих версиях ядра. * Смещение точки с координатами (x,y) вычисляется как (x+y*xsize)*3. - * Есть парная функция установки точки на фоновом изображении - + * Есть парная функция установки точки на фоновом изображении - подфункция 2 функции 15. ====================================================================== @@ -1925,7 +1878,7 @@ dd 638 * eax = 1 - замостить * eax = 2 - растянуть Замечания: - * Есть парная функция установки режима отрисовки фона - + * Есть парная функция установки режима отрисовки фона - подфункция 4 функции 15. ====================================================================== @@ -2068,7 +2021,7 @@ dd 638 все зарезервированные им IRQ. ====================================================================== -= Функция 46 - зарезервировать/освободить группу портов ввода/вывода. += Функция 46 - зарезервировать/освободить группу портов ввода/вывода. ====================================================================== К зарезервированным портам можно обращаться напрямую из приложения командами in/out (рекомендуемый способ) и вызовом функции 43 @@ -2163,7 +2116,7 @@ dd 638 Возвращаемое значение: * функция не возвращает значения Замечания: - * После вызова описываемой функции следует перерисовать экран + * После вызова описываемой функции следует перерисовать экран подфункцией 0. * Тип кнопок влияет только на их прорисовку функцией 8. @@ -2180,7 +2133,7 @@ dd 638 Возвращаемое значение: * функция не возвращает значения Замечания: - * После вызова описываемой функции следует перерисовать экран + * После вызова описываемой функции следует перерисовать экран подфункцией 0. * Таблица стандартных цветов влияет только на приложения, которые эту таблицу явным образом получают (подфункцией 3) и @@ -2219,11 +2172,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] ; читаем цвет текста + ; на кнопке в рабочей области * Использование/неиспользование этих цветов - дело исключительно самой программы. Для использования нужно просто при вызове функций рисования указывать цвет, взятый из этой таблицы. @@ -2294,7 +2247,7 @@ dword- Аналогично по оси y. * Смотри также функцию 14, позволяющую определить размеры всего экрана. - * Есть парная функция получения рабочей области - + * Есть парная функция получения рабочей области - подфункция 5. * Эта функция автоматически перерисовывает экран, по ходу дела обновляет координаты и размеры максимизированных окон. @@ -2418,7 +2371,7 @@ dword- * иначе eax = TID - идентификатор потока ====================================================================== -= Функция 52, подфункция 0 - получить конфигурацию сетевого драйвера. += Функция 52, подфункция 0 - получить конфигурацию сетевого драйвера. ====================================================================== Параметры: * eax = 52 - номер функции @@ -2443,7 +2396,7 @@ dword- * Локальный IP-адрес устанавливается подфункцией 3. ====================================================================== - Функция 52, подфункция 2 - установить конфигурацию сетевого драйвера. + Функция 52, подфункция 2 - установить конфигурацию сетевого драйвера. ====================================================================== Параметры: * eax = 52 - номер функции @@ -2771,7 +2724,7 @@ dword- * ebx разрушается ====================================================================== - Функция 53, подфункция 255 - отладочная информация сетевого драйвера. + Функция 53, подфункция 255 - отладочная информация сетевого драйвера. ====================================================================== Параметры: * eax = 53 - номер функции @@ -3013,8 +2966,8 @@ dword- * Размер блока - 512 байт; читается один блок. * Не следует полагаться на возвращаемое значение, оно может измениться в следующих версиях. - * Требуется, чтобы был разрешён LBA-доступ к устройствам - подфункцией 11 функции 21. Узнать это можно вызовом + * Требуется, чтобы был разрешён LBA-доступ к устройствам + подфункцией 11 функции 21. Узнать это можно вызовом подфункцией 11 функции 26. * LBA-чтение дискеты не поддерживается. * Функция считывает данные физического жёсткого диска; @@ -3028,7 +2981,7 @@ dword- это будет считаться успехом (eax=0). ====================================================================== -= Функция 58, подфункция 15 - получить информацию о файловой системе. += Функция 58, подфункция 15 - получить информацию о файловой системе. ====================================================================== Параметры: * eax = 58 - номер функции @@ -3125,10 +3078,10 @@ IPC Программе доступны данные графического экрана (область памяти, которая собственно и отображает содержимое экрана) напрямую без вызовов системных функций через селектор gs: - mov eax, [gs:0] + mov eax, [gs:0] поместит в eax первый dword буфера, содержащий информацию о цвете левой верхней точки (и, возможно, цвета нескольких следующих). - mov [gs:0], eax + mov [gs:0], eax при работе в режимах VESA c LFB установит цвет левой верхней точки (и возможно, цвета нескольких следующих). @@ -3289,63 +3242,6 @@ IPC входит, например, в известный Interrupt List by Ralf Brown; список вторых должен быть указан в документации по устройству. -====================================================================== -====================== Функция 62, подфункция 11 ===================== -== Инициализировать пользовательский В/В с отображением на память == -====================================================================== -Параметры: - * eax = 62 - номер функции - * bl = 11 - номер подфункции - * cx = адрес PCI-устройства -Возвращаемое значение: - * eax = -1 - доступ к PCI запрещён; - * eax = -2 - доступ к MMIO-блокам устройства не разрешён; - * eax = -3 - ошибка аллокации пользовательской дин. памяти; иначе - * eax = размер доступной динамической памяти. -Замечания: - * Предварительно должен быть разрешён низкоуровневый доступ к PCI - для приложений подфункцией 12 функции 21. - * адрес PCI-устройства должен совпадать с системной переменной - mmio_pci_addr - -====================================================================== -====================== Функция 62, подфункция 12 ===================== -== Выделить диапазон линейных адресов для пользовательского MMIO == -====================================================================== -Параметры: - * eax = 62 - номер функции - * bl = 12 - номер подфункции - * bh = номер BAR-регистра в конфигурационной зоне PCI - * ecx = размер MMIO-блока (в байтах) - * edx = смещение относительно начала MMIO-блока (в 4K-страницах!) -Возвращаемое значение: - * eax = -1 - доступ к PCI запрещён; - * eax = -2 - неверный номер BAR-регистра; - * eax = -3 - BAR не содержит адреса IO; - * eax = -4 - BAR адресует порты IO; - * eax = -5 - ошибка аллокации; иначе - * eax = начальный адрес MMIO в адресном пространстве приложения. -Замечания: - * Предварительно должен быть разрешён низкоуровневый доступ к PCI - для приложений подфункцией 12 функции 21. - * Адрес PCI-устройства задается системной переменной mmio_pci_addr. - * Предоставленный диапазон линейных адресов должен освобождаться - посредством вызова функции 62:13 - -====================================================================== -====================== Функция 62, подфункция 13 ===================== -== Освободить диапазон линейных адресов пользовательского MMIO == -====================================================================== -Параметры: - * eax = 62 - номер функции - * bl = 12 - номер подфункции - * ecx = начальный адрес освобождаемого MMIO-блока в адресном - пространстве приложения -Возвращаемое значение: - * eax = 1 - блок успешно освобожден; -Замечания: - * Предварительно приложению должен быть выделен uMMIO-блок (fn62:12) - ====================================================================== ================ Функция 63 - работа с доской отладки. =============== ====================================================================== @@ -3459,7 +3355,6 @@ IPC ====================================================================== Режим ввода влияет на результаты чтения клавиш функцией 2. При загрузке программы для неё устанавливается ASCII-режим ввода. -Если вызывается несуществующая подфункция возвращается в eax=-1. -------- Подфункция 1 - установить режим ввода с клавиатуры. --------- Параметры: @@ -3702,25 +3597,20 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); или подфункцией 20. ====================================================================== -==================== Функция 68, подфункция 14 ======================= -===== Ожидать получения сигнала, от других приложений/драйверов. ===== +====================== Функция 68, подфункция 14 ===================== +====== Ожидать получения сигнала от других приложений/драйверов. ===== ====================================================================== Параметры: * eax = 68 - номер функции * ebx = 14 - номер подфункции * ecx = указатель на буфер для информации (24 байта) Возвращаемое значение: + * eax разрушается * буфер, на который указывает ecx, содержит следующую информацию: * +0: dword: идентификатор последующих данных сигнала * +4: данные принятого сигнала (20 байт), формат которых определяется первым dword-ом -====================================================================== -== Функция 68, подфункция 15 - установить обработчик исключений FPU. = -====================================================================== -Удалена (в текущей реализации просто возвращает 0) -Использовать подфункции 24, 25 - ====================================================================== =========== Функция 68, подфункция 16 - загрузить драйвер. =========== ====================================================================== @@ -3759,12 +3649,6 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); определяются драйвером. * Предварительно должен быть получен хэндл драйвера подфункцией 16. -====================================================================== -== Функция 68, подфункция 18 - установить обработчик исключений SSE. = -====================================================================== -Удалена (в текущей реализации просто возвращает 0) -Использовать подфункции 24, 25 - ====================================================================== ============= Функция 68, подфункция 19 - загрузить DLL. ============= ====================================================================== @@ -3860,7 +3744,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); области памяти. ====================================================================== -==== Функция 68, подфункция 24 - установить обработчик исключений === +==== Функция 68, подфункция 24 - установить обработчик исключений. === ====================================================================== Параметры: * eax = 68 - номер функции @@ -3871,26 +3755,26 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * eax = адрес старого обработчика исключений (0, если не установлен) * ebx = маска старого обработчика исключений Замечания: - * Номер бита в маске исключений соответствуют номеру исключения по - спецификации на процессор (Intel-PC). Так например, исключения FPU - имеют номер 16 (#MF), а SSE - 19 (#XF). + * Номер бита в маске исключений соответствует номеру исключения по + спецификации на процессор (Intel-PC). Так, например, исключения + FPU имеют номер 16 (#MF), а SSE - 19 (#XF). * В данной реализации игнорируется запрос на перехват исключения 7 - система обрабатывает #NM самостоятельно. * Пользовательский обработчик получает номер исключения параметром в стеке. Поэтому правильный выход из обработчика: RET 4. Возврат при этом производится на команду, вызвавшую исключение. - * При передаче управления обработчику исключений, сбрасывается + * При передаче управления обработчику исключений сбрасывается соответствующий бит в маске исключений. Возникновение этого же - исключения в последствии - приведет к default-обработке такового. - А именно: к завершению работы приложения, или приостановке с - нотификацией отлаживающему приложению. - * После завершения критических действий в обработчике пользователя, + исключения впоследствии приведёт к умолчальной обработке такового. + А именно: к завершению работы приложения в отсутствии отладчика, + приостановка с уведомлением отлаживающего приложения иначе. + * После завершения критических действий в обработчике пользователя восстановление бита маски данного исключения можно сделать - подфункцией 25. Сброс флагов исключений в модулях FPU и XMM - - также возлагается на обработчик пользователя. + подфункцией 25. Сброс флагов исключений в модулях FPU и XMM также + возлагается на обработчик пользователя. ====================================================================== -= Функция 68, подфункция 25 - изменение состояния активности сигнала = += Функция 68, подфункция 25 - изменить состояние активности сигнала. = ====================================================================== Параметры: * eax = 68 - номер функции @@ -3898,10 +3782,11 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * ecx = номер сигнала * edx = значение устанавливаемой активности (0/1) Возвращаемое значение: - * eax = старое значение активности сигнала (0/1) + * eax = -1 - задан неверный номер сигнала + * иначе eax = старое значение активности сигнала (0/1) Замечания: * В текущей реализации изменяется только маска пользовательского - обработчика исключений, установленного подфункцией 24. При этом, + обработчика исключений, установленного подфункцией 24. При этом номер сигнала соответствует номеру исключения. ====================================================================== @@ -3971,7 +3856,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); и при поступлении нового сообщения система будет ждать. Для синхронизации обрамляйте всю работу с буфером операциями блокировки/разблокировки - neg [bufsize] + neg [bufsize] * Данные в буфере трактуются как массив элементов переменной длины - сообщений. Формат сообщения указан в общем описании. @@ -4082,7 +3967,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); общем описании). ====================================================================== - Функция 69, подфункция 7 - записать в память отлаживаемого процесса. + Функция 69, подфункция 7 - записать в память отлаживаемого процесса. ====================================================================== Параметры: * eax = 69 - номер функции @@ -4204,6 +4089,10 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * '/hd0/2/menuet/pics/tanzania.bmp',0 * '/hd0/1/Program files/NameOfProgram/SomeFile.SomeExtension',0 * '/sys/MySuperApp.ini',0 +Также функция поддерживает относительные имена. Если путь начинается +не с '/', то он считается относительно текущей папки. Получить или +установить текущую папку можно с помощью сисфункции 30. + Доступные подфункции: * подфункция 0 - чтение файла * подфункция 1 - чтение папки diff --git a/kernel/branches/Kolibri-acpi/docs/sysfuncs.txt b/kernel/branches/Kolibri-acpi/docs/sysfuncs.txt index 8d226d1cf6..8112493e2f 100644 --- a/kernel/branches/Kolibri-acpi/docs/sysfuncs.txt +++ b/kernel/branches/Kolibri-acpi/docs/sysfuncs.txt @@ -1,4 +1,4 @@ -SYSTEM FUNCTIONS of OS Kolibri 0.7.5.0 +SYSTEM FUNCTIONS of OS Kolibri 0.7.7.0 Number of the function is located in the register eax. The call of the system function is executed by "int 0x40" command. @@ -347,6 +347,7 @@ Returned value: * bit 0 (mask 1): window is maximized * bit 1 (mask 2): window is minimized to panel * bit 2 (mask 4): window is rolled up + * +71 = +0x47: dword: event mask Remarks: * Slots are numbered starting from 1. * Returned value is not a total number of threads, because there @@ -376,8 +377,8 @@ Remarks: and idle time in waiting for interrupt (which can be got by call to subfunction 4 of function 18). * Beginning from slot 2, the normal applications are placed. - * Applications are placed in memory at the address 0x0 - (kernel constant 'std_application_base_address'). + * The normal applications are placed in memory at the address + 0 (kernel constant 'std_application_base_address'). There is no intersection, as each process has its own page table. * At creation of the thread it is assigned the slot in the system table and identifier (Process/Thread IDentifier = @@ -679,7 +680,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 @@ -761,7 +762,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 +772,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 @@ -844,12 +845,12 @@ Returned value: * function does not return value Structure of the buffer: db a,b,c,d for version a.b.c.d -db UID_xxx: one of UID_NONE=0, UID_MENUET=1, UID_KOLIBRI=2 +db 0: reserved dd REV - kernel SVN revision number -For Kolibri 0.7.1.0 kernel: -db 0,7,0,0 -db 2 -dd 638 +For Kolibri 0.7.7.0+ kernel: +db 0,7,7,0 +db 0 +dd 1675 ====================================================================== ======= Function 18, subfunction 14 - wait for screen retrace. ======= @@ -1062,7 +1063,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 +1107,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 @@ -1160,7 +1161,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. ====================================================================== @@ -1182,12 +1183,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 11 - enable/disable low-level access to HD. + Function 21, subfunction 11 - enable/disable low-level access to HD. ====================================================================== Parameters: * eax = 21 - function number @@ -1201,7 +1202,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 @@ -1268,7 +1269,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 @@ -1403,7 +1404,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). @@ -1423,7 +1424,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. @@ -1438,7 +1439,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. ====================================================================== @@ -1513,7 +1514,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 @@ -1658,56 +1659,9 @@ Returned value: 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. + * By default, current folder for the thread is "/rd/1". + * At process/thread creation the current folder will be inherited + from the parent. ====================================================================== ======= Function 35 - read the color of a pixel on the screen. ======= @@ -1888,7 +1842,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. ====================================================================== @@ -1901,7 +1855,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. ====================================================================== @@ -2193,11 +2147,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. @@ -2392,7 +2346,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. === @@ -2470,7 +2424,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 @@ -2749,7 +2703,7 @@ Returned value: * ebx destroyed ====================================================================== -= Function 53, subfunction 255 - debug information of network driver. += Function 53, subfunction 255 - debug information of network driver. ====================================================================== Parameters: * eax = 53 - function number @@ -2780,7 +2734,7 @@ Possible values for ecx: * 6: status of packet driver, 0=inactive, nonzero=active ====================================================================== - 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 @@ -2925,7 +2879,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 @@ -2987,8 +2941,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 @@ -3098,11 +3052,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 @@ -3260,59 +3214,6 @@ Remarks: Ralf Brown; registers of the second type must be listed in the device documentation. -====================================================================== -===================== Function 62, subfunction 11 ==================== -== Initialize user-accessible MMIO channel == -====================================================================== -Parameters: - * eax = 62 - function - * bl = 11 - subfunction - * cx = PCI-address (bbbbbbbb dddddfff) -Returns: - * eax = -1 - PCI access not granted; - * eax = -2 - no user MMIO access to this PCI address; - * eax = -3 - memory allocation error; otherwise - * eax = available user heap size. -Remarks: - * Low-level PCI access must be allowed (fn21:12) - * PCI-address should correspond the system var [mmio_pci_addr] - -====================================================================== -===================== Function 62, subfunction 12 ==================== -== Request user-accessible MMIO address space == -====================================================================== -Parameters: - * eax = 62 - function - * bl = 12 - subfunction - * bh = BAR number in PCI configuration space - * ecx = MMIO-block size needed (bytes) - * edx = MMIO-offset (number of whole 4Kb-pages!) -Returns: - * eax = -1 - user PCI access denied; - * eax = -2 - invalid BAR number; - * eax = -3 - BAR contains no valid IO addres; - * eax = -4 - BAR addresses IO ports; - * eax = -5 - dynamic allocation error; otherwise - * eax = MMIO start address (in application's linear space). -Remarks: - * Low-level PCI access must be allowed (fn21:12) - * The system var [mmio_pci_addr] sets the actual PCI-address - * The granted MMIO addresses should be released after use (fn62:13) - -====================================================================== -===================== Function 62, subfunction 13 ==================== -== Release a block of user MMIO addresses == -====================================================================== -Параметры: - * eax = 62 - function - * bl = 12 - subfunction - * ecx = MMIO start address (in application's linear space). -Returns: - * eax = 1 if the block is successfully released; - * eax = 0 in case of reallocation error; -Remarks: - * A valid uMMIO block should exist at this address (fn62:12) - ====================================================================== ============== Function 63 - work with the debug board. ============== ====================================================================== @@ -3421,7 +3322,6 @@ Remarks: ====================================================================== The input mode influences results of reading keys by function 2. When a program loads, ASCII input mode is set for it. -If subfunction is not support then eax=-1. -------------- Subfunction 1 - set keyboard input mode. -------------- Parameters: @@ -3670,7 +3570,7 @@ Remarks: ====================================================================== ===================== Function 68, subfunction 14 ==================== -====== Waiting delivering of signal from another program/driver ====== +============ Wait for signal from another program/driver. ============ ====================================================================== Parameters: * eax = 68 - function number @@ -3678,15 +3578,9 @@ Parameters: * ecx = pointer to the buffer for information (24 bytes) Returned value: * buffer pointed to by ecx contains the following information: - * +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. ====== -====================================================================== -Deleted (in current implementation only 0 is returned). -Using subfunctions 24, 25 is true. + * +0: dword: identifier for following data of signal + * +4: dword: data of signal (20 bytes), format of which is defined + by the first dword ====================================================================== ============= Function 68, subfunction 16 - load driver. ============= @@ -3720,22 +3614,12 @@ Parameters: * +16 = +0x10: dword: pointer to output data * +20 = +0x14: dword: size of output data Returned value: - * 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 + * eax = determined by driver Remarks: * Function codes and the structure of input/output data are defined by driver. * Previously one must obtain driver handle by subfunction 16. -====================================================================== -====== Function 68, subfunction 18 - set SSE exception handler. ====== -====================================================================== -Deleted (in current implementation only 0 is returned). -Using subfunctions 24, 25 is true. - ====================================================================== =============== Function 68, subfunction 19 - load DLL. ============== ====================================================================== @@ -3775,36 +3659,92 @@ Remarks: the new and old sizes. ====================================================================== -====== Function 68, subfunction 24 - set new exceptions handler ====== +======== Function 68, subfunction 22 - open named memory area. ======= +====================================================================== +Parameters: + * eax = 68 - function number + * ebx = 22 - subfunction number + * ecx = area name. Maximum of 31 characters with terminating zero + * edx = area size in bytes for SHM_CREATE and SHM_OPEN_ALWAYS + * esi = flags for open and access: + * SHM_OPEN = 0x00 - open existing memory area. If an area + with such name does not exist, the function + will return error code 5. + * SHM_OPEN_ALWAYS = 0x04 - open existing or create new + memory area. + * SHM_CREATE = 0x08 - create new memory area. If an area + with such name already exists, the function + will return error code 10. + * SHM_READ = 0x00 - only read access + * SHM_WRITE = 0x01 - read and write access +Returned value: + * eax = pointer to memory area, 0 if error has occured + * if new area is created (SHM_CREATE or SHM_OPEN_ALWAYS): + edx = 0 - success, otherwise - error code + * if existing area is opened (SHM_OPEN or SHM_OPEN_ALWAYS): + edx = error code (if eax=0) or area size in bytes +Error codes: + * E_NOTFOUND = 5 + * E_ACCESS = 10 + * E_NOMEM = 30 + * E_PARAM = 33 +Remarks: + * Before this call one must initialize process heap by call to + subfunction 11. + * If a new area is created, access flags set maximal rights + for other processes. An attempt from other process to open + with denied rights will fail with error code E_ACCESS. + * The process which has created an area always has write access. + +====================================================================== +======= Function 68, subfunction 23 - close named memory area. ======= +====================================================================== +Parameters: + * eax = 68 - function number + * ebx = 23 - subfunction number + * ecx = area name. Maximum of 31 characters with terminating zero +Returned value: + * eax destroyed +Remarks: + * A memory area is physically freed (with deleting all data and + freeing physical memory), when all threads which have opened + this area will close it. + * When thread is terminating, all opened by it areas are closed. + +====================================================================== +======== Function 68, subfunction 24 - set exception handler. ======== ====================================================================== Parameters: * eax = 68 - function number * ebx = 24 - subfunction number * ecx = address of the new exception handler - * edx = the mask of processing exceptions + * edx = the mask of handled exceptions Returned value: * eax = address of the old exception handler (0, if it was not set) - * ebx = the old mask of exception handler + * ebx = the old mask of handled exceptions 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. + * Bit number in mask of exceptions corresponds to exception number + in CPU-specification (Intel-PC). For example, FPU exceptions have + number 16 (#MF), and SSE exceptions - 19 (#XF). + * The current implementation ignores the inquiry for hook of 7 + exception - the system handles #NM by its own. + * The exception handler is called with exception number as first + (and only) stack parameter. So, correct exit from the handler is + RET 4. It returns to the instruction, that caused the exception, + for faults, and to the next instruction for traps (see + classification of exceptions in CPU specification). + * When user handler receives control, the corresponding bit in + the exception mask is cleared. Raising this exception + in consequence leads to default handling, that is, + terminating the application in absence of debugger or + suspend with notification of debugger otherwise. + * After user handler completes critical operations, it can set + the corresponding bit in the exception mask with subfunction 25. + Also user handler is responsible for clearing exceptions flags in + FPU and/or SSE. ====================================================================== -==== Function 68, subfunction 25 - change state of signal activity === +====== Function 68, subfunction 25 - set FPU exception handler. ====== ====================================================================== Parameters: * eax = 68 - function number @@ -3812,14 +3752,15 @@ Parameters: * ecx = signal number * edx = value of activity (0/1) Returned value: - * eax = value of old activity for this signal (0/1) + * eax = -1 - invalid signal number + * otherwise eax = old value of 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. + * In current implementation only mask for user excepton handler, + which has been previously set by subfunction 24, + is changed. Signal number corresponds to exception number. ====================================================================== -====================== Fucntion 69 - debugging. ====================== +====================== Function 69 - debugging. ====================== ====================================================================== A process can load other process as debugged by set of corresponding bit by call to subfunction 7 of function 70. @@ -3882,7 +3823,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. @@ -4111,6 +4052,10 @@ Examples: * '/hd0/2/menuet/pics/tanzania.bmp',0 * '/hd0/1/Program files/NameOfProgram/SomeFile.SomeExtension',0 * '/sys/MySuperApp.ini',0 +Also function supports relative names. If the path begins not +with '/', it is considered relative to a current folder. To get or +set a current folder, use the function 30. + Available subfunctions: * subfunction 0 - read file * subfunction 1 - read folder diff --git a/kernel/branches/Kolibri-acpi/drivers/imports.inc b/kernel/branches/Kolibri-acpi/drivers/imports.inc index c1390a0f2f..cb703a0929 100644 --- a/kernel/branches/Kolibri-acpi/drivers/imports.inc +++ b/kernel/branches/Kolibri-acpi/drivers/imports.inc @@ -90,4 +90,6 @@ kernel_export \ strchr,\ strrchr,\ \ - LFBAddress + LFBAddress,\ + GetDisplay,\ + SetScreen diff --git a/kernel/branches/Kolibri-acpi/drivers/infinity.asm b/kernel/branches/Kolibri-acpi/drivers/infinity.asm index bcfbe909d4..ad85644e1f 100644 --- a/kernel/branches/Kolibri-acpi/drivers/infinity.asm +++ b/kernel/branches/Kolibri-acpi/drivers/infinity.asm @@ -55,6 +55,7 @@ MANUAL_DESTROY equ 0x80000000 DEV_PLAY equ 1 DEV_STOP equ 2 DEV_CALLBACK equ 3 +DEV_GET_POS equ 9 struc IOCTL { .handle dd ? @@ -159,14 +160,65 @@ inp_size equ IOCTL.inp_size output equ IOCTL.output out_size equ IOCTL.out_size + + align 4 + +srv_calls dd service_proc.srv_getversion ; 0 + dd service_proc.snd_create_buff ; 1 + dd service_proc.snd_destroy_buff ; 2 + dd service_proc.snd_setformat ; 3 + dd service_proc.snd_getformat ; 4 + dd service_proc.snd_reset ; 5 + dd service_proc.snd_setpos ; 6 + dd service_proc.snd_getpos ; 7 + dd service_proc.snd_setbuff ; 8 + dd service_proc.snd_out ; 9 + dd service_proc.snd_play ; 10 + dd service_proc.snd_stop ; 11 + dd service_proc.snd_setvolume ; 12 + dd service_proc.snd_getvolume ; 13 + dd service_proc.snd_setpan ; 14 + dd service_proc.snd_getpan ; 15 + dd service_proc.snd_getbuffsize ; 16 + dd service_proc.snd_getfreespace ; 17 + dd service_proc.snd_settimebase ; 18 + dd service_proc.snd_gettimestamp ; 19 +srv_calls_end: + proc service_proc stdcall, ioctl:dword mov edi, [ioctl] mov eax, [edi+io_code] - cmp eax, SRV_GETVERSION - jne @F + cmp eax, (srv_calls_end-srv_calls)/4 + ja .fail + + cmp eax, SND_DESTROY_BUFF + jb @F + +; cmp [edi+inp_size], 4 +; jb .fali + + mov ebx, [edi+input] + mov edx, [ebx] + + cmp [edx+STREAM.magic], 'WAVE' + jne .fail + + cmp [edx+STREAM.size], STREAM.sizeof + jne .fail + +@@: + jmp [srv_calls+eax*4] + + +.fail: + mov eax, -1 + ret + +align 4 +.srv_getversion: mov eax, [edi+output] cmp [edi+out_size], 4 jne .fail @@ -174,9 +226,9 @@ proc service_proc stdcall, ioctl:dword mov [eax], dword API_VERSION xor eax, eax ret -@@: - cmp eax, SND_CREATE_BUFF - jne @F + +align 4 +.snd_create_buff: mov ebx, [edi+input] stdcall CreateBuffer,[ebx],[ebx+4] mov edi, [ioctl] @@ -184,121 +236,105 @@ proc service_proc stdcall, ioctl:dword mov ecx, [ecx] mov [ecx], ebx ret -@@: - mov ebx, [edi+input] - mov edx, [ebx] - cmp [edx+STREAM.magic], 'WAVE' - jne .fail - - cmp [edx+STREAM.size], STREAM_SIZE - jne .fail - - cmp eax, SND_DESTROY_BUFF - jne @F +align 4 +.snd_destroy_buff: mov eax, edx - call DestroyBuffer ;edx= stream + call DestroyBuffer ret -@@: - cmp eax, SND_SETFORMAT - jne @F - stdcall SetFormat,edx,[ebx+4] - ret -@@: - cmp eax, SND_GETFORMAT - jne @F +align 4 +.snd_setformat: + stdcall SetFormat, edx,[ebx+4] + ret + +align 4 +.snd_getformat: movzx eax, word [edx+STREAM.format] mov ecx, [edi+output] mov ecx, [ecx] mov [ecx], eax xor eax, eax ret -@@: - cmp eax, SND_RESET - jne @F + +align 4 +.snd_reset: stdcall ResetBuffer,edx,[ebx+4] ret -@@: - cmp eax, SND_SETPOS - jne @F + +align 4 +.snd_setpos: stdcall SetBufferPos,edx,[ebx+4] ret -@@: - cmp eax, SND_GETPOS - jne @F + +align 4 +.snd_getpos: stdcall GetBufferPos, edx mov edi, [ioctl] mov ecx, [edi+output] mov ecx, [ecx] mov [ecx], ebx ret -@@: - cmp eax, SND_SETBUFF - jne @F + +align 4 +.snd_setbuff: mov eax, [ebx+4] stdcall set_buffer, edx,eax,[ebx+8],[ebx+12] ret -@@: - cmp eax, SND_SETVOLUME - jne @F + +align 4 +.snd_out: + mov eax, [ebx+4] + stdcall wave_out, edx,eax,[ebx+8] + ret + +align 4 +.snd_play: + stdcall play_buffer, edx,[ebx+4] + ret + +align 4 +.snd_stop: + stdcall stop_buffer, edx + ret + +align 4 +.snd_setvolume: stdcall SetBufferVol,edx,[ebx+4],[ebx+8] ret -@@: - cmp eax, SND_GETVOLUME - jne @F +align 4 +.snd_getvolume: mov eax, [edi+output] mov ecx, [eax] mov eax, [eax+4] stdcall GetBufferVol,edx,ecx,eax ret -@@: - cmp eax, SND_SETPAN - jne @F +align 4 +.snd_setpan: stdcall SetBufferPan,edx,[ebx+4] ret -@@: - cmp eax, SND_GETPAN - jne @F + +align 4 +.snd_getpan: mov eax, [edx+STREAM.pan] mov ebx, [edi+output] mov ebx, [ebx] mov [ebx], eax xor eax, eax ret -@@: - cmp eax, SND_OUT - jne @F - mov eax, [ebx+4] - stdcall wave_out, edx,eax,[ebx+8] - ret -@@: - cmp eax, SND_PLAY - jne @F - - stdcall play_buffer, edx,[ebx+4] - ret -@@: - cmp eax, SND_STOP - jne @F - - stdcall stop_buffer, edx - ret -@@: - cmp eax, SND_GETBUFFSIZE - jne @F +align 4 +.snd_getbuffsize: mov eax, [edx+STREAM.in_size] mov ecx, [edi+output] mov ecx, [ecx] mov [ecx], eax xor eax, eax ret -@@: - cmp eax, SND_GETFREESPACE - jne @F +align 4 +.snd_getfreespace: test [edx+STREAM.format], PCM_OUT jz .fail @@ -307,12 +343,73 @@ proc service_proc stdcall, ioctl:dword mov [ecx], ebx xor eax, eax ret +align 4 +.snd_settimebase: + cmp [edi+inp_size], 12 + jne .fail + + mov eax, [ebx] + mov ebx, [ebx+4] + mov dword [edx+STREAM.time_base], eax + mov dword [edx+STREAM.time_base+4], ebx + xor eax, eax + ret + +.snd_gettimestamp: + cmp [edi+out_size], 8 + jne .fail + + pushfd + cli + + xor ebx, ebx + push 48 + push ebx ; local storage + + cmp [edx+STREAM.flags], SND_STOP + je @F + + mov eax, esp + + push edx + push edi + + push 4 ;.out_size + push eax ;.output + push ebx ;.inp_size + push ebx ;.input + push DEV_GET_POS ;.code + push dword [hSound] ;.handle + mov eax, esp + + stdcall ServiceHandler, eax + add esp, 6*4 + + pop edi + pop edx + + test eax, eax + jz @F + + mov dword [esp], 0 ; clear offset @@: -.fail: - or eax, -1 + mov edi, [edi+output] + + emms + fild qword [edx+STREAM.time_stamp] + fiadd dword [esp] ; primary buffer offset + fidiv dword [esp+4] ; total_samples / frequency + fadd qword [edx+STREAM.time_base] + fstp qword [edi] + add esp, 8 + + popfd + + xor eax, eax ret endp + restore handle restore io_code restore input @@ -352,7 +449,7 @@ proc CreateBuffer stdcall, format:dword, size:dword call GetPid mov ebx, eax - mov eax, STREAM_SIZE + mov eax, STREAM.sizeof call CreateObject test eax, eax @@ -412,7 +509,6 @@ proc CreateBuffer stdcall, format:dword, size:dword mov [edi+STREAM.in_base], eax mov [edi+STREAM.in_size], ecx add eax, 128 - ; sub ecx, 128 mov [edi+STREAM.in_wp], eax mov [edi+STREAM.in_rp], eax mov [edi+STREAM.in_count], 0 @@ -443,13 +539,22 @@ proc CreateBuffer stdcall, format:dword, size:dword stdcall AllocKernelSpace, dword 128*1024 mov edi, [str] + xor ebx, ebx + mov [edi+STREAM.out_base], eax mov [edi+STREAM.out_wp], eax mov [edi+STREAM.out_rp], eax - mov [edi+STREAM.out_count], 0 + mov [edi+STREAM.out_count], ebx add eax, 64*1024 mov [edi+STREAM.out_top], eax + mov dword [edi+STREAM.time_base], ebx + mov dword [edi+STREAM.time_base+4], ebx + + mov dword [edi+STREAM.time_stamp], ebx + mov dword [edi+STREAM.time_stamp+4], ebx + mov dword [edi+STREAM.last_ts], ebx + stdcall AllocPages, dword 64/4 mov edi, [str] mov ebx, [edi+STREAM.out_base] @@ -488,7 +593,7 @@ proc CreateBuffer stdcall, format:dword, size:dword mov [ebx+STREAM.magic], 'WAVE' mov [ebx+STREAM.destroy], DestroyBuffer.destroy - mov [ebx+STREAM.size], STREAM_SIZE + mov [ebx+STREAM.size], STREAM.sizeof mov [ebx+STREAM.flags], SND_STOP pushf @@ -857,6 +962,26 @@ proc SetBufferVol stdcall, str:dword,l_vol:dword,r_vol:dword ret endp + +proc minw stdcall, arg1:dword, arg2:dword + mov ax, word [arg1] + cmp ax, word [arg2] + jle @f + mov eax, [arg2] +@@: + ret +endp + +proc maxw stdcall, arg1:dword, arg2:dword + mov ax, word [arg1] + cmp ax, word [arg2] + jge @f + mov eax, [arg2] +@@: + ret +endp + + proc set_vol_param stdcall, l_vol:dword,r_vol:dword,pan:dword locals _600 dd ? @@ -870,31 +995,34 @@ proc set_vol_param stdcall, l_vol:dword,r_vol:dword,pan:dword lea ebx, [state] fnsave [ebx] - movq mm0, qword [l_vol] - pminsw mm0, qword [vol_max] - pmaxsw mm0, qword [vol_min] - movq qword [l_vol], mm0 - movq qword [edx+STREAM.l_vol], mm0 + stdcall minw, [l_vol], [vol_max] + stdcall maxw, eax, [vol_min] + mov [l_vol], eax + mov [edx+STREAM.l_vol], eax + stdcall minw, [r_vol], [vol_max+4] + stdcall maxw, eax, [vol_min+4] + mov [r_vol], eax + mov [edx+STREAM.r_vol], eax - movd mm1,[pan] - pminsw mm1, qword [pan_max] - pmaxsw mm1, qword [vol_min] - movd [edx+STREAM.pan], mm1 + stdcall minw, [pan], [pan_max] + stdcall maxw, eax, [vol_min] + mov [edx+STREAM.pan], eax cmp word [edx+STREAM.pan], 0 - jl @F + jl @f - psubsw mm0,mm1 - pminsw mm0, qword [vol_max] - pmaxsw mm0, qword [vol_min] - movd [l_vol],mm0 + mov ebx, [l_vol] + sub ebx, eax + stdcall minw, ebx, [vol_max] + stdcall maxw, eax, [vol_min] + mov [l_vol], eax jmp .calc_amp @@: - punpckhdq mm0,mm0 - paddsw mm0,mm1 - pminsw mm0, qword [vol_max] - pmaxsw mm0, qword [vol_min] - movd [r_vol], mm0 + mov ebx, [r_vol] + add ebx, [pan] + stdcall minw, ebx, [vol_max+4] + stdcall maxw, eax, [vol_min+4] + mov [r_vol], eax .calc_amp: emms fild word [l_vol] @@ -935,6 +1063,7 @@ proc set_vol_param stdcall, l_vol:dword,r_vol:dword,pan:dword ret 0 endp + align 4 proc GetBufferVol stdcall, str:dword,p_lvol:dword,p_rvol:dword @@ -1039,7 +1168,7 @@ do_mix_list: cmp [ebx+STREAM.magic], 'WAVE' jne .next - cmp [ebx+STREAM.size], STREAM_SIZE + cmp [ebx+STREAM.size], STREAM.sizeof jne .next cmp [ebx+STREAM.flags], SND_PLAY; @@ -1108,7 +1237,7 @@ prepare_playlist: cmp [edi+STREAM.magic], 'WAVE' jne .next - cmp [edi+STREAM.size], STREAM_SIZE + cmp [edi+STREAM.size], STREAM.sizeof jne .next cmp [edi+STREAM.flags], SND_PLAY; diff --git a/kernel/branches/Kolibri-acpi/drivers/main.inc b/kernel/branches/Kolibri-acpi/drivers/main.inc index 67198c304d..75a0c09b05 100644 --- a/kernel/branches/Kolibri-acpi/drivers/main.inc +++ b/kernel/branches/Kolibri-acpi/drivers/main.inc @@ -91,6 +91,8 @@ SND_SETPAN equ 14 SND_GETPAN equ 15 SND_GETBUFFSIZE equ 16 SND_GETFREESPACE equ 17 +SND_SETTIMEBASE equ 18 +SND_GETTIMESTAMP equ 19 struc STREAM { @@ -113,6 +115,23 @@ struc STREAM .out_count dd ? .out_top dd ? ;16*4 + .in_base dd ? + .in_size dd ? + .in_wp dd ? + .in_rp dd ? + .in_count dd ? + .in_free dd ? + .in_top dd ? + +align 8 + + .time_base dq ? + .time_stamp dq ? + .last_ts dd ? + + .notify_event dd ? + .notify_id dd ? + .r_size dd ? .r_dt dd ? .r_silence dd ? @@ -125,19 +144,9 @@ struc STREAM .l_amp_f dd ? ;float point left .r_amp_f dd ? ;float point right - .in_base dd ? - .in_size dd ? - .in_wp dd ? - .in_rp dd ? - .in_count dd ? - .in_free dd ? - .in_top dd ? - - .notify_event dd ? - .notify_id dd ? + .sizeof: } -STREAM_SIZE equ 36*4 FD_OFFSET equ 24 virtual at 0 diff --git a/kernel/branches/Kolibri-acpi/drivers/mixer.asm b/kernel/branches/Kolibri-acpi/drivers/mixer.asm index f825ef4612..8feb37703e 100644 --- a/kernel/branches/Kolibri-acpi/drivers/mixer.asm +++ b/kernel/branches/Kolibri-acpi/drivers/mixer.asm @@ -29,7 +29,7 @@ proc new_mix stdcall, output:dword and eax, -16 ;must be 16b aligned call FpuSave - call update_stream + call update_streams .mix: lea eax, [mix_list] call do_mix_list @@ -87,7 +87,7 @@ end if endp align 4 -proc update_stream +proc update_streams locals stream_index dd ? event rd 6 @@ -98,6 +98,10 @@ proc update_stream mov edx, [stream_index] mov esi, [play_list+edx*4] + add dword [esi+STREAM.time_stamp], 4096 + adc dword [esi+STREAM.time_stamp+4], 0 + mov dword [esi+STREAM.last_ts], 0 + mov eax, [esi+STREAM.out_rp] cmp eax, [esi+STREAM.out_top] jb @f diff --git a/kernel/branches/Kolibri-acpi/drivers/sb16/sb16.asm b/kernel/branches/Kolibri-acpi/drivers/sb16/sb16.asm index 33a62da5df..424c7f9583 100644 --- a/kernel/branches/Kolibri-acpi/drivers/sb16/sb16.asm +++ b/kernel/branches/Kolibri-acpi/drivers/sb16/sb16.asm @@ -7,7 +7,7 @@ format MS COFF -include 'config.inc' +include 'CONFIG.INC' ;structs---------------------------------------------------------- struc IOCTL @@ -33,7 +33,7 @@ include '..\imports.inc' section '.flat' code readable align 16 -include 'sb16.inc' +include 'SB16.INC' ;------------------------------------------------------------------------------- proc START stdcall, state:dword diff --git a/kernel/branches/Kolibri-acpi/drivers/sceletone.asm b/kernel/branches/Kolibri-acpi/drivers/sceletone.asm index 4f9df29e5c..2b3f06f758 100644 --- a/kernel/branches/Kolibri-acpi/drivers/sceletone.asm +++ b/kernel/branches/Kolibri-acpi/drivers/sceletone.asm @@ -16,10 +16,6 @@ API_VERSION equ 0 ;debug include 'proc32.inc' include 'imports.inc' -OS_BASE equ 0; -new_app_base equ 0x60400000 -PROC_BASE equ OS_BASE+0x0080000 - struc IOCTL { .handle dd ? .io_code dd ? diff --git a/kernel/branches/Kolibri-acpi/drivers/sound.asm b/kernel/branches/Kolibri-acpi/drivers/sound.asm index c77c9a9647..9910bf8f86 100644 --- a/kernel/branches/Kolibri-acpi/drivers/sound.asm +++ b/kernel/branches/Kolibri-acpi/drivers/sound.asm @@ -138,6 +138,7 @@ DEV_NOTIFY equ 5 DEV_SET_MASTERVOL equ 6 DEV_GET_MASTERVOL equ 7 DEV_GET_INFO equ 8 +DEV_GET_POS equ 9 struc AC_CNTRL ;AC controller base class { .bus dd ? @@ -333,46 +334,7 @@ proc START stdcall, state:dword mov esi, msgDone call SysMsgBoardStr - if IRQ_REMAP - pushf - cli - - mov ebx, [ctrl.int_line] - in al, 0xA1 - mov ah, al - in al, 0x21 - test ebx, ebx - jz .skip - bts ax, bx ;mask old line -.skip - bts ax, IRQ_LINE ;mask new ine - out 0x21, al - mov al, ah - out 0xA1, al - ;remap IRQ - stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE - - mov dx, 0x4d0 ;8259 ELCR1 - in al, dx - bts ax, IRQ_LINE - out dx, al ;set level-triggered mode - mov [ctrl.int_line], IRQ_LINE - popf - mov esi, msgRemap - call SysMsgBoardStr - end if - - mov eax, VALID_IRQ - mov ebx, [ctrl.int_line] - mov esi, msgInvIRQ - bt eax, ebx - jnc .fail_msg - mov eax, ATTCH_IRQ - mov esi, msgAttchIRQ - bt eax, ebx - jnc .fail_msg - - stdcall AttachIntHandler, ebx, ac97_irq, dword 0 + stdcall AttachIntHandler, 17, ac97_irq, dword 0 .reg: stdcall RegService, sz_sound_srv, service_proc ret @@ -453,6 +415,21 @@ proc service_proc stdcall, ioctl:dword mov ebx, [edi+output] stdcall get_master_vol, ebx ret + +@@: + cmp eax, DEV_GET_POS + jne @F + + mov ebx, 8192 + mov edx, 0x18 + xor eax, eax + call [ctrl.ctrl_read16] + sub ebx, eax + shr ebx, 1 + mov edx, [edi+output] + mov [edx], ebx + xor eax, eax + ret ;@@: ; cmp eax, DEV_GET_INFO ; jne @F @@ -480,6 +457,22 @@ proc ac97_irq call SysMsgBoardStr end if + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + + push eax + + test eax, 0x40 + jnz .do_intr + + test eax, eax + jz .done + + mov edx, CTRL_STAT + call [ctrl.ctrl_write32] + jmp .done + +.do_intr: mov edx, PCM_OUT_CR_REG mov al, 0x10; 0x10 call [ctrl.ctrl_write8] @@ -512,18 +505,22 @@ proc ac97_irq and eax, 31 mov ebx, dword [buff_list+eax*4] - cmp [ctrl.user_callback], 0 - je @f + cmp [ctrl.user_callback], 0 + je .done - stdcall [ctrl.user_callback], ebx -@@: + stdcall [ctrl.user_callback], ebx +.done: + pop eax + and eax, 0x40 + mov edx, CTRL_STAT + call [ctrl.ctrl_write32] ret - .skip: mov edx, PCM_OUT_CR_REG mov ax, 0x11 ;0x1D call [ctrl.ctrl_write8] - ret + jmp .done + endp align 4 @@ -776,6 +773,8 @@ end if and eax, 0xFF mov [ctrl.cfg_reg], eax + mov [ctrl.user_callback], 0 + call [ctrl.ctrl_setup] xor eax, eax inc eax diff --git a/kernel/branches/Kolibri-acpi/fs/iso9660.inc b/kernel/branches/Kolibri-acpi/fs/iso9660.inc index fac5509b34..7a875e2660 100644 --- a/kernel/branches/Kolibri-acpi/fs/iso9660.inc +++ b/kernel/branches/Kolibri-acpi/fs/iso9660.inc @@ -67,9 +67,11 @@ free_cd_channel: jne .IDE_Channel_2 .IDE_Channel_1: mov [IDE_Channel_1],0 + sti ret .IDE_Channel_2: mov [IDE_Channel_2],0 + sti ret uglobal diff --git a/kernel/branches/Kolibri-acpi/hid/keyboard.inc b/kernel/branches/Kolibri-acpi/hid/keyboard.inc index 2eac6309b7..fe058a0fca 100644 --- a/kernel/branches/Kolibri-acpi/hid/keyboard.inc +++ b/kernel/branches/Kolibri-acpi/hid/keyboard.inc @@ -94,12 +94,34 @@ hotkey_do_test: pop eax ret + +align 4 + +set_keyboard_data: + + movzx eax,word[TASK_COUNT] ; top window process + movzx eax,word[WIN_POS+eax*2] + shl eax,8 + mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode] + mov [keyboard_mode],al + + mov eax, ecx + + push ebx + push esi + push edi + push ebp + + call send_scancode + + pop ebp + pop edi + pop esi + pop ebx + ret + align 4 irq1: -; save_ring3_context -; mov ax, os_data -; mov ds, ax -; mov es, ax movzx eax,word[TASK_COUNT] ; top window process movzx eax,word[WIN_POS+eax*2] @@ -108,6 +130,9 @@ irq1: mov [keyboard_mode],al in al,0x60 + +send_scancode: + mov [keyboard_data],al ; ch = scancode @@ -310,11 +335,6 @@ irq1: .exit.irq1: mov [check_idle_semaphore],5 -; mov al,0x20 ; ready for next irq -; out 0x20,al - -; restore_ring3_context -; iret ret set_lights: @@ -340,4 +360,4 @@ numlock_map: db 0x33 ;Num 3 db 0x30 ;Num 0 db 0x2E ;Num . -;..........................Part2 End................................................ \ No newline at end of file +;..........................Part2 End................................................ diff --git a/kernel/branches/Kolibri-acpi/hid/mousedrv.inc b/kernel/branches/Kolibri-acpi/hid/mousedrv.inc index e6de7c5af6..f13442cfe9 100644 --- a/kernel/branches/Kolibri-acpi/hid/mousedrv.inc +++ b/kernel/branches/Kolibri-acpi/hid/mousedrv.inc @@ -292,21 +292,20 @@ __sys_disable_mouse: add ecx,eax add ecx, [_WinMapAddress] mov eax, [CURRENT_TASK] - movzx ebx, byte [ecx] - cmp eax,ebx + cmp al, [ecx] je yes_mouse_disable - movzx ebx, byte [ecx+16] - cmp eax,ebx + cmp al, [ecx+16] je yes_mouse_disable + add ebx, 10 + cmp ebx, [Screen_Max_Y] + jae no_mouse_disable mov ebx,[Screen_Max_X] inc ebx imul ebx,10 add ecx,ebx - movzx ebx, byte [ecx] - cmp eax,ebx + cmp al, [ecx] je yes_mouse_disable - movzx ebx, byte [ecx+16] - cmp eax,ebx + cmp al, [ecx+16] je yes_mouse_disable jmp no_mouse_disable yes_mouse_disable: diff --git a/kernel/branches/Kolibri-acpi/kernel.asm b/kernel/branches/Kolibri-acpi/kernel.asm index 5f5d425bfc..b2b5bb628a 100644 --- a/kernel/branches/Kolibri-acpi/kernel.asm +++ b/kernel/branches/Kolibri-acpi/kernel.asm @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; PROGRAMMING: ;; Ivan Poddubny ;; Marat Zakiyanov (Mario79) @@ -19,6 +19,17 @@ ;; SPraid (simba) ;; Hidnplayr ;; Alexey Teplov () +;; Rus +;; Nable +;; shurf +;; Alver +;; Maxis +;; Galkov +;; CleverMouse +;; tsdima +;; turbanoff +;; Asper +;; art_zh ;; ;; 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 @@ -220,8 +231,8 @@ B32: ; CLEAR 0x280000 - HEAP_BASE xor eax,eax - mov edi,0x280000 - mov ecx,(HEAP_BASE-OS_BASE-0x280000) / 4 + mov edi,CLEAN_ZONE + mov ecx,(HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 cld rep stosd @@ -237,7 +248,7 @@ B32: ; SAVE & CLEAR 0-0xffff xor esi, esi - mov edi,0x2F0000 + mov edi,(BOOT_VAR-OS_BASE) mov ecx,0x10000 / 4 rep movsd mov edi,0x1000 @@ -605,6 +616,8 @@ high_code: ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) ; they are used: when partitions are scanned, hd_read relies on timer call unmask_timer + stdcall enable_irq, 12 + stdcall enable_irq, 1 stdcall enable_irq, 14 stdcall enable_irq, 15 @@ -621,11 +634,14 @@ include 'detect/disks.inc' call Parser_params +if ~ defined extended_primary_loader +; ramdisk image should be loaded by extended primary loader if it exists ; READ RAMDISK IMAGE FROM HD ;!!!!!!!!!!!!!!!!!!!!!!! include 'boot/rdload.inc' ;!!!!!!!!!!!!!!!!!!!!!!! +end if ; mov [dma_hdd],1 ; CALCULATE FAT CHAIN FOR RAMDISK @@ -780,6 +796,9 @@ end if mov [CPU_FREQ],eax ; save tsc / sec ; mov ebx, 1000000 ; div ebx +; вообще-то производительность в данном конкретном месте +; совершенно некритична, но чтобы заткнуть любителей +; оптимизирующих компиляторов ЯВУ... mov edx, 2251799814 mul edx shr edx, 19 @@ -960,7 +979,7 @@ if defined debug_com_base end if -;-=-=-=-=-=-=- START MULTITASKING -=-=-=-=-=-=-=-=- +; START MULTITASKING ; A 'All set - press ESC to start' messages if need if preboot_blogesc @@ -2775,6 +2794,10 @@ sys_cpuusage: mov al, [ecx+window_data+WDATA.fl_wstate] stosb + ; Event mask (+71) + mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] + stosd + pop esi pop edi @@ -5051,6 +5074,7 @@ system_shutdown: ; shut down the system yes_shutdown_param: cli +if ~ defined extended_primary_loader mov eax, kernel_file ; load kernel.mnt to 0x7000:0 push 12 pop esi @@ -5063,8 +5087,9 @@ yes_shutdown_param: mov edi,OS_BASE+0x40000 mov ecx,1000 rep movsb +end if - mov esi,OS_BASE+0x2F0000 ; restore 0x0 - 0xffff + mov esi, BOOT_VAR ; restore 0x0 - 0xffff mov edi, OS_BASE mov ecx,0x10000/4 cld diff --git a/kernel/branches/Kolibri-acpi/kernel32.inc b/kernel/branches/Kolibri-acpi/kernel32.inc index af94b8cef7..72620eb233 100644 --- a/kernel/branches/Kolibri-acpi/kernel32.inc +++ b/kernel/branches/Kolibri-acpi/kernel32.inc @@ -144,7 +144,7 @@ struc APPDATA .ev_count_ dd ? ;unused ;+20 .exc_handler dd ? ;+24 .except_mask dd ? ;+28 - .pl0_stack dd ? ;unused ;+32 + .pl0_stack dd ? ;+32 .heap_base dd ? ;+36 .heap_top dd ? ;+40 .cursor dd ? ;+44 @@ -221,7 +221,7 @@ include "core/peload.inc" ; include "core/exports.inc" include "core/string.inc" include "core/v86.inc" ; virtual-8086 manager -include "core/apic.inc" ; Interrupt Controller functions +include "core/apic.inc" ; Interrupt Controller functions ; GUI stuff include "gui/window.inc" @@ -250,6 +250,7 @@ include "sound/playnote.inc" ; player Note for Speaker PC include "video/vesa12.inc" ; Vesa 1.2 functions include "video/vesa20.inc" ; Vesa 2.0 functions +include "video/blitter.inc" ; include "video/vga.inc" ; VGA 16 color functions include "video/cursors.inc" ; cursors functions diff --git a/kernel/branches/Kolibri-acpi/network/eth_drv/drivers/r6040.inc b/kernel/branches/Kolibri-acpi/network/eth_drv/drivers/r6040.inc new file mode 100644 index 0000000000..cf0e2d6f1a --- /dev/null +++ b/kernel/branches/Kolibri-acpi/network/eth_drv/drivers/r6040.inc @@ -0,0 +1,813 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;; R6040 driver for KolibriOS ;; +;; ;; +;; based on R6040.c from linux ;; +;; ;; +;; Written by Asper (asper.85@mail.ru) ;; +;; and hidnplayr (hidnplayr@gmail.com) ;; +;; ;; +;; GNU GENERAL PUBLIC LICENSE ;; +;; Version 2, June 1991 ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + +;******************************************************************** +; Interface +; r6040_reset +; r6040_probe +; r6040_poll +; r6040_transmit +; +; These functions are referenced in ethernet.inc +; +;******************************************************************** + +;; A few user-configurable values. + +TX_RING_SIZE equ 4 +RX_RING_SIZE equ 4 + +; ethernet address length +ETH_ALEN equ 6 +ETH_HLEN equ (2 * ETH_ALEN + 2) +ETH_ZLEN equ 60 ; 60 + 4bytes auto payload for + ; mininmum 64bytes frame length +; system timer frequency +HZ equ 1000 + +; max time out delay time +W_MAX_TIMEOUT equ 0x0FFF + +;; Size of the in-memory receive ring. +RX_BUF_LEN_IDX equ 3 ;; 0==8K, 1==16K, 2==32K, 3==64K +RX_BUF_LEN equ (8192 << RX_BUF_LEN_IDX) + +;-; Size of the Tx bounce buffers -- must be at least (dev->mtu+14+4). +;-TX_BUF_SIZE equ 1536 +;-RX_BUF_SIZE equ 1536 + +;; PCI Tuning Parameters +; Threshold is bytes transferred to chip before transmission starts. +TX_FIFO_THRESH equ 256 ;; In bytes, rounded down to 32 byte units. + +;; The following settings are log_2(bytes)-4: 0 == 16 bytes .. 6==1024. +RX_FIFO_THRESH equ 4 ;; Rx buffer level before first PCI xfer. +RX_DMA_BURST equ 4 ;; Maximum PCI burst, '4' is 256 bytes +TX_DMA_BURST equ 4 + +;; Operational parameters that usually are not changed. +PHY1_ADDR equ 1 ;For MAC1 +PHY2_ADDR equ 3 ;For MAC2 +PHY_MODE equ 0x3100 ;PHY CHIP Register 0 +PHY_CAP equ 0x01E1 ;PHY CHIP Register 4 + +;; Time in jiffies before concluding the transmitter is hung. +TX_TIMEOUT equ ((6000*HZ)/1000) + +R6040_IO_SIZE equ 256 ; RDC MAC I/O Size +MAX_MAC equ 2 ; MAX RDC MAC + +;************************************************************************** +; RDC R6040 Register Definitions +;************************************************************************** +MCR0 equ 0x00 ;Control register 0 +MCR1 equ 0x01 ;Control register 1 +MAC_RST equ 0x0001 ;Reset the MAC +MBCR equ 0x08 ;Bus control +MT_ICR equ 0x0C ;TX interrupt control +MR_ICR equ 0x10 ;RX interrupt control +MTPR equ 0x14 ;TX poll command register +MR_BSR equ 0x18 ;RX buffer size +MR_DCR equ 0x1A ;RX descriptor control +MLSR equ 0x1C ;Last status +MMDIO equ 0x20 ;MDIO control register +MDIO_WRITE equ 0x4000 ;MDIO write +MDIO_READ equ 0x2000 ;MDIO read +MMRD equ 0x24 ;MDIO read data register +MMWD equ 0x28 ;MDIO write data register +MTD_SA0 equ 0x2C ;TX descriptor start address 0 +MTD_SA1 equ 0x30 ;TX descriptor start address 1 +MRD_SA0 equ 0x34 ;RX descriptor start address 0 +MRD_SA1 equ 0x38 ;RX descriptor start address 1 +MISR equ 0x3C ;Status register +MIER equ 0x40 ;INT enable register +MSK_INT equ 0x0000 ;Mask off interrupts +RX_FINISH equ 0x0001 ;RX finished +RX_NO_DESC equ 0x0002 ;No RX descriptor available +RX_FIFO_FULL equ 0x0004 ;RX FIFO full +RX_EARLY equ 0x0008 ;RX early +TX_FINISH equ 0x0010 ;TX finished +TX_EARLY equ 0x0080 ;TX early +EVENT_OVRFL equ 0x0100 ;Event counter overflow +LINK_CHANGED equ 0x0200 ;PHY link changed +ME_CISR equ 0x44 ;Event counter INT status +ME_CIER equ 0x48 ;Event counter INT enable +MR_CNT equ 0x50 ;Successfully received packet counter +ME_CNT0 equ 0x52 ;Event counter 0 +ME_CNT1 equ 0x54 ;Event counter 1 +ME_CNT2 equ 0x56 ;Event counter 2 +ME_CNT3 equ 0x58 ;Event counter 3 +MT_CNT equ 0x5A ;Successfully transmit packet counter +ME_CNT4 equ 0x5C ;Event counter 4 +MP_CNT equ 0x5E ;Pause frame counter register +MAR0 equ 0x60 ;Hash table 0 +MAR1 equ 0x62 ;Hash table 1 +MAR2 equ 0x64 ;Hash table 2 +MAR3 equ 0x66 ;Hash table 3 +MID_0L equ 0x68 ;Multicast address MID0 Low +MID_0M equ 0x6A ;Multicast address MID0 Medium +MID_0H equ 0x6C ;Multicast address MID0 High +MID_1L equ 0x70 ;MID1 Low +MID_1M equ 0x72 ;MID1 Medium +MID_1H equ 0x74 ;MID1 High +MID_2L equ 0x78 ;MID2 Low +MID_2M equ 0x7A ;MID2 Medium +MID_2H equ 0x7C ;MID2 High +MID_3L equ 0x80 ;MID3 Low +MID_3M equ 0x82 ;MID3 Medium +MID_3H equ 0x84 ;MID3 High +PHY_CC equ 0x88 ;PHY status change configuration register +PHY_ST equ 0x8A ;PHY status register +MAC_SM equ 0xAC ;MAC status machine +MAC_ID equ 0xBE ;Identifier register + +MAX_BUF_SIZE equ 0x600 ;1536 + +MBCR_DEFAULT equ 0x012A ;MAC Bus Control Register +MCAST_MAX equ 3 ;Max number multicast addresses to filter + +;Descriptor status +DSC_OWNER_MAC equ 0x8000 ;MAC is the owner of this descriptor +DSC_RX_OK equ 0x4000 ;RX was successfull +DSC_RX_ERR equ 0x0800 ;RX PHY error +DSC_RX_ERR_DRI equ 0x0400 ;RX dribble packet +DSC_RX_ERR_BUF equ 0x0200 ;RX length exceeds buffer size +DSC_RX_ERR_LONG equ 0x0100 ;RX length > maximum packet length +DSC_RX_ERR_RUNT equ 0x0080 ;RX packet length < 64 byte +DSC_RX_ERR_CRC equ 0x0040 ;RX CRC error +DSC_RX_BCAST equ 0x0020 ;RX broadcast (no error) +DSC_RX_MCAST equ 0x0010 ;RX multicast (no error) +DSC_RX_MCH_HIT equ 0x0008 ;RX multicast hit in hash table (no error) +DSC_RX_MIDH_HIT equ 0x0004 ;RX MID table hit (no error) +DSC_RX_IDX_MID_MASK equ 3 ;RX mask for the index of matched MIDx + +;PHY settings +ICPLUS_PHY_ID equ 0x0243 + +RX_INTS equ RX_FIFO_FULL or RX_NO_DESC or RX_FINISH +TX_INTS equ TX_FINISH +INT_MASK equ RX_INTS or TX_INTS + + +r6040_txb equ (eth_data_start) +r6040_rxb equ ((r6040_txb+(MAX_BUF_SIZE*TX_RING_SIZE)+32) and 0xfffffff0) +r6040_tx_ring equ ((r6040_rxb+(MAX_BUF_SIZE*RX_RING_SIZE)+32) and 0xfffffff0) +r6040_rx_ring equ ((r6040_tx_ring+(r6040_x_head.sizeof*TX_RING_SIZE)+32) and 0xfffffff0) + +virtual at ((r6040_rx_ring+(r6040_x_head.sizeof*RX_RING_SIZE)+32) and 0xfffffff0) +r6040_private: + .rx_ring dd ? + .tx_ring dd ? + .cur_rx dw ? + .cur_tx dw ? + .phy_addr dw ? + .phy_mode dw ? + .mcr0 dw ? + .mcr1 dw ? + .switch_sig dw ? +end virtual + +virtual at 0 +r6040_x_head: + .status dw ? ;0-1 + .len dw ? ;2-3 + .buf dd ? ;4-7 + .ndesc dd ? ;8-B + .rev1 dd ? ;C-F + .vbufp dd ? ;10-13 + .vndescp dd ? ;14-17 + .skb_ptr dd ? ;18-1B + .rev2 dd ? ;1C-1F + .sizeof: +end virtual + + + +; Read a word data from PHY Chip +proc r6040_phy_read stdcall, phy_addr:dword, reg:dword + push ecx edx + mov eax, [phy_addr] + shl eax, 8 + add eax, [reg] + add eax, MDIO_READ + mov edx, [io_addr] + add edx, MMDIO + out dx, ax + ;Wait for the read bit to be cleared. + mov ecx, 2048 ;limit + xor eax, eax + .read: + in ax, dx + test ax, MDIO_READ + jz @f + dec ecx + test ecx, ecx + jnz .read + @@: + mov edx, [io_addr] + add edx, MMRD + in ax, dx + and eax, 0xFFFF + pop edx ecx + ret +endp + +; Write a word data to PHY Chip +proc r6040_phy_write stdcall, phy_addr:dword, reg:dword, val:dword + push eax ecx edx + mov eax, [val] + mov edx, [io_addr] + add edx, MMWD + out dx, ax + ;Write the command to the MDIO bus + mov eax, [phy_addr] + shl eax, 8 + add eax, [reg] + add eax, MDIO_WRITE + mov edx, [io_addr] + add edx, MMDIO + out dx, ax + ;Wait for the write bit to be cleared. + mov ecx, 2048 ;limit + xor eax, eax + .write: + in ax, dx + test ax, MDIO_WRITE + jz @f + dec ecx + test ecx, ecx + jnz .write + @@: + pop edx ecx eax + ret +endp + +macro r6040_mdio_write reg, val { + stdcall r6040_phy_read, [io_addr], [r6040_private.phy_addr], reg +} + +macro r6040_mdio_write reg, val { + stdcall r6040_phy_write, [io_addr], [r6040_private.phy_addr], reg, val +} + + +proc r6040_init_ring_desc stdcall, desc_ring:dword, size:dword + push eax ecx esi + mov ecx, [size] + test ecx, ecx + jz .out + + mov esi, [desc_ring] + mov eax, esi + .next_desc: + add eax, r6040_x_head.sizeof - OS_BASE + mov [esi+r6040_x_head.ndesc], eax + add eax, OS_BASE + mov [esi+r6040_x_head.vndescp], eax + mov esi, eax + dec ecx + jnz .next_desc + + sub esi, r6040_x_head.sizeof + mov eax, [desc_ring] + mov [esi+r6040_x_head.vndescp], eax + sub eax, OS_BASE + mov [esi+r6040_x_head.ndesc], eax + .out: + pop esi ecx eax + ret +endp + + + + +r6040_init_rxbufs: + + stdcall r6040_init_ring_desc, r6040_rx_ring, RX_RING_SIZE + + ; Allocate skbs for the rx descriptors + mov esi, r6040_rx_ring + mov ebx, r6040_rxb + mov ecx, RX_RING_SIZE + mov eax, r6040_rx_ring + .next_desc: + mov [esi+r6040_x_head.skb_ptr], ebx + mov [esi+r6040_x_head.buf], ebx + sub [esi+r6040_x_head.buf], OS_BASE + mov [esi+r6040_x_head.status], DSC_OWNER_MAC + + mov eax, [esi+r6040_x_head.vndescp] + mov esi, eax + + add ebx, MAX_BUF_SIZE + dec ecx + jnz .next_desc + + xor eax, eax + .out: + + ret + + +r6040_probe: + + DEBUGF 1, "Probing r6040\n" + + call adjust_pci_device + + + ; If PHY status change register is still set to zero + ; it means the bootloader didn't initialize it + mov edx, [io_addr] + add edx, PHY_CC + in ax, dx + test ax, ax + jnz @f + mov eax, 0x9F07 + out dx, ax + @@: + ; Set MAC address + mov ecx, 3 + mov edi, node_addr + mov edx, [io_addr] + add edx, MID_0L + .mac: + in ax, dx + stosw + add edx, 2 + dec ecx + jnz .mac + ; Some bootloaders/BIOSes do not initialize + ; MAC address, warn about that + and eax, 0xFF + or eax, [node_addr] + test eax, eax + jnz @f + DEBUGF 1, "K : MAC address not initialized\n" ;, generating random" + ;Asper: Add here generate function call! + ; Temporary workaround: init by constant adress + mov dword [node_addr], 0x00006000 + mov word [node_addr+4], 0x0001 + @@: + ; Init RDC private data + mov [r6040_private.mcr0], 0x1002 + ;mov [r6040_private.phy_addr], 1 ; Asper: Only one network card is supported now. + mov [r6040_private.switch_sig], 0 + + ; Check the vendor ID on the PHY, if 0xFFFF assume none attached + stdcall r6040_phy_read, 1, 2 + cmp ax, 0xFFFF + jne @f + DEBUGF 1, "K : Failed to detect an attached PHY\n" ;, generating random" + mov eax, -1 + ret + @@: + + ; Set MAC address + call r6040_mac_address + + + ; Initialize and alloc RX/TX buffers + stdcall r6040_init_ring_desc, r6040_tx_ring, TX_RING_SIZE + call r6040_init_rxbufs ;r6040_alloc_rxbufs + test eax, eax + jnz .out + + ; Read the PHY ID + mov [r6040_private.phy_mode], 0x8000 + stdcall r6040_phy_read, 0, 2 + mov [r6040_private.switch_sig], ax + cmp ax, ICPLUS_PHY_ID + jne @f + stdcall r6040_phy_write, 29, 31, 0x175C ; Enable registers + jmp .phy_readen + @@: + + ; PHY Mode Check + movzx eax, [r6040_private.phy_addr] + stdcall r6040_phy_write, eax, 4, PHY_CAP + stdcall r6040_phy_write, eax, 0, PHY_MODE +; if PHY_MODE = 0x3100 + call r6040_phy_mode_chk + mov [r6040_private.phy_mode], ax + jmp .phy_readen +; end if +; if not (PHY_MODE and 0x0100) + mov [r6040_private.phy_mode], 0 +; end if + .phy_readen: + + ; Set duplex mode + mov ax, [r6040_private.phy_mode] + or [r6040_private.mcr0], ax + + ; improve performance (by RDC guys) + stdcall r6040_phy_read, 30, 17 + or ax, 0x4000 + stdcall r6040_phy_write, 30, 17, eax + + stdcall r6040_phy_read, 30, 17 + xor ax, -1 + or ax, 0x2000 + xor ax, -1 + stdcall r6040_phy_write, 30, 17, eax + + stdcall r6040_phy_write, 0, 19, 0x0000 + stdcall r6040_phy_write, 0, 30, 0x01F0 + + ; Initialize all Mac registers + call r6040_reset + + xor eax, eax + .out: + ret + + + + + + +align 4 +r6040_reset: + + DEBUGF 1, "Resetting r6040\n" + + push eax ecx edx + ; Mask off Interrupt + mov eax, MSK_INT + mov edx, [io_addr] + add edx, MIER + out dx, ax + + ;Reset RDC MAC + mov eax, MAC_RST + mov edx, [io_addr] + add edx, MCR1 + out dx, ax + + mov ecx, 2048 ;limit + .read: + in ax, dx + test ax, 0x1 + jnz @f + dec ecx + test ecx, ecx + jnz .read + @@: + ;Reset internal state machine + mov ax, 2 + mov edx, [io_addr] + add edx, MAC_SM + out dx, ax + xor ax, ax + out dx, ax + mov esi, 5 + call delay_ms + + ;MAC Bus Control Register + mov ax, MBCR_DEFAULT + mov edx, [io_addr] + add edx, MBCR + out dx, ax + + ;Buffer Size Register + mov ax, MAX_BUF_SIZE + mov edx, [io_addr] + add edx, MR_BSR + out dx, ax + + ;Write TX ring start address + mov eax, r6040_tx_ring - OS_BASE ;Asper: Maybe we can just write dword? Hidnplayr: better use word, as described in datasheet. + mov edx, [io_addr] + add edx, MTD_SA0 + out dx, ax + shr eax, 16 + add edx, MTD_SA1 - MTD_SA0 + out dx, ax + + ;Write RX ring start address + mov eax, r6040_rx_ring - OS_BASE ;Asper: Maybe we can just write dword? + mov edx, [io_addr] + add edx, MRD_SA0 + out dx, ax + shr eax, 16 + add edx, MRD_SA1 - MRD_SA0 + out dx, ax + + ;Set interrupt waiting time and packet numbers + xor ax, ax + mov edx, [io_addr] + add edx, MT_ICR + out dx, ax + + ;Asper: ~ Disable ints ;Enable interrupts + ;mov ax, MSK_INT ;INT_MASK ;Asper ~ + ;mov edx, [io_addr] + ;add edx, MIER + ;out dx, ax + + ;Enable TX and RX + mov ax, [r6040_private.mcr0] + or ax, 0x0002 + mov edx, [io_addr] + out dx, ax + + ;Let TX poll the descriptors + ;we may got called by r6040_tx_timeout which has left + ;some unset tx buffers + xor ax, ax + inc ax + mov edx, [io_addr] + add edx, MTPR + out dx, ax + + pop edx ecx eax + + DEBUGF 1, "reset ok!\n" + + ; Indicate that we have successfully reset the card + mov eax, [pci_data] + mov [eth_status], eax + ret + + + +proc r6040_tx_timeout + push eax edx + ;... + inc [stats.tx_errors] + ;Reset MAC and re-init all registers + call r6040_init_mac_regs + pop edx eax + ret +endp + +proc r6040_get_stats + push eax edx + mov edx, [io_addr] + add edx, ME_CNT1 + in al, dx + add [stats.rx_crc_errors], al + mov edx, [io_addr] + add edx, ME_CNT0 + in al, dx + add [stats.multicast], al + pop edx eax + ret +endp + +;... + +proc r6040_phy_mode_chk + push ebx + ;PHY Link Status Check + movzx eax, [r6040_private.phy_addr] + stdcall r6040_phy_read, eax, 1 + test eax, 0x4 + jnz @f + mov eax, 0x8000 ;Link Failed, full duplex + @@: + ;PHY Chip Auto-Negotiation Status + movzx eax, [r6040_private.phy_addr] + stdcall r6040_phy_read, eax, 1 + test eax, 0x0020 + jz .force_mode + ;Auto Negotuiation Mode + movzx eax, [r6040_private.phy_addr] + stdcall r6040_phy_read, eax, 5 + mov ebx, eax + movzx eax, [r6040_private.phy_addr] + stdcall r6040_phy_read, eax, 4 + and eax, ebx + test eax, 0x140 + jz .ret_0 + jmp .ret_0x8000 + .force_mode: + ;Force Mode + movzx eax, [r6040_private.phy_addr] + stdcall r6040_phy_read, eax, 0 + test eax, 0x100 + jz .ret_0 + .ret_0x8000: + mov eax, 0x8000 + pop ebx + ret + .ret_0: + xor eax, eax + pop ebx + ret +endp + + + +;*************************************************************************** +; Function +; r6040_rx +; Description +; polls card to see if there is a packet waiting +; +; Currently only supports one descriptor per packet, if packet is fragmented +; between multiple descriptors you will lose part of the packet +;*************************************************************************** +r6040_poll: + push ebx ecx esi edi + + xor eax, eax + mov [eth_rx_data_len], ax + + movzx eax, [r6040_private.cur_rx] + mov ebx, eax + shl ebx, 5 + + mov cx, [ebx+r6040_rx_ring+r6040_x_head.status] ; Read the descriptor status + test cx, DSC_OWNER_MAC + jnz .out + + test cx, DSC_RX_ERR ; Global error status set + jz .no_dsc_rx_err + ;... + jmp .out + + .no_dsc_rx_err: + ; Packet successfully received + movzx ecx, [ebx+r6040_rx_ring+r6040_x_head.len] + and ecx, 0xFFF + sub ecx, 4 ; Do not count the CRC + mov [eth_rx_data_len], cx + mov esi, [ebx+r6040_rx_ring+r6040_x_head.skb_ptr] + + push ecx + shr ecx, 2 + mov edi, Ether_buffer + cld + rep movsd + pop ecx + and ecx, 3 + rep movsb + + or [ebx+r6040_rx_ring+r6040_x_head.status], DSC_OWNER_MAC + + inc [r6040_private.cur_rx] + and [r6040_private.cur_rx], RX_RING_SIZE-1 + + xor eax, eax + .out: + pop edi esi ecx ebx + ret + + + +;*************************************************************************** +; Function +; r6040_transmit +; Description +; Transmits a packet of data via the ethernet card +; Pointer to 48 bit destination address in edi +; Type of packet in bx +; size of packet in ecx +; pointer to packet data in esi +; +;*************************************************************************** +r6040_transmit: + cmp ecx, MAX_BUF_SIZE + jg .out ; packet is too long + + push edi esi ebx ecx + + movzx eax, [r6040_private.cur_tx] + shl eax, 5 + +; DEBUGF 1,"R6040: TX buffer status: 0x%x, eax=%u\n", [eax + r6040_tx_ring + r6040_x_head.status]:4, eax + + test [r6040_tx_ring + eax + r6040_x_head.status], 0x8000 ; check if buffer is available + jz .l3 + + push ecx esi + mov ecx, [timer_ticks] + add ecx, 100 + .l2: + test [r6040_tx_ring + eax + r6040_x_head.status], 0x8000 + jz .l5 + cmp ecx, [timer_ticks] + jb .l4 + mov esi, 10 + call delay_ms + jmp .l2 + + .l4: + pop esi ecx + DEBUGF 1,"R6040: Send timeout\n" + jmp .out + + .l5: + pop esi ecx + .l3: + push eax + + mov esi, edi + +; point to the current tx buffer + movzx edi, [r6040_private.cur_tx] + imul edi, MAX_BUF_SIZE + add edi, r6040_txb + lea eax, [edi - OS_BASE] ; real buffer address in eax + +; copy destination address + movsd + movsw +; copy source address + mov esi, node_addr + movsd + movsw +; copy packet type + mov [edi], bx + add edi, 2 + + mov esi, [esp+8+4] + mov ecx, [esp+4] +; copy the packet data + push ecx + shr ecx,2 + rep movsd + pop ecx + and ecx,3 + rep movsb + + pop edi + + mov ecx, [esp] + add ecx, ETH_HLEN + cmp cx, ETH_ZLEN + jae @f + mov cx, ETH_ZLEN + @@: + + mov [r6040_tx_ring + edi + r6040_x_head.len], cx + mov [r6040_tx_ring + edi + r6040_x_head.buf], eax + mov [r6040_tx_ring + edi + r6040_x_head.status], 0x8000 + + ; Trigger the MAC to check the TX descriptor + mov ax, 0x01 + mov edx, [io_addr] + add edx, MTPR + out dx, ax + + inc [r6040_private.cur_tx] + and [r6040_private.cur_tx], TX_RING_SIZE-1 + xor eax, eax + + pop ecx ebx esi edi + .out: + ret + + + +r6040_mac_address: + push eax ecx edx esi edi + ; MAC operation register + mov ax, 1 + mov edx, [io_addr] + add edx, MCR1 + out dx, ax + ; Reset MAC + mov ax, 2 + mov edx, [io_addr] + add edx, MAC_SM + out dx, ax + ; Reset internal state machine + xor ax, ax + out dx, ax + mov esi, 5 + call delay_ms + + ; Restore MAC Address + mov ecx, 3 + mov edi, node_addr + mov edx, [io_addr] + add edx, MID_0L + .mac: + in ax, dx + stosw + add edx, 2 + dec ecx + jnz .mac + + pop edi esi edx ecx eax + ret + diff --git a/kernel/branches/Kolibri-acpi/network/eth_drv/drivers/rtl8139.inc b/kernel/branches/Kolibri-acpi/network/eth_drv/drivers/rtl8139.inc index e63169f84e..a6af3f8999 100644 --- a/kernel/branches/Kolibri-acpi/network/eth_drv/drivers/rtl8139.inc +++ b/kernel/branches/Kolibri-acpi/network/eth_drv/drivers/rtl8139.inc @@ -323,14 +323,14 @@ rtl8139_reset: out dx, al ; 32k Rxbuffer, unlimited dma burst, no wrapping, no rx threshold ; accept broadcast packets, accept physical match packets - mov ax, RTL8139_RX_CONFIG + mov eax, RTL8139_RX_CONFIG add edx, RTL8139_REG_RXCONFIG - RTL8139_REG_COMMAND - out dx, ax + out dx, eax ; 1024 bytes DMA burst, total retries = 16 + 8 * 16 = 144 - mov ax, (RTL8139_TX_MXDMA shl RTL8139_BIT_TX_MXDMA) \ + mov eax, (RTL8139_TX_MXDMA shl RTL8139_BIT_TX_MXDMA) \ or (RTL8139_TXRR shl RTL8139_BIT_TXRR) add edx, RTL8139_REG_TXCONFIG - RTL8139_REG_RXCONFIG - out dx, ax + out dx, eax ; enable auto negotiation add edx, RTL8139_REG_BMCR - RTL8139_REG_TXCONFIG in ax, dx diff --git a/kernel/branches/Kolibri-acpi/network/eth_drv/ethernet.inc b/kernel/branches/Kolibri-acpi/network/eth_drv/ethernet.inc index d113aaecb0..5a8e4772d0 100644 --- a/kernel/branches/Kolibri-acpi/network/eth_drv/ethernet.inc +++ b/kernel/branches/Kolibri-acpi/network/eth_drv/ethernet.inc @@ -49,7 +49,7 @@ struc ETH_FRAME .SrcMAC dp ? ;source MAC-address [6 bytes] .Type dw ? ;type of the upper-layer protocol [2 bytes] .Data db ? ;data [46-1500 bytes] -} + } virtual at Ether_buffer ETH_FRAME ETH_FRAME @@ -103,6 +103,7 @@ include "drivers/sis900.inc" include "drivers/pcnet32.inc" include "drivers/rtl8169.inc" include "drivers/forcedeth.inc" +include "drivers/r6040.inc" ; PCICards ; ======== @@ -128,25 +129,25 @@ dd 0x24498086, I8255x_probe, I8255x_reset, I8255x_poll, I8255x_transmit, 0 dd 0x802910ec, rtl8029_probe, rtl8029_reset, rtl8029_poll, rtl8029_transmit, 0 -dd 0x813910ec, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable ; tested by hidnplayr: works ok -dd 0x813810ec, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x12111113, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable ; tested by hidnplayr: works ok -dd 0x13601500, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x13604033, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x13001186, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x13401186, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0xab0613d1, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0xa1171259, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0xa11e1259, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0xab0614ea, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0xab0714ea, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x123411db, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x91301432, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x101202ac, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x0106018a, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x1211126c, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x81391743, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable -dd 0x8139021b, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x813910ec, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x813810ec, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x12111113, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x13601500, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x13604033, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x13001186, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x13401186, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0xab0613d1, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0xa1171259, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0xa11e1259, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0xab0614ea, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0xab0714ea, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x123411db, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x91301432, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x101202ac, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x0106018a, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x1211126c, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x81391743, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable +;dd 0x8139021b, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable dd 0x816810ec, rtl8169_probe, rtl8169_reset, rtl8169_poll, rtl8169_transmit, 0 dd 0x816910ec, rtl8169_probe, rtl8169_reset, rtl8169_poll, rtl8169_transmit, 0 @@ -188,58 +189,54 @@ dd 0x656410b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0 dd 0x450010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0 dd 0x09001039, SIS900_probe, SIS900_reset, SIS900_poll, SIS900_transmit, 0 +dd 0x70161039, SIS900_probe, SIS900_reset, SIS900_poll, SIS900_transmit, 0 dd 0x20001022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0 dd 0x26251022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0 dd 0x20011022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0 -;dd 0x08031516, mtd80x_probe, mtd80x_reset, mtd80x_poll, mtd80x_transmit, mtd80x_cable +dd 0x006610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; nVidia Corporation nForce2 Ethernet Controller +dd 0x01c310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x00D610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x008610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x008c10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x00e610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x00df10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x005610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x005710de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x003710de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x003810de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x026810de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x026910de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x037210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x037310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x03e510de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x03e610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x03ee10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x03ef10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x045010de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x045110de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x045210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x045310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x054c10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x054d10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x054e10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x054f10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x07dc10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x07dd10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x07de10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x07df10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x076010de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; MCP77 Ethernet Controller +dd 0x076110de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x076210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x076310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x0ab010de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x0ab110de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x0ab210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x0ab310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x0d7d10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -; following cards are untested -dd 0x70161039, SIS900_probe, SIS900_reset, SIS900_poll, SIS900_transmit, 0 -;dd 0x08001516, mtd80x_probe, mtd80x_reset, mtd80x_poll, mtd80x_transmit, mtd80x_cable -;dd 0x08911516, mtd80x_probe, mtd80x_reset, mtd80x_poll, mtd80x_transmit, mtd80x_cable - -dd 0x006610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; nVidia Corporation nForce2 Ethernet Controller -dd 0x01c310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x00D610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x008610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x008c10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x00e610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x00df10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x005610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x005710de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x003710de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x003810de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x026810de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x026910de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x037210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x037310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x03e510de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x03e610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x03ee10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x03ef10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x045010de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x045110de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x045210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x045310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x054c10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x054d10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x054e10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x054f10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x07dc10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x07dd10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x07de10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x07df10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x076010de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; MCP77 Ethernet Controller -dd 0x076110de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x076210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x076310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x0ab010de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x0ab110de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x0ab210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x0ab310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested -dd 0x0d7d10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested +dd 0x604017F3, r6040_probe, r6040_reset, r6040_poll, r6040_transmit, 0 rb PCICARDS_ENTRY_SIZE ; end of list marker, do not remove endg diff --git a/kernel/branches/Kolibri-acpi/video/blitter.inc b/kernel/branches/Kolibri-acpi/video/blitter.inc new file mode 100644 index 0000000000..9fed049aa4 --- /dev/null +++ b/kernel/branches/Kolibri-acpi/video/blitter.inc @@ -0,0 +1,444 @@ + + + +struc BLITTER +{ + .dc.xmin rd 1 ; 0 + .dc.ymin rd 1 ; 4 + .dc.xmax rd 1 ; 8 + .dc.ymax rd 1 ; 12 + + .sc: + .sc.xmin rd 1 ; 16 + .sc.ymin rd 1 ; 20 + .sc.xmax rd 1 ; 24 + .sc.ymax rd 1 ; 28 + + .dst_x rd 1 ; 32 + .dst_y rd 1 ; 36 + .src_x rd 1 ; 40 + .src_y rd 1 ; 44 + .w rd 1 ; 48 + .h rd 1 ; 52 + + .bitmap rd 1 ; 56 + .stride rd 1 ; 60 + +} + +virtual at 0 + BLITTER BLITTER +end virtual + + +align 4 + +__L1OutCode: + push ebx + mov ebx, 8 + cmp edx, [eax] + jl .L2 + xor ebx, ebx + cmp edx, [eax+8] + setg bl + sal ebx, 2 +.L2: + cmp ecx, [eax+4] + jge .L3 + or ebx, 1 + jmp .L4 + +.L3: + cmp ecx, [eax+12] + jle .L4 + or ebx, 2 +.L4: + mov eax, ebx + pop ebx + ret + +align 4 +block_clip: + push ebp + push edi + push esi + push ebx + sub esp, 4 + + mov ebx, eax + mov [esp], edx + mov ebp, ecx + mov ecx, [ecx] + mov edx, [edx] + call __L1OutCode + + mov esi, eax + mov edx, [esp+28] + mov ecx, [edx] +.L21: + mov eax, [esp+24] + mov edx, [eax] + mov eax, ebx + call __L1OutCode + + mov edi, eax +.L20: + mov eax, edi + and eax, esi + jne .L9 + cmp esi, edi + je .L9 + test esi, esi + jne .L10 + test edi, 1 + je .L11 + mov eax, [ebx+4] + jmp .L25 +.L11: + test edi, 2 + je .L13 + mov eax, [ebx+12] +.L25: + mov edx, [esp+28] + jmp .L22 +.L13: + test edi, 4 + je .L14 + mov eax, [ebx+8] + jmp .L26 +.L14: + and edi, 8 + je .L12 + mov eax, [ebx] +.L26: + mov edx, [esp+24] +.L22: + mov [edx], eax +.L12: + mov eax, [esp+28] + mov ecx, [eax] + jmp .L21 +.L10: + test esi, 1 + je .L16 + mov eax, [ebx+4] + jmp .L23 +.L16: + test esi, 2 + je .L18 + mov eax, [ebx+12] +.L23: + mov [ebp+0], eax + jmp .L17 +.L18: + test esi, 4 + je .L19 + mov eax, [ebx+8] + jmp .L24 +.L19: + and esi, 8 + je .L17 + mov eax, [ebx] +.L24: + mov edx, [esp] + mov [edx], eax +.L17: + mov ecx, [ebp+0] + mov eax, [esp] + mov edx, [eax] + mov eax, ebx + call __L1OutCode + mov esi, eax + jmp .L20 +.L9: + add esp, 4 + pop ebx + pop esi + pop edi + pop ebp + ret + +align 4 +blit_clip: + +.sx0 equ 36 +.sy0 equ 32 +.sx1 equ 28 +.sy1 equ 24 + +.dx0 equ 20 +.dy0 equ 16 +.dx1 equ 12 +.dy1 equ 8 + + + push edi + push esi + push ebx + sub esp, 40 + + mov ebx, ecx + mov edx, [ecx+BLITTER.src_x] + mov [esp+.sx0], edx + mov eax, [ecx+BLITTER.src_y] + mov [esp+.sy0], eax + add edx, [ecx+BLITTER.w] + dec edx + mov [esp+.sx1], edx + add eax, [ecx+BLITTER.h] + dec eax + mov [esp+.sy1], eax + + lea ecx, [esp+.sy0] + lea edx, [esp+.sx0] + lea eax, [ebx+BLITTER.sc] + lea esi, [esp+.sy1] + + mov [esp+4], esi + lea esi, [esp+.sx1] + mov [esp], esi + call block_clip + + mov esi, 1 + test eax, eax + jne .L28 + + mov edi, [esp+.sx0] + mov edx, [ebx+BLITTER.dst_x] + add edx, edi + sub edx, [ebx+BLITTER.src_x] + mov [esp+.dx0], edx + + mov ecx, [esp+.sy0] + mov eax, [ebx+BLITTER.dst_y] + add eax, ecx + sub eax, [ebx+BLITTER.src_y] + mov [esp+.dy0], eax + sub edx, edi + add edx, [esp+.sx1] + mov [esp+.dx1], edx + + sub eax, ecx + add eax, [esp+.sy1] + mov [esp+.dy1], eax + + lea ecx, [esp+.dy0] + lea edx, [esp+.dx0] + lea eax, [esp+.dy1] + mov [esp+4], eax + lea eax, [esp+.dx1] + mov [esp], eax + mov eax, ebx + call block_clip + test eax, eax + jne .L28 + + mov edx, [esp+.dx0] + mov eax, [esp+.dx1] + inc eax + sub eax, edx + mov [ebx+BLITTER.w], eax + + mov eax, [esp+.dy0] + mov ecx, [esp+.dy1] + inc ecx + sub ecx, eax + mov [ebx+BLITTER.h], ecx + + mov ecx, [ebx+BLITTER.src_x] + add ecx, edx + sub ecx, [ebx+BLITTER.dst_x] + mov [ebx+BLITTER.src_x], ecx + + mov ecx, [ebx+BLITTER.src_y] + add ecx, eax + sub ecx, [ebx+BLITTER.dst_y] + mov [ebx+BLITTER.src_y], ecx + mov [ebx+BLITTER.dst_x], edx + mov [ebx+BLITTER.dst_y], eax + xor esi, esi +.L28: + mov eax, esi + add esp, 40 + pop ebx + pop esi + pop edi + + +purge .sx0 +purge .sy0 +purge .sx1 +purge .sy1 + +purge .dx0 +purge .dy0 +purge .dx1 +purge .dy1 + + ret + + + +align 4 + +blit_32: + push ebp + push edi + push esi + push ebx + sub esp, 72 + + mov eax, [TASK_BASE] + mov ebx, [eax-twdw + WDATA.box.width] + mov edx, [eax-twdw + WDATA.box.height] + + xor eax, eax + + mov [esp+BLITTER.dc.xmin], eax + mov [esp+BLITTER.dc.ymin], eax + mov [esp+BLITTER.dc.xmax], ebx + mov [esp+BLITTER.dc.ymax], edx + + mov [esp+BLITTER.sc.xmin], eax + mov [esp+BLITTER.sc.ymin], eax + mov eax, [ecx+24] + dec eax + mov [esp+BLITTER.sc.xmax], eax + mov eax, [ecx+28] + dec eax + mov [esp+BLITTER.sc.ymax], eax + + mov eax, [ecx] + mov [esp+BLITTER.dst_x], eax + mov eax, [ecx+4] + mov [esp+BLITTER.dst_y], eax + + mov eax, [ecx+16] + mov [esp+BLITTER.src_x], eax + mov eax, [ecx+20] + mov [esp+BLITTER.src_y], eax + mov eax, [ecx+8] + mov [esp+BLITTER.w], eax + mov eax, [ecx+12] + mov [esp+BLITTER.h], eax + + + mov eax, [ecx+32] + mov [esp+56], eax + mov eax, [ecx+36] + mov [esp+60], eax + + mov ecx, esp + call blit_clip + test eax, eax + jne .L57 + + inc [mouse_pause] + call [_display.disable_mouse] + + mov eax, [TASK_BASE] + + mov ebx, [esp+BLITTER.dst_x] + mov ebp, [esp+BLITTER.dst_y] + add ebx, [eax-twdw + WDATA.box.left] + add ebp, [eax-twdw + WDATA.box.top] + mov edi, ebp + + imul edi, [_display.pitch] + imul ebp, [_display.width] + add ebp, ebx + add ebp, [_WinMapAddress] + + mov eax, [esp+BLITTER.src_y] + imul eax, [esp+BLITTER.stride] + mov esi, [esp+BLITTER.src_x] + lea esi, [eax+esi*4] + add esi, [esp+BLITTER.bitmap] + + mov ecx, [esp+BLITTER.h] + mov edx, [esp+BLITTER.w] + + test ecx, ecx ;FIXME check clipping + jz .L57 + + test edx, edx + jz .L57 + + cmp [_display.bpp], 32 + jne .core_24 + + lea edi, [edi+ebx*4] + + mov ebx, [CURRENT_TASK] + +align 4 +.outer32: + xor ecx, ecx + +align 4 +.inner32: + cmp [ebp+ecx], bl + jne @F + + mov eax, [esi+ecx*4] + mov [LFB_BASE+edi+ecx*4], eax +@@: + inc ecx + dec edx + jnz .inner32 + + add esi, [esp+BLITTER.stride] + add edi, [_display.pitch] + add ebp, [_display.width] + + mov edx, [esp+BLITTER.w] + dec [esp+BLITTER.h] + jnz .outer32 + +.done: + dec [mouse_pause] + call [draw_pointer] +.L57: + add esp, 72 + pop ebx + pop esi + pop edi + pop ebp + ret + +.core_24: + lea ebx, [ebx+ebx*2] + lea edi, [LFB_BASE+edi+ebx] + mov ebx, [CURRENT_TASK] + +align 4 +.outer24: + mov [esp+64], edi + xor ecx, ecx + +align 4 +.inner24: + cmp [ebp+ecx], bl + jne @F + + mov eax, [esi+ecx*4] + + lea edi, [edi+ecx*2] + mov [edi+ecx], ax + shr eax, 16 + mov [edi+ecx+2], al +@@: + mov edi, [esp+64] + inc ecx + dec edx + jnz .inner24 + + add esi, [esp+BLITTER.stride] + add edi, [_display.pitch] + add ebp, [_display.width] + + mov edx, [esp+BLITTER.w] + dec [esp+BLITTER.h] + jnz .outer24 + + jmp .done