-Fixed build.bat for NET branch

-Removed some unrelated files
-updates in telnet

git-svn-id: svn://kolibrios.org@2314 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2011-11-13 15:19:27 +00:00
parent dfbe402a16
commit 61a835651a
14 changed files with 117 additions and 1480 deletions

View File

@ -2,12 +2,12 @@ format MS COFF
public @EXPORT as 'EXPORTS'
include '../struct.inc'
include '../proc32.inc'
include '../macros.inc'
include '../../struct.inc'
include '../../proc32.inc'
include '../../macros.inc'
purge section,mov,add,sub
include '../network.inc'
include '../../network.inc'
section '.flat' code readable align 16

View File

@ -144,4 +144,45 @@ db 'R6040',0
dd 0x604017F3
dd 0x0
db 'i8254x'
dd 0x10008086 ; 82542 (Fiber)
dd 0x10018086 ; 82543GC (Fiber)
dd 0x10048086 ; 82543GC (Copper)
dd 0x10088086 ; 82544EI (Copper)
dd 0x10098086 ; 82544EI (Fiber)
dd 0x100A8086 ; 82540EM
dd 0x100C8086 ; 82544GC (Copper)
dd 0x100D8086 ; 82544GC (LOM)
dd 0x100E8086 ; 82540EM
dd 0x100F8086 ; 82545EM (Copper)
dd 0x10108086 ; 82546EB (Copper)
dd 0x10118086 ; 82545EM (Fiber)
dd 0x10128086 ; 82546EB (Fiber)
dd 0x10138086 ; 82541EI
dd 0x10148086 ; 82541ER
dd 0x10158086 ; 82540EM (LOM)
dd 0x10168086 ; 82540EP (Mobile)
dd 0x10178086 ; 82540EP
dd 0x10188086 ; 82541EI
dd 0x10198086 ; 82547EI
dd 0x101a8086 ; 82547EI (Mobile)
dd 0x101d8086 ; 82546EB
dd 0x101e8086 ; 82540EP (Mobile)
dd 0x10268086 ; 82545GM
dd 0x10278086 ; 82545GM
dd 0x10288086 ; 82545GM
dd 0x105b8086 ; 82546GB (Copper)
dd 0x10758086 ; 82547GI
dd 0x10768086 ; 82541GI
dd 0x10778086 ; 82541GI
dd 0x10788086 ; 82541ER
dd 0x10798086 ; 82546GB
dd 0x107a8086 ; 82546GB
dd 0x107b8086 ; 82546GB
dd 0x107c8086 ; 82541PI
dd 0x10b58086 ; 82546GB (Copper)
dd 0x11078086 ; 82544EI
dd 0x11128086 ; 82544GC
dd 0x0
dd 0x0 ; driverlist end

View File

@ -10,7 +10,7 @@ use32
dd 0 ; path
BUFFERSIZE equ 1500
BUFFERSIZE equ 4096
; useful includes
include '../macros.inc'
purge mov,add,sub
@ -116,40 +116,56 @@ mainloop:
je mainloop
mov esi, buffer_ptr
mov byte [esi + eax], 0
lea edi, [esi + eax]
mov byte [edi], 0
@@:
.scan_cmd:
cmp byte [esi], 0xff ; Interpret As Command
jne @f
jne .no_cmd
; TODO: parse options, for now, we will reply with 'WONT' to everything
mov byte [esi + 1], 252 ; WONT
add esi, 3 ; a command is always 3 bytes
jmp @r
jmp .scan_cmd
.no_cmd:
@@:
cmp byte [esi], 0x1b ; escape character
jne @f
cmp word [esi+1], 0x485b ; move cursor to beginning
jne @f
push 0
push 0
call [con_set_cursor_pos]
add esi, 3
@@:
push esi
cmp esi, buffer_ptr
je .nocommands
je .print_it
push edi
mov edx, buffer_ptr
sub esi, buffer_ptr
xor edi, edi
mcall send, [socketnum]
pop edi
.nocommands:
.print_it:
mov esi, [esp]
@@:
cmp esi, edi
jge .last_print
cmp byte [esi], 0x1b ; escape character
inc esi
jne @f
cmp word [esi], 0x485b ; move cursor to beginning
jne @f
mov byte [esi - 1], 0
call [con_write_asciiz]
push 0
push 0
call [con_set_cursor_pos]
inc esi
inc esi
push esi
jmp @r
.last_print:
call [con_write_asciiz]
jmp mainloop
@ -221,7 +237,7 @@ import console, \
i_end:
socketnum dd ?
buffer_ptr rb BUFFERSIZE
buffer_ptr rb BUFFERSIZE+1
send_data rb 100
s rb 256

View File

