mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-25 08:06:49 +03:00
New branch - network experimental code
git-svn-id: svn://kolibrios.org@1159 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
de54d697db
commit
c13e52817d
347
kernel/branches/COPYING.TXT
Normal file
347
kernel/branches/COPYING.TXT
Normal file
@ -0,0 +1,347 @@
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
10
kernel/branches/README.TXT
Normal file
10
kernel/branches/README.TXT
Normal file
@ -0,0 +1,10 @@
|
||||
This code is experimental, none of the used programming interfaces (API, driver calls,..) are definite solutions.
|
||||
Lot of work needs to be done, and descissions need to be made.
|
||||
|
||||
But, everyone is free to explore the code, make suggestions or write parts of the code.
|
||||
|
||||
I'm open for discussion on hidnplayr@gmail.com or as hidnplayr in #general on irc.kolibrios.org:6667
|
||||
|
||||
PS: dont expect anything to be working at al, this way you wont be dissapointed ;)
|
||||
|
||||
Hidnplayr - september 2009
|
901
kernel/branches/blkdev/cd_drv.inc
Normal file
901
kernel/branches/blkdev/cd_drv.inc
Normal file
@ -0,0 +1,901 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 758 $
|
||||
|
||||
|
||||
;**********************************************************
|
||||
; Непосредственная работа с устройством СD (ATAPI)
|
||||
;**********************************************************
|
||||
; Автор части исходного текста Кулаков Владимир Геннадьевич
|
||||
; Адаптация, доработка и разработка Mario79
|
||||
|
||||
; Максимальное количество повторений операции чтения
|
||||
MaxRetr equ 10
|
||||
; Предельное время ожидания готовности к приему команды
|
||||
; (в тиках)
|
||||
BSYWaitTime equ 1000 ;2
|
||||
NoTickWaitTime equ 0xfffff
|
||||
|
||||
;*************************************************
|
||||
;* ПОЛНОЕ ЧТЕНИЕ СЕКТОРА КОМПАКТ-ДИСКА *
|
||||
;* Считываются данные пользователя, информация *
|
||||
;* субканала и контрольная информация *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале; *
|
||||
;* CDSectorAddress - адрес считываемого сектора. *
|
||||
;* Данные считывается в массив CDDataBuf. *
|
||||
;*************************************************
|
||||
ReadCD:
|
||||
pusha
|
||||
; Задать размер сектора
|
||||
mov [CDBlockSize],2048 ;2352
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать пакетную команду для считывания
|
||||
; сектора данных
|
||||
; Задать код команды Read CD
|
||||
mov [PacketCommand],byte 0x28 ;0xBE
|
||||
; Задать адрес сектора
|
||||
mov AX,word [CDSectorAddress+2]
|
||||
xchg AL,AH
|
||||
mov word [PacketCommand+2],AX
|
||||
mov AX,word [CDSectorAddress]
|
||||
xchg AL,AH
|
||||
mov word [PacketCommand+4],AX
|
||||
; mov eax,[CDSectorAddress]
|
||||
; mov [PacketCommand+2],eax
|
||||
; Задать количество считываемых секторов
|
||||
mov [PacketCommand+8],byte 1
|
||||
; Задать считывание данных в полном объеме
|
||||
; mov [PacketCommand+9],byte 0xF8
|
||||
; Подать команду
|
||||
call SendPacketDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;********************************************
|
||||
;* ЧТЕНИЕ СЕКТОРА С ПОВТОРАМИ *
|
||||
;* Многократное повторение чтения при сбоях *
|
||||
;********************************************
|
||||
ReadCDWRetr:
|
||||
;-----------------------------------------------------------
|
||||
; input : eax = block to read
|
||||
; ebx = destination
|
||||
;-----------------------------------------------------------
|
||||
pushad
|
||||
mov eax,[CDSectorAddress]
|
||||
mov ebx,[CDDataBuf_pointer]
|
||||
call cd_calculate_cache
|
||||
add esi,8
|
||||
mov edi,1
|
||||
.hdreadcache:
|
||||
; cmp dword [esi+4],0 ; empty
|
||||
; je .nohdcache
|
||||
cmp [esi],eax ; correct sector
|
||||
je .yeshdcache
|
||||
.nohdcache:
|
||||
add esi,8
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz .hdreadcache
|
||||
call find_empty_slot_CD_cache ; ret in edi
|
||||
|
||||
push edi
|
||||
push eax
|
||||
call cd_calculate_cache_2
|
||||
shl edi,11
|
||||
add edi,eax
|
||||
mov [CDDataBuf_pointer],edi
|
||||
pop eax
|
||||
pop edi
|
||||
|
||||
call ReadCDWRetr_1
|
||||
cmp [DevErrorCode],0
|
||||
jne .exit
|
||||
|
||||
mov [CDDataBuf_pointer],ebx
|
||||
call cd_calculate_cache_1
|
||||
lea esi,[edi*8+esi]
|
||||
mov [esi],eax ; sector number
|
||||
; mov dword [esi+4],1 ; hd read - mark as same as in hd
|
||||
.yeshdcache:
|
||||
mov esi,edi
|
||||
shl esi,11 ;9
|
||||
push eax
|
||||
call cd_calculate_cache_2
|
||||
add esi,eax
|
||||
pop eax
|
||||
mov edi,ebx ;[CDDataBuf_pointer]
|
||||
mov ecx,512 ;/4
|
||||
cld
|
||||
rep movsd ; move data
|
||||
.exit:
|
||||
popad
|
||||
ret
|
||||
|
||||
ReadCDWRetr_1:
|
||||
pushad
|
||||
|
||||
; Цикл, пока команда не выполнена успешно или не
|
||||
; исчерпано количество попыток
|
||||
mov ECX,MaxRetr
|
||||
@@NextRetr:
|
||||
; Подать команду
|
||||
call ReadCD
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_4
|
||||
|
||||
or ecx,ecx ;{SPraid.simba} (for cd load)
|
||||
jz @@End_4
|
||||
dec ecx
|
||||
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
mov eax,NoTickWaitTime
|
||||
.wait:
|
||||
dec eax
|
||||
cmp eax,0
|
||||
je @@NextRetr
|
||||
jmp .wait
|
||||
@@:
|
||||
; Задержка на 2,5 секунды
|
||||
; mov EAX,[timer_ticks]
|
||||
; add EAX,50 ;250
|
||||
;@@Wait:
|
||||
; call change_task
|
||||
; cmp EAX,[timer_ticks]
|
||||
; ja @@Wait
|
||||
loop @@NextRetr
|
||||
@@End_4:
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
; Универсальные процедуры, обеспечивающие выполнение
|
||||
; пакетных команд в режиме PIO
|
||||
|
||||
; Максимально допустимое время ожидания реакции
|
||||
; устройства на пакетную команду (в тиках)
|
||||
MaxCDWaitTime equ 1000 ;200 ;10 секунд
|
||||
|
||||
; Область памяти для формирования пакетной команды
|
||||
PacketCommand: rb 12 ;DB 12 DUP (?)
|
||||
; Область памяти для приема данных от дисковода
|
||||
;CDDataBuf DB 4096 DUP (0)
|
||||
; Размер принимаемого блока данных в байтах
|
||||
CDBlockSize DW ?
|
||||
; Адрес считываемого сектора данных
|
||||
CDSectorAddress: DD ?
|
||||
; Время начала очередной операции с диском
|
||||
TickCounter_1 DD 0
|
||||
; Время начала ожидания готовности устройства
|
||||
WURStartTime DD 0
|
||||
; указатель буфера для считывания
|
||||
CDDataBuf_pointer dd 0
|
||||
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ УСТРОЙСТВУ ATAPI ПАКЕТНУЮ КОМАНДУ, *
|
||||
;* ПРЕДУСМАТРИВАЮЩУЮ ПЕРЕДАЧУ ОДНОГО СЕКТОРА ДАННЫХ *
|
||||
;* РАЗМЕРОМ 2048 БАЙТ ОТ УСТРОЙСТВА К ХОСТУ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале; *
|
||||
;* PacketCommand - 12-байтный командный пакет; *
|
||||
;* CDBlockSize - размер принимаемого блока данных. *
|
||||
;****************************************************
|
||||
SendPacketDatCommand:
|
||||
pushad
|
||||
mov [DevErrorCode],0
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
; Послать ATA-команду передачи пакетной команды
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
; Загрузить размер передаваемого блока
|
||||
mov AX,[CDBlockSize]
|
||||
mov [ATACylinder],AX
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A0h
|
||||
call SendCommandToHDD_1
|
||||
cmp [DevErrorCode],0 ;проверить код ошибки
|
||||
jne @@End_8 ;закончить, сохранив код ошибки
|
||||
|
||||
; Ожидание готовности дисковода к приему
|
||||
; пакетной команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
mov ecx,NoTickWaitTime
|
||||
@@WaitDevice0:
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_1
|
||||
jmp .test
|
||||
@@:
|
||||
call change_task
|
||||
; Проверить время выполнения команды
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,BSYWaitTime
|
||||
ja @@Err1_1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
.test:
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitDevice0
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitDevice0
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Err6
|
||||
; Послать пакетную команду
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
mov AX,[PacketCommand]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+2]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+4]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+6]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+8]
|
||||
out DX,AX
|
||||
mov AX,[PacketCommand+10]
|
||||
out DX,AX
|
||||
sti
|
||||
; Ожидание готовности данных
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
mov ecx,NoTickWaitTime
|
||||
@@WaitDevice1:
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_1
|
||||
jmp .test_1
|
||||
@@:
|
||||
call change_task
|
||||
; Проверить время выполнения команды
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
ja @@Err1_1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
.test_1:
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitDevice1
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitDevice1
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Err6_temp
|
||||
; Принять блок данных от контроллера
|
||||
mov EDI,[CDDataBuf_pointer] ;0x7000 ;CDDataBuf
|
||||
; Загрузить адрес регистра данных контроллера
|
||||
mov DX,[ATABasePortAddr] ;порт 1x0h
|
||||
; Загрузить в счетчик размер блока в байтах
|
||||
xor ecx,ecx
|
||||
mov CX,[CDBlockSize]
|
||||
; Вычислить размер блока в 16-разрядных словах
|
||||
shr CX,1 ;разделить размер блока на 2
|
||||
; Принять блок данных
|
||||
cli
|
||||
cld
|
||||
rep insw
|
||||
sti
|
||||
; Успешное завершение приема данных
|
||||
jmp @@End_8
|
||||
|
||||
; Записать код ошибки
|
||||
@@Err1_1:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_8
|
||||
@@Err6_temp:
|
||||
mov [DevErrorCode],7
|
||||
jmp @@End_8
|
||||
@@Err6:
|
||||
mov [DevErrorCode],6
|
||||
@@End_8:
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***********************************************
|
||||
;* ПОСЛАТЬ УСТРОЙСТВУ ATAPI ПАКЕТНУЮ КОМАНДУ, *
|
||||
;* НЕ ПРЕДУСМАТРИВАЮЩУЮ ПЕРЕДАЧИ ДАННЫХ *
|
||||
;* Входные параметры передаются через *
|
||||
;* глобальные перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале; *
|
||||
;* PacketCommand - 12-байтный командный пакет. *
|
||||
;***********************************************
|
||||
SendPacketNoDatCommand:
|
||||
pushad
|
||||
mov [DevErrorCode],0
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
; Послать ATA-команду передачи пакетной команды
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
mov [ATACylinder],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A0h
|
||||
call SendCommandToHDD_1
|
||||
cmp [DevErrorCode],0 ;проверить код ошибки
|
||||
jne @@End_9 ;закончить, сохранив код ошибки
|
||||
; Ожидание готовности дисковода к приему
|
||||
; пакетной команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
@@WaitDevice0_1:
|
||||
call change_task
|
||||
; Проверить время ожидания
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,BSYWaitTime
|
||||
ja @@Err1_3 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitDevice0_1
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Err6_1
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitDevice0_1
|
||||
; Послать пакетную команду
|
||||
; cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
mov AX,word [PacketCommand]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+2]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+4]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+6]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+8]
|
||||
out DX,AX
|
||||
mov AX,word [PacketCommand+10]
|
||||
out DX,AX
|
||||
; sti
|
||||
cmp [ignore_CD_eject_wait],1
|
||||
je @@End_9
|
||||
; Ожидание подтверждения приема команды
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
@@WaitDevice1_1:
|
||||
call change_task
|
||||
; Проверить время выполнения команды
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[TickCounter_1]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
ja @@Err1_3 ;ошибка тайм-аута
|
||||
; Ожидать освобождения устройства
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitDevice1_1
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Err6_1
|
||||
test AL,40h ;состояние сигнала DRDY
|
||||
jz @@WaitDevice1_1
|
||||
jmp @@End_9
|
||||
|
||||
; Записать код ошибки
|
||||
@@Err1_3:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_9
|
||||
@@Err6_1:
|
||||
mov [DevErrorCode],6
|
||||
@@End_9:
|
||||
popad
|
||||
ret
|
||||
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала (1 или 2); *
|
||||
;* DiskNumber - номер диска (0 или 1); *
|
||||
;* ATAFeatures - "особенности"; *
|
||||
;* ATASectorCount - количество секторов; *
|
||||
;* ATASectorNumber - номер начального сектора; *
|
||||
;* ATACylinder - номер начального цилиндра; *
|
||||
;* ATAHead - номер начальной головки; *
|
||||
;* ATAAddressMode - режим адресации (0-CHS, 1-LBA); *
|
||||
;* ATACommand - код команды. *
|
||||
;* После успешного выполнения функции: *
|
||||
;* в ATABasePortAddr - базовый адрес HDD; *
|
||||
;* в DevErrorCode - ноль. *
|
||||
;* При возникновении ошибки в DevErrorCode будет *
|
||||
;* возвращен код ошибки. *
|
||||
;****************************************************
|
||||
SendCommandToHDD_1:
|
||||
pushad
|
||||
mov [DevErrorCode],0
|
||||
; Проверить значение кода режима
|
||||
cmp [ATAAddressMode],1
|
||||
ja @@Err2_4
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3_4
|
||||
cmp BX,2
|
||||
ja @@Err3_4
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov AX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],AX
|
||||
; Ожидание готовности HDD к приему команды
|
||||
; Выбрать нужный диск
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,6 ;адрес регистра головок
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;проверить номера диска
|
||||
ja @@Err4_4
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Ожидать, пока диск не будет готов
|
||||
inc DX
|
||||
mov eax,[timer_ticks]
|
||||
mov [TickCounter_1],eax
|
||||
mov ecx,NoTickWaitTime
|
||||
@@WaitHDReady_2:
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_4
|
||||
jmp .test
|
||||
@@:
|
||||
call change_task
|
||||
; Проверить время ожидания
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[TickCounter_1]
|
||||
cmp eax,BSYWaitTime ;300 ;ожидать 3 сек.
|
||||
ja @@Err1_4 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояния
|
||||
.test:
|
||||
in AL,DX
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady_2
|
||||
; Проверить состояние сигнала DRQ
|
||||
test AL,08h
|
||||
jnz @@WaitHDReady_2
|
||||
|
||||
; Загрузить команду в регистры контроллера
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
inc DX ;регистр "особенностей"
|
||||
mov AL,[ATAFeatures]
|
||||
out DX,AL
|
||||
inc DX ;счетчик секторов
|
||||
mov AL,[ATASectorCount]
|
||||
out DX,AL
|
||||
inc DX ;регистр номера сектора
|
||||
mov AL,[ATASectorNumber]
|
||||
out DX,AL
|
||||
inc DX ;номер цилиндра (младший байт)
|
||||
mov AX,[ATACylinder]
|
||||
out DX,AL
|
||||
inc DX ;номер цилиндра (старший байт)
|
||||
mov AL,AH
|
||||
out DX,AL
|
||||
inc DX ;номер головки/номер диска
|
||||
mov AL,[DiskNumber]
|
||||
shl AL,4
|
||||
cmp [ATAHead],0Fh ;проверить номер головки
|
||||
ja @@Err5_4
|
||||
or AL,[ATAHead]
|
||||
or AL,10100000b
|
||||
mov AH,[ATAAddressMode]
|
||||
shl AH,6
|
||||
or AL,AH
|
||||
out DX,AL
|
||||
; Послать команду
|
||||
mov AL,[ATACommand]
|
||||
inc DX ;регистр команд
|
||||
out DX,AL
|
||||
sti
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
jmp @@End_10
|
||||
; Записать код ошибки
|
||||
@@Err1_4:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_10
|
||||
@@Err2_4:
|
||||
mov [DevErrorCode],2
|
||||
jmp @@End_10
|
||||
@@Err3_4:
|
||||
mov [DevErrorCode],3
|
||||
jmp @@End_10
|
||||
@@Err4_4:
|
||||
mov [DevErrorCode],4
|
||||
jmp @@End_10
|
||||
@@Err5_4:
|
||||
mov [DevErrorCode],5
|
||||
; Завершение работы программы
|
||||
@@End_10:
|
||||
; sti
|
||||
popad
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ОЖИДАНИЕ ГОТОВНОСТИ УСТРОЙСТВА К РАБОТЕ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
WaitUnitReady:
|
||||
pusha
|
||||
; Запомнить время начала операции
|
||||
mov EAX,[timer_ticks]
|
||||
mov [WURStartTime],EAX
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду TEST UNIT READY
|
||||
mov [PacketCommand],word 00h
|
||||
; ЦИКЛ ОЖИДАНИЯ ГОТОВНОСТИ УСТРОЙСТВА
|
||||
mov ecx,NoTickWaitTime
|
||||
@@SendCommand:
|
||||
; Подать команду проверки готовности
|
||||
call SendPacketNoDatCommand
|
||||
cmp [timer_ticks_enable],0
|
||||
jne @f
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_11
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je .Error
|
||||
jmp @@SendCommand
|
||||
@@:
|
||||
call change_task
|
||||
; Проверить код ошибки
|
||||
cmp [DevErrorCode],0
|
||||
je @@End_11
|
||||
; Проверить время ожидания готовности
|
||||
mov EAX,[timer_ticks]
|
||||
sub EAX,[WURStartTime]
|
||||
cmp EAX,MaxCDWaitTime
|
||||
jb @@SendCommand
|
||||
.Error:
|
||||
; Ошибка тайм-аута
|
||||
mov [DevErrorCode],1
|
||||
@@End_11:
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ЗАПРЕТИТЬ СМЕНУ ДИСКА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
prevent_medium_removal:
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Задать код команды
|
||||
mov [PacketCommand],byte 0x1E
|
||||
; Задать код запрета
|
||||
mov [PacketCommand+4],byte 11b
|
||||
; Подать команду
|
||||
call SendPacketNoDatCommand
|
||||
mov eax,ATAPI_IDE0_lock
|
||||
add eax,[cdpos]
|
||||
dec eax
|
||||
mov [eax],byte 1
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* РАЗРЕШИТЬ СМЕНУ ДИСКА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
allow_medium_removal:
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Задать код команды
|
||||
mov [PacketCommand],byte 0x1E
|
||||
; Задать код запрета
|
||||
mov [PacketCommand+4],byte 00b
|
||||
; Подать команду
|
||||
call SendPacketNoDatCommand
|
||||
mov eax,ATAPI_IDE0_lock
|
||||
add eax,[cdpos]
|
||||
dec eax
|
||||
mov [eax],byte 0
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ЗАГРУЗИТЬ НОСИТЕЛЬ В ДИСКОВОД *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
LoadMedium:
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду START/STOP UNIT
|
||||
; Задать код команды
|
||||
mov [PacketCommand],word 1Bh
|
||||
; Задать операцию загрузки носителя
|
||||
mov [PacketCommand+4],word 00000011b
|
||||
; Подать команду
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ИЗВЛЕЧЬ НОСИТЕЛЬ ИЗ ДИСКОВОДА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
EjectMedium:
|
||||
pusha
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать команду START/STOP UNIT
|
||||
; Задать код команды
|
||||
mov [PacketCommand],word 1Bh
|
||||
; Задать операцию извлечения носителя
|
||||
mov [PacketCommand+4],word 00000010b
|
||||
; Подать команду
|
||||
call SendPacketNoDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* Проверить событие нажатия кнопки извлечения *
|
||||
;* диска *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
check_ATAPI_device_event:
|
||||
pusha
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[timer_ATAPI_check]
|
||||
cmp eax,100
|
||||
jb .end_1
|
||||
mov al,[DRIVE_DATA+1]
|
||||
and al,11b
|
||||
cmp al,10b
|
||||
jz .ide3
|
||||
.ide2_1:
|
||||
mov al,[DRIVE_DATA+1]
|
||||
and al,1100b
|
||||
cmp al,1000b
|
||||
jz .ide2
|
||||
.ide1_1:
|
||||
mov al,[DRIVE_DATA+1]
|
||||
and al,110000b
|
||||
cmp al,100000b
|
||||
jz .ide1
|
||||
.ide0_1:
|
||||
mov al,[DRIVE_DATA+1]
|
||||
and al,11000000b
|
||||
cmp al,10000000b
|
||||
jz .ide0
|
||||
.end:
|
||||
|
||||
sti
|
||||
mov eax,[timer_ticks]
|
||||
mov [timer_ATAPI_check],eax
|
||||
.end_1:
|
||||
popa
|
||||
ret
|
||||
|
||||
.ide3:
|
||||
cli
|
||||
cmp [ATAPI_IDE3_lock],1
|
||||
jne .ide2_1
|
||||
cmp [IDE_Channel_2],0
|
||||
jne .ide1_1
|
||||
cmp [cd_status],0
|
||||
jne .end
|
||||
mov [IDE_Channel_2],1
|
||||
call reserve_ok2
|
||||
mov [ChannelNumber],2
|
||||
mov [DiskNumber],1
|
||||
mov [cdpos],4
|
||||
call GetEvent_StatusNotification
|
||||
cmp [CDDataBuf+4],byte 1
|
||||
je .eject_ide3
|
||||
call syscall_cdaudio.free
|
||||
jmp .ide2_1
|
||||
.eject_ide3:
|
||||
call .eject
|
||||
call syscall_cdaudio.free
|
||||
jmp .ide2_1
|
||||
|
||||
.ide2:
|
||||
cli
|
||||
cmp [ATAPI_IDE2_lock],1
|
||||
jne .ide1_1
|
||||
cmp [IDE_Channel_2],0
|
||||
jne .ide1_1
|
||||
cmp [cd_status],0
|
||||
jne .end
|
||||
mov [IDE_Channel_2],1
|
||||
call reserve_ok2
|
||||
mov [ChannelNumber],2
|
||||
mov [DiskNumber],0
|
||||
mov [cdpos],3
|
||||
call GetEvent_StatusNotification
|
||||
cmp [CDDataBuf+4],byte 1
|
||||
je .eject_ide2
|
||||
call syscall_cdaudio.free
|
||||
jmp .ide1_1
|
||||
.eject_ide2:
|
||||
call .eject
|
||||
call syscall_cdaudio.free
|
||||
jmp .ide1_1
|
||||
|
||||
.ide1:
|
||||
cli
|
||||
cmp [ATAPI_IDE1_lock],1
|
||||
jne .ide0_1
|
||||
cmp [IDE_Channel_1],0
|
||||
jne .end
|
||||
cmp [cd_status],0
|
||||
jne .end
|
||||
mov [IDE_Channel_1],1
|
||||
call reserve_ok2
|
||||
mov [ChannelNumber],1
|
||||
mov [DiskNumber],1
|
||||
mov [cdpos],2
|
||||
call GetEvent_StatusNotification
|
||||
cmp [CDDataBuf+4],byte 1
|
||||
je .eject_ide1
|
||||
call syscall_cdaudio.free
|
||||
jmp .ide0_1
|
||||
.eject_ide1:
|
||||
call .eject
|
||||
call syscall_cdaudio.free
|
||||
jmp .ide0_1
|
||||
|
||||
.ide0:
|
||||
cli
|
||||
cmp [ATAPI_IDE0_lock],1
|
||||
jne .end
|
||||
cmp [IDE_Channel_1],0
|
||||
jne .end
|
||||
cmp [cd_status],0
|
||||
jne .end
|
||||
mov [IDE_Channel_1],1
|
||||
call reserve_ok2
|
||||
mov [ChannelNumber],1
|
||||
mov [DiskNumber],0
|
||||
mov [cdpos],1
|
||||
call GetEvent_StatusNotification
|
||||
cmp [CDDataBuf+4],byte 1
|
||||
je .eject_ide0
|
||||
call syscall_cdaudio.free
|
||||
jmp .end
|
||||
.eject_ide0:
|
||||
call .eject
|
||||
call syscall_cdaudio.free
|
||||
jmp .end
|
||||
|
||||
.eject:
|
||||
call clear_CD_cache
|
||||
call allow_medium_removal
|
||||
mov [ignore_CD_eject_wait],1
|
||||
call EjectMedium
|
||||
mov [ignore_CD_eject_wait],0
|
||||
ret
|
||||
|
||||
timer_ATAPI_check dd 0
|
||||
ATAPI_IDE0_lock db 0
|
||||
ATAPI_IDE1_lock db 0
|
||||
ATAPI_IDE2_lock db 0
|
||||
ATAPI_IDE3_lock db 0
|
||||
ignore_CD_eject_wait db 0
|
||||
|
||||
;*************************************************
|
||||
;* Получить сообщение о событии или состоянии *
|
||||
;* устройства *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
GetEvent_StatusNotification:
|
||||
pusha
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Задать код команды
|
||||
mov [PacketCommand],byte 4Ah
|
||||
mov [PacketCommand+1],byte 00000001b
|
||||
; Задать запрос класса сообщений
|
||||
mov [PacketCommand+4],byte 00010000b
|
||||
; Размер выделенной области
|
||||
mov [PacketCommand+7],byte 8h
|
||||
mov [PacketCommand+8],byte 0h
|
||||
; Подать команду
|
||||
call SendPacketDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
; прочитать информацию из TOC
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
Read_TOC:
|
||||
pusha
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
; Очистить буфер пакетной команды
|
||||
call clear_packet_buffer
|
||||
; Сформировать пакетную команду для считывания
|
||||
; сектора данных
|
||||
mov [PacketCommand],byte 0x43
|
||||
; Задать формат
|
||||
mov [PacketCommand+2],byte 1
|
||||
; Размер выделенной области
|
||||
mov [PacketCommand+7],byte 0xFF
|
||||
mov [PacketCommand+8],byte 0h
|
||||
; Подать команду
|
||||
call SendPacketDatCommand
|
||||
popa
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ОПРЕДЕЛИТЬ ОБЩЕЕ КОЛИЧЕСТВО СЕКТОРОВ НА ДИСКЕ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;*************************************************
|
||||
;ReadCapacity:
|
||||
; pusha
|
||||
;; Очистить буфер пакетной команды
|
||||
; call clear_packet_buffer
|
||||
;; Задать размер буфера в байтах
|
||||
; mov [CDBlockSize],8
|
||||
;; Сформировать команду READ CAPACITY
|
||||
; mov [PacketCommand],word 25h
|
||||
;; Подать команду
|
||||
; call SendPacketDatCommand
|
||||
; popa
|
||||
; ret
|
||||
|
||||
clear_packet_buffer:
|
||||
; Очистить буфер пакетной команды
|
||||
mov [PacketCommand],dword 0
|
||||
mov [PacketCommand+4],dword 0
|
||||
mov [PacketCommand+8],dword 0
|
||||
ret
|
271
kernel/branches/blkdev/cdrom.inc
Normal file
271
kernel/branches/blkdev/cdrom.inc
Normal file
@ -0,0 +1,271 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 593 $
|
||||
|
||||
|
||||
sys_cd_audio:
|
||||
|
||||
cmp word [cdbase],word 0
|
||||
jnz @f
|
||||
mov eax,1
|
||||
ret
|
||||
@@:
|
||||
|
||||
; eax=1 cdplay at ebx 0x00FFSSMM
|
||||
; eax=2 get tracklist size of ecx to [ebx]
|
||||
; eax=3 stop/pause playing
|
||||
|
||||
cmp eax,1
|
||||
jnz nocdp
|
||||
call sys_cdplay
|
||||
ret
|
||||
nocdp:
|
||||
|
||||
cmp eax,2
|
||||
jnz nocdtl
|
||||
mov edi,[TASK_BASE]
|
||||
add edi,TASKDATA.mem_start
|
||||
add ebx,[edi]
|
||||
call sys_cdtracklist
|
||||
ret
|
||||
nocdtl:
|
||||
|
||||
cmp eax,3
|
||||
jnz nocdpause
|
||||
call sys_cdpause
|
||||
ret
|
||||
nocdpause:
|
||||
|
||||
mov eax,0xffffff01
|
||||
ret
|
||||
|
||||
|
||||
|
||||
sys_cd_atapi_command:
|
||||
|
||||
pushad
|
||||
|
||||
mov dx,word [cdbase]
|
||||
add dx,6
|
||||
mov ax,word [cdid]
|
||||
out dx,al
|
||||
mov esi,10
|
||||
call delay_ms
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
in al,dx
|
||||
and al,0x80
|
||||
cmp al,0
|
||||
jnz res
|
||||
jmp cdl6
|
||||
res:
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
mov al,0x8
|
||||
out dx,al
|
||||
mov dx,word [cdbase]
|
||||
add dx,0x206
|
||||
mov al,0xe
|
||||
out dx,al
|
||||
mov esi,1
|
||||
call delay_ms
|
||||
mov dx,word [cdbase]
|
||||
add dx,0x206
|
||||
mov al,0x8
|
||||
out dx,al
|
||||
mov esi,30
|
||||
call delay_ms
|
||||
xor cx,cx
|
||||
cdl5:
|
||||
inc cx
|
||||
cmp cx,10
|
||||
jz cdl6
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
in al,dx
|
||||
and al,0x88
|
||||
cmp al,0x00
|
||||
jz cdl5
|
||||
mov esi,100
|
||||
call delay_ms
|
||||
jmp cdl5
|
||||
cdl6:
|
||||
mov dx,word [cdbase]
|
||||
add dx,4
|
||||
mov al,0
|
||||
out dx,al
|
||||
mov dx,word [cdbase]
|
||||
add dx,5
|
||||
mov al,0
|
||||
out dx,al
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
mov al,0xec
|
||||
out dx,al
|
||||
mov esi,5
|
||||
call delay_ms
|
||||
mov dx,word [cdbase]
|
||||
add dx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
add dx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
add dx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
add dx,1
|
||||
mov al,0
|
||||
out dx,al
|
||||
add dx,1
|
||||
mov al,128
|
||||
out dx,al
|
||||
add dx,2
|
||||
mov al,0xa0
|
||||
out dx,al
|
||||
xor cx,cx
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
cdl1:
|
||||
inc cx
|
||||
cmp cx,100
|
||||
jz cdl2
|
||||
in al,dx
|
||||
and ax,0x88
|
||||
cmp al,0x8
|
||||
jz cdl2
|
||||
mov esi,2
|
||||
call delay_ms
|
||||
jmp cdl1
|
||||
cdl2:
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
sys_cdplay:
|
||||
|
||||
mov ax,5
|
||||
push ax
|
||||
push ebx
|
||||
cdplay:
|
||||
call sys_cd_atapi_command
|
||||
cli
|
||||
mov dx,word [cdbase]
|
||||
mov ax,0x0047
|
||||
out dx,ax
|
||||
mov al,1
|
||||
mov ah,[esp+0] ; min xx
|
||||
out dx,ax
|
||||
mov ax,[esp+1] ; fr sec
|
||||
out dx,ax
|
||||
mov ax,256+99
|
||||
out dx,ax
|
||||
mov ax,0x0001
|
||||
out dx,ax
|
||||
mov ax,0x0000
|
||||
out dx,ax
|
||||
mov esi,10
|
||||
call delay_ms
|
||||
sti
|
||||
add dx,7
|
||||
in al,dx
|
||||
test al,1
|
||||
jz cdplayok
|
||||
mov ax,[esp+4]
|
||||
dec ax
|
||||
mov [esp+4],ax
|
||||
cmp ax,0
|
||||
jz cdplayfail
|
||||
jmp cdplay
|
||||
cdplayfail:
|
||||
cdplayok:
|
||||
pop ebx
|
||||
pop ax
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
|
||||
sys_cdtracklist:
|
||||
|
||||
push ebx
|
||||
tcdplay:
|
||||
call sys_cd_atapi_command
|
||||
mov dx,word [cdbase]
|
||||
mov ax,0x43+2*256
|
||||
out dx,ax
|
||||
mov ax,0x0
|
||||
out dx,ax
|
||||
mov ax,0x0
|
||||
out dx,ax
|
||||
mov ax,0x0
|
||||
out dx,ax
|
||||
mov ax,200
|
||||
out dx,ax
|
||||
mov ax,0x0
|
||||
out dx,ax
|
||||
in al,dx
|
||||
mov cx,1000
|
||||
mov dx,word [cdbase]
|
||||
add dx,7
|
||||
cld
|
||||
cdtrnwewait:
|
||||
mov esi,10
|
||||
call delay_ms
|
||||
in al,dx
|
||||
and al,128
|
||||
cmp al,0
|
||||
jz cdtrl1
|
||||
loop cdtrnwewait
|
||||
cdtrl1:
|
||||
; read the result
|
||||
mov ecx,[esp+0]
|
||||
mov dx,word [cdbase]
|
||||
cdtrread:
|
||||
add dx,7
|
||||
in al,dx
|
||||
and al,8
|
||||
cmp al,8
|
||||
jnz cdtrdone
|
||||
sub dx,7
|
||||
in ax,dx
|
||||
mov [ecx],ax
|
||||
add ecx,2
|
||||
jmp cdtrread
|
||||
cdtrdone:
|
||||
pop ecx
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
|
||||
sys_cdpause:
|
||||
|
||||
call sys_cd_atapi_command
|
||||
|
||||
mov dx,word [cdbase]
|
||||
mov ax,0x004B
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
mov ax,0
|
||||
out dx,ax
|
||||
|
||||
mov esi,10
|
||||
call delay_ms
|
||||
add dx,7
|
||||
in al,dx
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
|
71
kernel/branches/blkdev/fdc.inc
Normal file
71
kernel/branches/blkdev/fdc.inc
Normal file
@ -0,0 +1,71 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 766 $
|
||||
|
||||
|
||||
iglobal
|
||||
;function pointers.
|
||||
fdc_irq_func dd fdc_null
|
||||
endg
|
||||
|
||||
uglobal
|
||||
dmasize db 0x0
|
||||
dmamode db 0x0
|
||||
endg
|
||||
|
||||
fdc_init: ;start with clean tracks.
|
||||
mov edi,OS_BASE+0xD201
|
||||
mov al,0
|
||||
mov ecx,160
|
||||
rep stosb
|
||||
ret
|
||||
|
||||
fdc_irq:
|
||||
call [fdc_irq_func]
|
||||
fdc_null:
|
||||
ret
|
||||
|
||||
save_image:
|
||||
call reserve_flp
|
||||
call restorefatchain
|
||||
pusha
|
||||
call check_label
|
||||
cmp [FDC_Status],0
|
||||
jne unnecessary_save_image
|
||||
mov [FDD_Track],0 ; Öèëèíäð
|
||||
mov [FDD_Head],0 ; Ñòîðîíà
|
||||
mov [FDD_Sector],1 ; Ñåêòîð
|
||||
mov esi,RAMDISK
|
||||
call SeekTrack
|
||||
save_image_1:
|
||||
push esi
|
||||
call take_data_from_application_1
|
||||
pop esi
|
||||
add esi,512
|
||||
call WriteSectWithRetr
|
||||
; call WriteSector
|
||||
cmp [FDC_Status],0
|
||||
jne unnecessary_save_image
|
||||
inc [FDD_Sector]
|
||||
cmp [FDD_Sector],19
|
||||
jne save_image_1
|
||||
mov [FDD_Sector],1
|
||||
inc [FDD_Head]
|
||||
cmp [FDD_Head],2
|
||||
jne save_image_1
|
||||
mov [FDD_Head],0
|
||||
inc [FDD_Track]
|
||||
call SeekTrack
|
||||
cmp [FDD_Track],80
|
||||
jne save_image_1
|
||||
unnecessary_save_image:
|
||||
mov [fdc_irq_func],fdc_null
|
||||
popa
|
||||
mov [flp_status],0
|
||||
ret
|
||||
|
625
kernel/branches/blkdev/flp_drv.inc
Normal file
625
kernel/branches/blkdev/flp_drv.inc
Normal file
@ -0,0 +1,625 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 593 $
|
||||
|
||||
|
||||
;**********************************************************
|
||||
; Непосредственная работа с контроллером гибкого диска
|
||||
;**********************************************************
|
||||
; Автор исходного текста Кулаков Владимир Геннадьевич.
|
||||
; Адаптация и доработка Mario79
|
||||
|
||||
;give_back_application_data: ; переслать приложению
|
||||
; mov edi,[TASK_BASE]
|
||||
; mov edi,[edi+TASKDATA.mem_start]
|
||||
; add edi,ecx
|
||||
give_back_application_data_1:
|
||||
mov esi,FDD_BUFF ;FDD_DataBuffer ;0x40000
|
||||
xor ecx,ecx
|
||||
mov cx,128
|
||||
cld
|
||||
rep movsd
|
||||
ret
|
||||
|
||||
;take_data_from_application: ; взять из приложени
|
||||
; mov esi,[TASK_BASE]
|
||||
; mov esi,[esi+TASKDATA.mem_start]
|
||||
; add esi,ecx
|
||||
take_data_from_application_1:
|
||||
mov edi,FDD_BUFF ;FDD_DataBuffer ;0x40000
|
||||
xor ecx,ecx
|
||||
mov cx,128
|
||||
cld
|
||||
rep movsd
|
||||
ret
|
||||
|
||||
; Коды завершения операции с контроллером (FDC_Status)
|
||||
FDC_Normal equ 0 ;нормальное завершение
|
||||
FDC_TimeOut equ 1 ;ошибка тайм-аута
|
||||
FDC_DiskNotFound equ 2 ;в дисководе нет диска
|
||||
FDC_TrackNotFound equ 3 ;дорожка не найдена
|
||||
FDC_SectorNotFound equ 4 ;сектор не найден
|
||||
|
||||
; Максимальные значения координат сектора (заданные
|
||||
; значения соответствуют параметрам стандартного
|
||||
; трехдюймового гибкого диска объемом 1,44 Мб)
|
||||
MAX_Track equ 79
|
||||
MAX_Head equ 1
|
||||
MAX_Sector equ 18
|
||||
|
||||
uglobal
|
||||
; Счетчик тиков таймера
|
||||
TickCounter dd ?
|
||||
; Код завершения операции с контроллером НГМД
|
||||
FDC_Status DB ?
|
||||
; Флаг прерывания от НГМД
|
||||
FDD_IntFlag DB ?
|
||||
; Момент начала последней операции с НГМД
|
||||
FDD_Time DD ?
|
||||
; Номер дисковода
|
||||
FDD_Type db 0
|
||||
; Координаты сектора
|
||||
FDD_Track DB ?
|
||||
FDD_Head DB ?
|
||||
FDD_Sector DB ?
|
||||
|
||||
; Блок результата операции
|
||||
FDC_ST0 DB ?
|
||||
FDC_ST1 DB ?
|
||||
FDC_ST2 DB ?
|
||||
FDC_C DB ?
|
||||
FDC_H DB ?
|
||||
FDC_R DB ?
|
||||
FDC_N DB ?
|
||||
; Счетчик повторения операции чтени
|
||||
ReadRepCounter DB ?
|
||||
; Счетчик повторения операции рекалибровки
|
||||
RecalRepCounter DB ?
|
||||
endg
|
||||
; Область памяти для хранения прочитанного сектора
|
||||
;FDD_DataBuffer: times 512 db 0 ;DB 512 DUP (?)
|
||||
fdd_motor_status db 0
|
||||
timer_fdd_motor dd 0
|
||||
|
||||
;*************************************
|
||||
;* ИНИЦИАЛИЗАЦИЯ РЕЖИМА ПДП ДЛЯ НГМД *
|
||||
;*************************************
|
||||
Init_FDC_DMA:
|
||||
pushad
|
||||
mov al,0
|
||||
out 0x0c,al ; reset the flip-flop to a known state.
|
||||
mov al,6 ; mask channel 2 so we can reprogram it.
|
||||
out 0x0a,al
|
||||
mov al,[dmamode] ; 0x46 -> Read from floppy - 0x4A Write to floppy
|
||||
out 0x0b,al
|
||||
mov al,0
|
||||
out 0x0c,al ; reset the flip-flop to a known state.
|
||||
mov eax,0xD000
|
||||
out 0x04,al ; set the channel 2 starting address to 0
|
||||
shr eax,8
|
||||
out 0x04,al
|
||||
shr eax,8
|
||||
out 0x81,al
|
||||
mov al,0
|
||||
out 0x0c, al ; reset flip-flop
|
||||
mov al, 0xff ;set count (actual size -1)
|
||||
out 0x5, al
|
||||
mov al,0x1 ;[dmasize] ;(0x1ff = 511 / 0x23ff =9215)
|
||||
out 0x5,al
|
||||
mov al,2
|
||||
out 0xa,al
|
||||
popad
|
||||
ret
|
||||
|
||||
;***********************************
|
||||
;* ЗАПИСАТЬ БАЙТ В ПОРТ ДАННЫХ FDC *
|
||||
;* Параметры: *
|
||||
;* AL - выводимый байт. *
|
||||
;***********************************
|
||||
FDCDataOutput:
|
||||
; pusha
|
||||
push eax ecx edx
|
||||
mov AH,AL ;запомнить байт в AH
|
||||
; Сбросить переменную состояния контроллера
|
||||
mov [FDC_Status],FDC_Normal
|
||||
; Проверить готовность контроллера к приему данных
|
||||
mov DX,3F4h ;(порт состояния FDC)
|
||||
mov ecx, 0x10000 ;установить счетчик тайм-аута
|
||||
@@TestRS:
|
||||
in AL,DX ;прочитать регистр RS
|
||||
and AL,0C0h ;выделить разряды 6 и 7
|
||||
cmp AL,80h ;проверить разряды 6 и 7
|
||||
je @@OutByteToFDC
|
||||
loop @@TestRS
|
||||
; Ошибка тайм-аута
|
||||
mov [FDC_Status],FDC_TimeOut
|
||||
jmp @@End_5
|
||||
; Вывести байт в порт данных
|
||||
@@OutByteToFDC:
|
||||
inc DX
|
||||
mov AL,AH
|
||||
out DX,AL
|
||||
@@End_5:
|
||||
; popa
|
||||
pop edx ecx eax
|
||||
ret
|
||||
|
||||
;******************************************
|
||||
;* ПРОЧИТАТЬ БАЙТ ИЗ ПОРТА ДАННЫХ FDC *
|
||||
;* Процедура не имеет входных параметров. *
|
||||
;* Выходные данные: *
|
||||
;* AL - считанный байт. *
|
||||
;******************************************
|
||||
FDCDataInput:
|
||||
push ECX
|
||||
push DX
|
||||
; Сбросить переменную состояния контроллера
|
||||
mov [FDC_Status],FDC_Normal
|
||||
; Проверить готовность контроллера к передаче данных
|
||||
mov DX,3F4h ;(порт состояния FDC)
|
||||
xor CX,CX ;установить счетчик тайм-аута
|
||||
@@TestRS_1:
|
||||
in AL,DX ;прочитать регистр RS
|
||||
and AL,0C0h ;выдлить разряды 6 и 7
|
||||
cmp AL,0C0h ;проверить разряды 6 и 7
|
||||
je @@GetByteFromFDC
|
||||
loop @@TestRS_1
|
||||
; Ошибка тайм-аута
|
||||
mov [FDC_Status],FDC_TimeOut
|
||||
jmp @@End_6
|
||||
; Ввести байт из порта данных
|
||||
@@GetByteFromFDC:
|
||||
inc DX
|
||||
in AL,DX
|
||||
@@End_6: pop DX
|
||||
pop ECX
|
||||
ret
|
||||
|
||||
;*********************************************
|
||||
;* ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ КОНТРОЛЛЕРА НГМД *
|
||||
;*********************************************
|
||||
FDCInterrupt:
|
||||
; Установить флаг прерывани
|
||||
mov [FDD_IntFlag],1
|
||||
ret
|
||||
|
||||
|
||||
;******************************************
|
||||
;* УСТАНОВИТЬ НОВЫЙ ОБРАБОТЧИК ПРЕРЫВАНИЙ *
|
||||
;* НГМД *
|
||||
;******************************************
|
||||
SetUserInterrupts:
|
||||
mov [fdc_irq_func],FDCInterrupt
|
||||
ret
|
||||
|
||||
;*******************************************
|
||||
;* ОЖИДАНИЕ ПРЕРЫВАНИЯ ОТ КОНТРОЛЛЕРА НГМД *
|
||||
;*******************************************
|
||||
WaitFDCInterrupt:
|
||||
pusha
|
||||
; Сбросить байт состояния операции
|
||||
mov [FDC_Status],FDC_Normal
|
||||
; Сбросить флаг прерывани
|
||||
mov [FDD_IntFlag],0
|
||||
; Обнулить счетчик тиков
|
||||
mov eax,[timer_ticks]
|
||||
mov [TickCounter],eax
|
||||
; Ожидать установки флага прерывания НГМД
|
||||
@@TestRS_2:
|
||||
cmp [FDD_IntFlag],0
|
||||
jnz @@End_7 ;прерывание произошло
|
||||
call change_task
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[TickCounter]
|
||||
cmp eax,50 ;25 ;5 ;ожидать 5 тиков
|
||||
jb @@TestRS_2
|
||||
; jl @@TestRS_2
|
||||
; Ошибка тайм-аута
|
||||
mov [FDC_Status],FDC_TimeOut
|
||||
; mov [flp_status],0
|
||||
@@End_7: popa
|
||||
ret
|
||||
|
||||
;*********************************
|
||||
;* ВКЛЮЧИТЬ МОТОР ДИСКОВОДА "A:" *
|
||||
;*********************************
|
||||
FDDMotorON:
|
||||
pusha
|
||||
; cmp [fdd_motor_status],1
|
||||
; je fdd_motor_on
|
||||
mov al,[flp_number]
|
||||
cmp [fdd_motor_status],al
|
||||
je fdd_motor_on
|
||||
; Произвести сброс контроллера НГМД
|
||||
mov DX,3F2h ;порт управления двигателями
|
||||
mov AL,0
|
||||
out DX,AL
|
||||
; Выбрать и включить мотор дисковода
|
||||
cmp [flp_number],1
|
||||
jne FDDMotorON_B
|
||||
; call FDDMotorOFF_B
|
||||
mov AL,1Ch ; Floppy A
|
||||
jmp FDDMotorON_1
|
||||
FDDMotorON_B:
|
||||
; call FDDMotorOFF_A
|
||||
mov AL,2Dh ; Floppy B
|
||||
FDDMotorON_1:
|
||||
out DX,AL
|
||||
; Обнулить счетчик тиков
|
||||
mov eax,[timer_ticks]
|
||||
mov [TickCounter],eax
|
||||
; Ожидать 0,5 с
|
||||
@@dT:
|
||||
call change_task
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[TickCounter]
|
||||
cmp eax,50 ;10
|
||||
jb @@dT
|
||||
cmp [flp_number],1
|
||||
jne fdd_motor_on_B
|
||||
mov [fdd_motor_status],1
|
||||
jmp fdd_motor_on
|
||||
fdd_motor_on_B:
|
||||
mov [fdd_motor_status],2
|
||||
fdd_motor_on:
|
||||
call save_timer_fdd_motor
|
||||
popa
|
||||
ret
|
||||
|
||||
;*****************************************
|
||||
;* СОХРАНЕНИЕ УКАЗАТЕЛЯ ВРЕМЕНИ *
|
||||
;*****************************************
|
||||
save_timer_fdd_motor:
|
||||
mov eax,[timer_ticks]
|
||||
mov [timer_fdd_motor],eax
|
||||
ret
|
||||
|
||||
;*****************************************
|
||||
;* ПРОВЕРКА ЗАДЕРЖКИ ВЫКЛЮЧЕНИЯ МОТОРА *
|
||||
;*****************************************
|
||||
check_fdd_motor_status:
|
||||
cmp [fdd_motor_status],0
|
||||
je end_check_fdd_motor_status_1
|
||||
mov eax,[timer_ticks]
|
||||
sub eax,[timer_fdd_motor]
|
||||
cmp eax,500
|
||||
jb end_check_fdd_motor_status
|
||||
call FDDMotorOFF
|
||||
mov [fdd_motor_status],0
|
||||
end_check_fdd_motor_status_1:
|
||||
mov [flp_status],0
|
||||
end_check_fdd_motor_status:
|
||||
ret
|
||||
|
||||
;**********************************
|
||||
;* ВЫКЛЮЧИТЬ МОТОР ДИСКОВОДА *
|
||||
;**********************************
|
||||
FDDMotorOFF:
|
||||
push AX
|
||||
push DX
|
||||
cmp [flp_number],1
|
||||
jne FDDMotorOFF_1
|
||||
call FDDMotorOFF_A
|
||||
jmp FDDMotorOFF_2
|
||||
FDDMotorOFF_1:
|
||||
call FDDMotorOFF_B
|
||||
FDDMotorOFF_2:
|
||||
pop DX
|
||||
pop AX
|
||||
; сброс флагов кеширования в связи с устареванием информации
|
||||
mov [root_read],0
|
||||
mov [flp_fat],0
|
||||
ret
|
||||
|
||||
FDDMotorOFF_A:
|
||||
mov DX,3F2h ;порт управления двигателями
|
||||
mov AL,0Ch ; Floppy A
|
||||
out DX,AL
|
||||
ret
|
||||
|
||||
FDDMotorOFF_B:
|
||||
mov DX,3F2h ;порт управления двигателями
|
||||
mov AL,5h ; Floppy B
|
||||
out DX,AL
|
||||
ret
|
||||
|
||||
;*******************************
|
||||
;* РЕКАЛИБРОВКА ДИСКОВОДА "A:" *
|
||||
;*******************************
|
||||
RecalibrateFDD:
|
||||
pusha
|
||||
call save_timer_fdd_motor
|
||||
; Подать команду "Рекалибровка"
|
||||
mov AL,07h
|
||||
call FDCDataOutput
|
||||
mov AL,00h
|
||||
call FDCDataOutput
|
||||
; Ожидать завершения операции
|
||||
call WaitFDCInterrupt
|
||||
; cmp [FDC_Status],0
|
||||
; je no_fdc_status_error
|
||||
; mov [flp_status],0
|
||||
;no_fdc_status_error:
|
||||
call save_timer_fdd_motor
|
||||
popa
|
||||
ret
|
||||
|
||||
;*****************************************************
|
||||
;* ПОИСК ДОРОЖКИ *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;*****************************************************
|
||||
SeekTrack:
|
||||
pusha
|
||||
call save_timer_fdd_motor
|
||||
; Подать команду "Поиск"
|
||||
mov AL,0Fh
|
||||
call FDCDataOutput
|
||||
; Передать байт номера головки/накопител
|
||||
mov AL,[FDD_Head]
|
||||
shl AL,2
|
||||
call FDCDataOutput
|
||||
; Передать байт номера дорожки
|
||||
mov AL,[FDD_Track]
|
||||
call FDCDataOutput
|
||||
; Ожидать завершения операции
|
||||
call WaitFDCInterrupt
|
||||
cmp [FDC_Status],FDC_Normal
|
||||
jne @@Exit
|
||||
; Сохранить результат поиска
|
||||
mov AL,08h
|
||||
call FDCDataOutput
|
||||
call FDCDataInput
|
||||
mov [FDC_ST0],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_C],AL
|
||||
; Проверить результат поиска
|
||||
; Поиск завершен?
|
||||
test [FDC_ST0],100000b
|
||||
je @@Err
|
||||
; Заданный трек найден?
|
||||
mov AL,[FDC_C]
|
||||
cmp AL,[FDD_Track]
|
||||
jne @@Err
|
||||
; Номер головки совпадает с заданным?
|
||||
mov AL,[FDC_ST0]
|
||||
and AL,100b
|
||||
shr AL,2
|
||||
cmp AL,[FDD_Head]
|
||||
jne @@Err
|
||||
; Операция завершена успешно
|
||||
mov [FDC_Status],FDC_Normal
|
||||
jmp @@Exit
|
||||
@@Err: ; Трек не найден
|
||||
mov [FDC_Status],FDC_TrackNotFound
|
||||
; mov [flp_status],0
|
||||
@@Exit:
|
||||
call save_timer_fdd_motor
|
||||
popa
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;* ЧТЕНИЕ СЕКТОРА ДАННЫХ *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1); *
|
||||
;* FDD_Sector - номер сектора (1-18). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;* В случае успешного выполнения операции чтения *
|
||||
;* содержимое сектора будет занесено в FDD_DataBuffer. *
|
||||
;*******************************************************
|
||||
ReadSector:
|
||||
pushad
|
||||
call save_timer_fdd_motor
|
||||
; Установить скорость передачи 500 Кбайт/с
|
||||
mov AX,0
|
||||
mov DX,03F7h
|
||||
out DX,AL
|
||||
; Инициализировать канал прямого доступа к памяти
|
||||
mov [dmamode],0x46
|
||||
call Init_FDC_DMA
|
||||
; Подать команду "Чтение данных"
|
||||
mov AL,0E6h ;чтение в мультитрековом режиме
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Head]
|
||||
shl AL,2
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Track]
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Head]
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Sector]
|
||||
call FDCDataOutput
|
||||
mov AL,2 ;код размера сектора (512 байт)
|
||||
call FDCDataOutput
|
||||
mov AL,18 ;+1; 3Fh ;число секторов на дорожке
|
||||
call FDCDataOutput
|
||||
mov AL,1Bh ;значение GPL
|
||||
call FDCDataOutput
|
||||
mov AL,0FFh ;значение DTL
|
||||
call FDCDataOutput
|
||||
; Ожидаем прерывание по завершении операции
|
||||
call WaitFDCInterrupt
|
||||
cmp [FDC_Status],FDC_Normal
|
||||
jne @@Exit_1
|
||||
; Считываем статус завершения операции
|
||||
call GetStatusInfo
|
||||
test [FDC_ST0],11011000b
|
||||
jnz @@Err_1
|
||||
mov [FDC_Status],FDC_Normal
|
||||
jmp @@Exit_1
|
||||
@@Err_1: mov [FDC_Status],FDC_SectorNotFound
|
||||
; mov [flp_status],0
|
||||
@@Exit_1:
|
||||
call save_timer_fdd_motor
|
||||
popad
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;* ЧТЕНИЕ СЕКТОРА (С ПОВТОРЕНИЕМ ОПЕРАЦИИ ПРИ СБОЕ) *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1); *
|
||||
;* FDD_Sector - номер сектора (1-18). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;* В случае успешного выполнения операции чтения *
|
||||
;* содержимое сектора будет занесено в FDD_DataBuffer. *
|
||||
;*******************************************************
|
||||
ReadSectWithRetr:
|
||||
pusha
|
||||
; Обнулить счетчик повторения операции рекалибровки
|
||||
mov [RecalRepCounter],0
|
||||
@@TryAgain:
|
||||
; Обнулить счетчик повторения операции чтени
|
||||
mov [ReadRepCounter],0
|
||||
@@ReadSector_1:
|
||||
call ReadSector
|
||||
cmp [FDC_Status],0
|
||||
je @@Exit_2
|
||||
cmp [FDC_Status],1
|
||||
je @@Err_3
|
||||
; Троекратное повторение чтени
|
||||
inc [ReadRepCounter]
|
||||
cmp [ReadRepCounter],3
|
||||
jb @@ReadSector_1
|
||||
; Троекратное повторение рекалибровки
|
||||
call RecalibrateFDD
|
||||
call SeekTrack
|
||||
inc [RecalRepCounter]
|
||||
cmp [RecalRepCounter],3
|
||||
jb @@TryAgain
|
||||
; mov [flp_status],0
|
||||
@@Exit_2:
|
||||
popa
|
||||
ret
|
||||
@@Err_3:
|
||||
mov [flp_status],0
|
||||
popa
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;* ЗАПИСЬ СЕКТОРА ДАННЫХ *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1); *
|
||||
;* FDD_Sector - номер сектора (1-18). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;* В случае успешного выполнения операции записи *
|
||||
;* содержимое FDD_DataBuffer будет занесено в сектор. *
|
||||
;*******************************************************
|
||||
WriteSector:
|
||||
pushad
|
||||
call save_timer_fdd_motor
|
||||
; Установить скорость передачи 500 Кбайт/с
|
||||
mov AX,0
|
||||
mov DX,03F7h
|
||||
out DX,AL
|
||||
; Инициализировать канал прямого доступа к памяти
|
||||
mov [dmamode],0x4A
|
||||
call Init_FDC_DMA
|
||||
; Подать команду "Запись данных"
|
||||
mov AL,0xC5 ;0x45 ;запись в мультитрековом режиме
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Head]
|
||||
shl AL,2
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Track]
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Head]
|
||||
call FDCDataOutput
|
||||
mov AL,[FDD_Sector]
|
||||
call FDCDataOutput
|
||||
mov AL,2 ;код размера сектора (512 байт)
|
||||
call FDCDataOutput
|
||||
mov AL,18; 3Fh ;число секторов на дорожке
|
||||
call FDCDataOutput
|
||||
mov AL,1Bh ;значение GPL
|
||||
call FDCDataOutput
|
||||
mov AL,0FFh ;значение DTL
|
||||
call FDCDataOutput
|
||||
; Ожидаем прерывание по завершении операции
|
||||
call WaitFDCInterrupt
|
||||
cmp [FDC_Status],FDC_Normal
|
||||
jne @@Exit_3
|
||||
; Считываем статус завершения операции
|
||||
call GetStatusInfo
|
||||
test [FDC_ST0],11000000b ;11011000b
|
||||
jnz @@Err_2
|
||||
mov [FDC_Status],FDC_Normal
|
||||
jmp @@Exit_3
|
||||
@@Err_2: mov [FDC_Status],FDC_SectorNotFound
|
||||
@@Exit_3:
|
||||
call save_timer_fdd_motor
|
||||
popad
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;* ЗАПИСЬ СЕКТОРА (С ПОВТОРЕНИЕМ ОПЕРАЦИИ ПРИ СБОЕ) *
|
||||
;* Параметры передаются через глобальные переменные: *
|
||||
;* FDD_Track - номер дорожки (0-79); *
|
||||
;* FDD_Head - номер головки (0-1); *
|
||||
;* FDD_Sector - номер сектора (1-18). *
|
||||
;* Результат операции заносится в FDC_Status. *
|
||||
;* В случае успешного выполнения операции записи *
|
||||
;* содержимое FDD_DataBuffer будет занесено в сектор. *
|
||||
;*******************************************************
|
||||
WriteSectWithRetr:
|
||||
pusha
|
||||
; Обнулить счетчик повторения операции рекалибровки
|
||||
mov [RecalRepCounter],0
|
||||
@@TryAgain_1:
|
||||
; Обнулить счетчик повторения операции чтени
|
||||
mov [ReadRepCounter],0
|
||||
@@WriteSector_1:
|
||||
call WriteSector
|
||||
cmp [FDC_Status],0
|
||||
je @@Exit_4
|
||||
cmp [FDC_Status],1
|
||||
je @@Err_4
|
||||
; Троекратное повторение чтени
|
||||
inc [ReadRepCounter]
|
||||
cmp [ReadRepCounter],3
|
||||
jb @@WriteSector_1
|
||||
; Троекратное повторение рекалибровки
|
||||
call RecalibrateFDD
|
||||
call SeekTrack
|
||||
inc [RecalRepCounter]
|
||||
cmp [RecalRepCounter],3
|
||||
jb @@TryAgain_1
|
||||
@@Exit_4:
|
||||
popa
|
||||
ret
|
||||
@@Err_4:
|
||||
mov [flp_status],0
|
||||
popa
|
||||
ret
|
||||
|
||||
;*********************************************
|
||||
;* ПОЛУЧИТЬ ИНФОРМАЦИЮ О РЕЗУЛЬТАТЕ ОПЕРАЦИИ *
|
||||
;*********************************************
|
||||
GetStatusInfo:
|
||||
push AX
|
||||
call FDCDataInput
|
||||
mov [FDC_ST0],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_ST1],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_ST2],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_C],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_H],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_R],AL
|
||||
call FDCDataInput
|
||||
mov [FDC_N],AL
|
||||
pop AX
|
||||
ret
|
||||
|
928
kernel/branches/blkdev/hd_drv.inc
Normal file
928
kernel/branches/blkdev/hd_drv.inc
Normal file
@ -0,0 +1,928 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 820 $
|
||||
|
||||
|
||||
; Low-level driver for HDD access
|
||||
; DMA support by Mario79
|
||||
; Access through BIOS by diamond
|
||||
|
||||
align 4
|
||||
hd_read:
|
||||
;-----------------------------------------------------------
|
||||
; input : eax = block to read
|
||||
; ebx = destination
|
||||
;-----------------------------------------------------------
|
||||
and [hd_error], 0
|
||||
push ecx esi edi ; scan cache
|
||||
|
||||
; mov ecx,cache_max ; entries in cache
|
||||
; mov esi,HD_CACHE+8
|
||||
call calculate_cache
|
||||
add esi,8
|
||||
|
||||
mov edi,1
|
||||
|
||||
hdreadcache:
|
||||
|
||||
cmp dword [esi+4],0 ; empty
|
||||
je nohdcache
|
||||
|
||||
cmp [esi],eax ; correct sector
|
||||
je yeshdcache
|
||||
|
||||
nohdcache:
|
||||
|
||||
add esi,8
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz hdreadcache
|
||||
|
||||
call find_empty_slot ; ret in edi
|
||||
cmp [hd_error],0
|
||||
jne return_01
|
||||
; Read through BIOS?
|
||||
cmp [hdpos], 0x80
|
||||
jae .bios
|
||||
; DMA read is permitted if [allow_dma_access]=1 or 2
|
||||
cmp [allow_dma_access], 2
|
||||
ja .nodma
|
||||
cmp [dma_hdd], 1
|
||||
jnz .nodma
|
||||
call hd_read_dma
|
||||
jmp @f
|
||||
.nodma:
|
||||
call hd_read_pio
|
||||
jmp @f
|
||||
.bios:
|
||||
call bd_read
|
||||
@@:
|
||||
cmp [hd_error], 0
|
||||
jne return_01
|
||||
; lea esi,[edi*8+HD_CACHE]
|
||||
; push eax
|
||||
call calculate_cache_1
|
||||
lea esi,[edi*8+esi]
|
||||
; pop eax
|
||||
|
||||
mov [esi],eax ; sector number
|
||||
mov dword [esi+4],1 ; hd read - mark as same as in hd
|
||||
|
||||
yeshdcache:
|
||||
|
||||
mov esi,edi
|
||||
shl esi,9
|
||||
; add esi,HD_CACHE+65536
|
||||
push eax
|
||||
call calculate_cache_2
|
||||
add esi,eax
|
||||
pop eax
|
||||
|
||||
mov edi,ebx
|
||||
mov ecx,512/4
|
||||
cld
|
||||
rep movsd ; move data
|
||||
return_01:
|
||||
pop edi esi ecx
|
||||
ret
|
||||
|
||||
align 4
|
||||
hd_read_pio:
|
||||
push eax edx
|
||||
|
||||
call wait_for_hd_idle
|
||||
cmp [hd_error],0
|
||||
jne hd_read_error
|
||||
|
||||
cli
|
||||
xor eax,eax
|
||||
mov edx,[hdbase]
|
||||
inc edx
|
||||
out dx,al ; ATAFeatures ॣ¨áâà "®á®¡¥®á⥩"
|
||||
inc edx
|
||||
inc eax
|
||||
out dx,al ; ATASectorCount áçñâ稪 ᥪâ®à®¢
|
||||
inc edx
|
||||
mov eax,[esp+4]
|
||||
out dx,al ; ATASectorNumber ॣ¨áâà ®¬¥à ᥪâ®à
|
||||
shr eax,8
|
||||
inc edx
|
||||
out dx,al ; ATACylinder ®¬¥à 樫¨¤à (¬« ¤è¨© ¡ ©â)
|
||||
shr eax,8
|
||||
inc edx
|
||||
out dx,al ; ®¬¥à 樫¨¤à (áâ à訩 ¡ ©â)
|
||||
shr eax,8
|
||||
inc edx
|
||||
and al,1+2+4+8
|
||||
add al,byte [hdid]
|
||||
add al,128+64+32
|
||||
out dx,al ; ®¬¥à £®«®¢ª¨/®¬¥à ¤¨áª
|
||||
inc edx
|
||||
mov al,20h
|
||||
out dx,al ; ATACommand ॣ¨áâà ª®¬ ¤
|
||||
sti
|
||||
|
||||
call wait_for_sector_buffer
|
||||
|
||||
cmp [hd_error],0
|
||||
jne hd_read_error
|
||||
|
||||
cli
|
||||
push edi
|
||||
shl edi,9
|
||||
; add edi,HD_CACHE+65536
|
||||
push eax
|
||||
call calculate_cache_2
|
||||
add edi,eax
|
||||
pop eax
|
||||
|
||||
mov ecx,256
|
||||
mov edx,[hdbase]
|
||||
cld
|
||||
rep insw
|
||||
pop edi
|
||||
sti
|
||||
|
||||
pop edx eax
|
||||
ret
|
||||
|
||||
disable_ide_int:
|
||||
; mov edx,[hdbase]
|
||||
; add edx,0x206
|
||||
; mov al,2
|
||||
; out dx,al
|
||||
cli
|
||||
ret
|
||||
|
||||
enable_ide_int:
|
||||
; mov edx,[hdbase]
|
||||
; add edx,0x206
|
||||
; mov al,0
|
||||
; out dx,al
|
||||
sti
|
||||
ret
|
||||
|
||||
align 4
|
||||
hd_write:
|
||||
;-----------------------------------------------------------
|
||||
; input : eax = block
|
||||
; ebx = pointer to memory
|
||||
;-----------------------------------------------------------
|
||||
push ecx esi edi
|
||||
|
||||
; check if the cache already has the sector and overwrite it
|
||||
|
||||
; mov ecx,cache_max
|
||||
; mov esi,HD_CACHE+8
|
||||
call calculate_cache
|
||||
add esi,8
|
||||
|
||||
mov edi,1
|
||||
|
||||
hdwritecache:
|
||||
|
||||
cmp dword [esi+4],0 ; if cache slot is empty
|
||||
je not_in_cache_write
|
||||
|
||||
cmp [esi],eax ; if the slot has the sector
|
||||
je yes_in_cache_write
|
||||
|
||||
not_in_cache_write:
|
||||
|
||||
add esi,8
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz hdwritecache
|
||||
|
||||
; sector not found in cache
|
||||
; write the block to a new location
|
||||
|
||||
call find_empty_slot ; ret in edi
|
||||
cmp [hd_error],0
|
||||
jne hd_write_access_denied
|
||||
|
||||
; lea esi,[edi*8+HD_CACHE]
|
||||
; push eax
|
||||
call calculate_cache_1
|
||||
lea esi,[edi*8+esi]
|
||||
; pop eax
|
||||
|
||||
mov [esi],eax ; sector number
|
||||
|
||||
yes_in_cache_write:
|
||||
|
||||
mov dword [esi+4],2 ; write - differs from hd
|
||||
|
||||
shl edi,9
|
||||
; add edi,HD_CACHE+65536
|
||||
push eax
|
||||
call calculate_cache_2
|
||||
add edi,eax
|
||||
pop eax
|
||||
|
||||
mov esi,ebx
|
||||
mov ecx,512/4
|
||||
cld
|
||||
rep movsd ; move data
|
||||
hd_write_access_denied:
|
||||
pop edi esi ecx
|
||||
ret
|
||||
|
||||
align 4
|
||||
cache_write_pio:
|
||||
; call disable_ide_int
|
||||
|
||||
call wait_for_hd_idle
|
||||
cmp [hd_error],0
|
||||
jne hd_write_error
|
||||
|
||||
cli
|
||||
xor eax,eax
|
||||
mov edx,[hdbase]
|
||||
inc edx
|
||||
out dx,al
|
||||
inc edx
|
||||
inc eax
|
||||
out dx,al
|
||||
inc edx
|
||||
mov eax,[esi] ; eax = sector to write
|
||||
out dx,al
|
||||
shr eax,8
|
||||
inc edx
|
||||
out dx,al
|
||||
shr eax,8
|
||||
inc edx
|
||||
out dx,al
|
||||
shr eax,8
|
||||
inc edx
|
||||
and al,1+2+4+8
|
||||
add al,byte [hdid]
|
||||
add al,128+64+32
|
||||
out dx,al
|
||||
inc edx
|
||||
mov al,30h
|
||||
out dx,al
|
||||
sti
|
||||
|
||||
call wait_for_sector_buffer
|
||||
|
||||
cmp [hd_error],0
|
||||
jne hd_write_error
|
||||
|
||||
push ecx esi
|
||||
|
||||
cli
|
||||
mov esi,edi
|
||||
shl esi,9
|
||||
; add esi,HD_CACHE+65536 ; esi = from memory position
|
||||
push eax
|
||||
call calculate_cache_2
|
||||
add esi,eax
|
||||
pop eax
|
||||
|
||||
mov ecx,256
|
||||
mov edx,[hdbase]
|
||||
cld
|
||||
rep outsw
|
||||
sti
|
||||
|
||||
; call enable_ide_int
|
||||
pop esi ecx
|
||||
|
||||
ret
|
||||
|
||||
save_hd_wait_timeout:
|
||||
|
||||
push eax
|
||||
mov eax,[timer_ticks]
|
||||
add eax,300 ; 3 sec timeout
|
||||
mov [hd_wait_timeout],eax
|
||||
pop eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
check_hd_wait_timeout:
|
||||
|
||||
push eax
|
||||
mov eax,[hd_wait_timeout]
|
||||
cmp [timer_ticks], eax
|
||||
jg hd_timeout_error
|
||||
pop eax
|
||||
mov [hd_error],0
|
||||
ret
|
||||
|
||||
;iglobal
|
||||
; hd_timeout_str db 'K : FS - HD timeout',0
|
||||
; hd_read_str db 'K : FS - HD read error',0
|
||||
; hd_write_str db 'K : FS - HD write error',0
|
||||
; hd_lba_str db 'K : FS - HD LBA error',0
|
||||
;endg
|
||||
|
||||
hd_timeout_error:
|
||||
|
||||
; call clear_hd_cache
|
||||
; call clear_application_table_status
|
||||
; mov esi,hd_timeout_str
|
||||
; call sys_msg_board_str
|
||||
DEBUGF 1,"K : FS - HD timeout\n"
|
||||
|
||||
mov [hd_error],1
|
||||
pop eax
|
||||
ret
|
||||
|
||||
hd_read_error:
|
||||
|
||||
; call clear_hd_cache
|
||||
; call clear_application_table_status
|
||||
; mov esi,hd_read_str
|
||||
; call sys_msg_board_str
|
||||
DEBUGF 1,"K : FS - HD read error\n"
|
||||
pop edx eax
|
||||
ret
|
||||
|
||||
hd_write_error:
|
||||
|
||||
; call clear_hd_cache
|
||||
; call clear_application_table_status
|
||||
; mov esi,hd_write_str
|
||||
; call sys_msg_board_str
|
||||
DEBUGF 1,"K : FS - HD write error\n"
|
||||
ret
|
||||
|
||||
hd_write_error_dma:
|
||||
; call clear_hd_cache
|
||||
; call clear_application_table_status
|
||||
; mov esi, hd_write_str
|
||||
; call sys_msg_board_str
|
||||
DEBUGF 1,"K : FS - HD read error\n"
|
||||
pop esi
|
||||
ret
|
||||
|
||||
hd_lba_error:
|
||||
; call clear_hd_cache
|
||||
; call clear_application_table_status
|
||||
; mov esi,hd_lba_str
|
||||
; call sys_msg_board_str
|
||||
DEBUGF 1,"K : FS - HD LBA error\n"
|
||||
jmp LBA_read_ret
|
||||
|
||||
|
||||
align 4
|
||||
wait_for_hd_idle:
|
||||
|
||||
push eax edx
|
||||
|
||||
call save_hd_wait_timeout
|
||||
|
||||
mov edx,[hdbase]
|
||||
add edx,0x7
|
||||
|
||||
wfhil1:
|
||||
|
||||
call check_hd_wait_timeout
|
||||
cmp [hd_error],0
|
||||
jne @f
|
||||
|
||||
in al,dx
|
||||
test al,128
|
||||
jnz wfhil1
|
||||
|
||||
@@:
|
||||
|
||||
pop edx eax
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
wait_for_sector_buffer:
|
||||
|
||||
push eax edx
|
||||
|
||||
mov edx,[hdbase]
|
||||
add edx,0x7
|
||||
|
||||
call save_hd_wait_timeout
|
||||
|
||||
hdwait_sbuf: ; wait for sector buffer to be ready
|
||||
|
||||
call check_hd_wait_timeout
|
||||
cmp [hd_error],0
|
||||
jne @f
|
||||
|
||||
in al,dx
|
||||
test al,8
|
||||
jz hdwait_sbuf
|
||||
|
||||
mov [hd_error],0
|
||||
|
||||
cmp [hd_setup],1 ; do not mark error for setup request
|
||||
je buf_wait_ok
|
||||
|
||||
test al,1 ; previous command ended up with an error
|
||||
jz buf_wait_ok
|
||||
@@:
|
||||
mov [hd_error],1
|
||||
|
||||
buf_wait_ok:
|
||||
|
||||
pop edx eax
|
||||
ret
|
||||
|
||||
; \begin{Mario79}
|
||||
align 4
|
||||
wait_for_sector_dma_ide0:
|
||||
push eax
|
||||
push edx
|
||||
call save_hd_wait_timeout
|
||||
.wait:
|
||||
call change_task
|
||||
cmp [irq14_func], hdd_irq14
|
||||
jnz .done
|
||||
call check_hd_wait_timeout
|
||||
cmp [hd_error], 0
|
||||
jz .wait
|
||||
mov [irq14_func], hdd_irq_null
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov al, 0
|
||||
out dx, al
|
||||
.done:
|
||||
pop edx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
wait_for_sector_dma_ide1:
|
||||
push eax
|
||||
push edx
|
||||
call save_hd_wait_timeout
|
||||
.wait:
|
||||
call change_task
|
||||
cmp [irq15_func], hdd_irq15
|
||||
jnz .done
|
||||
call check_hd_wait_timeout
|
||||
cmp [hd_error], 0
|
||||
jz .wait
|
||||
mov [irq15_func], hdd_irq_null
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
add dx, 8
|
||||
mov al, 0
|
||||
out dx, al
|
||||
.done:
|
||||
pop edx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
iglobal
|
||||
align 4
|
||||
; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary
|
||||
IDE_descriptor_table:
|
||||
dd IDE_DMA
|
||||
dw 0x2000
|
||||
dw 0x8000
|
||||
|
||||
dma_cur_sector dd not 40h
|
||||
dma_hdpos dd 0
|
||||
irq14_func dd hdd_irq_null
|
||||
irq15_func dd hdd_irq_null
|
||||
endg
|
||||
|
||||
uglobal
|
||||
; all uglobals are zeroed at boot
|
||||
dma_process dd 0
|
||||
dma_slot_ptr dd 0
|
||||
cache_chain_pos dd 0
|
||||
cache_chain_ptr dd 0
|
||||
cache_chain_size db 0
|
||||
cache_chain_started db 0
|
||||
dma_task_switched db 0
|
||||
dma_hdd db 0
|
||||
allow_dma_access db 0
|
||||
endg
|
||||
|
||||
align 4
|
||||
hdd_irq14:
|
||||
pushfd
|
||||
cli
|
||||
pushad
|
||||
mov [irq14_func], hdd_irq_null
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov al, 0
|
||||
out dx, al
|
||||
; call update_counters
|
||||
; mov ebx, [dma_process]
|
||||
; cmp [CURRENT_TASK], ebx
|
||||
; jz .noswitch
|
||||
; mov [dma_task_switched], 1
|
||||
; mov edi, [dma_slot_ptr]
|
||||
; mov eax, [CURRENT_TASK]
|
||||
; mov [dma_process], eax
|
||||
; mov eax, [TASK_BASE]
|
||||
; mov [dma_slot_ptr], eax
|
||||
; mov [CURRENT_TASK], ebx
|
||||
; mov [TASK_BASE], edi
|
||||
; mov byte [DONT_SWITCH], 1
|
||||
; call do_change_task
|
||||
.noswitch:
|
||||
popad
|
||||
popfd
|
||||
align 4
|
||||
hdd_irq_null:
|
||||
ret
|
||||
|
||||
align 4
|
||||
hdd_irq15:
|
||||
pushfd
|
||||
cli
|
||||
pushad
|
||||
mov [irq15_func], hdd_irq_null
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
add dx, 8
|
||||
mov al, 0
|
||||
out dx, al
|
||||
; call update_counters
|
||||
; mov ebx, [dma_process]
|
||||
; cmp [CURRENT_TASK], ebx
|
||||
; jz .noswitch
|
||||
; mov [dma_task_switched], 1
|
||||
; mov edi, [dma_slot_ptr]
|
||||
; mov eax, [CURRENT_TASK]
|
||||
; mov [dma_process], eax
|
||||
; mov eax, [TASK_BASE]
|
||||
; mov [dma_slot_ptr], eax
|
||||
; mov [CURRENT_TASK], ebx
|
||||
; mov [TASK_BASE], edi
|
||||
; mov byte [DONT_SWITCH], 1
|
||||
; call do_change_task
|
||||
.noswitch:
|
||||
popad
|
||||
popfd
|
||||
ret
|
||||
|
||||
align 4
|
||||
hd_read_dma:
|
||||
push eax
|
||||
push edx
|
||||
mov edx,[dma_hdpos]
|
||||
cmp edx,[hdpos]
|
||||
jne .notread
|
||||
mov edx, [dma_cur_sector]
|
||||
cmp eax, edx
|
||||
jb .notread
|
||||
add edx, 15
|
||||
cmp [esp+4], edx
|
||||
ja .notread
|
||||
mov eax, [esp+4]
|
||||
sub eax, [dma_cur_sector]
|
||||
shl eax, 9
|
||||
add eax, (OS_BASE+IDE_DMA)
|
||||
push ecx esi edi
|
||||
mov esi, eax
|
||||
shl edi, 9
|
||||
; add edi, HD_CACHE+0x10000
|
||||
push eax
|
||||
call calculate_cache_2
|
||||
add edi,eax
|
||||
pop eax
|
||||
|
||||
mov ecx, 512/4
|
||||
cld
|
||||
rep movsd
|
||||
pop edi esi ecx
|
||||
pop edx
|
||||
pop eax
|
||||
ret
|
||||
.notread:
|
||||
mov eax, IDE_descriptor_table
|
||||
mov dword [eax], IDE_DMA
|
||||
mov word [eax+4], 0x2000
|
||||
sub eax, OS_BASE
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
cmp [hdbase], 0x1F0
|
||||
jz @f
|
||||
add edx, 8
|
||||
@@:
|
||||
push edx
|
||||
add edx, 4
|
||||
out dx, eax
|
||||
pop edx
|
||||
mov al, 0
|
||||
out dx, al
|
||||
add edx, 2
|
||||
mov al, 6
|
||||
out dx, al
|
||||
call wait_for_hd_idle
|
||||
cmp [hd_error], 0
|
||||
jnz hd_read_error
|
||||
call disable_ide_int
|
||||
xor eax, eax
|
||||
mov edx, [hdbase]
|
||||
inc edx
|
||||
out dx, al
|
||||
inc edx
|
||||
mov eax, 10h
|
||||
out dx, al
|
||||
inc edx
|
||||
mov eax, [esp+4]
|
||||
out dx, al
|
||||
shr eax, 8
|
||||
inc edx
|
||||
out dx, al
|
||||
shr eax, 8
|
||||
inc edx
|
||||
out dx, al
|
||||
shr eax, 8
|
||||
inc edx
|
||||
and al, 0xF
|
||||
add al, byte [hdid]
|
||||
add al, 11100000b
|
||||
out dx, al
|
||||
inc edx
|
||||
mov al, 0xC8
|
||||
out dx, al
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
cmp [hdbase], 0x1F0
|
||||
jz @f
|
||||
add dx, 8
|
||||
@@:
|
||||
mov al, 9
|
||||
out dx, al
|
||||
mov eax, [CURRENT_TASK]
|
||||
mov [dma_process], eax
|
||||
mov eax, [TASK_BASE]
|
||||
mov [dma_slot_ptr], eax
|
||||
cmp [hdbase], 0x1F0
|
||||
jnz .ide1
|
||||
mov [irq14_func], hdd_irq14
|
||||
jmp @f
|
||||
.ide1:
|
||||
mov [irq15_func], hdd_irq15
|
||||
@@:
|
||||
call enable_ide_int
|
||||
cmp [hdbase], 0x1F0
|
||||
jnz .wait_ide1
|
||||
call wait_for_sector_dma_ide0
|
||||
jmp @f
|
||||
.wait_ide1:
|
||||
call wait_for_sector_dma_ide1
|
||||
@@:
|
||||
cmp [hd_error], 0
|
||||
jnz hd_read_error
|
||||
mov eax,[hdpos]
|
||||
mov [dma_hdpos],eax
|
||||
pop edx
|
||||
pop eax
|
||||
mov [dma_cur_sector], eax
|
||||
jmp hd_read_dma
|
||||
|
||||
align 4
|
||||
write_cache_sector:
|
||||
mov [cache_chain_size],1
|
||||
mov [cache_chain_pos],edi
|
||||
write_cache_chain:
|
||||
cmp [hdpos], 0x80
|
||||
jae bd_write_cache_chain
|
||||
push esi
|
||||
mov eax, IDE_descriptor_table
|
||||
mov edx,eax
|
||||
pusha
|
||||
mov esi,[cache_chain_pos]
|
||||
shl esi, 9
|
||||
call calculate_cache_2
|
||||
add esi,eax
|
||||
mov edi, (OS_BASE+IDE_DMA)
|
||||
mov dword [edx], IDE_DMA
|
||||
movzx ecx, [cache_chain_size]
|
||||
shl ecx, 9
|
||||
mov word [edx+4], cx
|
||||
shr ecx,2
|
||||
cld
|
||||
rep movsd
|
||||
popa
|
||||
sub eax, OS_BASE
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
cmp [hdbase], 0x1F0
|
||||
jz @f
|
||||
add edx, 8
|
||||
@@:
|
||||
push edx
|
||||
add edx, 4
|
||||
out dx, eax
|
||||
pop edx
|
||||
mov al, 0
|
||||
out dx, al
|
||||
add edx, 2
|
||||
mov al, 6
|
||||
out dx, al
|
||||
call wait_for_hd_idle
|
||||
cmp [hd_error], 0
|
||||
jnz hd_write_error_dma
|
||||
call disable_ide_int
|
||||
xor eax, eax
|
||||
mov edx, [hdbase]
|
||||
inc edx
|
||||
out dx, al
|
||||
inc edx
|
||||
mov al, [cache_chain_size]
|
||||
out dx, al
|
||||
inc edx
|
||||
mov esi, [cache_chain_ptr]
|
||||
mov eax, [esi]
|
||||
out dx, al
|
||||
shr eax, 8
|
||||
inc edx
|
||||
out dx, al
|
||||
shr eax, 8
|
||||
inc edx
|
||||
out dx, al
|
||||
shr eax, 8
|
||||
inc edx
|
||||
and al, 0xF
|
||||
add al, byte [hdid]
|
||||
add al, 11100000b
|
||||
out dx, al
|
||||
inc edx
|
||||
mov al, 0xCA
|
||||
out dx, al
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
cmp [hdbase], 0x1F0
|
||||
jz @f
|
||||
add dx, 8
|
||||
@@:
|
||||
mov al, 1
|
||||
out dx, al
|
||||
mov eax, [CURRENT_TASK]
|
||||
mov [dma_process], eax
|
||||
mov eax, [TASK_BASE]
|
||||
mov [dma_slot_ptr], eax
|
||||
cmp [hdbase], 0x1F0
|
||||
jnz .ide1
|
||||
mov [irq14_func], hdd_irq14
|
||||
jmp @f
|
||||
.ide1:
|
||||
mov [irq15_func], hdd_irq15
|
||||
@@:
|
||||
call enable_ide_int
|
||||
mov [dma_cur_sector], not 0x40
|
||||
cmp [hdbase], 0x1F0
|
||||
jnz .wait_ide1
|
||||
call wait_for_sector_dma_ide0
|
||||
jmp @f
|
||||
.wait_ide1:
|
||||
call wait_for_sector_dma_ide1
|
||||
@@:
|
||||
cmp [hd_error], 0
|
||||
jnz hd_write_error_dma
|
||||
pop esi
|
||||
ret
|
||||
|
||||
uglobal
|
||||
IDEContrRegsBaseAddr dw ?
|
||||
endg
|
||||
; \end{Mario79}
|
||||
|
||||
; \begin{diamond}
|
||||
uglobal
|
||||
bios_hdpos dd 0 ; 0 is invalid value for [hdpos]
|
||||
bios_cur_sector dd ?
|
||||
bios_read_len dd ?
|
||||
endg
|
||||
bd_read:
|
||||
push eax
|
||||
push edx
|
||||
mov edx, [bios_hdpos]
|
||||
cmp edx, [hdpos]
|
||||
jne .notread
|
||||
mov edx, [bios_cur_sector]
|
||||
cmp eax, edx
|
||||
jb .notread
|
||||
add edx, [bios_read_len]
|
||||
dec edx
|
||||
cmp eax, edx
|
||||
ja .notread
|
||||
sub eax, [bios_cur_sector]
|
||||
shl eax, 9
|
||||
add eax, (OS_BASE+0x9A000)
|
||||
push ecx esi edi
|
||||
mov esi, eax
|
||||
shl edi, 9
|
||||
; add edi, HD_CACHE+0x10000
|
||||
push eax
|
||||
call calculate_cache_2
|
||||
add edi,eax
|
||||
pop eax
|
||||
|
||||
mov ecx, 512/4
|
||||
cld
|
||||
rep movsd
|
||||
pop edi esi ecx
|
||||
pop edx
|
||||
pop eax
|
||||
ret
|
||||
.notread:
|
||||
push ecx
|
||||
mov dl, 42h
|
||||
mov ecx, 16
|
||||
call int13_call
|
||||
pop ecx
|
||||
test eax, eax
|
||||
jnz .v86err
|
||||
test edx, edx
|
||||
jz .readerr
|
||||
mov [bios_read_len], edx
|
||||
mov edx, [hdpos]
|
||||
mov [bios_hdpos], edx
|
||||
pop edx
|
||||
pop eax
|
||||
mov [bios_cur_sector], eax
|
||||
jmp bd_read
|
||||
.readerr:
|
||||
.v86err:
|
||||
mov [hd_error], 1
|
||||
jmp hd_read_error
|
||||
|
||||
bd_write_cache_chain:
|
||||
pusha
|
||||
mov esi, [cache_chain_pos]
|
||||
shl esi, 9
|
||||
call calculate_cache_2
|
||||
add esi, eax
|
||||
mov edi, OS_BASE + 0x9A000
|
||||
movzx ecx, [cache_chain_size]
|
||||
push ecx
|
||||
shl ecx, 9-2
|
||||
rep movsd
|
||||
pop ecx
|
||||
mov dl, 43h
|
||||
mov eax, [cache_chain_ptr]
|
||||
mov eax, [eax]
|
||||
call int13_call
|
||||
test eax, eax
|
||||
jnz .v86err
|
||||
cmp edx, ecx
|
||||
jnz .writeerr
|
||||
popa
|
||||
ret
|
||||
.v86err:
|
||||
.writeerr:
|
||||
popa
|
||||
mov [hd_error], 1
|
||||
jmp hd_write_error
|
||||
|
||||
uglobal
|
||||
int13_regs_in rb v86_regs.size
|
||||
int13_regs_out rb v86_regs.size
|
||||
endg
|
||||
|
||||
int13_call:
|
||||
; Because this code uses fixed addresses,
|
||||
; it can not be run simultaniously by many threads.
|
||||
; In current implementation it is protected by common mutex 'hd1_status'
|
||||
mov word [BOOT_VAR + 510h], 10h ; packet length
|
||||
mov word [BOOT_VAR + 512h], cx ; number of sectors
|
||||
mov dword [BOOT_VAR + 514h], 9A000000h ; buffer 9A00:0000
|
||||
mov dword [BOOT_VAR + 518h], eax
|
||||
and dword [BOOT_VAR + 51Ch], 0
|
||||
push ebx ecx esi edi
|
||||
mov ebx, int13_regs_in
|
||||
mov edi, ebx
|
||||
mov ecx, v86_regs.size/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
mov byte [ebx+v86_regs.eax+1], dl
|
||||
mov eax, [hdpos]
|
||||
lea eax, [BiosDisksData+(eax-80h)*4]
|
||||
mov dl, [eax]
|
||||
mov byte [ebx+v86_regs.edx], dl
|
||||
movzx edx, byte [eax+1]
|
||||
; mov dl, 5
|
||||
test edx, edx
|
||||
jnz .hasirq
|
||||
dec edx
|
||||
jmp @f
|
||||
.hasirq:
|
||||
pushad
|
||||
stdcall enable_irq, edx
|
||||
popad
|
||||
@@:
|
||||
mov word [ebx+v86_regs.esi], 510h
|
||||
mov word [ebx+v86_regs.ss], 9000h
|
||||
mov word [ebx+v86_regs.esp], 0A000h
|
||||
mov word [ebx+v86_regs.eip], 500h
|
||||
mov [ebx+v86_regs.eflags], 20200h
|
||||
mov esi, [sys_v86_machine]
|
||||
mov ecx, 0x502
|
||||
call v86_start
|
||||
and [bios_hdpos], 0
|
||||
pop edi esi ecx ebx
|
||||
movzx edx, byte [BOOT_VAR + 512h]
|
||||
test byte [int13_regs_out+v86_regs.eflags], 1
|
||||
jnz @f
|
||||
mov edx, ecx
|
||||
@@:
|
||||
ret
|
||||
; \end{diamond}
|
922
kernel/branches/blkdev/ide_cache.inc
Normal file
922
kernel/branches/blkdev/ide_cache.inc
Normal file
@ -0,0 +1,922 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;**************************************************************************
|
||||
;
|
||||
; [cache_ide[X]_pointer]
|
||||
; or [cache_ide[X]_data_pointer] first entry in cache list
|
||||
;
|
||||
; +0 - lba sector
|
||||
; +4 - state of cache sector
|
||||
; 0 = empty
|
||||
; 1 = used for read ( same as in hd )
|
||||
; 2 = used for write ( differs from hd )
|
||||
;
|
||||
; [cache_ide[X]_system_data]
|
||||
; or [cache_ide[x]_appl_data] - cache entries
|
||||
;
|
||||
;**************************************************************************
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
align 4
|
||||
write_cache:
|
||||
;-----------------------------------------------------------
|
||||
; write all changed sectors to disk
|
||||
;-----------------------------------------------------------
|
||||
push eax ecx edx esi edi
|
||||
|
||||
; write difference ( 2 ) from cache to hd
|
||||
call calculate_cache
|
||||
add esi,8
|
||||
mov edi,1
|
||||
write_cache_more:
|
||||
cmp dword [esi+4],2 ; if cache slot is not different
|
||||
jne .write_chain
|
||||
mov dword [esi+4],1 ; same as in hd
|
||||
mov eax,[esi] ; eax = sector to write
|
||||
cmp eax,[PARTITION_START]
|
||||
jb danger
|
||||
cmp eax,[PARTITION_END]
|
||||
ja danger
|
||||
cmp [hdpos], 0x80
|
||||
jae @f
|
||||
; DMA write is permitted only if [allow_dma_access]=1
|
||||
cmp [allow_dma_access], 2
|
||||
jae .nodma
|
||||
cmp [dma_hdd], 1
|
||||
jnz .nodma
|
||||
@@:
|
||||
; Ž¡ê¥¤¨ï¥¬ § ¯¨áì 楯®çª¨ ¯®á«¥¤®¢ ⥫ìëå ᥪâ®à®¢ ¢ ®¤® ®¡à 饨¥ ª ¤¨áªã
|
||||
cmp ecx, 1
|
||||
jz .nonext
|
||||
cmp dword [esi+8+4], 2
|
||||
jnz .nonext
|
||||
push eax
|
||||
inc eax
|
||||
cmp eax, [esi+8]
|
||||
pop eax
|
||||
jnz .nonext
|
||||
cmp [cache_chain_started], 1
|
||||
jz @f
|
||||
mov [cache_chain_started], 1
|
||||
mov [cache_chain_size], 0
|
||||
mov [cache_chain_pos], edi
|
||||
mov [cache_chain_ptr], esi
|
||||
@@:
|
||||
inc [cache_chain_size]
|
||||
cmp [cache_chain_size], 16
|
||||
jnz .continue
|
||||
jmp .write_chain
|
||||
.nonext:
|
||||
call flush_cache_chain
|
||||
mov [cache_chain_size], 1
|
||||
mov [cache_chain_ptr], esi
|
||||
call write_cache_sector
|
||||
jmp .continue
|
||||
.nodma:
|
||||
call cache_write_pio
|
||||
.write_chain:
|
||||
call flush_cache_chain
|
||||
.continue:
|
||||
danger:
|
||||
add esi,8
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz write_cache_more
|
||||
call flush_cache_chain
|
||||
return_02:
|
||||
pop edi esi edx ecx eax
|
||||
ret
|
||||
|
||||
flush_cache_chain:
|
||||
cmp [cache_chain_started], 0
|
||||
jz @f
|
||||
call write_cache_chain
|
||||
mov [cache_chain_started], 0
|
||||
@@:
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
find_empty_slot:
|
||||
;-----------------------------------------------------------
|
||||
; find empty or read slot, flush cache if next 10% is used by write
|
||||
; output : edi = cache slot
|
||||
;-----------------------------------------------------------
|
||||
; push ecx esi
|
||||
|
||||
search_again:
|
||||
call calculate_cache_3
|
||||
shr ecx,3
|
||||
search_for_empty:
|
||||
inc edi
|
||||
call calculate_cache_4
|
||||
jbe inside_cache
|
||||
mov edi,1
|
||||
inside_cache:
|
||||
push esi
|
||||
call calculate_cache_1
|
||||
cmp dword [edi*8+esi+4],2
|
||||
pop esi
|
||||
jb found_slot ; it's empty or read
|
||||
dec ecx
|
||||
jnz search_for_empty
|
||||
call write_cache ; no empty slots found, write all
|
||||
cmp [hd_error],0
|
||||
jne found_slot_access_denied
|
||||
jmp search_again ; and start again
|
||||
found_slot:
|
||||
call calculate_cache_5
|
||||
found_slot_access_denied:
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
clear_hd_cache:
|
||||
mov [fat_in_cache],-1
|
||||
mov [fat_change],0
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache:
|
||||
; mov ecx,cache_max ; entries in cache
|
||||
; mov esi,HD_CACHE+8
|
||||
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [hdpos],1
|
||||
jne .ide1
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov ecx,[cache_ide0_system_sad_size]
|
||||
mov esi,[cache_ide0_pointer]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov ecx,[cache_ide0_appl_sad_size]
|
||||
mov esi,[cache_ide0_data_pointer]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [hdpos],2
|
||||
jne .ide2
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov ecx,[cache_ide1_system_sad_size]
|
||||
mov esi,[cache_ide1_pointer]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov ecx,[cache_ide1_appl_sad_size]
|
||||
mov esi,[cache_ide1_data_pointer]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [hdpos],3
|
||||
jne .ide3
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov ecx,[cache_ide2_system_sad_size]
|
||||
mov esi,[cache_ide2_pointer]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov ecx,[cache_ide2_appl_sad_size]
|
||||
mov esi,[cache_ide2_data_pointer]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov ecx,[cache_ide3_system_sad_size]
|
||||
mov esi,[cache_ide3_pointer]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov ecx,[cache_ide3_appl_sad_size]
|
||||
mov esi,[cache_ide3_data_pointer]
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov ecx,[cache_ide0_system_sad_size-cache_ide0+eax]
|
||||
mov esi,[cache_ide0_pointer-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov ecx,[cache_ide0_appl_sad_size-cache_ide0+eax]
|
||||
mov esi,[cache_ide0_data_pointer-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_1:
|
||||
; lea esi,[edi*8+HD_CACHE]
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [hdpos],1
|
||||
jne .ide1
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov esi,[cache_ide0_pointer]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov esi,[cache_ide0_data_pointer]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [hdpos],2
|
||||
jne .ide2
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov esi,[cache_ide1_pointer]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov esi,[cache_ide1_data_pointer]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [hdpos],3
|
||||
jne .ide3
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov esi,[cache_ide2_pointer]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov esi,[cache_ide2_data_pointer]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov esi,[cache_ide3_pointer]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov esi,[cache_ide3_data_pointer]
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov esi,[cache_ide0_pointer-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov esi,[cache_ide0_data_pointer-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_2:
|
||||
; add esi,HD_CACHE+65536
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [hdpos],1
|
||||
jne .ide1
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov eax,[cache_ide0_system_data]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov eax,[cache_ide0_appl_data]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [hdpos],2
|
||||
jne .ide2
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov eax,[cache_ide1_system_data]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov eax,[cache_ide1_appl_data]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [hdpos],3
|
||||
jne .ide3
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov eax,[cache_ide2_system_data]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov eax,[cache_ide2_appl_data]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov eax,[cache_ide3_system_data]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov eax,[cache_ide3_appl_data]
|
||||
ret
|
||||
.noide:
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov eax,[cache_ide0_system_data-cache_ide0+eax]
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov eax,[cache_ide0_appl_data-cache_ide0+eax]
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_3:
|
||||
; mov ecx,cache_max*10/100
|
||||
; mov edi,[cache_search_start]
|
||||
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [hdpos],1
|
||||
jne .ide1
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov ecx,[cache_ide0_system_sad_size]
|
||||
mov edi,[cache_ide0_search_start]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov ecx,[cache_ide0_appl_sad_size]
|
||||
mov edi,[cache_ide0_appl_search_start]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [hdpos],2
|
||||
jne .ide2
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov ecx,[cache_ide1_system_sad_size]
|
||||
mov edi,[cache_ide1_search_start]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov ecx,[cache_ide1_appl_sad_size]
|
||||
mov edi,[cache_ide1_appl_search_start]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [hdpos],3
|
||||
jne .ide3
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov ecx,[cache_ide2_system_sad_size]
|
||||
mov edi,[cache_ide2_search_start]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov ecx,[cache_ide2_appl_sad_size]
|
||||
mov edi,[cache_ide2_appl_search_start]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov ecx,[cache_ide3_system_sad_size]
|
||||
mov edi,[cache_ide3_search_start]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov ecx,[cache_ide3_appl_sad_size]
|
||||
mov edi,[cache_ide3_appl_search_start]
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov ecx,[cache_ide0_system_sad_size-cache_ide0+eax]
|
||||
mov edi,[cache_ide0_search_start-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov ecx,[cache_ide0_appl_sad_size-cache_ide0+eax]
|
||||
mov edi,[cache_ide0_appl_search_start-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_4:
|
||||
; cmp edi,cache_max
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [hdpos],1
|
||||
jne .ide1
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
cmp edi,[cache_ide0_system_sad_size]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
cmp edi,[cache_ide0_appl_sad_size]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [hdpos],2
|
||||
jne .ide2
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
cmp edi,[cache_ide1_system_sad_size]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
cmp edi,[cache_ide1_appl_sad_size]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [hdpos],3
|
||||
jne .ide3
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
cmp edi,[cache_ide2_system_sad_size]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
cmp edi,[cache_ide2_appl_sad_size]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
cmp edi,[cache_ide3_system_sad_size]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
cmp edi,[cache_ide3_appl_sad_size]
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
cmp edi,[cache_ide0_system_sad_size-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
cmp edi,[cache_ide0_appl_sad_size-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_5:
|
||||
; mov [cache_search_start],edi
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [hdpos],1
|
||||
jne .ide1
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov [cache_ide0_search_start],edi
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov [cache_ide0_appl_search_start],edi
|
||||
ret
|
||||
.ide1:
|
||||
cmp [hdpos],2
|
||||
jne .ide2
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov [cache_ide1_search_start],edi
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov [cache_ide1_appl_search_start],edi
|
||||
ret
|
||||
.ide2:
|
||||
cmp [hdpos],3
|
||||
jne .ide3
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov [cache_ide2_search_start],edi
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov [cache_ide2_appl_search_start],edi
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov [cache_ide3_search_start],edi
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov [cache_ide3_appl_search_start],edi
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov [cache_ide0_search_start-cache_ide0+eax],edi
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov [cache_ide0_appl_search_start-cache_ide0+eax],edi
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
find_empty_slot_CD_cache:
|
||||
;-----------------------------------------------------------
|
||||
; find empty or read slot, flush cache if next 10% is used by write
|
||||
; output : edi = cache slot
|
||||
;-----------------------------------------------------------
|
||||
.search_again:
|
||||
call cd_calculate_cache_3
|
||||
.search_for_empty:
|
||||
inc edi
|
||||
call cd_calculate_cache_4
|
||||
jbe .inside_cache
|
||||
mov edi,1
|
||||
.inside_cache:
|
||||
call cd_calculate_cache_5
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
clear_CD_cache:
|
||||
pusha
|
||||
.ide0:
|
||||
xor eax,eax
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
mov [cache_ide0_search_start],eax
|
||||
mov ecx,[cache_ide0_system_sad_size]
|
||||
mov edi,[cache_ide0_pointer]
|
||||
call .clear
|
||||
mov [cache_ide0_appl_search_start],eax
|
||||
mov ecx,[cache_ide0_appl_sad_size]
|
||||
mov edi,[cache_ide0_data_pointer]
|
||||
jmp .continue
|
||||
.ide1:
|
||||
cmp [cdpos],2
|
||||
jne .ide2
|
||||
mov [cache_ide1_search_start],eax
|
||||
mov ecx,[cache_ide1_system_sad_size]
|
||||
mov edi,[cache_ide1_pointer]
|
||||
call .clear
|
||||
mov [cache_ide1_appl_search_start],eax
|
||||
mov ecx,[cache_ide1_appl_sad_size]
|
||||
mov edi,[cache_ide1_data_pointer]
|
||||
jmp .continue
|
||||
.ide2:
|
||||
cmp [cdpos],3
|
||||
jne .ide3
|
||||
mov [cache_ide2_search_start],eax
|
||||
mov ecx,[cache_ide2_system_sad_size]
|
||||
mov edi,[cache_ide2_pointer]
|
||||
call .clear
|
||||
mov [cache_ide2_appl_search_start],eax
|
||||
mov ecx,[cache_ide2_appl_sad_size]
|
||||
mov edi,[cache_ide2_data_pointer]
|
||||
jmp .continue
|
||||
.ide3:
|
||||
mov [cache_ide3_search_start],eax
|
||||
mov ecx,[cache_ide3_system_sad_size]
|
||||
mov edi,[cache_ide3_pointer]
|
||||
call .clear
|
||||
mov [cache_ide3_appl_search_start],eax
|
||||
mov ecx,[cache_ide3_appl_sad_size]
|
||||
mov edi,[cache_ide3_data_pointer]
|
||||
.continue:
|
||||
call .clear
|
||||
popa
|
||||
ret
|
||||
.clear:
|
||||
shl ecx,1
|
||||
cld
|
||||
rep stosd
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache:
|
||||
; mov ecx,cache_max ; entries in cache
|
||||
; mov esi,HD_CACHE+8
|
||||
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov ecx,[cache_ide0_system_sad_size]
|
||||
mov esi,[cache_ide0_pointer]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov ecx,[cache_ide0_appl_sad_size]
|
||||
mov esi,[cache_ide0_data_pointer]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [cdpos],2
|
||||
jne .ide2
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov ecx,[cache_ide1_system_sad_size]
|
||||
mov esi,[cache_ide1_pointer]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov ecx,[cache_ide1_appl_sad_size]
|
||||
mov esi,[cache_ide1_data_pointer]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [cdpos],3
|
||||
jne .ide3
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov ecx,[cache_ide2_system_sad_size]
|
||||
mov esi,[cache_ide2_pointer]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov ecx,[cache_ide2_appl_sad_size]
|
||||
mov esi,[cache_ide2_data_pointer]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov ecx,[cache_ide3_system_sad_size]
|
||||
mov esi,[cache_ide3_pointer]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov ecx,[cache_ide3_appl_sad_size]
|
||||
mov esi,[cache_ide3_data_pointer]
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_1:
|
||||
; lea esi,[edi*8+HD_CACHE]
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov esi,[cache_ide0_pointer]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov esi,[cache_ide0_data_pointer]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [cdpos],2
|
||||
jne .ide2
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov esi,[cache_ide1_pointer]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov esi,[cache_ide1_data_pointer]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [cdpos],3
|
||||
jne .ide3
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov esi,[cache_ide2_pointer]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov esi,[cache_ide2_data_pointer]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov esi,[cache_ide3_pointer]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov esi,[cache_ide3_data_pointer]
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_2:
|
||||
; add esi,HD_CACHE+65536
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov eax,[cache_ide0_system_data]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov eax,[cache_ide0_appl_data]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [cdpos],2
|
||||
jne .ide2
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov eax,[cache_ide1_system_data]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov eax,[cache_ide1_appl_data]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [cdpos],3
|
||||
jne .ide3
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov eax,[cache_ide2_system_data]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov eax,[cache_ide2_appl_data]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov eax,[cache_ide3_system_data]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov eax,[cache_ide3_appl_data]
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_3:
|
||||
; mov ecx,cache_max*10/100
|
||||
; mov edi,[cache_search_start]
|
||||
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov edi,[cache_ide0_search_start]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov edi,[cache_ide0_appl_search_start]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [cdpos],2
|
||||
jne .ide2
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov edi,[cache_ide1_search_start]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov edi,[cache_ide1_appl_search_start]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [cdpos],3
|
||||
jne .ide3
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov edi,[cache_ide2_search_start]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov edi,[cache_ide2_appl_search_start]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov edi,[cache_ide3_search_start]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov edi,[cache_ide3_appl_search_start]
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_4:
|
||||
; cmp edi,cache_max
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
cmp edi,[cache_ide0_system_sad_size]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
cmp edi,[cache_ide0_appl_sad_size]
|
||||
ret
|
||||
.ide1:
|
||||
cmp [cdpos],2
|
||||
jne .ide2
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
cmp edi,[cache_ide1_system_sad_size]
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
cmp edi,[cache_ide1_appl_sad_size]
|
||||
ret
|
||||
.ide2:
|
||||
cmp [cdpos],3
|
||||
jne .ide3
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
cmp edi,[cache_ide2_system_sad_size]
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
cmp edi,[cache_ide2_appl_sad_size]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
cmp edi,[cache_ide3_system_sad_size]
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
cmp edi,[cache_ide3_appl_sad_size]
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_5:
|
||||
; mov [cache_search_start],edi
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos],1
|
||||
jne .ide1
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide0_appl_data
|
||||
mov [cache_ide0_search_start],edi
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov [cache_ide0_appl_search_start],edi
|
||||
ret
|
||||
.ide1:
|
||||
cmp [cdpos],2
|
||||
jne .ide2
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide1_appl_data
|
||||
mov [cache_ide1_search_start],edi
|
||||
ret
|
||||
.ide1_appl_data:
|
||||
mov [cache_ide1_appl_search_start],edi
|
||||
ret
|
||||
.ide2:
|
||||
cmp [cdpos],3
|
||||
jne .ide3
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide2_appl_data
|
||||
mov [cache_ide2_search_start],edi
|
||||
ret
|
||||
.ide2_appl_data:
|
||||
mov [cache_ide2_appl_search_start],edi
|
||||
ret
|
||||
.ide3:
|
||||
cmp [cd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov [cache_ide3_search_start],edi
|
||||
ret
|
||||
.ide3_appl_data:
|
||||
mov [cache_ide3_appl_search_start],edi
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
;align 4
|
||||
;calculate_linear_to_real:
|
||||
; shr eax, 12
|
||||
; mov eax, [page_tabs+eax*4]
|
||||
; and eax, 0xFFFFF000
|
||||
; ret
|
2266
kernel/branches/blkdev/rd.inc
Normal file
2266
kernel/branches/blkdev/rd.inc
Normal file
File diff suppressed because it is too large
Load Diff
32
kernel/branches/blkdev/rdsave.inc
Normal file
32
kernel/branches/blkdev/rdsave.inc
Normal file
@ -0,0 +1,32 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 684 $
|
||||
|
||||
|
||||
iglobal
|
||||
saverd_fileinfo:
|
||||
dd 2 ; subfunction: write
|
||||
dd 0 ; (reserved)
|
||||
dd 0 ; (reserved)
|
||||
dd 1440*1024 ; size 1440 Kb
|
||||
dd RAMDISK
|
||||
db 0
|
||||
.name:
|
||||
dd ?
|
||||
endg
|
||||
sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only)
|
||||
call restorefatchain
|
||||
mov eax, saverd_fileinfo
|
||||
mov [saverd_fileinfo.name], ecx
|
||||
pushad
|
||||
push eax
|
||||
call file_system_lfn
|
||||
pop eax
|
||||
popad
|
||||
mov [esp+32], eax
|
||||
ret
|
BIN
kernel/branches/boot/ETFONT.FNT
Normal file
BIN
kernel/branches/boot/ETFONT.FNT
Normal file
Binary file not shown.
1188
kernel/branches/boot/bootcode.inc
Normal file
1188
kernel/branches/boot/bootcode.inc
Normal file
File diff suppressed because it is too large
Load Diff
110
kernel/branches/boot/booteng.inc
Normal file
110
kernel/branches/boot/booteng.inc
Normal file
@ -0,0 +1,110 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;======================================================================
|
||||
;
|
||||
; BOOT DATA
|
||||
;
|
||||
;======================================================================
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
d80x25_bottom:
|
||||
db 186,' KolibriOS is based on MenuetOS and comes with ABSOLUTELY '
|
||||
db 'NO WARRANTY ',186
|
||||
db 186,' See file COPYING for details '
|
||||
db ' ',186
|
||||
line_full_bottom
|
||||
d80x25_bottom_num = 3
|
||||
|
||||
msg_apm db " APM x.x ", 0
|
||||
vervesa db "Version of Vesa: Vesa x.x",13,10,0
|
||||
novesa db "Display: EGA/CGA",13,10,0
|
||||
s_vesa db "Version of VESA: "
|
||||
.ver db "?.?",13,10,0
|
||||
|
||||
gr_mode db "Select a videomode: ",13,10,0
|
||||
;s_bpp db 13,10,186," ƒ«ã¡¨ 梥â : "
|
||||
; .bpp dw "??"
|
||||
; db 13,10,0
|
||||
|
||||
vrrmprint db "Apply VRR? (picture frequency greater than 60Hz"
|
||||
db " only for transfers:",13,10
|
||||
db 186," 1024*768->800*600 and 800*600->640*480) [1-yes,2-no]:",0
|
||||
|
||||
|
||||
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
|
||||
|
||||
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
|
||||
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
|
||||
;memokz128 db 13,10,186," RAM 128 Mb",0
|
||||
;memokz64 db 13,10,186," RAM 64 Mb",0
|
||||
;memokz32 db 13,10,186," RAM 32 Mb",0
|
||||
;memokz16 db 13,10,186," RAM 16 Mb",0
|
||||
prnotfnd db "Fatal - Videomode not found.",0
|
||||
;modena db "Fatal - VBE 0x112+ required.",0
|
||||
not386 db "Fatal - CPU 386+ required.",0
|
||||
btns db "Fatal - Can't determine color depth.",0
|
||||
fatalsel db "Fatal - Graphics mode not supported by hardware.",0
|
||||
pres_key db "Press any key to choose a new videomode.",0
|
||||
badsect db 13,10,186," Fatal - Bad sector. Replace floppy.",0
|
||||
memmovefailed db 13,10,186," Fatal - Int 0x15 move failed.",0
|
||||
okt db " ... OK"
|
||||
linef db 13,10,0
|
||||
diskload db "Loading diskette: 00 %",8,8,8,8,0
|
||||
pros db "00"
|
||||
backspace2 db 8,8,0
|
||||
boot_dev db 0 ; 0=floppy, 1=hd
|
||||
start_msg db "Press [abcd] to change settings, press [Enter] to continue booting",13,10,0
|
||||
time_msg db " or wait "
|
||||
time_str db " 5 seconds"
|
||||
db " before automatical continuation",13,10,0
|
||||
current_cfg_msg db "Current settings:",13,10,0
|
||||
curvideo_msg db " [a] Videomode: ",0
|
||||
|
||||
;modes_msg dw mode4,mode1,mode2,mode3
|
||||
;modevesa20 db " with LFB",0
|
||||
;modevesa12 db ", VESA 1.2 Bnk",0
|
||||
mode0 db "320x200, EGA/CGA 256 colors",13,10,0
|
||||
mode9 db "640x480, VGA 16 colors",13,10,0
|
||||
|
||||
;probeno_msg db " (standard mode)",0
|
||||
;probeok_msg db " (check nonstandard modes)",0
|
||||
;dma_msg db " [b] Use DMA for HDD access:",0
|
||||
usebd_msg db " [b] Add disks visible by BIOS:",0
|
||||
on_msg db " on",13,10,0
|
||||
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
|
||||
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
|
||||
loading_msg db "Loading KolibriOS...",0
|
||||
save_quest db "Remember current settings? [y/n]: ",0
|
||||
loader_block_error db "Bootloader data invalid, I cannot continue. Stopped.",0
|
||||
|
||||
_st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿',13,10,0
|
||||
_r1 db 186,' ³ 320x200 EGA/CGA 256 colors ³ ³',13,10,0
|
||||
_r2 db 186,' ³ 640x480 VGA 16 colors ³ ³',13,10,0
|
||||
_rs db 186,' ³ ????x????@?? SVGA VESA ³ ³',13,10,0
|
||||
_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ',13,10,0
|
||||
|
||||
remark1 db "Default values were selected to match most of configurations, but not all.",0
|
||||
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
|
||||
remark3 db "If the system does not boot, try to disable the item [b].",0
|
||||
remarks dw remark1, remark2, remark3
|
||||
num_remarks = 3
|
115
kernel/branches/boot/bootet.inc
Normal file
115
kernel/branches/boot/bootet.inc
Normal file
@ -0,0 +1,115 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;======================================================================
|
||||
;
|
||||
; BOOT DATA
|
||||
;
|
||||
;======================================================================
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
d80x25_bottom:
|
||||
db 186,' KolibriOS based on MenuetOS and comes with ABSOLUTELY '
|
||||
db 'NO WARRANTY ',186
|
||||
db 186,' See file COPYING for details '
|
||||
db ' ',186
|
||||
line_full_bottom
|
||||
d80x25_bottom_num = 3
|
||||
|
||||
novesa db "Ekraan: EGA/CGA",13,10,0
|
||||
vervesa db "Vesa versioon: Vesa x.x",13,10,0
|
||||
vervesa_off=20
|
||||
msg_apm db " APM x.x ", 0
|
||||
gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, "
|
||||
db "[3] 1024x768, [4] 1280x1024",13,10
|
||||
db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, "
|
||||
db "[7] 1024x768, [8] 1280x1024",13,10
|
||||
db 186," EGA/CGA 256 värvi: [9] 320x200, "
|
||||
db "VGA 16 värvi: [0] 640x480",13,10
|
||||
db 186," Vali reziim: ",0
|
||||
bt24 db "Bitti pikseli kohta: 24",13,10,0
|
||||
bt32 db "Bitti pikseli kohta: 32",13,10,0
|
||||
vrrmprint db "Kinnita VRR? (ekraani sagedus suurem kui 60Hz"
|
||||
db " ainult:",13,10
|
||||
db 186," 1024*768->800*600 ja 800*600->640*480) [1-jah,2-ei]:",0
|
||||
;askmouse db " Hiir:"
|
||||
; db " [1] PS/2 (USB), [2] Com1, [3] Com2."
|
||||
; db " Vali port [1-3]: ",0
|
||||
;no_com1 db 13,10,186, " No COM1 mouse",0
|
||||
;no_com2 db 13,10,186, " No COM2 mouse",0
|
||||
;ask_dma db "Use DMA for HDD access? [1-yes, 2-only for reading, 3-no]: ",0
|
||||
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
|
||||
;gr_direct db 186," Use direct LFB writing? "
|
||||
; db "[1-yes/2-no] ? ",0
|
||||
;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
|
||||
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
|
||||
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
|
||||
;memokz128 db 13,10,186," RAM 128 Mb",0
|
||||
;memokz64 db 13,10,186," RAM 64 Mb",0
|
||||
;memokz32 db 13,10,186," RAM 32 Mb",0
|
||||
;memokz16 db 13,10,186," RAM 16 Mb",0
|
||||
prnotfnd db "Fataalne - Videoreziimi ei leitud.",0
|
||||
;modena db "Fataalne - VBE 0x112+ on vajalik.",0
|
||||
not386 db "Fataalne - CPU 386+ on vajalik.",0
|
||||
btns db "Fataalne - Ei suuda värvisügavust määratleda.",0
|
||||
fatalsel db "Fataalne - Graafilist reziimi riistvara ei toeta.",0
|
||||
badsect db 13,10,186," Fataalne - Vigane sektor. Asenda diskett.",0
|
||||
memmovefailed db 13,10,186," Fataalne - Int 0x15 liigutamine ebaõnnestus.",0
|
||||
okt db " ... OK"
|
||||
linef db 13,10,0
|
||||
diskload db "Loen disketti: 00 %",8,8,8,8,0
|
||||
pros db "00"
|
||||
backspace2 db 8,8,0
|
||||
boot_dev db 0 ; 0=floppy, 1=hd
|
||||
start_msg db "Vajuta [abcd] seadete muutmiseks, vajuta [Enter] laadimise jätkamiseks",13,10,0
|
||||
time_msg db " või oota "
|
||||
time_str db " 5 sekundit"
|
||||
db " automaatseks jätkamiseks",13,10,0
|
||||
current_cfg_msg db "Praegused seaded:",13,10,0
|
||||
curvideo_msg db " [a] Videoreziim: ",0
|
||||
mode1 db "640x480",0
|
||||
mode2 db "800x600",0
|
||||
mode3 db "1024x768",0
|
||||
mode4 db "1280x1024",0
|
||||
modes_msg dw mode4,mode1,mode2,mode3
|
||||
modevesa20 db " koos LFB",0
|
||||
modevesa12 db ", VESA 1.2 Bnk",0
|
||||
mode9 db "320x200, EGA/CGA 256 värvi",0
|
||||
mode10 db "640x480, VGA 16 värvi",0
|
||||
probeno_msg db " (standard reziim)",0
|
||||
probeok_msg db " (kontrolli ebastandardseid reziime)",0
|
||||
;dma_msg db " [b] Kasuta DMA'd HDD juurdepääsuks:",0
|
||||
usebd_msg db " [b] Add disks visible by BIOS:",0
|
||||
on_msg db " sees",13,10,0
|
||||
off_msg db " väljas",13,10,0
|
||||
;readonly_msg db " ainult lugemiseks",13,10,0
|
||||
vrrm_msg db " [c] Kasuta VRR:",0
|
||||
preboot_device_msg db " [d] Disketi kujutis: ",0
|
||||
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
|
||||
loading_msg db "Laadin KolibriOS...",0
|
||||
save_quest db "Jäta meelde praegused seaded? [y/n]: ",0
|
||||
loader_block_error db "Alglaaduri andmed vigased, ei saa jätkata. Peatatud.",0
|
||||
|
||||
remark1 db "Default values were selected to match most of configurations, but not all.",0
|
||||
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
|
||||
remark3 db "If the system does not boot, try to disable the item [b].",0
|
||||
remarks dw remark1, remark2, remark3
|
||||
num_remarks = 3
|
120
kernel/branches/boot/bootge.inc
Normal file
120
kernel/branches/boot/bootge.inc
Normal file
@ -0,0 +1,120 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;======================================================================
|
||||
;
|
||||
; BOOT DATA
|
||||
;
|
||||
;======================================================================
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
d80x25_bottom:
|
||||
; db 186,' KolibriOS based on MenuetOS and comes with ABSOLUTELY '
|
||||
; db 'NO WARRANTY ',186
|
||||
; db 186,' See file COPYING for details '
|
||||
; db ' ',186
|
||||
|
||||
db 186,' KolibriOS basiert auf MenuetOS und wird ohne jegliche '
|
||||
db ' Garantie vertrieben ',186
|
||||
db 186,' Details stehen in der Datei COPYING '
|
||||
db ' ',186
|
||||
line_full_bottom
|
||||
d80x25_bottom_num = 3
|
||||
|
||||
novesa db "Anzeige: EGA/CGA ",13,10,0
|
||||
vervesa db "Vesa-Version: Vesa ",13,10,0
|
||||
vervesa_off=22
|
||||
msg_apm db " APM x.x ", 0
|
||||
gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, "
|
||||
db "[3] 1024x768, [4] 1280x1024",13,10
|
||||
db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, "
|
||||
db "[7] 1024x768, [8] 1280x1024",13,10
|
||||
db 186," EGA/CGA 256 Farben: [9] 320x200, "
|
||||
db "VGA 16 Farben: [0] 640x480",13,10
|
||||
db 186," Waehle Modus: ",0
|
||||
bt24 db "Bits Per Pixel: 24",13,10,0
|
||||
bt32 db "Bits Per Pixel: 32",13,10,0
|
||||
vrrmprint db "VRR verwenden? (Monitorfrequenz groesser als 60Hz"
|
||||
db " only for transfers:",13,10
|
||||
db 186," 1024*768->800*600 und 800*600->640*480) [1-ja,2-nein]:",0
|
||||
;askmouse db " Maus angeschlossen an:"
|
||||
; db " [1] PS/2 (USB), [2] Com1, [3] Com2."
|
||||
; db " Waehle Port [1-3]: ",0
|
||||
;no_com1 db 13,10,186, " Keine COM1 Maus",0
|
||||
;no_com2 db 13,10,186, " Keine COM2 Maus",0
|
||||
;ask_dma db "Nutze DMA zum HDD Zugriff? [1-ja, 2-allein fur Lesen, 3-nein]: ",0
|
||||
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
|
||||
;gr_direct db 186," Benutze direct LFB? "
|
||||
; db "[1-ja/2-nein] ? ",0
|
||||
;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
|
||||
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
|
||||
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
|
||||
;memokz128 db 13,10,186," RAM 128 Mb",0
|
||||
;memokz64 db 13,10,186," RAM 64 Mb",0
|
||||
;memokz32 db 13,10,186," RAM 32 Mb",0
|
||||
;memokz16 db 13,10,186," RAM 16 Mb",0
|
||||
prnotfnd db "Fatal - Videomodus nicht gefunden.",0
|
||||
;modena db "Fatal - VBE 0x112+ required.",0
|
||||
not386 db "Fatal - CPU 386+ benoetigt.",0
|
||||
btns db "Fatal - konnte Farbtiefe nicht erkennen.",0
|
||||
fatalsel db "Fatal - Grafikmodus nicht unterstuetzt.",0
|
||||
badsect db 13,10,186," Fatal - Sektorfehler, Andere Diskette neutzen.",0
|
||||
memmovefailed db 13,10,186," Fatal - Int 0x15 Fehler.",0
|
||||
okt db " ... OK"
|
||||
linef db 13,10,0
|
||||
diskload db "Lade Diskette: 00 %",8,8,8,8,0
|
||||
pros db "00"
|
||||
backspace2 db 8,8,0
|
||||
boot_dev db 0 ; 0=floppy, 1=hd
|
||||
start_msg db "Druecke [abcd], um die Einstellungen zu aendern , druecke [Enter] zum starten",13,10,0
|
||||
time_msg db " oder warte "
|
||||
time_str db " 5 Sekunden"
|
||||
db " bis zum automatischen Start",13,10,0
|
||||
current_cfg_msg db "Aktuelle Einstellungen:",13,10,0
|
||||
curvideo_msg db " [a] Videomodus: ",0
|
||||
mode1 db "640x480",0
|
||||
mode2 db "800x600",0
|
||||
mode3 db "1024x768",0
|
||||
mode4 db "1280x1024",0
|
||||
modes_msg dw mode4,mode1,mode2,mode3
|
||||
modevesa20 db " mit LFB",0
|
||||
modevesa12 db ", VESA 1.2 Bnk",0
|
||||
mode9 db "320x200, EGA/CGA 256 colors",0
|
||||
mode10 db "640x480, VGA 16 colors",0
|
||||
probeno_msg db " (Standard Modus)",0
|
||||
probeok_msg db " (teste nicht-standard Modi)",0
|
||||
;dma_msg db " [b] Nutze DMA zum HDD Aufschreiben:",0
|
||||
usebd_msg db " [b] Add disks visible by BIOS:",0
|
||||
on_msg db " an",13,10,0
|
||||
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
|
||||
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
|
||||
loading_msg db "Lade KolibriOS...",0
|
||||
save_quest db "Aktuelle Einstellungen speichern? [y/n]: ",0
|
||||
loader_block_error db "Bootloader Daten ungueltig, Kann nicht fortfahren. Angehalten.",0
|
||||
|
||||
remark1 db "Default values were selected to match most of configurations, but not all.",0
|
||||
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
|
||||
remark3 db "If the system does not boot, try to disable the item [b].",0
|
||||
remarks dw remark1, remark2, remark3
|
||||
num_remarks = 3
|
91
kernel/branches/boot/bootru.inc
Normal file
91
kernel/branches/boot/bootru.inc
Normal file
@ -0,0 +1,91 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;=================================================================
|
||||
;
|
||||
; BOOT DATA
|
||||
;
|
||||
;=================================================================
|
||||
|
||||
$Revision: 751 $
|
||||
|
||||
|
||||
d80x25_bottom:
|
||||
db 186,' Kolibri OS ®á®¢ Menuet OS ¨ ¥ ¯à¥¤®áâ ¢«ï¥â '
|
||||
db '¨ª ª¨å £ àa⨩. ',186
|
||||
db 186,' <20>®¤à®¡¥¥ ᬮâà¨â¥ ¢ ä ©«¥ COPYING.TXT '
|
||||
db ' ',186
|
||||
line_full_bottom
|
||||
d80x25_bottom_num = 3
|
||||
|
||||
msg_apm db " APM x.x ", 0
|
||||
novesa db "‚¨¤¥®ª àâ : EGA/CGA",13,10,0
|
||||
s_vesa db "‚¥àá¨ï VESA: "
|
||||
.ver db "?.?",13,10,0
|
||||
|
||||
gr_mode db "‚ë¡¥à¨â¥ ¢¨¤¥®à¥¦¨¬: ",13,10,0
|
||||
vrrmprint db "ˆá¯®«ì§®¢ âì VRR? (ç áâ®â ª ¤à®¢ ¢ëè¥ 60 ƒæ"
|
||||
db " ⮫쪮 ¤«ï ¯¥à¥å®¤®¢:",13,10
|
||||
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
|
||||
bdev db "‡ £à㧨âì ®¡à § ¨§ [1-¤¨áª¥â ; 2-C:\kolibri.img (FAT32);"
|
||||
db 13,10,186," "
|
||||
db "3-¨á¯®«ì§®¢ âì 㦥 § £àã¦¥ë© ®¡à §;"
|
||||
db 13,10,186," "
|
||||
db "4-ᮧ¤ âì ç¨áâë© ®¡à §]: ",0
|
||||
prnotfnd db "Žè¨¡ª - ‚¨¤¥®à¥¦¨¬ ¥ ©¤¥.",0
|
||||
not386 db "Žè¨¡ª - ’ॡã¥âáï ¯à®æ¥áá®à 386+.",0
|
||||
fatalsel db "Žè¨¡ª - ‚ë¡à ë© ¢¨¤¥®à¥¦¨¬ ¥ ¯®¤¤¥à¦¨¢ ¥âáï.",0
|
||||
pres_key db "<EFBFBD> ¦¨¬¨â¥ «î¡ãî ª« ¢¨èã, ¤«ï ¯¥à¥å®¤ ¢ ¢ë¡®à ०¨¬®¢.",0
|
||||
badsect db 13,10,186," Žè¨¡ª - „¨áª¥â ¯®¢à¥¦¤¥ . <20>®¯à®¡ã©â¥ ¤àã£ãî.",0
|
||||
memmovefailed db 13,10,186," Žè¨¡ª - Int 0x15 move failed.",0
|
||||
okt db " ... OK"
|
||||
linef db 13,10,0
|
||||
diskload db "‡ £à㧪 ¤¨áª¥âë: 00 %",8,8,8,8,0
|
||||
pros db "00"
|
||||
backspace2 db 8,8,0
|
||||
boot_dev db 0
|
||||
start_msg db "<EFBFBD> ¦¬¨â¥ [abcd] ¤«ï ¨§¬¥¥¨ï áâ஥ª, [Enter] ¤«ï ¯à®¤®«¦¥¨ï § £à㧪¨",13,10,0
|
||||
time_msg db " ¨«¨ ¯®¤®¦¤¨â¥ "
|
||||
time_str db " 5 ᥪ㤠"
|
||||
db " ¤® ¢â®¬ â¨ç¥áª®£® ¯à®¤®«¦¥¨ï",13,10,0
|
||||
current_cfg_msg db "’¥ªã騥 áâனª¨:",13,10,0
|
||||
curvideo_msg db " [a] ‚¨¤¥®à¥¦¨¬: ",0
|
||||
|
||||
|
||||
mode0 db "320x200, EGA/CGA 256 梥⮢",13,10,0
|
||||
mode9 db "640x480, VGA 16 梥⮢",13,10,0
|
||||
|
||||
usebd_msg db " [b] „®¡ ¢¨âì ¤¨áª¨, ¢¨¤¨¬ë¥ ç¥à¥§ BIOS:",0
|
||||
on_msg db " ¢ª«",13,10,0
|
||||
off_msg db " ¢ëª«",13,10,0
|
||||
readonly_msg db " ⮫쪮 ç⥨¥",13,10,0
|
||||
vrrm_msg db " [c] ˆá¯®«ì§®¢ ¨¥ VRR:",0
|
||||
preboot_device_msg db " [d] Ž¡à § ¤¨áª¥âë: ",0
|
||||
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
|
||||
loading_msg db "ˆ¤ñâ § £à㧪 KolibriOS...",0
|
||||
save_quest db "‡ ¯®¬¨âì ⥪ã騥 áâனª¨? [y/n]: ",0
|
||||
loader_block_error db "Žè¨¡ª ¢ ¤ ëå ç «ì®£® § £àã§ç¨ª , ¯à®¤®«¦¥¨¥ ¥¢®§¬®¦®.",0
|
||||
|
||||
|
||||
_st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿ ',13,10,0
|
||||
_r1 db 186,' ³ 320x200 EGA/CGA 256 梥⮢ ³ ³ ',13,10,0
|
||||
_r2 db 186,' ³ 640x480 VGA 16 梥⮢ ³ ³ ',13,10,0
|
||||
_rs db 186,' ³ ????x????@?? SVGA VESA ³ ³ ',13,10,0
|
||||
_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ ',13,10,0
|
||||
|
||||
|
||||
remark1 db "‡ ç¥¨ï ¯® 㬮«ç ¨î ¢ë¡à ë ¤«ï 㤮¡á⢠¡®«ìè¨á⢠, ® ¥ ¢á¥å.",0
|
||||
remark2 db "…᫨ ã ‚ á LCD-¬®¨â®à, ®âª«îç¨â¥ VRR ¢ ¯ãªâ¥ [c] - ® ‚ ¬ ¥ 㦥.",0
|
||||
remark3 db "…᫨ ã ‚ á ¥ £à㧨âáï á¨á⥬ , ¯®¯à®¡ã©â¥ ®âª«îç¨âì ¯ãªâ [b].",0
|
||||
remarks dw remark1, remark2, remark3
|
||||
num_remarks = 3
|
62
kernel/branches/boot/bootstr.inc
Normal file
62
kernel/branches/boot/bootstr.inc
Normal file
@ -0,0 +1,62 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
; boot data: common strings (for all languages)
|
||||
macro line_full_top {
|
||||
db 201
|
||||
times 78 db 205
|
||||
db 187
|
||||
}
|
||||
macro line_full_bottom {
|
||||
db 200
|
||||
times 78 db 205
|
||||
db 188
|
||||
}
|
||||
macro line_half {
|
||||
db 186,' '
|
||||
times 76 db 0xc4
|
||||
db ' ',186
|
||||
}
|
||||
macro line_space {
|
||||
db 186
|
||||
times 78 db 32
|
||||
db 186
|
||||
}
|
||||
d80x25_top:
|
||||
line_full_top
|
||||
cur_line_pos = 75
|
||||
store byte ' ' at d80x25_top+cur_line_pos+1
|
||||
rev_var = __REV__
|
||||
while rev_var > 0
|
||||
store byte rev_var mod 10 + '0' at d80x25_top+cur_line_pos
|
||||
cur_line_pos = cur_line_pos - 1
|
||||
rev_var = rev_var / 10
|
||||
end while
|
||||
store byte ' ' at d80x25_top+cur_line_pos
|
||||
store dword ' SVN' at d80x25_top+cur_line_pos-4
|
||||
|
||||
space_msg: line_space
|
||||
verstr:
|
||||
; line_space
|
||||
; version string
|
||||
db 186,32
|
||||
repeat 78
|
||||
load a byte from version+%-1
|
||||
if a = 13
|
||||
break
|
||||
end if
|
||||
db a
|
||||
end repeat
|
||||
repeat 78 - ($-verstr)
|
||||
db ' '
|
||||
end repeat
|
||||
db 32,186
|
||||
line_half
|
||||
d80x25_top_num = 4
|
755
kernel/branches/boot/bootvesa.inc
Normal file
755
kernel/branches/boot/bootvesa.inc
Normal file
@ -0,0 +1,755 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 947 $
|
||||
|
||||
struc VBE_VGAInfo {
|
||||
.VESASignature dd ? ; char
|
||||
.VESAVersion dw ? ; short
|
||||
.OemStringPtr dd ? ; char *
|
||||
.Capabilities dd ? ; ulong
|
||||
.VideoModePtr dd ? ; ulong
|
||||
.TotalMemory dw ? ; short
|
||||
; VBE 2.0+
|
||||
.OemSoftwareRev db ? ; short
|
||||
.OemVendorNamePtr dw ? ; char *
|
||||
.OemProductNamePtr dw ? ; char *
|
||||
.OemProductRevPtr dw ? ; char *
|
||||
.reserved rb 222 ; char
|
||||
.OemData rb 256 ; char
|
||||
}
|
||||
|
||||
struc VBE_ModeInfo {
|
||||
.ModeAttributes dw ? ; short
|
||||
.WinAAttributes db ? ; char
|
||||
.WinBAttributes db ? ; char
|
||||
.WinGranularity dw ? ; short
|
||||
.WinSize dw ? ; short
|
||||
.WinASegment dw ? ; ushort
|
||||
.WinBSegment dw ? ; ushort
|
||||
.WinFuncPtr dd ? ; void *
|
||||
.BytesPerScanLine dw ? ; short
|
||||
.XRes dw ? ; short
|
||||
.YRes dw ? ; short
|
||||
.XCharSize db ? ; char
|
||||
.YCharSize db ? ; char
|
||||
.NumberOfPlanes db ? ; char
|
||||
.BitsPerPixel db ? ; char
|
||||
.NumberOfBanks db ? ; char
|
||||
.MemoryModel db ? ; char
|
||||
.BankSize db ? ; char
|
||||
.NumberOfImagePages db ? ; char
|
||||
.res1 db ? ; char
|
||||
.RedMaskSize db ? ; char
|
||||
.RedFieldPosition db ? ; char
|
||||
.GreenMaskSize db ? ; char
|
||||
.GreenFieldPosition db ? ; char
|
||||
.BlueMaskSize db ? ; char
|
||||
.BlueFieldPosition db ? ; char
|
||||
.RsvedMaskSize db ? ; char
|
||||
.RsvedFieldPosition db ? ; char
|
||||
.DirectColorModeInfo db ? ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE
|
||||
; VBE 2.0+
|
||||
.PhysBasePtr dd ? ; ulong
|
||||
.OffScreenMemOffset dd ? ; ulong
|
||||
.OffScreenMemSize dw ? ; short
|
||||
; VBE 3.0+
|
||||
.LinbytesPerScanLine dw ? ; short
|
||||
.BankNumberOfImagePages db ? ; char
|
||||
.LinNumberOfImagePages db ? ; char
|
||||
.LinRedMaskSize db ? ; char
|
||||
.LinRedFieldPosition db ? ; char
|
||||
.LingreenMaskSize db ? ; char
|
||||
.LinGreenFieldPosition db ? ; char
|
||||
.LinBlueMaskSize db ? ; char
|
||||
.LinBlueFieldPosition db ? ; char
|
||||
.LinRsvdMaskSize db ? ; char
|
||||
.LinRsvdFieldPosition db ? ; char
|
||||
.MaxPixelClock dd ? ; ulong
|
||||
.res2 rb 190 ; char
|
||||
}
|
||||
|
||||
virtual at $A000
|
||||
vi VBE_VGAInfo
|
||||
mi VBE_ModeInfo
|
||||
modes_table:
|
||||
end virtual
|
||||
cursor_pos dw 0 ;âðåìåííîå õðàíåíèå êóðñîðà.
|
||||
home_cursor dw 0 ;current shows rows a table
|
||||
end_cursor dw 0 ;end of position current shows rows a table
|
||||
scroll_start dw 0 ;start position of scroll bar
|
||||
scroll_end dw 0 ;end position of scroll bar
|
||||
long_v_table equ 9 ;long of visible video table
|
||||
size_of_step equ 10
|
||||
scroll_area_size equ (long_v_table-2)
|
||||
int2str:
|
||||
dec bl
|
||||
jz @f
|
||||
xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
call int2str
|
||||
pop eax
|
||||
@@: or al,0x30
|
||||
mov [ds:di],al
|
||||
inc di
|
||||
ret
|
||||
|
||||
int2strnz:
|
||||
cmp eax,ecx
|
||||
jb @f
|
||||
xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
call int2strnz
|
||||
pop eax
|
||||
@@: or al,0x30
|
||||
mov [es:di],al
|
||||
inc di
|
||||
ret
|
||||
|
||||
;-------------------------------------------------------
|
||||
;Write message about incorrect v_mode and write message about jmp on swith v_mode
|
||||
v_mode_error:
|
||||
_setcursor 19,2
|
||||
mov si, fatalsel
|
||||
call printplain
|
||||
_setcursor 20,2
|
||||
mov si,pres_key
|
||||
call printplain
|
||||
xor eax,eax
|
||||
int 16h
|
||||
jmp cfgmanager.d
|
||||
;-------------------------------------------------------
|
||||
;
|
||||
|
||||
|
||||
|
||||
;-------------------------------------------------------
|
||||
print_vesa_info:
|
||||
_setcursor 5,2
|
||||
|
||||
mov [es:vi.VESASignature],'VBE2'
|
||||
mov ax,0x4F00
|
||||
mov di,vi ;0xa000
|
||||
int 0x10
|
||||
or ah,ah
|
||||
jz @f
|
||||
mov [es:vi.VESASignature],'VESA'
|
||||
mov ax,$4F00
|
||||
mov di,vi
|
||||
int 0x10
|
||||
or ah,ah
|
||||
jnz .exit
|
||||
@@:
|
||||
cmp [es:vi.VESASignature],'VESA'
|
||||
jne .exit
|
||||
cmp [es:vi.VESAVersion],0x0100
|
||||
jb .exit
|
||||
jmp .vesaok2
|
||||
|
||||
.exit:
|
||||
mov si,novesa
|
||||
call printplain
|
||||
ret
|
||||
|
||||
.vesaok2:
|
||||
mov ax,[es:vi.VESAVersion]
|
||||
add ax,'00'
|
||||
|
||||
mov [s_vesa.ver], ah
|
||||
mov [s_vesa.ver+2], al
|
||||
mov si,s_vesa
|
||||
call printplain
|
||||
|
||||
_setcursor 4,2
|
||||
mov si,word[es:vi.OemStringPtr]
|
||||
mov di,si
|
||||
|
||||
push ds
|
||||
mov ds,word[es:vi.OemStringPtr+2]
|
||||
call printplain
|
||||
pop ds
|
||||
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
calc_vmodes_table:
|
||||
pushad
|
||||
|
||||
; push 0
|
||||
; pop es
|
||||
|
||||
lfs si, [es:vi.VideoModePtr]
|
||||
|
||||
mov bx,modes_table
|
||||
;save no vesa mode of work 320x200, EGA/CGA 256 梥⮢ and 640x480, VGA 16 梥⮢
|
||||
mov word [es:bx],640
|
||||
mov word [es:bx+2],480
|
||||
mov word [es:bx+6],0x13
|
||||
|
||||
mov word [es:bx+10],640
|
||||
mov word [es:bx+12],480
|
||||
mov word [es:bx+16],0x12
|
||||
add bx,20
|
||||
.next_mode:
|
||||
mov cx,word [fs:si] ; mode number
|
||||
cmp cx,-1
|
||||
je .modes_ok.2
|
||||
|
||||
mov ax,0x4F01
|
||||
mov di,mi
|
||||
int 0x10
|
||||
|
||||
or ah,ah
|
||||
jnz .modes_ok.2;vesa_info.exit
|
||||
|
||||
test [es:mi.ModeAttributes],00000001b ;videomode support ?
|
||||
jz @f
|
||||
test [es:mi.ModeAttributes],00010000b ;picture ?
|
||||
jz @f
|
||||
test [es:mi.ModeAttributes],10000000b ;LFB ?
|
||||
jz @f
|
||||
|
||||
cmp [es:mi.BitsPerPixel], 24 ;It show only videomodes to have support 24 and 32 bpp
|
||||
jb @f
|
||||
|
||||
; cmp [es:mi.BitsPerPixel],16
|
||||
; jne .l0
|
||||
; cmp [es:mi.GreenMaskSize],5
|
||||
; jne .l0
|
||||
; mov [es:mi.BitsPerPixel],15
|
||||
|
||||
|
||||
.l0:
|
||||
cmp [es:mi.XRes],640
|
||||
jb @f
|
||||
cmp [es:mi.YRes],480
|
||||
jb @f
|
||||
; cmp [es:mi.BitsPerPixel],8
|
||||
; jb @f
|
||||
|
||||
mov ax,[es:mi.XRes]
|
||||
mov [es:bx+0],ax ; +0[2] : resolution X
|
||||
mov ax,[es:mi.YRes]
|
||||
mov [es:bx+2],ax ; +2[2] : resolution Y
|
||||
mov ax,[es:mi.ModeAttributes]
|
||||
mov [es:bx+4],ax ; +4[2] : attributes
|
||||
|
||||
cmp [s_vesa.ver],'2'
|
||||
jb .lp1
|
||||
|
||||
or cx,0x4000 ; use LFB
|
||||
.lp1: mov [es:bx+6],cx ; +6 : mode number
|
||||
movzx ax,byte [es:mi.BitsPerPixel]
|
||||
mov word [es:bx+8],ax ; +8 : bits per pixel
|
||||
add bx,size_of_step ; size of record
|
||||
|
||||
@@:
|
||||
add si,2
|
||||
jmp .next_mode
|
||||
|
||||
.modes_ok.2:
|
||||
|
||||
mov word[es:bx],-1 ;end video table
|
||||
mov word[end_cursor],bx ;save end cursor position
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
;Sort array
|
||||
; mov si,modes_table
|
||||
;.new_mode:
|
||||
; mov ax,word [es:si]
|
||||
; cmp ax,-1
|
||||
; je .exxit
|
||||
; add ax,word [es:si+2]
|
||||
; add ax,word [es:si+8]
|
||||
; mov bp,si
|
||||
;.again:
|
||||
; add bp,12
|
||||
; mov bx,word [es:bp]
|
||||
; cmp bx,-1
|
||||
; je .exit
|
||||
; add bx,word [es:bp+2]
|
||||
; add bx,word [es:bp+8]
|
||||
;
|
||||
; cmp ax,bx
|
||||
; ja .loops
|
||||
; jmp .again
|
||||
;.loops:
|
||||
; push dword [es:si]
|
||||
; push dword [es:si+4]
|
||||
; push dword [es:si+8]
|
||||
; push dword [es:bp]
|
||||
; push dword [es:bp+4]
|
||||
; push dword [es:bp+8]
|
||||
;
|
||||
; pop dword [es:si+8]
|
||||
; pop dword [es:si+4]
|
||||
; pop dword [es:si]
|
||||
; pop dword [es:bp+8]
|
||||
; pop dword [es:bp+4]
|
||||
; pop dword [es:bp]
|
||||
; jmp .new_mode
|
||||
;
|
||||
;.exit: add si,12
|
||||
; jmp .new_mode
|
||||
;.exxit:
|
||||
popad
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
draw_current_vmode:
|
||||
push 0
|
||||
pop es
|
||||
|
||||
mov si,word [cursor_pos]
|
||||
|
||||
cmp word [es:si+6],0x12
|
||||
je .no_vesa_0x12
|
||||
|
||||
cmp word [es:si+6],0x13
|
||||
je .no_vesa_0x13
|
||||
|
||||
mov di,loader_block_error
|
||||
movzx eax,word[es:si+0]
|
||||
mov ecx,10
|
||||
call int2strnz
|
||||
mov byte[es:di],'x'
|
||||
inc di
|
||||
movzx eax,word[es:si+2]
|
||||
call int2strnz
|
||||
mov byte[es:di],'x'
|
||||
inc di
|
||||
movzx eax,word[es:si+8]
|
||||
call int2strnz
|
||||
mov dword[es:di],0x00000d0a
|
||||
mov si,loader_block_error
|
||||
push ds
|
||||
push es
|
||||
pop ds
|
||||
call printplain
|
||||
pop ds
|
||||
ret
|
||||
.no_vesa_0x13:
|
||||
mov si,mode0
|
||||
jmp .print
|
||||
.no_vesa_0x12:
|
||||
mov si,mode9
|
||||
.print:
|
||||
call printplain
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
check_first_parm:
|
||||
mov si,word [preboot_graph]
|
||||
test si,si
|
||||
jnz .no_zero ;if no zero
|
||||
.zerro:
|
||||
; mov ax,modes_table
|
||||
; mov word [cursor_pos],ax
|
||||
; mov word [home_cursor],ax
|
||||
; mov word [preboot_graph],ax
|
||||
;SET default video of mode first probe will fined a move of work 1024x768@32
|
||||
|
||||
mov ax,1024
|
||||
mov bx,768
|
||||
mov si,modes_table
|
||||
call .loops
|
||||
test ax,ax
|
||||
jz .ok_found_mode
|
||||
mov ax,800
|
||||
mov bx,600
|
||||
mov si,modes_table
|
||||
call .loops
|
||||
test ax,ax
|
||||
jz .ok_found_mode
|
||||
mov ax,640
|
||||
mov bx,480
|
||||
mov si,modes_table
|
||||
call .loops
|
||||
test ax,ax
|
||||
jz .ok_found_mode
|
||||
|
||||
mov si,modes_table
|
||||
jmp .ok_found_mode
|
||||
|
||||
|
||||
|
||||
.no_zero:
|
||||
mov bp,word [number_vm]
|
||||
cmp bp,word [es:si+6]
|
||||
jz .ok_found_mode
|
||||
mov ax,word [x_save]
|
||||
mov bx,word [y_save]
|
||||
mov si,modes_table
|
||||
call .loops
|
||||
test ax,ax
|
||||
jz .ok_found_mode
|
||||
|
||||
mov si,modes_table
|
||||
; cmp ax,modes_table
|
||||
; jb .zerro ;check on correct if bellow
|
||||
; cmp ax,word [end_cursor]
|
||||
; ja .zerro ;check on correct if anymore
|
||||
|
||||
.ok_found_mode:
|
||||
mov word [home_cursor],si
|
||||
; mov word [cursor_pos],si
|
||||
mov word [preboot_graph],si
|
||||
mov ax,si
|
||||
|
||||
mov ecx,long_v_table
|
||||
|
||||
.loop: add ax,size_of_step
|
||||
cmp ax,word [end_cursor]
|
||||
jae .next_step
|
||||
loop .loop
|
||||
.next_step:
|
||||
sub ax,size_of_step*long_v_table
|
||||
cmp ax,modes_table
|
||||
jae @f
|
||||
mov ax,modes_table
|
||||
@@:
|
||||
|
||||
mov word [home_cursor],ax
|
||||
mov si,[preboot_graph]
|
||||
mov word [cursor_pos],si
|
||||
|
||||
push word [es:si]
|
||||
pop word [x_save]
|
||||
push word [es:si+2]
|
||||
pop word [y_save]
|
||||
push word [es:si+6]
|
||||
pop word [number_vm]
|
||||
|
||||
ret
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
.loops:
|
||||
cmp ax,word [es:si]
|
||||
jne .next
|
||||
cmp bx,word [es:si+2]
|
||||
jne .next
|
||||
cmp word [es:si+8],32
|
||||
je .ok
|
||||
cmp word [es:si+8],24
|
||||
je .ok
|
||||
.next: add si,size_of_step
|
||||
cmp word [es:si],-1
|
||||
je .exit
|
||||
jmp .loops
|
||||
.ok: xor ax,ax
|
||||
ret
|
||||
.exit: or ax,-1
|
||||
ret
|
||||
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
;default_vmode:
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
draw_vmodes_table:
|
||||
_setcursor 9, 2
|
||||
mov si,gr_mode
|
||||
call printplain
|
||||
|
||||
mov si,_st
|
||||
call printplain
|
||||
|
||||
push word [cursor_pos]
|
||||
pop ax
|
||||
push word [home_cursor]
|
||||
pop si
|
||||
mov cx,si
|
||||
|
||||
cmp ax,si
|
||||
je .ok
|
||||
jb .low
|
||||
|
||||
|
||||
add cx,size_of_step*long_v_table
|
||||
|
||||
cmp ax,cx
|
||||
jb .ok
|
||||
|
||||
sub cx,size_of_step*long_v_table
|
||||
add cx,size_of_step
|
||||
cmp cx,word[end_cursor]
|
||||
jae .ok
|
||||
add si,size_of_step
|
||||
push si
|
||||
pop word [home_cursor]
|
||||
jmp .ok
|
||||
|
||||
|
||||
.low: sub cx,size_of_step
|
||||
cmp cx,modes_table
|
||||
jb .ok
|
||||
push cx
|
||||
push cx
|
||||
pop word [home_cursor]
|
||||
pop si
|
||||
|
||||
|
||||
.ok:
|
||||
; calculate scroll position
|
||||
push si
|
||||
mov ax, [end_cursor]
|
||||
sub ax, modes_table
|
||||
mov bx, size_of_step
|
||||
cwd
|
||||
div bx
|
||||
mov si, ax ; si = size of list
|
||||
mov ax, [home_cursor]
|
||||
sub ax, modes_table
|
||||
cwd
|
||||
div bx
|
||||
mov di, ax
|
||||
mov ax, scroll_area_size*long_v_table
|
||||
cwd
|
||||
div si
|
||||
test ax, ax
|
||||
jnz @f
|
||||
inc ax
|
||||
@@:
|
||||
cmp al, scroll_area_size
|
||||
jb @f
|
||||
mov al, scroll_area_size
|
||||
@@:
|
||||
mov cx, ax
|
||||
; cx = scroll height
|
||||
; calculate scroll pos
|
||||
xor bx, bx ; initialize scroll pos
|
||||
sub al, scroll_area_size+1
|
||||
neg al
|
||||
sub si, long_v_table-1
|
||||
jbe @f
|
||||
mul di
|
||||
div si
|
||||
mov bx, ax
|
||||
@@:
|
||||
inc bx
|
||||
imul ax, bx, size_of_step
|
||||
add ax, [home_cursor]
|
||||
mov [scroll_start], ax
|
||||
imul cx, size_of_step
|
||||
add ax, cx
|
||||
mov [scroll_end], ax
|
||||
pop si
|
||||
mov bp,long_v_table ;show rows
|
||||
.@@_next_bit:
|
||||
;clear cursor
|
||||
mov ax,' '
|
||||
mov word[ds:_r1+21],ax
|
||||
mov word[ds:_r1+50],ax
|
||||
|
||||
mov word[ds:_r2+21],ax
|
||||
mov word[ds:_r2+45],ax
|
||||
|
||||
mov word[ds:_rs+21],ax
|
||||
mov word[ds:_rs+46],ax
|
||||
; draw string
|
||||
cmp word [es:si+6],0x12
|
||||
je .show_0x12
|
||||
cmp word [es:si+6],0x13
|
||||
je .show_0x13
|
||||
|
||||
movzx eax,word[es:si]
|
||||
cmp ax,-1
|
||||
je .@@_end
|
||||
mov di,_rs+23
|
||||
mov ecx,10
|
||||
mov bl,4
|
||||
call int2str
|
||||
movzx eax,word[es:si+2]
|
||||
inc di
|
||||
mov bl,4
|
||||
call int2str
|
||||
|
||||
movzx eax,word[es:si+8]
|
||||
inc di
|
||||
mov bl,2
|
||||
call int2str
|
||||
|
||||
cmp si, word [cursor_pos]
|
||||
jne .next
|
||||
;draw cursor
|
||||
mov word[ds:_rs+21],'>>'
|
||||
mov word[ds:_rs+46],'<<'
|
||||
|
||||
|
||||
|
||||
.next:
|
||||
push si
|
||||
mov si,_rs
|
||||
.@@_sh:
|
||||
; add to the string pseudographics for scrollbar
|
||||
pop bx
|
||||
push bx
|
||||
mov byte [si+53], ' '
|
||||
cmp bx, [scroll_start]
|
||||
jb @f
|
||||
cmp bx, [scroll_end]
|
||||
jae @f
|
||||
mov byte [si+53], 0xDB ; filled bar
|
||||
@@:
|
||||
push bx
|
||||
add bx, size_of_step
|
||||
cmp bx, [end_cursor]
|
||||
jnz @f
|
||||
mov byte [si+53], 31 ; 'down arrow' symbol
|
||||
@@:
|
||||
sub bx, [home_cursor]
|
||||
cmp bx, size_of_step*long_v_table
|
||||
jnz @f
|
||||
mov byte [si+53], 31 ; 'down arrow' symbol
|
||||
@@:
|
||||
pop bx
|
||||
cmp bx, [home_cursor]
|
||||
jnz @f
|
||||
mov byte [si+53], 30 ; 'up arrow' symbol
|
||||
@@:
|
||||
call printplain
|
||||
pop si
|
||||
add si,size_of_step
|
||||
|
||||
dec bp
|
||||
jnz .@@_next_bit
|
||||
|
||||
.@@_end:
|
||||
mov si,_bt
|
||||
call printplain
|
||||
ret
|
||||
.show_0x13:
|
||||
push si
|
||||
|
||||
cmp si, word [cursor_pos]
|
||||
jne @f
|
||||
mov word[ds:_r1+21],'>>'
|
||||
mov word[ds:_r1+50],'<<'
|
||||
@@:
|
||||
mov si,_r1
|
||||
jmp .@@_sh
|
||||
.show_0x12:
|
||||
push si
|
||||
cmp si, word [cursor_pos]
|
||||
jne @f
|
||||
|
||||
mov word[ds:_r2+21],'>>'
|
||||
mov word[ds:_r2+45],'<<'
|
||||
@@:
|
||||
mov si,_r2
|
||||
jmp .@@_sh
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
;Clear arrea of current video page (0xb800)
|
||||
clear_vmodes_table:
|
||||
pusha
|
||||
; draw frames
|
||||
push es
|
||||
push 0xb800
|
||||
pop es
|
||||
mov di,1444
|
||||
xor ax,ax
|
||||
mov ah, 1*16+15
|
||||
mov cx,70
|
||||
mov bp,12
|
||||
.loop_start:
|
||||
rep stosw
|
||||
mov cx,70
|
||||
add di,20
|
||||
dec bp
|
||||
jns .loop_start
|
||||
pop es
|
||||
popa
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
set_vmode:
|
||||
push 0 ;0;x1000
|
||||
pop es
|
||||
|
||||
mov si,word [preboot_graph] ;[preboot_graph]
|
||||
mov cx,word [es:si+6] ; number of mode
|
||||
|
||||
|
||||
mov ax,word [es:si+0] ; resolution X
|
||||
mov bx,word [es:si+2] ; resolution Y
|
||||
|
||||
|
||||
mov word [es:0x900A],ax ; resolution X
|
||||
mov word [es:0x900C],bx ; resolution Y
|
||||
mov word [es:0x9008],cx ; number of mode
|
||||
|
||||
cmp cx,0x12
|
||||
je .mode0x12_0x13
|
||||
cmp cx,0x13
|
||||
je .mode0x12_0x13
|
||||
|
||||
|
||||
cmp byte [s_vesa.ver],'2'
|
||||
jb .vesa12
|
||||
|
||||
; VESA 2 and Vesa 3
|
||||
|
||||
mov ax,0x4f01
|
||||
and cx,0xfff
|
||||
mov di,mi;0xa000
|
||||
int 0x10
|
||||
; LFB
|
||||
mov eax,[es:mi.PhysBasePtr];di+0x28]
|
||||
mov [es:0x9018],eax
|
||||
; ---- vbe voodoo
|
||||
BytesPerLine equ 0x10
|
||||
mov ax, [es:di+BytesPerLine]
|
||||
mov [es:0x9001], ax
|
||||
; BPP
|
||||
cmp [es:mi.BitsPerPixel],16
|
||||
jne .l0
|
||||
cmp [es:mi.GreenMaskSize],5
|
||||
jne .l0
|
||||
mov [es:mi.BitsPerPixel],15
|
||||
.l0:
|
||||
mov al, byte [es:di+0x19]
|
||||
mov [es:0x9000], al
|
||||
jmp .exit
|
||||
|
||||
.mode0x12_0x13:
|
||||
mov byte [es:0x9000], 32
|
||||
or dword [es:0x9018], 0xFFFFFFFF; 0x800000
|
||||
|
||||
|
||||
; VESA 1.2 PM BANK SWITCH ADDRESS
|
||||
|
||||
.vesa12:
|
||||
|
||||
|
||||
mov ax,0x4f0A
|
||||
xor bx,bx
|
||||
int 0x10
|
||||
xor eax,eax
|
||||
xor ebx,ebx
|
||||
mov ax,es
|
||||
shl eax,4
|
||||
mov bx,di
|
||||
add eax,ebx
|
||||
movzx ebx,word[es:di]
|
||||
add eax,ebx
|
||||
push 0x0000
|
||||
pop es
|
||||
mov [es:0x9014],eax
|
||||
.exit:
|
||||
ret
|
||||
|
||||
|
||||
; mov dword[es:0x9018],0x000A0000
|
||||
; ret
|
||||
|
||||
;=============================================================================
|
||||
;=============================================================================
|
||||
;=============================================================================
|
||||
|
16
kernel/branches/boot/et.inc
Normal file
16
kernel/branches/boot/et.inc
Normal file
@ -0,0 +1,16 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
; Full ASCII code font
|
||||
; only õ and ä added
|
||||
; Kaitz
|
||||
ET_FNT:
|
||||
fontfile file "ETFONT.FNT"
|
||||
|
38
kernel/branches/boot/preboot.inc
Normal file
38
kernel/branches/boot/preboot.inc
Normal file
@ -0,0 +1,38 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 767 $
|
||||
|
||||
|
||||
display_modechg db 0 ; display mode change for text, yes/no (0 or 2)
|
||||
;
|
||||
; !! Important note !!
|
||||
;
|
||||
; Must be set to 2, to avoid two screenmode
|
||||
; changes within a very short period of time.
|
||||
|
||||
display_atboot db 0 ; show boot screen messages ( 2-no )
|
||||
|
||||
preboot_graph dw 0 ; graph mode
|
||||
x_save dw 0 ; x
|
||||
y_save dw 0 ; y
|
||||
number_vm dw 0 ;
|
||||
;pixel_save dw 0 ; per to pixel
|
||||
preboot_gprobe db 0 ; probe vesa3 videomodes (1-no, 2-yes)
|
||||
preboot_vrrm db 0 ; use VRR_M (1-yes, 2- no)
|
||||
preboot_dma db 0 ; use DMA for access to HDD (1-always, 2-only for read, 3-never)
|
||||
preboot_device db 0 ; boot device
|
||||
; (1-floppy 2-harddisk 3-kernel restart 4-format ram disk)
|
||||
;!!!! 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 $>0x200
|
||||
ERROR: prebooting parameters must fit in first sector!!!
|
||||
end if
|
||||
hdsysimage db 'KOLIBRI IMG' ; load from
|
||||
image_save db 'KOLIBRI IMG' ; save to
|
125
kernel/branches/boot/rdload.inc
Normal file
125
kernel/branches/boot/rdload.inc
Normal file
@ -0,0 +1,125 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 593 $
|
||||
|
||||
|
||||
; READ RAMDISK IMAGE FROM HD
|
||||
|
||||
cmp [boot_dev+OS_BASE+0x10000],1
|
||||
jne no_sys_on_hd
|
||||
|
||||
test [DRIVE_DATA+1],byte 0x40
|
||||
jz position_2
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],1
|
||||
mov [fat32part],0
|
||||
position_1_1:
|
||||
inc [fat32part]
|
||||
call search_and_read_image
|
||||
cmp [image_retrieved],1
|
||||
je yes_sys_on_hd
|
||||
movzx eax,byte [DRIVE_DATA+2]
|
||||
cmp [fat32part],eax
|
||||
jle position_1_1
|
||||
position_2:
|
||||
test [DRIVE_DATA+1],byte 0x10
|
||||
jz position_3
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],2
|
||||
mov [fat32part],0
|
||||
position_2_1:
|
||||
inc [fat32part]
|
||||
call search_and_read_image
|
||||
cmp [image_retrieved],1
|
||||
je yes_sys_on_hd
|
||||
movzx eax,byte [DRIVE_DATA+3]
|
||||
cmp eax,[fat32part]
|
||||
jle position_2_1
|
||||
position_3:
|
||||
test [DRIVE_DATA+1],byte 0x4
|
||||
jz position_4
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],3
|
||||
mov [fat32part],0
|
||||
position_3_1:
|
||||
inc [fat32part]
|
||||
call search_and_read_image
|
||||
cmp [image_retrieved],1
|
||||
je yes_sys_on_hd
|
||||
movzx eax,byte [DRIVE_DATA+4]
|
||||
cmp eax,[fat32part]
|
||||
jle position_3_1
|
||||
position_4:
|
||||
test [DRIVE_DATA+1],byte 0x1
|
||||
jz no_sys_on_hd
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],4
|
||||
mov [fat32part],0
|
||||
position_4_1:
|
||||
inc [fat32part]
|
||||
call search_and_read_image
|
||||
cmp [image_retrieved],1
|
||||
je yes_sys_on_hd
|
||||
movzx eax,byte [DRIVE_DATA+5]
|
||||
cmp eax,[fat32part]
|
||||
jle position_4_1
|
||||
jmp yes_sys_on_hd
|
||||
|
||||
search_and_read_image:
|
||||
call set_FAT32_variables
|
||||
mov edx, bootpath
|
||||
call read_image
|
||||
test eax, eax
|
||||
jz image_present
|
||||
mov edx, bootpath2
|
||||
call read_image
|
||||
test eax, eax
|
||||
jz image_present
|
||||
ret
|
||||
image_present:
|
||||
mov [image_retrieved],1
|
||||
ret
|
||||
|
||||
read_image:
|
||||
mov eax, hdsysimage+OS_BASE+0x10000
|
||||
mov ebx, 1474560/512
|
||||
mov ecx, RAMDISK
|
||||
mov esi, 0
|
||||
mov edi, 12
|
||||
call file_read
|
||||
ret
|
||||
|
||||
image_retrieved db 0
|
||||
counter_of_partitions db 0
|
||||
no_sys_on_hd:
|
||||
; test_to_format_ram_disk (need if not using ram disk)
|
||||
cmp [boot_dev+OS_BASE+0x10000],3
|
||||
jne not_format_ram_disk
|
||||
; format_ram_disk
|
||||
mov edi, RAMDISK
|
||||
mov ecx, 0x1080
|
||||
xor eax,eax
|
||||
@@:
|
||||
stosd
|
||||
loop @b
|
||||
|
||||
mov ecx, 0x58F7F
|
||||
mov eax,0xF6F6F6F6
|
||||
@@:
|
||||
stosd
|
||||
loop @b
|
||||
|
||||
mov [RAMDISK+0x200],dword 0xFFFFF0 ; fat table
|
||||
mov [RAMDISK+0x4200],dword 0xFFFFF0
|
||||
|
||||
not_format_ram_disk:
|
||||
yes_sys_on_hd:
|
102
kernel/branches/boot/ru.inc
Normal file
102
kernel/branches/boot/ru.inc
Normal file
@ -0,0 +1,102 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 774 $
|
||||
|
||||
|
||||
; Generated by RUFNT.EXE
|
||||
; By BadBugsKiller (C)
|
||||
; Modifyed by BadBugsKiller 12.01.2004 17:45
|
||||
; Øðèôò óìåíüøåí â ðàçìåðå è òåïåðü ñîñòîèò èç 2-óõ ÷àñòåé,
|
||||
; ñîäåðæàùèõ òîëüêî ñèìâîëû ðóññêîãî àëôàâèòà.
|
||||
; ñèìâîëû â êîäèðîâêå ASCII (ÄÎÑ'îâñêàÿ), êîäîâàÿ ñòðàíèöà 866.
|
||||
RU_FNT1:
|
||||
db 0x00, 0x00, 0x1E, 0x36, 0x66, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFE, 0x62, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFE, 0x66, 0x62, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xFF, 0xC3, 0x81, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xDB, 0xDB, 0x5A, 0x5A, 0x7E, 0x7E, 0x5A, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x3C, 0x06, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xE6, 0x66, 0x6C, 0x6C, 0x78, 0x78, 0x6C, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x1F, 0x36, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xCF, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
db 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC0, 0xC0, 0xC0, 0xC0, 0xC2, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xFF, 0xDB, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x7E, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0x6C, 0x7C, 0x38, 0x38, 0x7C, 0x6C, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFF, 0x03, 0x03, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFF, 0x03, 0x03, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xF8, 0xF0, 0xB0, 0x30, 0x3E, 0x33, 0x33, 0x33, 0x33, 0x7E, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xF3, 0xDB, 0xDB, 0xDB, 0xDB, 0xF3, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xF0, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x26, 0x3E, 0x26, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xCE, 0xDB, 0xDB, 0xDB, 0xFB, 0xDB, 0xDB, 0xDB, 0xDB, 0xCE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x3F, 0x66, 0x66, 0x66, 0x3E, 0x3E, 0x66, 0x66, 0x66, 0xE7, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x02, 0x06, 0x7C, 0xC0, 0xC0, 0xFC, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x62, 0x62, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0xFF, 0xC3, 0xC3, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xFE, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0x54, 0x7C, 0x54, 0xD6, 0xD6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x3C, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xCE, 0xD6, 0xE6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x6C, 0x38, 0xC6, 0xC6, 0xCE, 0xD6, 0xE6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xD6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
RU_FNT2:
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x3C, 0x18, 0x7E, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x7E, 0x18, 0x18, 0x3C, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x38, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFF, 0x03, 0x03, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x03, 0x03, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB0, 0xB0, 0x3E, 0x33, 0x33, 0x7E, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xF6, 0xDE, 0xDE, 0xF6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x3E, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE, 0xDB, 0xDB, 0xFB, 0xDB, 0xDB, 0xCE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xC6, 0xC6, 0x7E, 0x36, 0x66, 0xE7, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
db 0x6C, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x6C, 0x00, 0x7C, 0xC6, 0xC6, 0xFC, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC8, 0xF8, 0xC8, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xF8, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x66, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x6C, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00
|
||||
db 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0xCF, 0xCD, 0xEF, 0xEC, 0xFF, 0xDC, 0xDC, 0xCC, 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
209
kernel/branches/boot/shutdown.inc
Normal file
209
kernel/branches/boot/shutdown.inc
Normal file
@ -0,0 +1,209 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; Shutdown for Menuet ;;
|
||||
;; ;;
|
||||
;; Distributed under General Public License ;;
|
||||
;; See file COPYING for details. ;;
|
||||
;; Copyright 2003 Ville Turjanmaa ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 748 $
|
||||
|
||||
|
||||
align 4
|
||||
pr_mode_exit:
|
||||
|
||||
; setup stack
|
||||
mov ax, 0x3000
|
||||
mov ss, ax
|
||||
mov esp, 0x0EC00
|
||||
; setup ds
|
||||
push cs
|
||||
pop ds
|
||||
|
||||
lidt [old_ints_h]
|
||||
;remap IRQs
|
||||
mov al,0x11
|
||||
out 0x20,al
|
||||
call rdelay
|
||||
out 0xA0,al
|
||||
call rdelay
|
||||
|
||||
mov al,0x08
|
||||
out 0x21,al
|
||||
call rdelay
|
||||
mov al,0x70
|
||||
out 0xA1,al
|
||||
call rdelay
|
||||
|
||||
mov al,0x04
|
||||
out 0x21,al
|
||||
call rdelay
|
||||
mov al,0x02
|
||||
out 0xA1,al
|
||||
call rdelay
|
||||
|
||||
mov al,0x01
|
||||
out 0x21,al
|
||||
call rdelay
|
||||
out 0xA1,al
|
||||
call rdelay
|
||||
|
||||
mov al,0xB8
|
||||
out 0x21,al
|
||||
call rdelay
|
||||
mov al,0xBD
|
||||
out 0xA1,al
|
||||
sti
|
||||
|
||||
temp_3456:
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov al,byte [es:0x9030]
|
||||
cmp al,1
|
||||
jl nbw
|
||||
cmp al,4
|
||||
jle nbw32
|
||||
|
||||
nbw:
|
||||
in al,0x60
|
||||
cmp al,6
|
||||
jae nbw
|
||||
mov bl,al
|
||||
nbw2:
|
||||
in al,0x60
|
||||
cmp al,bl
|
||||
je nbw2
|
||||
cmp al,240 ;ax,240
|
||||
jne nbw31
|
||||
mov al,bl
|
||||
dec ax
|
||||
jmp nbw32
|
||||
nbw31:
|
||||
add bl,128
|
||||
cmp al,bl
|
||||
jne nbw
|
||||
sub al,129
|
||||
|
||||
nbw32:
|
||||
|
||||
dec ax
|
||||
dec ax ; 2 = power off
|
||||
jnz no_apm_off
|
||||
call APM_PowerOff
|
||||
jmp $
|
||||
no_apm_off:
|
||||
|
||||
dec ax ; 3 = reboot
|
||||
jnz restart_kernel ; 4 = restart kernel
|
||||
push 0x40
|
||||
pop ds
|
||||
mov word[0x0072],0x1234
|
||||
jmp 0xF000:0xFFF0
|
||||
|
||||
|
||||
rdelay:
|
||||
ret
|
||||
|
||||
APM_PowerOff:
|
||||
mov ax, 5304h
|
||||
xor bx, bx
|
||||
int 15h
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
mov ax,0x5300
|
||||
xor bx,bx
|
||||
int 0x15
|
||||
push ax
|
||||
|
||||
mov ax,0x5301
|
||||
xor bx,bx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x5308
|
||||
mov bx,1
|
||||
mov cx,bx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x530E
|
||||
xor bx,bx
|
||||
pop cx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x530D
|
||||
mov bx,1
|
||||
mov cx,bx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x530F
|
||||
mov bx,1
|
||||
mov cx,bx
|
||||
int 0x15
|
||||
|
||||
mov ax,0x5307
|
||||
mov bx,1
|
||||
mov cx,3
|
||||
int 0x15
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
ret
|
||||
|
||||
restart_kernel:
|
||||
|
||||
mov ax,0x0003 ; set text mode for screen
|
||||
int 0x10
|
||||
jmp 0x4000:0000
|
||||
|
||||
restart_kernel_4000:
|
||||
cli
|
||||
|
||||
push ds
|
||||
pop es
|
||||
mov cx, 0x8000
|
||||
push cx
|
||||
push 0x7000
|
||||
pop ds
|
||||
xor si, si
|
||||
xor di, di
|
||||
rep movsw
|
||||
pop cx
|
||||
mov ds, cx
|
||||
push 0x2000
|
||||
pop es
|
||||
rep movsw
|
||||
push 0x9000
|
||||
pop ds
|
||||
push 0x3000
|
||||
pop es
|
||||
mov cx, 0xE000/2
|
||||
rep movsw
|
||||
|
||||
wbinvd ; write and invalidate cache
|
||||
|
||||
mov al, 00110100b
|
||||
out 43h, al
|
||||
jcxz $+2
|
||||
mov al, 0xFF
|
||||
out 40h, al
|
||||
jcxz $+2
|
||||
out 40h, al
|
||||
jcxz $+2
|
||||
sti
|
||||
|
||||
; (hint by Black_mirror)
|
||||
; We must read data from keyboard port,
|
||||
; because there may be situation when previous keyboard interrupt is lost
|
||||
; (due to return to real mode and IRQ reprogramming)
|
||||
; and next interrupt will not be generated (as keyboard waits for handling)
|
||||
in al, 0x60
|
||||
|
||||
; bootloader interface
|
||||
push 0x1000
|
||||
pop ds
|
||||
mov si, kernel_restart_bootblock
|
||||
mov ax, 'KL'
|
||||
jmp 0x1000:0000
|
||||
|
||||
|
287
kernel/branches/bootloader/boot_fat12.asm
Normal file
287
kernel/branches/bootloader/boot_fat12.asm
Normal file
@ -0,0 +1,287 @@
|
||||
; FAT12 boot sector for Kolibri OS
|
||||
;
|
||||
; Copyright (C) Alex Nogueira Teixeira
|
||||
; Copyright (C) Diamond
|
||||
; Copyright (C) Dmitry Kartashov aka shurf
|
||||
;
|
||||
; Distributed under GPL, see file COPYING for details
|
||||
;
|
||||
; Version 1.0
|
||||
|
||||
lf equ 0ah
|
||||
cr equ 0dh
|
||||
|
||||
pos_read_tmp equ 0700h ;position for temporary read
|
||||
boot_program equ 07c00h ;position for boot code
|
||||
seg_read_kernel equ 01000h ;segment to kernel read
|
||||
|
||||
jmp start_program
|
||||
nop
|
||||
|
||||
; Boot Sector and BPB Structure
|
||||
include 'floppy1440.inc'
|
||||
;include 'floppy2880.inc'
|
||||
;include 'floppy1680.inc'
|
||||
;include 'floppy1743.inc'
|
||||
|
||||
start_program:
|
||||
|
||||
xor ax,ax
|
||||
mov ss,ax
|
||||
mov sp,boot_program
|
||||
push ss
|
||||
pop ds
|
||||
|
||||
; print loading string
|
||||
mov si,loading+boot_program
|
||||
loop_loading:
|
||||
lodsb
|
||||
or al,al
|
||||
jz read_root_directory
|
||||
mov ah,0eh
|
||||
mov bx,7
|
||||
int 10h
|
||||
jmp loop_loading
|
||||
|
||||
read_root_directory:
|
||||
push ss
|
||||
pop es
|
||||
|
||||
; calculate some disk parameters
|
||||
; - beginning sector of RootDir
|
||||
mov ax,word [BPB_FATSz16+boot_program]
|
||||
xor cx,cx
|
||||
mov cl,byte [BPB_NumFATs+boot_program]
|
||||
mul cx
|
||||
add ax,word [BPB_RsvdSecCnt+boot_program]
|
||||
mov word [FirstRootDirSecNum+boot_program],ax ; 19
|
||||
mov si,ax
|
||||
|
||||
; - count of sectors in RootDir
|
||||
mov bx,word [BPB_BytsPerSec+boot_program]
|
||||
mov cl,5 ; divide ax by 32
|
||||
shr bx,cl ; bx = directory entries per sector
|
||||
mov ax,word [BPB_RootEntCnt+boot_program]
|
||||
xor dx,dx
|
||||
div bx
|
||||
mov word [RootDirSecs+boot_program],ax ; 14
|
||||
|
||||
; - data start
|
||||
add si,ax ; add beginning sector of RootDir and count sectors in RootDir
|
||||
mov word [data_start+boot_program],si ; 33
|
||||
; reading root directory
|
||||
; al=count root dir sectrors !!!! TODO: al, max 255 sectors !!!!
|
||||
mov ah,2 ; read
|
||||
push ax
|
||||
|
||||
mov ax,word [FirstRootDirSecNum+boot_program]
|
||||
call conv_abs_to_THS ; convert abs sector (AX) to BIOS T:H:S (track:head:sector)
|
||||
pop ax
|
||||
mov bx,pos_read_tmp ; es:bx read buffer
|
||||
call read_sector
|
||||
|
||||
mov si,bx ; read buffer address: es:si
|
||||
mov ax,[RootDirSecs+boot_program]
|
||||
mul word [BPB_BytsPerSec+boot_program]
|
||||
add ax,si ; AX = end of root dir. in buffer pos_read_tmp
|
||||
|
||||
; find kernel file in root directory
|
||||
loop_find_dir_entry:
|
||||
push si
|
||||
mov cx,11
|
||||
mov di,kernel_name+boot_program
|
||||
rep cmpsb ; compare es:si and es:di, cx bytes long
|
||||
pop si
|
||||
je found_kernel_file
|
||||
add si,32 ; next dir. entry
|
||||
cmp si,ax ; end of directory
|
||||
jb loop_find_dir_entry
|
||||
|
||||
file_error_message:
|
||||
mov si,error_message+boot_program
|
||||
|
||||
loop_error_message:
|
||||
lodsb
|
||||
or al,al
|
||||
jz freeze_pc
|
||||
mov ah,0eh
|
||||
mov bx,7
|
||||
int 10h
|
||||
jmp loop_error_message
|
||||
|
||||
freeze_pc:
|
||||
jmp $ ; endless loop
|
||||
|
||||
; === KERNEL FOUND. LOADING... ===
|
||||
|
||||
found_kernel_file:
|
||||
mov bp,[si+01ah] ; first cluster of kernel file
|
||||
; <diamond>
|
||||
mov [cluster1st+boot_program],bp ; starting cluster of kernel file
|
||||
; <\diamond>
|
||||
|
||||
; reading first FAT table
|
||||
mov ax,word [BPB_RsvdSecCnt+boot_program] ; begin first FAT abs sector number
|
||||
call conv_abs_to_THS ; convert abs sector (AX) to BIOS T:H:S (track:head:sector)
|
||||
mov bx,pos_read_tmp ; es:bx read position
|
||||
mov ah,2 ; ah=2 (read)
|
||||
mov al, byte [BPB_FATSz16+boot_program] ; FAT size in sectors (TODO: max 255 sectors)
|
||||
call read_sector
|
||||
jc file_error_message ; read error
|
||||
|
||||
mov ax,seg_read_kernel
|
||||
mov es,ax
|
||||
xor bx,bx ; es:bx = 1000h:0000h
|
||||
|
||||
|
||||
; reading kernel file
|
||||
loop_obtains_kernel_data:
|
||||
; read one cluster of file
|
||||
call obtain_cluster
|
||||
jc file_error_message ; read error
|
||||
|
||||
; add one cluster length to segment:offset
|
||||
push bx
|
||||
mov bx,es
|
||||
mov ax,word [BPB_BytsPerSec+boot_program] ;\
|
||||
movsx cx,byte [BPB_SecPerClus+boot_program] ; | !!! TODO: !!!
|
||||
mul cx ; | out this from loop !!!
|
||||
shr ax,4 ;/
|
||||
add bx,ax
|
||||
mov es,bx
|
||||
pop bx
|
||||
|
||||
mov di,bp
|
||||
shr di,1
|
||||
pushf
|
||||
add di,bp ; di = bp * 1.5
|
||||
add di,pos_read_tmp
|
||||
mov ax,[di] ; read next entry from FAT-chain
|
||||
popf
|
||||
jc move_4_right
|
||||
and ax,0fffh
|
||||
jmp verify_end_sector
|
||||
move_4_right:
|
||||
mov cl,4
|
||||
shr ax,cl
|
||||
verify_end_sector:
|
||||
cmp ax,0ff8h ; last cluster
|
||||
jae execute_kernel
|
||||
mov bp,ax
|
||||
jmp loop_obtains_kernel_data
|
||||
|
||||
execute_kernel:
|
||||
; <diamond>
|
||||
mov ax,'KL'
|
||||
push 0
|
||||
pop ds
|
||||
mov si,loader_block+boot_program
|
||||
; </diamond>
|
||||
push word seg_read_kernel
|
||||
push word 0
|
||||
retf ; jmp far 1000:0000
|
||||
|
||||
|
||||
;------------------------------------------
|
||||
; loading cluster from file to es:bx
|
||||
obtain_cluster:
|
||||
; bp - cluster number to read
|
||||
; carry = 0 -> read OK
|
||||
; carry = 1 -> read ERROR
|
||||
|
||||
; print one dot
|
||||
push bx
|
||||
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:
|
||||
call conv_abs_to_THS ; convert abs sector (AX) to BIOS T:H:S (track:head:sector)
|
||||
patchhere:
|
||||
mov ah,2 ; ah=2 (read)
|
||||
mov al,byte [BPB_SecPerClus+boot_program] ; al=(one cluster)
|
||||
call read_sector
|
||||
retn
|
||||
;------------------------------------------
|
||||
|
||||
;------------------------------------------
|
||||
; read sector from disk
|
||||
read_sector:
|
||||
push bp
|
||||
mov bp,20 ; try 20 times
|
||||
newread:
|
||||
dec bp
|
||||
jz file_error_message
|
||||
push ax bx cx dx
|
||||
int 13h
|
||||
pop dx cx bx ax
|
||||
jc newread
|
||||
pop bp
|
||||
retn
|
||||
;------------------------------------------
|
||||
; convert abs. sector number (AX) to BIOS T:H:S
|
||||
; sector number = (abs.sector%BPB_SecPerTrk)+1
|
||||
; pre.track number = (abs.sector/BPB_SecPerTrk)
|
||||
; head number = pre.track number%BPB_NumHeads
|
||||
; track number = pre.track number/BPB_NumHeads
|
||||
; Return: cl - sector number
|
||||
; ch - track number
|
||||
; dl - drive number (0 = a:)
|
||||
; dh - head number
|
||||
conv_abs_to_THS:
|
||||
push bx
|
||||
mov bx,word [BPB_SecPerTrk+boot_program]
|
||||
xor dx,dx
|
||||
div bx
|
||||
inc dx
|
||||
mov cl, dl ; cl = sector number
|
||||
mov bx,word [BPB_NumHeads+boot_program]
|
||||
xor dx,dx
|
||||
div bx
|
||||
; !!!!!!! ax = track number, dx = head number
|
||||
mov ch,al ; ch=track number
|
||||
xchg dh,dl ; dh=head number
|
||||
mov dl,0 ; dl=0 (drive 0 (a:))
|
||||
pop bx
|
||||
retn
|
||||
;------------------------------------------
|
||||
|
||||
loading db cr,lf,'Starting system ',00h
|
||||
error_message db 13,10
|
||||
kernel_name db 'KERNEL MNT ?',cr,lf,00h
|
||||
FirstRootDirSecNum dw ?
|
||||
RootDirSecs dw ?
|
||||
data_start dw ?
|
||||
|
||||
; <diamond>
|
||||
write1st:
|
||||
push cs
|
||||
pop ds
|
||||
mov byte [patchhere+1+boot_program], 3 ; change ah=2 to ah=3
|
||||
mov ax,[cluster1st+boot_program]
|
||||
push 1000h
|
||||
pop es
|
||||
xor bx,bx
|
||||
call writesec
|
||||
mov byte [patchhere+1+boot_program], 2 ; change back ah=3 to ah=2
|
||||
retf
|
||||
cluster1st dw ?
|
||||
loader_block:
|
||||
db 1
|
||||
dw 0
|
||||
dw write1st+boot_program
|
||||
dw 0
|
||||
; <\diamond>
|
||||
|
||||
times 0x1fe-$ db 00h
|
||||
|
||||
db 55h,0aah ;boot signature
|
19
kernel/branches/bootloader/floppy1440.inc
Normal file
19
kernel/branches/bootloader/floppy1440.inc
Normal file
@ -0,0 +1,19 @@
|
||||
BS_OEMName db 'KOLIBRI ' ; db 8
|
||||
BPB_BytsPerSec dw 512 ; bytes per sector
|
||||
BPB_SecPerClus db 1 ; sectors per cluster
|
||||
BPB_RsvdSecCnt dw 1 ; number of reserver sectors
|
||||
BPB_NumFATs db 2 ; count of FAT data structures
|
||||
BPB_RootEntCnt dw 224 ; count of 32-byte dir. entries (224*32 = 14 sectors)
|
||||
BPB_TotSec16 dw 2880 ; count of sectors on the volume (2880 for 1.44 mbytes disk)
|
||||
BPB_Media db 0f0h ; f0 - used for removable media
|
||||
BPB_FATSz16 dw 9 ; count of sectors by one copy of FAT
|
||||
BPB_SecPerTrk dw 18 ; sectors per track
|
||||
BPB_NumHeads dw 2 ; number of heads
|
||||
BPB_HiddSec dd 0 ; count of hidden sectors
|
||||
BPB_TotSec32 dd 0 ; count of sectors on the volume (if > 65535)
|
||||
BS_DrvNum db 0 ; int 13h drive number
|
||||
BS_Reserved db 0 ; reserved
|
||||
BS_BootSig db 29h ; Extended boot signature
|
||||
BS_VolID dd 0 ; Volume serial number
|
||||
BS_VolLab db 'KOLIBRI ' ; Volume label (db 11)
|
||||
BS_FilSysType db 'FAT12 ' ; file system type (db 8)
|
19
kernel/branches/bootloader/floppy1680.inc
Normal file
19
kernel/branches/bootloader/floppy1680.inc
Normal file
@ -0,0 +1,19 @@
|
||||
BS_OEMName db 'KOLIBRI ' ; db 8
|
||||
BPB_BytsPerSec dw 512 ; bytes per sector
|
||||
BPB_SecPerClus db 1 ; sectors per cluster
|
||||
BPB_RsvdSecCnt dw 1 ; number of reserver sectors
|
||||
BPB_NumFATs db 2 ; count of FAT data structures
|
||||
BPB_RootEntCnt dw 112 ; count of 32-byte dir. entries (112*32 = 7 sectors)
|
||||
BPB_TotSec16 dw 3360 ; count of sectors on the volume (3360 for 1.68 mbytes disk)
|
||||
BPB_Media db 0f0h ; f0 - used for removable media
|
||||
BPB_FATSz16 dw 10 ; count of sectors by one copy of FAT
|
||||
BPB_SecPerTrk dw 21 ; sectors per track
|
||||
BPB_NumHeads dw 2 ; number of heads
|
||||
BPB_HiddSec dd 0 ; count of hidden sectors
|
||||
BPB_TotSec32 dd 0 ; count of sectors on the volume (if > 65535)
|
||||
BS_DrvNum db 0 ; int 13h drive number
|
||||
BS_Reserved db 0 ; reserved
|
||||
BS_BootSig db 29h ; Extended boot signature
|
||||
BS_VolID dd 0 ; Volume serial number
|
||||
BS_VolLab db 'KOLIBRI ' ; Volume label (db 11)
|
||||
BS_FilSysType db 'FAT12 ' ; file system type (db 8)
|
19
kernel/branches/bootloader/floppy1743.inc
Normal file
19
kernel/branches/bootloader/floppy1743.inc
Normal file
@ -0,0 +1,19 @@
|
||||
BS_OEMName db 'KOLIBRI ' ; db 8
|
||||
BPB_BytsPerSec dw 512 ; bytes per sector
|
||||
BPB_SecPerClus db 1 ; sectors per cluster
|
||||
BPB_RsvdSecCnt dw 1 ; number of reserver sectors
|
||||
BPB_NumFATs db 2 ; count of FAT data structures
|
||||
BPB_RootEntCnt dw 224 ; count of 32-byte dir. entries (224*32 = 14 sectors)
|
||||
BPB_TotSec16 dw 3486 ; count of sectors on the volume (3486 for 1.74 mbytes disk)
|
||||
BPB_Media db 0f0h ; f0 - used for removable media
|
||||
BPB_FATSz16 dw 11 ; count of sectors by one copy of FAT
|
||||
BPB_SecPerTrk dw 21 ; sectors per track
|
||||
BPB_NumHeads dw 2 ; number of heads
|
||||
BPB_HiddSec dd 0 ; count of hidden sectors
|
||||
BPB_TotSec32 dd 0 ; count of sectors on the volume (if > 65535)
|
||||
BS_DrvNum db 0 ; int 13h drive number
|
||||
BS_Reserved db 0 ; reserved
|
||||
BS_BootSig db 29h ; Extended boot signature
|
||||
BS_VolID dd 0 ; Volume serial number
|
||||
BS_VolLab db 'KOLIBRI ' ; Volume label (db 11)
|
||||
BS_FilSysType db 'FAT12 ' ; file system type (db 8)
|
19
kernel/branches/bootloader/floppy2880.inc
Normal file
19
kernel/branches/bootloader/floppy2880.inc
Normal file
@ -0,0 +1,19 @@
|
||||
BS_OEMName db 'KOLIBRI ' ; db 8
|
||||
BPB_BytsPerSec dw 512 ; bytes per sector
|
||||
BPB_SecPerClus db 2 ; sectors per cluster
|
||||
BPB_RsvdSecCnt dw 1 ; number of reserver sectors
|
||||
BPB_NumFATs db 2 ; count of FAT data structures
|
||||
BPB_RootEntCnt dw 240 ; count of 32-byte dir. entries (240*32 = 15 sectors)
|
||||
BPB_TotSec16 dw 5760 ; count of sectors on the volume (5760 for 2.88 mbytes disk)
|
||||
BPB_Media db 0f0h ; f0 - used for removable media
|
||||
BPB_FATSz16 dw 9 ; count of sectors by one copy of FAT
|
||||
BPB_SecPerTrk dw 36 ; sectors per track
|
||||
BPB_NumHeads dw 2 ; number of heads
|
||||
BPB_HiddSec dd 0 ; count of hidden sectors
|
||||
BPB_TotSec32 dd 0 ; count of sectors on the volume (if > 65535)
|
||||
BS_DrvNum db 0 ; int 13h drive number
|
||||
BS_Reserved db 0 ; reserved
|
||||
BS_BootSig db 29h ; Extended boot signature
|
||||
BS_VolID dd 0 ; Volume serial number
|
||||
BS_VolLab db 'KOLIBRI ' ; Volume label (db 11)
|
||||
BS_FilSysType db 'FAT12 ' ; file system type (db 8)
|
43
kernel/branches/bootloader/readme
Normal file
43
kernel/branches/bootloader/readme
Normal file
@ -0,0 +1,43 @@
|
||||
‡ £à㧮çë© á¥ªâ®à ¤«ï Ž‘ Š®«¨¡à¨ (FAT12, ¤¨áª¥â )
|
||||
|
||||
- Ž¯¨á ¨¥
|
||||
<20>®§¢®«ï¥â § £à㦠âì KERNEL.MNT á ¤¨áª¥â/®¡à §®¢
|
||||
®¡êñ¬®¬ 1.44M, 1.68M, 1.72M ¨ 2.88M
|
||||
„«ï ¢ë¡®à ®¡êñ¬ ¤¨áª , ¤«ï ª®â®à®£® ¤® ᮡà âì
|
||||
§ £à㧮çë© á¥ªâ®à, ¥®¡å®¤¨¬® ¢ ä ©«¥ boot_fat12.asm
|
||||
à ᪮¬¬¥â¨à®¢ âì áâப㠢¨¤ :
|
||||
include 'floppy????.inc'
|
||||
¤«ï ¥®¡å®¤¨¬®£® ®¡êñ¬ ¤¨áª . „®áâã¯ë¥ ¢ ਠâë:
|
||||
floppy1440.inc,
|
||||
floppy1680.inc,
|
||||
floppy1743.inc ¨ floppy2880.inc
|
||||
|
||||
- ‘¡®àª
|
||||
fasm boot_fat12.asm
|
||||
|
||||
- „«ï § ¯¨á¨ § £à㧮箣® ᥪâ®à ¤¨áª/®¡à § ¯®¤ Linux
|
||||
¬®¦® ¢®á¯®«ì§®¢ âìáï á«¥¤ãî饩 ª®¬ ¤®©:
|
||||
dd if=boot_fat12.bin of=288.img bs=512 count=1 conv=notrunc
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Floppy FAT12 boot sector for KolibriOS.
|
||||
|
||||
- Description
|
||||
Allows booting KERNEL.MNT floppies/images
|
||||
with volumes of 1.44M, 1.68M, 1.72M and 2.88M
|
||||
To select the volume of the disk, which should gather
|
||||
boot sector, it was necessary in file boot_fat12.asm
|
||||
uncomment line:
|
||||
include 'floppy????. inc'
|
||||
for the necessary disk volume. Available options is:
|
||||
floppy1440.inc,
|
||||
floppy1680.inc,
|
||||
floppy1743.inc and floppy2880.inc
|
||||
|
||||
- Compile
|
||||
fasm boot_fat12.asm
|
||||
|
||||
- To write boot sector to the floppy/image under Linux
|
||||
you can use the following command:
|
||||
dd if=boot_fat12.bin of=288.img bs=512 count=1 conv=notrunc
|
105
kernel/branches/build.bat
Normal file
105
kernel/branches/build.bat
Normal file
@ -0,0 +1,105 @@
|
||||
@echo off
|
||||
|
||||
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
|
||||
|
||||
call :Check_Target %1
|
||||
for %%a in (all kernel) do if %%a==%target% call :Check_Lang %2
|
||||
call :Target_%target%
|
||||
|
||||
if ERRORLEVEL 0 goto Exit_OK
|
||||
|
||||
echo There was an error executing script.
|
||||
echo For any help, please send a report.
|
||||
pause
|
||||
goto :eof
|
||||
|
||||
|
||||
|
||||
|
||||
:Check_Lang
|
||||
set res=%1
|
||||
:Check_Lang_loop
|
||||
for %%a in (%languages%) do if %%a==%res% set lang=%res%
|
||||
if defined lang goto :eof
|
||||
|
||||
echo Language '%res%' is incorrect
|
||||
echo Enter valid language [ %languages% ]:
|
||||
|
||||
set /P res=">
|
||||
goto Check_Lang_loop
|
||||
goto :eof
|
||||
|
||||
:Check_Target
|
||||
set res=%1
|
||||
:Check_Target_loop
|
||||
for %%a in (%targets%) do if %%a==%res% set target=%res%
|
||||
if defined target goto :eof
|
||||
|
||||
echo Target '%res%' is incorrect
|
||||
echo Enter valid target [ %targets% ]:
|
||||
|
||||
set /P res=">
|
||||
goto Check_Target_loop
|
||||
goto :eof
|
||||
|
||||
|
||||
:Target_kernel
|
||||
echo *** building kernel with language '%lang%' ...
|
||||
|
||||
if not exist bin mkdir bin
|
||||
echo lang fix %lang% > lang.inc
|
||||
fasm -m 65536 kernel.asm bin\kernel.mnt
|
||||
if not %errorlevel%==0 goto :Error_FasmFailed
|
||||
erase lang.inc
|
||||
goto :eof
|
||||
|
||||
|
||||
:Target_all
|
||||
call :Target_kernel
|
||||
call :Target_drivers
|
||||
call :Target_skins
|
||||
goto :eof
|
||||
|
||||
|
||||
:Target_drivers
|
||||
echo *** building drivers ...
|
||||
|
||||
if not exist bin\drivers mkdir bin\drivers
|
||||
cd drivers
|
||||
for %%a in (%drivers%) do (
|
||||
fasm -m 65536 %%a.asm ..\bin\drivers\%%a.obj
|
||||
if not %errorlevel%==0 goto :Error_FasmFailed
|
||||
)
|
||||
cd ..
|
||||
move bin\drivers\vmode.obj bin\drivers\vmode.mdr
|
||||
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
|
||||
goto :Exit_OK
|
||||
|
||||
|
||||
:Error_FasmFailed
|
||||
echo error: fasm execution failed
|
||||
erase lang.inc
|
||||
pause
|
||||
exit 1
|
||||
|
||||
:Exit_OK
|
||||
echo all operations has been done
|
||||
pause
|
||||
exit 0
|
51
kernel/branches/bus/pci/pci16.inc
Normal file
51
kernel/branches/bus/pci/pci16.inc
Normal file
@ -0,0 +1,51 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; PCI16.INC ;;
|
||||
;; ;;
|
||||
;; 16 bit PCI driver code ;;
|
||||
;; ;;
|
||||
;; Version 0.2 December 21st, 2002 ;;
|
||||
;; ;;
|
||||
;; Author: Victor Prodan, victorprodan@yahoo.com ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 593 $
|
||||
|
||||
|
||||
init_pci_16:
|
||||
|
||||
pushad
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov byte [es:0x9020],1 ;default mechanism:1
|
||||
mov ax,0xb101
|
||||
int 0x1a
|
||||
or ah,ah
|
||||
jnz pci16skip
|
||||
|
||||
mov [es:0x9021],cl ;last PCI bus in system
|
||||
mov [es:0x9022],bx
|
||||
mov [es:0x9024],edi
|
||||
|
||||
; we have a PCI BIOS, so check which configuration mechanism(s)
|
||||
; it supports
|
||||
; AL = PCI hardware characteristics (bit0 => mechanism1, bit1 => mechanism2)
|
||||
test al,1
|
||||
jnz pci16skip
|
||||
test al,2
|
||||
jz pci16skip
|
||||
mov byte [es:0x9020],2 ; if (al&3)==2 => mechanism 2
|
||||
|
||||
pci16skip:
|
||||
|
||||
mov ax,0x1000
|
||||
mov es,ax
|
||||
|
||||
popad
|
483
kernel/branches/bus/pci/pci32.inc
Normal file
483
kernel/branches/bus/pci/pci32.inc
Normal file
@ -0,0 +1,483 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; ;;
|
||||
;; PCI32.INC ;;
|
||||
;; ;;
|
||||
;; 32 bit PCI driver code ;;
|
||||
;; ;;
|
||||
;; Version 0.3 April 9, 2007 ;;
|
||||
;; Version 0.2 December 21st, 2002 ;;
|
||||
;; ;;
|
||||
;; Author: Victor Prodan, victorprodan@yahoo.com ;;
|
||||
;; Mihailov Ilia, ghost.nsk@gmail.com ;;
|
||||
;; Credits: ;;
|
||||
;; Ralf Brown ;;
|
||||
;; Mike Hibbett, mikeh@oceanfree.net ;;
|
||||
;; ;;
|
||||
;; See file COPYING for details ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_api:
|
||||
;
|
||||
; Description
|
||||
; entry point for system PCI calls
|
||||
;***************************************************************************
|
||||
|
||||
align 4
|
||||
|
||||
pci_api:
|
||||
|
||||
cmp [pci_access_enabled],1
|
||||
jne no_pci_access_for_applications
|
||||
|
||||
or al,al
|
||||
jnz pci_fn_1
|
||||
; PCI function 0: get pci version (AH.AL)
|
||||
movzx eax,word [BOOT_VAR+0x9022]
|
||||
ret
|
||||
|
||||
pci_fn_1:
|
||||
cmp al,1
|
||||
jnz pci_fn_2
|
||||
|
||||
; PCI function 1: get last bus in AL
|
||||
mov al,[BOOT_VAR+0x9021]
|
||||
ret
|
||||
|
||||
pci_fn_2:
|
||||
cmp al,2
|
||||
jne pci_fn_3
|
||||
; PCI function 2: get pci access mechanism
|
||||
mov al,[BOOT_VAR+0x9020]
|
||||
ret
|
||||
pci_fn_3:
|
||||
|
||||
cmp al,4
|
||||
jz pci_read_reg ;byte
|
||||
cmp al,5
|
||||
jz pci_read_reg ;word
|
||||
cmp al,6
|
||||
jz pci_read_reg ;dword
|
||||
|
||||
cmp al,8
|
||||
jz pci_write_reg ;byte
|
||||
cmp al,9
|
||||
jz pci_write_reg ;word
|
||||
cmp al,10
|
||||
jz pci_write_reg ;dword
|
||||
|
||||
no_pci_access_for_applications:
|
||||
|
||||
mov eax,-1
|
||||
|
||||
ret
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_make_config_cmd
|
||||
;
|
||||
; Description
|
||||
; creates a command dword for use with the PCI bus
|
||||
; bus # in ah
|
||||
; device+func in bh (dddddfff)
|
||||
; register in bl
|
||||
;
|
||||
; command dword returned in eax ( 10000000 bbbbbbbb dddddfff rrrrrr00 )
|
||||
;***************************************************************************
|
||||
|
||||
align 4
|
||||
|
||||
pci_make_config_cmd:
|
||||
shl eax,8 ; move bus to bits 16-23
|
||||
mov ax,bx ; combine all
|
||||
and eax,0xffffff
|
||||
or eax,0x80000000
|
||||
ret
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_read_reg:
|
||||
;
|
||||
; Description
|
||||
; read a register from the PCI config space into EAX/AX/AL
|
||||
; IN: ah=bus,device+func=bh,register address=bl
|
||||
; number of bytes to read (1,2,4) coded into AL, bits 0-1
|
||||
; (0 - byte, 1 - word, 2 - dword)
|
||||
;***************************************************************************
|
||||
|
||||
align 4
|
||||
|
||||
pci_read_reg:
|
||||
cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use?
|
||||
je pci_read_reg_2
|
||||
|
||||
; mechanism 1
|
||||
push esi ; save register size into ESI
|
||||
mov esi,eax
|
||||
and esi,3
|
||||
|
||||
call pci_make_config_cmd
|
||||
mov ebx,eax
|
||||
; get current state
|
||||
mov dx,0xcf8
|
||||
in eax, dx
|
||||
push eax
|
||||
; set up addressing to config data
|
||||
mov eax,ebx
|
||||
and al,0xfc ; make address dword-aligned
|
||||
out dx,eax
|
||||
; get requested DWORD of config data
|
||||
mov dl,0xfc
|
||||
and bl,3
|
||||
or dl,bl ; add to port address first 2 bits of register address
|
||||
|
||||
or esi,esi
|
||||
jz pci_read_byte1
|
||||
cmp esi,1
|
||||
jz pci_read_word1
|
||||
cmp esi,2
|
||||
jz pci_read_dword1
|
||||
jmp pci_fin_read1
|
||||
|
||||
pci_read_byte1:
|
||||
in al,dx
|
||||
jmp pci_fin_read1
|
||||
pci_read_word1:
|
||||
in ax,dx
|
||||
jmp pci_fin_read1
|
||||
pci_read_dword1:
|
||||
in eax,dx
|
||||
jmp pci_fin_read1
|
||||
pci_fin_read1:
|
||||
; restore configuration control
|
||||
xchg eax,[esp]
|
||||
mov dx,0xcf8
|
||||
out dx,eax
|
||||
|
||||
pop eax
|
||||
pop esi
|
||||
ret
|
||||
pci_read_reg_2:
|
||||
|
||||
test bh,128 ;mech#2 only supports 16 devices per bus
|
||||
jnz pci_read_reg_err
|
||||
|
||||
push esi ; save register size into ESI
|
||||
mov esi,eax
|
||||
and esi,3
|
||||
|
||||
push eax
|
||||
;store current state of config space
|
||||
mov dx,0xcf8
|
||||
in al,dx
|
||||
mov ah,al
|
||||
mov dl,0xfa
|
||||
in al,dx
|
||||
|
||||
xchg eax,[esp]
|
||||
; out 0xcfa,bus
|
||||
mov al,ah
|
||||
out dx,al
|
||||
; out 0xcf8,0x80
|
||||
mov dl,0xf8
|
||||
mov al,0x80
|
||||
out dx,al
|
||||
; compute addr
|
||||
shr bh,3 ; func is ignored in mechanism 2
|
||||
or bh,0xc0
|
||||
mov dx,bx
|
||||
|
||||
or esi,esi
|
||||
jz pci_read_byte2
|
||||
cmp esi,1
|
||||
jz pci_read_word2
|
||||
cmp esi,2
|
||||
jz pci_read_dword2
|
||||
jmp pci_fin_read2
|
||||
|
||||
pci_read_byte2:
|
||||
in al,dx
|
||||
jmp pci_fin_read2
|
||||
pci_read_word2:
|
||||
in ax,dx
|
||||
jmp pci_fin_read2
|
||||
pci_read_dword2:
|
||||
in eax,dx
|
||||
; jmp pci_fin_read2
|
||||
pci_fin_read2:
|
||||
|
||||
; restore configuration space
|
||||
xchg eax,[esp]
|
||||
mov dx,0xcfa
|
||||
out dx,al
|
||||
mov dl,0xf8
|
||||
mov al,ah
|
||||
out dx,al
|
||||
|
||||
pop eax
|
||||
pop esi
|
||||
ret
|
||||
|
||||
pci_read_reg_err:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
ret
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_write_reg:
|
||||
;
|
||||
; Description
|
||||
; write a register from ECX/CX/CL into the PCI config space
|
||||
; IN: ah=bus,device+func=bh,register address (dword aligned)=bl,
|
||||
; value to write in ecx
|
||||
; number of bytes to write (1,2,4) coded into AL, bits 0-1
|
||||
; (0 - byte, 1 - word, 2 - dword)
|
||||
;***************************************************************************
|
||||
|
||||
align 4
|
||||
|
||||
pci_write_reg:
|
||||
cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use?
|
||||
je pci_write_reg_2
|
||||
|
||||
; mechanism 1
|
||||
push esi ; save register size into ESI
|
||||
mov esi,eax
|
||||
and esi,3
|
||||
|
||||
call pci_make_config_cmd
|
||||
mov ebx,eax
|
||||
; get current state into ecx
|
||||
mov dx,0xcf8
|
||||
in eax, dx
|
||||
push eax
|
||||
; set up addressing to config data
|
||||
mov eax,ebx
|
||||
and al,0xfc ; make address dword-aligned
|
||||
out dx,eax
|
||||
; write DWORD of config data
|
||||
mov dl,0xfc
|
||||
and bl,3
|
||||
or dl,bl
|
||||
mov eax,ecx
|
||||
|
||||
or esi,esi
|
||||
jz pci_write_byte1
|
||||
cmp esi,1
|
||||
jz pci_write_word1
|
||||
cmp esi,2
|
||||
jz pci_write_dword1
|
||||
jmp pci_fin_write1
|
||||
|
||||
pci_write_byte1:
|
||||
out dx,al
|
||||
jmp pci_fin_write1
|
||||
pci_write_word1:
|
||||
out dx,ax
|
||||
jmp pci_fin_write1
|
||||
pci_write_dword1:
|
||||
out dx,eax
|
||||
jmp pci_fin_write1
|
||||
pci_fin_write1:
|
||||
|
||||
; restore configuration control
|
||||
pop eax
|
||||
mov dl,0xf8
|
||||
out dx,eax
|
||||
|
||||
xor eax,eax
|
||||
pop esi
|
||||
|
||||
ret
|
||||
pci_write_reg_2:
|
||||
|
||||
test bh,128 ;mech#2 only supports 16 devices per bus
|
||||
jnz pci_write_reg_err
|
||||
|
||||
|
||||
push esi ; save register size into ESI
|
||||
mov esi,eax
|
||||
and esi,3
|
||||
|
||||
push eax
|
||||
;store current state of config space
|
||||
mov dx,0xcf8
|
||||
in al,dx
|
||||
mov ah,al
|
||||
mov dl,0xfa
|
||||
in al,dx
|
||||
xchg eax,[esp]
|
||||
; out 0xcfa,bus
|
||||
mov al,ah
|
||||
out dx,al
|
||||
; out 0xcf8,0x80
|
||||
mov dl,0xf8
|
||||
mov al,0x80
|
||||
out dx,al
|
||||
; compute addr
|
||||
shr bh,3 ; func is ignored in mechanism 2
|
||||
or bh,0xc0
|
||||
mov dx,bx
|
||||
; write register
|
||||
mov eax,ecx
|
||||
|
||||
or esi,esi
|
||||
jz pci_write_byte2
|
||||
cmp esi,1
|
||||
jz pci_write_word2
|
||||
cmp esi,2
|
||||
jz pci_write_dword2
|
||||
jmp pci_fin_write2
|
||||
|
||||
pci_write_byte2:
|
||||
out dx,al
|
||||
jmp pci_fin_write2
|
||||
pci_write_word2:
|
||||
out dx,ax
|
||||
jmp pci_fin_write2
|
||||
pci_write_dword2:
|
||||
out dx,eax
|
||||
jmp pci_fin_write2
|
||||
pci_fin_write2:
|
||||
; restore configuration space
|
||||
pop eax
|
||||
mov dx,0xcfa
|
||||
out dx,al
|
||||
mov dl,0xf8
|
||||
mov al,ah
|
||||
out dx,al
|
||||
|
||||
xor eax,eax
|
||||
pop esi
|
||||
ret
|
||||
|
||||
pci_write_reg_err:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
ret
|
||||
|
||||
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
; VendID (2), DevID (2), Revision = 0 (1), Class Code (3), FNum (1), Bus (1)
|
||||
pci_emu_dat: times 30*10 db 0
|
||||
|
||||
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
align 4
|
||||
sys_pcibios:
|
||||
xchg ebx, eax
|
||||
xchg ecx, eax
|
||||
xchg edx, eax
|
||||
xchg esi, eax
|
||||
xchg edi, eax
|
||||
cmp [pci_access_enabled], 1
|
||||
jne .unsupported_func
|
||||
cmp [pci_bios_entry], 0
|
||||
jz .emulate_bios
|
||||
|
||||
push ds
|
||||
mov ax, pci_data_sel
|
||||
mov ds, ax
|
||||
mov eax, ebp
|
||||
mov ah, 0B1h
|
||||
call pword [cs:pci_bios_entry]
|
||||
pop ds
|
||||
|
||||
jmp .return
|
||||
;-=-=-=-=-=-=-=-=
|
||||
.emulate_bios:
|
||||
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]
|
||||
xor ah, ah
|
||||
jmp .return_abcd
|
||||
|
||||
.not_PCI_BIOS_PRESENT:
|
||||
cmp ebp, 2 ; FIND_PCI_DEVICE
|
||||
jne .not_FIND_PCI_DEVICE
|
||||
mov ebx, pci_emu_dat
|
||||
..nxt: cmp [ebx], dx
|
||||
jne ..no
|
||||
cmp [ebx + 2], cx
|
||||
jne ..no
|
||||
dec si
|
||||
jns ..no
|
||||
mov bx, [ebx + 4]
|
||||
xor ah, ah
|
||||
jmp .return_ab
|
||||
..no: cmp word[ebx], 0
|
||||
je ..dev_not_found
|
||||
add ebx, 10
|
||||
jmp ..nxt
|
||||
..dev_not_found:
|
||||
mov ah, 0x86 ; DEVICE_NOT_FOUND
|
||||
jmp .return_a
|
||||
|
||||
.not_FIND_PCI_DEVICE:
|
||||
cmp ebp, 3 ; FIND_PCI_CLASS_CODE
|
||||
jne .not_FIND_PCI_CLASS_CODE
|
||||
mov esi, pci_emu_dat
|
||||
shl ecx, 8
|
||||
..nxt2: cmp [esi], ecx
|
||||
jne ..no2
|
||||
mov bx, [esi]
|
||||
xor ah, ah
|
||||
jmp .return_ab
|
||||
..no2: cmp dword[esi], 0
|
||||
je ..dev_not_found
|
||||
add esi, 10
|
||||
jmp ..nxt2
|
||||
|
||||
.not_FIND_PCI_CLASS_CODE:
|
||||
cmp ebp, 8 ; READ_CONFIG_*
|
||||
jb .not_READ_CONFIG
|
||||
cmp ebp, 0x0A
|
||||
ja .not_READ_CONFIG
|
||||
mov eax, ebp
|
||||
mov ah, bh
|
||||
mov edx, edi
|
||||
mov bh, bl
|
||||
mov bl, dl
|
||||
call pci_read_reg
|
||||
mov ecx, eax
|
||||
xor ah, ah ; SUCCESSFUL
|
||||
jmp .return_abc
|
||||
.not_READ_CONFIG:
|
||||
cmp ebp, 0x0B ; WRITE_CONFIG_*
|
||||
jb .not_WRITE_CONFIG
|
||||
cmp ebp, 0x0D
|
||||
ja .not_WRITE_CONFIG
|
||||
lea eax, [ebp+1]
|
||||
mov ah, bh
|
||||
mov edx, edi
|
||||
mov bh, bl
|
||||
mov bl, dl
|
||||
call pci_write_reg
|
||||
xor ah, ah ; SUCCESSFUL
|
||||
jmp .return_abc
|
||||
.not_WRITE_CONFIG:
|
||||
.unsupported_func:
|
||||
mov ah, 0x81 ; FUNC_NOT_SUPPORTED
|
||||
.return:mov dword[esp + 8 ], edi
|
||||
mov dword[esp + 12], esi
|
||||
.return_abcd:
|
||||
mov dword[esp + 28], edx
|
||||
.return_abc:
|
||||
mov dword[esp + 32], ecx
|
||||
.return_ab:
|
||||
mov dword[esp + 24], ebx
|
||||
.return_a:
|
||||
mov dword[esp + 36], eax
|
||||
ret
|
690
kernel/branches/const.inc
Normal file
690
kernel/branches/const.inc
Normal file
@ -0,0 +1,690 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 983 $
|
||||
|
||||
|
||||
dpl0 equ 10010000b ; data read dpl0
|
||||
drw0 equ 10010010b ; data read/write dpl0
|
||||
drw3 equ 11110010b ; data read/write dpl3
|
||||
cpl0 equ 10011010b ; code read dpl0
|
||||
cpl3 equ 11111010b ; code read dpl3
|
||||
|
||||
D32 equ 01000000b ; 32bit segment
|
||||
G32 equ 10000000b ; page gran
|
||||
|
||||
|
||||
;;;;;;;;;;;;cpu_caps flags;;;;;;;;;;;;;;;;
|
||||
|
||||
CPU_386 equ 3
|
||||
CPU_486 equ 4
|
||||
CPU_PENTIUM equ 5
|
||||
CPU_P6 equ 6
|
||||
CPU_PENTIUM4 equ 0x0F
|
||||
|
||||
CAPS_FPU equ 00 ;on-chip x87 floating point unit
|
||||
CAPS_VME equ 01 ;virtual-mode enhancements
|
||||
CAPS_DE equ 02 ;debugging extensions
|
||||
CAPS_PSE equ 03 ;page-size extensions
|
||||
CAPS_TSC equ 04 ;time stamp counter
|
||||
CAPS_MSR equ 05 ;model-specific registers
|
||||
CAPS_PAE equ 06 ;physical-address extensions
|
||||
CAPS_MCE equ 07 ;machine check exception
|
||||
CAPS_CX8 equ 08 ;CMPXCHG8B instruction
|
||||
CAPS_APIC equ 09 ;on-chip advanced programmable
|
||||
; interrupt controller
|
||||
; 10 ;unused
|
||||
CAPS_SEP equ 11 ;SYSENTER and SYSEXIT instructions
|
||||
CAPS_MTRR equ 12 ;memory-type range registers
|
||||
CAPS_PGE equ 13 ;page global extension
|
||||
CAPS_MCA equ 14 ;machine check architecture
|
||||
CAPS_CMOV equ 15 ;conditional move instructions
|
||||
CAPS_PAT equ 16 ;page attribute table
|
||||
|
||||
CAPS_PSE36 equ 17 ;page-size extensions
|
||||
CAPS_PSN equ 18 ;processor serial number
|
||||
CAPS_CLFLUSH equ 19 ;CLFUSH instruction
|
||||
|
||||
CAPS_DS equ 21 ;debug store
|
||||
CAPS_ACPI equ 22 ;thermal monitor and software
|
||||
;controlled clock supported
|
||||
CAPS_MMX equ 23 ;MMX instructions
|
||||
CAPS_FXSR equ 24 ;FXSAVE and FXRSTOR instructions
|
||||
CAPS_SSE equ 25 ;SSE instructions
|
||||
CAPS_SSE2 equ 26 ;SSE2 instructions
|
||||
CAPS_SS equ 27 ;self-snoop
|
||||
CAPS_HTT equ 28 ;hyper-threading technology
|
||||
CAPS_TM equ 29 ;thermal monitor supported
|
||||
CAPS_IA64 equ 30 ;IA64 capabilities
|
||||
CAPS_PBE equ 31 ;pending break enable
|
||||
|
||||
;ecx
|
||||
CAPS_SSE3 equ 32 ;SSE3 instructions
|
||||
; 33
|
||||
; 34
|
||||
CAPS_MONITOR equ 35 ;MONITOR/MWAIT instructions
|
||||
CAPS_DS_CPL equ 36 ;
|
||||
CAPS_VMX equ 37 ;virtual mode extensions
|
||||
; 38 ;
|
||||
CAPS_EST equ 39 ;enhansed speed step
|
||||
CAPS_TM2 equ 40 ;thermal monitor2 supported
|
||||
; 41
|
||||
CAPS_CID equ 42 ;
|
||||
; 43
|
||||
; 44
|
||||
CAPS_CX16 equ 45 ;CMPXCHG16B instruction
|
||||
CAPS_xTPR equ 46 ;
|
||||
;
|
||||
;reserved
|
||||
;
|
||||
;ext edx /ecx
|
||||
CAPS_SYSCAL equ 64 ;
|
||||
CAPS_XD equ 65 ;execution disable
|
||||
CAPS_FFXSR equ 66 ;
|
||||
CAPS_RDTSCP equ 67 ;
|
||||
CAPS_X64 equ 68 ;
|
||||
CAPS_3DNOW equ 69 ;
|
||||
CAPS_3DNOWEXT equ 70 ;
|
||||
CAPS_LAHF equ 71 ;
|
||||
CAPS_CMP_LEG equ 72 ;
|
||||
CAPS_SVM equ 73 ;secure virual machine
|
||||
CAPS_ALTMOVCR8 equ 74 ;
|
||||
|
||||
; CPU MSR names
|
||||
MSR_SYSENTER_CS equ 0x174
|
||||
MSR_SYSENTER_ESP equ 0x175
|
||||
MSR_SYSENTER_EIP equ 0x176
|
||||
MSR_AMD_EFER equ 0xC0000080 ; Extended Feature Enable Register
|
||||
MSR_AMD_STAR equ 0xC0000081 ; SYSCALL/SYSRET Target Address Register
|
||||
|
||||
CR0_PE equ 0x00000001 ;protected mode
|
||||
CR0_MP equ 0x00000002 ;monitor fpu
|
||||
CR0_EM equ 0x00000004 ;fpu emulation
|
||||
CR0_TS equ 0x00000008 ;task switch
|
||||
CR0_ET equ 0x00000010 ;extension type hardcoded to 1
|
||||
CR0_NE equ 0x00000020 ;numeric error
|
||||
CR0_WP equ 0x00010000 ;write protect
|
||||
CR0_AM equ 0x00040000 ;alignment check
|
||||
CR0_NW equ 0x20000000 ;not write-through
|
||||
CR0_CD equ 0x40000000 ;cache disable
|
||||
CR0_PG equ 0x80000000 ;paging
|
||||
|
||||
|
||||
CR4_VME equ 0x0001
|
||||
CR4_PVI equ 0x0002
|
||||
CR4_TSD equ 0x0004
|
||||
CR4_DE equ 0x0008
|
||||
CR4_PSE equ 0x0010
|
||||
CR4_PAE equ 0x0020
|
||||
CR4_MCE equ 0x0040
|
||||
CR4_PGE equ 0x0080
|
||||
CR4_PCE equ 0x0100
|
||||
CR4_OSFXSR equ 0x0200
|
||||
CR4_OSXMMEXPT equ 0x0400
|
||||
|
||||
SSE_IE equ 0x0001
|
||||
SSE_DE equ 0x0002
|
||||
SSE_ZE equ 0x0004
|
||||
SSE_OE equ 0x0008
|
||||
SSE_UE equ 0x0010
|
||||
SSE_PE equ 0x0020
|
||||
SSE_DAZ equ 0x0040
|
||||
SSE_IM equ 0x0080
|
||||
SSE_DM equ 0x0100
|
||||
SSE_ZM equ 0x0200
|
||||
SSE_OM equ 0x0400
|
||||
SSE_UM equ 0x0800
|
||||
SSE_PM equ 0x1000
|
||||
SSE_FZ equ 0x8000
|
||||
|
||||
SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
|
||||
|
||||
|
||||
struc TSS
|
||||
{
|
||||
._back rw 2
|
||||
._esp0 rd 1
|
||||
._ss0 rw 2
|
||||
._esp1 rd 1
|
||||
._ss1 rw 2
|
||||
._esp2 rd 1
|
||||
._ss2 rw 2
|
||||
._cr3 rd 1
|
||||
._eip rd 1
|
||||
._eflags rd 1
|
||||
._eax rd 1
|
||||
._ecx rd 1
|
||||
._edx rd 1
|
||||
._ebx rd 1
|
||||
._esp rd 1
|
||||
._ebp rd 1
|
||||
._esi rd 1
|
||||
._edi rd 1
|
||||
._es rw 2
|
||||
._cs rw 2
|
||||
._ss rw 2
|
||||
._ds rw 2
|
||||
._fs rw 2
|
||||
._gs rw 2
|
||||
._ldt rw 2
|
||||
._trap rw 1
|
||||
._io rw 1
|
||||
rb 24
|
||||
._io_map_0 rb 4096
|
||||
._io_map_1 rb 4096
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
TSS TSS
|
||||
end virtual
|
||||
|
||||
TSS_SIZE equ (128+8192)
|
||||
|
||||
OS_BASE equ 0x80000000
|
||||
|
||||
window_data equ OS_BASE
|
||||
|
||||
CURRENT_TASK equ (OS_BASE+0x0003000)
|
||||
TASK_COUNT equ (OS_BASE+0x0003004)
|
||||
TASK_BASE equ (OS_BASE+0x0003010)
|
||||
TASK_DATA equ (OS_BASE+0x0003020)
|
||||
TASK_EVENT equ (OS_BASE+0x0003020)
|
||||
|
||||
mouseunder equ (OS_BASE+0x0006900)
|
||||
CDDataBuf equ (OS_BASE+0x0007000)
|
||||
FLOPPY_BUFF equ (OS_BASE+0x0008000)
|
||||
ACTIVE_PROC_STACK equ (OS_BASE+0x000A400) ;unused
|
||||
idts equ (OS_BASE+0x000B100)
|
||||
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)
|
||||
|
||||
;unused ? only one reference
|
||||
BANK_SWITCH equ (OS_BASE+0x000E030)
|
||||
|
||||
;unused ? store mousepointer
|
||||
MOUSE_PICTURE equ (OS_BASE+0x000F200)
|
||||
|
||||
MOUSE_VISIBLE equ (OS_BASE+0x000F204)
|
||||
WIN_TEMP_XY equ (OS_BASE+0x000F300)
|
||||
KEY_COUNT equ (OS_BASE+0x000F400)
|
||||
KEY_BUFF equ (OS_BASE+0x000F401)
|
||||
|
||||
BTN_COUNT equ (OS_BASE+0x000F500)
|
||||
BTN_BUFF equ (OS_BASE+0x000F501)
|
||||
|
||||
CPU_FREQ equ (OS_BASE+0x000F600)
|
||||
|
||||
;unused ? no active references
|
||||
MOUSE_PORT equ (OS_BASE+0x000F604)
|
||||
|
||||
;unused
|
||||
PS2_CHUNK equ (OS_BASE+0x000FB00)
|
||||
|
||||
MOUSE_SCROLL_H equ (OS_BASE+0x000FB08)
|
||||
MOUSE_X equ (OS_BASE+0x000FB0A)
|
||||
MOUSE_Y equ (OS_BASE+0x000FB0C)
|
||||
MOUSE_SCROLL_V equ (OS_BASE+0x000FB0E)
|
||||
|
||||
MOUSE_COLOR_MEM equ (OS_BASE+0x000FB10)
|
||||
COLOR_TEMP equ (OS_BASE+0x000FB30)
|
||||
BTN_DOWN equ (OS_BASE+0x000FB40)
|
||||
MOUSE_DOWN equ (OS_BASE+0x000FB44)
|
||||
X_UNDER equ (OS_BASE+0x000FB4A)
|
||||
Y_UNDER equ (OS_BASE+0x000FB4C)
|
||||
ScreenBPP equ (OS_BASE+0x000FBF1)
|
||||
|
||||
;unused ? only one reference
|
||||
MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF)
|
||||
|
||||
LFBAddress equ (OS_BASE+0x000FE80)
|
||||
MEM_AMOUNT equ (OS_BASE+0x000FE8C)
|
||||
|
||||
Screen_Max_X equ (OS_BASE+0x000FE00)
|
||||
Screen_Max_Y equ (OS_BASE+0x000FE04)
|
||||
BytesPerScanLine equ (OS_BASE+0x000FE08)
|
||||
SCR_MODE equ (OS_BASE+0x000FE0C)
|
||||
|
||||
BTN_ADDR equ (OS_BASE+0x000FE88)
|
||||
SYS_SHUTDOWN equ (OS_BASE+0x000FF00)
|
||||
TASK_ACTIVATE equ (OS_BASE+0x000FF01)
|
||||
|
||||
REDRAW_BACKGROUND equ (OS_BASE+0x000FFF0)
|
||||
BANK_RW equ (OS_BASE+0x000FFF2)
|
||||
MOUSE_BACKGROUND equ (OS_BASE+0x000FFF4)
|
||||
DONT_DRAW_MOUSE equ (OS_BASE+0x000FFF5)
|
||||
DONT_SWITCH equ (OS_BASE+0x000FFFF)
|
||||
|
||||
TMP_STACK_TOP equ 0x006CC00
|
||||
|
||||
FONT_II equ (OS_BASE+0x006DC00)
|
||||
FONT_I equ (OS_BASE+0x006E600)
|
||||
|
||||
sys_pgdir equ (OS_BASE+0x006F000)
|
||||
|
||||
DRIVE_DATA equ (OS_BASE+0x0070000)
|
||||
|
||||
SLOT_BASE equ (OS_BASE+0x0080000)
|
||||
|
||||
;unused
|
||||
TMP_BUFF equ (OS_BASE+0x0090000)
|
||||
|
||||
VGABasePtr equ (OS_BASE+0x00A0000)
|
||||
|
||||
RAMDISK equ (OS_BASE+0x0100000)
|
||||
RAMDISK_FAT equ (OS_BASE+0x0280000)
|
||||
FLOPPY_FAT equ (OS_BASE+0x0282000)
|
||||
|
||||
IDE_DMA equ 0x284000
|
||||
|
||||
BgrAuxTable equ (OS_BASE+0x0298000)
|
||||
; unused?
|
||||
SB16Buffer equ (OS_BASE+0x2A0000)
|
||||
SB16_Status equ (OS_BASE+0x02B0000)
|
||||
|
||||
BUTTON_INFO equ (OS_BASE+0x02C0000)
|
||||
RESERVED_PORTS equ (OS_BASE+0x02D0000)
|
||||
IRQ_SAVE equ (OS_BASE+0x02E0000)
|
||||
BOOT_VAR equ (OS_BASE+0x02f0000)
|
||||
|
||||
stack_data_start equ (OS_BASE+0x0300000)
|
||||
eth_data_start equ (OS_BASE+0x0300000)
|
||||
stack_data equ (OS_BASE+0x0304000)
|
||||
stack_data_end equ (OS_BASE+0x031ffff)
|
||||
resendQ equ (OS_BASE+0x0320000)
|
||||
VMODE_BASE equ (OS_BASE+0x0328000)
|
||||
skin_data equ (OS_BASE+0x0330000)
|
||||
draw_data equ (OS_BASE+0x0338000);
|
||||
|
||||
BgrDrawMode equ (OS_BASE+0x033BFF4)
|
||||
BgrDataWidth equ (OS_BASE+0x033BFF8)
|
||||
BgrDataHeight equ (OS_BASE+0x033BFFC)
|
||||
WinMapAddress equ (OS_BASE+0x033C000)
|
||||
display_data equ (OS_BASE+0x033C000) ;1024*1280=0x140000
|
||||
|
||||
virtual at (OS_BASE+0x047CF80)
|
||||
tss TSS
|
||||
end virtual
|
||||
|
||||
sys_pgmap equ (OS_BASE+0x047F000)
|
||||
|
||||
HEAP_BASE equ (OS_BASE+0x0800000)
|
||||
HEAP_MIN_SIZE equ 0x01000000
|
||||
|
||||
page_tabs equ 0xFDC00000
|
||||
app_page_tabs equ 0xFDC00000
|
||||
kernel_tabs equ (page_tabs+ (OS_BASE shr 10)) ;0xFDE00000
|
||||
master_tab equ (page_tabs+ (page_tabs shr 10)) ;0xFDFF70000
|
||||
|
||||
LFB_BASE equ 0xFE000000
|
||||
|
||||
|
||||
new_app_base equ 0;
|
||||
|
||||
twdw equ 0x3000 ;(CURRENT_TASK-window_data)
|
||||
|
||||
std_application_base_address equ new_app_base
|
||||
RING0_STACK_SIZE equ (0x2000 - 512) ;512 áàéò äëÿ êîíòåêñòà FPU
|
||||
|
||||
REG_SS equ (RING0_STACK_SIZE-4)
|
||||
REG_APP_ESP equ (RING0_STACK_SIZE-8)
|
||||
REG_EFLAGS equ (RING0_STACK_SIZE-12)
|
||||
REG_CS equ (RING0_STACK_SIZE-16)
|
||||
REG_EIP equ (RING0_STACK_SIZE-20)
|
||||
REG_EAX equ (RING0_STACK_SIZE-24)
|
||||
REG_ECX equ (RING0_STACK_SIZE-28)
|
||||
REG_EDX equ (RING0_STACK_SIZE-32)
|
||||
REG_EBX equ (RING0_STACK_SIZE-36)
|
||||
REG_ESP equ (RING0_STACK_SIZE-40) ;RING0_STACK_SIZE-20
|
||||
REG_EBP equ (RING0_STACK_SIZE-44)
|
||||
REG_ESI equ (RING0_STACK_SIZE-48)
|
||||
REG_EDI equ (RING0_STACK_SIZE-52)
|
||||
REG_RET equ (RING0_STACK_SIZE-56) ;irq0.return
|
||||
|
||||
|
||||
PG_UNMAP equ 0x000
|
||||
PG_MAP equ 0x001
|
||||
PG_WRITE equ 0x002
|
||||
PG_SW equ 0x003
|
||||
PG_USER equ 0x005
|
||||
PG_UW equ 0x007
|
||||
PG_NOCACHE equ 0x018
|
||||
PG_LARGE equ 0x080
|
||||
PG_GLOBAL equ 0x100
|
||||
|
||||
PG_SHARED equ 0x200
|
||||
|
||||
;;;;;;;;;;;boot time variables
|
||||
|
||||
;BOOT_BPP equ 0x9000 ;byte bits per pixel
|
||||
BOOT_SCANLINE equ 0x9001 ;word scanline length
|
||||
BOOT_VESA_MODE equ 0x9008 ;word vesa video mode
|
||||
;;BOOT_X_RES equ 0x900A ;word X res
|
||||
;;BOOT_Y_RES equ 0x900C ;word Y res
|
||||
;;BOOT_MOUSE_PORT equ 0x9010 ;byte mouse port - not used
|
||||
BOOT_BANK_SW equ 0x9014 ;dword Vesa 1.2 pm bank switch
|
||||
BOOT_LFB equ 0x9018 ;dword Vesa 2.0 LFB address
|
||||
BOOT_MTRR equ 0x901C ;byte 0 or 1 : enable MTRR graphics acceleration
|
||||
BOOT_LOG equ 0x901D ;byte not used anymore (0 or 1 : enable system log display)
|
||||
BOOT_DIRECT_LFB equ 0x901E ;byte 0 or 1 : enable direct lfb write, paging disabled
|
||||
BOOT_PCI_DATA equ 0x9020 ;8bytes pci data
|
||||
BOOT_VRR equ 0x9030 ;byte VRR start enabled 1, 2-no
|
||||
BOOT_IDE_BASE_ADDR equ 0x9031 ;word IDEContrRegsBaseAddr
|
||||
BOOT_MEM_AMOUNT equ 0x9034 ;dword memory amount
|
||||
|
||||
TMP_FILE_NAME equ 0
|
||||
TMP_CMD_LINE equ 1024
|
||||
TMP_ICON_OFFS equ 1280
|
||||
|
||||
|
||||
EVENT_REDRAW equ 0x00000001
|
||||
EVENT_KEY equ 0x00000002
|
||||
EVENT_BUTTON equ 0x00000004
|
||||
EVENT_BACKGROUND equ 0x00000010
|
||||
EVENT_MOUSE equ 0x00000020
|
||||
EVENT_IPC equ 0x00000040
|
||||
EVENT_NETWORK equ 0x00000080
|
||||
EVENT_DEBUG equ 0x00000100
|
||||
EVENT_EXTENDED equ 0x00000200
|
||||
|
||||
EV_INTR equ 1
|
||||
|
||||
struc THR_DATA
|
||||
{
|
||||
rb (8192-512)
|
||||
.pl0_stack:
|
||||
.fpu_state rb 512
|
||||
.tls_page rb 4096
|
||||
.pdbr rb 4096
|
||||
}
|
||||
|
||||
THR_DATA_SIZE equ 4096*4
|
||||
|
||||
virtual at (OS_BASE-THR_DATA_SIZE)
|
||||
thr_data THR_DATA
|
||||
end virtual
|
||||
|
||||
struc SYS_VARS
|
||||
{ .bpp dd ?
|
||||
.scanline dd ?
|
||||
.vesa_mode dd ?
|
||||
.x_res dd ?
|
||||
.y_res dd ?
|
||||
}
|
||||
|
||||
struc APPOBJ ;common object header
|
||||
{
|
||||
.magic dd ? ;
|
||||
.destroy dd ? ;internal destructor
|
||||
.fd dd ? ;next object in list
|
||||
.bk dd ? ;prev object in list
|
||||
.pid dd ? ;owner id
|
||||
};
|
||||
|
||||
virtual at 0
|
||||
APPOBJ APPOBJ
|
||||
end virtual
|
||||
|
||||
APP_OBJ_OFFSET equ 48
|
||||
APP_EV_OFFSET equ 40
|
||||
|
||||
struc CURSOR
|
||||
{;common object header
|
||||
.magic dd ? ;'CURS'
|
||||
.destroy dd ? ;internal destructor
|
||||
.fd dd ? ;next object in list
|
||||
.bk dd ? ;prev object in list
|
||||
.pid dd ? ;owner id
|
||||
|
||||
;cursor data
|
||||
.base dd ? ;allocated memory
|
||||
.hot_x dd ? ;hotspot coords
|
||||
.hot_y dd ?
|
||||
}
|
||||
virtual at 0
|
||||
CURSOR CURSOR
|
||||
end virtual
|
||||
|
||||
CURSOR_SIZE equ 32
|
||||
|
||||
struc EVENT
|
||||
{
|
||||
.magic dd ? ;'EVNT'
|
||||
.destroy dd ? ;internal destructor
|
||||
.fd dd ? ;next object in list
|
||||
.bk dd ? ;prev object in list
|
||||
.pid dd ? ;owner id
|
||||
|
||||
.id dd ? ;event uid
|
||||
.state dd ? ;internal flags
|
||||
.code dd ?
|
||||
rd 5
|
||||
}
|
||||
EVENT_SIZE equ 52
|
||||
|
||||
virtual at 0
|
||||
EVENT EVENT
|
||||
end virtual
|
||||
|
||||
|
||||
struc SMEM
|
||||
{
|
||||
.bk dd ?
|
||||
.fd dd ? ;+4
|
||||
.base dd ? ;+8
|
||||
.size dd ? ;+12
|
||||
.access dd ? ;+16
|
||||
.refcount dd ? ;+20
|
||||
.name rb 32 ;+24
|
||||
.sizeof:
|
||||
}
|
||||
|
||||
struc SMAP
|
||||
{
|
||||
.magic dd ? ; SMAP
|
||||
.destroy dd ? ;internal destructor
|
||||
.fd dd ? ;next object in list
|
||||
.bk dd ? ;prev object in list
|
||||
.pid dd ? ;owner id
|
||||
|
||||
.base dd ? ;mapped base
|
||||
.parent dd ? ;SMEM
|
||||
.sizeof:
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
SMEM SMEM
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
SMAP SMAP
|
||||
end virtual
|
||||
|
||||
|
||||
struc HEAP_DATA
|
||||
{
|
||||
.mutex rd 1
|
||||
.refcount rd 1
|
||||
.heap_base rd 1
|
||||
.heap_top rd 1
|
||||
.app_mem rd 1
|
||||
}
|
||||
|
||||
HEAP_DATA_SIZE equ 20
|
||||
virtual at 0
|
||||
HEAP_DATA HEAP_DATA
|
||||
end virtual
|
||||
|
||||
struc BOOT_DATA
|
||||
{ .bpp dd ?
|
||||
.scanline dd ?
|
||||
.vesa_mode dd ?
|
||||
.x_res dd ?
|
||||
.y_res dd ?
|
||||
.mouse_port dd ?
|
||||
.bank_switch dd ?
|
||||
.lfb dd ?
|
||||
.vesa_mem dd ?
|
||||
.log dd ?
|
||||
.direct_lfb dd ?
|
||||
.pci_data dd ?
|
||||
; dd ?
|
||||
.vrr dd ?
|
||||
.ide_base dd ?
|
||||
.mem_amount dd ?
|
||||
.pages_count dd ?
|
||||
.pagemap_size dd ?
|
||||
.kernel_max dd ?
|
||||
.kernel_pages dd ?
|
||||
.kernel_tables dd ?
|
||||
|
||||
.cpu_vendor dd ?
|
||||
dd ?
|
||||
dd ?
|
||||
.cpu_sign dd ?
|
||||
.cpu_info dd ?
|
||||
.cpu_caps dd ?
|
||||
dd ?
|
||||
dd ?
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
BOOT_DATA BOOT_DATA
|
||||
end virtual
|
||||
|
||||
struc MEM_STATE
|
||||
{ .mutex rd 1
|
||||
.smallmap rd 1
|
||||
.treemap rd 1
|
||||
.topsize rd 1
|
||||
.top rd 1
|
||||
.smallbins rd 4*32
|
||||
.treebins rd 32
|
||||
}
|
||||
|
||||
struc PG_DATA
|
||||
{ .mem_amount dd ?
|
||||
.vesa_mem dd ?
|
||||
.pages_count dd ?
|
||||
.pages_free dd ?
|
||||
.pages_faults dd ?
|
||||
.pagemap_size dd ?
|
||||
.kernel_pages dd ?
|
||||
.kernel_tables dd ?
|
||||
.sys_page_dir dd ?
|
||||
.pg_mutex dd ?
|
||||
}
|
||||
|
||||
;struc LIB
|
||||
;{ .lib_name rb 16
|
||||
; .lib_base dd ?
|
||||
; .lib_start dd ?
|
||||
; .export dd ?
|
||||
; .import dd ?
|
||||
;}
|
||||
|
||||
struc SRV
|
||||
{ .srv_name rb 16 ;ASCIIZ string
|
||||
.magic dd ? ;+0x10 ;'SRV '
|
||||
.size dd ? ;+0x14 ;size of structure SRV
|
||||
.fd dd ? ;+0x18 ;next SRV descriptor
|
||||
.bk dd ? ;+0x1C ;prev SRV descriptor
|
||||
.base dd ? ;+0x20 ;service base address
|
||||
.entry dd ? ;+0x24 ;service START function
|
||||
.srv_proc dd ? ;+0x28 ;main service handler
|
||||
}
|
||||
|
||||
SRV_FD_OFFSET equ 0x18
|
||||
SRV_SIZE equ 44
|
||||
|
||||
DRV_ENTRY equ 1
|
||||
DRV_EXIT equ -1
|
||||
|
||||
struc COFF_HEADER
|
||||
{ .machine dw ?
|
||||
.nSections dw ?
|
||||
.DataTime dd ?
|
||||
.pSymTable dd ?
|
||||
.nSymbols dd ?
|
||||
.optHeader dw ?
|
||||
.flags dw ?
|
||||
};
|
||||
|
||||
|
||||
struc COFF_SECTION
|
||||
{ .Name rb 8
|
||||
.VirtualSize dd ?
|
||||
.VirtualAddress dd ?
|
||||
.SizeOfRawData dd ?
|
||||
.PtrRawData dd ?
|
||||
.PtrReloc dd ?
|
||||
.PtrLinenumbers dd ?
|
||||
.NumReloc dw ?
|
||||
.NumLinenum dw ?
|
||||
.Characteristics dd ?
|
||||
}
|
||||
COFF_SECTION_SIZE equ 40
|
||||
|
||||
struc COFF_RELOC
|
||||
{ .VirtualAddress dd ?
|
||||
.SymIndex dd ?
|
||||
.Type dw ?
|
||||
}
|
||||
|
||||
struc COFF_SYM
|
||||
{ .Name rb 8
|
||||
.Value dd ?
|
||||
.SectionNumber dw ?
|
||||
.Type dw ?
|
||||
.StorageClass db ?
|
||||
.NumAuxSymbols db ?
|
||||
}
|
||||
CSYM_SIZE equ 18
|
||||
|
||||
struc IOCTL
|
||||
{ .handle dd ?
|
||||
.io_code dd ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
IOCTL IOCTL
|
||||
end virtual
|
||||
|
||||
;virtual at 0
|
||||
; LIB LIB
|
||||
;end virtual
|
||||
|
||||
virtual at 0
|
||||
SRV SRV
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
CFH COFF_HEADER
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
CFS COFF_SECTION
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
CRELOC COFF_RELOC
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
CSYM COFF_SYM
|
||||
end virtual
|
||||
|
242
kernel/branches/core/conf_lib.inc
Normal file
242
kernel/branches/core/conf_lib.inc
Normal file
@ -0,0 +1,242 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;-------------------------------------------------------------------------
|
||||
;Loading configuration from ini file
|
||||
; {SPraid.simba}
|
||||
;-------------------------------------------------------------------------
|
||||
|
||||
$Revision: 802 $
|
||||
|
||||
|
||||
conf_path_sect: db 'path',0
|
||||
|
||||
conf_fname db '/sys/sys.conf',0
|
||||
|
||||
; set soke kernel configuration
|
||||
proc set_kernel_conf
|
||||
locals
|
||||
par db 30 dup(?)
|
||||
endl
|
||||
|
||||
pushad
|
||||
;[gui]
|
||||
;mouse_speed
|
||||
|
||||
lea eax,[par]
|
||||
push eax
|
||||
invoke ini.get_str,conf_fname, ugui, ugui_mouse_speed,\
|
||||
eax,30, ugui_mouse_speed_def
|
||||
pop eax
|
||||
stdcall strtoint,eax
|
||||
mov [mouse_speed_factor], ax
|
||||
|
||||
;mouse_delay
|
||||
lea eax,[par]
|
||||
push eax
|
||||
invoke ini.get_str,conf_fname, ugui, ugui_mouse_delay,\
|
||||
eax,30, ugui_mouse_delay_def
|
||||
pop eax
|
||||
stdcall strtoint,eax
|
||||
mov [mouse_delay], eax
|
||||
|
||||
|
||||
;midibase
|
||||
lea eax,[par]
|
||||
push eax
|
||||
invoke ini.get_str,conf_fname, udev, udev_midibase, eax,30, udev_midibase_def
|
||||
pop eax
|
||||
stdcall strtoint,eax
|
||||
|
||||
cmp eax, 0x100
|
||||
jb @f
|
||||
cmp eax, 0x10000
|
||||
jae @f
|
||||
mov [midi_base], ax
|
||||
mov [mididp], eax
|
||||
inc eax
|
||||
mov [midisp], eax
|
||||
@@:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
ugui db 'gui',0
|
||||
ugui_mouse_speed db 'mouse_speed',0
|
||||
ugui_mouse_speed_def db '2',0
|
||||
ugui_mouse_delay db 'mouse_delay',0
|
||||
ugui_mouse_delay_def db '0x00A',0
|
||||
|
||||
udev db 'dev',0
|
||||
udev_midibase db 'midibase',0
|
||||
udev_midibase_def db '0x320',0
|
||||
|
||||
|
||||
; convert string to DWord
|
||||
proc strtoint stdcall,strs
|
||||
pushad
|
||||
|
||||
mov eax,[strs]
|
||||
inc eax
|
||||
mov bl,[eax]
|
||||
cmp bl,'x'
|
||||
je .hex
|
||||
cmp bl,'X'
|
||||
je .hex
|
||||
jmp .dec
|
||||
.hex:
|
||||
inc eax
|
||||
stdcall strtoint_hex,eax
|
||||
jmp .exit
|
||||
.dec:
|
||||
dec eax
|
||||
stdcall strtoint_dec,eax
|
||||
.exit:
|
||||
mov [esp+28],eax
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; convert string to DWord for decimal value
|
||||
proc strtoint_dec stdcall,strs
|
||||
pushad
|
||||
xor edx,edx
|
||||
; ¯®¨áª ª®æ
|
||||
mov esi,[strs]
|
||||
@@:
|
||||
lodsb
|
||||
or al,al
|
||||
jnz @b
|
||||
mov ebx,esi
|
||||
mov esi,[strs]
|
||||
dec ebx
|
||||
sub ebx,esi
|
||||
mov ecx,1
|
||||
|
||||
@@:
|
||||
dec ebx
|
||||
or ebx,ebx
|
||||
jz @f
|
||||
imul ecx,ecx,10 ; ¯®à冷ª
|
||||
jmp @b
|
||||
@@:
|
||||
|
||||
xchg ebx,ecx
|
||||
|
||||
|
||||
xor ecx,ecx
|
||||
|
||||
|
||||
@@:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
cmp al,0
|
||||
je .eend
|
||||
|
||||
sub al,30h
|
||||
imul ebx
|
||||
add ecx,eax
|
||||
push ecx
|
||||
xchg eax,ebx
|
||||
mov ecx,10
|
||||
div ecx
|
||||
xchg eax,ebx
|
||||
pop ecx
|
||||
jmp @b
|
||||
|
||||
.eend:
|
||||
mov [esp+28],ecx
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
;convert string to DWord for hex value
|
||||
proc strtoint_hex stdcall,strs
|
||||
pushad
|
||||
xor edx,edx
|
||||
|
||||
mov esi,[strs]
|
||||
mov ebx,1
|
||||
add esi,1
|
||||
|
||||
@@:
|
||||
lodsb
|
||||
or al,al
|
||||
jz @f
|
||||
shl ebx,4
|
||||
jmp @b
|
||||
@@:
|
||||
xor ecx,ecx
|
||||
mov esi,[strs]
|
||||
|
||||
@@:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
cmp al,0
|
||||
je .eend
|
||||
|
||||
cmp al,'a'
|
||||
jae .bm
|
||||
cmp al,'A'
|
||||
jae .bb
|
||||
jmp .cc
|
||||
.bm: ; 57h
|
||||
sub al,57h
|
||||
jmp .do
|
||||
|
||||
.bb: ; 37h
|
||||
sub al,37h
|
||||
jmp .do
|
||||
|
||||
.cc: ; 30h
|
||||
sub al,30h
|
||||
|
||||
.do:
|
||||
imul ebx
|
||||
add ecx,eax
|
||||
shr ebx,4
|
||||
|
||||
jmp @b
|
||||
|
||||
.eend:
|
||||
mov [esp+28],ecx
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
; convert string to DWord for IP addres
|
||||
proc do_inet_adr stdcall,strs
|
||||
pushad
|
||||
|
||||
mov esi,[strs]
|
||||
mov ebx,0
|
||||
.next:
|
||||
push esi
|
||||
@@:
|
||||
lodsb
|
||||
or al,al
|
||||
jz @f
|
||||
cmp al,'.'
|
||||
jz @f
|
||||
jmp @b
|
||||
@@:
|
||||
mov cl, al
|
||||
mov [esi-1],byte 0
|
||||
;pop eax
|
||||
call strtoint_dec
|
||||
rol eax,24
|
||||
ror ebx,8
|
||||
add ebx,eax
|
||||
or cl,cl
|
||||
jz @f
|
||||
jmp .next
|
||||
@@:
|
||||
mov [esp+28],ebx
|
||||
popad
|
||||
ret
|
||||
endp
|
475
kernel/branches/core/debug.inc
Normal file
475
kernel/branches/core/debug.inc
Normal file
@ -0,0 +1,475 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
; diamond, 2006
|
||||
sys_debug_services:
|
||||
cmp eax, 9
|
||||
ja @f
|
||||
jmp dword [sys_debug_services_table+eax*4]
|
||||
@@: ret
|
||||
sys_debug_services_table:
|
||||
dd debug_set_event_data
|
||||
dd debug_getcontext
|
||||
dd debug_setcontext
|
||||
dd debug_detach
|
||||
dd debug_suspend
|
||||
dd debug_resume
|
||||
dd debug_read_process_memory
|
||||
dd debug_write_process_memory
|
||||
dd debug_terminate
|
||||
dd debug_set_drx
|
||||
|
||||
debug_set_event_data:
|
||||
; in: ebx = pointer
|
||||
; destroys eax
|
||||
mov eax, [current_slot]
|
||||
mov [eax+APPDATA.dbg_event_mem], ebx
|
||||
ret
|
||||
|
||||
get_debuggee_slot:
|
||||
; in: ebx=PID
|
||||
; out: CF=1 if error
|
||||
; CF=0 and eax=slot*0x20 if ok
|
||||
; out: interrupts disabled
|
||||
cli
|
||||
mov eax, ebx
|
||||
call pid_to_slot
|
||||
test eax, eax
|
||||
jz .ret_bad
|
||||
shl eax, 5
|
||||
push ebx
|
||||
mov ebx, [CURRENT_TASK]
|
||||
cmp [SLOT_BASE+eax*8+APPDATA.debugger_slot], ebx
|
||||
pop ebx
|
||||
jnz .ret_bad
|
||||
; clc ; automatically
|
||||
ret
|
||||
.ret_bad:
|
||||
stc
|
||||
ret
|
||||
|
||||
debug_detach:
|
||||
; in: ebx=pid
|
||||
; destroys eax,ebx
|
||||
call get_debuggee_slot
|
||||
jc .ret
|
||||
and dword [eax*8+SLOT_BASE+APPDATA.debugger_slot], 0
|
||||
call do_resume
|
||||
.ret:
|
||||
sti
|
||||
ret
|
||||
|
||||
debug_terminate:
|
||||
; in: ebx=pid
|
||||
call get_debuggee_slot
|
||||
jc debug_detach.ret
|
||||
mov ecx, eax
|
||||
shr ecx, 5
|
||||
push 2
|
||||
pop ebx
|
||||
jmp sys_system
|
||||
|
||||
debug_suspend:
|
||||
; in: ebx=pid
|
||||
; destroys eax,ebx
|
||||
cli
|
||||
mov eax, ebx
|
||||
call pid_to_slot
|
||||
shl eax, 5
|
||||
jz .ret
|
||||
mov bl, [CURRENT_TASK+eax+TASKDATA.state] ; process state
|
||||
test bl, bl
|
||||
jz .1
|
||||
cmp bl, 5
|
||||
jnz .ret
|
||||
mov bl, 2
|
||||
.2: mov [CURRENT_TASK+eax+TASKDATA.state], bl
|
||||
.ret:
|
||||
sti
|
||||
ret
|
||||
.1:
|
||||
inc ebx
|
||||
jmp .2
|
||||
|
||||
do_resume:
|
||||
mov bl, [CURRENT_TASK+eax+TASKDATA.state]
|
||||
cmp bl, 1
|
||||
jz .1
|
||||
cmp bl, 2
|
||||
jnz .ret
|
||||
mov bl, 5
|
||||
.2: mov [CURRENT_TASK+eax+TASKDATA.state], bl
|
||||
.ret: ret
|
||||
.1: dec ebx
|
||||
jmp .2
|
||||
|
||||
debug_resume:
|
||||
; in: ebx=pid
|
||||
; destroys eax,ebx
|
||||
cli
|
||||
mov eax, ebx
|
||||
call pid_to_slot
|
||||
shl eax, 5
|
||||
jz .ret
|
||||
call do_resume
|
||||
.ret: sti
|
||||
ret
|
||||
|
||||
debug_getcontext:
|
||||
; in:
|
||||
; ebx=pid
|
||||
; ecx=sizeof(CONTEXT)
|
||||
; edx->CONTEXT
|
||||
; destroys eax,ecx,edx,esi,edi
|
||||
cmp ecx, 28h
|
||||
jnz .ret
|
||||
push ebx
|
||||
mov ebx, edx
|
||||
call check_region
|
||||
pop ebx
|
||||
dec eax
|
||||
jnz .ret
|
||||
call get_debuggee_slot
|
||||
jc .ret
|
||||
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
|
||||
lea esi, [eax+RING0_STACK_SIZE]
|
||||
mov edi, edx
|
||||
.ring0:
|
||||
; note that following code assumes that all interrupt/exception handlers
|
||||
; saves ring-3 context by pushad in this order
|
||||
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad
|
||||
sub esi, 8+12+20h
|
||||
lodsd ;edi
|
||||
mov [edi+24h], eax
|
||||
lodsd ;esi
|
||||
mov [edi+20h], eax
|
||||
lodsd ; ebp
|
||||
mov [edi+1Ch], eax
|
||||
lodsd ;esp
|
||||
lodsd ;ebx
|
||||
mov [edi+14h], eax
|
||||
lodsd ;edx
|
||||
mov [edi+10h], eax
|
||||
lodsd ;ecx
|
||||
mov [edi+0Ch], eax
|
||||
lodsd ;eax
|
||||
mov [edi+8], eax
|
||||
lodsd ;eip
|
||||
mov [edi], eax
|
||||
lodsd ;cs
|
||||
lodsd ;eflags
|
||||
mov [edi+4], eax
|
||||
lodsd ;esp
|
||||
mov [edi+18h], eax
|
||||
.ret:
|
||||
sti
|
||||
ret
|
||||
|
||||
debug_setcontext:
|
||||
; in:
|
||||
; ebx=pid
|
||||
; ecx=sizeof(CONTEXT)
|
||||
; edx->CONTEXT
|
||||
; destroys eax,ecx,edx,esi,edi
|
||||
cmp ecx, 28h
|
||||
jnz .ret
|
||||
push ebx
|
||||
mov ebx, edx
|
||||
call check_region
|
||||
pop ebx
|
||||
dec eax
|
||||
jnz .ret
|
||||
call get_debuggee_slot
|
||||
jc .stiret
|
||||
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
|
||||
lea edi, [eax+RING0_STACK_SIZE]
|
||||
mov esi, edx
|
||||
.ring0:
|
||||
sub edi, 8+12+20h
|
||||
mov eax, [esi+24h] ;edi
|
||||
stosd
|
||||
mov eax, [esi+20h] ;esi
|
||||
stosd
|
||||
mov eax, [esi+1Ch] ;ebp
|
||||
stosd
|
||||
scasd
|
||||
mov eax, [esi+14h] ;ebx
|
||||
stosd
|
||||
mov eax, [esi+10h] ;edx
|
||||
stosd
|
||||
mov eax, [esi+0Ch] ;ecx
|
||||
stosd
|
||||
mov eax, [esi+8] ;eax
|
||||
stosd
|
||||
mov eax, [esi] ;eip
|
||||
stosd
|
||||
scasd
|
||||
mov eax, [esi+4] ;eflags
|
||||
stosd
|
||||
mov eax, [esi+18h] ;esp
|
||||
stosd
|
||||
.stiret:
|
||||
sti
|
||||
.ret:
|
||||
ret
|
||||
|
||||
debug_set_drx:
|
||||
call get_debuggee_slot
|
||||
jc .errret
|
||||
mov ebp, eax
|
||||
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs]
|
||||
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
|
||||
; [eax+10]=dr7
|
||||
cmp edx, OS_BASE
|
||||
jae .errret
|
||||
cmp cl, 3
|
||||
ja .errret
|
||||
mov ebx, dr7
|
||||
shr ebx, cl
|
||||
shr ebx, cl
|
||||
test ebx, 2 ; bit 1+2*index = G0..G3, global break enable
|
||||
jnz .errret2
|
||||
test ch, ch
|
||||
jns .new
|
||||
; clear breakpoint
|
||||
movzx ecx, cl
|
||||
add ecx, ecx
|
||||
and dword [eax+ecx*2], 0 ; clear DR<i>
|
||||
btr dword [eax+10h], ecx ; clear L<i> bit
|
||||
test byte [eax+10h], 55h
|
||||
jnz .okret
|
||||
; imul eax, ebp, tss_step/32
|
||||
; and byte [eax + tss_data + TSS._trap], not 1
|
||||
and [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1
|
||||
.okret:
|
||||
and dword [esp+36], 0
|
||||
sti
|
||||
ret
|
||||
.errret:
|
||||
sti
|
||||
mov dword [esp+36], 1
|
||||
ret
|
||||
.errret2:
|
||||
sti
|
||||
mov dword [esp+36], 2
|
||||
ret
|
||||
.new:
|
||||
; add new breakpoint
|
||||
; cl=index; ch=flags; edx=address
|
||||
test ch, 0xF0
|
||||
jnz .errret
|
||||
mov bl, ch
|
||||
and bl, 3
|
||||
cmp bl, 2
|
||||
jz .errret
|
||||
mov bl, ch
|
||||
shr bl, 2
|
||||
cmp bl, 2
|
||||
jz .errret
|
||||
test dl, bl
|
||||
jnz .errret
|
||||
or byte [eax+10h+1], 3 ; set GE and LE flags
|
||||
movzx ebx, ch
|
||||
movzx ecx, cl
|
||||
add ecx, ecx
|
||||
bts dword [eax+10h], ecx ; set L<i> flag
|
||||
add ecx, ecx
|
||||
mov [eax+ecx], edx ; set DR<i>
|
||||
shl ebx, cl
|
||||
mov edx, 0xF
|
||||
shl edx, cl
|
||||
not edx
|
||||
and [eax+10h+2], dx
|
||||
or [eax+10h+2], bx ; set R/W and LEN fields
|
||||
; imul eax, ebp, tss_step/32
|
||||
; or byte [eax + tss_data + TSS._trap], 1
|
||||
or [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1
|
||||
jmp .okret
|
||||
|
||||
debug_read_process_memory:
|
||||
; in:
|
||||
; ebx=pid
|
||||
; ecx=length
|
||||
; esi->buffer in debugger
|
||||
; edx=address in debuggee
|
||||
; out: [esp+36]=sizeof(read)
|
||||
; destroys all
|
||||
push ebx
|
||||
mov ebx, esi
|
||||
call check_region
|
||||
pop ebx
|
||||
dec eax
|
||||
jnz .err
|
||||
call get_debuggee_slot
|
||||
jc .err
|
||||
shr eax, 5
|
||||
mov ebx, esi
|
||||
call read_process_memory
|
||||
sti
|
||||
mov dword [esp+36], eax
|
||||
ret
|
||||
.err:
|
||||
or dword [esp+36], -1
|
||||
ret
|
||||
|
||||
debug_write_process_memory:
|
||||
; in:
|
||||
; ebx=pid
|
||||
; ecx=length
|
||||
; esi->buffer in debugger
|
||||
; edx=address in debuggee
|
||||
; out: [esp+36]=sizeof(write)
|
||||
; destroys all
|
||||
push ebx
|
||||
mov ebx, esi
|
||||
call check_region
|
||||
pop ebx
|
||||
dec eax
|
||||
jnz debug_read_process_memory.err
|
||||
call get_debuggee_slot
|
||||
jc debug_read_process_memory.err
|
||||
shr eax, 5
|
||||
mov ebx, esi
|
||||
call write_process_memory
|
||||
sti
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
|
||||
debugger_notify:
|
||||
; in: eax=debugger slot
|
||||
; ecx=size of debug message
|
||||
; [esp+4]..[esp+4+ecx]=message
|
||||
; interrupts must be disabled!
|
||||
; destroys all general registers
|
||||
; interrupts remain disabled
|
||||
xchg ebp, eax
|
||||
mov edi, [timer_ticks]
|
||||
add edi, 500 ; 5 sec timeout
|
||||
.1:
|
||||
mov eax, ebp
|
||||
shl eax, 8
|
||||
mov edx, [SLOT_BASE+eax+APPDATA.dbg_event_mem]
|
||||
test edx, edx
|
||||
jz .ret
|
||||
; read buffer header
|
||||
push ecx
|
||||
push eax
|
||||
push eax
|
||||
mov eax, ebp
|
||||
mov ebx, esp
|
||||
mov ecx, 8
|
||||
call read_process_memory
|
||||
cmp eax, ecx
|
||||
jz @f
|
||||
add esp, 12
|
||||
jmp .ret
|
||||
@@:
|
||||
cmp dword [ebx], 0
|
||||
jg @f
|
||||
.2:
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
cmp dword [CURRENT_TASK], 1
|
||||
jnz .notos
|
||||
cmp [timer_ticks], edi
|
||||
jae .ret
|
||||
.notos:
|
||||
sti
|
||||
call change_task
|
||||
cli
|
||||
jmp .1
|
||||
@@:
|
||||
mov ecx, [ebx+8]
|
||||
add ecx, [ebx+4]
|
||||
cmp ecx, [ebx]
|
||||
ja .2
|
||||
; advance buffer position
|
||||
push ecx
|
||||
mov ecx, 4
|
||||
sub ebx, ecx
|
||||
mov eax, ebp
|
||||
add edx, ecx
|
||||
call write_process_memory
|
||||
pop eax
|
||||
; write message
|
||||
mov eax, ebp
|
||||
add edx, ecx
|
||||
add edx, [ebx+8]
|
||||
add ebx, 20
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
call write_process_memory
|
||||
; new debug event
|
||||
mov eax, ebp
|
||||
shl eax, 8
|
||||
or byte [SLOT_BASE+eax+APPDATA.event_mask+1], 1 ; set flag 100h
|
||||
.ret:
|
||||
ret
|
||||
|
||||
debug_exc:
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_debug_exc
|
||||
; int 1 = #DB
|
||||
save_ring3_context
|
||||
cld
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov eax, dr6
|
||||
push eax
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
; test if debugging
|
||||
cli
|
||||
mov eax, [current_slot]
|
||||
mov eax, [eax+APPDATA.debugger_slot]
|
||||
test eax, eax
|
||||
jnz .debug
|
||||
sti
|
||||
; not debuggee => say error and terminate
|
||||
add esp, 0x20+4
|
||||
mov [error_interrupt], 1
|
||||
call show_error_parameters
|
||||
mov edx, [TASK_BASE]
|
||||
mov byte [edx+TASKDATA.state], 4
|
||||
jmp change_task
|
||||
.debug:
|
||||
; we are debugged process, notify debugger and suspend ourself
|
||||
; eax=debugger PID
|
||||
pop edx
|
||||
mov ebx, dr7
|
||||
mov cl, not 1
|
||||
.l1:
|
||||
test bl, 1
|
||||
jnz @f
|
||||
and dl, cl
|
||||
@@:
|
||||
shr ebx, 2
|
||||
add cl, cl
|
||||
inc ecx
|
||||
cmp cl, not 10h
|
||||
jnz .l1
|
||||
push edx ; DR6 image
|
||||
mov ecx, [TASK_BASE]
|
||||
push dword [ecx+TASKDATA.pid] ; PID
|
||||
push 12
|
||||
pop ecx
|
||||
push 3 ; 3 = debug exception
|
||||
call debugger_notify
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
mov edx, [TASK_BASE]
|
||||
mov byte [edx+TASKDATA.state], 1 ; suspended
|
||||
call change_task
|
||||
restore_ring3_context
|
||||
iretd
|
1229
kernel/branches/core/dll.inc
Normal file
1229
kernel/branches/core/dll.inc
Normal file
File diff suppressed because it is too large
Load Diff
39
kernel/branches/core/export.inc
Normal file
39
kernel/branches/core/export.inc
Normal file
@ -0,0 +1,39 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
; Macroinstruction for making export section
|
||||
|
||||
|
||||
macro export dllname,[label,string]
|
||||
{ common
|
||||
local module,addresses,names,ordinal,count
|
||||
count = 0
|
||||
forward
|
||||
count = count+1
|
||||
common
|
||||
dd 0,0,0, (module-OS_BASE) , 1
|
||||
dd count,count,(addresses-OS_BASE),(names-OS_BASE),(ordinal-OS_BASE)
|
||||
addresses:
|
||||
forward
|
||||
dd (label-OS_BASE)
|
||||
common
|
||||
names:
|
||||
forward
|
||||
local name
|
||||
dd (name-OS_BASE)
|
||||
common
|
||||
ordinal: count = 0
|
||||
forward
|
||||
dw count
|
||||
count = count+1
|
||||
common
|
||||
module db dllname,0
|
||||
forward
|
||||
name db string,0
|
||||
}
|
173
kernel/branches/core/exports.inc
Normal file
173
kernel/branches/core/exports.inc
Normal file
@ -0,0 +1,173 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 924 $
|
||||
|
||||
|
||||
iglobal
|
||||
szKernel db 'KERNEL', 0
|
||||
szVersion db 'version',0
|
||||
|
||||
szRegService db 'RegService',0
|
||||
szGetService db 'GetService',0
|
||||
szServiceHandler db 'ServiceHandler',0
|
||||
szAttachIntHandler db 'AttachIntHandler',0
|
||||
szGetIntHandler db 'GetIntHandler', 0
|
||||
szFpuSave db 'FpuSave',0
|
||||
szFpuRestore db 'FpuRestore',0
|
||||
szReservePortArea db 'ReservePortArea',0
|
||||
szBoot_Log db 'Boot_Log',0
|
||||
|
||||
szPciApi db 'PciApi', 0
|
||||
szPciRead32 db 'PciRead32', 0
|
||||
szPciRead16 db 'PciRead16', 0
|
||||
szPciRead8 db 'PciRead8', 0
|
||||
szPciWrite8 db 'PciWrite8',0
|
||||
szPciWrite16 db 'PciWrite16',0
|
||||
szPciWrite32 db 'PciWrite32',0
|
||||
|
||||
szAllocPage db 'AllocPage',0
|
||||
szAllocPages db 'AllocPages',0
|
||||
szFreePage db 'FreePage',0
|
||||
szGetPgAddr db 'GetPgAddr',0
|
||||
szMapPage db 'MapPage',0
|
||||
szMapSpace db 'MapSpace',0
|
||||
szMapIoMem db 'MapIoMem',0
|
||||
szCommitPages db 'CommitPages',0
|
||||
szReleasePages db 'ReleasePages',0
|
||||
|
||||
szAllocKernelSpace db 'AllocKernelSpace',0
|
||||
szFreeKernelSpace db 'FreeKernelSpace',0
|
||||
szKernelAlloc db 'KernelAlloc',0
|
||||
szKernelFree db 'KernelFree',0
|
||||
szUserAlloc db 'UserAlloc',0
|
||||
szUserFree db 'UserFree',0
|
||||
szKmalloc db 'Kmalloc',0
|
||||
szKfree db 'Kfree',0
|
||||
szCreateRingBuffer db 'CreateRingBuffer',0
|
||||
|
||||
szGetPid db 'GetPid',0
|
||||
szCreateObject db 'CreateObject',0
|
||||
szDestroyObject db 'DestroyObject',0
|
||||
szCreateEvent db 'CreateEvent',0
|
||||
szRaiseEvent db 'RaiseEvent',0
|
||||
szWaitEvent db 'WaitEvent',0
|
||||
szDestroyEvent db 'DestroyEvent',0
|
||||
szClearEvent db 'ClearEvent',0
|
||||
|
||||
szLoadCursor db 'LoadCursor',0
|
||||
szSelectHwCursor db 'SelectHwCursor',0
|
||||
szSetHwCursor db 'SetHwCursor',0
|
||||
szHwCursorRestore db 'HwCursorRestore', 0
|
||||
szHwCursorCreate db 'HwCursorCreate', 0
|
||||
|
||||
szSysMsgBoardStr db 'SysMsgBoardStr', 0
|
||||
szSysMsgBoardChar db 'SysMsgBoardChar', 0
|
||||
szGetCurrentTask db 'GetCurrentTask',0
|
||||
szLFBAddress db 'LFBAddress',0
|
||||
szLoadFile db 'LoadFile',0
|
||||
szSendEvent db 'SendEvent',0
|
||||
szSetMouseData db 'SetMouseData',0
|
||||
szSleep db 'Sleep',0
|
||||
szGetTimerTicks db 'GetTimerTicks',0
|
||||
|
||||
szStrncat db 'strncat',0
|
||||
szStrncpy db 'strncpy',0
|
||||
szstrncmp db 'strncmp',0
|
||||
szStrnlen db 'strnlen',0
|
||||
szStrchr db 'strchr',0
|
||||
szStrrchr db 'strrchr',0
|
||||
|
||||
szEthReceiver db 'EthReceiver',0
|
||||
szEthRegDev db 'EthRegDev',0
|
||||
szEthUnRegDev db 'EthUnRegDev',0
|
||||
szEthStruc2Dev db 'EthStruc2Dev',0
|
||||
|
||||
|
||||
align 16
|
||||
kernel_export:
|
||||
dd szRegService , reg_service
|
||||
dd szGetService , get_service
|
||||
dd szServiceHandler , srv_handler
|
||||
dd szAttachIntHandler, attach_int_handler
|
||||
dd szGetIntHandler , get_int_handler
|
||||
dd szFpuSave , fpu_save
|
||||
dd szFpuRestore , fpu_restore
|
||||
dd szReservePortArea , r_f_port_area
|
||||
dd szBoot_Log , boot_log
|
||||
|
||||
dd szPciApi , pci_api
|
||||
dd szPciRead32 , pci_read32
|
||||
dd szPciRead16 , pci_read16
|
||||
dd szPciRead8 , pci_read8
|
||||
dd szPciWrite8 , pci_write8
|
||||
dd szPciWrite16 , pci_write16
|
||||
dd szPciWrite32 , pci_write32
|
||||
|
||||
dd szAllocPage , alloc_page ;stdcall
|
||||
dd szAllocPages , alloc_pages ;stdcall
|
||||
dd szFreePage , free_page
|
||||
dd szMapPage , map_page ;stdcall
|
||||
dd szMapSpace , map_space
|
||||
dd szMapIoMem , map_io_mem ;stdcall
|
||||
dd szGetPgAddr , get_pg_addr
|
||||
dd szCommitPages , commit_pages ;not implemented
|
||||
dd szReleasePages , release_pages
|
||||
|
||||
dd szAllocKernelSpace, alloc_kernel_space ;stdcall
|
||||
dd szFreeKernelSpace , free_kernel_space ;stdcall
|
||||
dd szKernelAlloc , kernel_alloc ;stdcall
|
||||
dd szKernelFree , kernel_free ;stdcall
|
||||
dd szUserAlloc , user_alloc ;stdcall
|
||||
dd szUserFree , user_free ;stdcall
|
||||
dd szKmalloc , malloc
|
||||
dd szKfree , free
|
||||
dd szCreateRingBuffer, create_ring_buffer ;stdcall
|
||||
|
||||
dd szGetPid , get_pid
|
||||
dd szCreateObject , create_kernel_object
|
||||
dd szDestroyObject , destroy_kernel_object
|
||||
dd szCreateEvent , create_event
|
||||
dd szRaiseEvent , raise_event
|
||||
dd szWaitEvent , wait_event
|
||||
dd szDestroyEvent , destroy_event
|
||||
dd szClearEvent , clear_event
|
||||
|
||||
dd szLoadCursor , load_cursor ;stdcall
|
||||
|
||||
dd szSelectHwCursor , select_hw_cursor ;import stdcall
|
||||
dd szSetHwCursor , set_hw_cursor ;import stdcall
|
||||
dd szHwCursorRestore , hw_restore ;import
|
||||
dd szHwCursorCreate , create_cursor ;import
|
||||
|
||||
dd szSysMsgBoardStr , sys_msg_board_str
|
||||
dd szSysMsgBoardChar , sys_msg_board
|
||||
dd szGetCurrentTask , get_curr_task
|
||||
dd szLoadFile , load_file ;retval eax, ebx
|
||||
dd szSendEvent , send_event
|
||||
dd szSetMouseData , set_mouse_data ;stdcall
|
||||
dd szSleep , delay_ms
|
||||
dd szGetTimerTicks , get_timer_ticks
|
||||
|
||||
dd szStrncat , strncat
|
||||
dd szStrncpy , strncpy
|
||||
dd szstrncmp , strncmp
|
||||
dd szStrnlen , strnlen
|
||||
dd szStrchr , strchr
|
||||
dd szStrrchr , strrchr
|
||||
|
||||
dd szEthReceiver , ETH_Receiver
|
||||
dd szEthRegDev , ETH_Add_Device
|
||||
dd szEthUnRegDev , ETH_Remove_Device
|
||||
dd szEthStruc2Dev , ETH_struc2dev
|
||||
|
||||
exp_lfb:
|
||||
dd szLFBAddress , 0
|
||||
dd 0 ;terminator, must be zero
|
||||
|
||||
endg
|
||||
|
317
kernel/branches/core/ext_lib.inc
Normal file
317
kernel/branches/core/ext_lib.inc
Normal file
@ -0,0 +1,317 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;============================================================================
|
||||
;
|
||||
; External kernel dependencies (libraries) loading
|
||||
;
|
||||
;============================================================================
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
macro library [name,fname]
|
||||
{
|
||||
forward
|
||||
dd __#name#_library_table__,__#name#_library_name__
|
||||
common
|
||||
dd 0
|
||||
forward
|
||||
__#name#_library_name__ db fname,0
|
||||
}
|
||||
|
||||
macro import lname,[name,sname]
|
||||
{
|
||||
common
|
||||
align 4
|
||||
__#lname#_library_table__:
|
||||
forward
|
||||
name dd __#name#_import_name__
|
||||
common
|
||||
dd 0
|
||||
forward
|
||||
__#name#_import_name__ db sname,0
|
||||
}
|
||||
|
||||
macro export [name,sname]
|
||||
{
|
||||
align 4
|
||||
forward
|
||||
dd __#name#_export_name__,name
|
||||
common
|
||||
dd 0
|
||||
forward
|
||||
__#name#_export_name__ db sname,0
|
||||
}
|
||||
|
||||
|
||||
|
||||
align 4 ; loading library (use kernel functions)
|
||||
proc load_k_library stdcall, file_name:dword
|
||||
locals
|
||||
coff dd ?
|
||||
sym dd ?
|
||||
strings dd ?
|
||||
img_size dd ?
|
||||
img_base dd ?
|
||||
exports dd ?
|
||||
endl
|
||||
|
||||
cli
|
||||
|
||||
stdcall load_file, [file_name]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov [coff], eax
|
||||
movzx ecx, [eax+CFH.nSections]
|
||||
xor ebx, ebx
|
||||
|
||||
lea edx, [eax+20]
|
||||
@@:
|
||||
add ebx, [edx+CFS.SizeOfRawData]
|
||||
add ebx, 15
|
||||
and ebx, not 15
|
||||
add edx, COFF_SECTION_SIZE
|
||||
dec ecx
|
||||
jnz @B
|
||||
mov [img_size], ebx
|
||||
|
||||
stdcall kernel_alloc, [img_size]
|
||||
|
||||
test eax, eax
|
||||
jz .fail
|
||||
mov [img_base], eax
|
||||
|
||||
mov edx, [coff]
|
||||
movzx ebx, [edx+CFH.nSections]
|
||||
mov edi, [img_base]
|
||||
lea eax, [edx+20]
|
||||
@@:
|
||||
mov [eax+CFS.VirtualAddress], edi
|
||||
mov esi, [eax+CFS.PtrRawData]
|
||||
test esi, esi
|
||||
jnz .copy
|
||||
add edi, [eax+CFS.SizeOfRawData]
|
||||
jmp .next
|
||||
.copy:
|
||||
add esi, edx
|
||||
mov ecx, [eax+CFS.SizeOfRawData]
|
||||
cld
|
||||
rep movsb
|
||||
.next:
|
||||
add edi, 15
|
||||
and edi, not 15
|
||||
add eax, COFF_SECTION_SIZE
|
||||
dec ebx
|
||||
jnz @B
|
||||
|
||||
mov ebx, [edx+CFH.pSymTable]
|
||||
add ebx, edx
|
||||
mov [sym], ebx
|
||||
mov ecx, [edx+CFH.nSymbols]
|
||||
add ecx,ecx
|
||||
lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE
|
||||
add ecx, [sym]
|
||||
mov [strings], ecx
|
||||
|
||||
lea eax, [edx+20]
|
||||
|
||||
stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\
|
||||
[strings], dword 0
|
||||
test eax, eax
|
||||
jnz @F
|
||||
|
||||
@@:
|
||||
mov edx, [coff]
|
||||
movzx ebx, [edx+CFH.nSections]
|
||||
mov edi, 0
|
||||
lea eax, [edx+20]
|
||||
@@:
|
||||
add [eax+CFS.VirtualAddress], edi ;patch user space offset
|
||||
add eax, COFF_SECTION_SIZE
|
||||
dec ebx
|
||||
jnz @B
|
||||
|
||||
add edx, 20
|
||||
stdcall fix_coff_relocs, [coff], edx, [sym]
|
||||
|
||||
mov ebx, [coff]
|
||||
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS
|
||||
mov [exports], eax
|
||||
|
||||
stdcall kernel_free, [coff]
|
||||
|
||||
mov eax, [exports]
|
||||
ret
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc dll.Load, import_table:dword
|
||||
mov esi,[import_table]
|
||||
.next_lib: mov edx,[esi]
|
||||
or edx,edx
|
||||
jz .exit
|
||||
push esi
|
||||
|
||||
mov edi,s_libname
|
||||
|
||||
mov al, '/'
|
||||
stosb
|
||||
mov esi,sysdir_path
|
||||
@@: lodsb
|
||||
stosb
|
||||
or al,al
|
||||
jnz @b
|
||||
dec edi
|
||||
mov [edi], dword '/lib'
|
||||
mov [edi+4],byte '/'
|
||||
add edi,5
|
||||
pop esi
|
||||
push esi
|
||||
mov esi,[esi+4]
|
||||
@@: lodsb
|
||||
stosb
|
||||
or al,al
|
||||
jnz @b
|
||||
|
||||
pushad
|
||||
stdcall load_k_library,s_libname
|
||||
mov [esp+28],eax
|
||||
popad
|
||||
or eax,eax
|
||||
jz .fail
|
||||
stdcall dll.Link,eax,edx
|
||||
stdcall dll.Init,[eax+4]
|
||||
pop esi
|
||||
add esi,8
|
||||
jmp .next_lib
|
||||
.exit: xor eax,eax
|
||||
ret
|
||||
.fail: add esp,4
|
||||
xor eax,eax
|
||||
inc eax
|
||||
ret
|
||||
endp
|
||||
|
||||
proc dll.Link, exp:dword,imp:dword
|
||||
push eax
|
||||
mov esi,[imp]
|
||||
test esi,esi
|
||||
jz .done
|
||||
.next: lodsd
|
||||
test eax,eax
|
||||
jz .done
|
||||
stdcall dll.GetProcAddress,[exp],eax
|
||||
or eax,eax
|
||||
jz @f
|
||||
mov [esi-4],eax
|
||||
jmp .next
|
||||
@@: mov dword[esp],0
|
||||
.done: pop eax
|
||||
ret
|
||||
endp
|
||||
|
||||
proc dll.Init, dllentry:dword
|
||||
pushad
|
||||
mov eax,mem.Alloc
|
||||
mov ebx,mem.Free
|
||||
mov ecx,mem.ReAlloc
|
||||
mov edx,dll.Load
|
||||
stdcall [dllentry]
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
proc dll.GetProcAddress, exp:dword,sz_name:dword
|
||||
mov edx,[exp]
|
||||
.next: test edx,edx
|
||||
jz .end
|
||||
stdcall strncmp,[edx],[sz_name], dword -1
|
||||
test eax,eax
|
||||
jz .ok
|
||||
add edx,8
|
||||
jmp .next
|
||||
.ok: mov eax,[edx+4]
|
||||
.end: ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
proc mem.Alloc size ;/////////////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
push ebx ecx
|
||||
; mov eax,[size]
|
||||
; lea ecx,[eax+4+4095]
|
||||
; and ecx,not 4095
|
||||
; stdcall kernel_alloc, ecx
|
||||
; add ecx,-4
|
||||
; mov [eax],ecx
|
||||
; add eax,4
|
||||
|
||||
stdcall kernel_alloc, [size]
|
||||
|
||||
pop ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
push ebx ecx esi edi eax
|
||||
mov eax,[mptr]
|
||||
mov ebx,[size]
|
||||
or eax,eax
|
||||
jz @f
|
||||
lea ecx,[ebx+4+4095]
|
||||
and ecx,not 4095
|
||||
add ecx,-4
|
||||
cmp ecx,[eax-4]
|
||||
je .exit
|
||||
@@: mov eax,ebx
|
||||
call mem.Alloc
|
||||
xchg eax,[esp]
|
||||
or eax,eax
|
||||
jz .exit
|
||||
mov esi,eax
|
||||
xchg eax,[esp]
|
||||
mov edi,eax
|
||||
mov ecx,[esi-4]
|
||||
cmp ecx,[edi-4]
|
||||
jbe @f
|
||||
mov ecx,[edi-4]
|
||||
@@: add ecx,3
|
||||
shr ecx,2
|
||||
cld
|
||||
rep movsd
|
||||
xchg eax,[esp]
|
||||
call mem.Free
|
||||
.exit:
|
||||
pop eax edi esi ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
proc mem.Free mptr ;//////////////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; mov eax,[mptr]
|
||||
; or eax,eax
|
||||
; jz @f
|
||||
; push ebx ecx
|
||||
; lea ecx,[eax-4]
|
||||
; stdcall kernel_free, ecx
|
||||
; pop ecx ebx
|
||||
; @@: ret
|
||||
stdcall kernel_free, [mptr]
|
||||
ret
|
||||
endp
|
||||
|
||||
uglobal
|
||||
s_libname db 64 dup (0)
|
||||
endg
|
288
kernel/branches/core/fpu.inc
Normal file
288
kernel/branches/core/fpu.inc
Normal file
@ -0,0 +1,288 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
init_fpu:
|
||||
clts
|
||||
fninit
|
||||
|
||||
bt [cpu_caps], CAPS_SSE
|
||||
jnc .no_SSE
|
||||
|
||||
mov ebx, cr4
|
||||
mov ecx, cr0
|
||||
or ebx, CR4_OSFXSR+CR4_OSXMMEXPT
|
||||
mov cr4, ebx
|
||||
|
||||
and ecx, not (CR0_MP+CR0_EM)
|
||||
or ecx, CR0_NE
|
||||
mov cr0, ecx
|
||||
|
||||
mov dword [esp-4], SSE_INIT
|
||||
ldmxcsr [esp-4]
|
||||
|
||||
xorps xmm0, xmm0
|
||||
xorps xmm1, xmm1
|
||||
xorps xmm2, xmm2
|
||||
xorps xmm3, xmm3
|
||||
xorps xmm4, xmm4
|
||||
xorps xmm5, xmm5
|
||||
xorps xmm6, xmm6
|
||||
xorps xmm7, xmm7
|
||||
fxsave [fpu_data] ;[eax]
|
||||
ret
|
||||
.no_SSE:
|
||||
mov ecx, cr0
|
||||
and ecx, not CR0_EM
|
||||
or ecx, CR0_MP+CR0_NE
|
||||
mov cr0, ecx
|
||||
fnsave [fpu_data]
|
||||
ret
|
||||
|
||||
; param
|
||||
; eax= 512 bytes memory area
|
||||
|
||||
align 4
|
||||
fpu_save:
|
||||
push ecx
|
||||
push esi
|
||||
push edi
|
||||
|
||||
pushfd
|
||||
cli
|
||||
|
||||
clts
|
||||
mov edi, eax
|
||||
|
||||
mov ecx, [fpu_owner]
|
||||
mov esi, [CURRENT_TASK]
|
||||
cmp ecx, esi
|
||||
jne .save
|
||||
|
||||
call save_context
|
||||
jmp .exit
|
||||
.save:
|
||||
mov [fpu_owner], esi
|
||||
|
||||
shl ecx, 8
|
||||
mov eax, [ecx+SLOT_BASE+APPDATA.fpu_state]
|
||||
|
||||
call save_context
|
||||
|
||||
shl esi, 8
|
||||
mov esi, [esi+SLOT_BASE+APPDATA.fpu_state]
|
||||
mov ecx, 512/4
|
||||
cld
|
||||
rep movsd
|
||||
fninit
|
||||
.exit:
|
||||
popfd
|
||||
pop edi
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
align 4
|
||||
save_context:
|
||||
bt [cpu_caps], CAPS_SSE
|
||||
jnc .no_SSE
|
||||
|
||||
fxsave [eax]
|
||||
ret
|
||||
.no_SSE:
|
||||
fnsave [eax]
|
||||
ret
|
||||
|
||||
align 4
|
||||
fpu_restore:
|
||||
push ecx
|
||||
push esi
|
||||
|
||||
mov esi, eax
|
||||
|
||||
pushfd
|
||||
cli
|
||||
|
||||
mov ecx, [fpu_owner]
|
||||
mov eax, [CURRENT_TASK]
|
||||
cmp ecx, eax
|
||||
jne .copy
|
||||
|
||||
clts
|
||||
bt [cpu_caps], CAPS_SSE
|
||||
jnc .no_SSE
|
||||
|
||||
fxrstor [esi]
|
||||
popfd
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
.no_SSE:
|
||||
fnclex ;fix possible problems
|
||||
frstor [esi]
|
||||
popfd
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
.copy:
|
||||
shl eax, 8
|
||||
mov edi, [eax+SLOT_BASE+APPDATA.fpu_state]
|
||||
mov ecx, 512/4
|
||||
cld
|
||||
rep movsd
|
||||
popfd
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
align 4
|
||||
e7: ;#NM exception handler
|
||||
save_ring3_context
|
||||
clts
|
||||
mov ax, app_data ;
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov ebx, [fpu_owner]
|
||||
cmp ebx, [CURRENT_TASK]
|
||||
je .exit
|
||||
|
||||
shl ebx, 8
|
||||
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
|
||||
bt [cpu_caps], CAPS_SSE
|
||||
jnc .no_SSE
|
||||
|
||||
fxsave [eax]
|
||||
mov ebx, [CURRENT_TASK]
|
||||
mov [fpu_owner], ebx
|
||||
shl ebx, 8
|
||||
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
|
||||
fxrstor [eax]
|
||||
.exit:
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
.no_SSE:
|
||||
fnsave [eax]
|
||||
mov ebx, [CURRENT_TASK]
|
||||
mov [fpu_owner], ebx
|
||||
shl ebx, 8
|
||||
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
|
||||
frstor [eax]
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
iglobal
|
||||
fpu_owner dd 0
|
||||
endg
|
||||
|
||||
reg_eip equ ebp+4
|
||||
reg_cs equ ebp+8
|
||||
reg_eflags equ ebp+12
|
||||
reg_esp equ ebp+16
|
||||
reg_ss equ ebp+20
|
||||
|
||||
align 4
|
||||
except_16: ;fpu native exceptions handler
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_except_16
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
mov ebx, [CURRENT_TASK]
|
||||
shl ebx, 8
|
||||
|
||||
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_handler]
|
||||
test eax, eax
|
||||
jz .default
|
||||
|
||||
mov ecx, [reg_eip]
|
||||
mov edx, [reg_esp]
|
||||
sub edx, 4
|
||||
mov [edx], ecx
|
||||
mov [reg_esp], edx
|
||||
mov dword [reg_eip], eax
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
|
||||
leave
|
||||
iretd
|
||||
|
||||
.default:
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
leave
|
||||
|
||||
save_ring3_context ;debugger support
|
||||
|
||||
mov bl, 16
|
||||
jmp exc_c
|
||||
|
||||
align 4
|
||||
except_19: ;sse exceptions handler
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_except_19
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
mov ebx, [current_slot]
|
||||
|
||||
mov eax, [ebx+APPDATA.sse_handler]
|
||||
test eax, eax
|
||||
jz .default
|
||||
|
||||
mov ecx, [reg_eip]
|
||||
mov edx, [reg_esp]
|
||||
sub edx, 4
|
||||
mov [edx], ecx
|
||||
mov [reg_esp], edx
|
||||
mov dword [reg_eip], eax
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
|
||||
leave
|
||||
iretd
|
||||
|
||||
.default:
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
leave
|
||||
|
||||
save_ring3_context ;debugger support
|
||||
|
||||
mov bl, 19
|
||||
jmp exc_c
|
||||
|
||||
restore reg_eip
|
||||
restore reg_cs
|
||||
restore reg_eflags
|
||||
restore reg_esp
|
||||
restore reg_ss
|
||||
|
||||
|
1443
kernel/branches/core/heap.inc
Normal file
1443
kernel/branches/core/heap.inc
Normal file
File diff suppressed because it is too large
Load Diff
1003
kernel/branches/core/malloc.inc
Normal file
1003
kernel/branches/core/malloc.inc
Normal file
File diff suppressed because it is too large
Load Diff
1323
kernel/branches/core/memory.inc
Normal file
1323
kernel/branches/core/memory.inc
Normal file
File diff suppressed because it is too large
Load Diff
320
kernel/branches/core/peload.inc
Normal file
320
kernel/branches/core/peload.inc
Normal file
@ -0,0 +1,320 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 978 $
|
||||
|
||||
include 'export.inc'
|
||||
|
||||
align 4
|
||||
|
||||
proc load_PE stdcall, file_name:dword
|
||||
locals
|
||||
image dd ?
|
||||
entry dd ?
|
||||
base dd ?
|
||||
endl
|
||||
|
||||
stdcall load_file, [file_name]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov [image], eax
|
||||
|
||||
mov edx, [eax+60]
|
||||
|
||||
stdcall kernel_alloc, [eax+80+edx]
|
||||
test eax, eax
|
||||
jz .cleanup
|
||||
|
||||
mov [base], eax
|
||||
|
||||
stdcall map_PE, eax, [image]
|
||||
|
||||
mov [entry], eax
|
||||
test eax, eax
|
||||
jnz .cleanup
|
||||
|
||||
stdcall kernel_free, [base]
|
||||
.cleanup:
|
||||
stdcall kernel_free, [image]
|
||||
mov eax, [entry]
|
||||
ret
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
DWORD equ dword
|
||||
PTR equ
|
||||
|
||||
align 4
|
||||
map_PE: ;stdcall base:dword, image:dword
|
||||
cld
|
||||
push ebp
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
sub esp, 60
|
||||
mov ebx, DWORD PTR [esp+84]
|
||||
mov ebp, DWORD PTR [esp+80]
|
||||
mov edx, ebx
|
||||
mov esi, ebx
|
||||
add edx, DWORD PTR [ebx+60]
|
||||
mov edi, ebp
|
||||
mov DWORD PTR [esp+32], edx
|
||||
mov ecx, DWORD PTR [edx+84]
|
||||
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
|
||||
movzx eax, WORD PTR [edx+6]
|
||||
mov DWORD PTR [esp+36], 0
|
||||
mov DWORD PTR [esp+16], eax
|
||||
jmp L2
|
||||
L3:
|
||||
mov eax, DWORD PTR [edx+264]
|
||||
test eax, eax
|
||||
je L4
|
||||
mov esi, ebx
|
||||
mov edi, ebp
|
||||
add esi, DWORD PTR [edx+268]
|
||||
mov ecx, eax
|
||||
add edi, DWORD PTR [edx+260]
|
||||
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
|
||||
L4:
|
||||
mov ecx, DWORD PTR [edx+256]
|
||||
add ecx, 4095
|
||||
and ecx, -4096
|
||||
cmp ecx, eax
|
||||
jbe L6
|
||||
sub ecx, eax
|
||||
add eax, DWORD PTR [edx+260]
|
||||
lea edi, [eax+ebp]
|
||||
|
||||
xor eax, eax
|
||||
rep stosb
|
||||
|
||||
L6:
|
||||
inc DWORD PTR [esp+36]
|
||||
add edx, 40
|
||||
L2:
|
||||
mov esi, DWORD PTR [esp+16]
|
||||
cmp DWORD PTR [esp+36], esi
|
||||
jne L3
|
||||
mov edi, DWORD PTR [esp+32]
|
||||
cmp DWORD PTR [edi+164], 0
|
||||
je L9
|
||||
mov esi, ebp
|
||||
mov ecx, ebp
|
||||
sub esi, DWORD PTR [edi+52]
|
||||
add ecx, DWORD PTR [edi+160]
|
||||
mov eax, esi
|
||||
shr eax, 16
|
||||
mov DWORD PTR [esp+12], eax
|
||||
jmp L11
|
||||
L12:
|
||||
lea ebx, [eax-8]
|
||||
xor edi, edi
|
||||
shr ebx,1
|
||||
jmp L13
|
||||
L14:
|
||||
movzx eax, WORD PTR [ecx+8+edi*2]
|
||||
mov edx, eax
|
||||
shr eax, 12
|
||||
and edx, 4095
|
||||
add edx, DWORD PTR [ecx]
|
||||
cmp ax, 2
|
||||
je L17
|
||||
cmp ax, 3
|
||||
je L18
|
||||
dec ax
|
||||
jne L15
|
||||
mov eax, DWORD PTR [esp+12]
|
||||
add WORD PTR [edx+ebp], ax
|
||||
L17:
|
||||
add WORD PTR [edx+ebp], si
|
||||
L18:
|
||||
add DWORD PTR [edx+ebp], esi
|
||||
L15:
|
||||
inc edi
|
||||
L13:
|
||||
cmp edi, ebx
|
||||
jne L14
|
||||
add ecx, DWORD PTR [ecx+4]
|
||||
L11:
|
||||
mov eax, DWORD PTR [ecx+4]
|
||||
test eax, eax
|
||||
jne L12
|
||||
L9:
|
||||
mov edx, DWORD PTR [esp+32]
|
||||
cmp DWORD PTR [edx+132], 0
|
||||
je L20
|
||||
mov eax, ebp
|
||||
add eax, DWORD PTR [edx+128]
|
||||
mov DWORD PTR [esp+40], 0
|
||||
add eax, 20
|
||||
mov DWORD PTR [esp+56], eax
|
||||
L22:
|
||||
mov ecx, DWORD PTR [esp+56]
|
||||
cmp DWORD PTR [ecx-16], 0
|
||||
jne L23
|
||||
cmp DWORD PTR [ecx-8], 0
|
||||
je L25
|
||||
L23:
|
||||
mov edi, DWORD PTR [__exports+32]
|
||||
mov esi, DWORD PTR [__exports+28]
|
||||
mov eax, DWORD PTR [esp+56]
|
||||
mov DWORD PTR [esp+20], edi
|
||||
add edi, OS_BASE
|
||||
add esi, OS_BASE
|
||||
mov DWORD PTR [esp+44], esi
|
||||
mov ecx, DWORD PTR [eax-4]
|
||||
mov DWORD PTR [esp+48], edi
|
||||
mov edx, DWORD PTR [eax-20]
|
||||
mov DWORD PTR [esp+52], 0
|
||||
add ecx, ebp
|
||||
add edx, ebp
|
||||
mov DWORD PTR [esp+24], edx
|
||||
mov DWORD PTR [esp+28], ecx
|
||||
L26:
|
||||
mov esi, DWORD PTR [esp+52]
|
||||
mov edi, DWORD PTR [esp+24]
|
||||
mov eax, DWORD PTR [edi+esi*4]
|
||||
test eax, eax
|
||||
je L27
|
||||
test eax, eax
|
||||
js L27
|
||||
lea edi, [ebp+eax]
|
||||
mov eax, DWORD PTR [esp+28]
|
||||
mov DWORD PTR [eax+esi*4], 0
|
||||
lea esi, [edi+2]
|
||||
push eax
|
||||
push 32
|
||||
movzx eax, WORD PTR [edi]
|
||||
mov edx, DWORD PTR [esp+56]
|
||||
mov eax, DWORD PTR [edx+eax*4]
|
||||
add eax, OS_BASE
|
||||
push eax
|
||||
push esi
|
||||
call strncmp
|
||||
pop ebx
|
||||
xor ebx, ebx
|
||||
test eax, eax
|
||||
jne L32
|
||||
jmp L30
|
||||
L33:
|
||||
push ecx
|
||||
push 32
|
||||
mov ecx, DWORD PTR [esp+28]
|
||||
mov eax, DWORD PTR [ecx+OS_BASE+ebx*4]
|
||||
add eax, OS_BASE
|
||||
push eax
|
||||
push esi
|
||||
call strncmp
|
||||
pop edx
|
||||
test eax, eax
|
||||
jne L34
|
||||
mov esi, DWORD PTR [esp+44]
|
||||
mov edx, DWORD PTR [esp+52]
|
||||
mov ecx, DWORD PTR [esp+28]
|
||||
mov eax, DWORD PTR [esi+ebx*4]
|
||||
add eax, OS_BASE
|
||||
mov DWORD PTR [ecx+edx*4], eax
|
||||
jmp L36
|
||||
L34:
|
||||
inc ebx
|
||||
L32:
|
||||
cmp ebx, DWORD PTR [__exports+24]
|
||||
jb L33
|
||||
L36:
|
||||
cmp ebx, DWORD PTR [__exports+24]
|
||||
jne L37
|
||||
|
||||
mov esi, msg_unresolved
|
||||
call sys_msg_board_str
|
||||
lea esi, [edi+2]
|
||||
call sys_msg_board_str
|
||||
mov esi, msg_CR
|
||||
call sys_msg_board_str
|
||||
|
||||
mov DWORD PTR [esp+40], 1
|
||||
jmp L37
|
||||
L30:
|
||||
movzx eax, WORD PTR [edi]
|
||||
mov esi, DWORD PTR [esp+44]
|
||||
mov edi, DWORD PTR [esp+52]
|
||||
mov edx, DWORD PTR [esp+28]
|
||||
mov eax, DWORD PTR [esi+eax*4]
|
||||
add eax, OS_BASE
|
||||
mov DWORD PTR [edx+edi*4], eax
|
||||
L37:
|
||||
inc DWORD PTR [esp+52]
|
||||
jmp L26
|
||||
L27:
|
||||
add DWORD PTR [esp+56], 20
|
||||
jmp L22
|
||||
L25:
|
||||
xor eax, eax
|
||||
cmp DWORD PTR [esp+40], 0
|
||||
jne L40
|
||||
L20:
|
||||
mov ecx, DWORD PTR [esp+32]
|
||||
mov eax, ebp
|
||||
add eax, DWORD PTR [ecx+40]
|
||||
L40:
|
||||
add esp, 60
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret 8
|
||||
|
||||
align 16
|
||||
__exports:
|
||||
export 'KERNEL', \
|
||||
alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall
|
||||
commit_pages, 'CommitPages', \ ; eax, ebx, ecx
|
||||
create_kernel_object, 'CreateObject', \
|
||||
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
|
||||
destroy_kernel_object, 'DestroyObject', \
|
||||
free_kernel_space, 'FreeKernelSpace', \ ; stdcall
|
||||
kernel_alloc, 'KernelAlloc', \ ; stdcall
|
||||
kernel_free, 'KernelFree', \ ; stdcall
|
||||
alloc_pages, 'AllocPages', \ ; stdcall
|
||||
malloc, 'Kmalloc', \
|
||||
free, 'Kfree', \
|
||||
map_io_mem, 'MapIoMem', \ ; stdcall
|
||||
get_pg_addr, 'GetPgAddr', \ ; eax
|
||||
\
|
||||
select_hw_cursor, 'SelectHwCursor', \ ; stdcall
|
||||
set_hw_cursor, 'SetHwCursor', \ ; stdcall
|
||||
hw_restore, 'HwCursorRestore', \ ;
|
||||
create_cursor, 'HwCursorCreate', \ ;
|
||||
\
|
||||
set_screen, 'SetScreen', \
|
||||
pci_api, 'PciApi', \
|
||||
pci_read8, 'PciRead8', \ ; stdcall
|
||||
pci_read16, 'PciRead16', \ ; stdcall
|
||||
pci_read32, 'PciRead32', \ ; stdcall
|
||||
pci_write8, 'PciWrite8', \ ; stdcall
|
||||
pci_write16, 'PciWrite16', \ ; stdcall
|
||||
pci_write32, 'PciWrite32', \ ; stdcall
|
||||
\
|
||||
reg_service, 'RegService', \ ; stdcall
|
||||
attach_int_handler, 'AttachIntHandler', \ ; stdcall
|
||||
user_alloc, 'UserAlloc', \ ; stdcall
|
||||
user_free, 'UserFree', \ ; stdcall
|
||||
unmap_pages, 'UnmapPages', \ ; eax, ecx
|
||||
sys_msg_board_str, 'SysMsgBoardStr', \
|
||||
delay_hs, 'Delay', \ ; ebx
|
||||
set_mouse_data, 'SetMouseData'
|
||||
|
||||
|
||||
|
388
kernel/branches/core/sched.inc
Normal file
388
kernel/branches/core/sched.inc
Normal file
@ -0,0 +1,388 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 907 $
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
align 32
|
||||
irq0:
|
||||
pushad
|
||||
mov ax, app_data ;
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
; cmp dword[CURRENT_TASK], 1
|
||||
; jnz @f
|
||||
; mov eax, [esp + 32]
|
||||
; cmp eax, idle_loop + 1
|
||||
; jz @f
|
||||
; DEBUGF 1, "K : OOOPS! EAX = 0x%x\n", eax
|
||||
; @@:
|
||||
|
||||
inc dword [timer_ticks]
|
||||
|
||||
mov eax, [timer_ticks]
|
||||
call playNote ; <<<--- Speaker driver
|
||||
|
||||
cmp eax,[next_usage_update]
|
||||
jb .nocounter
|
||||
add eax,100
|
||||
mov [next_usage_update],eax
|
||||
call updatecputimes
|
||||
.nocounter:
|
||||
cmp [DONT_SWITCH], byte 1
|
||||
jne .change_task
|
||||
|
||||
mov al,0x20 ; send End Of Interrupt signal
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
mov [DONT_SWITCH], byte 0
|
||||
|
||||
popad
|
||||
iretd
|
||||
|
||||
.change_task:
|
||||
call update_counters
|
||||
|
||||
call find_next_task
|
||||
mov ecx, eax
|
||||
|
||||
mov al,0x20 ; send End Of Interrupt signal
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
test ecx, ecx ; if there is only one running process
|
||||
jnz .return
|
||||
|
||||
call do_change_task
|
||||
|
||||
.return:
|
||||
popad
|
||||
; popfd
|
||||
iretd
|
||||
|
||||
|
||||
align 4
|
||||
change_task:
|
||||
|
||||
pushfd
|
||||
cli
|
||||
pushad
|
||||
|
||||
call update_counters
|
||||
|
||||
if 0
|
||||
|
||||
; \begin{Mario79}
|
||||
cmp [dma_task_switched], 1
|
||||
jne .find_next_task
|
||||
mov [dma_task_switched], 0
|
||||
mov ebx, [dma_process]
|
||||
cmp [CURRENT_TASK], ebx
|
||||
je .return
|
||||
mov edi, [dma_slot_ptr]
|
||||
mov [CURRENT_TASK], ebx
|
||||
mov [TASK_BASE], edi
|
||||
jmp @f
|
||||
.find_next_task:
|
||||
; \end{Mario79}
|
||||
|
||||
end if
|
||||
|
||||
call find_next_task
|
||||
test eax, eax ; the same task -> skip switch
|
||||
jnz .return
|
||||
@@:
|
||||
mov [DONT_SWITCH],byte 1
|
||||
call do_change_task
|
||||
|
||||
.return:
|
||||
popad
|
||||
popfd
|
||||
ret
|
||||
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
far_jump:
|
||||
.offs dd ?
|
||||
.sel dw ?
|
||||
context_counter dd ? ;noname & halyavin
|
||||
next_usage_update dd ?
|
||||
timer_ticks dd ?
|
||||
prev_slot dd ?
|
||||
event_sched dd ?
|
||||
endg
|
||||
|
||||
|
||||
update_counters:
|
||||
mov edi, [TASK_BASE]
|
||||
mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
|
||||
rdtsc
|
||||
sub eax, ebx
|
||||
add eax, [edi+TASKDATA.counter_sum] ; counter sum
|
||||
mov [edi+TASKDATA.counter_sum], eax
|
||||
ret
|
||||
|
||||
|
||||
; Find next task to execute
|
||||
; result: ebx = number of the selected task
|
||||
; eax = 1 if the task is the same
|
||||
; edi = address of the data for the task in ebx
|
||||
; [0x3000] = ebx and [0x3010] = edi
|
||||
; corrupts other regs
|
||||
find_next_task:
|
||||
mov ebx, [CURRENT_TASK]
|
||||
mov edi, [TASK_BASE]
|
||||
mov [prev_slot], ebx
|
||||
|
||||
.waiting_for_termination:
|
||||
.waiting_for_reuse:
|
||||
.waiting_for_event:
|
||||
.suspended:
|
||||
cmp ebx, [TASK_COUNT]
|
||||
jb @f
|
||||
mov edi, CURRENT_TASK
|
||||
xor ebx, ebx
|
||||
@@:
|
||||
|
||||
add edi,0x20
|
||||
inc ebx
|
||||
|
||||
mov al, byte [edi+TASKDATA.state]
|
||||
test al, al
|
||||
jz .found
|
||||
cmp al, 1
|
||||
jz .suspended
|
||||
cmp al, 2
|
||||
jz .suspended
|
||||
cmp al, 3
|
||||
je .waiting_for_termination
|
||||
cmp al, 4
|
||||
je .waiting_for_termination
|
||||
cmp al, 9
|
||||
je .waiting_for_reuse
|
||||
|
||||
mov [CURRENT_TASK],ebx
|
||||
mov [TASK_BASE],edi
|
||||
|
||||
cmp al, 5
|
||||
jne .noevents
|
||||
call get_event_for_app
|
||||
test eax, eax
|
||||
jnz @f
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
mov eax, [SLOT_BASE + APPDATA.wait_timeout + eax]
|
||||
cmp eax, [timer_ticks]
|
||||
jae .waiting_for_event
|
||||
xor eax, eax
|
||||
@@:
|
||||
mov [event_sched], eax
|
||||
mov [edi+TASKDATA.state], byte 0
|
||||
.noevents:
|
||||
.found:
|
||||
mov [CURRENT_TASK],ebx
|
||||
mov [TASK_BASE],edi
|
||||
rdtsc ;call _rdtsc
|
||||
mov [edi+TASKDATA.counter_add],eax
|
||||
|
||||
mov esi, [prev_slot]
|
||||
xor eax, eax
|
||||
cmp ebx, esi
|
||||
sete al
|
||||
ret
|
||||
|
||||
; param
|
||||
; ebx = incoming task
|
||||
; esi = outcomig task
|
||||
|
||||
do_change_task:
|
||||
|
||||
shl ebx, 8
|
||||
add ebx, SLOT_BASE
|
||||
mov [current_slot], ebx
|
||||
|
||||
shl esi, 8
|
||||
add esi, SLOT_BASE
|
||||
|
||||
mov [esi+APPDATA.saved_esp], esp
|
||||
mov esp, [ebx+APPDATA.saved_esp]
|
||||
|
||||
; set thread io map
|
||||
|
||||
mov ecx, [ebx+APPDATA.io_map]
|
||||
mov edx, [ebx+APPDATA.io_map+4]
|
||||
mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)], ecx
|
||||
mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)], edx
|
||||
|
||||
mov eax, [ebx+APPDATA.dir_table]
|
||||
cmp eax, [esi+APPDATA.dir_table]
|
||||
je @F
|
||||
mov cr3, eax
|
||||
@@:
|
||||
mov eax, [ebx+APPDATA.saved_esp0]
|
||||
mov [tss._esp0], eax
|
||||
mov ax, graph_data
|
||||
mov gs, ax
|
||||
|
||||
mov eax, [CURRENT_TASK]
|
||||
cmp eax, [fpu_owner]
|
||||
clts ;clear a task switch flag
|
||||
je @F
|
||||
;and set it again if the owner
|
||||
mov ecx, cr0 ;of a fpu has changed
|
||||
or ecx, CR0_TS
|
||||
mov cr0, ecx
|
||||
@@:
|
||||
inc [context_counter] ;noname & halyavin
|
||||
test [ebx+APPDATA.dbg_state], 1
|
||||
jnz @F
|
||||
ret
|
||||
@@:
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr0]
|
||||
mov dr0, eax
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr1]
|
||||
mov dr1, eax
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr2]
|
||||
mov dr2, eax
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr3]
|
||||
mov dr3, eax
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr7]
|
||||
mov dr7, eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
updatecputimes:
|
||||
|
||||
mov eax,[idleuse]
|
||||
mov [idleusesec],eax
|
||||
mov [idleuse],dword 0
|
||||
mov ecx, [TASK_COUNT]
|
||||
mov edi, TASK_DATA
|
||||
.newupdate:
|
||||
mov ebx,[edi+TASKDATA.counter_sum]
|
||||
mov [edi+TASKDATA.cpu_usage],ebx
|
||||
mov [edi+TASKDATA.counter_sum],dword 0
|
||||
add edi,0x20
|
||||
dec ecx
|
||||
jnz .newupdate
|
||||
|
||||
ret
|
||||
|
||||
if 0
|
||||
|
||||
|
||||
struc TIMER
|
||||
{
|
||||
.next dd ?
|
||||
.exp_time dd ?
|
||||
.func dd ?
|
||||
.arg dd ?
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MAX_PROIRITY 0 ; highest, used for kernel tasks
|
||||
MAX_USER_PRIORITY 0 ; highest priority for user processes
|
||||
USER_PRIORITY 7 ; default (should correspond to nice 0)
|
||||
MIN_USER_PRIORITY 14 ; minimum priority for user processes
|
||||
IDLE_PRIORITY 15 ; lowest, only IDLE process goes here
|
||||
NR_SCHED_QUEUES 16 ; MUST equal IDLE_PRIORYTY + 1
|
||||
|
||||
rdy_head rd 16
|
||||
|
||||
|
||||
align 4
|
||||
pick_task:
|
||||
|
||||
xor eax, eax
|
||||
.pick:
|
||||
mov ebx, [rdy_head+eax*4]
|
||||
test ebx, ebx
|
||||
jz .next
|
||||
|
||||
mov [next_task], ebx
|
||||
test [ebx+flags.billable]
|
||||
jz @F
|
||||
mov [bill_task], ebx
|
||||
@@:
|
||||
ret
|
||||
.next:
|
||||
inc eax
|
||||
jmp .pick
|
||||
|
||||
|
||||
; param
|
||||
; eax= task
|
||||
;
|
||||
; retval
|
||||
; eax= task
|
||||
; ebx= queue
|
||||
; ecx= front if 1 or back if 0
|
||||
|
||||
align 4
|
||||
shed:
|
||||
cmp [eax+.tics_left], 0 ;signed compare
|
||||
mov ebx, [eax+.priority]
|
||||
setg ecx
|
||||
jg @F
|
||||
|
||||
mov edx, [eax+.tics_quantum]
|
||||
mov [eax+.ticks_left], edx
|
||||
cmp ebx, (IDLE_PRIORITY-1)
|
||||
je @F
|
||||
inc ebx
|
||||
@@:
|
||||
ret
|
||||
|
||||
; param
|
||||
; eax= task
|
||||
|
||||
align 4
|
||||
enqueue:
|
||||
call shed ;eax
|
||||
cmp [rdy_head+ebx*4],0
|
||||
jnz @F
|
||||
|
||||
mov [rdy_head+ebx*4], eax
|
||||
mov [rdy_tail+ebx*4], eax
|
||||
mov [eax+.next_ready], 0
|
||||
jmp .pick
|
||||
@@:
|
||||
test ecx, ecx
|
||||
jz .back
|
||||
|
||||
mov ecx, [rdy_head+ebx*4]
|
||||
mov [eax+.next_ready], ecx
|
||||
mov [rdy_head+ebx*4], eax
|
||||
jmp .pick
|
||||
.back:
|
||||
mov ecx, [rdy_tail+ebx*4]
|
||||
mov [ecx+.next_ready], eax
|
||||
mov [rdy_tail+ebx*4], eax
|
||||
mov [eax+.next_ready], 0
|
||||
.pick:
|
||||
call pick_proc ;select next task
|
||||
ret
|
||||
|
||||
end if
|
||||
|
188
kernel/branches/core/string.inc
Normal file
188
kernel/branches/core/string.inc
Normal file
@ -0,0 +1,188 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; Author: Kees J. Bot 1 Jan 1994 ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
; size_t strncat(char *s1, const char *s2, size_t n)
|
||||
; Append string s2 to s1.
|
||||
|
||||
; char *strchr(const char *s, int c)
|
||||
|
||||
|
||||
; int strncmp(const char *s1, const char *s2, size_t n)
|
||||
; Compare two strings.
|
||||
|
||||
; char *strncpy(char *s1, const char *s2, size_t n)
|
||||
; Copy string s2 to s1.
|
||||
|
||||
; size_t strnlen(const char *s, size_t n)
|
||||
; Return the length of a string.
|
||||
|
||||
; proc strrchr stdcall, s:dword, c:dword
|
||||
; Look for the last occurrence a character in a string.
|
||||
|
||||
proc strncat stdcall, s1:dword, s2:dword, n:dword
|
||||
push esi
|
||||
push edi
|
||||
mov edi, [s1] ; String s1
|
||||
mov edx, [n] ; Maximum length
|
||||
|
||||
mov ecx, -1
|
||||
xor al, al ; Null byte
|
||||
cld
|
||||
repne scasb ; Look for the zero byte in s1
|
||||
dec edi ; Back one up (and clear 'Z' flag)
|
||||
push edi ; Save end of s1
|
||||
mov edi, [s2] ; edi = string s2
|
||||
mov ecx, edx ; Maximum count
|
||||
repne scasb ; Look for the end of s2
|
||||
jne @F
|
||||
inc ecx ; Exclude null byte
|
||||
@@:
|
||||
sub edx, ecx ; Number of bytes in s2
|
||||
mov ecx, edx
|
||||
mov esi, [s2] ; esi = string s2
|
||||
pop edi ; edi = end of string s1
|
||||
rep movsb ; Copy bytes
|
||||
stosb ; Add a terminating null
|
||||
mov eax, [s1] ; Return s1
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc strncmp stdcall, s1:dword, s2:dword, n:dword
|
||||
|
||||
push esi
|
||||
push edi
|
||||
mov ecx, [n]
|
||||
test ecx, ecx ; Max length is zero?
|
||||
je .done
|
||||
|
||||
mov esi, [s1] ; esi = string s1
|
||||
mov edi, [s2] ; edi = string s2
|
||||
cld
|
||||
.compare:
|
||||
cmpsb ; Compare two bytes
|
||||
jne .done
|
||||
cmp byte [esi-1], 0 ; End of string?
|
||||
je .done
|
||||
dec ecx ; Length limit reached?
|
||||
jne .compare
|
||||
.done:
|
||||
seta al ; al = (s1 > s2)
|
||||
setb ah ; ah = (s1 < s2)
|
||||
sub al, ah
|
||||
movsx eax, al ; eax = (s1 > s2) - (s1 < s2), i.e. -1, 0, 1
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc strncpy stdcall, s1:dword, s2:dword, n:dword
|
||||
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov ecx, [n] ; Maximum length
|
||||
mov edi, [s2] ; edi = string s2
|
||||
xor al, al ; Look for a zero byte
|
||||
mov edx, ecx ; Save maximum count
|
||||
cld
|
||||
repne scasb ; Look for end of s2
|
||||
sub edx, ecx ; Number of bytes in s2 including null
|
||||
xchg ecx, edx
|
||||
mov esi, [s2] ; esi = string s2
|
||||
mov edi, [s1] ; edi = string s1
|
||||
rep movsb ; Copy bytes
|
||||
|
||||
mov ecx, edx ; Number of bytes not copied
|
||||
rep stosb ; strncpy always copies n bytes by null padding
|
||||
mov eax, [s1] ; Return s1
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc strnlen stdcall, s:dword, n:dword
|
||||
|
||||
push edi
|
||||
mov edi, [s] ; edi = string
|
||||
xor al, al ; Look for a zero byte
|
||||
mov edx, ecx ; Save maximum count
|
||||
cmp cl, 1 ; 'Z' bit must be clear if ecx = 0
|
||||
cld
|
||||
repne scasb ; Look for zero
|
||||
jne @F
|
||||
inc ecx ; Don't count zero byte
|
||||
@@:
|
||||
mov eax, edx
|
||||
sub eax, ecx ; Compute bytes scanned
|
||||
pop edi
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc strchr stdcall, s:dword, c:dword
|
||||
push edi
|
||||
cld
|
||||
mov edi, [s] ; edi = string
|
||||
mov edx, 16 ; Look at small chunks of the string
|
||||
.next:
|
||||
shl edx, 1 ; Chunks become bigger each time
|
||||
mov ecx, edx
|
||||
xor al, al ; Look for the zero at the end
|
||||
repne scasb
|
||||
pushf ; Remember the flags
|
||||
sub ecx, edx
|
||||
neg ecx ; Some or all of the chunk
|
||||
sub edi, ecx ; Step back
|
||||
mov eax, [c] ; The character to look for
|
||||
repne scasb
|
||||
je .found
|
||||
popf ; Did we find the end of string earlier?
|
||||
jne .next ; No, try again
|
||||
xor eax, eax ; Return NULL
|
||||
pop edi
|
||||
ret
|
||||
.found:
|
||||
pop eax ; Get rid of those flags
|
||||
lea eax, [edi-1] ; Address of byte found
|
||||
pop edi
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
|
||||
proc strrchr stdcall, s:dword, c:dword
|
||||
push edi
|
||||
mov edi, [s] ; edi = string
|
||||
mov ecx, -1
|
||||
xor al, al
|
||||
cld
|
||||
repne scasb ; Look for the end of the string
|
||||
not ecx ; -1 - ecx = Length of the string + null
|
||||
dec edi ; Put edi back on the zero byte
|
||||
mov eax, [c] ; The character to look for
|
||||
std ; Downwards search
|
||||
repne scasb
|
||||
cld ; Direction bit back to default
|
||||
jne .fail
|
||||
lea eax, [edi+1] ; Found it
|
||||
pop edi
|
||||
ret
|
||||
.fail:
|
||||
xor eax, eax ; Not there
|
||||
pop edi
|
||||
ret
|
||||
endp
|
||||
|
||||
|
119
kernel/branches/core/sync.inc
Normal file
119
kernel/branches/core/sync.inc
Normal file
@ -0,0 +1,119 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; Synhronization for MenuetOS. ;;
|
||||
;; Author: Halyavin Andrey, halyavin@land.ru ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
if ~defined sync_inc
|
||||
sync_inc_fix:
|
||||
sync_inc fix sync_inc_fix
|
||||
|
||||
;simplest mutex.
|
||||
macro SimpleMutex name
|
||||
{
|
||||
; iglobal
|
||||
name dd 0
|
||||
name#.type = 1
|
||||
; endg
|
||||
}
|
||||
macro WaitSimpleMutex name
|
||||
{
|
||||
local start_wait,ok
|
||||
start_wait=$
|
||||
cli
|
||||
cmp [name],dword 0
|
||||
jz ok
|
||||
sti
|
||||
call change_task
|
||||
jmp start_wait
|
||||
ok=$
|
||||
push eax
|
||||
mov eax,dword [TASK_BASE+second_base_address]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
mov [name],eax
|
||||
pop eax
|
||||
sti
|
||||
}
|
||||
macro ReleaseSimpleMutex name
|
||||
{
|
||||
mov [name],dword 0
|
||||
}
|
||||
macro TryWaitSimpleMutex name ;result in eax and in flags
|
||||
{
|
||||
local ok,try_end
|
||||
cmp [name],dword 0
|
||||
jz ok
|
||||
xor eax,eax
|
||||
jmp try_end
|
||||
ok=$
|
||||
xor eax,eax
|
||||
inc eax
|
||||
try_end=$
|
||||
}
|
||||
macro SimpleCriticalSection name
|
||||
{
|
||||
; iglobal
|
||||
name dd 0
|
||||
dd 0
|
||||
name#.type=2
|
||||
; endg
|
||||
}
|
||||
macro WaitSimpleCriticalSection name
|
||||
{
|
||||
local start_wait,first_wait,inc_counter,end_wait
|
||||
push eax
|
||||
mov eax,[TASK_BASE+second_base_address]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
start_wait=$
|
||||
cli
|
||||
cmp [name],dword 0
|
||||
jz first_wait
|
||||
cmp [name],eax
|
||||
jz inc_counter
|
||||
sti
|
||||
call change_task
|
||||
jmp start_wait
|
||||
first_wait=$
|
||||
mov [name],eax
|
||||
mov [name+4],dword 1
|
||||
jmp end_wait
|
||||
inc_counter=$
|
||||
inc dword [name+4]
|
||||
end_wait=$
|
||||
sti
|
||||
pop eax
|
||||
}
|
||||
macro ReleaseSimpleCriticalSection name
|
||||
{
|
||||
local release_end
|
||||
dec dword [name+4]
|
||||
jnz release_end
|
||||
mov [name],dword 0
|
||||
release_end=$
|
||||
}
|
||||
macro TryWaitSimpleCriticalSection name ;result in eax and in flags
|
||||
{
|
||||
local ok,try_end
|
||||
mov eax,[CURRENT_TASK+second_base_address]
|
||||
mov eax,[eax+TASKDATA.pid]
|
||||
cmp [name],eax
|
||||
jz ok
|
||||
cmp [name],0
|
||||
jz ok
|
||||
xor eax,eax
|
||||
jmp try_end
|
||||
ok=$
|
||||
xor eax,eax
|
||||
inc eax
|
||||
try_end=$
|
||||
}
|
||||
_cli equ call MEM_HeapLock
|
||||
_sti equ call MEM_HeapUnLock
|
||||
end if
|
||||
|
828
kernel/branches/core/sys32.inc
Normal file
828
kernel/branches/core/sys32.inc
Normal file
@ -0,0 +1,828 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; ;;
|
||||
;; MenuetOS process management, protected ring3 ;;
|
||||
;; ;;
|
||||
;; Distributed under GPL. See file COPYING for details. ;;
|
||||
;; Copyright 2003 Ville Turjanmaa ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 982 $
|
||||
|
||||
|
||||
align 4
|
||||
idtreg:
|
||||
dw 8*0x41-1
|
||||
dd idts+8
|
||||
|
||||
build_interrupt_table:
|
||||
|
||||
mov edi, idts+8
|
||||
mov esi, sys_int
|
||||
mov ecx, 0x40
|
||||
@@:
|
||||
lodsd
|
||||
mov [edi], ax ; lower part of offset
|
||||
mov [edi+2], word os_code ; segment selector
|
||||
mov ax, word 10001110b shl 8 ; type: interrupt gate
|
||||
mov [edi+4], eax
|
||||
add edi, 8
|
||||
loop @b
|
||||
|
||||
;mov edi,8*0x40+idts+8
|
||||
mov dword [edi], (i40 and 0xFFFF) or (os_code shl 16)
|
||||
mov dword [edi+4], (11101111b shl 8) or (i40 and 0xFFFF0000)
|
||||
; type: trap gate
|
||||
ret
|
||||
|
||||
iglobal
|
||||
|
||||
msg_sel_ker db "kernel", 0
|
||||
msg_sel_app db "application", 0
|
||||
|
||||
sys_int:
|
||||
dd e0,debug_exc,e2,e3
|
||||
dd e4,e5,e6,e7
|
||||
dd e8,e9,e10,e11
|
||||
dd e12,e13,page_fault_handler,e15
|
||||
|
||||
dd except_16, e17,e18, except_19
|
||||
times 12 dd unknown_interrupt
|
||||
|
||||
dd irq0, irq_serv.irq_1, irq_serv.irq_2
|
||||
if USE_COM_IRQ
|
||||
dd irq_serv.irq_3, irq_serv.irq_4
|
||||
else
|
||||
dd p_irq3, p_irq4
|
||||
end if
|
||||
dd irq_serv.irq_5, p_irq6, 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,irqD ,p_irq14,p_irq15
|
||||
|
||||
times 16 dd unknown_interrupt
|
||||
|
||||
dd i40
|
||||
endg
|
||||
|
||||
macro save_ring3_context
|
||||
{
|
||||
pushad
|
||||
}
|
||||
macro restore_ring3_context
|
||||
{
|
||||
popad
|
||||
}
|
||||
|
||||
; simply return control to interrupted process
|
||||
unknown_interrupt:
|
||||
iret
|
||||
|
||||
macro exc_wo_code [num]
|
||||
{
|
||||
forward
|
||||
e#num :
|
||||
save_ring3_context
|
||||
mov bl, num
|
||||
jmp exc_c
|
||||
}
|
||||
|
||||
macro exc_w_code [num]
|
||||
{
|
||||
forward
|
||||
e#num :
|
||||
add esp, 4
|
||||
save_ring3_context
|
||||
mov bl, num
|
||||
jmp exc_c
|
||||
}
|
||||
|
||||
exc_wo_code 0, 2, 3, 4, 5, 6, 9, 15, 18
|
||||
exc_w_code 8, 10, 11, 12, 13, 14, 17
|
||||
|
||||
exc_c:
|
||||
mov ax, app_data ;èñêëþ÷åíèå
|
||||
mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè
|
||||
mov es, ax ;â ðåãèñòðû
|
||||
|
||||
; redirect to V86 manager? (EFLAGS & 0x20000) != 0?
|
||||
test byte [esp+20h+8+2], 2
|
||||
jnz v86_exc_c
|
||||
|
||||
; test if debugging
|
||||
cli
|
||||
mov eax, [current_slot]
|
||||
mov eax, [eax+APPDATA.debugger_slot]
|
||||
test eax, eax
|
||||
jnz .debug
|
||||
sti
|
||||
; not debuggee => say error and terminate
|
||||
movzx eax, bl
|
||||
mov [error_interrupt], eax
|
||||
call show_error_parameters
|
||||
add esp, 0x20
|
||||
mov edx, [TASK_BASE]
|
||||
mov [edx + TASKDATA.state], byte 4
|
||||
|
||||
jmp change_task
|
||||
|
||||
.debug:
|
||||
; we are debugged process, notify debugger and suspend ourself
|
||||
; eax=debugger PID
|
||||
cld
|
||||
movzx ecx, bl
|
||||
push ecx
|
||||
mov ecx, [TASK_BASE]
|
||||
push dword [ecx+TASKDATA.pid] ; PID of current process
|
||||
push 12
|
||||
pop ecx
|
||||
push 1 ; 1=exception
|
||||
call debugger_notify
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
mov edx, [TASK_BASE]
|
||||
mov byte [edx+TASKDATA.state], 1 ; suspended
|
||||
call change_task
|
||||
restore_ring3_context
|
||||
iretd
|
||||
|
||||
iglobal
|
||||
hexletters db '0123456789ABCDEF'
|
||||
error_interrupt dd -1
|
||||
endg
|
||||
|
||||
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
show_error_parameters:
|
||||
mov eax,[CURRENT_TASK]
|
||||
shl eax, 5
|
||||
DEBUGF 1, "K : Process - forced terminate PID: %x\n", [CURRENT_TASK + TASKDATA.pid + eax]
|
||||
mov eax, [error_interrupt]
|
||||
cmp al, 0x08
|
||||
jne @f
|
||||
DEBUGF 1, "K : Double fault\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0a
|
||||
jne @f
|
||||
DEBUGF 1, "K : Invalid TSS\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0b
|
||||
jne @f
|
||||
DEBUGF 1, "K : Segment not present\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0c
|
||||
jne @f
|
||||
DEBUGF 1, "K : Stack fault\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0d
|
||||
jne @f
|
||||
DEBUGF 1, "K : General protection fault\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0e
|
||||
jne @f
|
||||
DEBUGF 1, "K : Page fault\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
DEBUGF 1, "K : Undefined Exception\n"
|
||||
defined_error:
|
||||
DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [esp + 0x20], [esp - 12 + 0x20], [esp - 4 + 0x20]
|
||||
DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [esp - 8 + 0x20], [esp - 24 + 0x20], [esp - 28 + 0x20]
|
||||
DEBUGF 1, "K : EBP : %x EIP : %x ", [esp - 20 + 0x20], [esp + 4 + 0x20]
|
||||
|
||||
mov eax, [esp + 8 + 0x20]
|
||||
mov edi, msg_sel_app
|
||||
mov ebx, [esp + 16 + 0x20]
|
||||
cmp eax, app_code
|
||||
je @f
|
||||
mov edi, msg_sel_ker
|
||||
mov ebx, [esp - 16 + 0x20]
|
||||
@@:
|
||||
DEBUGF 1, "ESP : %x\nK : Flags : %x CS : %x (%s)\n", ebx, [esp + 12 + 0x20], eax, edi
|
||||
ret
|
||||
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
|
||||
; irq1 -> hid/keyboard.inc
|
||||
macro irqh [num]
|
||||
{
|
||||
forward
|
||||
p_irq#num :
|
||||
mov edi, num
|
||||
jmp irqhandler
|
||||
}
|
||||
|
||||
irqh 2,3,4,5,7,8,9,10,11
|
||||
|
||||
|
||||
p_irq6:
|
||||
save_ring3_context
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov edi, 6
|
||||
cmp [v86_irqhooks+edi*8], 0
|
||||
jnz v86_irq2
|
||||
call fdc_irq
|
||||
call ready_for_next_irq
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
|
||||
p_irq14:
|
||||
save_ring3_context
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov edi, 14
|
||||
cmp [v86_irqhooks+edi*8], 0
|
||||
jnz v86_irq2
|
||||
; mov byte [BOOT_VAR + 0x48E], 0xFF
|
||||
call [irq14_func]
|
||||
call ready_for_next_irq_1
|
||||
restore_ring3_context
|
||||
iret
|
||||
p_irq15:
|
||||
save_ring3_context
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov edi, 15
|
||||
cmp [v86_irqhooks+edi*8], 0
|
||||
jnz v86_irq2
|
||||
; mov byte [BOOT_VAR + 0x48E], 0xFF
|
||||
call [irq15_func]
|
||||
call ready_for_next_irq_1
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
ready_for_next_irq:
|
||||
mov [check_idle_semaphore],5
|
||||
mov al, 0x20
|
||||
out 0x20, al
|
||||
ret
|
||||
|
||||
ready_for_next_irq_1:
|
||||
mov [check_idle_semaphore],5
|
||||
mov al, 0x20
|
||||
out 0xa0,al
|
||||
out 0x20, al
|
||||
ret
|
||||
|
||||
irqD:
|
||||
save_ring3_context
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov dx,0xf0
|
||||
mov al,0
|
||||
out dx,al
|
||||
|
||||
mov dx,0xa0
|
||||
mov al,0x20
|
||||
out dx,al
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
restore_ring3_context
|
||||
|
||||
iret
|
||||
|
||||
|
||||
irqhandler:
|
||||
|
||||
mov esi,edi ; 1
|
||||
shl esi,6 ; 1
|
||||
add esi,irq00read ; 1
|
||||
shl edi,12 ; 1
|
||||
add edi,IRQ_SAVE
|
||||
mov ecx,16
|
||||
|
||||
irqnewread:
|
||||
dec ecx
|
||||
js irqover
|
||||
|
||||
movzx edx, word [esi] ; 2+
|
||||
|
||||
test edx, edx ; 1
|
||||
jz irqover
|
||||
|
||||
|
||||
mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size
|
||||
mov eax, 4000 ; + 0x4 dword - data begin offset
|
||||
cmp ebx, eax
|
||||
je irqfull
|
||||
add ebx, [edi + 0x4] ; add data size to data begin offset
|
||||
cmp ebx, eax ; if end of buffer, begin cycle again
|
||||
jb @f
|
||||
|
||||
xor ebx, ebx
|
||||
|
||||
@@:
|
||||
add ebx, edi
|
||||
movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word
|
||||
dec eax
|
||||
jz irqbyte
|
||||
dec eax
|
||||
jnz noirqword
|
||||
|
||||
in ax,dx
|
||||
cmp ebx, 3999 ; check for address odd in the end of buffer
|
||||
jne .odd
|
||||
mov [ebx + 0x10], ax
|
||||
jmp .add_size
|
||||
.odd:
|
||||
mov [ebx + 0x10], al ; I could make mistake here :)
|
||||
mov [edi + 0x10], ah
|
||||
.add_size:
|
||||
add dword [edi], 2
|
||||
jmp nextport
|
||||
|
||||
|
||||
irqbyte:
|
||||
in al,dx
|
||||
mov [ebx + 0x10],al
|
||||
inc dword [edi]
|
||||
nextport:
|
||||
add esi,4
|
||||
jmp irqnewread
|
||||
|
||||
|
||||
noirqword:
|
||||
irqfull:
|
||||
irqover:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
set_application_table_status:
|
||||
push eax
|
||||
|
||||
mov eax,[CURRENT_TASK]
|
||||
shl eax, 5
|
||||
add eax,CURRENT_TASK+TASKDATA.pid
|
||||
mov eax,[eax]
|
||||
|
||||
mov [application_table_status],eax
|
||||
|
||||
pop eax
|
||||
|
||||
ret
|
||||
|
||||
|
||||
clear_application_table_status:
|
||||
push eax
|
||||
|
||||
mov eax,[CURRENT_TASK]
|
||||
shl eax, 5
|
||||
add eax,CURRENT_TASK+TASKDATA.pid
|
||||
mov eax,[eax]
|
||||
|
||||
cmp eax,[application_table_status]
|
||||
jne apptsl1
|
||||
mov [application_table_status],0
|
||||
apptsl1:
|
||||
|
||||
pop eax
|
||||
|
||||
ret
|
||||
|
||||
sys_resize_app_memory:
|
||||
; eax = 1 - resize
|
||||
; ebx = new amount of memory
|
||||
|
||||
cmp eax,1
|
||||
jne .no_application_mem_resize
|
||||
|
||||
stdcall new_mem_resize, ebx
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
|
||||
.no_application_mem_resize:
|
||||
ret
|
||||
|
||||
sys_threads:
|
||||
|
||||
; eax=1 create thread
|
||||
;
|
||||
; ebx=thread start
|
||||
; ecx=thread stack value
|
||||
;
|
||||
; on return : eax = pid
|
||||
jmp new_sys_threads
|
||||
|
||||
iglobal
|
||||
process_terminating db 'K : Process - terminating',13,10,0
|
||||
process_terminated db 'K : Process - done',13,10,0
|
||||
msg_obj_destroy db 'K : destroy app object',13,10,0
|
||||
endg
|
||||
|
||||
; param
|
||||
; esi= slot
|
||||
|
||||
terminate: ; terminate application
|
||||
|
||||
.slot equ esp ;locals
|
||||
|
||||
push esi ;save .slot
|
||||
|
||||
shl esi, 8
|
||||
cmp [SLOT_BASE+esi+APPDATA.dir_table], 0
|
||||
jne @F
|
||||
pop esi
|
||||
shl esi, 5
|
||||
mov [CURRENT_TASK+esi+TASKDATA.state], 9
|
||||
ret
|
||||
@@:
|
||||
;mov esi,process_terminating
|
||||
;call sys_msg_board_str
|
||||
DEBUGF 1,"%s",process_terminating
|
||||
@@:
|
||||
cli
|
||||
cmp [application_table_status],0
|
||||
je term9
|
||||
sti
|
||||
call change_task
|
||||
jmp @b
|
||||
term9:
|
||||
call set_application_table_status
|
||||
|
||||
; if the process is in V86 mode...
|
||||
mov eax, [.slot]
|
||||
shl eax, 8
|
||||
mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack]
|
||||
add esi, RING0_STACK_SIZE
|
||||
cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi
|
||||
jz .nov86
|
||||
; ...it has page directory for V86 mode
|
||||
mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0]
|
||||
mov ecx, [esi+4]
|
||||
mov [eax+SLOT_BASE+APPDATA.dir_table], ecx
|
||||
; ...and I/O permission map for V86 mode
|
||||
mov ecx, [esi+12]
|
||||
mov [eax+SLOT_BASE+APPDATA.io_map], ecx
|
||||
mov ecx, [esi+8]
|
||||
mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx
|
||||
.nov86:
|
||||
|
||||
mov esi, [.slot]
|
||||
shl esi,8
|
||||
add esi, SLOT_BASE+APP_OBJ_OFFSET
|
||||
@@:
|
||||
mov eax, [esi+APPOBJ.fd]
|
||||
test eax, eax
|
||||
jz @F
|
||||
|
||||
cmp eax, esi
|
||||
je @F
|
||||
|
||||
push esi
|
||||
call [eax+APPOBJ.destroy]
|
||||
DEBUGF 1,"%s",msg_obj_destroy
|
||||
pop esi
|
||||
jmp @B
|
||||
@@:
|
||||
mov eax, [.slot]
|
||||
shl eax, 8
|
||||
mov eax,[SLOT_BASE+eax+APPDATA.dir_table]
|
||||
stdcall destroy_app_space, eax
|
||||
|
||||
mov esi, [.slot]
|
||||
cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1
|
||||
jne @F
|
||||
|
||||
mov [fpu_owner],1
|
||||
mov eax, [256+SLOT_BASE+APPDATA.fpu_state]
|
||||
clts
|
||||
bt [cpu_caps], CAPS_SSE
|
||||
jnc .no_SSE
|
||||
fxrstor [eax]
|
||||
jmp @F
|
||||
.no_SSE:
|
||||
fnclex
|
||||
frstor [eax]
|
||||
@@:
|
||||
|
||||
mov [KEY_COUNT],byte 0 ; empty keyboard buffer
|
||||
mov [BTN_COUNT],byte 0 ; empty button buffer
|
||||
|
||||
|
||||
; remove defined hotkeys
|
||||
mov eax, hotkey_list
|
||||
.loop:
|
||||
cmp [eax+8], esi
|
||||
jnz .cont
|
||||
mov ecx, [eax]
|
||||
jecxz @f
|
||||
push dword [eax+12]
|
||||
pop dword [ecx+12]
|
||||
@@:
|
||||
mov ecx, [eax+12]
|
||||
push dword [eax]
|
||||
pop dword [ecx]
|
||||
xor ecx, ecx
|
||||
mov [eax], ecx
|
||||
mov [eax+4], ecx
|
||||
mov [eax+8], ecx
|
||||
mov [eax+12], ecx
|
||||
.cont:
|
||||
add eax, 16
|
||||
cmp eax, hotkey_list+256*16
|
||||
jb .loop
|
||||
; remove hotkeys in buffer
|
||||
mov eax, hotkey_buffer
|
||||
.loop2:
|
||||
cmp [eax], esi
|
||||
jnz .cont2
|
||||
and dword [eax+4], 0
|
||||
and dword [eax], 0
|
||||
.cont2:
|
||||
add eax, 8
|
||||
cmp eax, hotkey_buffer+120*8
|
||||
jb .loop2
|
||||
|
||||
mov ecx,esi ; remove buttons
|
||||
bnewba2:
|
||||
mov edi,[BTN_ADDR]
|
||||
mov eax,edi
|
||||
cld
|
||||
movzx ebx,word [edi]
|
||||
inc bx
|
||||
bnewba:
|
||||
dec bx
|
||||
jz bnmba
|
||||
add eax,0x10
|
||||
cmp cx,[eax]
|
||||
jnz bnewba
|
||||
pusha
|
||||
mov ecx,ebx
|
||||
inc ecx
|
||||
shl ecx,4
|
||||
mov ebx,eax
|
||||
add eax,0x10
|
||||
call memmove
|
||||
dec dword [edi]
|
||||
popa
|
||||
jmp bnewba2
|
||||
bnmba:
|
||||
|
||||
pusha ; save window coordinates for window restoring
|
||||
cld
|
||||
shl esi,5
|
||||
add esi,window_data
|
||||
mov eax,[esi+WDATA.box.left]
|
||||
mov [dlx],eax
|
||||
add eax,[esi+WDATA.box.width]
|
||||
mov [dlxe],eax
|
||||
mov eax,[esi+WDATA.box.top]
|
||||
mov [dly],eax
|
||||
add eax,[esi+WDATA.box.height]
|
||||
mov [dlye],eax
|
||||
|
||||
xor eax, eax
|
||||
mov [esi+WDATA.box.left],eax
|
||||
mov [esi+WDATA.box.width],eax
|
||||
mov [esi+WDATA.box.top],eax
|
||||
mov [esi+WDATA.box.height],eax
|
||||
mov [esi+WDATA.cl_workarea],eax
|
||||
mov [esi+WDATA.cl_titlebar],eax
|
||||
mov [esi+WDATA.cl_frames],eax
|
||||
mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn
|
||||
lea edi, [esi-window_data+draw_data]
|
||||
mov ecx,32/4
|
||||
rep stosd
|
||||
popa
|
||||
|
||||
; debuggee test
|
||||
pushad
|
||||
mov edi, esi
|
||||
shl edi, 5
|
||||
mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot]
|
||||
test eax, eax
|
||||
jz .nodebug
|
||||
push 8
|
||||
pop ecx
|
||||
push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID
|
||||
push 2
|
||||
call debugger_notify
|
||||
pop ecx
|
||||
pop ecx
|
||||
.nodebug:
|
||||
popad
|
||||
|
||||
mov ebx, [.slot]
|
||||
shl ebx, 8
|
||||
push ebx
|
||||
mov ebx,[SLOT_BASE+ebx+APPDATA.pl0_stack]
|
||||
|
||||
stdcall kernel_free, ebx
|
||||
|
||||
pop ebx
|
||||
mov ebx,[SLOT_BASE+ebx+APPDATA.cur_dir]
|
||||
stdcall kernel_free, ebx
|
||||
|
||||
mov edi, [.slot]
|
||||
shl edi,8
|
||||
add edi,SLOT_BASE
|
||||
|
||||
mov eax, [edi+APPDATA.io_map]
|
||||
cmp eax, (tss._io_map_0-OS_BASE+PG_MAP)
|
||||
je @F
|
||||
call free_page
|
||||
@@:
|
||||
mov eax, [edi+APPDATA.io_map+4]
|
||||
cmp eax, (tss._io_map_1-OS_BASE+PG_MAP)
|
||||
je @F
|
||||
call free_page
|
||||
@@:
|
||||
mov eax, 0x20202020
|
||||
stosd
|
||||
stosd
|
||||
stosd
|
||||
mov ecx,244/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
|
||||
; activate window
|
||||
movzx eax, word [WIN_STACK + esi*2]
|
||||
cmp eax, [TASK_COUNT]
|
||||
jne .dont_activate
|
||||
pushad
|
||||
.check_next_window:
|
||||
dec eax
|
||||
cmp eax, 1
|
||||
jbe .nothing_to_activate
|
||||
lea esi, [WIN_POS+eax*2]
|
||||
movzx edi, word [esi] ; edi = process
|
||||
shl edi, 5
|
||||
cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots
|
||||
je .check_next_window
|
||||
add edi, window_data
|
||||
; \begin{diamond}[19.09.2006]
|
||||
; skip minimized windows
|
||||
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
|
||||
jnz .check_next_window
|
||||
; \end{diamond}
|
||||
call waredraw
|
||||
.nothing_to_activate:
|
||||
popad
|
||||
.dont_activate:
|
||||
|
||||
push esi ; remove hd1 & cd & flp reservation
|
||||
shl esi, 5
|
||||
mov esi, [esi+CURRENT_TASK+TASKDATA.pid]
|
||||
cmp [hd1_status], esi
|
||||
jnz @f
|
||||
call free_hd_channel
|
||||
mov [hd1_status], 0
|
||||
@@:
|
||||
cmp [cd_status], esi
|
||||
jnz @f
|
||||
call free_cd_channel
|
||||
mov [cd_status], 0
|
||||
@@:
|
||||
cmp [flp_status], esi
|
||||
jnz @f
|
||||
mov [flp_status], 0
|
||||
@@:
|
||||
pop esi
|
||||
cmp [bgrlockpid], esi
|
||||
jnz @f
|
||||
and [bgrlockpid], 0
|
||||
mov [bgrlock], 0
|
||||
@@:
|
||||
|
||||
pusha ; remove all irq reservations
|
||||
mov eax,esi
|
||||
shl eax, 5
|
||||
mov eax,[eax+CURRENT_TASK+TASKDATA.pid]
|
||||
mov edi,irq_owner
|
||||
xor ebx, ebx
|
||||
xor edx, edx
|
||||
newirqfree:
|
||||
cmp [edi + 4 * ebx], eax
|
||||
jne nofreeirq
|
||||
mov [edi + 4 * ebx], edx ; remove irq reservation
|
||||
mov [irq_tab + 4 * ebx], edx ; remove irq handler
|
||||
mov [irq_rights + 4 * ebx], edx ; set access rights to full access
|
||||
nofreeirq:
|
||||
inc ebx
|
||||
cmp ebx, 16
|
||||
jb newirqfree
|
||||
popa
|
||||
|
||||
pusha ; remove all port reservations
|
||||
mov edx,esi
|
||||
shl edx, 5
|
||||
add edx,CURRENT_TASK
|
||||
mov edx,[edx+TASKDATA.pid]
|
||||
|
||||
rmpr0:
|
||||
|
||||
mov esi,[RESERVED_PORTS]
|
||||
|
||||
cmp esi,0
|
||||
je rmpr9
|
||||
|
||||
rmpr3:
|
||||
|
||||
mov edi,esi
|
||||
shl edi,4
|
||||
add edi,RESERVED_PORTS
|
||||
|
||||
cmp edx,[edi]
|
||||
je rmpr4
|
||||
|
||||
dec esi
|
||||
jnz rmpr3
|
||||
|
||||
jmp rmpr9
|
||||
|
||||
rmpr4:
|
||||
|
||||
mov ecx,256
|
||||
sub ecx,esi
|
||||
shl ecx,4
|
||||
|
||||
mov esi,edi
|
||||
add esi,16
|
||||
cld
|
||||
rep movsb
|
||||
|
||||
dec dword [RESERVED_PORTS]
|
||||
|
||||
jmp rmpr0
|
||||
|
||||
rmpr9:
|
||||
|
||||
popa
|
||||
mov edi,esi ; do not run this process slot
|
||||
shl edi, 5
|
||||
mov [edi+CURRENT_TASK + TASKDATA.state],byte 9
|
||||
; debugger test - terminate all debuggees
|
||||
mov eax, 2
|
||||
mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot
|
||||
.xd0:
|
||||
cmp eax, [TASK_COUNT]
|
||||
ja .xd1
|
||||
cmp dword [ecx], esi
|
||||
jnz @f
|
||||
and dword [ecx], 0
|
||||
pushad
|
||||
xchg eax, ecx
|
||||
mov ebx, 2
|
||||
call sys_system
|
||||
popad
|
||||
@@:
|
||||
inc eax
|
||||
add ecx, 0x100
|
||||
jmp .xd0
|
||||
.xd1:
|
||||
; call systest
|
||||
sti ; .. and life goes on
|
||||
|
||||
mov eax, [dlx]
|
||||
mov ebx, [dly]
|
||||
mov ecx, [dlxe]
|
||||
mov edx, [dlye]
|
||||
call calculatescreen
|
||||
xor eax, eax
|
||||
xor esi, esi
|
||||
call redrawscreen
|
||||
|
||||
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
|
||||
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
|
||||
|
||||
mov [application_table_status],0
|
||||
;mov esi,process_terminated
|
||||
;call sys_msg_board_str
|
||||
DEBUGF 1,"%s",process_terminated
|
||||
add esp, 4
|
||||
ret
|
||||
restore .slot
|
||||
|
||||
iglobal
|
||||
boot_sched_1 db 'Building gdt tss pointer',0
|
||||
boot_sched_2 db 'Building IDT table',0
|
||||
endg
|
||||
|
||||
|
||||
build_scheduler:
|
||||
|
||||
mov esi,boot_sched_1
|
||||
call boot_log
|
||||
; call build_process_gdt_tss_pointer
|
||||
|
||||
; mov esi,boot_sched_2
|
||||
; call boot_log
|
||||
|
||||
ret
|
266
kernel/branches/core/syscall.inc
Normal file
266
kernel/branches/core/syscall.inc
Normal file
@ -0,0 +1,266 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 940 $
|
||||
|
||||
; Old style system call converter
|
||||
align 16
|
||||
cross_order:
|
||||
; load all registers in crossed order
|
||||
mov eax, ebx
|
||||
mov ebx, ecx
|
||||
mov ecx, edx
|
||||
mov edx, esi
|
||||
mov esi, edi
|
||||
mov edi, [esp+28 + 4]
|
||||
and edi,0xff
|
||||
call dword [servetable+edi*4]
|
||||
ret
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SYSTEM CALL ENTRY ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
align 16
|
||||
i40:
|
||||
pushad
|
||||
cld
|
||||
movzx eax, al
|
||||
call dword [servetable2 + eax * 4]
|
||||
popad
|
||||
iretd
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SYSENTER ENTRY ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
align 32
|
||||
sysenter_entry:
|
||||
; Íàñòðàèâàåì ñòåê
|
||||
mov esp, [ss:tss._esp0]
|
||||
sti
|
||||
push ebp ; save app esp + 4
|
||||
mov ebp, [ebp] ; ebp - original ebp
|
||||
;------------------
|
||||
pushad
|
||||
cld
|
||||
|
||||
movzx eax, al
|
||||
call dword [servetable2 + eax * 4]
|
||||
|
||||
popad
|
||||
;------------------
|
||||
xchg ecx, [ss:esp] ; â âåðøèí ñòåêà - app ecx, ecx - app esp + 4
|
||||
sub ecx, 4
|
||||
xchg edx, [ecx] ; edx - return point, & save original edx
|
||||
push edx
|
||||
mov edx, [ss:esp + 4]
|
||||
mov [ecx + 4], edx ; save original ecx
|
||||
pop edx
|
||||
sysexit
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SYSCALL ENTRY ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
align 32
|
||||
syscall_entry:
|
||||
; cli syscall clear IF
|
||||
xchg esp, [ss:tss._esp0]
|
||||
push ecx
|
||||
lea ecx, [esp+4]
|
||||
xchg ecx, [ss:tss._esp0]
|
||||
sti
|
||||
push ecx
|
||||
mov ecx, [ecx]
|
||||
;------------------
|
||||
pushad
|
||||
cld
|
||||
|
||||
movzx eax, al
|
||||
call dword [servetable2 + eax * 4]
|
||||
|
||||
popad
|
||||
;------------------
|
||||
mov ecx, [ss:esp+4]
|
||||
pop esp
|
||||
sysret
|
||||
iglobal
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SYSTEM FUNCTIONS TABLE ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
align 4
|
||||
servetable:
|
||||
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd sys_midi ; 20-ResetMidi and OutputMidi
|
||||
dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
|
||||
dd sys_settime ; 22-setting date,time,clock and alarm-clock
|
||||
dd 0
|
||||
dd syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist
|
||||
dd 0 ;
|
||||
dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
|
||||
dd 0
|
||||
dd 0 ;
|
||||
dd 0
|
||||
dd sys_current_directory ; 30-Get/SetCurrentDirectory
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd readmousepos ; 37-GetMousePosition_ScreenRelative,.
|
||||
dd 0 ; 38-DrawLine
|
||||
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd sys_outport ; 43-SendDeviceData
|
||||
dd 0
|
||||
dd 0
|
||||
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
|
||||
dd display_number ; 47-WriteNum
|
||||
dd display_settings ; 48-SetRedrawType and SetButtonType
|
||||
dd sys_apm ; 49-Advanced Power Management (APM)
|
||||
dd random_shaped_window ; 50-Window shape & scale
|
||||
dd syscall_threads ; 51-Threads
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd sound_interface ; 55-Sound interface
|
||||
dd 0
|
||||
dd sys_pcibios ; 57-PCI BIOS32
|
||||
dd file_system ; 58-Common file system interface
|
||||
dd 0
|
||||
dd sys_IPC ; 60-Inter Process Communication
|
||||
dd sys_gs ; 61-Direct graphics access
|
||||
dd sys_pci ; 62-PCI functions
|
||||
dd sys_msg_board ; 63-System message board
|
||||
dd sys_resize_app_memory ; 64-Resize application memory usage
|
||||
dd syscall_putimage_palette; 65-PutImagePalette
|
||||
dd sys_process_def ; 66-Process definitions - keyboard
|
||||
dd sys_window_move ; 67-Window move or resize
|
||||
dd f68 ; 68-Some internal services
|
||||
dd sys_debug_services ; 69-Debug
|
||||
dd file_system_lfn ; 70-Common file system interface, version 2
|
||||
dd syscall_windowsettings ; 71-Window settings
|
||||
dd sys_sendwindowmsg ; 72-Send window message
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; NEW SYSTEM FUNCTIONS TABLE ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
align 4
|
||||
servetable2:
|
||||
|
||||
dd sys_drawwindow ; 0-DrawWindow
|
||||
dd syscall_setpixel ; 1-SetPixel
|
||||
dd sys_getkey ; 2-GetKey
|
||||
dd sys_clock ; 3-GetTime
|
||||
dd syscall_writetext ; 4-WriteText
|
||||
dd delay_hs ; 5-DelayHs
|
||||
dd syscall_openramdiskfile ; 6-OpenRamdiskFile
|
||||
dd syscall_putimage ; 7-PutImage
|
||||
dd sys_button ; 8-DefineButton
|
||||
dd sys_cpuusage ; 9-GetProcessInfo
|
||||
dd sys_waitforevent ; 10-WaitForEvent
|
||||
dd sys_getevent ; 11-CheckForEvent
|
||||
dd sys_redrawstat ; 12-BeginDraw and EndDraw
|
||||
dd syscall_drawrect ; 13-DrawRect
|
||||
dd syscall_getscreensize ; 14-GetScreenSize
|
||||
dd sys_background ; 15-bgr
|
||||
dd sys_cachetodiskette ; 16-FlushFloppyCache
|
||||
dd sys_getbutton ; 17-GetButton
|
||||
dd sys_system ; 18-System Services
|
||||
dd paleholder ; 19-reserved
|
||||
dd cross_order ; 20-ResetMidi and OutputMidi
|
||||
dd cross_order ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
|
||||
dd cross_order ; 22-setting date,time,clock and alarm-clock
|
||||
dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent
|
||||
dd cross_order ; 24-PlayCdTrack,StopCd and GetCdPlaylist
|
||||
dd undefined_syscall ; 25-reserved
|
||||
dd cross_order ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
|
||||
dd undefined_syscall ; 27-reserved
|
||||
dd undefined_syscall ; 28-reserved
|
||||
dd sys_date ; 29-GetDate
|
||||
dd cross_order ; 30-Get/SetCurrentDirectory
|
||||
dd undefined_syscall ; 31-reserved
|
||||
dd undefined_syscall ; 32-reserved
|
||||
dd undefined_syscall ; 33-reserved
|
||||
dd undefined_syscall ; 34-reserved
|
||||
dd syscall_getpixel ; 35-GetPixel
|
||||
dd syscall_getarea ; 36-GetArea
|
||||
dd cross_order ; 37-GetMousePosition_ScreenRelative,.
|
||||
dd syscall_drawline ; 38-DrawLine
|
||||
dd cross_order ; 39-GetBackgroundSize,ReadBgrData,.
|
||||
dd set_app_param ; 40-WantEvents
|
||||
dd syscall_getirqowner ; 41-GetIrqOwner
|
||||
dd get_irq_data ; 42-ReadIrqData
|
||||
dd cross_order ; 43-SendDeviceData
|
||||
dd sys_programirq ; 44-ProgramIrqs
|
||||
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq
|
||||
dd cross_order ; 46-ReservePortArea and FreePortArea
|
||||
dd cross_order ; 47-WriteNum
|
||||
dd cross_order ; 48-SetRedrawType and SetButtonType
|
||||
dd cross_order ; 49-Advanced Power Management (APM)
|
||||
dd cross_order ; 50-Window shape & scale
|
||||
dd cross_order ; 51-Threads
|
||||
dd cross_order ; 52-Stack driver status
|
||||
dd cross_order ; 53-Socket interface
|
||||
dd undefined_syscall ; 54-reserved
|
||||
dd cross_order ; 55-Sound interface
|
||||
dd undefined_syscall ; 56-reserved
|
||||
dd cross_order ; 57-PCI BIOS32
|
||||
dd cross_order ; 58-Common file system interface
|
||||
dd undefined_syscall ; 59-reserved
|
||||
dd cross_order ; 60-Inter Process Communication
|
||||
dd cross_order ; 61-Direct graphics access
|
||||
dd cross_order ; 62-PCI functions
|
||||
dd cross_order ; 63-System message board
|
||||
dd cross_order ; 64-Resize application memory usage
|
||||
dd cross_order ; 65-PutImagePalette
|
||||
dd cross_order ; 66-Process definitions - keyboard
|
||||
dd cross_order ; 67-Window move or resize
|
||||
dd cross_order ; 68-Some internal services
|
||||
dd cross_order ; 69-Debug
|
||||
dd cross_order ; 70-Common file system interface, version 2
|
||||
dd cross_order ; 71-Window settings
|
||||
dd cross_order ; 72-Send window message
|
||||
dd sys_network ; 73-Network stack
|
||||
dd sys_socket ; 74-Sockets
|
||||
dd sys_protocols ; 75-Protocols
|
||||
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
|
||||
dd sys_end ; -1-end application
|
||||
|
||||
endg
|
1111
kernel/branches/core/taskman.inc
Normal file
1111
kernel/branches/core/taskman.inc
Normal file
File diff suppressed because it is too large
Load Diff
956
kernel/branches/core/v86.inc
Normal file
956
kernel/branches/core/v86.inc
Normal file
@ -0,0 +1,956 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2007-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 979 $
|
||||
|
||||
; Virtual-8086 mode manager
|
||||
; diamond, 2007, 2008
|
||||
|
||||
DEBUG_SHOW_IO = 0
|
||||
|
||||
struc V86_machine
|
||||
{
|
||||
; page directory
|
||||
.pagedir dd ?
|
||||
; translation table: V86 address -> flat linear address
|
||||
.pages dd ?
|
||||
; mutex to protect all data from writing by multiple threads at one time
|
||||
.mutex dd ?
|
||||
; i/o permission map
|
||||
.iopm dd ?
|
||||
.size = $
|
||||
}
|
||||
virtual at 0
|
||||
V86_machine V86_machine
|
||||
end virtual
|
||||
|
||||
; Create V86 machine
|
||||
; in: nothing
|
||||
; out: eax = handle (pointer to struc V86_machine)
|
||||
; eax = NULL => failure
|
||||
; destroys: ebx, ecx, edx (due to malloc)
|
||||
v86_create:
|
||||
; allocate V86_machine structure
|
||||
mov eax, V86_machine.size
|
||||
call malloc
|
||||
test eax, eax
|
||||
jz .fail
|
||||
; initialize mutex
|
||||
and dword [eax+V86_machine.mutex], 0
|
||||
; allocate tables
|
||||
mov ebx, eax
|
||||
; We allocate 4 pages.
|
||||
; First is main page directory for V86 mode.
|
||||
; Second page:
|
||||
; first half (0x800 bytes) is page table for addresses 0 - 0x100000,
|
||||
; second half is for V86-to-linear translation.
|
||||
; Third and fourth are for I/O permission map.
|
||||
push 8000h ; blocks less than 8 pages are discontinuous
|
||||
call kernel_alloc
|
||||
test eax, eax
|
||||
jz .fail2
|
||||
mov [ebx+V86_machine.pagedir], eax
|
||||
push edi eax
|
||||
mov edi, eax
|
||||
add eax, 1800h
|
||||
mov [ebx+V86_machine.pages], eax
|
||||
; initialize tables
|
||||
mov ecx, 2000h/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
mov [ebx+V86_machine.iopm], edi
|
||||
dec eax
|
||||
mov ecx, 2000h/4
|
||||
rep stosd
|
||||
pop eax
|
||||
; page directory: first entry is page table...
|
||||
mov edi, eax
|
||||
add eax, 1000h
|
||||
push eax
|
||||
call get_pg_addr
|
||||
or al, PG_UW
|
||||
stosd
|
||||
; ...and also copy system page tables
|
||||
; thx to Serge, system is located at high addresses
|
||||
add edi, (OS_BASE shr 20) - 4
|
||||
push esi
|
||||
mov esi, (OS_BASE shr 20) + sys_pgdir
|
||||
mov ecx, 0x80000000 shr 22
|
||||
rep movsd
|
||||
|
||||
mov eax, [ebx+V86_machine.pagedir] ;root dir also is
|
||||
call get_pg_addr ;used as page table
|
||||
or al, PG_SW
|
||||
mov [edi-4096+(page_tabs shr 20)], eax
|
||||
|
||||
pop esi
|
||||
; now V86 specific: initialize known addresses in first Mb
|
||||
pop eax
|
||||
; first page - BIOS data (shared between all machines!)
|
||||
; physical address = 0x2f0000
|
||||
; linear address = BOOT_VAR = OS_BASE + 0x2f0000
|
||||
mov dword [eax], (BOOT_VAR - OS_BASE) or 111b
|
||||
mov dword [eax+800h], BOOT_VAR
|
||||
; page before 0xA0000 - Extended BIOS Data Area (shared between all machines!)
|
||||
; physical address = 0x9C000
|
||||
; linear address = 0x8009C000
|
||||
; (I have seen one computer with EBDA segment = 0x9D80,
|
||||
; all other computers use less memory)
|
||||
mov ecx, 4
|
||||
mov edx, 0x9C000
|
||||
push eax
|
||||
lea edi, [eax+0x9C*4]
|
||||
@@:
|
||||
lea eax, [edx + OS_BASE]
|
||||
mov [edi+800h], eax
|
||||
lea eax, [edx + 111b]
|
||||
stosd
|
||||
add edx, 0x1000
|
||||
loop @b
|
||||
pop eax
|
||||
pop edi
|
||||
; addresses 0xC0000 - 0xFFFFF - BIOS code (shared between all machines!)
|
||||
; physical address = 0xC0000
|
||||
; linear address = 0x800C0000
|
||||
mov ecx, 0xC0
|
||||
@@:
|
||||
mov edx, ecx
|
||||
shl edx, 12
|
||||
push edx
|
||||
or edx, 111b
|
||||
mov [eax+ecx*4], edx
|
||||
pop edx
|
||||
add edx, OS_BASE
|
||||
mov [eax+ecx*4+0x800], edx
|
||||
inc cl
|
||||
jnz @b
|
||||
mov eax, ebx
|
||||
ret
|
||||
.fail2:
|
||||
mov eax, ebx
|
||||
call free
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
; Destroy V86 machine
|
||||
; in: eax = handle
|
||||
; out: nothing
|
||||
; destroys: eax, ebx, ecx, edx (due to free)
|
||||
v86_destroy:
|
||||
push eax
|
||||
stdcall kernel_free, [eax+V86_machine.pagedir]
|
||||
pop eax
|
||||
jmp free
|
||||
|
||||
; Translate V86-address to linear address
|
||||
; in: eax=V86 address
|
||||
; esi=handle
|
||||
; out: eax=linear address
|
||||
; destroys: nothing
|
||||
v86_get_lin_addr:
|
||||
push ecx edx
|
||||
mov ecx, eax
|
||||
mov edx, [esi+V86_machine.pages]
|
||||
shr ecx, 12
|
||||
and eax, 0xFFF
|
||||
add eax, [edx+ecx*4] ; atomic operation, no mutex needed
|
||||
pop edx ecx
|
||||
ret
|
||||
|
||||
; Sets linear address for V86-page
|
||||
; in: eax=linear address (must be page-aligned)
|
||||
; ecx=V86 page (NOT address!)
|
||||
; esi=handle
|
||||
; out: nothing
|
||||
; destroys: nothing
|
||||
v86_set_page:
|
||||
push eax ebx
|
||||
mov ebx, [esi+V86_machine.pagedir]
|
||||
mov [ebx+ecx*4+0x1800], eax
|
||||
call get_pg_addr
|
||||
or al, 111b
|
||||
mov [ebx+ecx*4+0x1000], eax
|
||||
pop ebx eax
|
||||
ret
|
||||
|
||||
; Allocate memory in V86 machine
|
||||
; in: eax=size (in bytes)
|
||||
; esi=handle
|
||||
; out: eax=V86 address, para-aligned (0x10 multiple)
|
||||
; destroys: nothing
|
||||
; ¥¤®¯¨á !!!
|
||||
;v86_alloc:
|
||||
; push ebx ecx edx edi
|
||||
; lea ebx, [esi+V86_machine.mutex]
|
||||
; call wait_mutex
|
||||
; add eax, 0x1F
|
||||
; shr eax, 4
|
||||
; mov ebx, 0x1000 ; start with address 0x1000 (second page)
|
||||
; mov edi, [esi+V86_machine.tables]
|
||||
;.l:
|
||||
; mov ecx, ebx
|
||||
; shr ecx, 12
|
||||
; mov edx, [edi+0x1000+ecx*4] ; get linear address
|
||||
; test edx, edx ; page allocated?
|
||||
; jz .unalloc
|
||||
; mov ecx, ebx
|
||||
; and ecx, 0xFFF
|
||||
; add edx, ecx
|
||||
; cmp dword [edx], 0 ; free block?
|
||||
; jnz .n
|
||||
; cmp dword [edx+4],
|
||||
; and [esi+V86_machine.mutex], 0
|
||||
; pop edi edx ecx ebx
|
||||
; ret
|
||||
|
||||
uglobal
|
||||
sys_v86_machine dd ?
|
||||
endg
|
||||
|
||||
; Called from kernel.asm at first stages of loading
|
||||
; Initialize system V86 machine (used to simulate BIOS int 13h)
|
||||
init_sys_v86:
|
||||
call v86_create
|
||||
mov [sys_v86_machine], eax
|
||||
test eax, eax
|
||||
jz .ret
|
||||
mov byte [BOOT_VAR + 0x500], 0xCD
|
||||
mov byte [BOOT_VAR + 0x501], 0x13
|
||||
mov byte [BOOT_VAR + 0x502], 0xF4
|
||||
mov byte [BOOT_VAR + 0x503], 0xCD
|
||||
mov byte [BOOT_VAR + 0x504], 0x10
|
||||
mov byte [BOOT_VAR + 0x505], 0xF4
|
||||
mov esi, eax
|
||||
mov ebx, [eax+V86_machine.pagedir]
|
||||
; one page for stack, two pages for results (0x2000 bytes = 16 sectors)
|
||||
mov dword [ebx+0x99*4+0x1000], 0x99000 or 111b
|
||||
mov dword [ebx+0x99*4+0x1800], OS_BASE + 0x99000
|
||||
mov dword [ebx+0x9A*4+0x1000], 0x9A000 or 111b
|
||||
mov dword [ebx+0x9A*4+0x1800], OS_BASE + 0x9A000
|
||||
mov dword [ebx+0x9B*4+0x1000], 0x9B000 or 111b
|
||||
mov dword [ebx+0x9B*4+0x1800], OS_BASE + 0x9B000
|
||||
if ~DEBUG_SHOW_IO
|
||||
; allow access to all ports
|
||||
mov ecx, [esi+V86_machine.iopm]
|
||||
xor eax, eax
|
||||
mov edi, ecx
|
||||
mov ecx, 10000h/8/4
|
||||
rep stosd
|
||||
end if
|
||||
.ret:
|
||||
ret
|
||||
|
||||
struc v86_regs
|
||||
{
|
||||
; don't change the order, it is important
|
||||
.edi dd ?
|
||||
.esi dd ?
|
||||
.ebp dd ?
|
||||
dd ? ; ignored
|
||||
.ebx dd ?
|
||||
.edx dd ?
|
||||
.ecx dd ?
|
||||
.eax dd ?
|
||||
.eip dd ?
|
||||
.cs dd ?
|
||||
.eflags dd ? ; VM flag must be set!
|
||||
.esp dd ?
|
||||
.ss dd ?
|
||||
.es dd ?
|
||||
.ds dd ?
|
||||
.fs dd ?
|
||||
.gs dd ?
|
||||
.size = $
|
||||
}
|
||||
virtual at 0
|
||||
v86_regs v86_regs
|
||||
end virtual
|
||||
|
||||
; Run V86 machine
|
||||
; in: ebx -> registers for V86 (two structures: in and out)
|
||||
; esi = handle
|
||||
; ecx = expected end address (CS:IP)
|
||||
; edx = IRQ to hook or -1 if not required
|
||||
; out: structure pointed to by ebx is filled with new values
|
||||
; eax = 1 - exception has occured, cl contains code
|
||||
; eax = 2 - access to disabled i/o port, ecx contains port address
|
||||
; eax = 3 - IRQ is already hooked by another VM
|
||||
; destroys: nothing
|
||||
v86_start:
|
||||
pushad
|
||||
|
||||
cli
|
||||
|
||||
mov ecx, [CURRENT_TASK]
|
||||
shl ecx, 8
|
||||
add ecx, SLOT_BASE
|
||||
|
||||
mov eax, [esi+V86_machine.iopm]
|
||||
call get_pg_addr
|
||||
inc eax
|
||||
push dword [ecx+APPDATA.io_map]
|
||||
push dword [ecx+APPDATA.io_map+4]
|
||||
mov dword [ecx+APPDATA.io_map], eax
|
||||
mov dword [page_tabs + (tss._io_map_0 shr 10)], eax
|
||||
add eax, 0x1000
|
||||
mov dword [ecx+APPDATA.io_map+4], eax
|
||||
mov dword [page_tabs + (tss._io_map_1 shr 10)], eax
|
||||
|
||||
push [ecx+APPDATA.dir_table]
|
||||
push [ecx+APPDATA.saved_esp0]
|
||||
mov [ecx+APPDATA.saved_esp0], esp
|
||||
mov [tss._esp0], esp
|
||||
|
||||
mov eax, [esi+V86_machine.pagedir]
|
||||
call get_pg_addr
|
||||
mov [ecx+APPDATA.dir_table], eax
|
||||
mov cr3, eax
|
||||
|
||||
; mov [irq_tab+5*4], my05
|
||||
|
||||
; We do not enable interrupts, because V86 IRQ redirector assumes that
|
||||
; machine is running
|
||||
; They will be enabled by IRET.
|
||||
; sti
|
||||
|
||||
mov eax, esi
|
||||
sub esp, v86_regs.size
|
||||
mov esi, ebx
|
||||
mov edi, esp
|
||||
mov ecx, v86_regs.size/4
|
||||
rep movsd
|
||||
|
||||
cmp edx, -1
|
||||
jz .noirqhook
|
||||
uglobal
|
||||
v86_irqhooks rd 16*2
|
||||
endg
|
||||
cmp [v86_irqhooks+edx*8], 0
|
||||
jz @f
|
||||
cmp [v86_irqhooks+edx*8], eax
|
||||
jz @f
|
||||
mov esi, v86_irqerr
|
||||
call sys_msg_board_str
|
||||
inc [v86_irqhooks+edx*8+4]
|
||||
mov eax, 3
|
||||
jmp v86_exc_c.exit
|
||||
@@:
|
||||
mov [v86_irqhooks+edx*8], eax
|
||||
inc [v86_irqhooks+edx*8+4]
|
||||
.noirqhook:
|
||||
|
||||
popad
|
||||
iretd
|
||||
|
||||
; It is only possible to leave virtual-8086 mode by faulting to
|
||||
; a protected-mode interrupt handler (typically the general-protection
|
||||
; exception handler, which in turn calls the virtual 8086-mode monitor).
|
||||
|
||||
v86_debug_exc:
|
||||
pushad
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
mov bl, 1
|
||||
jmp v86_exc_c
|
||||
|
||||
v86_page_fault:
|
||||
add esp, 4
|
||||
pushad
|
||||
mov bl, 14
|
||||
jmp v86_exc_c
|
||||
|
||||
v86_except_16:
|
||||
pushad
|
||||
mov bl, 16
|
||||
jmp v86_exc_c
|
||||
v86_except_19:
|
||||
pushad
|
||||
mov bl, 19
|
||||
|
||||
iglobal
|
||||
v86_exc_str1 db 'V86 : unexpected exception ',0
|
||||
v86_exc_str2 db ' at ',0
|
||||
v86_exc_str3 db ':',0
|
||||
v86_exc_str4 db 13,10,'V86 : faulted code:',0
|
||||
v86_exc_str5 db ' (unavailable)',0
|
||||
v86_newline db 13,10,0
|
||||
v86_io_str1 db 'V86 : access to disabled i/o port ',0
|
||||
v86_io_byte db ' (byte)',13,10,0
|
||||
v86_io_word db ' (word)',13,10,0
|
||||
v86_io_dword db ' (dword)',13,10,0
|
||||
v86_irqerr db 'V86 : IRQ already hooked',13,10,0
|
||||
endg
|
||||
|
||||
v86_exc_c:
|
||||
mov ax, app_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
; Did we all that we have wanted to do?
|
||||
mov eax, [esp+v86_regs.size+10h+18h]
|
||||
cmp word [esp+v86_regs.eip], ax
|
||||
jnz @f
|
||||
shr eax, 16
|
||||
cmp word [esp+v86_regs.cs], ax
|
||||
jz .done
|
||||
@@:
|
||||
; Various system events, which must be handled, result in #GP
|
||||
cmp bl, 13
|
||||
jnz .nogp
|
||||
; If faulted EIP exceeds 0xFFFF, we have #GP and it is an error
|
||||
cmp word [esp+v86_regs.eip+2], 0
|
||||
jnz .nogp
|
||||
; Otherwise we can safely access byte at CS:IP
|
||||
; (because it is #GP, not #PF handler)
|
||||
; …᫨ ¡ë ¬ë ¬®£«¨ áå«®¯®â âì ¨áª«î票¥ ⮫쪮 ¨§-§ çâ¥¨ï ¡ ©â®¢ ª®¤ ,
|
||||
; ¬ë ¡ë ¥£® 㦥 áå«®¯®â «¨ ¨ íâ® ¡ë«® ¡ë ¥ #GP
|
||||
movzx esi, word [esp+v86_regs.cs]
|
||||
shl esi, 4
|
||||
add esi, [esp+v86_regs.eip]
|
||||
lodsb
|
||||
cmp al, 0xCD ; int xx command = CD xx
|
||||
jz .handle_int
|
||||
cmp al, 0xCF
|
||||
jz .handle_iret
|
||||
cmp al, 0xF3
|
||||
jz .handle_rep
|
||||
cmp al, 0xEC
|
||||
jz .handle_in
|
||||
cmp al, 0xED
|
||||
jz .handle_in_word
|
||||
cmp al, 0xEE
|
||||
jz .handle_out
|
||||
cmp al, 0xEF
|
||||
jz .handle_out_word
|
||||
cmp al, 0xE4
|
||||
jz .handle_in_imm
|
||||
cmp al, 0xE6
|
||||
jz .handle_out_imm
|
||||
cmp al, 0x9C
|
||||
jz .handle_pushf
|
||||
cmp al, 0x9D
|
||||
jz .handle_popf
|
||||
cmp al, 0xFA
|
||||
jz .handle_cli
|
||||
cmp al, 0xFB
|
||||
jz .handle_sti
|
||||
cmp al, 0x66
|
||||
jz .handle_66
|
||||
jmp .nogp
|
||||
.handle_int:
|
||||
cmp word [esp+v86_regs.eip], 0xFFFF
|
||||
jae .nogp
|
||||
xor eax, eax
|
||||
lodsb
|
||||
; call sys_msg_board_byte
|
||||
; simulate INT command
|
||||
; N.B. It is possible that some checks need to be corrected,
|
||||
; but at least in case of normal execution the code works.
|
||||
.simulate_int:
|
||||
cmp word [esp+v86_regs.esp], 6
|
||||
jae @f
|
||||
mov bl, 12 ; #SS exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
push eax
|
||||
movzx eax, word [esp+4+v86_regs.esp]
|
||||
sub eax, 6
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+4+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+5]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
sub word [esp+4+v86_regs.esp], 6
|
||||
mov eax, [esp+4+v86_regs.eip]
|
||||
cmp byte [esp+1], 0
|
||||
jnz @f
|
||||
inc eax
|
||||
inc eax
|
||||
@@:
|
||||
mov word [edx], ax
|
||||
mov eax, [esp+4+v86_regs.cs]
|
||||
mov word [edx+2], ax
|
||||
mov eax, [esp+4+v86_regs.eflags]
|
||||
mov word [edx+4], ax
|
||||
pop eax
|
||||
mov ah, 0
|
||||
mov cx, [eax*4]
|
||||
mov word [esp+v86_regs.eip], cx
|
||||
mov cx, [eax*4+2]
|
||||
mov word [esp+v86_regs.cs], cx
|
||||
; note that interrupts will be disabled globally at IRET
|
||||
and byte [esp+v86_regs.eflags+1], not 3 ; clear IF and TF flags
|
||||
; continue V86 execution
|
||||
popad
|
||||
iretd
|
||||
.handle_iret:
|
||||
cmp word [esp+v86_regs.esp], 0x10000 - 6
|
||||
jbe @f
|
||||
mov bl, 12
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
movzx eax, word [esp+v86_regs.esp]
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+5]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
mov ax, [edx]
|
||||
mov word [esp+v86_regs.eip], ax
|
||||
mov ax, [edx+2]
|
||||
mov word [esp+v86_regs.cs], ax
|
||||
mov ax, [edx+4]
|
||||
mov word [esp+v86_regs.eflags], ax
|
||||
add word [esp+v86_regs.esp], 6
|
||||
popad
|
||||
iretd
|
||||
.handle_pushf:
|
||||
cmp word [esp+v86_regs.esp], 1
|
||||
jnz @f
|
||||
mov bl, 12
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
mov eax, [esp+v86_regs.esp]
|
||||
sub eax, 2
|
||||
movzx eax, ax
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+1]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
sub word [esp+v86_regs.esp], 2
|
||||
mov eax, [esp+v86_regs.eflags]
|
||||
mov [edx], ax
|
||||
inc word [esp+v86_regs.eip]
|
||||
popad
|
||||
iretd
|
||||
.handle_pushfd:
|
||||
cmp word [esp+v86_regs.esp], 4
|
||||
jae @f
|
||||
mov bl, 12 ; #SS exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
movzx eax, word [esp+v86_regs.esp]
|
||||
sub eax, 4
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+3]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
sub word [esp+v86_regs.esp], 4
|
||||
movzx eax, word [esp+v86_regs.eflags]
|
||||
mov [edx], eax
|
||||
add word [esp+v86_regs.eip], 2
|
||||
popad
|
||||
iretd
|
||||
.handle_popf:
|
||||
cmp word [esp+v86_regs.esp], 0xFFFF
|
||||
jnz @f
|
||||
mov bl, 12
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
movzx eax, word [esp+v86_regs.esp]
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+1]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
mov ax, [edx]
|
||||
mov word [esp+v86_regs.eflags], ax
|
||||
add word [esp+v86_regs.esp], 2
|
||||
inc word [esp+v86_regs.eip]
|
||||
popad
|
||||
iretd
|
||||
.handle_popfd:
|
||||
cmp word [esp+v86_regs.esp], 0x10000 - 4
|
||||
jbe @f
|
||||
mov bl, 12
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
movzx eax, word [esp+v86_regs.esp]
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+3]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
mov eax, [edx]
|
||||
mov word [esp+v86_regs.eflags], ax
|
||||
add word [esp+v86_regs.esp], 4
|
||||
add word [esp+v86_regs.eip], 2
|
||||
popad
|
||||
iretd
|
||||
.handle_cli:
|
||||
and byte [esp+v86_regs.eflags+1], not 2
|
||||
inc word [esp+v86_regs.eip]
|
||||
popad
|
||||
iretd
|
||||
.handle_sti:
|
||||
or byte [esp+v86_regs.eflags+1], 2
|
||||
inc word [esp+v86_regs.eip]
|
||||
popad
|
||||
iretd
|
||||
.handle_rep:
|
||||
cmp word [esp+v86_regs.eip], 0xFFFF
|
||||
jae .nogp
|
||||
lodsb
|
||||
cmp al, 6Eh
|
||||
jz .handle_rep_outsb
|
||||
jmp .nogp
|
||||
.handle_rep_outsb:
|
||||
.handle_in:
|
||||
.handle_out:
|
||||
.invalid_io_byte:
|
||||
movzx ebx, word [esp+v86_regs.edx]
|
||||
mov ecx, 1
|
||||
jmp .invalid_io
|
||||
.handle_in_imm:
|
||||
.handle_out_imm:
|
||||
cmp word [esp+v86_regs.eip], 0xFFFF
|
||||
jae .nogp
|
||||
lodsb
|
||||
movzx ebx, al
|
||||
mov ecx, 1
|
||||
jmp .invalid_io
|
||||
.handle_66:
|
||||
cmp word [esp+v86_regs.eip], 0xFFFF
|
||||
jae .nogp
|
||||
lodsb
|
||||
cmp al, 0x9C
|
||||
jz .handle_pushfd
|
||||
cmp al, 0x9D
|
||||
jz .handle_popfd
|
||||
cmp al, 0xEF
|
||||
jz .handle_out_dword
|
||||
cmp al, 0xED
|
||||
jz .handle_in_dword
|
||||
jmp .nogp
|
||||
.handle_in_word:
|
||||
.handle_out_word:
|
||||
movzx ebx, word [esp+v86_regs.edx]
|
||||
mov ecx, 2
|
||||
jmp .invalid_io
|
||||
.handle_in_dword:
|
||||
.handle_out_dword:
|
||||
.invalid_io_dword:
|
||||
movzx ebx, word [esp+v86_regs.edx]
|
||||
mov ecx, 4
|
||||
.invalid_io:
|
||||
mov esi, v86_io_str1
|
||||
call sys_msg_board_str
|
||||
mov eax, ebx
|
||||
call sys_msg_board_dword
|
||||
mov esi, v86_io_byte
|
||||
cmp ecx, 1
|
||||
jz @f
|
||||
mov esi, v86_io_word
|
||||
cmp ecx, 2
|
||||
jz @f
|
||||
mov esi, v86_io_dword
|
||||
@@:
|
||||
call sys_msg_board_str
|
||||
if DEBUG_SHOW_IO
|
||||
mov edx, ebx
|
||||
mov ebx, 200
|
||||
call delay_hs
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
mov eax, [esi+V86_machine.iopm]
|
||||
@@:
|
||||
btr [eax], edx
|
||||
inc edx
|
||||
loop @b
|
||||
popad
|
||||
iretd
|
||||
else
|
||||
mov eax, 2
|
||||
jmp .exit
|
||||
end if
|
||||
.nogp:
|
||||
|
||||
mov esi, v86_exc_str1
|
||||
call sys_msg_board_str
|
||||
mov al, bl
|
||||
call sys_msg_board_byte
|
||||
mov esi, v86_exc_str2
|
||||
call sys_msg_board_str
|
||||
mov ax, [esp+32+4]
|
||||
call sys_msg_board_word
|
||||
mov esi, v86_exc_str3
|
||||
call sys_msg_board_str
|
||||
mov ax, [esp+32]
|
||||
call sys_msg_board_word
|
||||
mov esi, v86_exc_str4
|
||||
call sys_msg_board_str
|
||||
mov ecx, 8
|
||||
movzx edx, word [esp+32+4]
|
||||
shl edx, 4
|
||||
add edx, [esp+32]
|
||||
@@:
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
mov eax, edx
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jb .nopage
|
||||
mov esi, v86_exc_str3-2
|
||||
call sys_msg_board_str
|
||||
mov al, [edx]
|
||||
call sys_msg_board_byte
|
||||
inc edx
|
||||
loop @b
|
||||
jmp @f
|
||||
.nopage:
|
||||
mov esi, v86_exc_str5
|
||||
call sys_msg_board_str
|
||||
@@:
|
||||
mov esi, v86_newline
|
||||
call sys_msg_board_str
|
||||
mov eax, 1
|
||||
jmp .exit
|
||||
|
||||
.done:
|
||||
xor eax, eax
|
||||
|
||||
.exit:
|
||||
mov [esp+v86_regs.size+10h+1Ch], eax
|
||||
mov [esp+v86_regs.size+10h+18h], ebx
|
||||
|
||||
mov edx, [esp+v86_regs.size+10h+14h]
|
||||
cmp edx, -1
|
||||
jz @f
|
||||
dec [v86_irqhooks+edx*8+4]
|
||||
jnz @f
|
||||
and [v86_irqhooks+edx*8], 0
|
||||
@@:
|
||||
|
||||
mov esi, esp
|
||||
mov edi, [esi+v86_regs.size+10h+10h]
|
||||
add edi, v86_regs.size
|
||||
mov ecx, v86_regs.size/4
|
||||
rep movsd
|
||||
mov esp, esi
|
||||
|
||||
cli
|
||||
mov ecx, [CURRENT_TASK]
|
||||
shl ecx, 8
|
||||
pop eax
|
||||
mov [SLOT_BASE+ecx+APPDATA.saved_esp0], eax
|
||||
mov [tss._esp0], eax
|
||||
pop eax
|
||||
mov [SLOT_BASE+ecx+APPDATA.dir_table], eax
|
||||
pop ebx
|
||||
mov dword [SLOT_BASE+ecx+APPDATA.io_map+4], ebx
|
||||
mov dword [page_tabs + (tss._io_map_1 shr 10)], ebx
|
||||
pop ebx
|
||||
mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx
|
||||
mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx
|
||||
mov cr3, eax
|
||||
; mov [irq_tab+5*4], 0
|
||||
sti
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
;my05:
|
||||
; mov dx, 30C2h
|
||||
; mov cx, 4
|
||||
;.0:
|
||||
; in al, dx
|
||||
; cmp al, 0FFh
|
||||
; jz @f
|
||||
; test al, 4
|
||||
; jnz .1
|
||||
;@@:
|
||||
; add dx, 8
|
||||
; in al, dx
|
||||
; cmp al, 0FFh
|
||||
; jz @f
|
||||
; test al, 4
|
||||
; jnz .1
|
||||
;@@:
|
||||
; loop .0
|
||||
; ret
|
||||
;.1:
|
||||
; or al, 84h
|
||||
; out dx, al
|
||||
;.2:
|
||||
; mov dx, 30F7h
|
||||
; in al, dx
|
||||
; mov byte [BOOT_VAR + 48Eh], 0FFh
|
||||
; ret
|
||||
|
||||
v86_irq:
|
||||
; push irq/pushad/jmp v86_irq
|
||||
; eax = irq
|
||||
lea esi, [esp+1Ch]
|
||||
lea edi, [esi+4]
|
||||
mov ecx, 8
|
||||
std
|
||||
rep movsd
|
||||
cld
|
||||
mov edi, eax
|
||||
pop eax
|
||||
v86_irq2:
|
||||
mov esi, [v86_irqhooks+edi*8] ; get VM handle
|
||||
mov eax, [esi+V86_machine.pagedir]
|
||||
call get_pg_addr
|
||||
mov ecx, [CURRENT_TASK]
|
||||
shl ecx, 8
|
||||
cmp [SLOT_BASE+ecx+APPDATA.dir_table], eax
|
||||
jnz .notcurrent
|
||||
lea eax, [edi+8]
|
||||
cmp al, 10h
|
||||
mov ah, 1
|
||||
jb @f
|
||||
add al, 60h
|
||||
@@:
|
||||
jmp v86_exc_c.simulate_int
|
||||
.notcurrent:
|
||||
mov ebx, SLOT_BASE + 0x100
|
||||
mov ecx, [TASK_COUNT]
|
||||
.scan:
|
||||
cmp [ebx+APPDATA.dir_table], eax
|
||||
jnz .cont
|
||||
push ecx
|
||||
mov ecx, [ebx+APPDATA.saved_esp0]
|
||||
cmp word [ecx-v86_regs.size+v86_regs.esp], 6
|
||||
jb .cont2
|
||||
movzx edx, word [ecx-v86_regs.size+v86_regs.ss]
|
||||
shl edx, 4
|
||||
push eax
|
||||
movzx eax, word [ecx-v86_regs.size+v86_regs.esp]
|
||||
sub eax, 6
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jb .cont3
|
||||
lea eax, [edx+5]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jb .cont3
|
||||
pop eax
|
||||
pop ecx
|
||||
jmp .found
|
||||
.cont3:
|
||||
pop eax
|
||||
.cont2:
|
||||
pop ecx
|
||||
.cont:
|
||||
loop .scan
|
||||
mov al, 20h
|
||||
out 20h, al
|
||||
cmp edi, 8
|
||||
jb @f
|
||||
out 0A0h, al
|
||||
@@:
|
||||
popad
|
||||
iretd
|
||||
.found:
|
||||
mov cr3, eax
|
||||
sub word [esi-v86_regs.size+v86_regs.esp], 6
|
||||
mov ecx, [esi-v86_regs.size+v86_regs.eip]
|
||||
mov word [edx], cx
|
||||
mov ecx, [esi-v86_regs.size+v86_regs.cs]
|
||||
mov word [edx+2], cx
|
||||
mov ecx, [esi-v86_regs.size+v86_regs.eflags]
|
||||
mov word [edx+4], cx
|
||||
lea eax, [edi+8]
|
||||
cmp al, 10h
|
||||
jb @f
|
||||
add al, 60h
|
||||
@@:
|
||||
mov cx, [eax*4]
|
||||
mov word [esi-v86_regs.size+v86_regs.eip], cx
|
||||
mov cx, [eax*4+2]
|
||||
mov word [esi-v86_regs.size+v86_regs.cs], cx
|
||||
and byte [esi-v86_regs.size+v86_regs.eflags+1], not 3
|
||||
push ebx
|
||||
call update_counters
|
||||
pop ebx
|
||||
sub ebx, SLOT_BASE
|
||||
shr ebx, 8
|
||||
mov esi, [CURRENT_TASK]
|
||||
call do_change_task
|
||||
popad
|
||||
iretd
|
55
kernel/branches/data16.inc
Normal file
55
kernel/branches/data16.inc
Normal file
@ -0,0 +1,55 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
flm db 0
|
||||
preboot_lfb db 0
|
||||
preboot_bootlog db 0
|
||||
boot_drive db 0
|
||||
bx_from_load: dw 'r1' ; ñòðóêòóðà äëÿ õðàíåíèÿ ïàðàìåòðîâ- îòêóäà ãàøðóçèëèñü, áåðåòñÿ íèæå èç bx ; {SPraid}[13.03.2007]
|
||||
; a,b,c,d - âèí÷åñòåðû, r - ðàì äèñê
|
||||
; # äèñêà... ñèìâîë, à íå áàéò. '1', à íå 1
|
||||
|
||||
align 4
|
||||
old_ints_h:
|
||||
dw 0x400
|
||||
dd 0
|
||||
dw 0
|
||||
|
||||
kernel_restart_bootblock:
|
||||
db 1 ; version
|
||||
dw 1 ; floppy image is in memory
|
||||
dd 0 ; cannot save parameters
|
||||
|
||||
; table for move to extended memory (int 15h, ah=87h)
|
||||
align 8
|
||||
movedesc:
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
|
||||
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
|
||||
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
|
||||
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
|
||||
fwmovedesc:
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
|
||||
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
|
||||
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
|
||||
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
||||
|
473
kernel/branches/data32.inc
Normal file
473
kernel/branches/data32.inc
Normal file
@ -0,0 +1,473 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 1018 $
|
||||
|
||||
|
||||
keymap:
|
||||
|
||||
db '6',27
|
||||
db '1234567890-=',8,9
|
||||
db 'qwertyuiop[]',13
|
||||
db '~asdfghjkl;',39,96,0,'\zxcvbnm,./',0,'45 '
|
||||
db '@234567890123',180,178,184,'6',176,'7'
|
||||
db 179,'8',181,177,183,185,182
|
||||
db 'AB<D',255,'FGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
keymap_shift:
|
||||
db '6',27
|
||||
db '!@#$%^&*()_+',8,9
|
||||
db 'QWERTYUIOP{}',13
|
||||
db '~ASDFGHJKL:"~',0,'|ZXCVBNM<>?',0,'45 '
|
||||
db '@234567890123',180,178,184,'6',176,'7'
|
||||
db 179,'8',181,177,183,185,182
|
||||
db 'AB>D',255,'FGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
|
||||
keymap_alt:
|
||||
db ' ',27
|
||||
db ' @ $ {[]}\ ',8,9
|
||||
db ' ',13
|
||||
db ' ',0,' ',0,'4',0,' '
|
||||
db ' ',180,178,184,'6',176,'7'
|
||||
db 179,'8',181,177,183,185,182
|
||||
db 'ABCD',255,'FGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
|
||||
|
||||
boot_memdetect db 'Determining amount of memory',0
|
||||
boot_fonts db 'Fonts loaded',0
|
||||
boot_tss db 'Setting TSSs',0
|
||||
boot_cpuid db 'Reading CPUIDs',0
|
||||
boot_devices db 'Detecting devices',0
|
||||
boot_timer db 'Setting timer',0
|
||||
boot_irqs db 'Reprogramming IRQs',0
|
||||
boot_setmouse db 'Setting mouse',0
|
||||
boot_windefs db 'Setting window defaults',0
|
||||
boot_bgr db 'Calculating background',0
|
||||
boot_resirqports db 'Reserving IRQs & ports',0
|
||||
boot_setrports db 'Setting addresses for IRQs',0
|
||||
boot_setostask db 'Setting OS task',0
|
||||
boot_allirqs db 'Unmasking all IRQs',0
|
||||
boot_tsc db 'Reading TSC',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_mtrr db 'Setting MTRR',0
|
||||
if preboot_blogesc
|
||||
boot_tasking db 'All set - press ESC to start',0
|
||||
end if
|
||||
|
||||
new_process_loading db 'K : New Process - loading',13,10,0
|
||||
new_process_running db 'K : New Process - done',13,10,0
|
||||
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
|
||||
|
||||
msg_unresolved db 'unresolved ',0
|
||||
msg_module db 'in module ',0
|
||||
msg_version db 'incompatible driver version',13,10,0
|
||||
msg_www db 'please visit www.kolibrios.org',13,10,0
|
||||
msg_CR db 13,10,0
|
||||
aSis db 'SIS',0
|
||||
|
||||
intel_str db "GenuineIntel",0
|
||||
AMD_str db "AuthenticAMD",0
|
||||
|
||||
;szSound db 'SOUND',0
|
||||
;szInfinity db 'INFINITY',0
|
||||
szHwMouse db 'ATI2D',0
|
||||
szPS2MDriver db 'PS2MOUSE',0
|
||||
szCOM_MDriver db 'COM_MOUSE',0
|
||||
szUSB db 'USB',0
|
||||
szAtiHW db '/rd/1/drivers/ati2d.drv',0
|
||||
|
||||
szSTART db 'START',0
|
||||
szEXPORTS db 'EXPORTS',0
|
||||
sz_EXPORTS db '_EXPORTS',0
|
||||
|
||||
szIMPORTS db 'IMPORTS',0
|
||||
|
||||
read_firstapp db '/sys/'
|
||||
firstapp db 'LAUNCHER',0
|
||||
|
||||
char db '/sys/FONTS/CHAR.MT',0
|
||||
char2 db '/sys/FONTS/CHAR2.MT',0
|
||||
|
||||
bootpath db '/KOLIBRI '
|
||||
bootpath2 db 0
|
||||
vmode db '/sys/drivers/VMODE.MDR',0
|
||||
vrr_m db 'VRR_M',0
|
||||
kernel_file db 'KERNEL MNT'
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
shmem_list:
|
||||
.bk dd shmem_list
|
||||
.fd dd shmem_list
|
||||
|
||||
; supported videomodes
|
||||
|
||||
mode_1280_1024_32:
|
||||
dw 1280,1024,32,60
|
||||
mode_1280_1024_24:
|
||||
dw 1280,1024,24,60
|
||||
mode_1024_768_32:
|
||||
dw 1024,768,32,60
|
||||
mode_1024_768_24:
|
||||
dw 1024,768,24,60
|
||||
mode_800_600_32:
|
||||
dw 800,600,32,60
|
||||
mode_800_600_24:
|
||||
dw 800,600,24,60
|
||||
mode_640_480_32:
|
||||
dw 640,480,32,60
|
||||
mode_640_480_24:
|
||||
dw 640,480,24,60
|
||||
mode_640_480_16:
|
||||
dw 640,480,16,60
|
||||
mode_320_240_8:
|
||||
dw 320,240,8,60
|
||||
|
||||
; mike.dld {
|
||||
db 0
|
||||
dd servetable-0x10000
|
||||
draw_line dd __sys_draw_line
|
||||
disable_mouse dd __sys_disable_mouse
|
||||
draw_pointer dd __sys_draw_pointer
|
||||
;//mike.dld, 2006-08-02 [
|
||||
;drawbar dd __sys_drawbar
|
||||
drawbar dd __sys_drawbar.forced
|
||||
;//mike.dld, 2006-08-02 ]
|
||||
putpixel dd __sys_putpixel
|
||||
; } mike.dld
|
||||
|
||||
|
||||
align 4
|
||||
keyboard dd 1
|
||||
syslang dd 1
|
||||
|
||||
boot_y dd 10
|
||||
|
||||
pci_bios_entry dd 0
|
||||
dw pci_code_sel
|
||||
|
||||
if __DEBUG__ eq 1
|
||||
include_debug_strings
|
||||
end if
|
||||
|
||||
IncludeIGlobals
|
||||
|
||||
align 16
|
||||
gdts:
|
||||
|
||||
dw gdte-$-1
|
||||
dd gdts
|
||||
dw 0
|
||||
|
||||
; Attention! Do not change the order of the first four selectors. They are used in Fast System Call
|
||||
; must be : os_code, os_data, app_code, app_data, ....
|
||||
|
||||
int_code_l:
|
||||
os_code_l:
|
||||
dw 0xffff
|
||||
dw 0x0000
|
||||
db 0x00
|
||||
dw 11011111b *256 +10011010b
|
||||
db 0x00
|
||||
|
||||
int_data_l:
|
||||
os_data_l:
|
||||
dw 0xffff
|
||||
dw 0x0000
|
||||
db 0x00
|
||||
dw 11011111b *256 +10010010b
|
||||
db 0x00
|
||||
|
||||
app_code_l:
|
||||
dw 0xFFFF
|
||||
dw 0
|
||||
db 0
|
||||
db cpl3
|
||||
dw G32+D32+(new_app_base shr 16)+0xF;
|
||||
|
||||
app_data_l:
|
||||
dw 0xFFFF
|
||||
dw 0
|
||||
db 0
|
||||
db drw3
|
||||
dw G32+D32+(new_app_base shr 16)+0xF;
|
||||
|
||||
; ------------- PCI BIOS ------------------
|
||||
|
||||
pci_code_32:
|
||||
dw 0 ;lim 0-15
|
||||
dw 0 ;base 0-15
|
||||
db 0 ;base 16-23
|
||||
db cpl0 ;type
|
||||
db D32 ;lim 16-19+props
|
||||
db 0 ;base 24-31
|
||||
|
||||
pci_data_32:
|
||||
dw 0 ;lim 0-15
|
||||
dw 0 ;base 0-15
|
||||
db 0 ;base 16-23
|
||||
db dpl0 ;type
|
||||
db D32 ;lim 16-19+props
|
||||
db 0 ;base 24-31
|
||||
|
||||
; --------------- APM ---------------------
|
||||
apm_code_32:
|
||||
dw 0x0f ; limit 64kb
|
||||
db 0, 0, 0
|
||||
dw 11010000b *256 +10011010b
|
||||
db 0x00
|
||||
apm_code_16:
|
||||
dw 0x0f
|
||||
db 0, 0, 0
|
||||
dw 10010000b *256 +10011010b
|
||||
db 0x00
|
||||
apm_data_16:
|
||||
dw 0x0f
|
||||
db 0, 0, 0
|
||||
dw 10010000b *256 +10010010b
|
||||
db 0x00
|
||||
; -----------------------------------------
|
||||
|
||||
graph_data_l:
|
||||
|
||||
dw 0x7ff
|
||||
dw 0x0000
|
||||
db 0x00
|
||||
dw 11010000b *256 +11110010b
|
||||
db 0x00
|
||||
tss0_l:
|
||||
dw TSS_SIZE-1
|
||||
dw tss and 0xFFFF
|
||||
db (tss shr 16) and 0xFF
|
||||
db 10001001b
|
||||
dw (tss shr 16) and 0xFF00
|
||||
endofcode:
|
||||
gdte:
|
||||
|
||||
align 16
|
||||
cur_saved_data rb 4096
|
||||
fpu_data: rb 512
|
||||
|
||||
; device irq owners
|
||||
irq_owner rd 16 ; process id
|
||||
|
||||
; on irq read ports
|
||||
|
||||
irq00read rd 16
|
||||
irq01read rd 16
|
||||
irq02read rd 16
|
||||
irq03read rd 16
|
||||
irq04read rd 16
|
||||
irq05read rd 16
|
||||
irq06read rd 16
|
||||
irq07read rd 16
|
||||
irq08read rd 16
|
||||
irq09read rd 16
|
||||
irq10read rd 16
|
||||
irq11read rd 16
|
||||
irq12read rd 16
|
||||
irq13read rd 16
|
||||
irq14read rd 16
|
||||
irq15read rd 16
|
||||
|
||||
irq_tab rd 16
|
||||
|
||||
mem_block_map rb 512
|
||||
event_map rb 64
|
||||
mem_block_list rd 64
|
||||
large_block_list rd 31
|
||||
mem_block_mask rd 2
|
||||
large_block_mask rd 1
|
||||
|
||||
mem_used.fd rd 1
|
||||
mem_used.bk rd 1
|
||||
|
||||
mem_block_arr rd 1
|
||||
mem_block_start rd 1
|
||||
mem_block_end rd 1
|
||||
|
||||
heap_mutex rd 1
|
||||
heap_size rd 1
|
||||
heap_free rd 1
|
||||
heap_blocks rd 1
|
||||
free_blocks rd 1
|
||||
|
||||
mst MEM_STATE
|
||||
|
||||
page_start rd 1
|
||||
page_end rd 1
|
||||
events rd 1
|
||||
event_start rd 1
|
||||
event_end rd 1
|
||||
event_uid rd 1
|
||||
sys_page_map rd 1
|
||||
os_stack_seg rd 1
|
||||
|
||||
|
||||
srv.fd rd 1
|
||||
srv.bk rd 1
|
||||
|
||||
scr_width rd 1
|
||||
scr_height rd 1
|
||||
|
||||
create_cursor rd 1
|
||||
select_hw_cursor rd 1
|
||||
set_hw_cursor rd 1
|
||||
hw_restore rd 1
|
||||
|
||||
def_cursor rd 1
|
||||
current_cursor rd 1
|
||||
hw_cursor rd 1
|
||||
cur_def_interl rd 1
|
||||
cur_saved_base rd 1
|
||||
cur_saved_interl rd 1
|
||||
cur_saved_w rd 1
|
||||
cur_saved_h rd 1
|
||||
|
||||
ipc_tmp rd 1
|
||||
ipc_pdir rd 1
|
||||
ipc_ptab rd 1
|
||||
|
||||
proc_mem_map rd 1
|
||||
proc_mem_pdir rd 1
|
||||
proc_mem_tab rd 1
|
||||
|
||||
tmp_task_pdir rd 1
|
||||
tmp_task_ptab rd 1
|
||||
|
||||
default_io_map rd 1
|
||||
|
||||
LFBSize rd 1
|
||||
|
||||
stall_mcs rd 1
|
||||
current_slot rd 1
|
||||
|
||||
; status
|
||||
hd1_status rd 1 ; 0 - free : other - pid
|
||||
application_table_status rd 1 ; 0 - free : other - pid
|
||||
|
||||
; device addresses
|
||||
mididp rd 1
|
||||
midisp rd 1
|
||||
|
||||
cdbase rd 1
|
||||
cdid rd 1
|
||||
|
||||
hdbase rd 1 ; for boot 0x1f0
|
||||
hdid rd 1
|
||||
hdpos rd 1 ; for boot 0x1
|
||||
fat32part rd 1 ; for boot 0x1
|
||||
cdpos rd 1
|
||||
|
||||
;CPUID information
|
||||
cpu_vendor rd 3
|
||||
cpu_sign rd 1
|
||||
cpu_info rd 1
|
||||
cpu_caps rd 4
|
||||
|
||||
|
||||
pg_data PG_DATA
|
||||
heap_test rd 1
|
||||
|
||||
buttontype rd 1
|
||||
windowtypechanged rd 1
|
||||
|
||||
hd_entries rd 1 ;unused ? 0xfe10
|
||||
|
||||
;* start code - Mario79
|
||||
|
||||
mouse_active rd 1
|
||||
mouse_pause rd 1
|
||||
MouseTickCounter rd 1
|
||||
|
||||
;* end code - Mario79
|
||||
|
||||
img_background rd 1
|
||||
mem_BACKGROUND rd 1
|
||||
wraw_bacground_select rb 1
|
||||
|
||||
cache_ide0:
|
||||
cache_ide0_pointer rd 1
|
||||
cache_ide0_size rd 1 ; not use
|
||||
cache_ide0_data_pointer rd 1
|
||||
cache_ide0_system_data_size rd 1 ; not use
|
||||
cache_ide0_appl_data_size rd 1 ; not use
|
||||
cache_ide0_system_data rd 1
|
||||
cache_ide0_appl_data rd 1
|
||||
cache_ide0_system_sad_size rd 1
|
||||
cache_ide0_appl_sad_size rd 1
|
||||
cache_ide0_search_start rd 1
|
||||
cache_ide0_appl_search_start rd 1
|
||||
|
||||
cache_ide1:
|
||||
cache_ide1_pointer rd 1
|
||||
cache_ide1_size rd 1 ; not use
|
||||
cache_ide1_data_pointer rd 1
|
||||
cache_ide1_system_data_size rd 1 ; not use
|
||||
cache_ide1_appl_data_size rd 1 ; not use
|
||||
cache_ide1_system_data rd 1
|
||||
cache_ide1_appl_data rd 1
|
||||
cache_ide1_system_sad_size rd 1
|
||||
cache_ide1_appl_sad_size rd 1
|
||||
cache_ide1_search_start rd 1
|
||||
cache_ide1_appl_search_start rd 1
|
||||
|
||||
cache_ide2:
|
||||
cache_ide2_pointer rd 1
|
||||
cache_ide2_size rd 1 ; not use
|
||||
cache_ide2_data_pointer rd 1
|
||||
cache_ide2_system_data_size rd 1 ; not use
|
||||
cache_ide2_appl_data_size rd 1 ; not use
|
||||
cache_ide2_system_data rd 1
|
||||
cache_ide2_appl_data rd 1
|
||||
cache_ide2_system_sad_size rd 1
|
||||
cache_ide2_appl_sad_size rd 1
|
||||
cache_ide2_search_start rd 1
|
||||
cache_ide2_appl_search_start rd 1
|
||||
|
||||
cache_ide3:
|
||||
cache_ide3_pointer rd 1
|
||||
cache_ide3_size rd 1 ; not use
|
||||
cache_ide3_data_pointer rd 1
|
||||
cache_ide3_system_data_size rd 1 ; not use
|
||||
cache_ide3_appl_data_size rd 1 ; not use
|
||||
cache_ide3_system_data rd 1
|
||||
cache_ide3_appl_data rd 1
|
||||
cache_ide3_system_sad_size rd 1
|
||||
cache_ide3_appl_sad_size rd 1
|
||||
cache_ide3_search_start rd 1
|
||||
cache_ide3_appl_search_start rd 1
|
||||
|
||||
debug_step_pointer rd 1
|
||||
hdd_appl_data rb 1 ; 0 = system cache, 1 - application cache
|
||||
cd_appl_data rb 1 ; 0 = system cache, 1 - application cache
|
||||
|
||||
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
|
||||
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
|
||||
timer_ticks_enable rb 1 ; for cd driver
|
||||
|
||||
NumBiosDisks rd 1
|
||||
BiosDisksData rb 200h
|
||||
BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
|
||||
BiosDiskPartitions rd 80h
|
||||
|
||||
IncludeUGlobals
|
||||
|
76
kernel/branches/detect/biosdisk.inc
Normal file
76
kernel/branches/detect/biosdisk.inc
Normal file
@ -0,0 +1,76 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; Detect all BIOS hard drives.
|
||||
; diamond, 2008
|
||||
|
||||
xor cx, cx
|
||||
mov es, cx
|
||||
mov di, 0x9080
|
||||
mov byte [es:di-1], cl
|
||||
cmp [preboot_biosdisk], 1
|
||||
jnz bdde
|
||||
mov dl, 80h
|
||||
bdds:
|
||||
mov ah, 15h
|
||||
push cx dx di
|
||||
int 13h
|
||||
pop di dx cx
|
||||
jc bddc
|
||||
test ah, ah
|
||||
jz bddc
|
||||
inc cx
|
||||
mov ah, 48h
|
||||
push ds
|
||||
push es
|
||||
pop ds
|
||||
mov si, 0xA000
|
||||
mov word [si], 1Eh
|
||||
mov ah, 48h
|
||||
int 13h
|
||||
pop ds
|
||||
jc bddc2
|
||||
inc byte [es:0x907F]
|
||||
cmp word [es:si], 1Eh
|
||||
jb bddl
|
||||
cmp word [es:si+1Ah], 0xFFFF
|
||||
jz bddl
|
||||
mov al, dl
|
||||
stosb
|
||||
push ds
|
||||
lds si, [es:si+1Ah]
|
||||
mov al, [si+6]
|
||||
and al, 0xF
|
||||
stosb
|
||||
mov al, byte [si+4]
|
||||
shr al, 4
|
||||
and ax, 1
|
||||
cmp word [si], 1F0h
|
||||
jz @f
|
||||
inc ax
|
||||
inc ax
|
||||
cmp word [si], 170h
|
||||
jz @f
|
||||
mov ax, -1
|
||||
@@:
|
||||
stosw
|
||||
pop ds
|
||||
jmp bddc2
|
||||
bddl:
|
||||
mov al, dl
|
||||
stosb
|
||||
mov al, 0
|
||||
stosb
|
||||
mov ax, -1
|
||||
stosw
|
||||
bddc2:
|
||||
cmp cl, [es:0x475]
|
||||
jae bdde
|
||||
bddc:
|
||||
inc dl
|
||||
jnz bdds
|
||||
bdde:
|
30
kernel/branches/detect/dev_fd.inc
Normal file
30
kernel/branches/detect/dev_fd.inc
Normal file
@ -0,0 +1,30 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 593 $
|
||||
|
||||
|
||||
;***************************************************
|
||||
; ïðåäâàðèòåëüíàÿ î÷èñòêà îáëàñòè òàáëèöû
|
||||
; ïîèñê è çàíåñåíèå â òàáëèöó ïðèâîäîâ FDD
|
||||
; àâòîð Mario79
|
||||
;***************************************************
|
||||
xor eax,eax
|
||||
mov edi,DRIVE_DATA
|
||||
mov ecx,16384
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
mov al,0x10
|
||||
out 0x70,al
|
||||
mov cx,0xff
|
||||
wait_cmos:
|
||||
dec cx
|
||||
cmp cx,0
|
||||
jne wait_cmos
|
||||
in al,0x71
|
||||
mov [DRIVE_DATA],al
|
384
kernel/branches/detect/dev_hdcd.inc
Normal file
384
kernel/branches/detect/dev_hdcd.inc
Normal file
@ -0,0 +1,384 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 593 $
|
||||
|
||||
|
||||
;******************************************************
|
||||
; поиск приводов HDD и CD
|
||||
; автор исходного текста Кулаков Владимир Геннадьевич.
|
||||
; адаптация и доработка Mario79
|
||||
;******************************************************
|
||||
|
||||
;****************************************************
|
||||
;* ПОИСК HDD и CD *
|
||||
;****************************************************
|
||||
FindHDD:
|
||||
mov [ChannelNumber],1
|
||||
mov [DiskNumber],0
|
||||
call FindHDD_3
|
||||
; mov ax,[Sector512+176]
|
||||
; mov [DRIVE_DATA+6],ax
|
||||
; mov ax,[Sector512+126]
|
||||
; mov [DRIVE_DATA+8],ax
|
||||
; mov ax,[Sector512+128]
|
||||
; mov [DRIVE_DATA+8],ax
|
||||
mov [DiskNumber],1
|
||||
call FindHDD_3
|
||||
; mov al,[Sector512+176]
|
||||
; mov [DRIVE_DATA+7],al
|
||||
inc [ChannelNumber]
|
||||
mov [DiskNumber],0
|
||||
call FindHDD_3
|
||||
; mov al,[Sector512+176]
|
||||
; mov [DRIVE_DATA+8],al
|
||||
mov [DiskNumber],1
|
||||
call FindHDD_1
|
||||
; mov al,[Sector512+176]
|
||||
; mov [DRIVE_DATA+9],al
|
||||
|
||||
jmp EndFindHDD
|
||||
|
||||
FindHDD_1:
|
||||
call ReadHDD_ID
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2
|
||||
cmp [Sector512+6],word 16
|
||||
ja FindHDD_2
|
||||
cmp [Sector512+12],word 255
|
||||
ja FindHDD_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
jmp FindHDD_2_2
|
||||
FindHDD_2:
|
||||
call DeviceReset
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2_2
|
||||
call ReadCD_ID
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
inc byte [DRIVE_DATA+1]
|
||||
FindHDD_2_2:
|
||||
ret
|
||||
|
||||
FindHDD_3:
|
||||
call FindHDD_1
|
||||
shl byte [DRIVE_DATA+1],2
|
||||
ret
|
||||
|
||||
|
||||
; Адрес считываемого сектора в режиме LBA
|
||||
SectorAddress DD ?
|
||||
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала (1 или 2); *
|
||||
;* DiskNumber - номер диска на канале (0 или 1). *
|
||||
;* Идентификационный блок данных считывается *
|
||||
;* в массив Sector512. *
|
||||
;*************************************************
|
||||
ReadHDD_ID:
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
; Послать команду идентификации устройства
|
||||
mov [ATAFeatures],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0ECh
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode],0 ;проверить код ошибки
|
||||
jne @@End ;закончить, сохранив код ошибки
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;адрес регистра состояни
|
||||
mov ecx,0xffff
|
||||
@@WaitCompleet:
|
||||
; Проверить время выполнения команды
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Error1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitCompleet
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Error6
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitCompleet
|
||||
; Принять блок данных от контроллера
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI,Sector512 ;offset Sector512
|
||||
mov DX,[ATABasePortAddr] ;регистр данных
|
||||
mov CX,256 ;число считываемых слов
|
||||
rep insw ;принять блок данных
|
||||
jmp @@End
|
||||
; Записать код ошибки
|
||||
@@Error1:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End
|
||||
@@Error6:
|
||||
mov [DevErrorCode],6
|
||||
@@End: ret
|
||||
|
||||
|
||||
|
||||
; Стандартные базовые адреса каналов 1 и 2
|
||||
StandardATABases DW 1F0h, 170h
|
||||
; Номер канала
|
||||
ChannelNumber DW ?
|
||||
; Номер диска
|
||||
DiskNumber DB ?
|
||||
; Базовый адрес группы портов контроллера ATA
|
||||
ATABasePortAddr DW ?
|
||||
; Параметры ATA-команды
|
||||
ATAFeatures DB ? ;особенности
|
||||
ATASectorCount DB ? ;количество обрабатываемых секторов
|
||||
ATASectorNumber DB ? ;номер начального сектора
|
||||
ATACylinder DW ? ;номер начального цилиндра
|
||||
ATAHead DB ? ;номер начальной головки
|
||||
ATAAddressMode DB ? ;режим адресации (0 - CHS, 1 - LBA)
|
||||
ATACommand DB ? ;код команды, подлежащей выполнению
|
||||
; Код ошибки (0 - нет ошибок, 1 - превышен допустимый
|
||||
; интервал ожидания, 2 - неверный код режима адресации,
|
||||
; 3 - неверный номер канала, 4 - неверный номер диска,
|
||||
; 5 - неверный номер головки, 6 - ошибка при выполнении
|
||||
; команды)
|
||||
DevErrorCode DB ?
|
||||
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала (1 или 2); *
|
||||
;* DiskNumber - номер диска (0 или 1); *
|
||||
;* ATAFeatures - "особенности"; *
|
||||
;* ATASectorCount - количество секторов; *
|
||||
;* ATASectorNumber - номер начального сектора; *
|
||||
;* ATACylinder - номер начального цилиндра; *
|
||||
;* ATAHead - номер начальной головки; *
|
||||
;* ATAAddressMode - режим адресации (0-CHS, 1-LBA); *
|
||||
;* ATACommand - код команды. *
|
||||
;* После успешного выполнения функции: *
|
||||
;* в ATABasePortAddr - базовый адрес HDD; *
|
||||
;* в DevErrorCode - ноль. *
|
||||
;* При возникновении ошибки в DevErrorCode будет *
|
||||
;* возвращен код ошибки. *
|
||||
;****************************************************
|
||||
SendCommandToHDD:
|
||||
; Проверить значение кода режима
|
||||
cmp [ATAAddressMode],1
|
||||
ja @@Err2
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3
|
||||
cmp BX,2
|
||||
ja @@Err3
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov AX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],AX
|
||||
; Ожидание готовности HDD к приему команды
|
||||
; Выбрать нужный диск
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,6 ;адрес регистра головок
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;проверить номера диска
|
||||
ja @@Err4
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Ожидать, пока диск не будет готов
|
||||
inc DX
|
||||
mov ecx,0xfff
|
||||
; mov eax,[timer_ticks]
|
||||
; mov [TickCounter_1],eax
|
||||
@@WaitHDReady:
|
||||
; Проверить время ожидани
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1
|
||||
; mov eax,[timer_ticks]
|
||||
; sub eax,[TickCounter_1]
|
||||
; cmp eax,300 ;ожидать 300 тиков
|
||||
; ja @@Err1 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояни
|
||||
in AL,DX
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady
|
||||
; Проверить состояние сигнала DRQ
|
||||
test AL,08h
|
||||
jnz @@WaitHDReady
|
||||
; Загрузить команду в регистры контроллера
|
||||
cli
|
||||
mov DX,[ATABasePortAddr]
|
||||
inc DX ;регистр "особенностей"
|
||||
mov AL,[ATAFeatures]
|
||||
out DX,AL
|
||||
inc DX ;счетчик секторов
|
||||
mov AL,[ATASectorCount]
|
||||
out DX,AL
|
||||
inc DX ;регистр номера сектора
|
||||
mov AL,[ATASectorNumber]
|
||||
out DX,AL
|
||||
inc DX ;номер цилиндра (младший байт)
|
||||
mov AX,[ATACylinder]
|
||||
out DX,AL
|
||||
inc DX ;номер цилиндра (старший байт)
|
||||
mov AL,AH
|
||||
out DX,AL
|
||||
inc DX ;номер головки/номер диска
|
||||
mov AL,[DiskNumber]
|
||||
shl AL,4
|
||||
cmp [ATAHead],0Fh ;проверить номер головки
|
||||
ja @@Err5
|
||||
or AL,[ATAHead]
|
||||
or AL,10100000b
|
||||
mov AH,[ATAAddressMode]
|
||||
shl AH,6
|
||||
or AL,AH
|
||||
out DX,AL
|
||||
; Послать команду
|
||||
mov AL,[ATACommand]
|
||||
inc DX ;регистр команд
|
||||
out DX,AL
|
||||
sti
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
jmp @@End_2
|
||||
; Записать код ошибки
|
||||
@@Err1: mov [DevErrorCode],1
|
||||
jmp @@End_2
|
||||
@@Err2: mov [DevErrorCode],2
|
||||
jmp @@End_2
|
||||
@@Err3: mov [DevErrorCode],3
|
||||
jmp @@End_2
|
||||
@@Err4: mov [DevErrorCode],4
|
||||
jmp @@End_2
|
||||
@@Err5: mov [DevErrorCode],5
|
||||
; Завершение работы программы
|
||||
@@End_2:
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* перменные: *
|
||||
;* ChannelNumber - номер канала; *
|
||||
;* DiskNumber - номер диска на канале. *
|
||||
;* Идентификационный блок данных считывается *
|
||||
;* в массив Sector512. *
|
||||
;*************************************************
|
||||
ReadCD_ID:
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
; Послать команду идентификации устройства
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
mov [ATACylinder],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A1h
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode],0 ;проверить код ошибки
|
||||
jne @@End_1 ;закончить, сохранив код ошибки
|
||||
; Ожидать готовность данных HDD
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;порт 1х7h
|
||||
mov ecx,0xffff
|
||||
@@WaitCompleet_1:
|
||||
; Проверить врем
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Error1_1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL,DX
|
||||
test AL,80h ;состояние сигнала BSY
|
||||
jnz @@WaitCompleet_1
|
||||
test AL,1 ;состояние сигнала ERR
|
||||
jnz @@Error6_1
|
||||
test AL,08h ;состояние сигнала DRQ
|
||||
jz @@WaitCompleet_1
|
||||
; Принять блок данных от контроллера
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI,Sector512 ;offset Sector512
|
||||
mov DX,[ATABasePortAddr] ;порт 1x0h
|
||||
mov CX,256 ;число считываемых слов
|
||||
rep insw
|
||||
jmp @@End_1
|
||||
; Записать код ошибки
|
||||
@@Error1_1:
|
||||
mov [DevErrorCode],1
|
||||
jmp @@End_1
|
||||
@@Error6_1:
|
||||
mov [DevErrorCode],6
|
||||
@@End_1:
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* СБРОС УСТРОЙСТВА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
;* переменные: *
|
||||
;* ChannelNumber - номер канала (1 или 2); *
|
||||
;* DiskNumber - номер диска (0 или 1). *
|
||||
;*************************************************
|
||||
DeviceReset:
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3_2
|
||||
cmp BX,2
|
||||
ja @@Err3_2
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov DX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],DX
|
||||
; Выбрать нужный диск
|
||||
add DX,6 ;адрес регистра головок
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;проверить номера диска
|
||||
ja @@Err4_2
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Послать команду "Сброс"
|
||||
mov AL,08h
|
||||
inc DX ;регистр команд
|
||||
out DX,AL
|
||||
mov ecx,0x80000
|
||||
@@WaitHDReady_1:
|
||||
; Проверить время ожидани
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je @@Err1_2 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояни
|
||||
in AL,DX
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady_1
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
jmp @@End_3
|
||||
; Обработка ошибок
|
||||
@@Err1_2: mov [DevErrorCode],1
|
||||
jmp @@End_3
|
||||
@@Err3_2: mov [DevErrorCode],3
|
||||
jmp @@End_3
|
||||
@@Err4_2: mov [DevErrorCode],4
|
||||
; Записать код ошибки
|
||||
@@End_3:
|
||||
ret
|
||||
|
||||
EndFindHDD:
|
||||
|
15
kernel/branches/detect/disks.inc
Normal file
15
kernel/branches/detect/disks.inc
Normal file
@ -0,0 +1,15 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
include 'dev_fd.inc'
|
||||
include 'dev_hdcd.inc'
|
||||
include 'getcache.inc'
|
||||
include 'sear_par.inc'
|
||||
|
201
kernel/branches/detect/getcache.inc
Normal file
201
kernel/branches/detect/getcache.inc
Normal file
@ -0,0 +1,201 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,[pg_data.pages_free]
|
||||
; 1/32
|
||||
shr eax,5
|
||||
; round off up to 8 pages
|
||||
shr eax,3
|
||||
shl eax,3
|
||||
; translate pages in butes *4096
|
||||
shl eax,12
|
||||
; check a upper size of the cache, no more than 1 Mb on the physical device
|
||||
cmp eax,1024*1024
|
||||
jbe @f
|
||||
mov eax,1024*1024
|
||||
jmp .continue
|
||||
@@:
|
||||
; check a lower size of the cache, not less than 128 Kb on the physical device
|
||||
cmp eax,128*1024
|
||||
jae @f
|
||||
mov eax,128*1024
|
||||
@@:
|
||||
.continue:
|
||||
mov [cache_ide0_size],eax
|
||||
mov [cache_ide1_size],eax
|
||||
mov [cache_ide2_size],eax
|
||||
mov [cache_ide3_size],eax
|
||||
xor eax,eax
|
||||
mov [hdd_appl_data],1 ;al
|
||||
mov [cd_appl_data],1
|
||||
|
||||
mov ch,[DRIVE_DATA+1]
|
||||
mov cl,ch
|
||||
and cl,11b
|
||||
je .ide2
|
||||
mov esi,cache_ide3
|
||||
call get_cache_ide
|
||||
.ide2:
|
||||
mov cl,ch
|
||||
shr cl,2
|
||||
and cl,11b
|
||||
je .ide1
|
||||
mov esi,cache_ide2
|
||||
call get_cache_ide
|
||||
.ide1:
|
||||
mov cl,ch
|
||||
shr cl,4
|
||||
and cl,11b
|
||||
je .ide0
|
||||
mov esi,cache_ide1
|
||||
call get_cache_ide
|
||||
.ide0:
|
||||
mov cl,ch
|
||||
shr cl,6
|
||||
and cl,11b
|
||||
je @f
|
||||
mov esi,cache_ide0
|
||||
call get_cache_ide
|
||||
@@:
|
||||
xor ecx,ecx
|
||||
cmp [NumBiosDisks],ecx
|
||||
jz .endbd
|
||||
mov esi,BiosDiskCaches
|
||||
.loopbd:
|
||||
cmp byte [BiosDisksData+ecx*4+2],-1
|
||||
jnz .contbd
|
||||
mov eax,[cache_ide0_size]
|
||||
mov [esi+cache_ide0_size-cache_ide0],eax
|
||||
push ecx
|
||||
mov cl,1
|
||||
call get_cache_ide
|
||||
pop ecx
|
||||
.contbd:
|
||||
add esi,cache_ide1-cache_ide0
|
||||
inc ecx
|
||||
cmp ecx,[NumBiosDisks]
|
||||
jb .loopbd
|
||||
.endbd:
|
||||
jmp end_get_cache
|
||||
|
||||
get_cache_ide:
|
||||
and [esi+cache_ide0_search_start-cache_ide0],0
|
||||
and [esi+cache_ide0_appl_search_start-cache_ide0],0
|
||||
push ecx
|
||||
stdcall kernel_alloc,[esi+cache_ide0_size-cache_ide0]
|
||||
mov [esi+cache_ide0_pointer-cache_ide0],eax
|
||||
pop ecx
|
||||
mov edx,eax
|
||||
mov eax,[esi+cache_ide0_size-cache_ide0]
|
||||
shr eax,3
|
||||
mov [esi+cache_ide0_system_data_size-cache_ide0],eax
|
||||
mov ebx,eax
|
||||
imul eax,7
|
||||
mov [esi+cache_ide0_appl_data_size-cache_ide0],eax
|
||||
add ebx,edx
|
||||
mov [esi+cache_ide0_data_pointer-cache_ide0],ebx
|
||||
|
||||
cmp cl,10b
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[esi+cache_ide0_system_data_size-cache_ide0]
|
||||
call calculate_for_hd
|
||||
add eax,[esi+cache_ide0_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_system_data-cache_ide0],eax
|
||||
mov [esi+cache_ide0_system_sad_size-cache_ide0],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[esi+cache_ide0_pointer-cache_ide0]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[esi+cache_ide0_appl_data_size-cache_ide0]
|
||||
call calculate_for_hd
|
||||
add eax,[esi+cache_ide0_data_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_appl_data-cache_ide0],eax
|
||||
mov [esi+cache_ide0_appl_sad_size-cache_ide0],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[esi+cache_ide0_data_pointer-cache_ide0]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
.cd:
|
||||
push ecx
|
||||
mov eax,[esi+cache_ide0_system_data_size-cache_ide0]
|
||||
call calculate_for_cd
|
||||
add eax,[esi+cache_ide0_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_system_data-cache_ide0],eax
|
||||
mov [esi+cache_ide0_system_sad_size-cache_ide0],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[esi+cache_ide0_pointer-cache_ide0]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[esi+cache_ide0_appl_data_size-cache_ide0]
|
||||
call calculate_for_cd
|
||||
add eax,[esi+cache_ide0_data_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_appl_data-cache_ide0],eax
|
||||
mov [esi+cache_ide0_appl_sad_size-cache_ide0],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[esi+cache_ide0_data_pointer-cache_ide0]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
calculate_for_hd:
|
||||
push eax
|
||||
mov ebx,eax
|
||||
shr eax,9
|
||||
shl eax,3
|
||||
sub ebx,eax
|
||||
shr ebx,9
|
||||
mov ecx,ebx
|
||||
shl ebx,9
|
||||
pop eax
|
||||
sub eax,ebx
|
||||
dec ecx
|
||||
ret
|
||||
|
||||
calculate_for_cd:
|
||||
push eax
|
||||
mov ebx,eax
|
||||
shr eax,11
|
||||
shl eax,3
|
||||
sub ebx,eax
|
||||
shr ebx,11
|
||||
mov ecx,ebx
|
||||
shl ebx,11
|
||||
pop eax
|
||||
sub eax,ebx
|
||||
dec ecx
|
||||
ret
|
||||
|
||||
clear_ide_cache:
|
||||
push eax
|
||||
shl ecx,1
|
||||
xor eax,eax
|
||||
cld
|
||||
rep stosd
|
||||
pop eax
|
||||
ret
|
||||
|
||||
end_get_cache:
|
||||
; mov [cache_ide0_pointer],HD_CACHE
|
||||
; mov [cache_ide0_system_data],HD_CACHE+65536
|
||||
; mov [cache_ide0_system_sad_size],1919
|
||||
popa
|
153
kernel/branches/detect/sear_par.inc
Normal file
153
kernel/branches/detect/sear_par.inc
Normal file
@ -0,0 +1,153 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 709 $
|
||||
|
||||
|
||||
;****************************************************
|
||||
; ïîèñê ëîãè÷åñêèõ äèñêîâ íà îáíàðóæåííûõ HDD
|
||||
; è çàíåñåíèå äàííûõ â îáëàñòü òàáëèöû
|
||||
; àâòîð Mario79
|
||||
;****************************************************
|
||||
mov [transfer_adress],DRIVE_DATA+0xa
|
||||
search_partitions_ide0:
|
||||
test [DRIVE_DATA+1],byte 0x40
|
||||
jz search_partitions_ide1
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],1
|
||||
mov [fat32part],1
|
||||
search_partitions_ide0_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide1
|
||||
inc byte [DRIVE_DATA+2]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress],100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide0_1
|
||||
|
||||
search_partitions_ide1:
|
||||
test [DRIVE_DATA+1],byte 0x10
|
||||
jz search_partitions_ide2
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],2
|
||||
mov [fat32part],1
|
||||
search_partitions_ide1_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide2
|
||||
inc byte [DRIVE_DATA+3]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress],100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide1_1
|
||||
|
||||
search_partitions_ide2:
|
||||
test [DRIVE_DATA+1],byte 0x4
|
||||
jz search_partitions_ide3
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],3
|
||||
mov [fat32part],1
|
||||
search_partitions_ide2_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide3
|
||||
inc byte [DRIVE_DATA+4]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress],100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide2_1
|
||||
|
||||
search_partitions_ide3:
|
||||
test [DRIVE_DATA+1],byte 0x1
|
||||
jz end_search_partitions_ide
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],4
|
||||
mov [fat32part],1
|
||||
search_partitions_ide3_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne end_search_partitions_ide
|
||||
inc byte [DRIVE_DATA+5]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress],100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide3_1
|
||||
|
||||
end_search_partitions_ide:
|
||||
mov [hdpos], 80h
|
||||
mov ecx, [NumBiosDisks]
|
||||
test ecx, ecx
|
||||
jz end_search_partitions
|
||||
start_search_partitions_bd:
|
||||
push ecx
|
||||
mov eax, [hdpos]
|
||||
and [BiosDiskPartitions+(eax-80h)*4], 0
|
||||
mov [fat32part], 1
|
||||
search_partitions_bd:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition], 0
|
||||
jne end_search_partitions_bd
|
||||
mov eax, [hdpos]
|
||||
inc [BiosDiskPartitions+(eax-80h)*4]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress], 100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_bd
|
||||
end_search_partitions_bd:
|
||||
pop ecx
|
||||
inc [hdpos]
|
||||
loop start_search_partitions_bd
|
||||
jmp end_search_partitions
|
||||
|
||||
partition_data_transfer:
|
||||
mov edi,[transfer_adress]
|
||||
mov esi,PARTITION_START
|
||||
mov ecx,(file_system_data_size+3)/4
|
||||
rep movsd
|
||||
ret
|
||||
uglobal
|
||||
transfer_adress dd 0
|
||||
endg
|
||||
partition_data_transfer_1:
|
||||
; cli
|
||||
push edi
|
||||
mov edi,PARTITION_START
|
||||
mov esi,[transfer_adress]
|
||||
mov ecx,(file_system_data_size+3)/4
|
||||
rep movsd
|
||||
pop edi
|
||||
; sti
|
||||
ret
|
||||
|
||||
end_search_partitions:
|
||||
|
||||
;PARTITION_START dd 0x3f
|
||||
;PARTITION_END dd 0
|
||||
;SECTORS_PER_FAT dd 0x1f3a
|
||||
;NUMBER_OF_FATS dd 0x2
|
||||
;SECTORS_PER_CLUSTER dd 0x8
|
||||
;BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes
|
||||
;ROOT_CLUSTER dd 2 ; first rootdir cluster
|
||||
;FAT_START dd 0 ; start of fat table
|
||||
;ROOT_START dd 0 ; start of rootdir (only fat16)
|
||||
;ROOT_SECTORS dd 0 ; count of rootdir sectors (only fat16)
|
||||
;DATA_START dd 0 ; start of data area (=first cluster 2)
|
||||
;LAST_CLUSTER dd 0 ; last availabe cluster
|
||||
;ADR_FSINFO dd 0 ; used only by fat32
|
||||
;
|
||||
;fatRESERVED dd 0x0FFFFFF6
|
||||
;fatBAD dd 0x0FFFFFF7
|
||||
;fatEND dd 0x0FFFFFF8
|
||||
;fatMASK dd 0x0FFFFFFF
|
||||
;
|
||||
;fat_type db 0 ; 0=none, 16=fat16, 32=fat32
|
||||
|
518
kernel/branches/docs/apm.txt
Normal file
518
kernel/branches/docs/apm.txt
Normal file
@ -0,0 +1,518 @@
|
||||
--------p-155300-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - INSTALLATION CHECK
|
||||
AX = 5300h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
AH = major version (BCD)
|
||||
AL = minor version (BCD)
|
||||
BX = 504Dh ("PM")
|
||||
CX = flags (see #00472)
|
||||
CF set on error
|
||||
AH = error code (06h,09h,86h) (see #00473)
|
||||
BUG: early versions of the Award Modular BIOS with built-in APM support
|
||||
reportedly do not set BX on return
|
||||
|
||||
Bitfields for APM flags:
|
||||
Bit(s) Description (Table 00472)
|
||||
0 16-bit protected mode interface supported
|
||||
1 32-bit protected mode interface supported
|
||||
2 CPU idle call reduces processor speed
|
||||
3 BIOS power management disabled
|
||||
4 BIOS power management disengaged (APM v1.1)
|
||||
5-7 reserved
|
||||
|
||||
(Table 00473)
|
||||
Values for APM error code:
|
||||
01h power management functionality disabled
|
||||
02h interface connection already in effect
|
||||
03h interface not connected
|
||||
04h real-mode interface not connected
|
||||
05h 16-bit protected-mode interface already connected
|
||||
06h 16-bit protected-mode interface not supported
|
||||
07h 32-bit protected-mode interface already connected
|
||||
08h 32-bit protected-mode interface not supported
|
||||
09h unrecognized device ID
|
||||
0Ah invalid parameter value in CX
|
||||
0Bh (APM v1.1) interface not engaged
|
||||
0Ch (APM v1.2) function not supported
|
||||
0Dh (APM v1.2) Resume Timer disabled
|
||||
0Eh-1Fh reserved for other interface and general errors
|
||||
20h-3Fh reserved for CPU errors
|
||||
40h-5Fh reserved for device errors
|
||||
60h can't enter requested state
|
||||
61h-7Fh reserved for other system errors
|
||||
80h no power management events pending
|
||||
81h-85h reserved for other power management event errors
|
||||
86h APM not present
|
||||
87h-9Fh reserved for other power management event errors
|
||||
A0h-FEh reserved
|
||||
FFh undefined
|
||||
--------p-155301-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - CONNECT REAL-MODE INTERFACE
|
||||
AX = 5301h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (02h,05h,07h,09h) (see #00473)
|
||||
Note: on connection, an APM v1.1 or v1.2 BIOS switches to APM v1.0
|
||||
compatibility mode until it is informed that the user supports a
|
||||
newer version of APM (see AX=530Eh)
|
||||
SeeAlso: AX=5302h,AX=5303h,AX=5304h
|
||||
--------p-155302-----------------------------
|
||||
INT 15 R - Advanced Power Management v1.0+ - CONNECT 16-BIT PROTMODE INTERFACE
|
||||
AX = 5302h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
AX = real-mode segment base address of protected-mode 16-bit code
|
||||
segment
|
||||
BX = offset of entry point
|
||||
CX = real-mode segment base address of protected-mode 16-bit data
|
||||
segment
|
||||
---APM v1.1---
|
||||
SI = APM BIOS code segment length
|
||||
DI = APM BIOS data segment length
|
||||
CF set on error
|
||||
AH = error code (02h,05h,06h,07h,09h) (see #00473)
|
||||
Notes: the caller must initialize two consecutive descriptors with the
|
||||
returned segment base addresses; these descriptors must be valid
|
||||
whenever the protected-mode interface is called, and will have
|
||||
their limits arbitrarily set to 64K.
|
||||
the protected mode interface is invoked by making a far call with the
|
||||
same register values as for INT 15; it must be invoked while CPL=0,
|
||||
the code segment descriptor must have a DPL of 0, the stack must be
|
||||
in a 16-bit segment and have enough room for BIOS use and possible
|
||||
interrupts, and the current I/O permission bit map must allow access
|
||||
to the I/O ports used for power management.
|
||||
functions 00h-03h are not available from protected mode
|
||||
on connection, an APM v1.1 or v1.2 BIOS switches to APM v1.0
|
||||
compatibility mode until it is informed that the user supports a
|
||||
newer version of APM (see AX=530Eh)
|
||||
SeeAlso: AX=5301h,AX=5303h,AX=5304h
|
||||
--------p-155303-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - CONNECT 32-BIT PROTMODE INTERFACE
|
||||
AX = 5303h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
AX = real-mode segment base address of protected-mode 32-bit code
|
||||
segment
|
||||
EBX = offset of entry point
|
||||
CX = real-mode segment base address of protected-mode 16-bit code
|
||||
segment
|
||||
DX = real-mode segment base address of protected-mode 16-bit data
|
||||
segment
|
||||
---APM v1.1---
|
||||
SI = APM BIOS code segment length
|
||||
DI = APM BIOS data segment length
|
||||
CF set on error
|
||||
AH = error code (02h,05h,07h,08h,09h) (see #00473)
|
||||
Notes: the caller must initialize three consecutive descriptors with the
|
||||
returned segment base addresses for 32-bit code, 16-bit code, and
|
||||
16-bit data, respectively; these descriptors must be valid whenever
|
||||
the protected-mode interface is called, and will have their limits
|
||||
arbitrarily set to 64K.
|
||||
the protected mode interface is invoked by making a far call to the
|
||||
32-bit code segment with the same register values as for INT 15; it
|
||||
must be invoked while CPL=0, the code segment descriptor must have a
|
||||
DPL of 0, the stack must be in a 32-bit segment and have enough room
|
||||
for BIOS use and possible interrupts, and the current I/O permission
|
||||
bit map must allow access to the I/O ports used for power management.
|
||||
functions 00h-03h are not available from protected mode
|
||||
on connection, an APM v1.1 or v1.2 BIOS switches to APM v1.0
|
||||
compatibility mode until it is informed that the user supports a
|
||||
newer version of APM (see AX=530Eh)
|
||||
SeeAlso: AX=5301h,AX=5302h,AX=5304h
|
||||
--------p-155304-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - DISCONNECT INTERFACE
|
||||
AX = 5304h
|
||||
BX = device ID of system BIOS (0000h)
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (03h,09h) (see #00473)
|
||||
SeeAlso: AX=5301h,AX=5302h,AX=5303h
|
||||
--------p-155305-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - CPU IDLE
|
||||
AX = 5305h
|
||||
Return: CF clear if successful (after system leaves idle state)
|
||||
CF set on error
|
||||
AH = error code (03h,0Bh) (see #00473)
|
||||
Notes: call when the system is idle and should be suspended until the next
|
||||
system event or interrupt
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
if an interrupt causes the system to resume normal processing, the
|
||||
interrupt may or may not have been handled when the BIOS returns
|
||||
from this call; thus, the caller should allow interrupts on return
|
||||
interrupt handlers may not retain control if the BIOS allows
|
||||
interrupts while in idle mode even if they are able to determine
|
||||
that they were called from idle mode
|
||||
the caller should issue this call continuously in a loop until it needs
|
||||
to perform some processing of its own
|
||||
SeeAlso: AX=1000h,AX=5306h,INT 2F/AX=1680h
|
||||
--------p-155306-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - CPU BUSY
|
||||
AX = 5306h
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (03h,0Bh) (see #00473)
|
||||
Notes: called to ensure that the system runs at full speed even on systems
|
||||
where the BIOS is unable to recognize increased activity (especially
|
||||
if interrupts are hooked by other programs and not chained to the
|
||||
BIOS)
|
||||
this call may be made even when the system is already running at full
|
||||
speed, but it will create unnecessary overhead
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
SeeAlso: AX=5305h
|
||||
--------p-155307-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - SET POWER STATE
|
||||
AX = 5307h
|
||||
BX = device ID (see #00474)
|
||||
CX = system state ID (see #00475)
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (01h,03h,09h,0Ah,0Bh,60h) (see #00473)
|
||||
Note: should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
SeeAlso: AX=530Ch
|
||||
|
||||
(Table 00474)
|
||||
Values for APM device IDs:
|
||||
0000h system BIOS
|
||||
0001h all devices for which the system BIOS manages power
|
||||
01xxh display (01FFh for all attached display devices)
|
||||
02xxh secondary storage (02FFh for all attached secondary storage devices)
|
||||
03xxh parallel ports (03FFh for all attached parallel ports)
|
||||
04xxh serial ports (04FFh for all attached serial ports)
|
||||
---APM v1.1+ ---
|
||||
05xxh network adapters (05FFh for all attached network adapters)
|
||||
06xxh PCMCIA sockets (06FFh for all)
|
||||
0700h-7FFFh reserved
|
||||
80xxh system battery devices (APM v1.2)
|
||||
8100h-DFFFh reserved
|
||||
Exxxh OEM-defined power device IDs
|
||||
F000h-FFFFh reserved
|
||||
|
||||
(Table 00475)
|
||||
Values for system state ID:
|
||||
0000h ready (not supported for device ID 0001h)
|
||||
0001h stand-by
|
||||
0002h suspend
|
||||
0003h off (not supported for device ID 0001h in APM v1.0)
|
||||
---APM v1.1---
|
||||
0004h last request processing notification (only for device ID 0001h)
|
||||
0005h last request rejected (only for device ID 0001h)
|
||||
0006h-001Fh reserved system states
|
||||
0020h-003Fh OEM-defined system states
|
||||
0040h-007Fh OEM-defined device states
|
||||
0080h-FFFFh reserved device states
|
||||
--------p-155307CX0001-----------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - SYSTEM STAND-BY
|
||||
AX = 5307h
|
||||
CX = 0001h
|
||||
BX = 0001h (device ID for all power-managed devices)
|
||||
Return: CF clear
|
||||
Notes: puts the entire system into stand-by mode; normally called in response
|
||||
to a System Stand-by Request notification after any necessary
|
||||
processing, but may also be invoked at the caller's discretion
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
the stand-by state is typically exited on an interrupt
|
||||
SeeAlso: AX=4280h,AX=5307h/CX=0002h"SUSPEND",AX=5307h/CX=0003h,AX=530Bh
|
||||
--------p-155307CX0002-----------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - SUSPEND SYSTEM
|
||||
AX = 5307h
|
||||
CX = 0002h
|
||||
BX = 0001h (device ID for all power-managed devices)
|
||||
Return: after system is resumed
|
||||
CF clear
|
||||
Notes: puts the entire system into a low-power suspended state; normally
|
||||
called in response to a Suspend System Request notification after
|
||||
any necessary processing, but may also be invoked at the caller's
|
||||
discretion
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
the caller may need to update its date and time values because the
|
||||
system could have been suspended for a long period of time
|
||||
SeeAlso: AX=5307h/CX=0001h"STAND-BY",AX=530Bh
|
||||
--------p-155307CX0003-----------------------
|
||||
INT 15 - Advanced Power Management v1.2 - TURN OFF SYSTEM
|
||||
AX = 5307h
|
||||
CX = 0003h
|
||||
BX = 0001h (device ID for all power-managed devices)
|
||||
Return: after system is resumed
|
||||
CF clear
|
||||
Notes: if supported by the system's power supply, turns off the system power
|
||||
SeeAlso: AX=5307h/CX=0001h"STAND-BY",AX=530Bh
|
||||
--------p-155308-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - ENABLE/DISABLE POWER MANAGEMENT
|
||||
AX = 5308h
|
||||
BX = device ID for all devices power-managed by APM
|
||||
0001h (APM v1.1+)
|
||||
FFFFh (APM v1.0)
|
||||
CX = new state
|
||||
0000h disabled
|
||||
0001h enabled
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (01h,03h,09h,0Ah,0Bh) (see #00473)
|
||||
Notes: when power management is disabled, the system BIOS will not
|
||||
automatically power down devices, enter stand-by or suspended mode,
|
||||
or perform any power-saving actions in response to AX=5305h calls
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
the APM BIOS should never be both disabled and disengaged at the same
|
||||
time
|
||||
SeeAlso: AX=5309h,AX=530Dh,AX=530Fh
|
||||
--------p-155309-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - RESTORE POWER-ON DEFAULTS
|
||||
AX = 5309h
|
||||
BX = device ID for all devices power-managed by APM
|
||||
0001h (APM v1.1)
|
||||
FFFFh (APM v1.0)
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Bh) (see #00473)
|
||||
Note: should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
SeeAlso: AX=5308h
|
||||
--------p-15530A-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - GET POWER STATUS
|
||||
AX = 530Ah
|
||||
BX = device ID
|
||||
0001h all devices power-managed by APM
|
||||
80xxh specific battery unit number XXh (01h-FFh) (APM v1.2)
|
||||
Return: CF clear if successful
|
||||
BH = AC line status
|
||||
00h off-line
|
||||
01h on-line
|
||||
02h on backup power (APM v1.1)
|
||||
FFh unknown
|
||||
other reserved
|
||||
BL = battery status (see #00476)
|
||||
CH = battery flag (APM v1.1+) (see #00477)
|
||||
CL = remaining battery life, percentage
|
||||
00h-64h (0-100) percentage of full charge
|
||||
FFh unknown
|
||||
DX = remaining battery life, time (APM v1.1) (see #00478)
|
||||
---if specific battery unit specified---
|
||||
SI = number of battery units currently installed
|
||||
CF set on error
|
||||
AH = error code (09h,0Ah) (see #00473)
|
||||
Notes: should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
supported in real mode (INT 15) and both 16-bit and 32-bit protected
|
||||
mode
|
||||
|
||||
(Table 00476)
|
||||
Values for APM v1.0+ battery status:
|
||||
00h high
|
||||
01h low
|
||||
02h critical
|
||||
03h charging
|
||||
FFh unknown
|
||||
other reserved
|
||||
SeeAlso: #00477,#00478
|
||||
|
||||
Bitfields for APM v1.1+ battery flag:
|
||||
Bit(s) Description (Table 00477)
|
||||
0 high
|
||||
1 low
|
||||
2 critical
|
||||
3 charging
|
||||
4 selected battery not present (APM v1.2)
|
||||
5-6 reserved (0)
|
||||
7 no system battery
|
||||
Note: all bits set (FFh) if unknown
|
||||
SeeAlso: #00476,#00478
|
||||
|
||||
Bitfields for APM v1.1+ remaining battery life:
|
||||
Bit(s) Description (Table 00478)
|
||||
15 time units: 0=seconds, 1=minutes
|
||||
14-0 battery life in minutes or seconds
|
||||
Note: all bits set (FFFFh) if unknown
|
||||
SeeAlso: #00476,#00477
|
||||
--------p-15530B-----------------------------
|
||||
INT 15 - Advanced Power Management v1.0+ - GET POWER MANAGEMENT EVENT
|
||||
AX = 530Bh
|
||||
Return: CF clear if successful
|
||||
BX = event code (see #00479)
|
||||
CX = event information (APM v1.2) if BX=0003h or BX=0004h
|
||||
bit 0: PCMCIA socket was powered down in suspend state
|
||||
CF set on error
|
||||
AH = error code (03h,0Bh,80h) (see #00473)
|
||||
Notes: although power management events are often asynchronous, notification
|
||||
will not be made until polled via this call to permit software to
|
||||
only receive event notification when it is prepared to process
|
||||
power management events; since these events are not very time-
|
||||
critical, it should be sufficient to poll once or twice per second
|
||||
the critical resume notification is made after the system resumes
|
||||
from an emergency suspension; normally, the system BIOS only notifies
|
||||
its partner that it wishes to suspend and relies on the partner to
|
||||
actually request the suspension, but no notification is made on an
|
||||
emergency suspension
|
||||
should not be called from within a hardware interrupt handler to avoid
|
||||
reentrance problems
|
||||
SeeAlso: AX=5307h,AX=5307h/CX=0001h"STAND-BY",AX=5307h/CX=0002h"SUSPEND"
|
||||
|
||||
(Table 00479)
|
||||
Values for APM event code:
|
||||
0001h system stand-by request
|
||||
0002h system suspend request
|
||||
0003h normal resume system notification
|
||||
0004h critical resume system notification
|
||||
0005h battery low notification
|
||||
---APM v1.1---
|
||||
0006h power status change notification
|
||||
0007h update time notification
|
||||
0008h critical system suspend notification
|
||||
0009h user system standby request notification
|
||||
000Ah user system suspend request notification
|
||||
000Bh system standby resume notification
|
||||
---APM v1.2---
|
||||
000Ch capabilities change notification (see AX=5310h)
|
||||
------
|
||||
000Dh-00FFh reserved system events
|
||||
01xxh reserved device events
|
||||
02xxh OEM-defined APM events
|
||||
0300h-FFFFh reserved
|
||||
--------p-15530C-----------------------------
|
||||
INT 15 - Advanced Power Management v1.1+ - GET POWER STATE
|
||||
AX = 530Ch
|
||||
BX = device ID (see #00474)
|
||||
Return: CF clear if successful
|
||||
CX = system state ID (see #00475)
|
||||
CF set on error
|
||||
AH = error code (01h,09h) (see #00473)
|
||||
SeeAlso: AX=5307h
|
||||
--------p-15530D-----------------------------
|
||||
INT 15 - Advanced Power Management v1.1+ - EN/DISABLE DEVICE POWER MANAGEMENT
|
||||
AX = 530Dh
|
||||
BX = device ID (see #00474)
|
||||
CX = function
|
||||
0000h disable power management
|
||||
0001h enable power management
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (01h,03h,09h,0Ah,0Bh) (see #00473)
|
||||
Desc: specify whether automatic power management should be active for a
|
||||
given device
|
||||
SeeAlso: AX=5308h,AX=530Fh
|
||||
--------p-15530E-----------------------------
|
||||
INT 15 - Advanced Power Management v1.1+ - DRIVER VERSION
|
||||
AX = 530Eh
|
||||
BX = device ID of system BIOS (0000h)
|
||||
CH = APM driver major version (BCD)
|
||||
CL = APM driver minor version (BCD) (02h for APM v1.2)
|
||||
Return: CF clear if successful
|
||||
AH = APM connection major version (BCD)
|
||||
AL = APM connection minor version (BCD)
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Bh) (see #00473)
|
||||
SeeAlso: AX=5300h,AX=5303h
|
||||
--------p-15530F-----------------------------
|
||||
INT 15 - Advanced Power Management v1.1+ - ENGAGE/DISENGAGE POWER MANAGEMENT
|
||||
AX = 530Fh
|
||||
BX = device ID (see #00474)
|
||||
CX = function
|
||||
0000h disengage power management
|
||||
0001h engage power management
|
||||
Return: CF clear if successful
|
||||
CF set on error
|
||||
AH = error code (01h,09h) (see #00473)
|
||||
Notes: unlike AX=5308h, this call does not affect the functioning of the APM
|
||||
BIOS
|
||||
when cooperative power management is disengaged, the APM BIOS performs
|
||||
automatic power management of the system or device
|
||||
SeeAlso: AX=5308h,AX=530Dh
|
||||
--------p-155310-----------------------------
|
||||
INT 15 - Advanced Power Management v1.2 - GET CAPABILITIES
|
||||
AX = 5310h
|
||||
BX = device ID (see #00474)
|
||||
0000h (APM BIOS)
|
||||
other reserved
|
||||
Return: CF clear if successful
|
||||
BL = number of battery units supported (00h if no system batteries)
|
||||
CX = capabilities flags (see #00480)
|
||||
CF set on error
|
||||
AH = error code (01h,09h,86h) (see #00473)
|
||||
Notes: this function is supported via the INT 15, 16-bit protected mode, and
|
||||
32-bit protected mode interfaces; it does not require that a
|
||||
connection be established prior to use
|
||||
this function will return the capabilities currently in effect, not
|
||||
any new settings which have been made but do not take effect until
|
||||
a system restart
|
||||
SeeAlso: AX=5300h,AX=530Fh,AX=5311h,AX=5312h,AX=5313h
|
||||
|
||||
Bitfields for APM v1.2 capabilities flags:
|
||||
Bit(s) Description (Table 00480)
|
||||
15-8 reserved
|
||||
7 PCMCIA Ring Indicator will wake up system from suspend mode
|
||||
6 PCMCIA Ring Indicator will wake up system from standby mode
|
||||
5 Resume on Ring Indicator will wake up system from suspend mode
|
||||
4 Resume on Ring Indicator will wake up system from standby mode
|
||||
3 resume timer will wake up system from suspend mode
|
||||
2 resume timer will wake up system from standby mode
|
||||
1 can enter global suspend state
|
||||
0 can enter global standby state
|
||||
--------p-155311-----------------------------
|
||||
INT 15 - Advanced Power Management v1.2 - GET/SET/DISABLE RESUME TIMER
|
||||
AX = 5311h
|
||||
BX = device ID (see #00474)
|
||||
0000h (APM BIOS)
|
||||
other reserved
|
||||
CL = function
|
||||
00h disable Resume Timer
|
||||
01h get Resume Timer
|
||||
02h set Resume Timer
|
||||
CH = resume time, seconds (BCD)
|
||||
DL = resume time, minutes (BCD)
|
||||
DH = resume time, hours (BCD)
|
||||
SI = resume date (BCD), high byte = month, low byte = day
|
||||
DI = resume date, year (BCD)
|
||||
Return: CF clear if successful
|
||||
---if getting timer---
|
||||
CH = resume time, seconds (BCD)
|
||||
DL = resume time, minutes (BCD)
|
||||
DH = resume time, hours (BCD)
|
||||
SI = resume date (BCD), high byte = month, low byte = day
|
||||
DI = resume date, year (BCD)
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Ah,0Bh,0Ch,0Dh,86h) (see #00473)
|
||||
Notes: this function is supported via the INT 15, 16-bit protected mode, and
|
||||
32-bit protected mode interfaces
|
||||
SeeAlso: AX=5300h,AX=5310h,AX=5312h,AX=5313h
|
||||
--------p-155312-----------------------------
|
||||
INT 15 - Advanced Power Management v1.2 - ENABLE/DISABLE RESUME ON RING
|
||||
AX = 5312h
|
||||
BX = device ID (see #00474)
|
||||
0000h (APM BIOS)
|
||||
other reserved
|
||||
CL = function
|
||||
00h disable Resume on Ring Indicator
|
||||
01h enable Resume on Ring Indicator
|
||||
02h get Resume on Ring Indicator status
|
||||
Return: CF clear if successful
|
||||
CX = resume status (0000h disabled, 0001h enabled)
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Ah,0Bh,0Ch,86h) (see #00473)
|
||||
Notes: this function is supported via the INT 15, 16-bit protected mode, and
|
||||
32-bit protected mode interfaces
|
||||
SeeAlso: AX=5300h,AX=5310h,AX=5311h,AX=5313h
|
||||
--------p-155313-----------------------------
|
||||
INT 15 - Advanced Power Management v1.2 - ENABLE/DISABLE TIMER-BASED REQUESTS
|
||||
AX = 5313h
|
||||
BX = device ID (see #00474)
|
||||
0000h (APM BIOS)
|
||||
other reserved
|
||||
CL = function
|
||||
00h disable timer-based requests
|
||||
01h enable timer-based requests
|
||||
02h get timer-based requests status
|
||||
Return: CF clear if successful
|
||||
CX = timer-based requests status (0000h disabled, 0001h enabled)
|
||||
CF set on error
|
||||
AH = error code (03h,09h,0Ah,0Bh,86h) (see #00473)
|
||||
Notes: this function is supported via the INT 15, 16-bit protected mode, and
|
||||
32-bit protected mode interfaces
|
||||
some BIOSes set AH on return even when successful
|
||||
SeeAlso: AX=5300h,AX=5310h,AX=5311h,AX=5312h
|
88
kernel/branches/docs/loader_doc.txt
Normal file
88
kernel/branches/docs/loader_doc.txt
Normal file
@ -0,0 +1,88 @@
|
||||
; (english text below)
|
||||
|
||||
;------------------------------------------
|
||||
; Èíòåðôåéñ ñîõðàíåíèÿ ïàðàìåòðîâ
|
||||
;------------------------------------------
|
||||
Åñëè ïðè ïåðåäà÷å óïðàâëåíèÿ ÿäðó çàãðóç÷èê óñòàíàâëèâàåò AX='KL',
|
||||
òî â DS:SI ÿäðî îæèäàåò äàëüíåãî óêàçàòåëÿ íà ñëåäóþùóþ ñòðóêòóðó:
|
||||
db âåðñèÿ ñòðóêòóðû, äîëæíà áûòü 1
|
||||
dw ôëàãè:
|
||||
áèò 0 óñòàíîâëåí = ïðèñóòñòâóåò îáðàç ðàìäèñêà â ïàìÿòè
|
||||
dd äàëüíèé óêàçàòåëü íà ïðîöåäóðó ñîõðàíåíèÿ ïàðàìåòðîâ
|
||||
ìîæåò áûòü 0, åñëè çàãðóç÷èê íå ïîääåðæèâàåò
|
||||
Ïðîöåäóðà ñîõðàíåíèÿ ïàðàìåòðîâ äîëæíà çàïèñàòü ïåðâûé ñåêòîð ÿäðà
|
||||
kernel.mnt íàçàä íà òî ìåñòî, îòêóäà îíà åãî ñ÷èòàëà; âîçâðàò èç
|
||||
ïðîöåäóðû îñóùåñòâëÿåòñÿ ïî retf.
|
||||
|
||||
;------------------------------------------
|
||||
; Óêàçàíèå çàãðóç÷èêîì ñèñòåìíîãî êàòàëîãà
|
||||
;------------------------------------------
|
||||
Ïåðåä ïåðåäà÷åé óïðàâëåíèÿ ÿäðó ìîãóò áûòü óñòàíîâëåíû ñëåäóþùèå ðåãèñòðû:
|
||||
CX='HA'
|
||||
DX='RD'
|
||||
Ýòî óêàçûâàåò íà òî, ÷òî ðåãèñòð BX óêàçûâàåò íà ñèñòåìíûé ðàçäåë. Êàòàëîã /kolibri/ íà
|
||||
ýòîì ðàçäåëå ÿâëÿåòñÿ ñèñòåìíûì, ê íåìó ìîæíî îáðàùàòüñÿ êàê ê /sys/
|
||||
|
||||
Âîçìîæíûå çíà÷åíèÿ ðåãèñòðà BL (óêàçûâàåò íà óñòðîéñòâî):
|
||||
'a' - Primary Master
|
||||
'b' - Primary Slave
|
||||
'c' - Secondary Master
|
||||
'd' - Secondary Slave
|
||||
'r' - RAM äèñê
|
||||
'm' - Ïðèâîäû CD-ROM
|
||||
|
||||
Âîçìîæíûå çíà÷åíèÿ ðåãèñòðà BH (óêàçûâàåò íà ðàçäåë):
|
||||
äëÿ BL='a','b','c','d','r' - óêàçûâàåò íà ðàçäåë, ãäå ðàñïîëîæåí ñèñòåìíûé êàòàëîã
|
||||
äëÿ BL='m',óêàçûâàåò íà íîìåð ôèçè÷åñêîãî óñòðîéñòâà, ñ êîòîðîãî íàäî íà÷èíàòü ïîèñê ñèñòåìíîãî êàòàëîãà.
|
||||
|
||||
ïðèìåðû çíà÷åíèé ðåãèñòðà BX:
|
||||
'a1' - /hd0/1/
|
||||
'a2' - /hd0/2/
|
||||
'b1' - /hd1/1/
|
||||
'd4' - /hd3/4/
|
||||
'm0' - ïîèñê ïî ñèäþêàì êàòàëîãà kolibri
|
||||
'r1' - /rd/1/
|
||||
|
||||
|
||||
;------------------------------------------
|
||||
; Interface for saving boot-screen settings
|
||||
;------------------------------------------
|
||||
If a loader sets AX='KL' when transferring control to the kernel,
|
||||
the kernel expects in DS:SI far pointer to the following structure:
|
||||
db structure version, must be 1
|
||||
dw flags
|
||||
bit 0 set = ramdisk image in memory is present
|
||||
dd far pointer to save settings procedure
|
||||
may be 0 if such procedure is not supported by loader
|
||||
Procedure for saving settings must write the first sector of the kernel
|
||||
kernel.mnt back to the place, from where it has been read; return from
|
||||
this procedure must be with retf.
|
||||
|
||||
;------------------------------------------
|
||||
; System directory information from loader
|
||||
;------------------------------------------
|
||||
Before transfer of control to the kernel following registers can be set:
|
||||
CX = 'HA'
|
||||
DX = 'RD'
|
||||
This indicates that the register BX identifies system partition. The folder /kolibri/ in
|
||||
this partition is system folder, it can be referenced as /sys/
|
||||
|
||||
Possible values for register BL (indicates the device):
|
||||
'a' - Primary Master
|
||||
'b' - Primary Slave
|
||||
'c' - Secondary Master
|
||||
'd' - Secondary Slave
|
||||
'r' - RAM disc
|
||||
'm' - ROM drives
|
||||
|
||||
Possible values for register BH (indicates section):
|
||||
for BL = 'a', 'b', 'c', 'd', 'r' to denote partition where the system folder
|
||||
for BL = 'm', indicates the number of physical devices, which must begin a systematic search directory.
|
||||
|
||||
Examples of register BX:
|
||||
'a1' - /hd0/1/
|
||||
'a2' - /hd0/2/
|
||||
'b1' - /hd1/1/
|
||||
'd4' - /hd3/4/
|
||||
'm0' - search directory 'kolibri' by all CD-ROMs
|
||||
'r1' - /rd/1/
|
4587
kernel/branches/docs/sysfuncr.txt
Normal file
4587
kernel/branches/docs/sysfuncr.txt
Normal file
File diff suppressed because it is too large
Load Diff
4488
kernel/branches/docs/sysfuncs.txt
Normal file
4488
kernel/branches/docs/sysfuncs.txt
Normal file
File diff suppressed because it is too large
Load Diff
1278
kernel/branches/drivers/RTL8029.asm
Normal file
1278
kernel/branches/drivers/RTL8029.asm
Normal file
File diff suppressed because it is too large
Load Diff
1315
kernel/branches/drivers/RTL8139.asm
Normal file
1315
kernel/branches/drivers/RTL8139.asm
Normal file
File diff suppressed because it is too large
Load Diff
1731
kernel/branches/drivers/ati2d.asm
Normal file
1731
kernel/branches/drivers/ati2d.asm
Normal file
File diff suppressed because it is too large
Load Diff
283
kernel/branches/drivers/codec.inc
Normal file
283
kernel/branches/drivers/codec.inc
Normal file
@ -0,0 +1,283 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
AD_LOSEL equ BIT5
|
||||
AD_HPSEL equ BIT10
|
||||
|
||||
align 4
|
||||
proc detect_codec
|
||||
locals
|
||||
codec_id dd ?
|
||||
endl
|
||||
|
||||
stdcall codec_read, dword 0x7C
|
||||
shl eax, 16
|
||||
mov [codec_id], eax
|
||||
|
||||
stdcall codec_read, dword 0x7E
|
||||
or eax, [codec_id]
|
||||
|
||||
mov [codec.chip_id], eax
|
||||
and eax, 0xFFFFFF00
|
||||
|
||||
mov edi, codecs
|
||||
@@:
|
||||
mov ebx, [edi]
|
||||
test ebx, ebx
|
||||
jz .unknown
|
||||
|
||||
cmp eax, ebx
|
||||
jne .next
|
||||
mov eax, [edi+4]
|
||||
mov [codec.ac_vendor_ids], eax
|
||||
mov esi, eax
|
||||
call SysMsgBoardStr
|
||||
stdcall detect_chip, [edi+8]
|
||||
|
||||
ret
|
||||
.next:
|
||||
add edi, 12
|
||||
jmp @B
|
||||
.unknown:
|
||||
mov [codec.ac_vendor_ids], ac_unknown
|
||||
mov [codec.chip_ids], chip_unknown
|
||||
|
||||
mov esi, chip_unknown
|
||||
call SysMsgBoardStr
|
||||
mov eax, [codec.chip_id]
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc detect_chip stdcall, chip_tab:dword
|
||||
|
||||
mov eax, [codec.chip_id]
|
||||
and eax, 0xFF
|
||||
|
||||
mov edi, [chip_tab]
|
||||
@@:
|
||||
mov ebx, [edi]
|
||||
cmp ebx, 0xFF
|
||||
je .unknown
|
||||
|
||||
cmp eax,ebx
|
||||
jne .next
|
||||
mov eax, [edi+4]
|
||||
mov [codec.chip_ids], eax
|
||||
mov esi, eax
|
||||
call SysMsgBoardStr
|
||||
ret
|
||||
.next:
|
||||
add edi, 8
|
||||
jmp @b
|
||||
.unknown:
|
||||
mov [codec.chip_ids], chip_unknown
|
||||
mov esi, chip_unknown
|
||||
call SysMsgBoardStr
|
||||
mov eax, [codec.chip_id]
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc setup_codec
|
||||
|
||||
xor eax, eax
|
||||
stdcall codec_write, dword CODEC_AUX_VOL
|
||||
|
||||
mov eax, 0x0B0B
|
||||
stdcall codec_write, dword CODEC_MASTER_VOL_REG
|
||||
|
||||
mov ax, 0x08
|
||||
stdcall codec_write, dword 0x0C
|
||||
|
||||
mov ax, 0x0808
|
||||
stdcall codec_write, dword CODEC_PCM_OUT_REG
|
||||
|
||||
mov ax, 0x0808
|
||||
stdcall codec_write, dword 0x10
|
||||
|
||||
mov ax, 0x0808
|
||||
stdcall codec_write, dword 0x12
|
||||
|
||||
mov ax, 0x0808
|
||||
stdcall codec_write, dword 0x16
|
||||
|
||||
|
||||
stdcall codec_read, dword CODEC_EXT_AUDIO_CTRL_REG
|
||||
and eax, 0FFFFh - BIT1 ; clear DRA (BIT1)
|
||||
or eax, BIT0 ; set VRA (BIT0)
|
||||
stdcall codec_write, dword CODEC_EXT_AUDIO_CTRL_REG
|
||||
|
||||
stdcall set_sample_rate, dword 48000
|
||||
|
||||
.init_error:
|
||||
xor eax, eax ; exit with error
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
; param
|
||||
; eax= volume -10000 - 0 for both channels
|
||||
|
||||
align 4
|
||||
set_master_vol:
|
||||
cmp eax, 0
|
||||
jl @F
|
||||
xor eax, eax
|
||||
jmp .set
|
||||
@@:
|
||||
cmp eax, -9450
|
||||
jg .set
|
||||
mov eax, -9450 ;clamp into 6 bits
|
||||
.set:
|
||||
cdq
|
||||
mov ebx, -150
|
||||
idiv ebx
|
||||
mov ah, al
|
||||
stdcall codec_write, dword CODEC_MASTER_VOL_REG
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
proc get_master_vol stdcall, pvol:dword
|
||||
|
||||
stdcall codec_read, dword CODEC_MASTER_VOL_REG
|
||||
and eax, 0x3F
|
||||
imul eax, -150
|
||||
mov ebx, [pvol]
|
||||
mov [ebx], eax
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc set_sample_rate stdcall, rate:dword
|
||||
mov eax, [rate]
|
||||
stdcall codec_write, dword CODEC_PCM_FRONT_DACRATE_REG
|
||||
ret
|
||||
endp
|
||||
|
||||
patch_AD:
|
||||
stdcall codec_read, 0x76
|
||||
or ax, BIT5+BIT10
|
||||
stdcall codec_write, 0x76
|
||||
ret
|
||||
|
||||
|
||||
|
||||
align 16
|
||||
ac_unknown db 'unknown manufacturer',13,10,0
|
||||
ac_Realtek db 'Realtek Semiconductor',13,10,0
|
||||
ac_Analog db 'Analog Devices',13,10,0
|
||||
ac_CMedia db 'C-Media Electronics',13,10,0
|
||||
ac_Cirrus db 'Cirrus Logic',13,10,0
|
||||
|
||||
chip_unknown db 'unknown codec id ', 0
|
||||
|
||||
CHIP_ANALOG equ 0x41445300
|
||||
CHIP_REALTEK equ 0x414C4700
|
||||
CHIP_CMEDIA equ 0x434D4900
|
||||
CHIP_CIRRUS equ 0x43525900
|
||||
|
||||
align 16
|
||||
codecs dd CHIP_ANALOG, ac_Analog, chips_Analog
|
||||
dd CHIP_CMEDIA, ac_CMedia, chips_CMedia
|
||||
dd CHIP_REALTEK,ac_Realtek, chips_Realtek
|
||||
dd CHIP_CIRRUS, ac_Cirrus, chips_Cirrus
|
||||
dd 0
|
||||
|
||||
align 16
|
||||
chips_Analog dd 0x03, chip_AD1819
|
||||
dd 0x40, chip_AD1881
|
||||
dd 0x48, chip_AD1881A
|
||||
dd 0x60, chip_AD1884
|
||||
dd 0x61, chip_AD1886
|
||||
dd 0x62, chip_AD1887
|
||||
dd 0x63, chip_AD1886A
|
||||
dd 0x70, chip_AD1980
|
||||
dd 0x75, chip_AD1985
|
||||
dd 0xFF
|
||||
|
||||
chips_Realtek:
|
||||
dd 0x20, chip_ALC650
|
||||
dd 0x21, chip_ALC650D
|
||||
dd 0x22, chip_ALC650E
|
||||
dd 0x23, chip_ALC650F
|
||||
dd 0x60, chip_ALC655
|
||||
dd 0x80, chip_ALC658
|
||||
dd 0x81, chip_ALC658D
|
||||
dd 0x90, chip_ALC850
|
||||
dd 0xFF
|
||||
|
||||
chips_CMedia dd 0x41, chip_CM9738
|
||||
dd 0x61, chip_CM9739
|
||||
dd 0x69, chip_CM9780
|
||||
dd 0x78, chip_CM9761
|
||||
dd 0x82, chip_CM9761
|
||||
dd 0x83, chip_CM9761
|
||||
dd 0xFF
|
||||
|
||||
chips_Cirrus dd 0x00, chip_CS4297
|
||||
dd 0x10, chip_CS4297A
|
||||
dd 0x20, chip_CS4298
|
||||
dd 0x28, chip_CS4294
|
||||
dd 0x30, chip_CS4299
|
||||
dd 0x34, chip_CS4299D
|
||||
dd 0x48, chip_CS4201
|
||||
dd 0x58, chip_CS4205
|
||||
dd 0x60, chip_CS4291
|
||||
dd 0x70, chip_CS4202
|
||||
dd 0xFF
|
||||
|
||||
|
||||
align 16
|
||||
;Analog Devices
|
||||
chip_AD1819 db 'AD1819 ',0dh,0ah,00h
|
||||
chip_AD1881 db 'AD1881 ',0dh,0ah,00h
|
||||
chip_AD1881A db 'AD1881A',0dh,0ah,00h
|
||||
chip_AD1884 db 'AD1885 ',0dh,0ah,00h
|
||||
chip_AD1885 db 'AD1885 ',0dh,0ah,00h
|
||||
chip_AD1886 db 'AD1886 ',0dh,0ah,00h
|
||||
chip_AD1886A db 'AD1886A',0dh,0ah,00h
|
||||
chip_AD1887 db 'AD1887 ',0dh,0ah,00h
|
||||
chip_AD1980 db 'AD1980 ',0dh,0ah,00h
|
||||
chip_AD1985 db 'AD1985 ',0dh,0ah,00h
|
||||
|
||||
;Realtek
|
||||
chip_ALC650 db 'ALC650 ',0dh,0ah,00h
|
||||
chip_ALC650D db 'ALC650D',0dh,0ah,00h
|
||||
chip_ALC650E db 'ALC650E',0dh,0ah,00h
|
||||
chip_ALC650F db 'ALC650F',0dh,0ah,00h
|
||||
chip_ALC655 db 'ALC655 ',0dh,0ah,00h
|
||||
chip_ALC658 db 'ALC658 ',0dh,0ah,00h
|
||||
chip_ALC658D db 'ALC658D',0dh,0ah,00h
|
||||
chip_ALC850 db 'ALC850 ',0dh,0ah,00h
|
||||
|
||||
;CMedia
|
||||
chip_CM9738 db 'CMI9738', 0dh,0ah,0
|
||||
chip_CM9739 db 'CMI9739', 0dh,0ah,0
|
||||
chip_CM9780 db 'CMI9780', 0dh,0ah,0
|
||||
chip_CM9761 db 'CMI9761', 0dh,0ah,0
|
||||
|
||||
;Cirrus
|
||||
chip_CS4297 db 'CS4297',13,10,0
|
||||
chip_CS4297A db 'CS4297A',13,10,0
|
||||
chip_CS4298 db 'CS4298',13,10,0
|
||||
chip_CS4294 db 'CS4294',13,10,0
|
||||
chip_CS4299 db 'CS4299',13,10,0
|
||||
chip_CS4299D db 'CS4299D',13,10,0
|
||||
chip_CS4201 db 'CS4201',13,10,0
|
||||
chip_CS4205 db 'CS4205',13,10,0
|
||||
chip_CS4291 db 'CS4291',13,10,0
|
||||
chip_CS4202 db 'CS4202',13,10,0
|
||||
|
||||
|
374
kernel/branches/drivers/com_mouse.asm
Normal file
374
kernel/branches/drivers/com_mouse.asm
Normal file
@ -0,0 +1,374 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; Includes source code by Kulakov Vladimir Gennadievich. ;;
|
||||
;; Modified by Mario79 and Rus. ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;driver sceletone
|
||||
|
||||
format MS COFF
|
||||
|
||||
DEBUG equ 0
|
||||
|
||||
include 'proc32.inc'
|
||||
include 'imports.inc'
|
||||
|
||||
API_VERSION equ 5 ;debug
|
||||
|
||||
struc IOCTL
|
||||
{ .handle dd ?
|
||||
.io_code dd ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
IOCTL IOCTL
|
||||
end virtual
|
||||
|
||||
public START
|
||||
public version
|
||||
|
||||
|
||||
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:
|
||||
;Detect_COM_Mouse:
|
||||
if DEBUG
|
||||
mov esi, msgInit
|
||||
call Boot_Log
|
||||
end if
|
||||
mov bx, 0x3f8
|
||||
call MSMouseSearch
|
||||
cmp AL,'M'
|
||||
jne @f
|
||||
;mov [com1_mouse_detected],1
|
||||
;mov [irq_owner+4*4], 1 ; IRQ4 owner is System
|
||||
|
||||
mov dx, bx
|
||||
inc dx ; 0x3f8 + 1
|
||||
mov al, 1
|
||||
out dx, al
|
||||
|
||||
stdcall AttachIntHandler, 4, irq4_handler, dword 0
|
||||
if DEBUG
|
||||
cmp eax, 0
|
||||
jne .label1
|
||||
|
||||
mov esi, msg_error_attach_int_handler
|
||||
call Boot_Log
|
||||
end if
|
||||
.label1:
|
||||
mov eax, 0
|
||||
mov ebx, 0x3F8
|
||||
mov ecx, 0x3FF
|
||||
call ReservePortArea
|
||||
|
||||
if DEBUG
|
||||
cmp eax, 1
|
||||
jne .go
|
||||
|
||||
mov esi, msg_error_reserve_ports
|
||||
call Boot_Log
|
||||
|
||||
.go:
|
||||
mov esi,boot_setmouse_type
|
||||
call Boot_Log
|
||||
end if
|
||||
@@:
|
||||
mov bx, 0x2f8
|
||||
call MSMouseSearch
|
||||
cmp AL,'M'
|
||||
jne .resume
|
||||
;mov [com2_mouse_detected],1
|
||||
;mov [irq_owner+3*4], 1 ; IRQ3 owner is System
|
||||
|
||||
stdcall AttachIntHandler, 3, irq3_handler, dword 0
|
||||
|
||||
mov eax, 0
|
||||
mov ebx, 0x2F8
|
||||
mov ecx, 0x3F8
|
||||
call ReservePortArea
|
||||
if DEBUG
|
||||
cmp eax, 1
|
||||
jne @f
|
||||
|
||||
mov esi, msg_error_reserve_ports
|
||||
call Boot_Log
|
||||
@@:
|
||||
|
||||
mov esi,boot_setmouse_type + 22
|
||||
call Boot_Log
|
||||
end if
|
||||
.resume:
|
||||
|
||||
stdcall RegService, my_service, service_proc
|
||||
if DEBUG
|
||||
cmp eax, 0
|
||||
jne @f
|
||||
|
||||
mov esi, msg_exit
|
||||
call Boot_Log
|
||||
end if
|
||||
@@:
|
||||
ret
|
||||
.fail:
|
||||
.exit:
|
||||
if DEBUG
|
||||
mov esi, msg_exit
|
||||
call Boot_Log
|
||||
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 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
|
||||
|
||||
align 4
|
||||
MSMouseSearch:
|
||||
; ÏÎÈÑÊ ÌÛØÈ ×ÅÐÅÇ COM-ÏÎÐÒÛ
|
||||
MouseSearch:
|
||||
; Óñòàíàâëèâàåì ñêîðîñòü
|
||||
; ïðèåìà/ïåðåäà÷è 1200 áîä
|
||||
; in bx COM Port Base Address
|
||||
mov DX, bx
|
||||
add DX,3
|
||||
in AL,DX
|
||||
or AL,80h ;óñòàíîâèòü áèò DLAB
|
||||
out DX,AL
|
||||
mov DX, bx
|
||||
mov AL,60h ;1200 áîä
|
||||
out DX,AL
|
||||
inc DX
|
||||
mov AL,0
|
||||
out DX,AL
|
||||
; Óñòàíîâèòü äëèíó ñëîâà 7 áèò, 1 ñòîïîâûé áèò,
|
||||
; ÷åòíîñòü íå êîíòðîëèðîâàòü
|
||||
mov DX, bx
|
||||
add DX,3
|
||||
mov AL,00000010b
|
||||
out DX,AL
|
||||
; Çàïðåòèòü âñå ïðåðûâàíè
|
||||
mov dx, bx
|
||||
inc dx
|
||||
mov AL,0
|
||||
out DX,AL
|
||||
; Ïðîâåðèòü, ÷òî óñòðîéñòâî ïîäêëþ÷åíî è ÿâëÿåòñ
|
||||
; ìûøüþ òèïà MSMouse
|
||||
; Îòêëþ÷èòü ïèòàíèå ìûøè è ïðåðûâàíè
|
||||
mov DX, bx
|
||||
add EDX,4 ;ðåãèñòð óïðàâëåíèÿ ìîäåìîì
|
||||
mov AL,0 ;ñáðîñèòü DTR, RTS è OUT2
|
||||
out DX,AL
|
||||
; Îæèäàòü 5 "òèêîâ" (0,2 ñ)
|
||||
mov ecx, 0xFFFF
|
||||
loop $
|
||||
; Âêëþ÷èòü ïèòàíèå ìûøè
|
||||
mov al, 1
|
||||
out dx, al
|
||||
mov ecx, 0xFFFF
|
||||
loop $
|
||||
; Î÷èñòèòü ðåãèñòð äàííûõ
|
||||
mov dx, bx
|
||||
in AL,DX
|
||||
add edx, 4
|
||||
mov AL, 1011b ;óñòàíîâèòü DTR è RTS è OUT2
|
||||
out DX,AL
|
||||
mov ecx, 0x1FFFF
|
||||
; Öèêë îïðîñà ïîðòà
|
||||
WaitData:
|
||||
; Îæèäàòü åùå 10 "òèêîâ"
|
||||
dec ecx
|
||||
cmp ecx,0
|
||||
je NoMouse
|
||||
; Ïðîâåðèòü íàëè÷èå èäåíòèôèêàöèîííîãî áàéòà
|
||||
mov DX, bx
|
||||
add DX,5
|
||||
in AL,DX
|
||||
test AL,1 ;Äàííûå ãîòîâû?
|
||||
jz WaitData
|
||||
; Ââåñòè äàííûå
|
||||
mov DX, bx
|
||||
in AL,DX
|
||||
NoMouse:
|
||||
ret
|
||||
|
||||
align 4
|
||||
irq3_handler:
|
||||
mov dx, 0x2f8
|
||||
mov esi, com2_mouse
|
||||
jmp irq_handler
|
||||
|
||||
align 4
|
||||
irq4_handler:
|
||||
mov dx, 0x3f8
|
||||
mov esi, com1_mouse
|
||||
|
||||
irq_handler:
|
||||
|
||||
; in: esi -> COM_MOUSE_DATA struc, dx = base port (xF8h)
|
||||
add edx, 5 ; xFDh
|
||||
in al, dx
|
||||
test al, 1 ; Äàííûå ãîòîâû?
|
||||
jz .Error
|
||||
; Ââåñòè äàííûå
|
||||
sub edx, 5
|
||||
in al, dx
|
||||
; Ñáðîñèòü ñòàðøèé íåçíà÷àùèé áèò
|
||||
and al, 01111111b
|
||||
|
||||
; Îïðåäåëèòü ïîðÿäêîâûé íîìåð ïðèíèìàåìîãî áàéòà
|
||||
cmp [esi+COM_MOUSE_DATA.MouseByteNumber], 2
|
||||
ja .Error
|
||||
jz .ThirdByte
|
||||
jp .SecondByte
|
||||
; Ñîõðàíèòü ïåðâûé áàéò äàííûõ
|
||||
.FirstByte:
|
||||
test al, 1000000b ; Ïåðâûé áàéò ïîñûëêè?
|
||||
jz .Error
|
||||
mov [esi+COM_MOUSE_DATA.FirstByte], al
|
||||
inc [esi+COM_MOUSE_DATA.MouseByteNumber]
|
||||
jmp .EndMouseInterrupt
|
||||
; Ñîõðàíèòü âòîðîé áàéò äàííûõ
|
||||
.SecondByte:
|
||||
test al, 1000000b
|
||||
jnz .Error
|
||||
mov [esi+COM_MOUSE_DATA.SecondByte], al
|
||||
inc [esi+COM_MOUSE_DATA.MouseByteNumber]
|
||||
jmp .EndMouseInterrupt
|
||||
; Ñîõðàíèòü òðåòèé áàéò äàííûõ
|
||||
.ThirdByte:
|
||||
test al, 1000000b
|
||||
jnz .Error
|
||||
mov [esi+COM_MOUSE_DATA.ThirdByte], al
|
||||
mov [esi+COM_MOUSE_DATA.MouseByteNumber], 0
|
||||
; (Ïàêåò äàííûõ îò ìûøè ïðèíÿò ïîëíîñòüþ).
|
||||
; Çàïèñàòü íîâîå çíà÷åíèå ñîñòîÿíèÿ êíîïîê ìûøè
|
||||
mov al, [esi+COM_MOUSE_DATA.FirstByte]
|
||||
mov ah, al
|
||||
shr al, 3
|
||||
and al, 2
|
||||
shr ah, 5
|
||||
and ah, 1
|
||||
add al, ah
|
||||
movzx eax, al
|
||||
mov [BTN_DOWN], eax
|
||||
|
||||
; Ïðèáàâèòü ïåðåìåùåíèå ïî X ê êîîðäèíàòå X
|
||||
mov al, [esi+COM_MOUSE_DATA.FirstByte]
|
||||
shl al, 6
|
||||
or al, [esi+COM_MOUSE_DATA.SecondByte]
|
||||
|
||||
cbw
|
||||
movzx eax, ax
|
||||
mov [MOUSE_X], eax
|
||||
|
||||
; Ïðèáàâèòü ïåðåìåùåíèå ïî Y ê êîîðäèíàòå Y
|
||||
mov al, [esi+COM_MOUSE_DATA.FirstByte]
|
||||
and al, 00001100b
|
||||
shl al, 4
|
||||
or al, [esi+COM_MOUSE_DATA.ThirdByte]
|
||||
|
||||
cbw
|
||||
movzx eax, ax
|
||||
neg eax
|
||||
mov [MOUSE_Y], eax
|
||||
|
||||
stdcall SetMouseData, [BTN_DOWN], [MOUSE_X], [MOUSE_Y], 0, 0
|
||||
|
||||
jmp .EndMouseInterrupt
|
||||
|
||||
.Error:
|
||||
; Ïðîèçîøåë ñáîé â ïîðÿäêå ïåðåäà÷è èíôîðìàöèè îò
|
||||
; ìûøè, îáíóëèòü ñ÷åò÷èê áàéòîâ ïàêåòà äàííûõ
|
||||
|
||||
mov [esi+COM_MOUSE_DATA.MouseByteNumber],0
|
||||
.EndMouseInterrupt:
|
||||
|
||||
ret
|
||||
|
||||
;all initialized data place here
|
||||
|
||||
align 4
|
||||
|
||||
struc COM_MOUSE_DATA {
|
||||
; Íîìåð ïðèíèìàåìîãî îò ìûøè áàéòà
|
||||
.MouseByteNumber db ?
|
||||
; Òðåõáàéòîâàÿ ñòðóêòóðà äàííûõ, ïåðåäàâàåìàÿ ìûøüþ
|
||||
.FirstByte db ?
|
||||
.SecondByte db ?
|
||||
.ThirdByte db ?
|
||||
;.timer_ticks_com dd ?
|
||||
}
|
||||
virtual at 0
|
||||
COM_MOUSE_DATA COM_MOUSE_DATA
|
||||
end virtual
|
||||
|
||||
com1_mouse COM_MOUSE_DATA
|
||||
com2_mouse COM_MOUSE_DATA
|
||||
|
||||
MOUSE_X dd 0
|
||||
MOUSE_Y dd 0
|
||||
BTN_DOWN dd 0
|
||||
|
||||
COMPortBaseAddr dw 3F8h
|
||||
|
||||
|
||||
|
||||
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
|
||||
|
||||
my_service db 'COM_Mouse',0 ;max 16 chars include zero
|
||||
|
||||
if DEBUG
|
||||
msgInit db 'Preved bugoga!',13,10,0
|
||||
boot_setmouse_type db 'Detected - COM1 mouse',13,10,0
|
||||
db 'Detected - COM2 mouse',13,10,0
|
||||
msg_error_reserve_ports db 'Error reserving ports!',13,10,0
|
||||
msg_error_attach_int_handler db 'Error attach interrupt handler!',13,10,0
|
||||
msg_exit db 'Exit!',13,10,0
|
||||
end if
|
||||
|
||||
section '.data' data readable writable align 16
|
||||
|
||||
;all uninitialized data place here
|
||||
|
1177
kernel/branches/drivers/ensoniq.asm
Normal file
1177
kernel/branches/drivers/ensoniq.asm
Normal file
File diff suppressed because it is too large
Load Diff
434
kernel/branches/drivers/fdo.inc
Normal file
434
kernel/branches/drivers/fdo.inc
Normal file
@ -0,0 +1,434 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
;
|
||||
; Formatted Debug Output (FDO)
|
||||
; Copyright (c) 2005-2006, mike.dld
|
||||
; Created: 2005-01-29, Changed: 2006-11-10
|
||||
;
|
||||
; For questions and bug reports, mail to mike.dld@gmail.com
|
||||
;
|
||||
; Available format specifiers are: %s, %d, %u, %x (with partial width support)
|
||||
;
|
||||
|
||||
; to be defined:
|
||||
; __DEBUG__ equ 1
|
||||
; __DEBUG_LEVEL__ equ 5
|
||||
|
||||
macro debug_func name {
|
||||
if used name
|
||||
name@of@func equ name
|
||||
}
|
||||
|
||||
macro debug_beginf {
|
||||
align 4
|
||||
name@of@func:
|
||||
}
|
||||
|
||||
debug_endf fix end if
|
||||
|
||||
macro DEBUGS _sign,[_str] {
|
||||
common
|
||||
local tp
|
||||
tp equ 0
|
||||
match _arg:_num,_str \{
|
||||
DEBUGS_N _sign,_num,_arg
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 _arg,tp _str \{
|
||||
DEBUGS_N _sign,,_arg
|
||||
\}
|
||||
}
|
||||
|
||||
macro DEBUGS_N _sign,_num,[_str] {
|
||||
common
|
||||
pushf
|
||||
pushad
|
||||
local ..str,..label,is_str
|
||||
is_str = 0
|
||||
forward
|
||||
if _str eqtype ''
|
||||
is_str = 1
|
||||
end if
|
||||
common
|
||||
if is_str = 1
|
||||
jmp ..label
|
||||
..str db _str,0
|
||||
..label:
|
||||
add esp,4*8+4
|
||||
mov edx,..str
|
||||
sub esp,4*8+4
|
||||
else
|
||||
mov edx,_str
|
||||
end if
|
||||
if ~_num eq
|
||||
if _num eqtype eax
|
||||
if _num in <eax,ebx,ecx,edx,edi,ebp,esp>
|
||||
mov esi,_num
|
||||
else if ~_num eq esi
|
||||
movzx esi,_num
|
||||
end if
|
||||
else if _num eqtype 0
|
||||
mov esi,_num
|
||||
else
|
||||
local tp
|
||||
tp equ 0
|
||||
match [_arg],_num \{
|
||||
mov esi,dword[_arg]
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 =dword[_arg],tp _num \{
|
||||
mov esi,dword[_arg]
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 =word[_arg],tp _num \{
|
||||
movzx esi,word[_arg]
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 =byte[_arg],tp _num \{
|
||||
movzx esi,byte[_arg]
|
||||
tp equ 1
|
||||
\}
|
||||
match =0,tp \{
|
||||
'Error: specified string width is incorrect'
|
||||
\}
|
||||
end if
|
||||
else
|
||||
mov esi,0x7FFFFFFF
|
||||
end if
|
||||
call fdo_debug_outstr
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
macro DEBUGD _sign,_dec {
|
||||
local tp
|
||||
tp equ 0
|
||||
match _arg:_num,_dec \{
|
||||
DEBUGD_N _sign,_num,_arg
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 _arg,tp _dec \{
|
||||
DEBUGD_N _sign,,_arg
|
||||
\}
|
||||
}
|
||||
|
||||
macro DEBUGD_N _sign,_num,_dec {
|
||||
pushf
|
||||
pushad
|
||||
if (~_num eq)
|
||||
if (_dec eqtype eax | _dec eqtype 0)
|
||||
'Error: precision allowed only for in-memory variables'
|
||||
end if
|
||||
if (~_num in <1,2,4>)
|
||||
if _sign
|
||||
'Error: 1, 2 and 4 are only allowed for precision in %d'
|
||||
else
|
||||
'Error: 1, 2 and 4 are only allowed for precision in %u'
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
if _dec eqtype eax
|
||||
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp>
|
||||
mov eax,_dec
|
||||
else if ~_dec eq eax
|
||||
if _sign = 1
|
||||
movsx eax,_dec
|
||||
else
|
||||
movzx eax,_dec
|
||||
end if
|
||||
end if
|
||||
else if _dec eqtype 0
|
||||
mov eax,_dec
|
||||
else
|
||||
add esp,4*8+4
|
||||
if _num eq
|
||||
mov eax,dword _dec
|
||||
else if _num = 1
|
||||
if _sign = 1
|
||||
movsx eax,byte _dec
|
||||
else
|
||||
movzx eax,byte _dec
|
||||
end if
|
||||
else if _num = 2
|
||||
if _sign = 1
|
||||
movsx eax,word _dec
|
||||
else
|
||||
movzx eax,word _dec
|
||||
end if
|
||||
else
|
||||
mov eax,dword _dec
|
||||
end if
|
||||
sub esp,4*8+4
|
||||
end if
|
||||
mov cl,_sign
|
||||
call fdo_debug_outdec
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
macro DEBUGH _sign,_hex {
|
||||
local tp
|
||||
tp equ 0
|
||||
match _arg:_num,_hex \{
|
||||
DEBUGH_N _sign,_num,_arg
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 _arg,tp _hex \{
|
||||
DEBUGH_N _sign,,_arg
|
||||
\}
|
||||
}
|
||||
|
||||
macro DEBUGH_N _sign,_num,_hex {
|
||||
pushf
|
||||
pushad
|
||||
if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>)
|
||||
'Error: 1..8 are only allowed for precision in %x'
|
||||
end if
|
||||
if _hex eqtype eax
|
||||
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
|
||||
if ~_hex eq eax
|
||||
mov eax,_hex
|
||||
end if
|
||||
mov edx,8
|
||||
else if _hex in <ax,bx,cx,dx,si,di,bp,sp>
|
||||
if ~_hex eq ax
|
||||
movzx eax,_hex
|
||||
end if
|
||||
shl eax,16
|
||||
if (_num eq)
|
||||
mov edx,4
|
||||
end if
|
||||
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh>
|
||||
if ~_hex eq al
|
||||
movzx eax,_hex
|
||||
end if
|
||||
shl eax,24
|
||||
if (_num eq)
|
||||
mov edx,2
|
||||
end if
|
||||
end if
|
||||
else if _hex eqtype 0
|
||||
mov eax,_hex
|
||||
else
|
||||
add esp,4*8+4
|
||||
mov eax,dword _hex
|
||||
sub esp,4*8+4
|
||||
end if
|
||||
if ~_num eq
|
||||
mov edx,_num
|
||||
else
|
||||
if ~_hex eqtype eax
|
||||
mov edx,8
|
||||
end if
|
||||
end if
|
||||
call fdo_debug_outhex
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
debug_func fdo_debug_outchar
|
||||
debug_beginf
|
||||
pushad
|
||||
movzx ebx,al
|
||||
mov eax,1
|
||||
; mov ecx,sys_msg_board
|
||||
; call ecx ; sys_msg_board
|
||||
stdcall SysMsgBoardChar
|
||||
popad
|
||||
ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outstr
|
||||
debug_beginf
|
||||
mov eax,1
|
||||
.l1: dec esi
|
||||
js .l2
|
||||
movzx ebx,byte[edx]
|
||||
or bl,bl
|
||||
jz .l2
|
||||
; mov ecx,sys_msg_board
|
||||
; call ecx ; sys_msg_board
|
||||
stdcall SysMsgBoardChar
|
||||
inc edx
|
||||
jmp .l1
|
||||
.l2: ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outdec
|
||||
debug_beginf
|
||||
or cl,cl
|
||||
jz @f
|
||||
or eax,eax
|
||||
jns @f
|
||||
neg eax
|
||||
push eax
|
||||
mov al,'-'
|
||||
call fdo_debug_outchar
|
||||
pop eax
|
||||
@@: push 10
|
||||
pop ecx
|
||||
push -'0'
|
||||
.l1: xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
test eax,eax
|
||||
jnz .l1
|
||||
.l2: pop eax
|
||||
add al,'0'
|
||||
jz .l3
|
||||
call fdo_debug_outchar
|
||||
jmp .l2
|
||||
.l3: ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outhex
|
||||
__fdo_hexdigits db '0123456789ABCDEF'
|
||||
debug_beginf
|
||||
mov cl,dl
|
||||
neg cl
|
||||
add cl,8
|
||||
shl cl,2
|
||||
rol eax,cl
|
||||
.l1: rol eax,4
|
||||
push eax
|
||||
and eax,0x0000000F
|
||||
mov al,[__fdo_hexdigits+eax]
|
||||
call fdo_debug_outchar
|
||||
pop eax
|
||||
dec edx
|
||||
jnz .l1
|
||||
ret
|
||||
debug_endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
macro DEBUGF _level,_format,[_arg] {
|
||||
common
|
||||
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__
|
||||
local ..f1,f2,a1,a2,c1,c2,c3,..lbl
|
||||
_debug_str_ equ __debug_str_ # a1
|
||||
a1 = 0
|
||||
c2 = 0
|
||||
c3 = 0
|
||||
f2 = 0
|
||||
repeat ..lbl-..f1
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
load c1 word from %-1
|
||||
end virtual
|
||||
if c1 = '%s'
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER S,a1,0,_arg
|
||||
else if c1 = '%x'
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER H,a1,0,_arg
|
||||
else if c1 = '%d' | c1 = '%u'
|
||||
local c4
|
||||
if c1 = '%d'
|
||||
c4 = 1
|
||||
else
|
||||
c4 = 0
|
||||
end if
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER D,a1,c4,_arg
|
||||
else if c1 = '\n'
|
||||
c3 = c3 + 1
|
||||
end if
|
||||
end repeat
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if (c1<>0)&(f2<>..lbl-..f1-1)
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
virtual at 0
|
||||
..f1 db _format,0
|
||||
..lbl:
|
||||
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3
|
||||
end virtual
|
||||
end if
|
||||
}
|
||||
|
||||
macro __include_debug_strings dummy,[_id,_fmt,_len] {
|
||||
common
|
||||
local c1,a1,a2
|
||||
forward
|
||||
if defined _len & ~_len eq
|
||||
_id:
|
||||
a1 = 0
|
||||
a2 = 0
|
||||
repeat _len
|
||||
virtual at 0
|
||||
db _fmt,0,0
|
||||
load c1 word from %+a2-1
|
||||
end virtual
|
||||
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u')
|
||||
db 0
|
||||
a2 = a2 + 1
|
||||
else if (c1='\n')
|
||||
dw $0A0D
|
||||
a1 = a1 + 1
|
||||
a2 = a2 + 1
|
||||
else
|
||||
db c1 and 0x0FF
|
||||
end if
|
||||
end repeat
|
||||
db 0
|
||||
end if
|
||||
}
|
||||
|
||||
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] {
|
||||
common
|
||||
local num
|
||||
num = 0
|
||||
forward
|
||||
if num = _num
|
||||
DEBUG#_letter _sign,_arg
|
||||
end if
|
||||
num = num+1
|
||||
common
|
||||
_num = _num+1
|
||||
}
|
||||
|
||||
macro include_debug_strings {
|
||||
if __DEBUG__ = 1
|
||||
match dbg_str,__debug_strings \{
|
||||
__include_debug_strings dbg_str
|
||||
\}
|
||||
end if
|
||||
}
|
1138
kernel/branches/drivers/i8255x.asm
Normal file
1138
kernel/branches/drivers/i8255x.asm
Normal file
File diff suppressed because it is too large
Load Diff
94
kernel/branches/drivers/imports.inc
Normal file
94
kernel/branches/drivers/imports.inc
Normal file
@ -0,0 +1,94 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
macro kernel_export [name]{
|
||||
forward
|
||||
if used name
|
||||
if DEBUG
|
||||
display 'uses: ',`name,#13,#10
|
||||
end if ;
|
||||
extrn name
|
||||
end if
|
||||
}
|
||||
; all exported kernel functions and data
|
||||
|
||||
|
||||
kernel_export \
|
||||
RegService,\
|
||||
GetService,\
|
||||
ServiceHandler,\
|
||||
AttachIntHandler,\
|
||||
GetIntHandler,\
|
||||
FpuSave,\
|
||||
FpuRestore,\
|
||||
ReservePortArea,\
|
||||
Boot_Log,\
|
||||
\
|
||||
PciApi,\
|
||||
PciRead32,\
|
||||
PciRead16,\
|
||||
PciRead8,\
|
||||
PciWrite8,\
|
||||
PciWrite16,\
|
||||
PciWrite32,\
|
||||
\
|
||||
AllocPage,\
|
||||
AllocPages,\
|
||||
FreePage,\
|
||||
MapPage,\
|
||||
MapSpace,\
|
||||
MapIoMem,\
|
||||
GetPgAddr,\
|
||||
CommitPages,\
|
||||
ReleasePages,\
|
||||
\
|
||||
AllocKernelSpace,\
|
||||
FreeKernelSpace,\
|
||||
KernelAlloc,\
|
||||
KernelFree,\
|
||||
UserAlloc,\
|
||||
UserFree,\
|
||||
Kmalloc,\
|
||||
Kfree,\
|
||||
CreateRingBuffer,\
|
||||
\
|
||||
GetPid,\
|
||||
CreateObject,\
|
||||
DestroyObject,\
|
||||
CreateEvent,\
|
||||
RaiseEvent,\
|
||||
WaitEvent,\
|
||||
DestroyEvent,\
|
||||
ClearEvent,\
|
||||
\
|
||||
LoadCursor,\
|
||||
SelectHwCursor,\
|
||||
SetHwCursor,\
|
||||
HwCursorRestore,\
|
||||
HwCursorCreate,\
|
||||
\
|
||||
SysMsgBoardStr,\
|
||||
SysMsgBoardChar,\
|
||||
GetCurrentTask,\
|
||||
LoadFile,\
|
||||
SendEvent,\
|
||||
SetMouseData,\
|
||||
Sleep,\
|
||||
GetTimerTicks,\
|
||||
\
|
||||
strncat,\
|
||||
strncpy,\
|
||||
strncmp,\
|
||||
strnlen,\
|
||||
strchr,\
|
||||
strrchr,\
|
||||
\
|
||||
LFBAddress,\
|
||||
\
|
||||
EthReceiver,\
|
||||
EthRegDev,\
|
||||
EthUnRegDev,\
|
||||
EthStruc2Dev
|
1312
kernel/branches/drivers/infinity.asm
Normal file
1312
kernel/branches/drivers/infinity.asm
Normal file
File diff suppressed because it is too large
Load Diff
164
kernel/branches/drivers/main.inc
Normal file
164
kernel/branches/drivers/main.inc
Normal file
@ -0,0 +1,164 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2006-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; Serge 2006-2008
|
||||
; email: infinity_sound@mail.ru
|
||||
|
||||
|
||||
PLAY_SYNC equ 0x80000000
|
||||
|
||||
PCM_ALL equ 0
|
||||
|
||||
PCM_OUT equ 0x08000000
|
||||
PCM_RING equ 0x10000000
|
||||
PCM_STATIC equ 0x20000000
|
||||
PCM_FLOAT equ 0x40000000 ;reserved
|
||||
PCM_FILTER equ 0x80000000 ;reserved
|
||||
|
||||
PCM_2_16_48 equ 1
|
||||
PCM_1_16_48 equ 2
|
||||
|
||||
PCM_2_16_44 equ 3
|
||||
PCM_1_16_44 equ 4
|
||||
|
||||
PCM_2_16_32 equ 5
|
||||
PCM_1_16_32 equ 6
|
||||
|
||||
PCM_2_16_24 equ 7
|
||||
PCM_1_16_24 equ 8
|
||||
|
||||
PCM_2_16_22 equ 9
|
||||
PCM_1_16_22 equ 10
|
||||
|
||||
PCM_2_16_16 equ 11
|
||||
PCM_1_16_16 equ 12
|
||||
|
||||
PCM_2_16_12 equ 13
|
||||
PCM_1_16_12 equ 14
|
||||
|
||||
PCM_2_16_11 equ 15
|
||||
PCM_1_16_11 equ 16
|
||||
|
||||
PCM_2_16_8 equ 17
|
||||
PCM_1_16_8 equ 18
|
||||
|
||||
PCM_2_8_48 equ 19
|
||||
PCM_1_8_48 equ 20
|
||||
|
||||
PCM_2_8_44 equ 21
|
||||
PCM_1_8_44 equ 22
|
||||
|
||||
PCM_2_8_32 equ 23
|
||||
PCM_1_8_32 equ 24
|
||||
|
||||
PCM_2_8_24 equ 25
|
||||
PCM_1_8_24 equ 26
|
||||
|
||||
PCM_2_8_22 equ 27
|
||||
PCM_1_8_22 equ 28
|
||||
|
||||
PCM_2_8_16 equ 29
|
||||
PCM_1_8_16 equ 30
|
||||
|
||||
PCM_2_8_12 equ 31
|
||||
PCM_1_8_12 equ 32
|
||||
|
||||
PCM_2_8_11 equ 33
|
||||
PCM_1_8_11 equ 34
|
||||
|
||||
PCM_2_8_8 equ 35
|
||||
PCM_1_8_8 equ 36
|
||||
|
||||
SRV_GETVERSION equ 0
|
||||
SND_CREATE_BUFF equ 1
|
||||
SND_DESTROY_BUFF equ 2
|
||||
SND_SETFORMAT equ 3
|
||||
SND_GETFORMAT equ 4
|
||||
SND_RESET equ 5
|
||||
SND_SETPOS equ 6
|
||||
SND_GETPOS equ 7
|
||||
SND_SETBUFF equ 8
|
||||
SND_OUT equ 9
|
||||
SND_PLAY equ 10
|
||||
SND_STOP equ 11
|
||||
SND_SETVOLUME equ 12
|
||||
SND_GETVOLUME equ 13
|
||||
SND_SETPAN equ 14
|
||||
SND_GETPAN equ 15
|
||||
SND_GETBUFFSIZE equ 16
|
||||
SND_GETFREESPACE equ 17
|
||||
|
||||
struc STREAM
|
||||
{
|
||||
.magic dd ? ;'WAVE'
|
||||
.destroy dd ? ;internal destructor
|
||||
.fd dd ? ;next object in list
|
||||
.bk dd ? ;prev object in list
|
||||
.pid dd ? ;owner id
|
||||
|
||||
.size dd ?
|
||||
.str_fd dd ?
|
||||
.str_bk dd ?
|
||||
.device dd ?
|
||||
.format dd ?
|
||||
.flags dd ?
|
||||
|
||||
.out_base dd ?
|
||||
.out_wp dd ?
|
||||
.out_rp dd ?
|
||||
.out_count dd ?
|
||||
.out_top dd ? ;16*4
|
||||
|
||||
.r_size dd ?
|
||||
.r_dt dd ?
|
||||
.r_silence dd ?
|
||||
.resample dd ?
|
||||
.l_vol dd ?
|
||||
.r_vol dd ?
|
||||
.l_amp dw ?
|
||||
.r_amp dw ?
|
||||
.pan dd ?
|
||||
.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 ?
|
||||
}
|
||||
|
||||
STREAM_SIZE equ 36*4
|
||||
FD_OFFSET equ 24
|
||||
|
||||
virtual at 0
|
||||
STREAM STREAM
|
||||
end virtual
|
||||
|
||||
struc WAVE_HEADER
|
||||
{ .riff_id dd ?
|
||||
.riff_size dd ?
|
||||
.riff_format dd ?
|
||||
|
||||
.fmt_id dd ?
|
||||
.fmt_size dd ?
|
||||
.format_tag dw ?
|
||||
.channels dw ?
|
||||
.freq dd ?
|
||||
.bytes_sec dd ?
|
||||
.block_align dw ?
|
||||
.bits_sample dw ?
|
||||
|
||||
.data_id dd ?
|
||||
.data_size dd ?
|
||||
}
|
||||
|
247
kernel/branches/drivers/mix_mmx.inc
Normal file
247
kernel/branches/drivers/mix_mmx.inc
Normal file
@ -0,0 +1,247 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; params
|
||||
; edi= output
|
||||
; eax= input stream 1
|
||||
; ebx= input stream 2
|
||||
|
||||
if used mmx_mix_2
|
||||
|
||||
align 4
|
||||
mmx_mix_2:
|
||||
movq mm0, [eax]
|
||||
movq mm1, [eax+8]
|
||||
movq mm2, [eax+16]
|
||||
movq mm3, [eax+24]
|
||||
movq mm4, [eax+32]
|
||||
movq mm5, [eax+40]
|
||||
movq mm6, [eax+48]
|
||||
movq mm7, [eax+56]
|
||||
|
||||
paddsw mm0, [ebx]
|
||||
movq [edi], mm0
|
||||
paddsw mm1,[ebx+8]
|
||||
movq [edi+8], mm1
|
||||
paddsw mm2, [ebx+16]
|
||||
movq [edi+16], mm2
|
||||
paddsw mm3, [ebx+24]
|
||||
movq [edi+24], mm3
|
||||
paddsw mm4, [ebx+32]
|
||||
movq [edi+32], mm4
|
||||
paddsw mm5, [ebx+40]
|
||||
movq [edi+40], mm5
|
||||
paddsw mm6, [ebx+48]
|
||||
movq [edi+48], mm6
|
||||
paddsw mm7, [ebx+56]
|
||||
movq [edi+56], mm7
|
||||
|
||||
movq mm0, [eax+64]
|
||||
movq mm1, [eax+72]
|
||||
movq mm2, [eax+80]
|
||||
movq mm3, [eax+88]
|
||||
movq mm4, [eax+96]
|
||||
movq mm5, [eax+104]
|
||||
movq mm6, [eax+112]
|
||||
movq mm7, [eax+120]
|
||||
|
||||
paddsw mm0, [ebx+64]
|
||||
movq [edi+64], mm0
|
||||
paddsw mm1, [ebx+72]
|
||||
movq [edi+72], mm1
|
||||
paddsw mm2, [ebx+80]
|
||||
movq [edi+80], mm2
|
||||
paddsw mm3, [ebx+88]
|
||||
movq [edi+88], mm3
|
||||
paddsw mm4, [ebx+96]
|
||||
movq [edi+96], mm4
|
||||
paddsw mm5, [ecx+104]
|
||||
movq [edx+104], mm5
|
||||
paddsw mm6, [ebx+112]
|
||||
movq [edi+112], mm6
|
||||
paddsw mm7, [ebx+120]
|
||||
movq [edi+120], mm7
|
||||
ret
|
||||
|
||||
align 4
|
||||
mmx_mix_3:
|
||||
movq mm0, [eax]
|
||||
movq mm1, [eax+8]
|
||||
movq mm2, [eax+16]
|
||||
movq mm3, [eax+24]
|
||||
movq mm4, [eax+32]
|
||||
movq mm5, [eax+40]
|
||||
movq mm6, [eax+48]
|
||||
movq mm7, [eax+56]
|
||||
|
||||
paddsw mm0, [ebx]
|
||||
paddsw mm1, [ebx+8]
|
||||
paddsw mm2, [ebx+16]
|
||||
paddsw mm3, [ebx+24]
|
||||
paddsw mm4, [ebx+32]
|
||||
paddsw mm5, [ebx+40]
|
||||
paddsw mm6, [ebx+48]
|
||||
paddsw mm7, [ebx+56]
|
||||
paddsw mm0, [ecx]
|
||||
movq [edi], mm0
|
||||
paddsw mm1,[ecx+8]
|
||||
movq [edi+8], mm1
|
||||
paddsw mm2, [ecx+16]
|
||||
movq [edi+16], mm2
|
||||
paddsw mm3, [ecx+24]
|
||||
movq [edi+24], mm3
|
||||
paddsw mm4, [ecx+32]
|
||||
movq [edi+32], mm4
|
||||
paddsw mm5, [ecx+40]
|
||||
movq [edi+40], mm5
|
||||
paddsw mm6, [ecx+48]
|
||||
movq [edi+48], mm6
|
||||
paddsw mm7, [ecx+56]
|
||||
movq [edi+56], mm7
|
||||
|
||||
movq mm0, [eax+64]
|
||||
movq mm1, [eax+72]
|
||||
movq mm2, [eax+80]
|
||||
movq mm3, [eax+88]
|
||||
movq mm4, [eax+96]
|
||||
movq mm5, [eax+104]
|
||||
movq mm6, [eax+112]
|
||||
movq mm7, [eax+120]
|
||||
paddsw mm0, [ebx+64]
|
||||
paddsw mm1, [ebx+72]
|
||||
paddsw mm2, [ebx+80]
|
||||
paddsw mm3, [ebx+88]
|
||||
paddsw mm4, [ebx+96]
|
||||
paddsw mm5, [ebx+104]
|
||||
paddsw mm6, [ebx+112]
|
||||
paddsw mm7, [ebx+120]
|
||||
paddsw mm0, [ecx+64]
|
||||
movq [edi+64], mm0
|
||||
paddsw mm1, [ecx+72]
|
||||
movq [edi+72], mm1
|
||||
paddsw mm2, [ecx+80]
|
||||
movq [edi+80], mm2
|
||||
paddsw mm3, [ecx+88]
|
||||
movq [edi+88], mm3
|
||||
paddsw mm4, [ecx+96]
|
||||
movq [edi+96], mm4
|
||||
paddsw mm5, [ecx+104]
|
||||
movq [edi+104], mm5
|
||||
paddsw mm6, [ecx+112]
|
||||
movq [edi+112], mm6
|
||||
paddsw mm7, [ecx+120]
|
||||
movq [edi+120], mm7
|
||||
ret
|
||||
|
||||
align 4
|
||||
mmx_mix_4:
|
||||
|
||||
movq mm0, [eax]
|
||||
movq mm2, [eax+8]
|
||||
movq mm4, [eax+16]
|
||||
movq mm6, [eax+24]
|
||||
movq mm1, [ebx]
|
||||
movq mm3, [ebx+8]
|
||||
movq mm5, [ebx+16]
|
||||
movq mm7, [ebx+24]
|
||||
paddsw mm0, [ecx]
|
||||
paddsw mm2, [ecx+8]
|
||||
paddsw mm4, [ecx+16]
|
||||
paddsw mm6, [ecx+24]
|
||||
paddsw mm1, [edx]
|
||||
paddsw mm3, [edx+8]
|
||||
paddsw mm5, [edx+16]
|
||||
paddsw mm7, [edx+24]
|
||||
|
||||
paddsw mm0, mm1
|
||||
movq [edi], mm0
|
||||
paddsw mm2, mm3
|
||||
movq [edi+8], mm2
|
||||
paddsw mm4, mm5
|
||||
movq [edi+16], mm4
|
||||
paddsw mm5, mm6
|
||||
movq [edi+24], mm6
|
||||
|
||||
movq mm0, [eax+32]
|
||||
movq mm2, [eax+40]
|
||||
movq mm4, [eax+48]
|
||||
movq mm6, [eax+56]
|
||||
movq mm1, [ebx+32]
|
||||
movq mm3, [ebx+40]
|
||||
movq mm5, [ebx+48]
|
||||
movq mm7, [ebx+56]
|
||||
paddsw mm0, [ecx+32]
|
||||
paddsw mm2, [ecx+40]
|
||||
paddsw mm4, [ecx+48]
|
||||
paddsw mm6, [ecx+56]
|
||||
paddsw mm1, [edx+32]
|
||||
paddsw mm3, [edx+40]
|
||||
paddsw mm5, [edx+48]
|
||||
paddsw mm7, [edx+56]
|
||||
|
||||
paddsw mm0, mm1
|
||||
movq [edi+32], mm0
|
||||
paddsw mm2, mm2
|
||||
movq [edi+40], mm2
|
||||
paddsw mm4, mm5
|
||||
movq [edi+48], mm4
|
||||
paddsw mm6, mm7
|
||||
movq [edi+56], mm6
|
||||
|
||||
movq mm0, [eax+64]
|
||||
movq mm2, [eax+72]
|
||||
movq mm4, [eax+80]
|
||||
movq mm6, [eax+88]
|
||||
movq mm1, [ebx+64]
|
||||
movq mm3, [ebx+72]
|
||||
movq mm5, [ebx+80]
|
||||
movq mm7, [ebx+88]
|
||||
paddsw mm0, [ecx+64]
|
||||
paddsw mm2, [ecx+72]
|
||||
paddsw mm4, [ecx+80]
|
||||
paddsw mm6, [ecx+88]
|
||||
paddsw mm1, [edx+64]
|
||||
paddsw mm3, [edx+72]
|
||||
paddsw mm5, [edx+80]
|
||||
paddsw mm7, [edx+88]
|
||||
|
||||
paddsw mm0, mm1
|
||||
movq [edi+64], mm0
|
||||
paddsw mm2, mm3
|
||||
movq [edi+72], mm2
|
||||
paddsw mm4, mm5
|
||||
movq [edi+80], mm4
|
||||
paddsw mm6, mm5
|
||||
movq [edi+88], mm7
|
||||
|
||||
movq mm0, [eax+96]
|
||||
movq mm2, [eax+104]
|
||||
movq mm4, [eax+112]
|
||||
movq mm6, [eax+120]
|
||||
movq mm1, [ebx+96]
|
||||
movq mm3, [ebx+104]
|
||||
movq mm5, [ebx+112]
|
||||
movq mm7, [ebx+120]
|
||||
paddsw mm0, [ecx+96]
|
||||
paddsw mm2, [ecx+104]
|
||||
paddsw mm4, [ecx+112]
|
||||
paddsw mm6, [ecx+120]
|
||||
paddsw mm1, [edx+96]
|
||||
paddsw mm3, [edx+104]
|
||||
paddsw mm5, [edx+112]
|
||||
paddsw mm7, [edx+120]
|
||||
paddsw mm0, mm1
|
||||
movq [eax+96], mm0
|
||||
paddsw mm2, mm3
|
||||
movq [edi+104], mm2
|
||||
paddsw mm4, mm5
|
||||
movq [edi+112], mm4
|
||||
paddsw mm6, mm7
|
||||
movq [edi+120], mm6
|
||||
ret
|
||||
|
||||
end if
|
145
kernel/branches/drivers/mix_sse2.inc
Normal file
145
kernel/branches/drivers/mix_sse2.inc
Normal file
@ -0,0 +1,145 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
if used mmx128_mix_2
|
||||
|
||||
align 4
|
||||
mmx128_mix_2:
|
||||
prefetcht1 [eax+128]
|
||||
prefetcht1 [ebx+128]
|
||||
|
||||
movaps xmm0, [eax]
|
||||
movaps xmm1, [eax+16]
|
||||
movaps xmm2, [eax+32]
|
||||
movaps xmm3, [eax+48]
|
||||
movaps xmm4, [eax+64]
|
||||
movaps xmm5, [eax+80]
|
||||
movaps xmm6, [eax+96]
|
||||
movaps xmm7, [eax+112]
|
||||
|
||||
paddsw xmm0, [ebx]
|
||||
movaps [edi], xmm0
|
||||
paddsw xmm1,[ebx+16]
|
||||
movaps [edi+16], xmm1
|
||||
paddsw xmm2, [ebx+32]
|
||||
movaps [edi+32], xmm2
|
||||
paddsw xmm3, [ebx+48]
|
||||
movaps [edi+48], xmm3
|
||||
paddsw xmm4, [ebx+64]
|
||||
movaps [edi+64], xmm4
|
||||
paddsw xmm5, [ebx+80]
|
||||
movaps [edi+80], xmm5
|
||||
paddsw xmm6, [ebx+96]
|
||||
movaps [edi+96], xmm6
|
||||
paddsw xmm7, [ebx+112]
|
||||
movaps [edi+112], xmm7
|
||||
ret
|
||||
|
||||
align 4
|
||||
mmx128_mix_3:
|
||||
prefetcht1 [eax+128]
|
||||
prefetcht1 [ebx+128]
|
||||
prefetcht1 [ecx+128]
|
||||
|
||||
movaps xmm0, [eax]
|
||||
movaps xmm1, [eax+16]
|
||||
movaps xmm2, [eax+32]
|
||||
movaps xmm3, [eax+48]
|
||||
movaps xmm4, [eax+64]
|
||||
movaps xmm5, [eax+80]
|
||||
movaps xmm6, [eax+96]
|
||||
movaps xmm7, [eax+112]
|
||||
|
||||
paddsw xmm0, [ebx]
|
||||
paddsw xmm1, [ebx+16]
|
||||
paddsw xmm2, [ebx+32]
|
||||
paddsw xmm3, [ebx+48]
|
||||
paddsw xmm4, [ebx+64]
|
||||
paddsw xmm5, [ebx+80]
|
||||
paddsw xmm6, [ebx+96]
|
||||
paddsw xmm7, [ebx+112]
|
||||
|
||||
paddsw xmm0, [ecx]
|
||||
movaps [edi], xmm0
|
||||
paddsw xmm1, [ecx+16]
|
||||
movaps [edi+16], xmm1
|
||||
paddsw xmm2, [ecx+32]
|
||||
movaps [edi+32], xmm2
|
||||
paddsw xmm3, [ecx+48]
|
||||
movaps [edi+48], xmm3
|
||||
paddsw xmm4, [ecx+64]
|
||||
movaps [edi+64], xmm4
|
||||
paddsw xmm5, [ecx+80]
|
||||
movaps [edi+80], xmm5
|
||||
paddsw xmm6, [ecx+96]
|
||||
movaps [edi+96], xmm6
|
||||
paddsw xmm7, [ecx+112]
|
||||
movaps [edi+112], xmm7
|
||||
ret
|
||||
|
||||
align 4
|
||||
mmx128_mix_4:
|
||||
prefetcht1 [eax+128]
|
||||
prefetcht1 [ebx+128]
|
||||
prefetcht1 [ecx+128]
|
||||
prefetcht1 [edx+128]
|
||||
|
||||
movaps xmm0, [eax]
|
||||
movaps xmm2, [eax+16]
|
||||
movaps xmm4, [eax+32]
|
||||
movaps xmm6, [eax+48]
|
||||
movaps xmm1, [ebx]
|
||||
movaps xmm3, [ebx+16]
|
||||
movaps xmm5, [ebx+32]
|
||||
movaps xmm7, [ebx+48]
|
||||
|
||||
paddsw xmm0, [ecx]
|
||||
paddsw xmm2, [ecx+16]
|
||||
paddsw xmm4, [ecx+32]
|
||||
paddsw xmm6, [ecx+48]
|
||||
paddsw xmm1, [edx]
|
||||
paddsw xmm3, [edx+16]
|
||||
paddsw xmm5, [edx+32]
|
||||
paddsw xmm7, [edx+48]
|
||||
|
||||
paddsw xmm0, xmm1
|
||||
movaps [edi], xmm0
|
||||
paddsw xmm2, xmm3
|
||||
movaps [edi+16], xmm2
|
||||
paddsw xmm4, xmm5
|
||||
movaps [edi+32], xmm4
|
||||
paddsw xmm6, xmm7
|
||||
movaps [edi+48], xmm6
|
||||
|
||||
movaps xmm0, [eax+64]
|
||||
movaps xmm2, [eax+80]
|
||||
movaps xmm4, [eax+96]
|
||||
movaps xmm6, [eax+112]
|
||||
|
||||
movaps xmm1, [ebx+64]
|
||||
movaps xmm3, [ebx+80]
|
||||
movaps xmm5, [ebx+96]
|
||||
movaps xmm7, [ebx+112]
|
||||
paddsw xmm0, [ecx+64]
|
||||
paddsw xmm2, [ecx+80]
|
||||
paddsw xmm4, [ecx+96]
|
||||
paddsw xmm6, [ecx+112]
|
||||
|
||||
paddsw xmm1, [edx+64]
|
||||
paddsw xmm3, [edx+80]
|
||||
paddsw xmm5, [edx+96]
|
||||
paddsw xmm7, [edx+112]
|
||||
paddsw xmm0, xmm1
|
||||
movaps [edi+64], xmm0
|
||||
paddsw xmm2, xmm3
|
||||
movaps [edi+80], xmm2
|
||||
paddsw xmm4, xmm5
|
||||
movaps [edi+96], xmm4
|
||||
paddsw xmm6, xmm7
|
||||
movaps [edi+112], xmm6
|
||||
ret
|
||||
end if
|
1263
kernel/branches/drivers/mixer.asm
Normal file
1263
kernel/branches/drivers/mixer.asm
Normal file
File diff suppressed because it is too large
Load Diff
268
kernel/branches/drivers/proc32.inc
Normal file
268
kernel/branches/drivers/proc32.inc
Normal file
@ -0,0 +1,268 @@
|
||||
|
||||
; Macroinstructions for defining and calling procedures
|
||||
|
||||
macro stdcall proc,[arg] ; directly call STDCALL procedure
|
||||
{ common
|
||||
if ~ arg eq
|
||||
reverse
|
||||
pushd arg
|
||||
common
|
||||
end if
|
||||
call proc }
|
||||
|
||||
macro invoke proc,[arg] ; indirectly call STDCALL procedure
|
||||
{ common
|
||||
if ~ arg eq
|
||||
reverse
|
||||
pushd arg
|
||||
common
|
||||
end if
|
||||
call [proc] }
|
||||
|
||||
macro ccall proc,[arg] ; directly call CDECL procedure
|
||||
{ common
|
||||
size@ccall = 0
|
||||
if ~ arg eq
|
||||
reverse
|
||||
pushd arg
|
||||
size@ccall = size@ccall+4
|
||||
common
|
||||
end if
|
||||
call proc
|
||||
if size@ccall
|
||||
add esp,size@ccall
|
||||
end if }
|
||||
|
||||
macro cinvoke proc,[arg] ; indirectly call CDECL procedure
|
||||
{ common
|
||||
size@ccall = 0
|
||||
if ~ arg eq
|
||||
reverse
|
||||
pushd arg
|
||||
size@ccall = size@ccall+4
|
||||
common
|
||||
end if
|
||||
call [proc]
|
||||
if size@ccall
|
||||
add esp,size@ccall
|
||||
end if }
|
||||
|
||||
macro proc [args] ; define procedure
|
||||
{ common
|
||||
match name params, args>
|
||||
\{ define@proc name,<params \} }
|
||||
|
||||
prologue@proc equ prologuedef
|
||||
|
||||
macro prologuedef procname,flag,parmbytes,localbytes,reglist
|
||||
{ if parmbytes | localbytes
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
if localbytes
|
||||
sub esp,localbytes
|
||||
end if
|
||||
end if
|
||||
irps reg, reglist \{ push reg \} }
|
||||
|
||||
epilogue@proc equ epiloguedef
|
||||
|
||||
macro epiloguedef procname,flag,parmbytes,localbytes,reglist
|
||||
{ irps reg, reglist \{ reverse pop reg \}
|
||||
if parmbytes | localbytes
|
||||
leave
|
||||
end if
|
||||
if flag and 10000b
|
||||
retn
|
||||
else
|
||||
retn parmbytes
|
||||
end if }
|
||||
|
||||
macro define@proc name,statement
|
||||
{ local params,flag,regs,parmbytes,localbytes,current
|
||||
if used name
|
||||
name:
|
||||
match =stdcall args, statement \{ params equ args
|
||||
flag = 11b \}
|
||||
match =stdcall, statement \{ params equ
|
||||
flag = 11b \}
|
||||
match =c args, statement \{ params equ args
|
||||
flag = 10001b \}
|
||||
match =c, statement \{ params equ
|
||||
flag = 10001b \}
|
||||
match =params, params \{ params equ statement
|
||||
flag = 0 \}
|
||||
virtual at ebp+8
|
||||
match =uses reglist=,args, params \{ regs equ reglist
|
||||
params equ args \}
|
||||
match =regs =uses reglist, regs params \{ regs equ reglist
|
||||
params equ \}
|
||||
match =regs, regs \{ regs equ \}
|
||||
match =,args, params \{ defargs@proc args \}
|
||||
match =args@proc args, args@proc params \{ defargs@proc args \}
|
||||
parmbytes = $ - (ebp+8)
|
||||
end virtual
|
||||
name # % = parmbytes/4
|
||||
all@vars equ
|
||||
current = 0
|
||||
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
|
||||
macro locals
|
||||
\{ virtual at ebp-localbytes+current
|
||||
macro label . \\{ deflocal@proc .,:, \\}
|
||||
struc db [val] \\{ \common deflocal@proc .,db,val \\}
|
||||
struc dw [val] \\{ \common deflocal@proc .,dw,val \\}
|
||||
struc dp [val] \\{ \common deflocal@proc .,dp,val \\}
|
||||
struc dd [val] \\{ \common deflocal@proc .,dd,val \\}
|
||||
struc dt [val] \\{ \common deflocal@proc .,dt,val \\}
|
||||
struc dq [val] \\{ \common deflocal@proc .,dq,val \\}
|
||||
struc rb cnt \\{ deflocal@proc .,rb cnt, \\}
|
||||
struc rw cnt \\{ deflocal@proc .,rw cnt, \\}
|
||||
struc rp cnt \\{ deflocal@proc .,rp cnt, \\}
|
||||
struc rd cnt \\{ deflocal@proc .,rd cnt, \\}
|
||||
struc rt cnt \\{ deflocal@proc .,rt cnt, \\}
|
||||
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \}
|
||||
macro endl
|
||||
\{ purge label
|
||||
restruc db,dw,dp,dd,dt,dq
|
||||
restruc rb,rw,rp,rd,rt,rq
|
||||
restruc byte,word,dword,pword,tword,qword
|
||||
current = $-(ebp-localbytes)
|
||||
end virtual \}
|
||||
macro ret operand
|
||||
\{ match any, operand \\{ retn operand \\}
|
||||
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
|
||||
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
|
||||
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2
|
||||
end if \} }
|
||||
|
||||
macro defargs@proc [arg]
|
||||
{ common
|
||||
if ~ arg eq
|
||||
forward
|
||||
local ..arg,current@arg
|
||||
match argname:type, arg
|
||||
\{ current@arg equ argname
|
||||
label ..arg type
|
||||
argname equ ..arg
|
||||
if dqword eq type
|
||||
dd ?,?,?,?
|
||||
else if tbyte eq type
|
||||
dd ?,?,?
|
||||
else if qword eq type | pword eq type
|
||||
dd ?,?
|
||||
else
|
||||
dd ?
|
||||
end if \}
|
||||
match =current@arg,current@arg
|
||||
\{ current@arg equ arg
|
||||
arg equ ..arg
|
||||
..arg dd ? \}
|
||||
common
|
||||
args@proc equ current@arg
|
||||
forward
|
||||
restore current@arg
|
||||
common
|
||||
end if }
|
||||
|
||||
macro deflocal@proc name,def,[val]
|
||||
{ common
|
||||
match vars, all@vars \{ all@vars equ all@vars, \}
|
||||
all@vars equ all@vars name
|
||||
forward
|
||||
local ..var,..tmp
|
||||
..var def val
|
||||
match =?, val \{ ..tmp equ \}
|
||||
match any =dup (=?), val \{ ..tmp equ \}
|
||||
match tmp : value, ..tmp : val
|
||||
\{ tmp: end virtual
|
||||
initlocal@proc ..var,def value
|
||||
virtual at tmp\}
|
||||
common
|
||||
match first rest, ..var, \{ name equ first \} }
|
||||
|
||||
macro initlocal@proc name,def
|
||||
{ virtual at name
|
||||
def
|
||||
size@initlocal = $ - name
|
||||
end virtual
|
||||
position@initlocal = 0
|
||||
while size@initlocal > position@initlocal
|
||||
virtual at name
|
||||
def
|
||||
if size@initlocal - position@initlocal < 2
|
||||
current@initlocal = 1
|
||||
load byte@initlocal byte from name+position@initlocal
|
||||
else if size@initlocal - position@initlocal < 4
|
||||
current@initlocal = 2
|
||||
load word@initlocal word from name+position@initlocal
|
||||
else
|
||||
current@initlocal = 4
|
||||
load dword@initlocal dword from name+position@initlocal
|
||||
end if
|
||||
end virtual
|
||||
if current@initlocal = 1
|
||||
mov byte [name+position@initlocal],byte@initlocal
|
||||
else if current@initlocal = 2
|
||||
mov word [name+position@initlocal],word@initlocal
|
||||
else
|
||||
mov dword [name+position@initlocal],dword@initlocal
|
||||
end if
|
||||
position@initlocal = position@initlocal + current@initlocal
|
||||
end while }
|
||||
|
||||
macro endp
|
||||
{ purge ret,locals,endl
|
||||
finish@proc
|
||||
purge finish@proc
|
||||
restore regs@proc
|
||||
match all,args@proc \{ restore all \}
|
||||
restore args@proc
|
||||
match all,all@vars \{ restore all \} }
|
||||
|
||||
macro local [var]
|
||||
{ common
|
||||
locals
|
||||
forward done@local equ
|
||||
match varname[count]:vartype, var
|
||||
\{ match =BYTE, vartype \\{ varname rb count
|
||||
restore done@local \\}
|
||||
match =WORD, vartype \\{ varname rw count
|
||||
restore done@local \\}
|
||||
match =DWORD, vartype \\{ varname rd count
|
||||
restore done@local \\}
|
||||
match =PWORD, vartype \\{ varname rp count
|
||||
restore done@local \\}
|
||||
match =QWORD, vartype \\{ varname rq count
|
||||
restore done@local \\}
|
||||
match =TBYTE, vartype \\{ varname rt count
|
||||
restore done@local \\}
|
||||
match =DQWORD, vartype \\{ label varname dqword
|
||||
rq count+count
|
||||
restore done@local \\}
|
||||
match , done@local \\{ virtual
|
||||
varname vartype
|
||||
end virtual
|
||||
rb count*sizeof.\#vartype
|
||||
restore done@local \\} \}
|
||||
match :varname:vartype, done@local:var
|
||||
\{ match =BYTE, vartype \\{ varname db ?
|
||||
restore done@local \\}
|
||||
match =WORD, vartype \\{ varname dw ?
|
||||
restore done@local \\}
|
||||
match =DWORD, vartype \\{ varname dd ?
|
||||
restore done@local \\}
|
||||
match =PWORD, vartype \\{ varname dp ?
|
||||
restore done@local \\}
|
||||
match =QWORD, vartype \\{ varname dq ?
|
||||
restore done@local \\}
|
||||
match =TBYTE, vartype \\{ varname dt ?
|
||||
restore done@local \\}
|
||||
match =DQWORD, vartype \\{ label varname dqword
|
||||
dq ?,?
|
||||
restore done@local \\}
|
||||
match , done@local \\{ varname vartype
|
||||
restore done@local \\} \}
|
||||
match ,done@local
|
||||
\{ var
|
||||
restore done@local \}
|
||||
common
|
||||
endl }
|
141
kernel/branches/drivers/ps2m_iofuncs.inc
Normal file
141
kernel/branches/drivers/ps2m_iofuncs.inc
Normal file
@ -0,0 +1,141 @@
|
||||
kbd_read:
|
||||
push ecx edx
|
||||
|
||||
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
|
||||
kr_loop:
|
||||
in al,0x64
|
||||
test al,1
|
||||
jnz kr_ready
|
||||
loop kr_loop
|
||||
mov ah,1
|
||||
jmp kr_exit
|
||||
kr_ready:
|
||||
push ecx
|
||||
mov ecx,32
|
||||
kr_delay:
|
||||
loop kr_delay
|
||||
pop ecx
|
||||
in al,0x60
|
||||
xor ah,ah
|
||||
kr_exit:
|
||||
pop edx ecx
|
||||
ret
|
||||
|
||||
|
||||
kbd_write:
|
||||
|
||||
push ecx edx
|
||||
|
||||
mov dl,al
|
||||
in al,0x60
|
||||
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
|
||||
kw_loop:
|
||||
in al,0x64
|
||||
test al,2
|
||||
jz kw_ok
|
||||
loop kw_loop
|
||||
mov ah,1
|
||||
jmp kw_exit
|
||||
kw_ok:
|
||||
mov al,dl
|
||||
out 0x60,al
|
||||
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
|
||||
kw_loop3:
|
||||
in al,0x64
|
||||
test al,2
|
||||
jz kw_ok3
|
||||
loop kw_loop3
|
||||
mov ah,1
|
||||
jmp kw_exit
|
||||
kw_ok3:
|
||||
mov ah,8
|
||||
kw_loop4:
|
||||
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
|
||||
kw_loop5:
|
||||
in al,0x64
|
||||
test al,1
|
||||
jnz kw_ok4
|
||||
loop kw_loop5
|
||||
dec ah
|
||||
jnz kw_loop4
|
||||
kw_ok4:
|
||||
xor ah,ah
|
||||
kw_exit:
|
||||
pop edx ecx
|
||||
ret
|
||||
|
||||
|
||||
kbd_cmd:
|
||||
|
||||
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
|
||||
c_wait:
|
||||
in al,0x64
|
||||
test al,2
|
||||
jz c_send
|
||||
loop c_wait
|
||||
jmp c_error
|
||||
c_send:
|
||||
mov al,bl
|
||||
out 0x64,al
|
||||
mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
|
||||
c_accept:
|
||||
in al,0x64
|
||||
test al,2
|
||||
jz c_ok
|
||||
loop c_accept
|
||||
c_error:
|
||||
mov ah,1
|
||||
jmp c_exit
|
||||
c_ok:
|
||||
xor ah,ah
|
||||
c_exit:
|
||||
ret
|
||||
|
||||
mouse_cmd:
|
||||
mov [mouse_cmd_byte], al
|
||||
mov [mouse_nr_resends], 5
|
||||
.resend:
|
||||
mov bl, 0xd4
|
||||
call kbd_cmd
|
||||
cmp ah,1
|
||||
je .fail
|
||||
|
||||
mov al, [mouse_cmd_byte]
|
||||
call kbd_write
|
||||
cmp ah, 1
|
||||
je .fail
|
||||
|
||||
call mouse_read
|
||||
|
||||
cmp al, 0xFA
|
||||
jne .noack
|
||||
clc
|
||||
ret
|
||||
.noack:
|
||||
cmp al, 0xFE ; resend
|
||||
jne .noresend
|
||||
dec [mouse_nr_resends]
|
||||
jnz .resend
|
||||
.noresend:
|
||||
.fail:
|
||||
stc
|
||||
ret
|
||||
|
||||
|
||||
mouse_read:
|
||||
mov [mouse_nr_tries], 100
|
||||
.repeat:
|
||||
call kbd_read
|
||||
cmp ah, 1
|
||||
jne .fin
|
||||
mov esi, 10
|
||||
call Sleep
|
||||
dec [mouse_nr_tries]
|
||||
jnz .repeat
|
||||
|
||||
stc
|
||||
ret
|
||||
|
||||
.fin:
|
||||
clc
|
||||
ret
|
120
kernel/branches/drivers/ps2m_irqh.inc
Normal file
120
kernel/branches/drivers/ps2m_irqh.inc
Normal file
@ -0,0 +1,120 @@
|
||||
;**************************************
|
||||
;* IRQ HANDLER FOR PS/2 MOUSE *
|
||||
;**************************************
|
||||
|
||||
proc irq_handler
|
||||
|
||||
call Wait8042BufferEmpty ;clear buffer
|
||||
in al,0x60 ;get scan-code
|
||||
|
||||
cmp [mouse_byte],0
|
||||
je .byte1
|
||||
cmp [mouse_byte],1
|
||||
je .byte2
|
||||
cmp [mouse_byte],2
|
||||
je .byte3
|
||||
cmp [mouse_byte],3
|
||||
je .byte4
|
||||
jmp .error
|
||||
|
||||
.byte1:
|
||||
test al,1000b ;first byte?
|
||||
jz .error
|
||||
mov [first_byte],al
|
||||
inc [mouse_byte]
|
||||
jmp .exit
|
||||
|
||||
.byte2:
|
||||
mov [second_byte],al
|
||||
inc [mouse_byte]
|
||||
jmp .exit
|
||||
|
||||
.byte3:
|
||||
mov [third_byte],al
|
||||
cmp [MouseType],MT_3B
|
||||
je .full_packet
|
||||
inc [mouse_byte]
|
||||
jmp .exit
|
||||
|
||||
.byte4:
|
||||
mov [fourth_byte],al
|
||||
|
||||
|
||||
.full_packet:
|
||||
mov [mouse_byte],0
|
||||
mov al,byte [first_byte]
|
||||
and eax,7
|
||||
mov byte [ButtonState],al
|
||||
|
||||
cmp [MouseType],MT_3B
|
||||
je .xy_moving
|
||||
mov al,[fourth_byte]
|
||||
cmp [MouseType],MT_3BScroll
|
||||
je .z_moving
|
||||
|
||||
mov ah,al
|
||||
and ah,00110000b
|
||||
shr ah,1
|
||||
or byte [ButtonState],ah
|
||||
and al,00001111b
|
||||
bt eax,3
|
||||
jnc .z_moving
|
||||
or al,11110000b
|
||||
|
||||
.z_moving:
|
||||
movsx eax,al
|
||||
mov [ZMoving],eax
|
||||
|
||||
.xy_moving:
|
||||
mov ah,0
|
||||
mov al,[first_byte]
|
||||
test al,10000b
|
||||
jz @f
|
||||
mov ah,0FFh
|
||||
|
||||
@@:
|
||||
mov al,[second_byte]
|
||||
cwd
|
||||
mov [XMoving],eax
|
||||
|
||||
mov ah,0
|
||||
mov al,[first_byte]
|
||||
test al,100000b
|
||||
jz @f
|
||||
mov ah,0FFh
|
||||
|
||||
@@:
|
||||
mov al,[third_byte]
|
||||
cwd
|
||||
|
||||
@@:
|
||||
mov [YMoving],eax
|
||||
stdcall SetMouseData, [ButtonState], [XMoving], [YMoving], [ZMoving], 0
|
||||
|
||||
|
||||
jmp .exit
|
||||
|
||||
.error:
|
||||
mov [mouse_byte],0
|
||||
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;***********************************************
|
||||
;* Waiting for clearing I8042 buffer *
|
||||
;* Retutned state: *
|
||||
;* ZF is set - good ending, *
|
||||
;* ZF is cleared - time-out error. *
|
||||
;***********************************************
|
||||
Wait8042BufferEmpty:
|
||||
push ecx
|
||||
xor ecx,ecx
|
||||
@@:
|
||||
in al,64h
|
||||
test al,00000010b
|
||||
loopnz @b
|
||||
pop ecx
|
||||
|
||||
ret
|
270
kernel/branches/drivers/ps2mouse.asm
Normal file
270
kernel/branches/drivers/ps2mouse.asm
Normal file
@ -0,0 +1,270 @@
|
||||
format MS COFF
|
||||
|
||||
DEBUG equ 0
|
||||
|
||||
include 'proc32.inc'
|
||||
include 'imports.inc'
|
||||
|
||||
struc IOCTL
|
||||
{ .handle dd ?
|
||||
.io_code dd ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
IOCTL IOCTL
|
||||
end virtual
|
||||
|
||||
public START
|
||||
public version
|
||||
|
||||
DRV_ENTRY equ 1
|
||||
DRV_EXIT equ -1
|
||||
|
||||
MT_3B equ 0
|
||||
MT_3BScroll equ 1
|
||||
MT_5BScroll equ 2
|
||||
|
||||
PS2_DRV_VER equ 1
|
||||
|
||||
section '.flat' code readable align 16
|
||||
|
||||
|
||||
proc START stdcall, state:dword
|
||||
|
||||
cmp [state], DRV_ENTRY
|
||||
jne .fin
|
||||
.init:
|
||||
|
||||
call detect_mouse
|
||||
test eax,eax
|
||||
jnz .exit
|
||||
|
||||
mov [MouseType],MT_3B
|
||||
|
||||
call try_mode_ID3
|
||||
test eax,eax
|
||||
jnz .stop_try
|
||||
mov [MouseType],MT_3BScroll
|
||||
|
||||
call try_mode_ID4
|
||||
test eax,eax
|
||||
jnz .stop_try
|
||||
mov [MouseType],MT_5BScroll
|
||||
|
||||
.stop_try:
|
||||
|
||||
mov bl, 0x20 ; read command byte
|
||||
call kbd_cmd
|
||||
cmp ah,1
|
||||
je .exit
|
||||
|
||||
call kbd_read
|
||||
cmp ah,1
|
||||
je .exit
|
||||
|
||||
or al, 10b
|
||||
push eax
|
||||
mov bl, 0x60 ; write command byte
|
||||
call kbd_cmd
|
||||
cmp ah,1
|
||||
je .exit
|
||||
|
||||
pop eax
|
||||
call kbd_write
|
||||
cmp ah,1
|
||||
je .exit
|
||||
|
||||
mov al, 0xF4 ; enable data reporting
|
||||
call mouse_cmd
|
||||
|
||||
mov bl, 0xAE ; enable keyboard interface
|
||||
call kbd_cmd
|
||||
|
||||
stdcall AttachIntHandler, 12, irq_handler, dword 0
|
||||
stdcall RegService, my_service, service_proc
|
||||
ret
|
||||
|
||||
.fin:
|
||||
;stdcall DetachIntHandler, 12, irq_handler
|
||||
mov bl, 0xA7 ; disable mouse interface
|
||||
call kbd_cmd
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.exit:
|
||||
mov bl, 0xA7 ; disable mouse interface
|
||||
call kbd_cmd
|
||||
mov bl, 0xAE ; enable keyboard interface
|
||||
call kbd_cmd
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
proc service_proc stdcall, ioctl:dword
|
||||
mov edi, [ioctl]
|
||||
mov eax, [edi+IOCTL.io_code]
|
||||
test eax, eax
|
||||
jz .getversion
|
||||
cmp eax,1
|
||||
jz .gettype
|
||||
|
||||
.err:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
.ok:
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.getversion:
|
||||
cmp [edi+IOCTL.out_size], 4
|
||||
jb .err
|
||||
mov edi, [edi+IOCTL.output]
|
||||
mov dword [edi], PS2_DRV_VER ; version of driver
|
||||
jmp .ok
|
||||
.gettype:
|
||||
cmp [edi+IOCTL.out_size], 4
|
||||
jb .err
|
||||
mov edi, [edi+IOCTL.output]
|
||||
mov eax,[MouseType]
|
||||
mov dword [edi], eax ; mouse type
|
||||
jmp .ok
|
||||
endp
|
||||
|
||||
detect_mouse:
|
||||
|
||||
mov bl, 0xAD ; disable keyboard interface
|
||||
call kbd_cmd
|
||||
cmp ah,1
|
||||
je .fail
|
||||
|
||||
mov bl, 0xA8 ; enable mouse interface
|
||||
call kbd_cmd
|
||||
cmp ah,1
|
||||
je .fail
|
||||
|
||||
mov al, 0xFF ; reset
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
|
||||
call mouse_read
|
||||
jc .fail
|
||||
cmp al, 0xAA
|
||||
jne .fail ; dead mouse
|
||||
|
||||
; get device ID
|
||||
call mouse_read
|
||||
jc .fail
|
||||
cmp al, 0x00
|
||||
jne .fail ; unknown device
|
||||
xor eax,eax
|
||||
ret
|
||||
|
||||
.fail:
|
||||
or eax,-1
|
||||
ret
|
||||
|
||||
try_mode_ID3:
|
||||
mov al, 0xF3 ;Set Sample Rate
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0xC8 ;200d
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0xF3 ;Set Sample Rate
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0x64 ;100d
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0xF3 ;Set Sample Rate
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0x50 ;80d
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
|
||||
mov al, 0xF2 ;Get device id
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
|
||||
call mouse_read
|
||||
jc .fail
|
||||
cmp al, 0x03
|
||||
jne .fail
|
||||
|
||||
xor eax,eax
|
||||
ret
|
||||
.fail:
|
||||
or eax,-1
|
||||
ret
|
||||
|
||||
try_mode_ID4:
|
||||
mov al, 0xF3 ;Set Sample Rate
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0xC8 ;200d
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0xF3 ;Set Sample Rate
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0xC8 ;100d
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0xF3 ;Set Sample Rate
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
mov al, 0x50 ;80d
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
|
||||
mov al, 0xF2 ;Get device id
|
||||
call mouse_cmd
|
||||
jc .fail
|
||||
|
||||
call mouse_read
|
||||
jc .fail
|
||||
cmp al, 0x04
|
||||
jne .fail
|
||||
|
||||
xor eax,eax
|
||||
ret
|
||||
|
||||
.fail:
|
||||
or eax,-1
|
||||
ret
|
||||
|
||||
include 'ps2m_iofuncs.inc'
|
||||
include 'ps2m_irqh.inc'
|
||||
|
||||
section '.data' data readable writable align 16
|
||||
|
||||
version dd 0x00050005
|
||||
my_service db 'ps2mouse',0
|
||||
|
||||
;iofuncs data
|
||||
mouse_cmd_byte db 0
|
||||
mouse_nr_tries db 0
|
||||
mouse_nr_resends db 0
|
||||
|
||||
;hid data
|
||||
mouse_byte dd 0
|
||||
|
||||
first_byte db 0
|
||||
second_byte db 0
|
||||
third_byte db 0
|
||||
fourth_byte db 0
|
||||
|
||||
;main data
|
||||
MouseType dd 0
|
||||
|
||||
XMoving dd 0
|
||||
YMoving dd 0
|
||||
ZMoving dd 0
|
||||
ButtonState dd 0
|
||||
;timerTicks dd 0
|
1272
kernel/branches/drivers/r500hw.inc
Normal file
1272
kernel/branches/drivers/r500hw.inc
Normal file
File diff suppressed because it is too large
Load Diff
50
kernel/branches/drivers/sb16/CONFIG.INC
Normal file
50
kernel/branches/drivers/sb16/CONFIG.INC
Normal file
@ -0,0 +1,50 @@
|
||||
;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 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
|
||||
|
72
kernel/branches/drivers/sb16/README.TXT
Normal file
72
kernel/branches/drivers/sb16/README.TXT
Normal file
@ -0,0 +1,72 @@
|
||||
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.
|
297
kernel/branches/drivers/sb16/SB16.INC
Normal file
297
kernel/branches/drivers/sb16/SB16.INC
Normal file
@ -0,0 +1,297 @@
|
||||
;--------------------------------
|
||||
; 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
|
||||
;-------------------------------------------------------------------------------
|
389
kernel/branches/drivers/sb16/sb16.asm
Normal file
389
kernel/branches/drivers/sb16/sb16.asm
Normal file
@ -0,0 +1,389 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; 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
|
177
kernel/branches/drivers/sceletone.asm
Normal file
177
kernel/branches/drivers/sceletone.asm
Normal file
@ -0,0 +1,177 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;driver sceletone
|
||||
|
||||
format MS COFF
|
||||
|
||||
DEBUG equ 1
|
||||
|
||||
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 ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
IOCTL IOCTL
|
||||
end virtual
|
||||
|
||||
public START
|
||||
public service_proc
|
||||
public version
|
||||
|
||||
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
|
||||
|
||||
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 ?
|
||||
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:
|
||||
xor eax, eax
|
||||
inc eax
|
||||
ret
|
||||
.err:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
DEVICE_ID equ 1234; pci device id
|
||||
VENDOR_ID equ 5678; device vendor id
|
||||
|
||||
|
||||
;all initialized data place here
|
||||
|
||||
align 4
|
||||
devices dd (DEVICE_ID shl 16)+VENDOR_ID
|
||||
dd 0 ;terminator
|
||||
|
||||
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
|
||||
|
||||
my_service db 'MY_SERVICE',0 ;max 16 chars include zero
|
||||
|
||||
msgInit db 'detect hardware...',13,10,0
|
||||
msgPCI db 'PCI accsess not supported',13,10,0
|
||||
msgFail db 'device not found',13,10,0
|
||||
|
||||
section '.data' data readable writable align 16
|
||||
|
||||
;all uninitialized data place here
|
||||
|
1307
kernel/branches/drivers/sis.asm
Normal file
1307
kernel/branches/drivers/sis.asm
Normal file
File diff suppressed because it is too large
Load Diff
1473
kernel/branches/drivers/sound.asm
Normal file
1473
kernel/branches/drivers/sound.asm
Normal file
File diff suppressed because it is too large
Load Diff
976
kernel/branches/drivers/uart.asm
Normal file
976
kernel/branches/drivers/uart.asm
Normal file
@ -0,0 +1,976 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
format MS COFF
|
||||
|
||||
DEBUG equ 1
|
||||
|
||||
include 'proc32.inc'
|
||||
include 'imports.inc'
|
||||
|
||||
|
||||
|
||||
API_VERSION equ 0
|
||||
UART_VERSION equ API_VERSION
|
||||
|
||||
PG_SW equ 0x003
|
||||
page_tabs equ 0xFDC00000 ;hack
|
||||
|
||||
OS_BASE equ 0x80000000
|
||||
SLOT_BASE equ (OS_BASE+0x0080000)
|
||||
TASK_COUNT equ (OS_BASE+0x0003004)
|
||||
CURRENT_TASK equ (OS_BASE+0x0003000)
|
||||
|
||||
|
||||
struc APPOBJ ;common object header
|
||||
{
|
||||
.magic dd ? ;
|
||||
.destroy dd ? ;internal destructor
|
||||
.fd dd ? ;next object in list
|
||||
.bk dd ? ;prev object in list
|
||||
.pid dd ? ;owner id
|
||||
};
|
||||
|
||||
virtual at 0
|
||||
APPOBJ APPOBJ
|
||||
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
|
||||
|
||||
DEBUG equ 1
|
||||
|
||||
DRV_ENTRY equ 1
|
||||
DRV_EXIT equ -1
|
||||
|
||||
THR_REG equ 0; x3f8 ;transtitter/reciever
|
||||
IER_REG equ 1; x3f9 ;interrupt enable
|
||||
IIR_REG equ 2; x3fA ;interrupt info
|
||||
LCR_REG equ 3; x3FB ;line control
|
||||
MCR_REG equ 4; x3FC ;modem control
|
||||
LSR_REG equ 5; x3FD ;line status
|
||||
MSR_REG equ 6; x3FE ;modem status
|
||||
|
||||
LCR_5BIT equ 0x00
|
||||
LCR_6BIT equ 0x01
|
||||
LCR_7BIT equ 0x02
|
||||
LCR_8BIT equ 0x03
|
||||
LCR_STOP_1 equ 0x00
|
||||
LCR_STOP_2 equ 0x04
|
||||
LCR_PARITY equ 0x08
|
||||
LCR_EVEN equ 0x10
|
||||
LCR_STICK equ 0x20
|
||||
LCR_BREAK equ 0x40
|
||||
LCR_DLAB equ 0x80
|
||||
|
||||
LSR_DR equ 0x01 ;data ready
|
||||
LSR_OE equ 0x02 ;overrun error
|
||||
LSR_PE equ 0x04 ;parity error
|
||||
LSR_FE equ 0x08 ;framing error
|
||||
LSR_BI equ 0x10 ;break interrupt
|
||||
LSR_THRE equ 0x20 ;transmitter holding empty
|
||||
LSR_TEMT equ 0x40 ;transmitter empty
|
||||
LSR_FER equ 0x80 ;FIFO error
|
||||
|
||||
FCR_EFIFO equ 0x01 ;enable FIFO
|
||||
FCR_CRB equ 0x02 ;clear reciever FIFO
|
||||
FCR_CXMIT equ 0x04 ;clear transmitter FIFO
|
||||
FCR_RDY equ 0x08 ;set RXRDY and TXRDY pins
|
||||
FCR_FIFO_1 equ 0x00 ;1 byte trigger
|
||||
FCR_FIFO_4 equ 0x40 ;4 bytes trigger
|
||||
FCR_FIFO_8 equ 0x80 ;8 bytes trigger
|
||||
FCR_FIFO_14 equ 0xC0 ;14 bytes trigger
|
||||
|
||||
IIR_INTR equ 0x01 ;1= no interrupts
|
||||
|
||||
IER_RDAI equ 0x01 ;reciever data interrupt
|
||||
IER_THRI equ 0x02 ;transmitter empty interrupt
|
||||
IER_LSI equ 0x04 ;line status interrupt
|
||||
IER_MSI equ 0x08 ;modem status interrupt
|
||||
|
||||
MCR_DTR equ 0x01 ;0-> DTR=1, 1-> DTR=0
|
||||
MCR_RTS equ 0x02 ;0-> RTS=1, 1-> RTS=0
|
||||
MCR_OUT_1 equ 0x04 ;0-> OUT1=1, 1-> OUT1=0
|
||||
MCR_OUT_2 equ 0x08 ;0-> OUT2=1, 1-> OUT2=0; enable intr
|
||||
MCR_LOOP equ 0x10 ;lopback mode
|
||||
|
||||
MSR_DCTS equ 0x01 ;delta clear to send
|
||||
MSR_DDSR equ 0x02 ;delta data set redy
|
||||
MSR_TERI equ 0x04 ;trailinh edge of ring
|
||||
MSR_DDCD equ 0x08 ;delta carrier detect
|
||||
|
||||
|
||||
RATE_50 equ 0
|
||||
RATE_75 equ 1
|
||||
RATE_110 equ 2
|
||||
RATE_134 equ 3
|
||||
RATE_150 equ 4
|
||||
RATE_300 equ 5
|
||||
RATE_600 equ 6
|
||||
RATE_1200 equ 7
|
||||
RATE_1800 equ 8
|
||||
RATE_2000 equ 9
|
||||
RATE_2400 equ 10
|
||||
RATE_3600 equ 11
|
||||
RATE_4800 equ 12
|
||||
RATE_7200 equ 13
|
||||
RATE_9600 equ 14
|
||||
RATE_19200 equ 15
|
||||
RATE_38400 equ 16
|
||||
RATE_57600 equ 17
|
||||
RATE_115200 equ 18
|
||||
|
||||
COM_1 equ 1
|
||||
COM_2 equ 2
|
||||
COM_3 equ 3
|
||||
COM_4 equ 4
|
||||
COM_MAX equ 2 ;only two port supported
|
||||
|
||||
COM_1_BASE equ 0x3F8
|
||||
COM_2_BASE equ 0x2F8
|
||||
|
||||
COM_1_IRQ equ 4
|
||||
COM_2_IRQ equ 3
|
||||
|
||||
UART_CLOSED equ 0
|
||||
UART_TRANSMIT equ 1
|
||||
UART_STOP equ 2
|
||||
|
||||
struc UART
|
||||
{
|
||||
.lock dd ?
|
||||
.base dd ?
|
||||
.lcr_reg dd ?
|
||||
.mcr_reg dd ?
|
||||
.rate dd ?
|
||||
.mode dd ?
|
||||
.state dd ?
|
||||
|
||||
.rcvr_buff dd ?
|
||||
.rcvr_rp dd ?
|
||||
.rcvr_wp dd ?
|
||||
.rcvr_count dd ?
|
||||
.rcvr_top dd ?
|
||||
|
||||
.xmit_buff dd ?
|
||||
.xmit_rp dd ?
|
||||
.xmit_wp dd ?
|
||||
.xmit_count dd ?
|
||||
.xmit_free dd ?
|
||||
.xmit_top dd ?
|
||||
}
|
||||
virtual at 0
|
||||
UART UART
|
||||
end virtual
|
||||
|
||||
UART_SIZE equ 18*4
|
||||
|
||||
struc CONNECTION
|
||||
{
|
||||
.magic dd ? ;'CNCT'
|
||||
.destroy dd ? ;internal destructor
|
||||
.fd dd ? ;next object in list
|
||||
.bk dd ? ;prev object in list
|
||||
.pid dd ? ;owner id
|
||||
|
||||
.id dd ? ;reserved
|
||||
.uart dd ? ;uart pointer
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
CONNECTION CONNECTION
|
||||
end virtual
|
||||
|
||||
CONNECTION_SIZE equ 7*4
|
||||
|
||||
public START
|
||||
public service_proc
|
||||
public version
|
||||
|
||||
section '.flat' code readable align 16
|
||||
|
||||
proc START stdcall, state:dword
|
||||
|
||||
cmp [state], 1
|
||||
jne .stop
|
||||
|
||||
mov eax, UART_SIZE
|
||||
call Kmalloc
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov [com1], eax
|
||||
mov edi, eax
|
||||
mov ecx, UART_SIZE/4
|
||||
xor eax, eax
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
mov eax, [com1]
|
||||
mov [eax+UART.base], COM_1_BASE
|
||||
|
||||
stdcall AllocKernelSpace, 32768
|
||||
|
||||
mov edi, [com1]
|
||||
mov edx, eax
|
||||
|
||||
mov [edi+UART.rcvr_buff], eax
|
||||
add eax, 8192
|
||||
mov [edi+UART.rcvr_top], eax
|
||||
add eax, 8192
|
||||
mov [edi+UART.xmit_buff], eax
|
||||
add eax, 8192
|
||||
mov [edi+UART.xmit_top], eax
|
||||
|
||||
call AllocPage
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
shr edx, 12
|
||||
or eax, PG_SW
|
||||
mov [page_tabs+edx*4], eax
|
||||
mov [page_tabs+edx*4+8], eax
|
||||
|
||||
call AllocPage
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
or eax, PG_SW
|
||||
mov [page_tabs+edx*4+4], eax
|
||||
mov [page_tabs+edx*4+12], eax
|
||||
|
||||
call AllocPage
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
or eax, PG_SW
|
||||
mov [page_tabs+edx*4+16], eax
|
||||
mov [page_tabs+edx*4+24], eax
|
||||
|
||||
call AllocPage
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
or eax, PG_SW
|
||||
mov [page_tabs+edx*4+20], eax
|
||||
mov [page_tabs+edx*4+28], eax
|
||||
|
||||
mov eax, [edi+UART.rcvr_buff]
|
||||
invlpg [eax]
|
||||
invlpg [eax+0x1000]
|
||||
invlpg [eax+0x2000]
|
||||
invlpg [eax+0x3000]
|
||||
invlpg [eax+0x4000]
|
||||
invlpg [eax+0x5000]
|
||||
invlpg [eax+0x6000]
|
||||
invlpg [eax+0x7000]
|
||||
|
||||
mov eax, edi
|
||||
call uart_reset.internal ;eax= uart
|
||||
|
||||
stdcall AttachIntHandler, COM_1_IRQ, com_1_isr, dword 0
|
||||
stdcall RegService, sz_uart_srv, service_proc
|
||||
ret
|
||||
.fail:
|
||||
.stop:
|
||||
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
|
||||
|
||||
SRV_GETVERSION equ 0
|
||||
PORT_OPEN equ 1
|
||||
PORT_CLOSE equ 2
|
||||
PORT_RESET equ 3
|
||||
PORT_SETMODE equ 4
|
||||
PORT_GETMODE equ 5
|
||||
PORT_SETMCR equ 6
|
||||
PORT_GETMCR equ 7
|
||||
PORT_READ equ 8
|
||||
PORT_WRITE equ 9
|
||||
|
||||
align 4
|
||||
proc service_proc stdcall, ioctl:dword
|
||||
|
||||
mov ebx, [ioctl]
|
||||
mov eax, [ebx+io_code]
|
||||
cmp eax, PORT_WRITE
|
||||
ja .fail
|
||||
|
||||
cmp eax, SRV_GETVERSION
|
||||
jne @F
|
||||
|
||||
mov eax, [ebx+output]
|
||||
cmp [ebx+out_size], 4
|
||||
jne .fail
|
||||
mov [eax], dword UART_VERSION
|
||||
xor eax, eax
|
||||
ret
|
||||
@@:
|
||||
cmp eax, PORT_OPEN
|
||||
jne @F
|
||||
|
||||
cmp [ebx+out_size], 4
|
||||
jne .fail
|
||||
|
||||
mov ebx, [ebx+input]
|
||||
mov eax, [ebx]
|
||||
call uart_open
|
||||
mov ebx, [ioctl]
|
||||
mov ebx, [ebx+output]
|
||||
mov [ebx], ecx
|
||||
ret
|
||||
@@:
|
||||
mov esi, [ebx+input] ;input buffer
|
||||
mov edi, [ebx+output]
|
||||
call [uart_func+eax*4]
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
restore handle
|
||||
restore io_code
|
||||
restore input
|
||||
restore inp_size
|
||||
restore output
|
||||
restore out_size
|
||||
|
||||
|
||||
; param
|
||||
; esi= input buffer
|
||||
; +0 connection
|
||||
;
|
||||
; retval
|
||||
; eax= error code
|
||||
|
||||
align 4
|
||||
uart_reset:
|
||||
mov eax, [esi]
|
||||
cmp [eax+APPOBJ.magic], 'CNCT'
|
||||
jne .fail
|
||||
|
||||
cmp [eax+APPOBJ.destroy], uart_close.destroy
|
||||
jne .fail
|
||||
|
||||
mov eax, [eax+CONNECTION.uart]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
; set mode 2400 bod 8-bit
|
||||
; disable DTR & RTS
|
||||
; clear FIFO
|
||||
; clear pending interrupts
|
||||
;
|
||||
; param
|
||||
; eax= uart
|
||||
|
||||
align 4
|
||||
.internal:
|
||||
mov esi, eax
|
||||
mov [eax+UART.state], UART_CLOSED
|
||||
mov edx, [eax+UART.base]
|
||||
add edx, MCR_REG
|
||||
xor eax, eax
|
||||
out dx, al ;clear DTR & RTS
|
||||
|
||||
mov eax, esi
|
||||
mov ebx, RATE_2400
|
||||
mov ecx, LCR_8BIT+LCR_STOP_1
|
||||
call uart_set_mode.internal
|
||||
|
||||
mov edx, [esi+UART.base]
|
||||
add edx, IIR_REG
|
||||
mov eax,FCR_EFIFO+FCR_CRB+FCR_CXMIT+FCR_FIFO_14
|
||||
out dx, al
|
||||
.clear_RB:
|
||||
mov edx, [esi+UART.base]
|
||||
add edx, LSR_REG
|
||||
in al, dx
|
||||
test eax, LSR_DR
|
||||
jz @F
|
||||
|
||||
mov edx, [esi+UART.base]
|
||||
in al, dx
|
||||
jmp .clear_RB
|
||||
@@:
|
||||
mov edx, [esi+UART.base]
|
||||
add edx, IER_REG
|
||||
mov eax,IER_RDAI+IER_THRI+IER_LSI
|
||||
out dx, al
|
||||
.clear_IIR:
|
||||
mov edx, [esi+UART.base]
|
||||
add edx, IIR_REG
|
||||
in al, dx
|
||||
test al, IIR_INTR
|
||||
jnz .done
|
||||
|
||||
shr eax, 1
|
||||
and eax, 3
|
||||
jnz @F
|
||||
|
||||
mov edx, [esi+UART.base]
|
||||
add edx, MSR_REG
|
||||
in al, dx
|
||||
jmp .clear_IIR
|
||||
@@:
|
||||
cmp eax, 1
|
||||
je .clear_IIR
|
||||
|
||||
cmp eax, 2
|
||||
jne @F
|
||||
|
||||
mov edx, [esi+UART.base]
|
||||
in al, dx
|
||||
jmp .clear_IIR
|
||||
@@:
|
||||
mov edx, [esi+UART.base]
|
||||
add edx, LSR_REG
|
||||
in al, dx
|
||||
jmp .clear_IIR
|
||||
.done:
|
||||
mov edi, [esi+UART.rcvr_buff]
|
||||
mov ecx, 8192/4
|
||||
xor eax, eax
|
||||
|
||||
mov [esi+UART.rcvr_rp], edi
|
||||
mov [esi+UART.rcvr_wp], edi
|
||||
mov [esi+UART.rcvr_count], eax
|
||||
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
mov edi, [esi+UART.xmit_buff]
|
||||
mov ecx, 8192/4
|
||||
|
||||
mov [esi+UART.xmit_rp], edi
|
||||
mov [esi+UART.xmit_wp], edi
|
||||
mov [esi+UART.xmit_count], eax
|
||||
mov [esi+UART.xmit_free], 8192
|
||||
|
||||
rep stosd
|
||||
ret ;eax= 0
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
; param
|
||||
; esi= input buffer
|
||||
; +0 connection
|
||||
; +4 rate
|
||||
; +8 mode
|
||||
;
|
||||
; retval
|
||||
; eax= error code
|
||||
|
||||
align 4
|
||||
uart_set_mode:
|
||||
mov eax, [esi]
|
||||
cmp [eax+APPOBJ.magic], 'CNCT'
|
||||
jne .fail
|
||||
|
||||
cmp [eax+APPOBJ.destroy], uart_close.destroy
|
||||
jne .fail
|
||||
|
||||
mov eax, [eax+CONNECTION.uart]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov ebx, [esi+4]
|
||||
mov ecx, [esi+8]
|
||||
|
||||
; param
|
||||
; eax= uart
|
||||
; ebx= baud rate
|
||||
; ecx= mode
|
||||
|
||||
align 4
|
||||
.internal:
|
||||
cmp ebx, RATE_115200
|
||||
ja .fail
|
||||
|
||||
cmp ecx, LCR_BREAK
|
||||
jae .fail
|
||||
|
||||
mov [eax+UART.rate], ebx
|
||||
mov [eax+UART.mode], ecx
|
||||
|
||||
mov esi, eax
|
||||
mov bx, [divisor+ebx*2]
|
||||
|
||||
mov edx, [esi+UART.base]
|
||||
push edx
|
||||
add edx, LCR_REG
|
||||
in al, dx
|
||||
or al, 0x80
|
||||
out dx, al
|
||||
|
||||
pop edx
|
||||
mov al, bl
|
||||
out dx, al
|
||||
|
||||
inc dx
|
||||
mov al, bh
|
||||
out dx, al
|
||||
|
||||
add edx, LCR_REG-1
|
||||
mov eax, ecx
|
||||
out dx, al
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
; param
|
||||
; esi= input buffer
|
||||
; +0 connection
|
||||
; +4 modem control reg valie
|
||||
;
|
||||
; retval
|
||||
; eax= error code
|
||||
|
||||
align 4
|
||||
uart_set_mcr:
|
||||
|
||||
mov eax, [esi]
|
||||
cmp [eax+APPOBJ.magic], 'CNCT'
|
||||
jne .fail
|
||||
|
||||
cmp [eax+APPOBJ.destroy], uart_close.destroy
|
||||
jne .fail
|
||||
|
||||
mov eax, [eax+CONNECTION.uart]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov ebx, [esi+4]
|
||||
|
||||
mov [eax+UART.mcr_reg], ebx
|
||||
mov edx, [eax+UART.base]
|
||||
add edx, MCR_REG
|
||||
mov al, bl
|
||||
out dx, al
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
; param
|
||||
; eax= port
|
||||
;
|
||||
; retval
|
||||
; ecx= connection
|
||||
; eax= error code
|
||||
|
||||
align 4
|
||||
uart_open:
|
||||
dec eax
|
||||
cmp eax, COM_MAX
|
||||
jae .fail
|
||||
|
||||
mov esi, [com1+eax*4] ;uart
|
||||
push esi
|
||||
.do_wait:
|
||||
cmp dword [esi+UART.lock],0
|
||||
je .get_lock
|
||||
; call change_task
|
||||
jmp .do_wait
|
||||
.get_lock:
|
||||
mov eax, 1
|
||||
xchg eax, [esi+UART.lock]
|
||||
test eax, eax
|
||||
jnz .do_wait
|
||||
|
||||
mov eax, esi ;uart
|
||||
call uart_reset.internal
|
||||
|
||||
mov ebx, [CURRENT_TASK]
|
||||
shl ebx, 5
|
||||
mov ebx, [CURRENT_TASK+ebx+4]
|
||||
mov eax, CONNECTION_SIZE
|
||||
call CreateObject
|
||||
pop esi ;uart
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov [eax+APPOBJ.magic], 'CNCT'
|
||||
mov [eax+APPOBJ.destroy], uart_close.destroy
|
||||
mov [eax+CONNECTION.uart], esi
|
||||
mov ecx, eax
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
restore .uart
|
||||
|
||||
; param
|
||||
; esi= input buffer
|
||||
|
||||
align 4
|
||||
uart_close:
|
||||
mov eax, [esi]
|
||||
cmp [eax+APPOBJ.magic], 'CNCT'
|
||||
jne .fail
|
||||
|
||||
cmp [eax+APPOBJ.destroy], uart_close.destroy
|
||||
jne .fail
|
||||
.destroy:
|
||||
push [eax+CONNECTION.uart]
|
||||
call DestroyObject ;eax= object
|
||||
pop eax ;eax= uart
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov [eax+UART.state], UART_CLOSED
|
||||
mov [eax+UART.lock], 0 ;release port
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
|
||||
; param
|
||||
; eax= uart
|
||||
; ebx= baud rate
|
||||
|
||||
align 4
|
||||
set_rate:
|
||||
cmp ebx, RATE_115200
|
||||
ja .fail
|
||||
|
||||
mov [eax+UART.rate], ebx
|
||||
mov bx, [divisor+ebx*2]
|
||||
|
||||
mov edx, [eax+UART.base]
|
||||
add edx, LCR_REG
|
||||
in al, dx
|
||||
push eax
|
||||
or al, 0x80
|
||||
out dx, al
|
||||
|
||||
sub edx, LCR_REG
|
||||
mov al, bl
|
||||
out dx, al
|
||||
|
||||
inc edx
|
||||
mov al, bh
|
||||
out dx, al
|
||||
|
||||
pop eax
|
||||
add edx, LCR_REG-1
|
||||
out dx, al
|
||||
.fail:
|
||||
ret
|
||||
|
||||
|
||||
; param
|
||||
; ebx= uart
|
||||
|
||||
align 4
|
||||
transmit:
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov edx, [ebx+UART.base]
|
||||
|
||||
pushfd
|
||||
cli
|
||||
|
||||
mov esi, [ebx+UART.xmit_rp]
|
||||
mov ecx, [ebx+UART.xmit_count]
|
||||
test ecx, ecx
|
||||
je .stop
|
||||
|
||||
cmp ecx, 16
|
||||
jbe @F
|
||||
mov ecx, 16
|
||||
@@:
|
||||
sub [ebx+UART.xmit_count], ecx
|
||||
add [ebx+UART.xmit_free], ecx
|
||||
cld
|
||||
@@:
|
||||
lodsb
|
||||
out dx, al
|
||||
dec ecx
|
||||
jnz @B
|
||||
|
||||
cmp esi,[ebx+UART.xmit_top]
|
||||
jb @F
|
||||
sub esi, 8192
|
||||
@@:
|
||||
mov [ebx+UART.xmit_rp], esi
|
||||
|
||||
cmp [ebx+UART.xmit_count], 0
|
||||
je .stop
|
||||
|
||||
mov [ebx+UART.state], UART_TRANSMIT
|
||||
jmp @F
|
||||
.stop:
|
||||
mov [ebx+UART.state], UART_STOP
|
||||
@@:
|
||||
popfd
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
|
||||
|
||||
; param
|
||||
; esi= input buffer
|
||||
; +0 connection
|
||||
; +4 dst buffer
|
||||
; +8 dst size
|
||||
; edi= output buffer
|
||||
; +0 bytes read
|
||||
|
||||
; retval
|
||||
; eax= error code
|
||||
|
||||
align 4
|
||||
uart_read:
|
||||
mov eax, [esi]
|
||||
cmp [eax+APPOBJ.magic], 'CNCT'
|
||||
jne .fail
|
||||
|
||||
cmp [eax+APPOBJ.destroy], uart_close.destroy
|
||||
jne .fail
|
||||
|
||||
mov eax, [eax+CONNECTION.uart]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov ebx, [esi+8] ;dst size
|
||||
mov ecx, [eax+UART.rcvr_count]
|
||||
cmp ecx, ebx
|
||||
jbe @F
|
||||
mov ecx, ebx
|
||||
@@:
|
||||
mov [edi], ecx ;bytes read
|
||||
test ecx, ecx
|
||||
jz .done
|
||||
|
||||
push ecx
|
||||
|
||||
mov edi, [esi+4] ;dst
|
||||
mov esi, [eax+UART.rcvr_rp]
|
||||
cld
|
||||
rep movsb
|
||||
pop ecx
|
||||
|
||||
cmp esi, [eax+UART.rcvr_top]
|
||||
jb @F
|
||||
sub esi, 8192
|
||||
@@:
|
||||
mov [eax+UART.rcvr_rp], esi
|
||||
sub [eax+UART.rcvr_count], ecx
|
||||
.done:
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
; param
|
||||
; esi= input buffer
|
||||
; +0 connection
|
||||
; +4 src buffer
|
||||
; +8 src size
|
||||
;
|
||||
; retval
|
||||
; eax= error code
|
||||
|
||||
align 4
|
||||
uart_write:
|
||||
mov eax, [esi]
|
||||
cmp [eax+APPOBJ.magic], 'CNCT'
|
||||
jne .fail
|
||||
|
||||
cmp [eax+APPOBJ.destroy], uart_close.destroy
|
||||
jne .fail
|
||||
|
||||
mov eax, [eax+CONNECTION.uart]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov ebx, [esi+4]
|
||||
mov edx, [esi+8]
|
||||
|
||||
; param
|
||||
; eax= uart
|
||||
; ebx= src
|
||||
; edx= count
|
||||
|
||||
align 4
|
||||
.internal:
|
||||
mov esi, ebx
|
||||
mov edi, [eax+UART.xmit_wp]
|
||||
.write:
|
||||
test edx, edx
|
||||
jz .fail
|
||||
.wait:
|
||||
cmp [eax+UART.xmit_free], 0
|
||||
jne .fill
|
||||
|
||||
cmp [eax+UART.state], UART_TRANSMIT
|
||||
je .wait
|
||||
|
||||
mov ebx, eax
|
||||
push edx
|
||||
call transmit
|
||||
pop edx
|
||||
mov eax, ebx
|
||||
jmp .write
|
||||
.fill:
|
||||
mov ecx, [eax+UART.xmit_free]
|
||||
cmp ecx, edx
|
||||
jbe @F
|
||||
mov ecx, edx
|
||||
@@:
|
||||
push ecx
|
||||
cld
|
||||
rep movsb
|
||||
pop ecx
|
||||
sub [eax+UART.xmit_free], ecx
|
||||
add [eax+UART.xmit_count], ecx
|
||||
sub edx, ecx
|
||||
jnz .wait
|
||||
.done:
|
||||
cmp edi, [eax+UART.xmit_top]
|
||||
jb @F
|
||||
sub edi, 8192
|
||||
@@:
|
||||
mov [eax+UART.xmit_wp], edi
|
||||
cmp [eax+UART.state], UART_TRANSMIT
|
||||
je @F
|
||||
mov ebx, eax
|
||||
call transmit
|
||||
@@:
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
com_2_isr:
|
||||
mov ebx, [com2]
|
||||
jmp com_1_isr.get_info
|
||||
align 4
|
||||
com_1_isr:
|
||||
mov ebx, [com1]
|
||||
.get_info:
|
||||
mov edx, [ebx+UART.base]
|
||||
add edx, IIR_REG
|
||||
in al, dx
|
||||
|
||||
test al, IIR_INTR
|
||||
jnz .done
|
||||
|
||||
shr eax, 1
|
||||
and eax, 3
|
||||
|
||||
call [isr_action+eax*4]
|
||||
jmp .get_info
|
||||
.done:
|
||||
ret
|
||||
|
||||
align 4
|
||||
isr_line:
|
||||
mov edx, [ebx+UART.base]
|
||||
add edx, LSR_REG
|
||||
in al, dx
|
||||
ret
|
||||
|
||||
align 4
|
||||
isr_recieve:
|
||||
mov esi, [ebx+UART.base]
|
||||
add esi, LSR_REG
|
||||
mov edi, [ebx+UART.rcvr_wp]
|
||||
xor ecx, ecx
|
||||
cld
|
||||
.read:
|
||||
mov edx, esi
|
||||
in al, dx
|
||||
test eax, LSR_DR
|
||||
jz .done
|
||||
|
||||
mov edx, [ebx+UART.base]
|
||||
in al, dx
|
||||
stosb
|
||||
inc ecx
|
||||
jmp .read
|
||||
.done:
|
||||
cmp edi, [ebx+UART.rcvr_top]
|
||||
jb @F
|
||||
sub edi, 8192
|
||||
@@:
|
||||
mov [ebx+UART.rcvr_wp], edi
|
||||
add [ebx+UART.rcvr_count], ecx
|
||||
ret
|
||||
|
||||
align 4
|
||||
isr_modem:
|
||||
mov edx, [ebx+UART.base]
|
||||
add edx, MSR_REG
|
||||
in al, dx
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
divisor dw 2304, 1536, 1047, 857, 768, 384
|
||||
dw 192, 96, 64, 58, 48, 32
|
||||
dw 24, 16, 12, 6, 3, 2, 1
|
||||
|
||||
align 4
|
||||
uart_func dd 0 ;SRV_GETVERSION
|
||||
dd 0 ;PORT_OPEN
|
||||
dd uart_close ;PORT_CLOSE
|
||||
dd uart_reset ;PORT_RESET
|
||||
dd uart_set_mode ;PORT_SETMODE
|
||||
dd 0 ;PORT_GETMODE
|
||||
dd uart_set_mcr ;PORT_SETMODEM
|
||||
dd 0 ;PORT_GETMODEM
|
||||
dd uart_read ;PORT_READ
|
||||
dd uart_write ;PORT_WRITE
|
||||
|
||||
isr_action dd isr_modem
|
||||
dd transmit
|
||||
dd isr_recieve
|
||||
dd isr_line
|
||||
|
||||
version dd (5 shl 16) or (UART_VERSION and 0xFFFF)
|
||||
|
||||
sz_uart_srv db 'UART',0
|
||||
|
||||
align 4
|
||||
|
||||
com1 rd 1
|
||||
com2 rd 1
|
||||
|
115
kernel/branches/drivers/usb/urb.inc
Normal file
115
kernel/branches/drivers/usb/urb.inc
Normal file
@ -0,0 +1,115 @@
|
||||
|
||||
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;
|
||||
}
|
||||
|
435
kernel/branches/drivers/usb/usb.asm
Normal file
435
kernel/branches/drivers/usb/usb.asm
Normal file
@ -0,0 +1,435 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; 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
|
||||
|
736
kernel/branches/drivers/vmode.asm
Normal file
736
kernel/branches/drivers/vmode.asm
Normal file
@ -0,0 +1,736 @@
|
||||
;
|
||||
; MenuetOS Driver (vmode.mdr)
|
||||
; Target: Vertical Refresh Rate programming and videomode changing
|
||||
;
|
||||
; Author: Trans <<<<<13>>>>>
|
||||
; Date: 20.07.2003
|
||||
;
|
||||
; Version: 1.0
|
||||
; OS: MenuetOS
|
||||
; Compiler: FASM
|
||||
;
|
||||
|
||||
OS_BASE equ 0x80000000
|
||||
|
||||
use32
|
||||
|
||||
macro align value { rb (value-1) - ($ + value-1) mod value }
|
||||
|
||||
org OS_BASE+0x0328000
|
||||
|
||||
headerstart=$
|
||||
|
||||
mdid db 'MDAZ' ; 4 byte id
|
||||
mdhver dd 0x00 ; header version
|
||||
mdcode dd MDSTART ; start of code
|
||||
mdver dd 0x00000001 ; driver version (subversion*65536+version)
|
||||
mdname db 'Trans VideoDriver' ; 32 bytes of full driver name
|
||||
times (32-($-mdname)) db ' ' ;
|
||||
|
||||
headerlen=$-headerstart
|
||||
times (256-headerlen) db 0 ; reserved area for future
|
||||
|
||||
MDSTART: ; start of driver code ( base_adr+256 bytes)
|
||||
; ebx(=ecx in program):
|
||||
; 1 - Get DriverInfo and Driver Initial Set
|
||||
; 2 - Get Current Video Mode With Vertical Refresh Rate
|
||||
; 3 - Change Video Mode
|
||||
; 4 - Return at Start System Video Mode
|
||||
; 5 - Change vertical and horizontal size of visible screen area
|
||||
; 6 - Change Vert/Hor position visible area on screen (not complete yet)
|
||||
;
|
||||
; MAXF - ...
|
||||
MAXF=5
|
||||
|
||||
;-------Main Manager-------------
|
||||
pushad
|
||||
cmp ebx,1
|
||||
jb mdvm_00
|
||||
cmp ebx,MAXF
|
||||
ja mdvm_00
|
||||
shl ebx,2
|
||||
add ebx,mdvm_func_table
|
||||
call dword [ebx]
|
||||
mov [esp+28],eax
|
||||
mov [esp+24],ecx
|
||||
mov [esp+20],edx
|
||||
mov [esp+16],ebx
|
||||
popad
|
||||
retn
|
||||
mdvm_00:
|
||||
popad
|
||||
xor eax,eax
|
||||
dec eax
|
||||
retn
|
||||
|
||||
; ------Drivers Functions----------
|
||||
|
||||
align 4
|
||||
|
||||
; EBX=1 (in applications ECX=1)- Get DriverInfo and Driver Initial Set
|
||||
;
|
||||
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
|
||||
; OUT:
|
||||
;
|
||||
vm_info_init:
|
||||
push ecx
|
||||
cmp [mdrvm],dword 0
|
||||
jnz .vmii_00
|
||||
call vm_safe_reg
|
||||
call vm_get_initial_videomode
|
||||
mov eax,[initvm]
|
||||
mov [currvm],eax
|
||||
call vm_search_sys_func_table
|
||||
call vm_get_cur_vert_rate
|
||||
mov [initrr],eax
|
||||
call vm_calc_pixelclock
|
||||
call vm_calc_refrate
|
||||
inc [mdrvm]
|
||||
.vmii_00:
|
||||
pop ecx
|
||||
call vm_transfer_drv_info
|
||||
mov ebx,dword [refrate]
|
||||
mov eax,dword [mdid] ;dword [systlb]
|
||||
retn
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
; EBX=2 (in applications ECX=2)- Get Current Video Mode
|
||||
;
|
||||
; OUT: eax = X_screen*65536+Y_screen
|
||||
; ebx = current vertical rate
|
||||
; ecx = current video mode (number)
|
||||
vm_get_cur_mode:
|
||||
cmp [mdrvm],dword 0
|
||||
jz .vmgcm_00
|
||||
call vm_get_cur_vert_rate
|
||||
mov eax,[OS_BASE+0FE00h]
|
||||
mov ebx,[OS_BASE+0FE04h]
|
||||
shl eax,16
|
||||
add eax,ebx
|
||||
add eax,00010001h
|
||||
mov ebx,[refrate]
|
||||
mov ecx,[currvm]
|
||||
retn
|
||||
.vmgcm_00:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
retn
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
; EBX=3 (in applications ECX=3)- Change Video Mode
|
||||
;
|
||||
; IN: ecx = VertRate*65536+VideoMode
|
||||
; OUT: eax = 0 if no error
|
||||
;
|
||||
vm_set_video_mode:
|
||||
cmp [mdrvm],dword 0
|
||||
jz .vmsvm_00
|
||||
call vm_set_selected_mode
|
||||
; xor eax,eax
|
||||
retn
|
||||
.vmsvm_00:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
retn
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
; EBX=4 (in applications ECX=4)- Return at Start System Video Mode
|
||||
;
|
||||
; IN:
|
||||
; OUT: eax = = 0 if no error
|
||||
;
|
||||
vm_restore_init_video_mode:
|
||||
cmp [mdrvm],dword 0
|
||||
jz .vmrivm_00
|
||||
call vm_restore_reg
|
||||
xor eax,eax
|
||||
retn
|
||||
.vmrivm_00:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
retn
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
; EBX=5 (in applications ECX=5)- Change vertical and horizontal size
|
||||
; of visible screen area
|
||||
; IN: ecx (in app. edx) = 0/1 - -/+ horizontal size on 1 position
|
||||
; = 2/3 - -/+ vertical size on 1 position (8 pixels)
|
||||
; ^-^----- not complete yet
|
||||
; OUT: eax = = 0 if no error
|
||||
;
|
||||
vm_change_screen_size:
|
||||
cmp [mdrvm],dword 0
|
||||
jz .vmcss_00
|
||||
cmp cl,1
|
||||
ja .vmcss_01
|
||||
mov eax,ecx
|
||||
call vm_inc_dec_width
|
||||
xor eax,eax
|
||||
retn
|
||||
.vmcss_01:
|
||||
and ecx,01h
|
||||
mov eax,ecx
|
||||
; call vm_inc_dec_high ; not complete yet
|
||||
xor eax,eax
|
||||
retn
|
||||
.vmcss_00:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
retn
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
; EBX=6 (in applications ECX=6)- Change Vert/Hor position visible area on screen
|
||||
;
|
||||
; IN: ecx (in app. edx) = 0/1 - -/+ horizontal position on 1 point
|
||||
; = 2/3 - -/+ vertical position on 1 pixel
|
||||
; ^-^----- not complete yet
|
||||
; OUT: eax = 0 if no error
|
||||
;
|
||||
vm_change_position_screen:
|
||||
cmp [mdrvm],dword 0
|
||||
jz .vmcps_00
|
||||
; ...
|
||||
xor eax,eax
|
||||
retn
|
||||
.vmcps_00:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
retn
|
||||
|
||||
|
||||
;-----Drivers Subfunctions---------
|
||||
|
||||
;
|
||||
; Searching i40 system functions pointer table in kernel area location
|
||||
;
|
||||
vm_search_sys_func_table:
|
||||
push eax ; eax - current value
|
||||
push ecx ; ecx - will be counter of equevalent value
|
||||
push edx ; edx - last value
|
||||
push esi ; esi - current address
|
||||
xor ecx,ecx
|
||||
mov esi,OS_BASE+010000h ; Start address of kernel location
|
||||
lodsd
|
||||
mov edx,eax
|
||||
cld
|
||||
.vmssft_00:
|
||||
cmp esi,OS_BASE+30000h
|
||||
ja .vmssft_03
|
||||
inc ecx
|
||||
lodsd
|
||||
cmp edx,eax
|
||||
mov edx,eax
|
||||
je .vmssft_00
|
||||
cmp ecx,128
|
||||
ja .vmssft_02
|
||||
.vmssft_01:
|
||||
xor ecx,ecx
|
||||
jmp .vmssft_00
|
||||
.vmssft_02:
|
||||
cmp edx,0
|
||||
je .vmssft_01
|
||||
sub esi,256*4-1
|
||||
mov [systlb],esi
|
||||
xor ecx,ecx
|
||||
.vmssft_03_0:
|
||||
inc ecx
|
||||
lodsd
|
||||
cmp edx,eax
|
||||
mov edx,eax
|
||||
jne .vmssft_03_0
|
||||
mov esi,dword [systlb]
|
||||
cmp cx,60
|
||||
jae .vmssft_03
|
||||
add esi,256*4-4
|
||||
lodsb
|
||||
mov edx,eax
|
||||
jmp .vmssft_01
|
||||
.vmssft_03:
|
||||
mov [systlb],esi
|
||||
pop esi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop eax
|
||||
retn
|
||||
|
||||
; IN:
|
||||
; OUT: eax= vertical rate in Hz
|
||||
vm_get_cur_vert_rate:
|
||||
push edx
|
||||
push ebx
|
||||
xor eax,eax
|
||||
mov edx,eax
|
||||
mov ebx,eax
|
||||
mov dx,03DAh
|
||||
.vmgcvt_00:
|
||||
in al,dx
|
||||
test al,8
|
||||
jz .vmgcvt_00
|
||||
.vmgcvt_01:
|
||||
in al,dx
|
||||
test al,8
|
||||
jnz .vmgcvt_01
|
||||
mov ebx,edx
|
||||
rdtsc
|
||||
mov edx,ebx
|
||||
mov ebx,eax
|
||||
.vmgcvt_02:
|
||||
in al,dx
|
||||
test al,8
|
||||
jz .vmgcvt_02
|
||||
.vmgcvt_03:
|
||||
in al,dx
|
||||
test al,8
|
||||
jnz .vmgcvt_03
|
||||
rdtsc
|
||||
sub eax,ebx
|
||||
mov ebx,eax
|
||||
mov eax,[OS_BASE+0F600h]
|
||||
xor edx,edx
|
||||
div ebx
|
||||
inc eax
|
||||
mov [refrate],eax
|
||||
pop ebx
|
||||
pop edx
|
||||
retn
|
||||
|
||||
vm_calc_pixelclock:
|
||||
push ebx
|
||||
push edx
|
||||
xor eax,eax
|
||||
mov al,[_00]
|
||||
add ax,5
|
||||
shl eax,3
|
||||
xor ebx,ebx
|
||||
mov bl,[_06]
|
||||
mov bh,[_07]
|
||||
and bh,00100001b
|
||||
btr bx,13
|
||||
jnc .vmcpc_00
|
||||
or bh,2
|
||||
.vmcpc_00:
|
||||
xor edx,edx
|
||||
mul ebx
|
||||
xor edx,edx
|
||||
mul [initrr]
|
||||
mov [pclock],eax
|
||||
pop edx
|
||||
pop ebx
|
||||
retn
|
||||
|
||||
;
|
||||
; Safe of initial CRTC state
|
||||
;
|
||||
vm_safe_reg:
|
||||
push edx
|
||||
push ebx
|
||||
push ecx
|
||||
push edi
|
||||
cli
|
||||
mov dx,3d4h ; CRTC
|
||||
mov al,11h
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
and al,7fh
|
||||
out dx,al ; Clear protection bit
|
||||
dec dx
|
||||
xor ecx,ecx
|
||||
mov cl,19h
|
||||
xor bl,bl
|
||||
mov edi,CRTCreg
|
||||
.vmsr_00:
|
||||
mov al,bl
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
dec dx
|
||||
stosb
|
||||
inc bl
|
||||
loop .vmsr_00
|
||||
sti
|
||||
pop edi
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop edx
|
||||
retn
|
||||
|
||||
;
|
||||
; Restore of initial CRTC state
|
||||
;
|
||||
vm_restore_reg:
|
||||
push eax
|
||||
push ebx
|
||||
push edx
|
||||
push esi
|
||||
mov eax,[oldX]
|
||||
mov [OS_BASE+0FE00h],eax
|
||||
mov eax,[oldY]
|
||||
mov [OS_BASE+0FE04h],eax
|
||||
mov dx,03dah
|
||||
.vmrr_00:
|
||||
in al,dx
|
||||
test al,8
|
||||
jnz .vmrr_00
|
||||
.vmrr_01:
|
||||
in al,dx
|
||||
test al,8
|
||||
jnz .vmrr_01
|
||||
cli
|
||||
mov dx,03c4h
|
||||
mov ax,0101h
|
||||
out dx,ax
|
||||
mov dx,3d4h ; CRTC
|
||||
mov al,11h
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
and al,7fh ; Clear Protection bit
|
||||
out dx,al
|
||||
dec dx
|
||||
xor ecx,ecx
|
||||
mov cl,19h
|
||||
mov esi,CRTCreg
|
||||
xor bl,bl
|
||||
.vmrr_02:
|
||||
lodsb
|
||||
mov ah,al
|
||||
mov al,bl
|
||||
out dx,ax
|
||||
inc bl
|
||||
loop .vmrr_02
|
||||
sti
|
||||
; call ref_screen
|
||||
pop esi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop eax
|
||||
retn
|
||||
|
||||
; Calculate of possible vertical refrash rate
|
||||
; (light version of function)
|
||||
vm_calc_refrate:
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
push esi
|
||||
mov eax,[pclock]
|
||||
xor edx,edx
|
||||
mov edi,_m1
|
||||
mov ebx,eax
|
||||
mov ecx,(1696*1065)
|
||||
div ecx
|
||||
xor edx,edx
|
||||
stosw
|
||||
add edi,8
|
||||
mov eax,ebx
|
||||
mov ecx,(1344*804)
|
||||
div ecx
|
||||
xor edx,edx
|
||||
stosw
|
||||
add edi,8
|
||||
mov eax,ebx
|
||||
mov ecx,(1056*636)
|
||||
div ecx
|
||||
xor edx,edx
|
||||
stosw
|
||||
add edi,8
|
||||
mov eax,ebx
|
||||
mov ecx,(800*524)
|
||||
div ecx
|
||||
xor edx,edx
|
||||
stosw
|
||||
mov edi,_m1
|
||||
mov esi,edi
|
||||
mov ecx,5*4
|
||||
.vmcrr_00:
|
||||
lodsw
|
||||
cmp ax,55
|
||||
jb .vmcrr_01
|
||||
stosw
|
||||
loop .vmcrr_00
|
||||
pop esi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
retn
|
||||
.vmcrr_01:
|
||||
xor ax,ax
|
||||
stosw
|
||||
loop .vmcrr_00
|
||||
pop esi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
retn
|
||||
|
||||
vm_get_initial_videomode:
|
||||
push eax
|
||||
mov eax,dword [OS_BASE+0FE00h]
|
||||
mov [oldX],eax
|
||||
mov eax,dword [OS_BASE+0FE04h]
|
||||
mov [oldY],eax
|
||||
mov eax,dword [OS_BASE+0FE0Ch] ; initial video mode
|
||||
and ax,01FFh
|
||||
mov dword [initvm],eax
|
||||
pop eax
|
||||
retn
|
||||
|
||||
|
||||
; IN: eax = 0/1 - -/+ 1 position of width
|
||||
vm_inc_dec_width:
|
||||
push ebx
|
||||
push edx
|
||||
mov ebx,eax
|
||||
mov dx,3d4h ; CRTC
|
||||
mov al,11h
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
and al,7fh ; Clear Protection bit
|
||||
out dx,al
|
||||
dec dx
|
||||
xor al,al
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
dec al
|
||||
cmp bl,0
|
||||
jnz .vmidr_00
|
||||
inc al
|
||||
inc al
|
||||
.vmidr_00:
|
||||
out dx,al
|
||||
pop edx
|
||||
pop ebx
|
||||
retn
|
||||
|
||||
;
|
||||
; Copy driver info to application area
|
||||
;
|
||||
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
|
||||
; OUT:
|
||||
vm_transfer_drv_info:
|
||||
push ecx
|
||||
push edi
|
||||
push esi
|
||||
mov eax,ecx
|
||||
xor ecx,ecx
|
||||
mov cl,32/4
|
||||
mov esi,mdname
|
||||
mov edi,drvname
|
||||
rep movsd
|
||||
mov ecx,eax
|
||||
mov eax,[mdver]
|
||||
mov [drvver],eax
|
||||
mov edi,[OS_BASE+3010h]
|
||||
mov edi,[edi+10h]
|
||||
add edi,ecx
|
||||
mov esi,drvinfo
|
||||
xor ecx,ecx
|
||||
mov cx,512
|
||||
rep movsb
|
||||
pop esi
|
||||
pop edi
|
||||
pop ecx
|
||||
retn
|
||||
|
||||
|
||||
;
|
||||
; Set selected video mode
|
||||
; (light version)
|
||||
;
|
||||
; IN: ecx = VertRate*65536+VideoMode
|
||||
;
|
||||
vm_set_selected_mode:
|
||||
push edx
|
||||
push ecx
|
||||
push esi
|
||||
ror ecx,16
|
||||
cmp cx,00h
|
||||
je .vmssm_03
|
||||
rol ecx,16
|
||||
mov eax,ecx
|
||||
shl eax,16
|
||||
shr eax,16
|
||||
mov [currvm],eax
|
||||
cmp cx,112h
|
||||
jne .vmssm_00
|
||||
mov esi,mode0
|
||||
mov ecx,639
|
||||
mov edx,479
|
||||
jmp .vmssm_st00
|
||||
.vmssm_00:
|
||||
cmp cx,115h
|
||||
jne .vmssm_01
|
||||
mov esi,mode1
|
||||
mov ecx,799
|
||||
mov edx,599
|
||||
jmp .vmssm_st00
|
||||
.vmssm_01:
|
||||
cmp cx,118h
|
||||
jne .vmssm_02
|
||||
mov esi,mode2
|
||||
mov ecx,1023
|
||||
mov edx,767
|
||||
jmp .vmssm_st00
|
||||
.vmssm_02:
|
||||
cmp cx,11Bh
|
||||
jne .vmssm_03
|
||||
mov esi,mode2
|
||||
mov ecx,1279
|
||||
mov edx,1023
|
||||
jmp .vmssm_st00
|
||||
.vmssm_03:
|
||||
xor eax,eax
|
||||
dec eax
|
||||
pop esi
|
||||
pop ecx
|
||||
pop edx
|
||||
retn
|
||||
.vmssm_st00:
|
||||
mov [OS_BASE+0FE00h],ecx
|
||||
mov [OS_BASE+0FE04h],edx
|
||||
cli
|
||||
mov dx,03c4h
|
||||
lodsw
|
||||
out dx,ax
|
||||
mov dx,03d4h
|
||||
mov al,11h
|
||||
out dx,al
|
||||
inc dx
|
||||
in al,dx
|
||||
and al,7fh
|
||||
out dx,al
|
||||
dec dx
|
||||
mov ecx,13
|
||||
.vmssm_st01:
|
||||
lodsw
|
||||
out dx,ax
|
||||
loop .vmssm_st01
|
||||
sti
|
||||
xor eax,eax
|
||||
pop esi
|
||||
pop ecx
|
||||
pop edx
|
||||
retn
|
||||
|
||||
|
||||
;------------DATA AREA---------------
|
||||
align 4
|
||||
|
||||
mdvm_func_table:
|
||||
dd MDSTART
|
||||
dd vm_info_init, vm_get_cur_mode
|
||||
dd vm_set_video_mode, vm_restore_init_video_mode
|
||||
dd vm_change_screen_size, vm_change_position_screen
|
||||
|
||||
|
||||
CRTCreg:
|
||||
_00 db ?
|
||||
_01 db ?
|
||||
_02 db ?
|
||||
_03 db ?
|
||||
_04 db ?
|
||||
_05 db ?
|
||||
_06 db ?
|
||||
_07 db ?
|
||||
_08 db ?
|
||||
_09 db ?
|
||||
_0a db ?
|
||||
_0b db ?
|
||||
_0c db ?
|
||||
_0d db ?
|
||||
_0e db ?
|
||||
_0f db ?
|
||||
_10 db ?
|
||||
_11 db ?
|
||||
_12 db ?
|
||||
_13 db ?
|
||||
_14 db ?
|
||||
_15 db ?
|
||||
_16 db ?
|
||||
_17 db ?
|
||||
_18 db ?
|
||||
_19 db ?
|
||||
|
||||
align 4
|
||||
|
||||
oldX dd ?
|
||||
oldY dd ?
|
||||
initvm dd ?
|
||||
currvm dd 0
|
||||
refrate dd 0
|
||||
initrr dd 0
|
||||
systlb dd 0
|
||||
pclock dd ?
|
||||
mdrvm dd 0 ; 0 - not drv init yet, 1 - already drv init
|
||||
|
||||
|
||||
drvinfo:
|
||||
drvname: times 32 db ' '
|
||||
drvver dd 0
|
||||
times (32-($-drvver))/4 dd 0
|
||||
drvmode dw 011Bh,0118h,0115h,0112h
|
||||
times (64-($-drvmode))/2 dw 00h
|
||||
_m1 dw 0,0,0,0,0
|
||||
_m2 dw 0,0,0,0,0
|
||||
_m3 dw 0,0,0,0,0
|
||||
_m4 dw 0,0,0,0,0
|
||||
_m5 dw 0,0,0,0,0
|
||||
times (512-($-drvinfo)) db 0
|
||||
drvinfoend:
|
||||
|
||||
|
||||
;1280x1024 - 11Bh
|
||||
mode3:
|
||||
dw 0101h
|
||||
dw 0d000h,9f01h,9f02h,9303h,0a904h,1905h,2806h,5a07h
|
||||
dw 0110h,8411h,0ff12h,0ff15h,2916h
|
||||
|
||||
;1024x768 - 118h
|
||||
mode2:
|
||||
dw 0101h
|
||||
dw 0a400h,7f01h,7f02h,8703h,8404h,9505h,2406h,0f507h
|
||||
dw 0310h,8911h,0ff12h,0ff15h,2516h
|
||||
|
||||
;800x600 - 115h
|
||||
mode1:
|
||||
dw 0101h
|
||||
dw 8000h,6301h,6302h,8303h,6a04h,1a05h,7206h,0f007h
|
||||
dw 5910h,8d11h,5712h,5715h,7316h
|
||||
|
||||
;640x480 - 112h, 12h
|
||||
mode0:
|
||||
dw 0101h
|
||||
dw 6000h,4f01h,4f02h,8303h,5304h,9f05h,00b06h,3e07h
|
||||
dw 0ea10h,8c11h,0df12h,0df15h,0c16h
|
||||
|
||||
; 640x400
|
||||
;mymode0:
|
||||
; dw 0101h
|
||||
;_0_7 dw 5f00h,4f01h,4f02h,8303h,5304h,9f05h,0BF06h,1f07h
|
||||
; dw 9c10h,8e11h,8f12h,9615h,0B916h ;,4013h
|
||||
|
||||
; 640x800
|
||||
;mymode1:
|
||||
; dw 0101h
|
||||
; dw 5f00h,4f01h,4f02h,8003h,5004h,9f05h,06006h,0FF07h
|
||||
; dw 2d10h,8f11h,2012h,2615h,05716h ;,4013h
|
||||
|
||||
|
||||
DRVM_END:
|
||||
|
434
kernel/branches/fdo.inc
Normal file
434
kernel/branches/fdo.inc
Normal file
@ -0,0 +1,434 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 750 $
|
||||
|
||||
|
||||
;
|
||||
; Formatted Debug Output (FDO)
|
||||
; Copyright (c) 2005-2006, mike.dld
|
||||
; Created: 2005-01-29, Changed: 2006-11-10
|
||||
;
|
||||
; For questions and bug reports, mail to mike.dld@gmail.com
|
||||
;
|
||||
; Available format specifiers are: %s, %d, %u, %x (with partial width support)
|
||||
;
|
||||
|
||||
; to be defined:
|
||||
; __DEBUG__ equ 1
|
||||
; __DEBUG_LEVEL__ equ 5
|
||||
|
||||
macro debug_func name {
|
||||
if used name
|
||||
name@of@func equ name
|
||||
}
|
||||
|
||||
macro debug_beginf {
|
||||
align 4
|
||||
name@of@func:
|
||||
}
|
||||
|
||||
debug_endf fix end if
|
||||
|
||||
macro DEBUGS _sign,[_str] {
|
||||
common
|
||||
local tp
|
||||
tp equ 0
|
||||
match _arg:_num,_str \{
|
||||
DEBUGS_N _sign,_num,_arg
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 _arg,tp _str \{
|
||||
DEBUGS_N _sign,,_arg
|
||||
\}
|
||||
}
|
||||
|
||||
macro DEBUGS_N _sign,_num,[_str] {
|
||||
common
|
||||
pushf
|
||||
pushad
|
||||
local ..str,..label,is_str
|
||||
is_str = 0
|
||||
forward
|
||||
if _str eqtype ''
|
||||
is_str = 1
|
||||
end if
|
||||
common
|
||||
if is_str = 1
|
||||
jmp ..label
|
||||
..str db _str,0
|
||||
..label:
|
||||
add esp,4*8+4
|
||||
mov edx,..str
|
||||
sub esp,4*8+4
|
||||
else
|
||||
mov edx,_str
|
||||
end if
|
||||
if ~_num eq
|
||||
if _num eqtype eax
|
||||
if _num in <eax,ebx,ecx,edx,edi,ebp,esp>
|
||||
mov esi,_num
|
||||
else if ~_num eq esi
|
||||
movzx esi,_num
|
||||
end if
|
||||
else if _num eqtype 0
|
||||
mov esi,_num
|
||||
else
|
||||
local tp
|
||||
tp equ 0
|
||||
match [_arg],_num \{
|
||||
mov esi,dword[_arg]
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 =dword[_arg],tp _num \{
|
||||
mov esi,dword[_arg]
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 =word[_arg],tp _num \{
|
||||
movzx esi,word[_arg]
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 =byte[_arg],tp _num \{
|
||||
movzx esi,byte[_arg]
|
||||
tp equ 1
|
||||
\}
|
||||
match =0,tp \{
|
||||
'Error: specified string width is incorrect'
|
||||
\}
|
||||
end if
|
||||
else
|
||||
mov esi,0x7FFFFFFF
|
||||
end if
|
||||
call fdo_debug_outstr
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
macro DEBUGD _sign,_dec {
|
||||
local tp
|
||||
tp equ 0
|
||||
match _arg:_num,_dec \{
|
||||
DEBUGD_N _sign,_num,_arg
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 _arg,tp _dec \{
|
||||
DEBUGD_N _sign,,_arg
|
||||
\}
|
||||
}
|
||||
|
||||
macro DEBUGD_N _sign,_num,_dec {
|
||||
pushf
|
||||
pushad
|
||||
if (~_num eq)
|
||||
if (_dec eqtype eax | _dec eqtype 0)
|
||||
'Error: precision allowed only for in-memory variables'
|
||||
end if
|
||||
if (~_num in <1,2,4>)
|
||||
if _sign
|
||||
'Error: 1, 2 and 4 are only allowed for precision in %d'
|
||||
else
|
||||
'Error: 1, 2 and 4 are only allowed for precision in %u'
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
if _dec eqtype eax
|
||||
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp>
|
||||
mov eax,_dec
|
||||
else if ~_dec eq eax
|
||||
if _sign = 1
|
||||
movsx eax,_dec
|
||||
else
|
||||
movzx eax,_dec
|
||||
end if
|
||||
end if
|
||||
else if _dec eqtype 0
|
||||
mov eax,_dec
|
||||
else
|
||||
add esp,4*8+4
|
||||
if _num eq
|
||||
mov eax,dword _dec
|
||||
else if _num = 1
|
||||
if _sign = 1
|
||||
movsx eax,byte _dec
|
||||
else
|
||||
movzx eax,byte _dec
|
||||
end if
|
||||
else if _num = 2
|
||||
if _sign = 1
|
||||
movsx eax,word _dec
|
||||
else
|
||||
movzx eax,word _dec
|
||||
end if
|
||||
else
|
||||
mov eax,dword _dec
|
||||
end if
|
||||
sub esp,4*8+4
|
||||
end if
|
||||
mov cl,_sign
|
||||
call fdo_debug_outdec
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
macro DEBUGH _sign,_hex {
|
||||
local tp
|
||||
tp equ 0
|
||||
match _arg:_num,_hex \{
|
||||
DEBUGH_N _sign,_num,_arg
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 _arg,tp _hex \{
|
||||
DEBUGH_N _sign,,_arg
|
||||
\}
|
||||
}
|
||||
|
||||
macro DEBUGH_N _sign,_num,_hex {
|
||||
pushf
|
||||
pushad
|
||||
if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>)
|
||||
'Error: 1..8 are only allowed for precision in %x'
|
||||
end if
|
||||
if _hex eqtype eax
|
||||
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
|
||||
if ~_hex eq eax
|
||||
mov eax,_hex
|
||||
end if
|
||||
mov edx,8
|
||||
else if _hex in <ax,bx,cx,dx,si,di,bp,sp>
|
||||
if ~_hex eq ax
|
||||
movzx eax,_hex
|
||||
end if
|
||||
shl eax,16
|
||||
if (_num eq)
|
||||
mov edx,4
|
||||
end if
|
||||
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh>
|
||||
if ~_hex eq al
|
||||
movzx eax,_hex
|
||||
end if
|
||||
shl eax,24
|
||||
if (_num eq)
|
||||
mov edx,2
|
||||
end if
|
||||
end if
|
||||
else if _hex eqtype 0
|
||||
mov eax,_hex
|
||||
else
|
||||
add esp,4*8+4
|
||||
mov eax,dword _hex
|
||||
sub esp,4*8+4
|
||||
end if
|
||||
if ~_num eq
|
||||
mov edx,_num
|
||||
else
|
||||
if ~_hex eqtype eax
|
||||
mov edx,8
|
||||
end if
|
||||
end if
|
||||
call fdo_debug_outhex
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
debug_func fdo_debug_outchar
|
||||
debug_beginf
|
||||
pushad
|
||||
movzx ebx,al
|
||||
mov eax,1
|
||||
mov ecx,sys_msg_board
|
||||
call ecx ; sys_msg_board
|
||||
popad
|
||||
ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outstr
|
||||
debug_beginf
|
||||
mov eax,1
|
||||
.l1: dec esi
|
||||
js .l2
|
||||
movzx ebx,byte[edx]
|
||||
or bl,bl
|
||||
jz .l2
|
||||
mov ecx,sys_msg_board
|
||||
call ecx ; sys_msg_board
|
||||
inc edx
|
||||
jmp .l1
|
||||
.l2: ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outdec
|
||||
debug_beginf
|
||||
or cl,cl
|
||||
jz @f
|
||||
or eax,eax
|
||||
jns @f
|
||||
neg eax
|
||||
push eax
|
||||
mov al,'-'
|
||||
call fdo_debug_outchar
|
||||
pop eax
|
||||
@@: push 10
|
||||
pop ecx
|
||||
push -'0'
|
||||
.l1: xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
test eax,eax
|
||||
jnz .l1
|
||||
.l2: pop eax
|
||||
add al,'0'
|
||||
jz .l3
|
||||
call fdo_debug_outchar
|
||||
jmp .l2
|
||||
.l3: ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outhex
|
||||
__fdo_hexdigits db '0123456789ABCDEF'
|
||||
debug_beginf
|
||||
mov cl,dl
|
||||
neg cl
|
||||
add cl,8
|
||||
shl cl,2
|
||||
rol eax,cl
|
||||
.l1: rol eax,4
|
||||
push eax
|
||||
and eax,0x0000000F
|
||||
mov al,[__fdo_hexdigits+eax]
|
||||
call fdo_debug_outchar
|
||||
pop eax
|
||||
dec edx
|
||||
jnz .l1
|
||||
ret
|
||||
debug_endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
macro DEBUGF _level,_format,[_arg] {
|
||||
common
|
||||
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__
|
||||
local ..f1,f2,a1,a2,c1,c2,c3,..lbl
|
||||
_debug_str_ equ __debug_str_ # a1
|
||||
a1 = 0
|
||||
c2 = 0
|
||||
c3 = 0
|
||||
f2 = 0
|
||||
repeat ..lbl-..f1
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
load c1 word from %-1
|
||||
end virtual
|
||||
if c1 = '%s'
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER S,a1,0,_arg
|
||||
else if c1 = '%x'
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER H,a1,0,_arg
|
||||
else if c1 = '%d' | c1 = '%u'
|
||||
local c4
|
||||
if c1 = '%d'
|
||||
c4 = 1
|
||||
else
|
||||
c4 = 0
|
||||
end if
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER D,a1,c4,_arg
|
||||
else if c1 = '\n'
|
||||
c3 = c3 + 1
|
||||
end if
|
||||
end repeat
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if (c1<>0)&(f2<>..lbl-..f1-1)
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
virtual at 0
|
||||
..f1 db _format,0
|
||||
..lbl:
|
||||
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3
|
||||
end virtual
|
||||
end if
|
||||
}
|
||||
|
||||
macro __include_debug_strings dummy,[_id,_fmt,_len] {
|
||||
common
|
||||
local c1,a1,a2
|
||||
forward
|
||||
if defined _len & ~_len eq
|
||||
_id:
|
||||
a1 = 0
|
||||
a2 = 0
|
||||
repeat _len
|
||||
virtual at 0
|
||||
db _fmt,0,0
|
||||
load c1 word from %+a2-1
|
||||
end virtual
|
||||
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u')
|
||||
db 0
|
||||
a2 = a2 + 1
|
||||
else if (c1='\n')
|
||||
dw $0A0D
|
||||
a1 = a1 + 1
|
||||
a2 = a2 + 1
|
||||
else
|
||||
db c1 and 0x0FF
|
||||
end if
|
||||
end repeat
|
||||
db 0
|
||||
end if
|
||||
}
|
||||
|
||||
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] {
|
||||
common
|
||||
local num
|
||||
num = 0
|
||||
forward
|
||||
if num = _num
|
||||
DEBUG#_letter _sign,_arg
|
||||
end if
|
||||
num = num+1
|
||||
common
|
||||
_num = _num+1
|
||||
}
|
||||
|
||||
macro include_debug_strings {
|
||||
if __DEBUG__ = 1
|
||||
match dbg_str,__debug_strings \{
|
||||
__include_debug_strings dbg_str
|
||||
\}
|
||||
end if
|
||||
}
|
2269
kernel/branches/fs/fat12.inc
Normal file
2269
kernel/branches/fs/fat12.inc
Normal file
File diff suppressed because it is too large
Load Diff
2921
kernel/branches/fs/fat32.inc
Normal file
2921
kernel/branches/fs/fat32.inc
Normal file
File diff suppressed because it is too large
Load Diff
797
kernel/branches/fs/fs.inc
Normal file
797
kernel/branches/fs/fs.inc
Normal file
@ -0,0 +1,797 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; ;;
|
||||
;; System service for filesystem call ;;
|
||||
;; (C) 2004 Ville Turjanmaa, License: GPL ;;
|
||||
;; 29.04.2006 Elimination of hangup after the ;;
|
||||
;; expiration hd_wait_timeout (for LBA) - Mario79 ;;
|
||||
;; 15.01.2005 get file size/attr/date, ;;
|
||||
;; file_append (only for hd) - ATV ;;
|
||||
;; 23.11.2004 test if hd/partition is set - ATV ;;
|
||||
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
|
||||
;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;;
|
||||
;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 709 $
|
||||
|
||||
|
||||
iglobal
|
||||
dir0: db 'HARDDISK '
|
||||
db 'RAMDISK '
|
||||
db 'FLOPPYDISK '
|
||||
db 0
|
||||
|
||||
dir1: db 'FIRST '
|
||||
db 'SECOND '
|
||||
db 'THIRD '
|
||||
db 'FOURTH '
|
||||
db 0
|
||||
|
||||
not_select_IDE db 0
|
||||
|
||||
hd_address_table: dd 0x1f0,0x00,0x1f0,0x10
|
||||
dd 0x170,0x00,0x170,0x10
|
||||
endg
|
||||
|
||||
file_system:
|
||||
|
||||
; IN:
|
||||
;
|
||||
; eax = 0 ; read file /RamDisk/First 6
|
||||
; eax = 8 ; lba read
|
||||
; eax = 15 ; get_disk_info
|
||||
;
|
||||
; OUT:
|
||||
;
|
||||
; eax = 0 : read ok
|
||||
; eax = 1 : no hd base and/or partition defined
|
||||
; eax = 2 : function is unsupported for this FS
|
||||
; eax = 3 : unknown FS
|
||||
; eax = 4 : partition not defined at hd
|
||||
; eax = 5 : file not found
|
||||
; eax = 6 : end of file
|
||||
; eax = 7 : memory pointer not in application area
|
||||
; eax = 8 : disk full
|
||||
; eax = 9 : fat table corrupted
|
||||
; eax = 10 : access denied
|
||||
; eax = 11 : disk error
|
||||
;
|
||||
; ebx = size
|
||||
|
||||
; \begin{diamond}[18.03.2006]
|
||||
; for subfunction 16 (start application) error codes must be negative
|
||||
; because positive values are valid PIDs
|
||||
; so possible return values are:
|
||||
; eax > 0 : process created, eax=PID
|
||||
|
||||
; -0x10 <= eax < 0 : -eax is filesystem error code:
|
||||
; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined
|
||||
; eax = -3 = 0xFFFFFFFD : unknown FS
|
||||
; eax = -5 = 0xFFFFFFFB : file not found
|
||||
; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file)
|
||||
; eax = -9 = 0xFFFFFFF7 : fat table corrupted
|
||||
; eax = -10 = 0xFFFFFFF6 : access denied
|
||||
|
||||
; -0x20 <= eax < -0x10: eax is process creation error code:
|
||||
; eax = -0x20 = 0xFFFFFFE0 : too many processes
|
||||
; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable
|
||||
; eax = -0x1E = 0xFFFFFFE2 : no memory
|
||||
|
||||
; ebx is not changed
|
||||
|
||||
; \end{diamond}[18.03.2006]
|
||||
|
||||
; Extract parameters
|
||||
; add eax, std_application_base_address ; abs start of info block
|
||||
|
||||
cmp dword [eax+0],15 ; GET_DISK_INFO
|
||||
je fs_info
|
||||
|
||||
cmp dword [CURRENT_TASK],1 ; no memory checks for kernel requests
|
||||
jz no_checks_for_kernel
|
||||
mov edx,eax
|
||||
cmp dword [eax+0],1
|
||||
jnz .usual_check
|
||||
mov ebx,[eax+12]
|
||||
; add ebx,std_application_base_address
|
||||
mov ecx,[eax+8]
|
||||
call check_region
|
||||
test eax,eax
|
||||
jnz area_in_app_mem
|
||||
|
||||
.error_output:
|
||||
mov esi,buffer_failed
|
||||
call sys_msg_board_str
|
||||
; mov eax,7
|
||||
mov dword [esp+36],7
|
||||
ret
|
||||
iglobal
|
||||
buffer_failed db 'K : Buffer check failed',13,10,0
|
||||
endg
|
||||
.usual_check:
|
||||
cmp dword [eax+0],0
|
||||
mov ecx,512
|
||||
jnz .small_size
|
||||
mov ecx,[eax+8]
|
||||
shl ecx,9
|
||||
.small_size:
|
||||
mov ebx,[eax+12]
|
||||
; add ebx,std_application_base_address
|
||||
call check_region
|
||||
test eax,eax
|
||||
jz .error_output
|
||||
area_in_app_mem:
|
||||
mov eax,edx
|
||||
no_checks_for_kernel:
|
||||
|
||||
fs_read:
|
||||
|
||||
mov ebx,[eax+20] ; program wants root directory ?
|
||||
test bl,bl
|
||||
je fs_getroot
|
||||
test bh,bh
|
||||
jne fs_noroot
|
||||
fs_getroot:
|
||||
; \begin{diamond}[18.03.2006]
|
||||
; root - only read is allowed
|
||||
; other operations return "access denied", eax=10
|
||||
; (execute operation returns eax=-10)
|
||||
cmp dword [eax], 0
|
||||
jz .read_root
|
||||
mov dword [esp+36], 10
|
||||
ret
|
||||
.read_root:
|
||||
; \end{diamond}[18.03.2006]
|
||||
mov esi,dir0
|
||||
mov edi,[eax+12]
|
||||
; add edi,std_application_base_address
|
||||
mov ecx,11
|
||||
push ecx
|
||||
; cld ; already is
|
||||
rep movsb
|
||||
mov al,0x10
|
||||
stosb
|
||||
add edi,32-11-1
|
||||
pop ecx
|
||||
rep movsb
|
||||
stosb
|
||||
and dword [esp+36],0 ; ok read
|
||||
mov dword [esp+24],32*2 ; size of root
|
||||
ret
|
||||
|
||||
fs_info: ;start of code - Mihasik
|
||||
push eax
|
||||
cmp [eax+21],byte 'h'
|
||||
je fs_info_h
|
||||
cmp [eax+21],byte 'H'
|
||||
je fs_info_h
|
||||
cmp [eax+21],byte 'r'
|
||||
je fs_info_r
|
||||
cmp [eax+21],byte 'R'
|
||||
je fs_info_r
|
||||
mov eax,3 ;if unknown disk
|
||||
xor ebx,ebx
|
||||
xor ecx,ecx
|
||||
xor edx,edx
|
||||
jmp fs_info1
|
||||
fs_info_r:
|
||||
call ramdisk_free_space ;if ramdisk
|
||||
mov ecx,edi ;free space in ecx
|
||||
shr ecx,9 ;free clusters
|
||||
mov ebx,2847 ;total clusters
|
||||
mov edx,512 ;cluster size
|
||||
xor eax,eax ;always 0
|
||||
jmp fs_info1
|
||||
fs_info_h: ;if harddisk
|
||||
call get_hd_info
|
||||
fs_info1:
|
||||
pop edi
|
||||
mov [esp+36],eax
|
||||
mov [esp+24],ebx ; total clusters on disk
|
||||
mov [esp+32],ecx ; free clusters on disk
|
||||
mov [edi],edx ; cluster size in bytes
|
||||
ret ;end of code - Mihasik
|
||||
|
||||
fs_noroot:
|
||||
|
||||
push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run
|
||||
push dword [eax+4] ; 512 block number to read
|
||||
push dword [eax+8] ; bytes to write/append or 512 blocks to read
|
||||
mov ebx,[eax+12]
|
||||
; add ebx,std_application_base_address
|
||||
push ebx ; abs start of return/save area
|
||||
|
||||
lea esi,[eax+20] ; abs start of dir + filename
|
||||
mov edi,[eax+16]
|
||||
; add edi,std_application_base_address ; abs start of work area
|
||||
|
||||
call expand_pathz
|
||||
|
||||
push edi ; dir start
|
||||
push ebx ; name of file start
|
||||
|
||||
mov eax,[edi+1]
|
||||
cmp eax,'RD '
|
||||
je fs_yesramdisk
|
||||
cmp eax,'RAMD'
|
||||
jne fs_noramdisk
|
||||
|
||||
fs_yesramdisk:
|
||||
|
||||
cmp byte [edi+1+11],0
|
||||
je fs_give_dir1
|
||||
|
||||
mov eax,[edi+1+12]
|
||||
cmp eax,'1 '
|
||||
je fs_yesramdisk_first
|
||||
cmp eax,'FIRS'
|
||||
jne fs_noramdisk
|
||||
|
||||
fs_yesramdisk_first:
|
||||
|
||||
cmp dword [esp+20],8 ; LBA read ramdisk
|
||||
jne fs_no_LBA_read_ramdisk
|
||||
|
||||
mov eax,[esp+16] ; LBA block to read
|
||||
mov ecx,[esp+8] ; abs pointer to return area
|
||||
|
||||
call LBA_read_ramdisk
|
||||
jmp file_system_return
|
||||
|
||||
|
||||
fs_no_LBA_read_ramdisk:
|
||||
|
||||
cmp dword [esp+20],0 ; READ
|
||||
jne fs_noramdisk_read
|
||||
|
||||
mov eax,[esp+4] ; fname
|
||||
add eax,2*12+1
|
||||
mov ebx,[esp+16] ; block start
|
||||
inc ebx
|
||||
mov ecx,[esp+12] ; block count
|
||||
mov edx,[esp+8] ; return
|
||||
mov esi,[esp+0]
|
||||
sub esi,eax
|
||||
add esi,12+1 ; file name length
|
||||
call fileread
|
||||
|
||||
jmp file_system_return
|
||||
|
||||
|
||||
fs_noramdisk_read:
|
||||
fs_noramdisk:
|
||||
|
||||
;********************************************************************
|
||||
mov eax,[edi+1]
|
||||
cmp eax,'FD '
|
||||
je fs_yesflpdisk
|
||||
cmp eax,'FLOP'
|
||||
jne fs_noflpdisk
|
||||
|
||||
fs_yesflpdisk:
|
||||
call reserve_flp
|
||||
|
||||
cmp byte [edi+1+11],0
|
||||
je fs_give_dir1
|
||||
|
||||
mov eax,[edi+1+12]
|
||||
cmp eax,'1 '
|
||||
je fs_yesflpdisk_first
|
||||
cmp eax,'FIRS'
|
||||
je fs_yesflpdisk_first
|
||||
cmp eax,'2 '
|
||||
je fs_yesflpdisk_second
|
||||
cmp eax,'SECO'
|
||||
jne fs_noflpdisk
|
||||
jmp fs_yesflpdisk_second
|
||||
|
||||
fs_yesflpdisk_first:
|
||||
mov [flp_number],1
|
||||
jmp fs_yesflpdisk_start
|
||||
fs_yesflpdisk_second:
|
||||
mov [flp_number],2
|
||||
fs_yesflpdisk_start:
|
||||
cmp dword [esp+20],0 ; READ
|
||||
jne fs_noflpdisk_read
|
||||
|
||||
mov eax,[esp+4] ; fname
|
||||
add eax,2*12+1
|
||||
mov ebx,[esp+16] ; block start
|
||||
inc ebx
|
||||
mov ecx,[esp+12] ; block count
|
||||
mov edx,[esp+8] ; return
|
||||
mov esi,[esp+0]
|
||||
sub esi,eax
|
||||
add esi,12+1 ; file name length
|
||||
call floppy_fileread
|
||||
|
||||
jmp file_system_return
|
||||
|
||||
|
||||
fs_noflpdisk_read:
|
||||
fs_noflpdisk:
|
||||
;*****************************************************************
|
||||
|
||||
mov eax,[edi+1]
|
||||
cmp eax,'HD0 '
|
||||
je fs_yesharddisk_IDE0
|
||||
cmp eax,'HD1 '
|
||||
je fs_yesharddisk_IDE1
|
||||
cmp eax,'HD2 '
|
||||
je fs_yesharddisk_IDE2
|
||||
cmp eax,'HD3 '
|
||||
je fs_yesharddisk_IDE3
|
||||
jmp old_path_harddisk
|
||||
fs_yesharddisk_IDE0:
|
||||
call reserve_hd1
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],1
|
||||
jmp fs_yesharddisk_partition
|
||||
fs_yesharddisk_IDE1:
|
||||
call reserve_hd1
|
||||
mov [hdbase],0x1f0
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],2
|
||||
jmp fs_yesharddisk_partition
|
||||
fs_yesharddisk_IDE2:
|
||||
call reserve_hd1
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x0
|
||||
mov [hdpos],3
|
||||
jmp fs_yesharddisk_partition
|
||||
fs_yesharddisk_IDE3:
|
||||
call reserve_hd1
|
||||
mov [hdbase],0x170
|
||||
mov [hdid],0x10
|
||||
mov [hdpos],4
|
||||
fs_yesharddisk_partition:
|
||||
call reserve_hd_channel
|
||||
; call choice_necessity_partition
|
||||
; jmp fs_yesharddisk_all
|
||||
jmp fs_for_new_semantic
|
||||
|
||||
choice_necessity_partition:
|
||||
mov eax,[edi+1+12]
|
||||
call StringToNumber
|
||||
mov [fat32part],eax
|
||||
choice_necessity_partition_1:
|
||||
mov ecx,[hdpos]
|
||||
xor eax,eax
|
||||
mov [hd_entries], eax ; entries in hd cache
|
||||
mov edx,DRIVE_DATA+2
|
||||
cmp ecx,0x80
|
||||
jb search_partition_array
|
||||
mov ecx,4
|
||||
search_partition_array:
|
||||
mov bl,[edx]
|
||||
movzx ebx,bl
|
||||
add eax,ebx
|
||||
inc edx
|
||||
loop search_partition_array
|
||||
mov ecx,[hdpos]
|
||||
mov edx,BiosDiskPartitions
|
||||
sub ecx,0x80
|
||||
jb .s
|
||||
je .f
|
||||
@@:
|
||||
mov ebx,[edx]
|
||||
add edx,4
|
||||
add eax,ebx
|
||||
loop @b
|
||||
jmp .f
|
||||
.s:
|
||||
sub eax,ebx
|
||||
.f:
|
||||
add eax,[fat32part]
|
||||
dec eax
|
||||
xor edx,edx
|
||||
imul eax,100
|
||||
add eax,DRIVE_DATA+0xa
|
||||
mov [transfer_adress],eax
|
||||
call partition_data_transfer_1
|
||||
ret
|
||||
|
||||
old_path_harddisk:
|
||||
mov eax,[edi+1]
|
||||
cmp eax,'HD '
|
||||
je fs_yesharddisk
|
||||
cmp eax,'HARD'
|
||||
jne fs_noharddisk
|
||||
|
||||
fs_yesharddisk:
|
||||
cmp dword [esp+20],8 ; LBA read
|
||||
jne fs_no_LBA_read
|
||||
mov eax,[esp+16] ; LBA block to read
|
||||
lea ebx,[edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH
|
||||
mov ecx,[esp+8] ; abs pointer to return area
|
||||
call LBA_read
|
||||
jmp file_system_return
|
||||
|
||||
fs_no_LBA_read:
|
||||
|
||||
cmp byte [edi+1+11],0 ; directory read
|
||||
je fs_give_dir1
|
||||
call reserve_hd1
|
||||
fs_for_new_semantic:
|
||||
call choice_necessity_partition
|
||||
|
||||
fs_yesharddisk_all:
|
||||
mov eax,1
|
||||
mov ebx, [esp+24+24]
|
||||
cmp [hdpos],0 ; is hd base set?
|
||||
jz hd_err_return
|
||||
cmp [fat32part],0 ; is partition set?
|
||||
jnz @f
|
||||
hd_err_return:
|
||||
call free_hd_channel
|
||||
and [hd1_status], 0
|
||||
jmp file_system_return
|
||||
@@:
|
||||
|
||||
cmp dword [esp+20],0 ; READ
|
||||
jne fs_noharddisk_read
|
||||
|
||||
mov eax,[esp+0] ; /fname
|
||||
lea edi,[eax+12]
|
||||
mov byte [eax],0 ; path to asciiz
|
||||
inc eax ; filename start
|
||||
|
||||
mov ebx,[esp+12] ; count to read
|
||||
mov ecx,[esp+8] ; buffer
|
||||
mov edx,[esp+4]
|
||||
add edx,12*2 ; dir start
|
||||
sub edi,edx ; path length
|
||||
mov esi,[esp+16] ; blocks to read
|
||||
|
||||
call file_read
|
||||
|
||||
mov edi,[esp+0]
|
||||
mov byte [edi],'/'
|
||||
|
||||
call free_hd_channel
|
||||
and [hd1_status], 0
|
||||
jmp file_system_return
|
||||
|
||||
fs_noharddisk_read:
|
||||
|
||||
call free_hd_channel
|
||||
and [hd1_status], 0
|
||||
|
||||
fs_noharddisk:
|
||||
; \begin{diamond}[18.03.2006]
|
||||
mov eax, 5 ; file not found
|
||||
; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè?
|
||||
mov ebx, [esp+24+24] ; do not change ebx in application
|
||||
; \end{diamond}[18.03.2006]
|
||||
|
||||
file_system_return:
|
||||
|
||||
add esp,24
|
||||
|
||||
mov [esp+36],eax
|
||||
mov [esp+24],ebx
|
||||
ret
|
||||
|
||||
|
||||
fs_give_dir1:
|
||||
|
||||
; \begin{diamond}[18.03.2006]
|
||||
; /RD,/FD,/HD - only read is allowed
|
||||
; other operations return "access denied", eax=10
|
||||
; (execute operation returns eax=-10)
|
||||
cmp dword [esp+20], 0
|
||||
jz .read
|
||||
add esp, 20
|
||||
pop ecx
|
||||
mov dword [esp+36], 10
|
||||
ret
|
||||
.read:
|
||||
; \end{diamond}[18.03.2006]
|
||||
mov al,0x10
|
||||
mov ebx,1
|
||||
mov edi,[esp+8]
|
||||
mov esi,dir1
|
||||
fs_d1_new:
|
||||
mov ecx,11
|
||||
; cld
|
||||
rep movsb
|
||||
stosb
|
||||
add edi,32-11-1
|
||||
dec ebx
|
||||
jne fs_d1_new
|
||||
|
||||
add esp,24
|
||||
|
||||
and dword [esp+36],0 ; ok read
|
||||
mov dword [esp+24],32*1 ; dir/data size
|
||||
ret
|
||||
|
||||
|
||||
|
||||
LBA_read_ramdisk:
|
||||
|
||||
cmp [lba_read_enabled],1
|
||||
je lbarrl1
|
||||
|
||||
xor ebx,ebx
|
||||
mov eax,2
|
||||
ret
|
||||
|
||||
lbarrl1:
|
||||
|
||||
cmp eax,18*2*80
|
||||
jb lbarrl2
|
||||
xor ebx,ebx
|
||||
mov eax,3
|
||||
ret
|
||||
|
||||
lbarrl2:
|
||||
|
||||
pushad
|
||||
|
||||
call restorefatchain
|
||||
|
||||
mov edi,ecx
|
||||
mov esi,eax
|
||||
|
||||
shl esi,9
|
||||
add esi,RAMDISK
|
||||
mov ecx,512/4
|
||||
; cld
|
||||
rep movsd
|
||||
|
||||
popad
|
||||
|
||||
xor ebx,ebx
|
||||
xor eax,eax
|
||||
ret
|
||||
|
||||
LBA_read:
|
||||
|
||||
; IN:
|
||||
;
|
||||
; eax = LBA block to read
|
||||
; ebx = pointer to FIRST/SECOND/THIRD/FOURTH
|
||||
; ecx = abs pointer to return area
|
||||
|
||||
cmp [lba_read_enabled],1
|
||||
je lbarl1
|
||||
mov eax,2
|
||||
ret
|
||||
|
||||
lbarl1:
|
||||
|
||||
call reserve_hd1
|
||||
|
||||
push eax
|
||||
push ecx
|
||||
|
||||
mov edi,hd_address_table
|
||||
mov esi,dir1
|
||||
mov eax,[ebx]
|
||||
mov edx,'1 '
|
||||
mov ecx,4
|
||||
blar0:
|
||||
cmp eax,[esi]
|
||||
je blar2
|
||||
cmp eax,edx
|
||||
je blar2
|
||||
inc edx
|
||||
add edi,8
|
||||
add esi,11
|
||||
dec ecx
|
||||
jnz blar0
|
||||
|
||||
mov eax,1
|
||||
mov ebx,1
|
||||
jmp LBA_read_ret
|
||||
|
||||
blar2:
|
||||
mov eax,[edi+0]
|
||||
mov ebx,[edi+4]
|
||||
|
||||
mov [hdbase],eax
|
||||
mov [hdid],ebx
|
||||
|
||||
call wait_for_hd_idle
|
||||
cmp [hd_error],0
|
||||
jne hd_lba_error
|
||||
|
||||
; eax = hd port
|
||||
; ebx = set for primary (0x00) or slave (0x10)
|
||||
|
||||
cli
|
||||
|
||||
mov edx,eax
|
||||
inc edx
|
||||
xor eax,eax
|
||||
out dx,al
|
||||
inc edx
|
||||
inc eax
|
||||
out dx,al
|
||||
inc edx
|
||||
mov eax,[esp+4]
|
||||
out dx,al
|
||||
shr eax,8
|
||||
inc edx
|
||||
out dx,al
|
||||
shr eax,8
|
||||
inc edx
|
||||
out dx,al
|
||||
shr eax,8
|
||||
inc edx
|
||||
and al,1+2+4+8
|
||||
add al,bl
|
||||
add al,128+64+32
|
||||
out dx,al
|
||||
|
||||
inc edx
|
||||
mov al,20h
|
||||
out dx,al
|
||||
|
||||
sti
|
||||
|
||||
call wait_for_sector_buffer
|
||||
cmp [hd_error],0
|
||||
jne hd_lba_error
|
||||
|
||||
cli
|
||||
|
||||
mov edi,[esp+0]
|
||||
mov ecx,256
|
||||
sub edx,7
|
||||
cld
|
||||
rep insw
|
||||
|
||||
sti
|
||||
|
||||
xor eax,eax
|
||||
xor ebx,ebx
|
||||
|
||||
LBA_read_ret:
|
||||
mov [hd_error],0
|
||||
mov [hd1_status],0
|
||||
add esp,2*4
|
||||
|
||||
ret
|
||||
|
||||
|
||||
expand_pathz:
|
||||
; IN:
|
||||
; esi = asciiz path & file
|
||||
; edi = buffer for path & file name
|
||||
; OUT:
|
||||
; edi = directory & file : / 11 + / 11 + / 11 - zero terminated
|
||||
; ebx = /file name - zero terminated
|
||||
; esi = pointer after source
|
||||
|
||||
push eax
|
||||
push ecx
|
||||
push edi ;[esp+0]
|
||||
|
||||
pathz_start:
|
||||
mov byte [edi],'/'
|
||||
inc edi
|
||||
mov al,32
|
||||
mov ecx,11
|
||||
cld
|
||||
rep stosb ; clear filename area
|
||||
sub edi,11
|
||||
mov ebx,edi ; start of dir/file name
|
||||
|
||||
pathz_new_char:
|
||||
mov al,[esi]
|
||||
inc esi
|
||||
cmp al,0
|
||||
je pathz_end
|
||||
|
||||
cmp al,'/'
|
||||
jne pathz_not_path
|
||||
cmp edi,ebx ; skip first '/'
|
||||
jz pathz_new_char
|
||||
lea edi,[ebx+11] ; start of next directory
|
||||
jmp pathz_start
|
||||
|
||||
pathz_not_path:
|
||||
cmp al,'.'
|
||||
jne pathz_not_ext
|
||||
lea edi,[ebx+8] ; start of extension
|
||||
jmp pathz_new_char
|
||||
|
||||
pathz_not_ext:
|
||||
cmp al,'a'
|
||||
jb pathz_not_low
|
||||
cmp al,'z'
|
||||
ja pathz_not_low
|
||||
sub al,0x20 ; char to uppercase
|
||||
|
||||
pathz_not_low:
|
||||
mov [edi],al
|
||||
inc edi
|
||||
mov eax,[esp+0] ; start_of_dest_path
|
||||
add eax,512 ; keep maximum path under 512 bytes
|
||||
cmp edi,eax
|
||||
jb pathz_new_char
|
||||
|
||||
pathz_end:
|
||||
cmp ebx,edi ; if path end with '/'
|
||||
jnz pathz_put_zero ; go back 1 level
|
||||
sub ebx,12
|
||||
|
||||
pathz_put_zero:
|
||||
mov byte [ebx+11],0
|
||||
dec ebx ; include '/' char into file name
|
||||
pop edi
|
||||
pop ecx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;*******************************************
|
||||
;* string to number
|
||||
;* input eax - 4 byte string
|
||||
;* output eax - number
|
||||
;*******************************************
|
||||
StringToNumber:
|
||||
; ÏÅÐÅÂÎÄ ÑÒÐÎÊÎÂÎÃÎ ×ÈÑËÀ  ×ÈÑËÎÂÎÉ ÂÈÄ
|
||||
; Âõîä:
|
||||
; EDI - àäðåñ ñòðîêè ñ ÷èñëîì. Êîíåö ÷èñëà îòìå÷åí êîäîì 0Dh
|
||||
; Âûõîä:
|
||||
; CF - èíäèêàòîð îøèáîê:
|
||||
; 0 - îøèáîê íåò;
|
||||
; 1 - îøèáêà
|
||||
; Åñëè CF=0, òî AX - ÷èñëî.
|
||||
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push edi
|
||||
mov [partition_string],eax
|
||||
mov edi,partition_string
|
||||
xor cx,cx
|
||||
i1:
|
||||
mov al,[edi]
|
||||
cmp al,32 ;13
|
||||
je i_exit
|
||||
; cmp al,'0'
|
||||
; jb err
|
||||
; cmp al,'9'
|
||||
; ja err
|
||||
sub al,48
|
||||
shl cx,1
|
||||
jc err
|
||||
mov bx,cx
|
||||
shl cx,1
|
||||
jc err
|
||||
shl cx,1
|
||||
jc err
|
||||
add cx,bx
|
||||
jc err
|
||||
cbw
|
||||
add cx,ax
|
||||
jc err
|
||||
i3:
|
||||
inc edi
|
||||
jmp i1
|
||||
i_exit:
|
||||
mov ax,cx
|
||||
clc
|
||||
i4:
|
||||
movzx eax,ax
|
||||
pop edi
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
ret
|
||||
|
||||
err:
|
||||
stc
|
||||
jmp i4
|
||||
|
||||
partition_string: dd 0
|
||||
db 32
|
1079
kernel/branches/fs/fs_lfn.inc
Normal file
1079
kernel/branches/fs/fs_lfn.inc
Normal file
File diff suppressed because it is too large
Load Diff
757
kernel/branches/fs/iso9660.inc
Normal file
757
kernel/branches/fs/iso9660.inc
Normal file
@ -0,0 +1,757 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 983 $
|
||||
|
||||
|
||||
uglobal
|
||||
cd_current_pointer_of_input dd 0
|
||||
cd_current_pointer_of_input_2 dd 0
|
||||
cd_mem_location dd 0
|
||||
cd_counter_block dd 0
|
||||
IDE_Channel_1 db 0
|
||||
IDE_Channel_2 db 0
|
||||
endg
|
||||
|
||||
reserve_cd:
|
||||
|
||||
cli
|
||||
cmp [cd_status],0
|
||||
je reserve_ok2
|
||||
|
||||
sti
|
||||
call change_task
|
||||
jmp reserve_cd
|
||||
|
||||
reserve_ok2:
|
||||
|
||||
push eax
|
||||
mov eax,[CURRENT_TASK]
|
||||
shl eax,5
|
||||
mov eax,[eax+CURRENT_TASK+TASKDATA.pid]
|
||||
mov [cd_status],eax
|
||||
pop eax
|
||||
sti
|
||||
ret
|
||||
|
||||
reserve_cd_channel:
|
||||
cmp [ChannelNumber],1
|
||||
jne .IDE_Channel_2
|
||||
.IDE_Channel_1:
|
||||
cli
|
||||
cmp [IDE_Channel_1],0
|
||||
je .reserve_ok_1
|
||||
sti
|
||||
call change_task
|
||||
jmp .IDE_Channel_1
|
||||
.IDE_Channel_2:
|
||||
cli
|
||||
cmp [IDE_Channel_2],0
|
||||
je .reserve_ok_2
|
||||
sti
|
||||
call change_task
|
||||
jmp .IDE_Channel_1
|
||||
.reserve_ok_1:
|
||||
mov [IDE_Channel_1],1
|
||||
ret
|
||||
.reserve_ok_2:
|
||||
mov [IDE_Channel_2],1
|
||||
ret
|
||||
|
||||
free_cd_channel:
|
||||
cmp [ChannelNumber],1
|
||||
jne .IDE_Channel_2
|
||||
.IDE_Channel_1:
|
||||
mov [IDE_Channel_1],0
|
||||
ret
|
||||
.IDE_Channel_2:
|
||||
mov [IDE_Channel_2],0
|
||||
ret
|
||||
|
||||
uglobal
|
||||
cd_status dd 0
|
||||
endg
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; fs_CdRead - LFN variant for reading CD disk
|
||||
;
|
||||
; esi points to filename /dir1/dir2/.../dirn/file,0
|
||||
; ebx pointer to 64-bit number = first wanted byte, 0+
|
||||
; may be ebx=0 - start from first byte
|
||||
; ecx number of bytes to read, 0+
|
||||
; edx mem location to return data
|
||||
;
|
||||
; ret ebx = bytes read or 0xffffffff file not found
|
||||
; eax = 0 ok read or other = errormsg
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
fs_CdRead:
|
||||
push edi
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
.noaccess:
|
||||
pop edi
|
||||
.noaccess_2:
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
|
||||
.noaccess_3:
|
||||
pop eax edx ecx edi
|
||||
jmp .noaccess_2
|
||||
|
||||
@@:
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
pop edi
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_2
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
|
||||
.found:
|
||||
mov edi,[cd_current_pointer_of_input]
|
||||
test byte [edi+25],10b ; do not allow read directories
|
||||
jnz .noaccess
|
||||
test ebx, ebx
|
||||
jz .l1
|
||||
cmp dword [ebx+4], 0
|
||||
jz @f
|
||||
xor ebx, ebx
|
||||
.reteof:
|
||||
mov eax, 6 ; end of file
|
||||
pop edi
|
||||
ret
|
||||
@@:
|
||||
mov ebx, [ebx]
|
||||
.l1:
|
||||
push ecx edx
|
||||
push 0
|
||||
mov eax, [edi+10] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè
|
||||
sub eax, ebx
|
||||
jb .eof
|
||||
cmp eax, ecx
|
||||
jae @f
|
||||
mov ecx, eax
|
||||
mov byte [esp], 6
|
||||
@@:
|
||||
mov eax,[edi+2]
|
||||
mov [CDSectorAddress],eax
|
||||
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
|
||||
.new_sector:
|
||||
test ecx, ecx
|
||||
jz .done
|
||||
sub ebx, 2048
|
||||
jae .next
|
||||
add ebx, 2048
|
||||
jnz .incomplete_sector
|
||||
cmp ecx, 2048
|
||||
jb .incomplete_sector
|
||||
; we may read and memmove complete sector
|
||||
mov [CDDataBuf_pointer],edx
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_3
|
||||
add edx, 2048
|
||||
sub ecx, 2048
|
||||
.next:
|
||||
inc dword [CDSectorAddress]
|
||||
jmp .new_sector
|
||||
.incomplete_sector:
|
||||
; we must read and memmove incomplete sector
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà
|
||||
cmp [DevErrorCode],0
|
||||
jne .noaccess_3
|
||||
push ecx
|
||||
add ecx, ebx
|
||||
cmp ecx, 2048
|
||||
jbe @f
|
||||
mov ecx, 2048
|
||||
@@:
|
||||
sub ecx, ebx
|
||||
push edi esi ecx
|
||||
mov edi,edx
|
||||
lea esi, [CDDataBuf + ebx]
|
||||
cld
|
||||
rep movsb
|
||||
pop ecx esi edi
|
||||
add edx, ecx
|
||||
sub [esp], ecx
|
||||
pop ecx
|
||||
xor ebx, ebx
|
||||
jmp .next
|
||||
|
||||
.done:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx edi
|
||||
sub ebx, edx
|
||||
ret
|
||||
.eof:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx
|
||||
sub ebx, edx
|
||||
jmp .reteof
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; fs_CdReadFolder - LFN variant for reading CD disk folder
|
||||
;
|
||||
; esi points to filename /dir1/dir2/.../dirn/file,0
|
||||
; ebx pointer to structure 32-bit number = first wanted block, 0+
|
||||
; & flags (bitfields)
|
||||
; flags: bit 0: 0=ANSI names, 1=UNICODE names
|
||||
; ecx number of blocks to read, 0+
|
||||
; edx mem location to return data
|
||||
;
|
||||
; ret ebx = blocks read or 0xffffffff folder not found
|
||||
; eax = 0 ok read or other = errormsg
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
fs_CdReadFolder:
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
pop edi
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_1
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
.found:
|
||||
mov edi, [cd_current_pointer_of_input]
|
||||
test byte [edi+25], 10b ; do not allow read directories
|
||||
jnz .found_dir
|
||||
pop edi
|
||||
.noaccess_1:
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
.found_dir:
|
||||
mov eax, [edi+2] ; eax=cluster
|
||||
mov [CDSectorAddress], eax
|
||||
mov eax, [edi+10] ; ðàçìåð äèðåêòðîðèè
|
||||
.doit:
|
||||
; init header
|
||||
push eax ecx
|
||||
mov edi, edx
|
||||
mov ecx, 32/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop ecx eax
|
||||
mov byte [edx], 1 ; version
|
||||
mov [cd_mem_location], edx
|
||||
add [cd_mem_location], 32
|
||||
; íà÷èíàåì ïåðåáðîñêó ÁÄÂÊ â ÓÑÂÊ
|
||||
;.mainloop:
|
||||
mov [cd_counter_block], dword 0
|
||||
dec dword [CDSectorAddress]
|
||||
push ecx
|
||||
.read_to_buffer:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer], CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_1
|
||||
call .get_names_from_buffer
|
||||
sub eax,2048
|
||||
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
||||
ja .read_to_buffer
|
||||
mov edi, [cd_counter_block]
|
||||
mov [edx+8], edi
|
||||
mov edi, [ebx]
|
||||
sub [edx+4], edi
|
||||
xor eax, eax
|
||||
dec ecx
|
||||
js @f
|
||||
mov al, ERROR_END_OF_FILE
|
||||
@@:
|
||||
pop ecx edi
|
||||
mov ebx, [edx+4]
|
||||
ret
|
||||
|
||||
.get_names_from_buffer:
|
||||
mov [cd_current_pointer_of_input_2],CDDataBuf
|
||||
push eax esi edi edx
|
||||
.get_names_from_buffer_1:
|
||||
call cd_get_name
|
||||
jc .end_buffer
|
||||
inc dword [cd_counter_block]
|
||||
mov eax,[cd_counter_block]
|
||||
cmp [ebx],eax
|
||||
jae .get_names_from_buffer_1
|
||||
test ecx, ecx
|
||||
jz .get_names_from_buffer_1
|
||||
mov edi,[cd_counter_block]
|
||||
mov [edx+4],edi
|
||||
dec ecx
|
||||
mov esi,ebp
|
||||
mov edi,[cd_mem_location]
|
||||
add edi,40
|
||||
test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE
|
||||
jnz .unicode
|
||||
; jmp .unicode
|
||||
.ansi:
|
||||
cmp [cd_counter_block],2
|
||||
jbe .ansi_parent_directory
|
||||
cld
|
||||
lodsw
|
||||
xchg ah,al
|
||||
call uni2ansi_char
|
||||
cld
|
||||
stosb
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
mov ax,[esi]
|
||||
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .cd_get_parameters_of_file_1
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp esi,eax
|
||||
je .cd_get_parameters_of_file_1
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
cmp esi,eax
|
||||
jb .ansi
|
||||
.cd_get_parameters_of_file_1:
|
||||
mov [edi],byte 0
|
||||
call cd_get_parameters_of_file
|
||||
add [cd_mem_location],304
|
||||
jmp .get_names_from_buffer_1
|
||||
|
||||
.ansi_parent_directory:
|
||||
cmp [cd_counter_block],2
|
||||
je @f
|
||||
mov [edi],byte '.'
|
||||
inc edi
|
||||
jmp .cd_get_parameters_of_file_1
|
||||
@@:
|
||||
mov [edi],word '..'
|
||||
add edi,2
|
||||
jmp .cd_get_parameters_of_file_1
|
||||
|
||||
.unicode:
|
||||
cmp [cd_counter_block],2
|
||||
jbe .unicode_parent_directory
|
||||
cld
|
||||
movsw
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
mov ax,[esi]
|
||||
cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .cd_get_parameters_of_file_2
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp esi,eax
|
||||
je .cd_get_parameters_of_file_2
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
cmp esi,eax
|
||||
jb .unicode
|
||||
.cd_get_parameters_of_file_2:
|
||||
mov [edi],word 0
|
||||
call cd_get_parameters_of_file
|
||||
add [cd_mem_location],560
|
||||
jmp .get_names_from_buffer_1
|
||||
|
||||
.unicode_parent_directory:
|
||||
cmp [cd_counter_block],2
|
||||
je @f
|
||||
mov [edi],word 2E00h ; '.'
|
||||
add edi,2
|
||||
jmp .cd_get_parameters_of_file_2
|
||||
@@:
|
||||
mov [edi],dword 2E002E00h ; '..'
|
||||
add edi,4
|
||||
jmp .cd_get_parameters_of_file_2
|
||||
|
||||
.end_buffer:
|
||||
pop edx edi esi eax
|
||||
ret
|
||||
|
||||
cd_get_parameters_of_file:
|
||||
mov edi,[cd_mem_location]
|
||||
cd_get_parameters_of_file_1:
|
||||
; ïîëó÷àåì àòðèáóòû ôàéëà
|
||||
xor eax,eax
|
||||
; ôàéë íå àðõèâèðîâàëñÿ
|
||||
inc eax
|
||||
shl eax,1
|
||||
; ýòî êàòàëîã?
|
||||
test [ebp-8],byte 2
|
||||
jz .file
|
||||
inc eax
|
||||
.file:
|
||||
; ìåòêà òîìà íå êàê â FAT, â ýòîì âèäå îòñóòñâóåò
|
||||
; ôàéë íå ÿâëÿåòñÿ ñèñòåìíûì
|
||||
shl eax,3
|
||||
; ôàéë ÿâëÿåòñÿ ñêðûòûì? (àòðèáóò ñóùåñòâîâàíèå)
|
||||
test [ebp-8],byte 1
|
||||
jz .hidden
|
||||
inc eax
|
||||
.hidden:
|
||||
shl eax,1
|
||||
; ôàéë âñåãäà òîëüêî äëÿ ÷òåíèÿ, òàê êàê ýòî CD
|
||||
inc eax
|
||||
mov [edi],eax
|
||||
; ïîëó÷àåì âðåìÿ äëÿ ôàéëà
|
||||
;÷àñ
|
||||
movzx eax,byte [ebp-12]
|
||||
shl eax,8
|
||||
;ìèíóòà
|
||||
mov al,[ebp-11]
|
||||
shl eax,8
|
||||
;ñåêóíäà
|
||||
mov al,[ebp-10]
|
||||
;âðåìÿ ñîçäàíèÿ ôàéëà
|
||||
mov [edi+8],eax
|
||||
;âðåìÿ ïîñëåäíåãî äîñòóïà
|
||||
mov [edi+16],eax
|
||||
;âðåìÿ ïîñëåäíåé çàïèñè
|
||||
mov [edi+24],eax
|
||||
; ïîëó÷àåì äàòó äëÿ ôàéëà
|
||||
;ãîä
|
||||
movzx eax,byte [ebp-15]
|
||||
add eax,1900
|
||||
shl eax,8
|
||||
;ìåñÿö
|
||||
mov al,[ebp-14]
|
||||
shl eax,8
|
||||
;äåíü
|
||||
mov al,[ebp-13]
|
||||
;äàòà ñîçäàíèÿ ôàéëà
|
||||
mov [edi+12],eax
|
||||
;âðåìÿ ïîñëåäíåãî äîñòóïà
|
||||
mov [edi+20],eax
|
||||
;âðåìÿ ïîñëåäíåé çàïèñè
|
||||
mov [edi+28],eax
|
||||
; ïîëó÷àåì òèï äàííûõ èìåíè
|
||||
xor eax,eax
|
||||
test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE
|
||||
jnz .unicode_1
|
||||
mov [edi+4],eax
|
||||
jmp @f
|
||||
.unicode_1:
|
||||
inc eax
|
||||
mov [edi+4],eax
|
||||
@@:
|
||||
; ïîëó÷àåì ðàçìåð ôàéëà â áàéòàõ
|
||||
xor eax,eax
|
||||
mov [edi+32+4],eax
|
||||
mov eax,[ebp-23]
|
||||
mov [edi+32],eax
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; fs_CdGetFileInfo - LFN variant for CD
|
||||
; get file/directory attributes structure
|
||||
;
|
||||
;----------------------------------------------------------------
|
||||
fs_CdGetFileInfo:
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
mov eax, 2
|
||||
ret
|
||||
@@:
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
pushfd
|
||||
cmp [DevErrorCode], 0
|
||||
jz @f
|
||||
popfd
|
||||
pop edi
|
||||
mov eax, 11
|
||||
ret
|
||||
@@:
|
||||
popfd
|
||||
jnc @f
|
||||
pop edi
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
@@:
|
||||
|
||||
mov edi, edx
|
||||
push ebp
|
||||
mov ebp, [cd_current_pointer_of_input]
|
||||
add ebp, 33
|
||||
call cd_get_parameters_of_file_1
|
||||
pop ebp
|
||||
and dword [edi+4], 0
|
||||
pop edi
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------
|
||||
cd_find_lfn:
|
||||
mov [cd_appl_data],0
|
||||
; in: esi+ebp -> name
|
||||
; out: CF=1 - file not found
|
||||
; else CF=0 and [cd_current_pointer_of_input] direntry
|
||||
push eax esi
|
||||
; 16 ñåêòîð íà÷àëî íàáîðà äåñêðèïòîðîâ òîìîâ
|
||||
|
||||
call WaitUnitReady
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
|
||||
call prevent_medium_removal
|
||||
; òåñòîâîå ÷òåíèå
|
||||
mov [CDSectorAddress],dword 16
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ;_1
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
|
||||
; âû÷èñëåíèå ïîñëåäíåé ñåññèè
|
||||
call WaitUnitReady
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
call Read_TOC
|
||||
mov ah,[CDDataBuf+4+4]
|
||||
mov al,[CDDataBuf+4+5]
|
||||
shl eax,16
|
||||
mov ah,[CDDataBuf+4+6]
|
||||
mov al,[CDDataBuf+4+7]
|
||||
add eax,15
|
||||
mov [CDSectorAddress],eax
|
||||
; mov [CDSectorAddress],dword 15
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
|
||||
.start:
|
||||
inc dword [CDSectorAddress]
|
||||
call ReadCDWRetr ;_1
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
|
||||
.start_check:
|
||||
; ïðîâåðêà íà âøèâîñòü
|
||||
cmp [CDDataBuf+1],dword 'CD00'
|
||||
jne .access_denied
|
||||
cmp [CDDataBuf+5],byte '1'
|
||||
jne .access_denied
|
||||
; ñåêòîð ÿâëÿåòñÿ òåðìèíàòîðîì íàáîð äåñêðèïòîðîâ òîìîâ?
|
||||
cmp [CDDataBuf],byte 0xff
|
||||
je .access_denied
|
||||
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì è óëó÷øåííûì äåñêðèïòîðîì òîìà?
|
||||
cmp [CDDataBuf],byte 0x2
|
||||
jne .start
|
||||
; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì äåñêðèïòîðîì òîìà?
|
||||
cmp [CDDataBuf+6],byte 0x1
|
||||
jne .start
|
||||
|
||||
; ïàðàìåòðû root äèðåêòðîðèè
|
||||
mov eax,[CDDataBuf+0x9c+2] ; íà÷àëî root äèðåêòðîðèè
|
||||
mov [CDSectorAddress],eax
|
||||
mov eax,[CDDataBuf+0x9c+10] ; ðàçìåð root äèðåêòðîðèè
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
mov [cd_current_pointer_of_input],CDDataBuf+0x9c
|
||||
jmp .done
|
||||
@@:
|
||||
; íà÷èíàåì ïîèñê
|
||||
.mainloop:
|
||||
dec dword [CDSectorAddress]
|
||||
.read_to_buffer:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer],CDDataBuf
|
||||
call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè
|
||||
cmp [DevErrorCode],0
|
||||
jne .access_denied
|
||||
push ebp
|
||||
call cd_find_name_in_buffer
|
||||
pop ebp
|
||||
jnc .found
|
||||
sub eax,2048
|
||||
; äèðåêòîðèÿ çàêîí÷èëàñü?
|
||||
cmp eax,0
|
||||
ja .read_to_buffer
|
||||
; íåò èñêîìîãî ýëåìåíòà öåïî÷êè
|
||||
.access_denied:
|
||||
pop esi eax
|
||||
mov [cd_appl_data],1
|
||||
stc
|
||||
ret
|
||||
; èñêîìûé ýëåìåíò öåïî÷êè íàéäåí
|
||||
.found:
|
||||
; êîíåö ïóòè ôàéëà
|
||||
cmp byte [esi-1], 0
|
||||
jz .done
|
||||
.nested:
|
||||
mov eax,[cd_current_pointer_of_input]
|
||||
push dword [eax+2]
|
||||
pop dword [CDSectorAddress] ; íà÷àëî äèðåêòîðèè
|
||||
mov eax,[eax+2+8] ; ðàçìåð äèðåêòîðèè
|
||||
jmp .mainloop
|
||||
; óêàçàòåëü ôàéëà íàéäåí
|
||||
.done:
|
||||
test ebp, ebp
|
||||
jz @f
|
||||
mov esi, ebp
|
||||
xor ebp, ebp
|
||||
jmp .nested
|
||||
@@:
|
||||
pop esi eax
|
||||
mov [cd_appl_data],1
|
||||
clc
|
||||
ret
|
||||
|
||||
cd_find_name_in_buffer:
|
||||
mov [cd_current_pointer_of_input_2],CDDataBuf
|
||||
.start:
|
||||
call cd_get_name
|
||||
jc .not_found
|
||||
call cd_compare_name
|
||||
jc .start
|
||||
.found:
|
||||
clc
|
||||
ret
|
||||
.not_found:
|
||||
stc
|
||||
ret
|
||||
|
||||
cd_get_name:
|
||||
push eax
|
||||
mov ebp,[cd_current_pointer_of_input_2]
|
||||
mov [cd_current_pointer_of_input],ebp
|
||||
mov eax,[ebp]
|
||||
cmp eax,0 ; âõîäû çàêîí÷èëèñü?
|
||||
je .next_sector
|
||||
cmp ebp,CDDataBuf+2048 ; áóôåð çàêîí÷èëñÿ?
|
||||
jae .next_sector
|
||||
movzx eax, byte [ebp]
|
||||
add [cd_current_pointer_of_input_2],eax ; ñëåäóþùèé âõîä êàòàëîãà
|
||||
add ebp,33 ; óêàçàòåëü óñòàíîâëåí íà íà÷àëî èìåíè
|
||||
pop eax
|
||||
clc
|
||||
ret
|
||||
.next_sector:
|
||||
pop eax
|
||||
stc
|
||||
ret
|
||||
|
||||
cd_compare_name:
|
||||
; compares ASCIIZ-names, case-insensitive (cp866 encoding)
|
||||
; in: esi->name, ebp->name
|
||||
; out: if names match: ZF=1 and esi->next component of name
|
||||
; else: ZF=0, esi is not changed
|
||||
; destroys eax
|
||||
push esi eax edi
|
||||
mov edi,ebp
|
||||
.loop:
|
||||
cld
|
||||
lodsb
|
||||
push eax
|
||||
call char_todown
|
||||
call ansi2uni_char
|
||||
xchg ah,al
|
||||
scasw
|
||||
pop eax
|
||||
je .coincides
|
||||
call char_toupper
|
||||
call ansi2uni_char
|
||||
xchg ah,al
|
||||
sub edi,2
|
||||
scasw
|
||||
jne .name_not_coincide
|
||||
.coincides:
|
||||
cmp [esi],byte '/' ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||
je .done
|
||||
cmp [esi],byte 0 ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà
|
||||
je .done
|
||||
jmp .loop
|
||||
.name_not_coincide:
|
||||
pop edi eax esi
|
||||
stc
|
||||
ret
|
||||
.done:
|
||||
; ïðîâåðêà êîíöà ôàéëà
|
||||
cmp [edi],word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';'
|
||||
je .done_1
|
||||
; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì
|
||||
movzx eax,byte [ebp-33]
|
||||
add eax,ebp
|
||||
sub eax,34
|
||||
cmp edi,eax
|
||||
je .done_1
|
||||
; ïðîâåðêà êîíöà ïàïêè
|
||||
movzx eax,byte [ebp-1]
|
||||
add eax,ebp
|
||||
cmp edi,eax
|
||||
jne .name_not_coincide
|
||||
.done_1:
|
||||
pop edi eax
|
||||
add esp,4
|
||||
inc esi
|
||||
clc
|
||||
ret
|
||||
|
||||
char_todown:
|
||||
; convert character to uppercase, using cp866 encoding
|
||||
; in: al=symbol
|
||||
; out: al=converted symbol
|
||||
cmp al, 'A'
|
||||
jb .ret
|
||||
cmp al, 'Z'
|
||||
jbe .az
|
||||
cmp al, '€'
|
||||
jb .ret
|
||||
cmp al, '<27>'
|
||||
jb .rus1
|
||||
cmp al, 'Ÿ'
|
||||
ja .ret
|
||||
; 0x90-0x9F -> 0xE0-0xEF
|
||||
add al, 'à'-'<27>'
|
||||
.ret:
|
||||
ret
|
||||
.rus1:
|
||||
; 0x80-0x8F -> 0xA0-0xAF
|
||||
.az:
|
||||
add al, 0x20
|
||||
ret
|
||||
|
||||
uni2ansi_char:
|
||||
; convert UNICODE character in al to ANSI character in ax, using cp866 encoding
|
||||
; in: ax=UNICODE character
|
||||
; out: al=converted ANSI character
|
||||
cmp ax, 0x80
|
||||
jb .ascii
|
||||
cmp ax, 0x401
|
||||
jz .yo1
|
||||
cmp ax, 0x451
|
||||
jz .yo2
|
||||
cmp ax, 0x410
|
||||
jb .unk
|
||||
cmp ax, 0x440
|
||||
jb .rus1
|
||||
cmp ax, 0x450
|
||||
jb .rus2
|
||||
.unk:
|
||||
mov al, '_'
|
||||
jmp .doit
|
||||
.yo1:
|
||||
mov al, 'ð'
|
||||
jmp .doit
|
||||
.yo2:
|
||||
mov al, 'ñ'
|
||||
jmp .doit
|
||||
.rus1:
|
||||
; 0x410-0x43F -> 0x80-0xAF
|
||||
add al, 0x70
|
||||
jmp .doit
|
||||
.rus2:
|
||||
; 0x440-0x44F -> 0xE0-0xEF
|
||||
add al, 0xA0
|
||||
.ascii:
|
||||
.doit:
|
||||
ret
|
1815
kernel/branches/fs/ntfs.inc
Normal file
1815
kernel/branches/fs/ntfs.inc
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user