@ -1,8 +1,10 @@
@echo off
cls
set languages=en ru ge et
set drivers=sound sis infinity ensoniq ps2mouse com_mouse uart ati2d vmode
set targets=all kernel drivers skins clean
set languages=en
set drivers=3c59x dec21x4x i8255x mtd80x pcnet32 r6040 rtl8029 rtl8139 rtl8169 sis900
set apps=arpcfg icmp netcfg netstat nslookup synergyc tcpserv telnet tftpc zeroconf
set libs=network
set targets=all kernel apps libs drivers clean
call :Check_Target %1
for %%a in (all kernel) do if %%a==%target% call :Check_Lang %2
@ -58,8 +60,37 @@ goto :eof
:Target_all
call :Target_kernel
call :Target_apps
call :Target_libs
call :Target_drivers
call :Target_skins
goto :eof
:Target_apps
echo *** building applications ...
if not exist bin\apps mkdir bin\apps
cd applications
for %%a in (%apps%) do (
fasm -m 65536 %%a\%%a.asm ..\bin\apps\%%a
if not %errorlevel%==0 goto :Error_FasmFailed
)
cd ..
goto :eof
:Target_libs
echo *** building libraries ...
if not exist bin\lib mkdir bin\lib
cd applications\libraries
for %%a in (%libs%) do (
fasm -m 65536 %%a\%%a.asm ..\..\bin\libs\%%a.obj
if not %errorlevel%==0 goto :Error_FasmFailed
)
cd ..\..
goto :eof
@ -73,7 +104,6 @@ goto :eof
if not %errorlevel%==0 goto :Error_FasmFailed
)
cd ..
move bin\drivers\vmode.obj bin\drivers\vmode.mdr
kpack >nul 2>&1
@ -103,17 +133,6 @@ if "%res%"=="y" (
)
goto :eof
:Target_skins
echo *** building skins ...
if not exist bin\skins mkdir bin\skins
cd skin
fasm -m 65536 default.asm ..\bin\skins\default.skn
if not %errorlevel%==0 goto :Error_FasmFailed
cd ..
goto :eof
:Target_clean
echo *** cleaning ...
rmdir /S /Q bin

View File

@ -1,50 +0,0 @@
;flags------------------------------------------------------------
DEBUG equ 1 ;show messages at debug board
use_cli_sti equ 1 ;driver become more stable (theoretically)
;constants--------------------------------------------------------
API_VERSION equ 0 ;debug
OS_BASE equ 0x80000000
new_app_base equ 0x0
PROC_BASE equ (OS_BASE+0x080000)
SB16Buffer equ (OS_BASE+0x2A0000)
SB16_Status equ (OS_BASE+0x2B0000)
DMAPage equ ((SB16Buffer-OS_BASE) shr 16)
SB16Buffer0 equ SB16Buffer
SB16Buffer1 equ (SB16Buffer+16384)
SB16Buffer2 equ (SB16Buffer+(2*16384))
SB16Buffer3 equ (SB16Buffer+(3*16384))
sb_irq_num equ 5 ;default values for SB16, may be overrided by autodetect
sb_dma_num equ 5 ;default values for SB16, may be overrided by autodetect
small_buffer equ 32768
full_buffer equ 65536
sb_buffer_size equ small_buffer ; FIX ring buffer overlapped events issue; full_buffer
__supported_buffer_sizes fix <small_buffer, full_buffer>
if ~(sb_buffer_size in __supported_buffer_sizes)
display 13,10,'unsupported buffer size was selected, check config.inc',13,10
stop
end if
sb_out_rate equ 48000
;time constant for cards older than SB16
sb_tc equ (256-(1000000/(sb_out_rate*2)))
SRV_GETVERSION equ 0
DEV_PLAY equ 1
DEV_STOP equ 2
DEV_CALLBACK equ 3
DEV_SET_BUFF equ 4
DEV_NOTIFY equ 5
DEV_SET_MASTERVOL equ 6
DEV_GET_MASTERVOL equ 7
DEV_GET_INFO equ 8
DRV_ENTRY equ 1
DRV_EXIT equ -1

View File

@ -1,72 +0,0 @@
Nable 21.05.2008.
This driver is my contribution (or donation) to KolibriOS. This is provided
AS IS in hope it'll be useful, but WITHOUT ANY WARRANTY! No responcibility
for any hardware damage or data loss. Use at your own risk!
;-------------------------------------------------------------------------------
;Changelog:
;-------------------------------------------------------------------------------
v0.2 - DEV_SET(GET)_MASTERVOL functions are unlocked and implemented.
v0.1 - first release.
;-------------------------------------------------------------------------------
;Tiny FAQ for sound driver by Nable for SB16 sound card.
;-------------------------------------------------------------------------------
;What is it?--------------------------------------------------------------------
As you may know there is a sound subsystem ('INFINITY') in KolibriOS.
This subsystem includes mixer and separate interface for soundplayer
program and driver, so player application don't need to know what soundcard
is installed and how to cope with it, all work with card do the driver.
Before this time there were drivers only for AC97 integrated sound, but I
don't have such at home and if I would upgrade my computer with a newest
hardware, with 100% probability integrated sound will be HD Codec, nowadays
AC97 is not actual (2008 year is at calendar). But I'm not planning to upgrade
my computer so much now (and in next 5-6 years), writing the driver for my PCI
ESS Maestro1 card is difficult for me (may be some time later), so I decided
to write a driver for SB16. At first it is easy, there are many working
examples for DOS, there are heaps of good documentation and as an ISA device
SB16 can be programmed through I/O ports (about 5 ports are used), that is
more easy than PCI access. Now, enough lirics, lets go to physics :-)
If you still don't understand what stuff is it, I'll tell this in brief:
with this driver you can play MP3 and WAV music (using AC97SND player) and
sounds (some games and DOSBOX can produce sound output through sound
subsystem) in KolibriOS.
;Yeah! I need sound in Kolibri and I have SB16 card. Whats then?----------------
At first copy my SOUND.OBJ to /sys/drivers at your Kolibri system. Note,
that if you have AC97 card and it's driver started - then new driver won't
run until reboot. Then run BOARD and go to 'user' tab. Then try to run
AC97SND player. At BOARD you will see the following (if you had a proper
card):
|----------------------------|
|detecting hardware... | <- detector startup message
|DSP found at port 220h | <- if you have a proper card, it'll be
|DSP version 4.13 - SB16 | autodetected. Numbers may be different.
|failed to attach IRQ5 | <- don't mention. Old kernels reserve IRQ5
|owner's handler: 0x80D74284 | see below how to fix it.
|----------------------------|
At first, note that DSP version must be 4.xx or higher. Older cards are not
supported in this first release, maybe some time later. If nothing detected
but PNP/BIOS or some other OS detects your card - I'm sorry, it's perverted
PNP card like OPTi16, that is like HD Codec - until you init it through
PCI->ISA bridge (HD Codec of course through PCI->PCI bridge), map it, etc,
you can't use it in any way. I'd rather write a PCI device driver, than
for this extreme perversion. If your card detected and has a proper version
but you see 'failed to attach IRQ' - delete stroke 'mov [irq_owner+4*5],1' from the
file kernel.asm of your kernel source, save it, rebuild kernel, copy new
kernel to /sys/ (did you rename 'kernel' to 'kernel.mnt'? You should do it),
restart kernel (Ctrl+Alt+F12, Home). THE EASIER WAY IS TO USE A NEWER KERNEL,
since SVN802 it's fixed.
Now everything should be OK.
;It works for a part of the second and then stops, but system doesn't hang------
Go to 'config.inc' of my driver and change 'sb_irq_num' value from 5 to 7.
Then save, rebuild driver (compile 'sound.asm'), put 'sound' to /sys/drivers/
(you need to rename file 'sound' to 'sound.obj'), restart kernel and try again
to produce sound.
;-------------------------------------------------------------------------------
Ask your questions at KolibriOS forum: board.kolibrios.org
I'll try to answer you if possible.

View File

@ -1,297 +0,0 @@
;--------------------------------
; program dma
;--------------------------------
sb_set_dma:
mov ebx,[sound_dma]
lea eax,[ebx+4] ;mask required channel
cmp bl,4
ja .use_second_dma_controller
jb @f
.dma_setup_error:
if DEBUG
mov esi,msgErrDMAsetup
call SysMsgBoardStr
end if
mov dword[esp],START.stop
ret
@@:
if use_cli_sti
cli ;here to minimize time with disabled ints
end if
out 0xA,al ;mask required channel
xor eax,eax
out 0xC,al ;clear byte pointer flip-flop register
lea eax,[ebx+0x58] ;auto-init mode for channel (ebx)
out 0xB,al ;DMA channel 0-3 mode register
movzx edx,byte[ebx+dma_table] ;page register
mov al,DMAPage
out dx,al
lea edx,[ebx*2] ;DMA channel 0-3 base address
mov al,0 ;LSB is 0
out dx,al
; mov al,0 ;MSB is 0 too
out dx,al
inc edx ;DMA channel 0-3 byte count
mov al,((sb_buffer_size-1) and 0xff)
out dx,al
mov al,((sb_buffer_size-1) shr 8) ;it is the same
out dx,al
mov eax,ebx ;unmask DMA channel
out 0xA,al
if use_cli_sti
sti
end if
ret
.use_second_dma_controller:
cmp bl,7
ja .dma_setup_error
sub bl,4
sub al,4
if use_cli_sti
cli ;here to minimize time with disabled ints
end if
out 0xD4,al ;mask required channel
xor eax,eax
out 0xD8,al ;clear byte pointer flip-flop register
lea eax,[ebx+0x58] ;auto-init mode for channel (ebx+4)
out 0xD6,al ;DMA channel 4-7 mode register
movzx edx,byte[ebx+dma_table+4] ;page register
mov al,DMAPage
out dx,al
lea edx,[ebx*4+0xC0] ;DMA channel 4-7 base address
mov al,0 ;LSB is 0 ;for 16bit DMA this contains
out dx,al ;A1-A8 lines of address bus, A0 is zero
; mov al,0 ;MSB is 0 too ;for 16bit DMA this contains
out dx,al ;A9-A16 lines of address bus
inc edx
inc edx ;DMA channel 4-7 16bit word count
mov al,(((sb_buffer_size/2)-1) and 0xff)
out dx,al
mov al,(((sb_buffer_size/2)-1) shr 8)
out dx,al
mov eax,ebx ;unmask DMA channel
out 0xD4,al
if use_cli_sti
sti
end if
ret
;-------------------------------------------------------------------------------
; out byte to SB DSP's write port
;-------------------------------------------------------------------------------
macro sb_out data_to_out {
@@:
in al,dx
test al,al ;is DSP busy?
js @b ;it's busy
mov al,data_to_out ;it's free
out dx,al
}
;-------------------------------------------------------------------------------
; stop playing
;-------------------------------------------------------------------------------
proc sb_stop
mov edx,[sb_base_port]
add dl,0xC
sb_out 0xD3 ;turn the speaker off
sb_out 0xDA ;exit 8bit DMA
sb_out 0xD9 ;exit 16bit DMA
ret
endp
;-------------------------------------------------------------------------------
; start playing
;-------------------------------------------------------------------------------
proc sb_play
and [int_flip_flop],0
mov edx,[sb_base_port]
add dl,0xC
sb_out 0xD1 ;turn speaker on
; sb_out 0x48 ;set DSP transfer size ;for older cards, not supported
; ;in this version
; mov ax,32767 ;(64k)/2-1
;@@: ;out the low byte...
; in al,dx
; test al,al ;is DSP busy?
; js @b ;it's busy
; out dx,al
; mov al,ah ;...then the high byte
;@@:
; in al,dx
; test al,al ;is DSP busy?
; js @b ;it's busy
; out dx,al
; sb_out 0x1C ;auto-init 8bit playback
; 0xBXh - 16 bit DMA mode
; ||||
sb_out 10110110b ;bCommand
; ||||
; |||+-reserved
; ||+--turn FIFO on (0 for off)
; |+---auto-init mode on (0 for off)
; +----A/D: 0-output, 1-input
; +------stereo on
; |+-----unsigned (1 for signed)
; ||
sb_out 00110000b ;bMode
; || ||||
; ---------reserved
;wSize is a number of 16bit samples less 1. For auto-init mode each half
;buffer is (64k)/2 bytes long and, obviously, contains ((64k)/2)/2 samples
sb_out (((sb_buffer_size/2/2)-1) and 0xFF) ;wSize.LowByte
sb_out (((sb_buffer_size/2/2)-1) shr 8) ;wSize.HighByte
ret
endp
;-------------------------------------------------------------------------------
; reset DSP
;-------------------------------------------------------------------------------
proc sb_reset
and [int_flip_flop],0
mov edx,[sb_base_port]
add dl,6
mov al,1 ;start DSP reset
if use_cli_sti
cli ;here to minimize time with disabled ints
end if
out dx,al
mov ecx,40 ;wait at least 3 microsec.
@@:
in al,dx
loop @b
xor eax,eax ;stop DSP reset
if use_cli_sti
sti
end if
out dx,al
ret
endp
;-------------------------------------------------------------------------------
; set the rate for playing, enable stereo
;-------------------------------------------------------------------------------
proc sb_setup
mov edx,[sb_base_port]
add dl,0xC
sb_out 40h ;set time constant, this is for old cards
sb_out sb_tc
sb_out 41h ;set sound rate, this can only SB16
sb_out (sb_out_rate shr 8) ;first high byte (MSB)
sb_out (sb_out_rate and 0xff) ;then low byte (LSB)
; mov al,0xE ;for older cards, not supported in this version
; sub dl,(0xC-4) ;talk to SB's mixer
; out dx,al ;select this register of the mixer
; mov ecx,6 ;wait for the chip
;@@:
; in al,dx
; loop @b
; inc edx ;now read the data port
; in al,dx
; or al,22h ;turn on stereo
; mov ah,al
; mov al,0xE
; dec edx ;talk to SB's mixer
; out dx,al ;select this register of the mixer
; mov ecx,6 ;wait for the chip
;@@:
; in al,dx
; loop @b
; inc edx ;now send data to the data port
; mov al,ah
; out dx,al
; dec edx
; mov ecx,35 ;wait for the chip
;@@:
; in al,dx
; loop @b
ret
endp
;-------------------------------------------------------------------------------
; set master volume of SB mixer, note, not only SB16 but SBPro and older
; this is the first step to more full support for hardware
;-------------------------------------------------------------------------------
;in: eax in range [-10000;0] - master volume for _both_ channels
;note that x*3*17/2000 and x*3/2000*17 are not the same numbers,
;because we count in integers
proc sb_set_master_vol
mov [sb_master_vol],eax
add eax,10000 ;SB sound level rise from 0 to MAX_LEVEL
lea eax,[eax+eax*2] ;*3
mov ebx,2000 ;divisor
xor edx,edx
cmp byte[sb_DSP_version_int],4
jae @f ;SBPro's MAX_LEVEL is 15, but we *11 because
;volume byte looks like that: 0xLR, where L - left
;channel volume, R - right, 0<=R,L<=15
div ebx
imul eax,17
mov edx,[sb_base_port]
push eax ;here for optimisation
add dl,4
mov al,0x22 ;write mixer register 0x22
out dx,al
in al,dx ;wait for the chip ;6
in al,dx ;wait for the chip ;5
in al,dx ;wait for the chip ;4
in al,dx ;wait for the chip ;3
in al,dx ;wait for the chip ;2
in al,dx ;wait for the chip ;1
pop eax ;go!
inc edx
out dx,al
ret
@@: ;SB16's MAX_LEVEL is 255
imul eax,17
div ebx
mov edx,[sb_base_port]
push eax ;here for optimisation
add dl,4
mov al,0x30 ;left speaker
out dx,al
pop eax ;<--+
inc edx ; \/
push eax ;here for optimisation
out dx,al ;write
dec edx
mov al,0x31 ;right speaker
out dx,al
pop eax
inc edx
out dx,al ;write
ret
endp
;-------------------------------------------------------------------------------

View File

@ -1,389 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
include 'config.inc'
;structs----------------------------------------------------------
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
;something--------------------------------------------------------
public START
public service_proc
public version
include '..\proc32.inc'
include '..\imports.inc'
section '.flat' code readable align 16
include 'sb16.inc'
;-------------------------------------------------------------------------------
proc START stdcall, state:dword
cmp [state], 1
jne .stop
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
end if
call detect ;returns DSP version or zero if
test eax,eax ;SB card not found
jz .exit
if DEBUG
movzx eax,al ;major version
mov esi,sb_DSP_description
dec eax
jz .sb_say_about_found_dsp
mov dword[esi],'2.x '
dec eax
jz .sb_say_about_found_dsp
mov dword[esi],'Pro '
dec eax
jz .sb_say_about_found_dsp
mov dword[esi],'16 '
.sb_say_about_found_dsp:
mov esi,msgDSPFound
call SysMsgBoardStr
end if
xor eax,eax
mov ebx,[sb_base_port]
lea ecx,[ebx+0xF]
call ReservePortArea ;these ports must be my!
if DEBUG
dec eax
jnz @f
mov esi,msgErrRsrvPorts
call SysMsgBoardStr
@@:
end if
call sb_setup ;clock it, etc
stdcall AttachIntHandler, sb_irq_num, sb_irq, 0
if DEBUG
test eax,eax
jnz @f
mov esi,msgErrAtchIRQ
call SysMsgBoardStr
stdcall GetIntHandler, sb_irq_num
call SysMsgBoardNum
jmp .stop
@@:
mov esi,msgSucAtchIRQ
call SysMsgBoardStr
end if
stdcall RegService, my_service, service_proc
ret
.stop:
call sb_reset
.exit:
if DEBUG
mov esi,msgExit
call SysMsgBoardStr
end if
xor eax, eax
ret
endp
;-------------------------------------------------------------------------------
handle equ IOCTL.handle
io_code equ IOCTL.io_code
input equ IOCTL.input
inp_size equ IOCTL.inp_size
output equ IOCTL.output
out_size equ IOCTL.out_size
align 4
proc service_proc stdcall, ioctl:dword
mov edi,[ioctl]
mov eax,[edi+io_code]
cmp eax,SRV_GETVERSION
jne @F
mov eax,[edi+output]
cmp [edi+out_size],4
jne .fail
mov [eax],dword API_VERSION
xor eax,eax
ret
@@:
cmp eax,DEV_PLAY
jne @f
if DEBUG
mov esi,msgPlay
call SysMsgBoardStr
end if
call sb_stop ;to play smth new we must stop smth old
call pre_fill_data ;fill first and second half of the buffer
call pre_fill_data ;
call sb_set_dma ;is it really needed here? Paranoia.
call sb_play
xor eax,eax ;set maximum volume
call sb_set_master_vol
xor eax,eax
ret
;@@: ;all this commented stuff in service proc
; cmp eax,DEV_STOP ;is never used. Mixer do this virtually,
; jne @f ;e.g. instead of stopping driver it
;if DEBUG ;outputs silence
; mov esi,msgStop
; call SysMsgBoardStr
;end if
; call sb_stop
; xor eax,eax
; ret
@@:
cmp eax,DEV_CALLBACK
jne @f
if DEBUG
mov esi,msgCallback
call SysMsgBoardStr
end if
mov edi,[edi+input]
mov eax,[edi]
mov [callback],eax
if DEBUG
call SysMsgBoardNum
end if
xor eax,eax
ret
@@:
cmp eax,DEV_SET_MASTERVOL ;Serge asked me to unlock
jne @F ;DEV_SET(GET)_MASTERVOL, although mixer doesn't use it.
;It doesn't use it _in current version_ - but in the future...
if DEBUG
mov esi,msgSetVol
call SysMsgBoardStr
end if
mov eax,[edi+input]
mov eax,[eax]
call sb_set_master_vol
xor eax,eax
ret
@@:
cmp eax,DEV_GET_MASTERVOL
jne @F
if DEBUG
mov esi,msgGetVol
call SysMsgBoardStr
end if
mov eax,[edi+output]
mov edx,[sb_master_vol]
mov [eax],edx
xor eax,eax
ret
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
;-------------------------------------------------------------------------------
align 4
proc sb_irq
mov edx,[sb_base_port] ;tell the DSP that we have processed IRQ
add dl,0xF ;0xF for 16 bit sound, 0xE for 8 bit sound
in al,dx ;for non-stop sound
pre_fill_data:
mov eax,int_flip_flop
not dword[eax]
mov eax,[eax]
test eax,eax
jns .fill_second_half
if sb_buffer_size eq small_buffer
stdcall [callback],SB16Buffer0 ;for 32k buffer
else if sb_buffer_size eq full_buffer
stdcall [callback],SB16Buffer0 ;for 64k buffer
stdcall [callback],SB16Buffer1 ;for 64k buffer
end if
xor eax,eax
ret
.fill_second_half:
if sb_buffer_size eq small_buffer
stdcall [callback],SB16Buffer1 ;for 32k buffer
else if sb_buffer_size eq full_buffer
stdcall [callback],SB16Buffer2 ;for 64k buffer
stdcall [callback],SB16Buffer3 ;for 64k buffer
end if
xor eax,eax
ret
endp
;-------------------------------------------------------------------------------
align 4
proc detect
.sb_detect_next_port:
if DEBUG
inc dword[port_second_digit_num]
end if
mov edx,sb_base_port
add byte[edx],10h
cmp byte[edx],80h
jbe .sb_try_to_detect_at_specified_port
;error - no SB card detected
.sb_not_found_err:
xor eax, eax
ret
.sb_try_to_detect_at_specified_port:
call sb_reset
add dl,8
mov ecx,100
.sb_check_port:
in al,dx
test al,al ;is DSP port ready to be read?
jns .sb_port_not_ready
sub dl,4
in al,dx ;check for AAh response
add dl,4
cmp al,0xAA
jne .sb_port_not_ready
.sb_card_found:
and dl,0xF0
add dl,0xC
sb_out 0xE1 ;get DSP version
add dl,2
@@:
in al,dx
test al,al ;is DSP port ready to be read?
jns @b
sub dl,4
in al,dx ;get major version
ror eax,16
add dl,4
@@:
in al,dx
test al,al ;is DSP port ready to be read?
jns @b
sub dl,4
in al,dx ;get minor version
xor edx,edx
mov dl,10
div dl
ror eax,16
xor ah,ah
mov [sb_DSP_version_int],eax ;for internal usage
if DEBUG
add [sb_DSP_version],eax
end if
ret
.sb_port_not_ready:
loop .sb_check_port ;100 retries (~100 microsec.)
jmp .sb_detect_next_port
endp
;-------------------------------------------------------------------------------
if DEBUG
proc SysMsgBoardNum ;warning: destroys eax,ebx,ecx,esi
mov ebx,eax
mov ecx,8
mov esi,(number_to_out+1)
.1:
mov eax,ebx
and eax,0xF
add al,'0'
cmp al,(10+'0')
jb @f
add al,('A'-'0'-10)
@@:
mov [esi+ecx],al
shr ebx,4
loop .1
dec esi
call SysMsgBoardStr
ret
endp
end if
;all initialized data place here
align 4
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
sb_base_port: dd 200h ;don't ask me why - see the code&docs
sound_dma dd sb_dma_num
;note that 4th DMA channel doesn't exist, it is used for cascade
;plugging the first DMA controler to the second
dma_table db 0x87,0x83,0x81,0x82,0xFF,0x8B,0x89,0x8A
my_service db 'SOUND',0 ;max 16 chars include zero
if DEBUG
number_to_out db '0x00000000',13,10,0
msgInit db 'detecting hardware...',13,10,0
msgExit db 'exiting... May be some problems found?',13,10,0
msgPlay db 'start play',13,10,0
;msgStop db 'stop play',13,10,0
msgCallback db 'set_callback received from the mixer!',13,10
db 'callback handler is: ',0
msgErrAtchIRQ db 'failed to attach IRQ',(sb_irq_num+'0'),13,10
db 'owner',39,'s handler: ',0
msgSucAtchIRQ db 'succesfully attached IRQ',(sb_irq_num+'0')
db ' as hardcoded',13,10,0
msgErrRsrvPorts db 'failed to reserve needed ports.',13,10
db 'Driver may work unstable',13,10,0
msgSetVol db 'DEV_SET_MASTERVOL call came',13,10,0
msgGetVol db 'DEV_GET_MASTERVOL call came',13,10,0
msgErrDMAsetup db 'failed to setup DMA - bad channel',13,10,0
;-------------------------------------------------------------------------------
msgDSPFound db 'DSP found at port 2'
label port_second_digit_num dword at $
db '00h',13,10,'DSP version '
sb_DSP_version: db '0.00 - SB'
sb_DSP_description: db 32,32,32,32,13,10,0
;-------------------------------------------------------------------------------
end if
section '.data' data readable writable align 16
;all uninitialized data place here
;pTempBuf rd 1
callback rd 1
int_flip_flop rd 1
sb_master_vol rd 1
sb_DSP_version_int rd 1

View File

@ -1,115 +0,0 @@
struc URB
{
.fd dd ?
.bk dd ?
.dev dd ? ; pointer to associated device
.pipe dd ? ; pipe information
.status dd ? ; non-ISO status
.transfer_flags dd ? ; URB_SHORT_NOT_OK | ...
.transfer_buffer dd ? ; associated data buffer
.transfer_dma dd ? ; dma addr for transfer_buffer
.transfer_buffer_length dd ? ; data buffer length
.actual_length dd ? ; actual transfer length
.setup_packet dd ? ; setup packet (control only)
.setup_dma dd ? ; dma addr for setup_packet
.start_frame dd ? ; start frame (ISO)
.number_of_packets dd ? ; number of ISO packets
.interval dd ? ; transfer interval
.error_count dd ? ; number of ISO errors
.context dd ? ; context for completion
.complete dd ? ; (in) completion routine
.iso_frame_desc:
}
virtual at 0
URB URB
end virtual
struc REQ ;usb request
{
.request_type db ?
.request db ?
.value dw ?
.index dw ?
.length dw ?
}
virtual at 0
REQ REQ
end virtual
align 4
proc usb_control_msg stdcall, dev:dword, pipe:dword, request:dword,\
requesttype:dword, value:dword, index:dword,\
data:dword, size:dword, timeout:dword
locals
req REQ
endl
lea eax, [req]
mov ecx, [request]
mov ebx, [requesttupe]
mov edx, [value]
mov esi, [index]
mov edi, [size]
mov [eax+REQ.request_type], bl
mov [eax+REQ.request], cl
mov [eax+REQ.value], dx
mov [eax+REQ.index], si
mov [eax+REQ.length], di
stdcall usb_internal_control_msg, [dev], [pipe],\
eax, [data], [size], [timeout]
ret
endp
; returns status (negative) or length (positive)
static int usb_internal_control_msg(struct usb_device *usb_dev,
unsigned int pipe,
struct usb_ctrlrequest *cmd,
void *data, int len, int timeout)
{
struct urb *urb;
int retv;
int length;
urb = usb_alloc_urb(0, GFP_NOIO);
if (!urb)
return -ENOMEM;
usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data,
len, usb_api_blocking_completion, NULL);
retv = usb_start_wait_urb(urb, timeout, &length);
if (retv < 0)
return retv;
else
return length;
}
void usb_fill_control_urb (struct urb *urb,
struct usb_device *dev,
unsigned int pipe,
unsigned char *setup_packet,
void *transfer_buffer,
int buffer_length,
usb_complete_t complete_fn,
void *context)
{
urb->dev = dev;
urb->pipe = pipe;
urb->setup_packet = setup_packet;
urb->transfer_buffer = transfer_buffer;
urb->transfer_buffer_length = buffer_length;
urb->complete = complete_fn;
urb->context = context;
}

View File

@ -1,435 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;driver sceletone
format MS COFF
API_VERSION equ 0 ;debug
include '../proc32.inc'
include '../imports.inc'
include 'urb.inc'
struc UHCI
{
.bus dd ?
.devfn dd ?
.io_base dd ?
.mm_base dd ?
.irq dd ?
.flags dd ?
.reset dd ?
.start dd ?
.stop dd ?
.port_c_suspend dd ?
.resuming_ports dd ?
.rh_state dd ?
.rh_numports dd ?
.is_stopped dd ?
.dead dd ?
.sizeof:
}
virtual at 0
UHCI UHCI
end virtual
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
struc TD ;transfer descriptor
{
.link dd ?
.status dd ?
.token dd ?
.buffer dd ?
.addr dd ?
.frame dd ?
.fd dd ?
.bk dd ?
.sizeof:
}
virtual at 0
TD TD
end virtual
public START
public service_proc
public version
DEBUG equ 1
DRV_ENTRY equ 1
DRV_EXIT equ -1
STRIDE equ 4 ;size of row in devices table
SRV_GETVERSION equ 0
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1
jne .exit
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
end if
call init
stdcall RegService, my_service, service_proc
ret
.fail:
.exit:
xor eax, eax
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code
input equ IOCTL.input
inp_size equ IOCTL.inp_size
output equ IOCTL.output
out_size equ IOCTL.out_size
align 4
proc service_proc stdcall, ioctl:dword
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
align 4
proc detect
locals
last_bus dd ?
bus dd ?
devfn dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
call PciApi
cmp eax, -1
je .err
mov [last_bus], eax
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
mov edi, devices
@@:
mov ebx, [edi]
test ebx, ebx
jz .next
cmp eax, ebx
je .found
add edi, STRIDE
jmp @B
.next:
inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
mov eax, UHCI.sizeof
call Kmalloc
test eax, eax
jz .mem_fail
mov ebx, [bus]
mov [eax+UHCI.bus], ebx
mov ecx, [devfn]
mov [eax+UHCI.devfn], ecx
ret
.mem_fail:
if DEBUG
mov esi, msgMemFail
call SysMsgBoardStr
end if
.err:
xor eax, eax
ret
endp
PCI_BASE equ 0x20
USB_LEGKEY equ 0xC0
align 4
proc init
locals
uhci dd ?
endl
call detect
test eax, eax
jz .fail
mov [uhci], eax
stdcall PciRead32, [eax+UHCI.bus], [eax+UHCI.devfn], PCI_BASE
and eax, 0xFFC0
mov esi, [uhci]
mov [esi+UHCI.io_base], eax
stdcall uhci_reset, esi
stdcall finish_reset, [uhci]
.fail:
if DEBUG
mov esi, msgDevNotFound
call SysMsgBoardStr
end if
ret
endp
UHCI_USBINTR equ 4 ; interrupt register
UHCI_USBLEGSUP_RWC equ 0x8f00 ; the R/WC bits
UHCI_USBLEGSUP_RO equ 0x5040 ; R/O and reserved bits
UHCI_USBCMD_RUN equ 0x0001 ; RUN/STOP bit
UHCI_USBCMD_HCRESET equ 0x0002 ; Host Controller reset
UHCI_USBCMD_EGSM equ 0x0008 ; Global Suspend Mode
UHCI_USBCMD_CONFIGURE equ 0x0040 ; Config Flag
UHCI_USBINTR_RESUME equ 0x0002 ; Resume interrupt enable
PORTSC0 equ 0x10
PORTSC1 equ 0x12
UHCI_RH_RESET equ 0
UHCI_RH_SUSPENDED equ 1
UHCI_RH_AUTO_STOPPED equ 2
UHCI_RH_RESUMING equ 3
; In this state the HC changes from running to halted
; so it can legally appear either way.
UHCI_RH_SUSPENDING equ 4
; In the following states it's an error if the HC is halted.
; These two must come last.
UHCI_RH_RUNNING equ 5 ; The normal state
UHCI_RH_RUNNING_NODEVS equ 6 ; Running with no devices
UHCI_IS_STOPPED equ 9999
align 4
proc uhci_reset stdcall, uhci:dword
mov esi, [uhci]
stdcall PciRead16, [esi+UHCI.bus], [esi+UHCI.devfn], USB_LEGKEY
test eax, not (UHCI_USBLEGSUP_RO or UHCI_USBLEGSUP_RWC)
jnz .reset
mov edx, [esi+UHCI.io_base]
in ax, dx
test ax, UHCI_USBCMD_RUN
jnz .reset
test ax, UHCI_USBCMD_CONFIGURE
jz .reset
test ax, UHCI_USBCMD_EGSM
jz .reset
add edx, UHCI_USBINTR
in ax, dx
test ax, not UHCI_USBINTR_RESUME
jnz .reset
ret
.reset:
stdcall PciWrite16, [esi+UHCI.bus], [esi+UHCI.devfn], USB_LEGKEY, UHCI_USBLEGSUP_RWC
mov edx, [esi+UHCI.io_base]
mov ax, UHCI_USBCMD_HCRESET
out dx, ax
xor eax, eax
out dx, ax
add edx, UHCI_USBINTR
out dx, ax
ret
endp
proc finish_reset stdcall, uhci:dword
mov esi, [uhci]
mov edx, [esi+UHCI.io_base]
add edx, PORTSC0
xor eax, eax
out dx, ax
add edx, (PORTSC1-PORTSC0)
out dx, ax
mov [esi+UHCI.port_c_suspend], eax
mov [esi+UHCI.resuming_ports], eax
mov [esi+UHCI.rh_state], UHCI_RH_RESET
mov [esi+UHCI.rh_numports], 2
mov [esi+UHCI.is_stopped], UHCI_IS_STOPPED
; mov [ uhci_to_hcd(uhci)->state = HC_STATE_HALT;
; uhci_to_hcd(uhci)->poll_rh = 0;
mov [esi+UHCI.dead], eax ; Full reset resurrects the controller
ret
endp
proc insert_td stdcall, td:dword, frame:dword
mov edi, [td]
mov eax, [frame]
and eax, -1024
mov [edi+TD.frame], eax
mov ebx, [framelist]
mov edx, [dma_framelist]
shl eax, 5
mov ecx, [eax+ebx]
test ecx, ecx
jz .empty
mov ecx, [ecx+TD.bk] ;last TD
mov edx, [ecx+TD.fd]
mov [edi+TD.fd], edx
mov [edi+TD.bk], ecx
mov [ecx+TD.fd], edi
mov [edx+TD.bk], edi
mov eax, [ecx+TD.link]
mov [edi+TD.link], eax
mov ebx, [edi+TD.addr]
mov [ecx+TD.link], ebx
ret
.empty:
mov ecx, [eax+edx]
mov [edi+TD.link], ecx
mov [ebx+eax], edi
mov ecx, [edi+TD.addr]
mov [eax+edx], ecx
ret
endp
align 4
proc usb_get_descriptor stdcall, dev:dword, type:dword, index:dword,\
buf:dword, size:dword
locals
count dd ?
endl
mov esi, [buf]
mov ecx, [size]
xor eax, eax
cld
rep stosb
mov [count], 3
@@:
mov eax, [type]
shl eax, 8
add eax, [index]
stdcall usb_control_msg, [dev],pipe,USB_REQ_GET_DESCRIPTOR,\
USB_DIR_IN, eax,0,[buf], [size],\
USB_CTRL_GET_TIMEOUT
test eax, eax
jz .next
cmp eax, -1
je .next
jmp. ok
.next:
dec [count]
jnz @B
mov eax, -1
.ok:
ret
endp
DEVICE_ID equ 0x24D2 ; pci device id
VENDOR_ID equ 0x8086 ; device vendor id
QEMU_USB equ 0x7020
;all initialized data place here
align 4
devices dd (DEVICE_ID shl 16)+VENDOR_ID
dd (QEMU_USB shl 16)+VENDOR_ID
dd 0 ;terminator
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
my_service db 'UHCI',0 ;max 16 chars include zero
msgInit db 'detect hardware...',13,10,0
msgPCI db 'PCI accsess not supported',13,10,0
msgDevNotFound db 'device not found',13,10,0
msgMemFail db 'Kmalloc failed', 10,10,0
;msgFail db 'device not found',13,10,0
section '.data' data readable writable align 16
;all uninitialized data place here

View File

@ -1,33 +0,0 @@
#!/bin/bash
# This script does for linux the same as build.bat for DOS,
# it compiles the KoOS kernel, hopefully ;-)
CLANG=$1;
usage()
{
echo "Usage: make.sh [en|ru|ge|et]"
exit 1
}
compile()
{
fasm -m 65536 kernel.asm bin/kernel.mnt
rm -f lang.inc
exit 0
}
if [ ! $CLANG ] ; then
usage
fi
for i in "en" "ru" "ge" "et"; do
if [ $i == $CLANG ] ; then
echo "lang fix $i" > lang.inc
compile
fi
done
usage

View File

@ -1,48 +0,0 @@
FASM=fasm
FLAGS=-m 65536
languages=en|ru|ge|et
drivers_src=sound sis infinity uart ati2d vmode com_mouse
skins_src=default
.PHONY: all kernel drivers skins clean
all: kernel drivers skins
kernel: check_lang
@echo "*** building kernel with language '$(lang)' ..."
@mkdir -p bin
@echo "lang fix $(lang)" > lang.inc
@echo "--- building 'bin/kernel.mnt' ..."
@$(FASM) $(FLAGS) kernel.asm bin/kernel.mnt
@rm -f lang.inc
drivers:
@echo "*** building drivers ..."
@mkdir -p bin/drivers
@cd drivers; for f in $(drivers_src); do \
echo "--- building 'bin/drivers/$${f}.obj' ..."; \
$(FASM) $(FLAGS) $${f}.asm ../bin/drivers/$${f}.obj; \
done
@mv bin/drivers/vmode.obj bin/drivers/vmode.mdr
skins:
@echo "*** building skins ..."
@mkdir -p bin/skins
@cd skin; for f in $(skins_src); do \
echo "--- building 'bin/skins/$${f}.skn' ..."; \
$(FASM) $(FLAGS) $${f}.asm ../bin/skins/$${f}.skn; \
done
check_lang:
@case "$(lang)" in \
$(languages)) \
;; \
*) \
echo "*** error: language is incorrect or not specified"; \
exit 1; \
;; \
esac
clean:
rm -rf bin
rm -f lang.inc