Initial revision

svn path=/trunk/; revision=2
This commit is contained in:
The ReactOS Manager 1996-01-23 01:02:17 +00:00
commit 0f94427db0
111 changed files with 43361 additions and 0 deletions

1
reactos/boot.bat Normal file
View file

@ -0,0 +1 @@
loaders\dos\loadros kernel\kimage.bin %1 %2 %3 %4

340
reactos/copying_rex Normal file
View file

@ -0,0 +1,340 @@
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.

140
reactos/doc/api.txt Normal file
View file

@ -0,0 +1,140 @@
This file attempts to document the functions made publically available by
the various subsystems.
* Formatted I/O operations *
NAME: int vsprintf(char *buf, const char *fmt, va_list args)
NAME: int sprintf(char* buf, const char* fmt, ...)
WHERE: internal/kernel.h
FUNCTION: The same as the standard c library versions
* PIO operations *
NAME: in[b/w/l](port)
WHERE: internal/io.h
FUNCTION: Read an IO port of the specified size (byte/word or long)
RETURNS: The value read
NAME: out[b/w/l](port,val)
WHERE: internal/io.h
FUNCTION: Write an IO port of the specified size (byte/word or long)
NAME: in_p[b/w/l](port)
WHERE: internal/io.h
FUNCTION: Read an IO port of the specified size (byte/word or long) with
a pause
RETURNS: The value read
NAME: out_p[b/w/l](port,val)
WHERE: internal/io.h
FUNCTION: Write an IO port of the specified size (byte/word or long) with
a pause
* Bit operations *
NAME: int set_bit(int nr, void* addr)
NAME: int clear_bit(int nr, void* addr)
NAME: int change_bit(int nr, void* addr)
WHERE: internal/bitops.h>
FUNCTION: Operate on a bit in the word pointed to by addr
RETURN: 0 if the bit was cleared before the operations
non-zero otherwise
* Debugging functions *
NAME: DPRINT(fmt,....)
WHERE: internal/debug.h
FUNCTION: Outputs a string to the console if NDEBUG isn't defined before
including internal/debug.h, a NOP otherwise
ARGUMENTS: The same as printf
NAME: printk
WHERE: internal/kernel.h
FUNCTION: Outputs a string to the console
ARGUMENTS: The same as printf
* Memory managment functions *
NAME: unsigned int physical_to_linear(unsigned int paddr)
WHERE: hal/page.h
FUNCTION: Converts a physical address to a linear one
RECEIVES:
paddr = the physical address to convert
RETURNS: A virtual address where the memory at that physical address can be
accessed
NAME: void* ExAllocatePool(unsigned int size, unsigned int type = 0);
WHERE: internal/pool.h
FUNCTION: Allocates a block of memory
RECEIVES:
size = the size of the block to allocate
type = will be whether to allocate pagable memory
RETURNS: The address of the block
NOTE: This isn't interrupt safe
NAME: void ExFreePool(void* block)
WHERE: internal/pool.h
FUNCTION: Frees a block of memory
NAME: void free_page(unsigned int physical_base, unsigned int nr = 1)
WHERE: internal/mm.h
FUNCTION: Adds a continuous range of physical memory to the free list
NAME: unsigned int get_free_page(void)
WHERE: internal/mm.h
FUNCTION: Gets a free page
RETURNS: Its physical address
NAME: unsigned int get_page_physical_address(unsigned int vaddr)
WHERE: internal/mm.h
FUNCTION: Gets the physical address of a page
NAME: void mark_page_not_writable(unsigned int vaddr)
WHERE: internal/mm.h
FUNCTION: Prevent writing the page
* DMA functions *
NAME: unsigned int get_dma_page(unsigned int max_address)
WHERE: internal/mm.h
FUNCTION: Gets a page with a restricted physical address i.e. suitable for
dma
RETURNS: The physical address of the page
NAME: void disable_dma(unsigned int dmanr)
WHERE: internal/dma.h
FUNCTION: Disables the specified dma channel
NAME: void enable_dma(unsigned int dmanr)
WHERE: internal/dma.h
FUNCTION: Enables the specified dma channel
NAME: void clear_dma_ff(unsigned int dmanr)
WHERE: internal/dma.h
FUNCTION: Clear the dma flip-flop
NAME: void set_dma_mode(unsigned int dmanr, char mode)
WHERE: internal/dma.h
FUNCTION: Sets the type of dma transfer
NAME: void set_dma_page(unsigned int dmanr, char pagenr)
WHERE: internal/dma.h
FUNCTION: Set only the page register bits of the transfer address
NAME: void set_dma_addr(unsigned int dmanr, unsigned int a)
WHERE: internal/dma.h
FUNCTION: Set the transfer address for dma
NOTE: Assumes flip-flop is clear
NAME: void set_dma_count(unsigned int dmanr, unsigned int count)
WHERE: internal/dma.h
FUNCTION: Sets the size of the transfer
ARGUMENTS:
count = the number of bytes to transfer
NOTE: Count must be even for channels 5-7
NAME: int get_dma_residue(unsigned int dmanr)
WHERE: internal/dma.h
FUNCTION: Gets the residue remaining after a dma transfer on the channel

2
reactos/doc/buglist Normal file
View file

@ -0,0 +1,2 @@
* Kernel bugs not fixed

114
reactos/doc/faq.txt Normal file
View file

@ -0,0 +1,114 @@
Kernel Development FAQ (for v0.0.7)
This attempts to answer some of the common questions people developing for
the kernel might want to ask (or at least what I think they should ask).
Obviously I can only detail those parts which I have written so other
developers please fill in the gaps.
Q: What is this, what are you people, what's going on
A: This is the ReactOS, an operating system intended as a clone of windows
NT. See the project website (http://www.sid-dis.com/reactos/) for more details.
Q: Why ReactOS
A: To condemn Bill Gates to penury.
Q: What do I need to compile the kernel
A: DJGPP, get it from http://www.delorie.com/djgpp
Q: How do I compile the kernel
A: Unpack the zip. It is important not to install the kernel in the same
directory as a previous version, this has caused a bit of confusion in the
past. Edit the makefile in the top level directory, in particular select the
correct host to build from. Then run make in the top directory
Q: What files are created when I make the kernel
A: The following files are created in the kernel directory
kimage = the kernel as a coff executable
kimage.bin = the kernel as a raw binary image
kernel.sym = a list of the kernel symbols
Q: How do I load the kernel
A: Run the boot.bat batch file.
Q: Does it boot from disk
A: Not at the moment.
Q: When I run the kernel it crashes
A: The kernel (at the moment) can only be loaded from a clean system. That
is one without EMM386 or any version of windows loaded. A quick way to
ensure this (if you have windows 95) is to set the program to run in msdos
mode and specify an empty config.sys and autoexec.bat. See the windows help
for more information.
If you do that and the problem persists then contact the kernel team
(ros-kernel@sid-dis.com) as it is probably a bug in the kernel
Q6: How do I load a module with the kernel
A: Add the names of any modules to be loaded to the command line of boot.bat.
Q7: I want to add code to the kernel, how do I get it to be compiled
A: You will need to edit the Makefile in kernel directory. There should be
a statement like this
OBJECTS = hal/head.o hal/exp.o kernel/vsprintf.o \
....
kernel/irqhand.o hal/page.o mm/virtual.o kernel/error.o \
kernel/exports.o kernel/module.o
Add the name of the object file (the file produced when your code is
compiled) to the end of the statement (in this case after kernel/module.o).
If you need to go onto a new line then add a slash to the end of the
previous line. It is also very important to use an editor which preserves
tabs.
Q8: I want to add code to the kernel, how do I make it official
A: Contact the kernel mailing list ros-kernel@sid-dis.com or our coordinator
dwinkley@whitworth.edu. If it is for a specific section then the kernel
website (http://www.geocities.com/SiliconValley/Peaks/1957) has a list of
those working on individual areas, you might what to contact one of them
instead.
Q9: What header files should I use
A: Don't include the usual DJGPP headers like stdio.h unless you are using
something compiler based like stdargs.h. To use the DJGPP headers requires
linking with libc which is useless in kernel mode.
All the header files are in the top-level include directory which is laid
out like this
include = general win32 api declarations
include/internal = private kernel headers
include/internal/hal = HAL headers
include/ddk = header files with declarations for modules
There should be a file called api.txt which documents all of the functions
(and which header files they need).
Q11: I want to export my function for modules to use, how do I do that
A: Add the function to the list in kernel/exports.lst, then remake the
kernel. Note the function must be declared as extern "C".
Q12: I want to make my functions part of the kernel interface to user mode,
A: That section isn't finished yet, though it will probably mean adding a
pointer to the function and the size of its parameters to a internal table
somewhere.
Q14: I want to write a module, what are the guidelines
A: See modules.txt in this directory
Q15: I want to write an ISR (interrupt service routine)
A: See irq.txt in this directory
Q16: I want to use DMA
A: Firstly this answer covers only DMA via the dma chips *not*
busmaster DMA.
To program the dma chip use the functions in internal/dma.h (look in api.txt
for details). PC DMA can only go to memory with a physical address below
1mb (or 16mb on some systems), use the get_dma_page to allocate this kind
of memory.
Q17: You haven't answered my question
A: Send your questions to ros-kernel@sid-dis.com
- David Welch (welch@mcmail.com)

View file

@ -0,0 +1,10 @@
This document describes the implementation of the memory managment
* ReactOS memory map
0x00000000 - 0xc0000000 = User memory
0xc0000000 - 0xd0000000 = Kernel memory
0xd0000000 - 0xffffffff = Identify map of physical memory
*

1253
reactos/doc/internal/pe.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,2 @@
This contains documentation describing the internals of the various kernel
subsystems and a few other useful bits of information.

135
reactos/doc/irq.txt Normal file
View file

@ -0,0 +1,135 @@
** Introduction
This attempts to document the ReactOS irq handling. As of v0.0.8 this has
changed to be more nt like, I will attempt to summarize the new
implementation for those unavailable with nt device driver writing. Note,
ReactOS doesn't have an exact implementation but the omissions are, except
where noted, not user visible.
** Steps in grabbing an irq vector
* Call HalConnectInterrupt
PROTOTYPE:
ULONG HalGetInterruptVector(INTERFACE_TYPE InterfaceType,
ULONG BusNumber,
ULONG BusInterruptLevel,
ULONG BusInterruptVector,
OUT PKIRQL Irql,
OUT PKAFFINITY Affinity)
PURPOSE:
Translates a bus dependant interrupt vector to a system vector
ARGUMENTS:
InterfaceType = Type of bus to which the device to receive interrupts
from is connected to. Currently only 'Internal' is
recognized
BusNumber = Number of the bus the device is connected to
(currently ignored)
BusInterruptLevel = Bus specific interrupt level (currently ignored)
BusInterruptVector = Bus specific vector. Currently this is the same
as the normal vector (09 is the keyboard vector
for example)
Irql = On return contains the DIRQL for the vector
Affinity = On return contains the affinity mask for the vector
(currently unimplemented)
RETURNS:
The system mapped vector
* Call IoConnectInterrupt
PROTOTYPE:
NTSTATUS IoConnectInterrupt(OUT PKINTERRUPT* InterruptObject,
PKSERVICE_ROUTINE ServiceRoutine,
PVOID ServiceContext,
PKSPIN_LOCK SpinLock,
ULONG Vector,
KIRQL Irql,
KIRQL SynchronizeIrql,
KINTERRUPT_MODE InterruptMode,
BOOLEAN ShareVector,
KAFFINITY ProcessorEnableMask,
BOOLEAN FloatingSave)
PURPOSE:
Connect a service routine to an interrupt vector
ARGUMENTS:
InterruptObject = Points to an object describes the interrupt on
return
ServiceRoutine = Function to be called when the device interrupts
ServiceContext = Parameters to be passed to the service routine
SpinLock = Should be NULL
Vector = System mapped vector returned from HalGetInterruptVector
Irql = DIRQL returned from HalGetInterruptVector
SynchronizeIrql = Should be the same as Irql
InterruptMode = Device interrupt type (currently ignored)
ShareVector = True if the interrupt vector can shared
ProcessorEnableMask = Currently ignored
FloatingSave = Should be false
RETURNS: Status
* Sample code for snarfing an interrupt vector
void grab_my_irq()
{
ULONG MappedIrq;
KIRQL Dirql;
KAFFINITY Affinity;
PKINTERRUPT IrqObject;
MappedIrq = HalGetInterruptVector(Internal,
0,
0,
MY_VECTOR,
&Dirql,
&Affinity);
IoConnectInterrupt(&IrqObject,
my_irq_service_routine,
my_context,
NULL,
MappedIrq,
Dirql,
Dirql,
0,
FALSE, // Not sharable
Affinity,
FALSE);
}
** Designing an interrupt service routine
An interrupt service routine should have the following prototype
BOOLEAN my_irq_service_routine(PKINTERRUPT Interrupt,
PVOID ServiceContext);
ARGUMENTS:
Interrupt = The same as the object returned from the
IoConnectInterrupt
ServiceContext = A user defined parameters
(passed to IoConnectInterrupt)
RETURNS:
True if it handled the interrupt, false if it should be passed onto
other devices sharing the same vector
NOTES:
While an isr is executing all devices of a lower or equal priority
can't interrupt. For this reason it is important that an isr
should complete in a short an interval as possible. The set of
routines an isr can call is also restricted.

21
reactos/doc/irql.txt Normal file
View file

@ -0,0 +1,21 @@
This document describes the state of a uniprocessor PC at each of the IRQ
levels supported by the ReactOS kernel
PASSIVE_LEVEL: IF bit clear in the processor flags
All irqs umasked at the PIC
APC_LEVEL: Unknown
WAKE_LEVEL: Unknown
DISPATCH_LEVEL: IF bit clear in the processor flags
All irqs umasked at the PIC
Thread dispatching disabled
DIRQL (Device specific IRQ level):
IF bit clear in the processor flags
Device's irq and all lower priority irqs masked at the PIC
Thread dispatching disabled
HIGH_LEVEL: IF bit set in the processor flags
All irqs masked at the PIC
Thread dispatching disabled

33
reactos/doc/modules.txt Normal file
View file

@ -0,0 +1,33 @@
** Introduction
This is (an incomplete) guide to writing device drivers (and other kernel
extensions) for ReactOS.
** Setting up the build environment
Create a new subdirectory in the modules directory and copy one of the
existing module makefiles into it. Customize the makefile to compile the
source files for the module. Note: generally it is not necessary to specify
the compiler or compiler flags to use.
** Initializing a module
On loading the kernel will call the module function
PROTOTYPE:
NTSTATUS ModuleEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
PURPOSE:
Initializing the module
ARGUMENTS:
DriverObject = Pointer to an object describing the driver
RegistryPath = Currently NULL
RETURNS:
STATUS_SUCCESS = If the module initialized successfully

31
reactos/doc/todo Normal file
View file

@ -0,0 +1,31 @@
* Kernel things implemented [exceptions in brackets]
Spinlocks [Uniprocessor only]
IRQ levels [Not APC_LEVEL or WAKE_LEVEL, uniprocessor only]
ISRs [Partial, uniprocessor only]
Timers [Untested]
DPCs [Untested]
Objects [Partial]
Namespace [Partial]
Handle tables [One process only]
Threads [Some initial work]
RTL list functions [All except sequenced lists]
Zones [Untested]
Memory pool [Working but semantics partially incompatiable]
Device objects [Some but no support for layering]
IRP [Partial]
Memory sections [Partial, no file mappings]
PCI interface [Probes but no support]
CreateFile API [Device only]
ReadFile/WriteFile API [Device only]
MDL functions [Untested]
* Kernel things unimplemented (partial)
Add support for source level debugging to Bochs
Support for remote debugging
Process managment
Dispatcher objects (Mutex, Semaphore etc)
Investigate user and kernel mode APCs
Asynchronous I/O
Optimization

16
reactos/doc/wstring.txt Normal file
View file

@ -0,0 +1,16 @@
subject wstring.zip
author Boudewijn Dekker
date 06-06-98
I wrote some inline wide character string functions. It are modified version
of the ones in string.h. I added four more function nl stricmp, strnicmp,
wcsicmp, and wcsnicmp. These are the case insensitive variants of
strcmp, strncmp and wcscmp, wcsncmp. I tested all the functions but I
would urge anyone to tested again. I removed an extern specifier
__wcstok and strtok cause I it caused an compilation error when
using strtok or wcstok. Please could someone see if this correct.
I also used these string functions in lstring api functions.
Boudewijn Dekker

2979
reactos/include/ascii.h Normal file

File diff suppressed because it is too large Load diff

572
reactos/include/base.h Normal file
View file

@ -0,0 +1,572 @@
/*
Base.h
Base definitions
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
This file is part of the Windows32 API Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
If you are interested in a warranty or support for this source code,
contact Scott Christley <scottc@net-community.com> for more information.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNU_H_WINDOWS32_BASE
#define _GNU_H_WINDOWS32_BASE
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef NULL
#ifdef __cplusplus
#define NULL (0)
#else
#define NULL ((void *)0)
#endif
#endif /* !NULL */
#define FALSE 0
#define TRUE 1
#ifndef RC_INVOKED
/* typedef ACMDRIVERENUMCB;
typedef ACMDRIVERPROC;
typedef ACMFILERCHOOSEHOOKPROC;
typedef ACMFILTERENUMCB;
typedef ACMFILTERTAGENUMCB;
typedef ACMFORMATCHOOSEHOOKPROC;
typedef ACMFORMATENUMCB;
typedef ACMFORMATTAGENUMCB;
typedef APPLET_PROC;
*/
typedef unsigned short ATOM;
/* Changed from BOOL to WINBOOL to avoid Objective-C conflict */
typedef int WINBOOL;
typedef unsigned char BOOLEAN;
typedef unsigned char BYTE;
typedef unsigned long CALTYPE;
typedef unsigned long CALID;
typedef char CCHAR;
typedef unsigned long COLORREF;
#define CONST const
/* Check VOID before defining CHAR, SHORT, and LONG */
#ifndef VOID
#define VOID void
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
#endif
/*
typedef CTRYID;
typedef DLGPROC;
*/
typedef unsigned int DWORD; /* was unsigned long */
typedef double DWORDLONG, *PDWORDLONG;
/*
typedef EDITWORDBREAKPROC;
typedef ENHMFENUMPROC;
typedef ENUMRESLANGPROC;
typedef ENUMRESNAMEPROC;
typedef ENUMRESTYPEPROC;
*/
typedef float FLOAT;
/* typedef GLOBALHANDLE; */
typedef void *HANDLE;
typedef HANDLE HACCEL;
typedef HANDLE HBITMAP;
typedef HANDLE HBRUSH;
typedef HANDLE HCOLORSPACE;
typedef HANDLE HCONV;
typedef HANDLE HCONVLIST;
typedef HANDLE HCURSOR;
typedef HANDLE HDBC;
typedef HANDLE HDC;
typedef HANDLE HDDEDATA;
typedef HANDLE HDESK;
typedef HANDLE HDROP;
typedef HANDLE HDWP;
typedef HANDLE HENHMETAFILE;
typedef HANDLE HENV;
typedef int HFILE;
typedef HANDLE HFONT;
typedef HANDLE HGDIOBJ;
typedef HANDLE HGLOBAL;
typedef HANDLE HGLRC;
typedef HANDLE HHOOK;
typedef HANDLE HICON;
typedef HANDLE HIMAGELIST;
typedef HANDLE HINSTANCE;
typedef HANDLE HKEY, *PHKEY;
typedef HANDLE HKL;
typedef HANDLE HLOCAL;
typedef HANDLE HMENU;
typedef HANDLE HMETAFILE;
typedef HANDLE HMODULE;
typedef HANDLE HPALETTE;
typedef HANDLE HPEN;
typedef HANDLE HRASCONN;
typedef long HRESULT;
typedef HANDLE HRGN;
typedef HANDLE HRSRC;
typedef HANDLE HSTMT;
typedef HANDLE HSZ;
typedef HANDLE HWINSTA;
typedef HANDLE HWND;
typedef int INT;
typedef unsigned short LANGID;
typedef DWORD LCID;
typedef DWORD LCTYPE;
/* typedef LOCALHANDLE */
typedef double LONGLONG, *PLONGLONG;
typedef unsigned short *LP;
typedef long LPARAM;
typedef WINBOOL *LPBOOL;
typedef BYTE *LPBYTE;
typedef CONST CHAR *LPCCH;
typedef CHAR *LPCH;
typedef COLORREF *LPCOLORREF;
typedef const char *LPCSTR;
typedef char* PCSZ;
#ifdef UNICODE
typedef const unsigned short *LPCTSTR;
#else
typedef const char *LPCTSTR;
#endif /* UNICODE */
typedef const unsigned short *LPCWCH;
typedef const unsigned short *LPCWSTR;
typedef DWORD *LPDWORD;
/* typedef LPFRHOOKPROC; */
typedef HANDLE *LPHANDLE;
/* typedef LPHANDLER_FUNCTION; */
typedef int *LPINT;
typedef long *LPLONG;
typedef char *LPSTR;
#ifdef UNICODE
typedef unsigned short *LPTCH;
typedef unsigned short *LPTSTR;
#else
typedef char *LPTCH;
typedef char *LPTSTR;
#endif /* UNICODE */
typedef long LRESULT;
typedef void *LPVOID;
typedef const void *LPCVOID;
typedef unsigned short *LPWCH;
typedef unsigned short *LPWORD;
typedef unsigned short *LPWSTR;
typedef unsigned short *PWSTR;
/* typedef NPSTR; */
typedef unsigned short *NWPSTR;
typedef WINBOOL *PWINBOOL;
typedef BYTE *PBOOLEAN;
typedef BYTE *PBYTE;
typedef const CHAR *PCCH;
typedef CHAR *PCH;
typedef CHAR *PCHAR;
typedef const char *PCSTR;
typedef const unsigned short *PCWCH;
typedef const unsigned short *PCWSTR;
typedef DWORD *PDWORD;
typedef float *PFLOAT;
typedef HANDLE *PHANDLE;
/* typedef PHKEY; */
typedef int *PINT;
/* typedef LCID *PLCID; */
typedef long *PLONG;
typedef short *PSHORT;
/* typedef PSID; */
typedef char *PSTR;
typedef char *PSZ;
#ifdef UNICODE
typedef unsigned short *PTBYTE;
typedef unsigned short *PTCH;
typedef unsigned short *PTCHAR;
typedef unsigned short *PTSTR;
#else
typedef unsigned char *PTBYTE;
typedef char *PTCH;
typedef char *PTCHAR;
typedef char *PTSTR;
#endif /* UNICODE */
typedef unsigned char *PUCHAR;
typedef unsigned int *PUINT;
typedef unsigned long *PULONG;
typedef unsigned short *PUSHORT;
typedef void *PVOID;
typedef unsigned short *PWCH;
typedef unsigned short *PWCHAR;
typedef unsigned short *PWORD;
/*
typedef PWSTR;
typedef REGSAM;
*/
typedef short RETCODE;
typedef HANDLE SC_HANDLE;
typedef LPVOID SC_LOCK;
typedef SC_HANDLE *LPSC_HANDLE;
typedef DWORD SERVICE_STATUS_HANDLE;
/* typedef SPHANDLE; */
#ifdef UNICODE
typedef unsigned short TBYTE;
typedef unsigned short TCHAR;
typedef unsigned short BCHAR;
#else
typedef unsigned char TBYTE;
typedef char TCHAR;
typedef BYTE BCHAR;
#endif /* UNICODE */
typedef unsigned char UCHAR;
typedef unsigned int UINT;
typedef unsigned long ULONG;
typedef unsigned short USHORT;
typedef unsigned short WCHAR;
typedef unsigned short WORD;
typedef unsigned int WPARAM;
/* typedef YIELDPROC; */
/* Only use __stdcall under WIN32 compiler */
#ifdef i386
#define STDCALL __attribute__ ((stdcall))
#define CDECL __attribute((cdecl))
#define CALLBACK WINAPI
#define PASCAL WINAPI
#else
#define STDCALL
#define CDECL
#define CALLBACK
#define PASCAL
#endif
#define WINAPI STDCALL
#define APIENTRY STDCALL
#define WINGDIAPI
#define _export
/*
Enumerations
*/
typedef enum _ACL_INFORMATION_CLASS {
AclRevisionInformation = 1,
AclSizeInformation
} ACL_INFORMATION_CLASS;
typedef enum _MEDIA_TYPE {
Unknown,
F5_1Pt2_512,
F3_1Pt44_512,
F3_2Pt88_512,
F3_20Pt8_512,
F3_720_512,
F5_360_512,
F5_320_512,
F5_320_1024,
F5_180_512,
F5_160_512,
RemovableMedia,
FixedMedia
} MEDIA_TYPE;
#define RASCS_DONE 0x2000
#define RASCS_PAUSED 0x1000
typedef enum _RASCONNSTATE {
RASCS_OpenPort = 0,
RASCS_PortOpened,
RASCS_ConnectDevice,
RASCS_DeviceConnected,
RASCS_AllDevicesConnected,
RASCS_Authenticate,
RASCS_AuthNotify,
RASCS_AuthRetry,
RASCS_AuthCallback,
RASCS_AuthChangePassword,
RASCS_AuthProject,
RASCS_AuthLinkSpeed,
RASCS_AuthAck,
RASCS_ReAuthenticate,
RASCS_Authenticated,
RASCS_PrepareForCallback,
RASCS_WaitForModemReset,
RASCS_WaitForCallback,
RASCS_Projected,
RASCS_StartAuthentication,
RASCS_CallbackComplete,
RASCS_LogonNetwork,
RASCS_Interactive = RASCS_PAUSED,
RASCS_RetryAuthentication,
RASCS_CallbackSetByCaller,
RASCS_PasswordExpired,
RASCS_Connected = RASCS_DONE,
RASCS_Disconnected
} RASCONNSTATE ;
typedef enum _RASPROJECTION {
RASP_Amb = 0x10000,
RASP_PppNbf = 0x803F,
RASP_PppIpx = 0x802B,
RASP_PppIp = 0x8021
} RASPROJECTION ;
typedef enum _SECURITY_IMPERSONATION_LEVEL {
SecurityAnonymous,
SecurityIdentification,
SecurityImpersonation,
SecurityDelegation
} SECURITY_IMPERSONATION_LEVEL;
typedef enum _SID_NAME_USE {
SidTypeUser = 1,
SidTypeGroup,
SidTypeDomain,
SidTypeAlias,
SidTypeWellKnownGroup,
SidTypeDeletedAccount,
SidTypeInvalid,
SidTypeUnknown
} SID_NAME_USE, *PSID_NAME_USE;
typedef enum _TOKEN_INFORMATION_CLASS {
TokenUser = 1,
TokenGroups,
TokenPrivileges,
TokenOwner,
TokenPrimaryGroup,
TokenDefaultDacl,
TokenSource,
TokenType,
TokenImpersonationLevel,
TokenStatistics
} TOKEN_INFORMATION_CLASS;
typedef enum tagTOKEN_TYPE {
TokenPrimary = 1,
TokenImpersonation
} TOKEN_TYPE;
#endif /* ! defined (RC_INVOKED) */
/*
Macros
*/
#define FORWARD_WM_NOTIFY(hwnd, idFrom, pnmhdr, fn) (void)(fn)((hwnd), WM_NOTIFY, (WPARAM)(int)(id), (LPARAM)(NMHDR FAR*)(pnmhdr))
#define GetBValue(rgb) ((BYTE) ((rgb) >> 16))
#define GetGValue(rgb) ((BYTE) (((WORD) (rgb)) >> 8))
#define GetRValue(rgb) ((BYTE) (rgb))
#define RGB(r, g ,b) ((DWORD) (((BYTE) (r) | ((WORD) (g) << 8)) | (((DWORD) (BYTE) (b)) << 16)))
#define HANDLE_WM_NOTIFY(hwnd, wParam, lParam, fn) (fn)((hwnd), (int)(wParam), (NMHDR FAR*)(lParam))
#define HIBYTE(w) ((BYTE) (((WORD) (w) >> 8) & 0xFF))
#define HIWORD(l) ((WORD) (((DWORD) (l) >> 16) & 0xFFFF))
#define LOBYTE(w) ((BYTE) (w))
#define LOWORD(l) ((WORD) (l))
#define MAKELONG(a, b) ((LONG) (((WORD) (a)) | ((DWORD) ((WORD) (b))) << 16))
#define MAKEWORD(a, b) ((WORD) (((BYTE) (a)) | ((WORD) ((BYTE) (b))) << 8))
/* original Cygnus headers also had the following defined: */
#define SEXT_HIWORD(l) ((((int)l) >> 16))
#define ZEXT_HIWORD(l) ((((unsigned int)l) >> 16))
#define SEXT_LOWORD(l) ((int)(short)l)
#define INDEXTOOVERLAYMASK(i) ((i) << 8)
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
#define MAKEINTATOM(i) (LPTSTR) ((DWORD) ((WORD) (i)))
#define MAKEINTRESOURCE(i) (LPTSTR) ((DWORD) ((WORD) (i)))
#define MAKELANGID(p, s) ((((WORD) (s)) << 10) | (WORD) (p))
#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
#define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
#define LANGIDFROMLCID(lcid) ((WORD) (lcid))
#define SORTIDFROMLCID(lcid) ((WORD )((((DWORD)(lcid)) & 0x000FFFFF) >> 16))
#define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD)(srtid))) << 16) | ((DWORD)((WORD)(lgid)))))
#define MAKELPARAM(l, h) ((LPARAM) MAKELONG(l, h))
#define MAKELRESULT(l, h) ((LRESULT) MAKELONG(l, h))
#define MAKEPOINTS(l) (*((POINTS FAR *) & (l)))
#define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore))
#define MAKEWPARAM(l, h) ((WPARAM) MAKELONG(l, h))
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#define PALETTEINDEX(i) ((COLORREF) (0x01000000 | (DWORD) (WORD) (i)))
#define PALETTERGB(r, g, b) (0x02000000 | RGB(r, g, b))
#define POINTSTOPOINT(pt, pts) {(pt).x = (SHORT) LOWORD(pts); (pt).y = (SHORT) HIWORD(pts);}
#define POINTTOPOINTS(pt) (MAKELONG((short) ((pt).x), (short) ((pt).y)))
#define INDEXTOOVERLAYMASK(i) ((i) << 8)
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
#ifdef UNICODE
#define TEXT(quote) L##quote
#else
#define TEXT(quote) quote
#endif
#ifndef RC_INVOKED
/*
Definitions for callback procedures
*/
typedef int CALLBACK (*BFFCALLBACK) (HWND, UINT, LPARAM, LPARAM);
typedef UINT CALLBACK (*LPCCHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPCFHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef DWORD CALLBACK (*PTHREAD_START_ROUTINE) (LPVOID);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
typedef DWORD CALLBACK (*EDITSTREAMCALLBACK) (DWORD, LPBYTE, LONG, LONG);
typedef UINT CALLBACK (*LPFRHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPPRINTHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPSETUPHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef WINBOOL CALLBACK (*DLGPROC) (HWND, UINT, WPARAM, LPARAM);
typedef int CALLBACK (*PFNPROPSHEETCALLBACK) (HWND, UINT, LPARAM);
typedef VOID CALLBACK (*LPSERVICE_MAIN_FUNCTION) (DWORD, LPTSTR);
typedef int CALLBACK (*PFNTVCOMPARE) (LPARAM, LPARAM, LPARAM);
typedef LRESULT CALLBACK (*WNDPROC) (HWND, UINT, WPARAM, LPARAM);
typedef int CALLBACK (*FARPROC)(void);
typedef FARPROC PROC;
typedef WINBOOL CALLBACK (*ENUMRESTYPEPROC) (HANDLE, LPTSTR, LONG);
typedef WINBOOL CALLBACK (*ENUMRESNAMEPROC) (HANDLE, LPCTSTR, LPTSTR, LONG);
typedef WINBOOL CALLBACK (*ENUMRESLANGPROC) (HANDLE, LPCTSTR, LPCTSTR, WORD, LONG);
typedef FARPROC DESKTOPENUMPROC;
typedef WINBOOL CALLBACK (*ENUMWINDOWSPROC) (HWND, LPARAM);
typedef WINBOOL CALLBACK (*ENUMWINDOWSTATIONPROC) (LPTSTR, LPARAM);
typedef VOID CALLBACK (*SENDASYNCPROC) (HWND, UINT, DWORD, LRESULT);
typedef VOID CALLBACK (*TIMERPROC) (HWND, UINT, UINT, DWORD);
typedef FARPROC GRAYSTRINGPROC;
typedef WINBOOL CALLBACK (*DRAWSTATEPROC) (HDC, LPARAM, WPARAM, int, int);
typedef WINBOOL CALLBACK (*PROPENUMPROCEX) (HWND, LPCTSTR, HANDLE, DWORD);
typedef WINBOOL CALLBACK (*PROPENUMPROC) (HWND, LPCTSTR, HANDLE);
typedef LRESULT CALLBACK (*HOOKPROC) (int, WPARAM, LPARAM);
typedef VOID CALLBACK (*ENUMOBJECTSPROC) (LPVOID, LPARAM);
typedef VOID CALLBACK (*LINEDDAPROC) (int, int, LPARAM);
typedef WINBOOL CALLBACK (*ABORTPROC) (HDC, int);
typedef UINT CALLBACK (*LPPAGEPAINTHOOK) (HWND, UINT, WPARAM, LPARAM );
typedef UINT CALLBACK (*LPPAGESETUPHOOK) (HWND, UINT, WPARAM, LPARAM );
typedef int CALLBACK (*ICMENUMPROC) (LPTSTR, LPARAM);
typedef LONG (*EDITWORDBREAKPROCEX) (char *, LONG, BYTE, INT);
typedef int CALLBACK (*PFNLVCOMPARE) (LPARAM, LPARAM, LPARAM);
typedef WINBOOL CALLBACK (*LOCALE_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*CODEPAGE_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*DATEFMT_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*TIMEFMT_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*CALINFO_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*PHANDLER_ROUTINE) (DWORD);
typedef WINBOOL CALLBACK (*LPHANDLER_FUNCTION) (DWORD);
typedef UINT CALLBACK (*PFNGETPROFILEPATH) (LPCTSTR, LPSTR, UINT);
typedef UINT CALLBACK (*PFNRECONCILEPROFILE) (LPCTSTR, LPCTSTR, DWORD);
typedef WINBOOL CALLBACK (*PFNPROCESSPOLICIES) (HWND, LPCTSTR, LPCTSTR, LPCTSTR, DWORD);
#define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
#define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
#define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
#define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
#define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
#define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
#define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
#define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
#define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
#define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
#define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
#define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
#define SE_TCB_NAME TEXT("SeTcbPrivilege")
#define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
#define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
#define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
#define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
#define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
#define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
#define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
#define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
#define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
#define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
#define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
#define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
#define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
#define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
#define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
#define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
#define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
#define SERVICES_ACTIVE_DATABASEW L"ServicesActive"
#define SERVICES_FAILED_DATABASEW L"ServicesFailed"
#define SERVICES_ACTIVE_DATABASEA "ServicesActive"
#define SERVICES_FAILED_DATABASEA "ServicesFailed"
#define SC_GROUP_IDENTIFIERW L'+'
#define SC_GROUP_IDENTIFIERA '+'
#ifdef UNICODE
#define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEW
#define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEW
#define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERW
#else
#define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEA
#define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEA
#define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERA
#endif /* UNICODE */
/* ---------------------------------- */
/* From ddeml.h in old Cygnus headers */
typedef void (*CALLB) (void);
typedef CALLB PFNCALLBACK;
typedef WINBOOL SECURITY_CONTEXT_TRACKING_MODE;
/* End of stuff from ddeml.h in old Cygnus headers */
/* ----------------------------------------------- */
typedef FARPROC WNDENUMPROC;
typedef FARPROC ENHMFENUMPROC;
typedef DWORD CCSTYLE, *PCCSTYLE, *LPCCSTYLE;
typedef DWORD CCSTYLEFLAGA, *PCCSTYLEFLAGA, *LPCCSTYLEFLAGA;
#define DECLARE_HANDLE(s) typedef HANDLE s
#endif /* ! defined (RC_INVOKED) */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GNU_H_WINDOWS32_BASE */

339
reactos/include/coff.h Normal file
View file

@ -0,0 +1,339 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_coff_h_
#define __dj_include_coff_h_
#ifdef __cplusplus
extern "C" {
#endif
//#ifndef __dj_ENFORCE_ANSI_FREESTANDING
//#ifndef __STRICT_ANSI__
//#ifndef _POSIX_SOURCE
/*** coff information for Intel 386/486. */
/********************** FILE HEADER **********************/
struct external_filehdr {
unsigned short f_magic; /* magic number */
unsigned short f_nscns; /* number of sections */
unsigned long f_timdat; /* time & date stamp */
unsigned long f_symptr; /* file pointer to symtab */
unsigned long f_nsyms; /* number of symtab entries */
unsigned short f_opthdr; /* sizeof(optional hdr) */
unsigned short f_flags; /* flags */
};
/* Bits for f_flags:
* F_RELFLG relocation info stripped from file
* F_EXEC file is executable (no unresolved external references)
* F_LNNO line numbers stripped from file
* F_LSYMS local symbols stripped from file
* F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
*/
#define F_RELFLG (0x0001)
#define F_EXEC (0x0002)
#define F_LNNO (0x0004)
#define F_LSYMS (0x0008)
#define I386MAGIC 0x14c
#define I386AIXMAGIC 0x175
#define I386BADMAG(x) (((x).f_magic!=I386MAGIC) && (x).f_magic!=I386AIXMAGIC)
#define FILHDR struct external_filehdr
#define FILHSZ sizeof(FILHDR)
/********************** AOUT "OPTIONAL HEADER" **********************/
typedef struct
{
unsigned short magic; /* type of file */
unsigned short vstamp; /* version stamp */
unsigned long tsize; /* text size in bytes, padded to FW bdry*/
unsigned long dsize; /* initialized data " " */
unsigned long bsize; /* uninitialized data " " */
unsigned long entry; /* entry pt. */
unsigned long text_start; /* base of text used for this file */
unsigned long data_start; /* base of data used for this file */
}
AOUTHDR;
typedef struct gnu_aout {
unsigned long info;
unsigned long tsize;
unsigned long dsize;
unsigned long bsize;
unsigned long symsize;
unsigned long entry;
unsigned long txrel;
unsigned long dtrel;
} GNU_AOUT;
#define AOUTSZ (sizeof(AOUTHDR))
#define OMAGIC 0404 /* object files, eg as output */
#define ZMAGIC 0413 /* demand load format, eg normal ld output */
#define STMAGIC 0401 /* target shlib */
#define SHMAGIC 0443 /* host shlib */
/********************** SECTION HEADER **********************/
struct external_scnhdr {
char s_name[8]; /* section name */
unsigned long s_paddr; /* physical address, aliased s_nlib */
unsigned long s_vaddr; /* virtual address */
unsigned long s_size; /* section size */
unsigned long s_scnptr; /* file ptr to raw data for section */
unsigned long s_relptr; /* file ptr to relocation */
unsigned long s_lnnoptr; /* file ptr to line numbers */
unsigned short s_nreloc; /* number of relocation entries */
unsigned short s_nlnno; /* number of line number entries*/
unsigned long s_flags; /* flags */
};
#define SCNHDR struct external_scnhdr
#define SCNHSZ sizeof(SCNHDR)
/*
* names of "special" sections
*/
#define _TEXT ".text"
#define _DATA ".data"
#define _BSS ".bss"
#define _COMMENT ".comment"
#define _LIB ".lib"
/*
* s_flags "type"
*/
#define STYP_TEXT (0x0020) /* section contains text only */
#define STYP_DATA (0x0040) /* section contains data only */
#define STYP_BSS (0x0080) /* section contains bss only */
/********************** LINE NUMBERS **********************/
/* 1 line number entry for every "breakpointable" source line in a section.
* Line numbers are grouped on a per function basis; first entry in a function
* grouping will have l_lnno = 0 and in place of physical address will be the
* symbol table index of the function name.
*/
struct external_lineno {
union {
unsigned long l_symndx __attribute__((packed)); /* function name symbol index, iff l_lnno == 0 */
unsigned long l_paddr __attribute__((packed)); /* (physical) address of line number */
} l_addr;
unsigned short l_lnno; /* line number */
};
#define LINENO struct external_lineno
#define LINESZ sizeof(LINENO)
/********************** SYMBOLS **********************/
#define E_SYMNMLEN 8 /* # characters in a symbol name */
#define E_FILNMLEN 14 /* # characters in a file name */
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
struct external_syment
{
union {
char e_name[E_SYMNMLEN];
struct {
unsigned long e_zeroes __attribute__((packed));
unsigned long e_offset __attribute__((packed));
} e;
} e;
unsigned long e_value __attribute__((packed));
short e_scnum;
unsigned short e_type;
unsigned char e_sclass;
unsigned char e_numaux;
};
#define N_BTMASK (0xf)
#define N_TMASK (0x30)
#define N_BTSHFT (4)
#define N_TSHIFT (2)
union external_auxent {
struct {
unsigned long x_tagndx __attribute__((packed)); /* str, un, or enum tag indx */
union {
struct {
unsigned short x_lnno; /* declaration line number */
unsigned short x_size; /* str/union/array size */
} x_lnsz;
unsigned long x_fsize __attribute__((packed)); /* size of function */
} x_misc;
union {
struct { /* if ISFCN, tag, or .bb */
unsigned long x_lnnoptr __attribute__((packed)); /* ptr to fcn line # */
unsigned long x_endndx __attribute__((packed)); /* entry ndx past block end */
} x_fcn;
struct { /* if ISARY, up to 4 dimen. */
unsigned short x_dimen[E_DIMNUM];
} x_ary;
} x_fcnary;
unsigned short x_tvndx; /* tv index */
} x_sym;
union {
char x_fname[E_FILNMLEN];
struct {
unsigned long x_zeroes __attribute__((packed));
unsigned long x_offset __attribute__((packed));
} x_n;
} x_file;
struct {
unsigned long x_scnlen __attribute__((packed)); /* section length */
unsigned short x_nreloc; /* # relocation entries */
unsigned short x_nlinno; /* # line numbers */
} x_scn;
struct {
unsigned long x_tvfill __attribute__((packed)); /* tv fill value */
unsigned short x_tvlen; /* length of .tv */
unsigned short x_tvran[2]; /* tv range */
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
};
#define SYMENT struct external_syment
#define SYMESZ sizeof(SYMENT)
#define AUXENT union external_auxent
#define AUXESZ sizeof(AUXENT)
# define _ETEXT "etext"
/* Relocatable symbols have number of the section in which they are defined,
or one of the following: */
#define N_UNDEF ((short)0) /* undefined symbol */
#define N_ABS ((short)-1) /* value of symbol is absolute */
#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/
/*
* Type of a symbol, in low N bits of the word
*/
#define T_NULL 0
#define T_VOID 1 /* function argument (only used by compiler) */
#define T_CHAR 2 /* character */
#define T_SHORT 3 /* short integer */
#define T_INT 4 /* integer */
#define T_LONG 5 /* long integer */
#define T_FLOAT 6 /* floating point */
#define T_DOUBLE 7 /* double word */
#define T_STRUCT 8 /* structure */
#define T_UNION 9 /* union */
#define T_ENUM 10 /* enumeration */
#define T_MOE 11 /* member of enumeration*/
#define T_UCHAR 12 /* unsigned character */
#define T_USHORT 13 /* unsigned short */
#define T_UINT 14 /* unsigned integer */
#define T_ULONG 15 /* unsigned long */
#define T_LNGDBL 16 /* long double */
/*
* derived types, in n_type
*/
#define DT_NON (0) /* no derived type */
#define DT_PTR (1) /* pointer */
#define DT_FCN (2) /* function */
#define DT_ARY (3) /* array */
#define BTYPE(x) ((x) & N_BTMASK)
#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
#define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG)
#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
/********************** STORAGE CLASSES **********************/
/* This used to be defined as -1, but now n_sclass is unsigned. */
#define C_EFCN 0xff /* physical end of function */
#define C_NULL 0
#define C_AUTO 1 /* automatic variable */
#define C_EXT 2 /* external symbol */
#define C_STAT 3 /* static */
#define C_REG 4 /* register variable */
#define C_EXTDEF 5 /* external definition */
#define C_LABEL 6 /* label */
#define C_ULABEL 7 /* undefined label */
#define C_MOS 8 /* member of structure */
#define C_ARG 9 /* function argument */
#define C_STRTAG 10 /* structure tag */
#define C_MOU 11 /* member of union */
#define C_UNTAG 12 /* union tag */
#define C_TPDEF 13 /* type definition */
#define C_USTATIC 14 /* undefined static */
#define C_ENTAG 15 /* enumeration tag */
#define C_MOE 16 /* member of enumeration */
#define C_REGPARM 17 /* register parameter */
#define C_FIELD 18 /* bit field */
#define C_AUTOARG 19 /* auto argument */
#define C_LASTENT 20 /* dummy entry (end of block) */
#define C_BLOCK 100 /* ".bb" or ".eb" */
#define C_FCN 101 /* ".bf" or ".ef" */
#define C_EOS 102 /* end of structure */
#define C_FILE 103 /* file name */
#define C_LINE 104 /* line # reformatted as symbol table entry */
#define C_ALIAS 105 /* duplicate tag */
#define C_HIDDEN 106 /* ext symbol in dmert public lib */
/********************** RELOCATION DIRECTIVES **********************/
struct external_reloc {
unsigned long r_vaddr __attribute__((packed));
unsigned long r_symndx __attribute__((packed));
unsigned short r_type;
};
#define RELOC struct external_reloc
#define RELSZ sizeof(RELOC)
#define RELOC_REL32 20 /* 32-bit PC-relative address */
#define RELOC_ADDR32 6 /* 32-bit absolute address */
#define DEFAULT_DATA_SECTION_ALIGNMENT 4
#define DEFAULT_BSS_SECTION_ALIGNMENT 4
#define DEFAULT_TEXT_SECTION_ALIGNMENT 4
/* For new sections we havn't heard of before */
#define DEFAULT_SECTION_ALIGNMENT 4
//#endif /* !_POSIX_SOURCE */
//#endif /* !__STRICT_ANSI__ */
//#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_coff_h_ */

View file

@ -0,0 +1,72 @@
// registry key structures
typedef struct _KEY_BASIC_INFORMATION {
LARGE_INTEGER LastWriteTime;
ULONG TitleIndex;
ULONG NameLength;
WCHAR Name[1]; // variable size
} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
typedef struct _KEY_NODE_INFORMATION {
LARGE_INTEGER LastWriteTime;
ULONG TitleIndex;
ULONG ClassOffset;
ULONG ClassLength;
ULONG NameLength;
WCHAR Name[1]; // variable size
} KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
typedef struct _KEY_FULL_INFORMATION {
LARGE_INTEGER LastWriteTime;
ULONG TitleIndex;
ULONG ClassOffset;
ULONG ClassLength;
ULONG SubKeys;
ULONG MaxNameLen;
ULONG MaxClassLen;
ULONG Values;
ULONG MaxValueNameLen;
ULONG MaxValueDataLen;
WCHAR Class[1]; // variable size
} KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
typedef struct _KEY_WRITE_TIME_INFORMATION {
LARGE_INTEGER LastWriteTime;
} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
// key query value structures
typedef struct _KEY_VALUE_BASIC_INFORMATION {
ULONG TitleIndex;
ULONG Type;
ULONG NameLength;
WCHAR Name[1]; // variable size
} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
typedef struct _KEY_VALUE_FULL_INFORMATION {
ULONG TitleIndex;
ULONG Type;
ULONG DataOffset;
ULONG DataLength;
ULONG NameLength;
WCHAR Name[1]; // variable size
} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
ULONG TitleIndex;
ULONG Type;
ULONG DataLength;
UCHAR Data[1]; // variable size
} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
typedef struct _KEY_VALUE_ENTRY {
PUNICODE_STRING ValueName;
ULONG DataLength;
ULONG DataOffset;
ULONG Type;
} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;

View file

@ -0,0 +1,521 @@
/* GENERAL DEFINITIONS ****************************************************/
#include <internal/hal/irq.h>
/*
* PURPOSE: Number of a thread priority levels
*/
#define NR_PRIORITY_LEVELS (32)
/*
* PURPOSE: Type of queue to insert a work item in
*/
enum
{
CriticalWorkQueue,
DelayedWorkQueue,
HyperCriticalWorkQueue,
};
/*
* Types of memory to allocate
*/
enum
{
NonPagedPool,
NonPagedPoolMustSucceed,
NonPagedPoolCacheAligned,
NonPagedPoolCacheAlignedMustS,
PagedPool,
PagedPoolCacheAligned,
};
/*
* PURPOSE: Irp flags
*/
enum
{
/*
* Read any data from the actual backing media
*/
IRP_NOCACHE,
/*
* The I/O operation is performing paging
*/
IRP_PAGING_IO,
/*
* The IRP is for a mount operation
*/
IRP_MOUNT_COMPLETION,
/*
* The API expects synchronous behaviour
*/
IRP_SYNCHRONOUS_API,
/*
* The IRP is associated with a larger operation
*/
IRP_ASSOCIATED_IRP,
/*
* The AssociatedIrp.SystemBuffer field is valid
*/
IRP_BUFFERED_IO,
/*
* The system buffer was allocated from pool and should be deallocated
* by the I/O manager
*/
IRP_DEALLOCATE_BUFFER,
/*
* The IRP is for an input operation
*/
IRP_INPUT_OPERATION,
/*
* The paging operation should complete synchronously
*/
IRP_SYNCHRONOUS_PAGING_IO,
/*
* The IRP represents a filesystem create operation
*/
IRP_CREATE_OPERATION,
/*
* The IRP represents a filesystem read operation
*/
IRP_READ_OPERATION,
/*
* The IRP represents a filesystem write operation
*/
IRP_WRITE_OPERATION,
/*
* The IRP represents a filesystem close operation
*/
IRP_CLOSE_OPERATION,
/*
* Asynchronous behavior is advised but not required
*/
IRP_DEFER_IO_COMPLETION,
};
/*
* I/O operation flags
*/
enum
{
/*
* Force an access check even if opened in kernel mode
*/
SL_FORCE_ACCESS_CHECK,
/*
* The file being opened is a paging file
*/
SL_OPEN_PAGING_FILE,
SL_OPEN_TARGET_DIRECTORY,
SL_CASE_SENSITIVE,
SL_KEY_SPECIFIED,
SL_OVERRIDE_VERIFY_VOLUME,
SL_WRITE_THROUGH,
SL_FT_SEQUENTIAL_WRITE,
SL_FAIL_IMMEDIATELY,
SL_EXCLUSIVE_LOCK,
SL_RESTART_SCAN,
SL_RETURN_SINGLE_ENTRY,
SL_INDEX_SPECIFIED,
SL_WATCH_TREE,
SL_ALLOW_RAW_MOUNT,
};
/*
* Possible flags for the device object flags
*/
enum
{
DO_BUFFERED_IO = 0x1,
DO_DIRECT_IO = 0x2,
};
/*
* Possible status codes
* FIXME: These may not be the actual values used by NT
*/
enum
{
STATUS_SUCCESS,
STATUS_INSUFFICIENT_RESOURCES,
STATUS_OBJECT_NAME_EXISTS,
STATUS_OBJECT_NAME_COLLISION,
// STATUS_DATATYPE_MISALIGNMENT,
STATUS_CTL_FILE_NOT_SUPPORTED,
// STATUS_ACCESS_VIOLATION,
STATUS_PORT_ALREADY_SET,
STATUS_SECTION_NOT_IMAGE,
STATUS_BAD_WORKING_SET_LIMIT,
STATUS_INCOMPATIBLE_FILE_MAP,
STATUS_HANDLE_NOT_WAITABLE,
STATUS_PORT_DISCONNECTED,
STATUS_NOT_LOCKED,
STATUS_NOT_MAPPED_VIEW,
STATUS_UNABLE_TO_FREE_VM,
STATUS_UNABLE_TO_DELETE_SECTION,
STATUS_MORE_PROCESSING_REQUIRED,
STATUS_INVALID_CID,
STATUS_BAD_INITIAL_STACK,
STATUS_INVALID_VOLUME_LABEL,
STATUS_SECTION_NOT_EXTENDED,
STATUS_NOT_MAPPED_DATA,
STATUS_INFO_LENGTH_MISMATCH,
STATUS_INVALID_INFO_CLASS,
STATUS_SUSPEND_COUNT_EXCEEDED,
STATUS_NOTIFY_ENUM_DIR,
STATUS_REGISTRY_RECOVERED,
STATUS_REGISTRY_IO_FAILED,
STATUS_KEY_DELETED,
STATUS_NO_LOG_SPACE,
STATUS_KEY_HAS_CHILDREN,
STATUS_CHILD_MUST_BE_VOLATILE,
STATUS_REGISTRY_CORRUPT,
STATUS_DLL_NOT_FOUND,
STATUS_DLL_INIT_FAILED,
STATUS_ORDINAL_NOT_FOUND,
STATUS_ENTRYPOINT_NOT_FOUND,
// STATUS_PENDING,
STATUS_MORE_ENTRIES,
// STATUS_INTEGER_OVERFLOW,
STATUS_BUFFER_OVERFLOW,
STATUS_NO_MORE_FILES,
STATUS_NO_INHERITANCE,
STATUS_NO_MORE_EAS,
STATUS_NO_MORE_ENTRIES,
STATUS_GUIDS_EXHAUSTED,
STATUS_AGENTS_EXHAUSTED,
STATUS_UNSUCCESSFUL,
STATUS_NOT_IMPLEMENTED,
STATUS_ILLEGAL_FUNCTION,
// STATUS_IN_PAGE_ERROR,
STATUS_PAGEFILE_QUOTA,
STATUS_COMMITMENT_LIMIT,
STATUS_SECTION_TOO_BIG,
RPC_NT_SS_IN_NULL_CONTEXT,
RPC_NT_INVALID_BINDING,
// STATUS_INVALID_HANDLE,
STATUS_OBJECT_FILE_MISMATCH,
STATUS_FILE_CLOSED,
STATUS_INVALID_PORT_HANDLE,
STATUS_NOT_COMMITTED,
STATUS_INVALID_PARAMETER,
STATUS_INVALID_PARAMETER_1,
STATUS_INVALID_PARAMETER_2,
STATUS_INVALID_PARAMETER_3,
STATUS_INVALID_PARAMETER_4,
STATUS_INVALID_PARAMETER_5,
STATUS_INVALID_PARAMETER_6,
STATUS_INVALID_PARAMETER_7,
STATUS_INVALID_PARAMETER_8,
STATUS_INVALID_PARAMETER_9,
STATUS_INVALID_PARAMETER_10,
STATUS_INVALID_PARAMETER_11,
STATUS_INVALID_PARAMETER_12,
STATUS_INVALID_PARAMETER_MAX,
STATUS_INVALID_PAGE_PROTECTION,
STATUS_RESOURCE_DATA_NOT_FOUND,
STATUS_RESOURCE_TYPE_NOT_FOUND,
STATUS_RESOURCE_NAME_NOT_FOUND,
STATUS_RESOURCE_LANG_NOT_FOUND,
STATUS_NO_SUCH_DEVICE,
STATUS_NO_SUCH_FILE,
STATUS_INVALID_DEVICE_REQUEST,
STATUS_END_OF_FILE,
STATUS_FILE_FORCED_CLOSED,
STATUS_WRONG_VOLUME,
STATUS_NO_MEDIA,
STATUS_NO_MEDIA_IN_DEVICE,
STATUS_NONEXISTENT_SECTOR,
STATUS_WORKING_SET_QUOTA,
// STATUS_NO_MEMORY,
STATUS_CONFLICTING_ADDRESS,
STATUS_INVALID_SYSTEM_SERVICE,
STATUS_THREAD_IS_TERMINATING,
STATUS_PROCESS_IS_TERMINATING,
STATUS_INVALID_LOCK_SEQUENCE,
STATUS_INVALID_VIEW_SIZE,
STATUS_ALREADY_COMMITTED,
STATUS_ACCESS_DENIED,
STATUS_FILE_IS_A_DIRECTORY,
STATUS_CANNOT_DELETE,
STATUS_INVALID_COMPUTER_NAME,
STATUS_FILE_DELETED,
STATUS_DELETE_PENDING,
STATUS_PORT_CONNECTION_REFUSED,
STATUS_NO_SUCH_PRIVILEGE,
STATUS_PRIVILEGE_NOT_HELD,
STATUS_CANNOT_IMPERSONATE,
STATUS_LOGON_FAILURE,
STATUS_ACCOUNT_RESTRICTION,
STATUS_INVALID_LOGON_HOURS,
STATUS_INVALID_WORKSTATION,
STATUS_BUFFER_TOO_SMALL,
STATUS_UNABLE_TO_DECOMMIT_VM,
STATUS_DISK_CORRUPT_ERROR,
STATUS_OBJECT_NAME_INVALID,
STATUS_OBJECT_NAME_NOT_FOUND,
// STATUS_OBJECT_NAME_COLLISION,
STATUS_OBJECT_PATH_INVALID,
STATUS_OBJECT_PATH_NOT_FOUND,
STATUS_DFS_EXIT_PATH_FOUND,
STATUS_OBJECT_PATH_SYNTAX_BAD,
STATUS_DATA_OVERRUN,
STATUS_DATA_LATE_ERROR,
STATUS_DATA_ERROR,
STATUS_CRC_ERROR,
STATUS_SHARING_VIOLATION,
STATUS_QUOTA_EXCEEDED,
STATUS_MUTANT_NOT_OWNED,
STATUS_SEMAPHORE_LIMIT_EXCEEDED,
STATUS_DISK_FULL,
STATUS_LOCK_NOT_GRANTED,
};
/*
* Possible device types
*/
enum
{
/*
* Standard define types
*/
FILE_DEVICE_BEEP,
FILE_DEVICE_CDROM,
FILE_DEVICE_CONTROLLER,
FILE_DEVICE_DISK,
FILE_DEVICE_INPORT_PORT,
FILE_DEVICE_KEYBOARD,
FILE_DEVICE_MIDI_IN,
FILE_DEVICE_MIDI_OUT,
FILE_DEVICE_MOUSE,
FILE_DEVICE_NULL,
FILE_DEVICE_PARALLEL_PORT,
FILE_DEVICE_PRINTER,
FILE_DEVICE_SCANNER,
FILE_DEVICE_SERIAL_MOUSE_PORT,
FILE_DEVICE_SERIAL_PORT,
FILE_DEVICE_SCREEN,
FILE_DEVICE_TAPE,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_VIDEO,
FILE_DEVICE_VIRTUAL_DISK,
FILE_DEVICE_WAVE_IN,
FILE_DEVICE_WAVE_OUT,
FILE_DEVICE_8042_PORT,
/*
* Values beyond this are reserved for ISVs
*/
FILE_DEVICE_FIRST_FREE = 32768
};
/*
* Possible device characteristics
*/
enum
{
FILE_REMOVABLE_MEDIA = 0x1,
FILE_READ_ONLY_DEVICE = 0x2,
FILE_FLOPPY_DISKETTE = 0x4,
FILE_WRITE_ONCE_MEDIA = 0x8,
FILE_REMOTE_DEVICE = 0x10,
};
/*
* PURPOSE: Bus types
*/
enum
{
Internal,
Isa,
MicroChannel,
TurboChannel,
PCIBus,
MaximumInterfaceType,
};
/*
* This is a list of bug check types (not MS's)
*/
enum
{
KBUG_NONE,
KBUG_ORPHANED_IRP,
KBUG_IO_STACK_OVERFLOW,
KBUG_OUT_OF_MEMORY,
KBUG_POOL_FREE_LIST_CORRUPT,
/*
* These are well known but the actual value is unknown
*/
NO_PAGES_AVAILABLE,
/*
* These are well known (MS) bug types
* (Reference: NT Insider 1997 - http://www.osr.com)
*/
IRQL_NOT_LESS_OR_EQUAL = 0xa,
KMODE_EXCEPTION_NOT_HANDLED = 0x1e,
UNEXPECTED_KERNEL_MODE_TRAP = 0x7f,
PAGE_FAULT_IN_NON_PAGED_AREA = 0x50,
};
/*
* PURPOSE: Object attributes
*/
enum
{
OBJ_INHERIT = 0x1,
OBJ_PERMANENT = 0x2,
OBJ_EXCLUSIVE = 0x4,
OBJ_CASE_INSENSITIVE = 0x8,
OBJ_OPENIF = 0x10,
};
/*
* PURPOSE: DPC priorities
*/
enum
{
High,
Medium,
Low,
};
/*
* PURPOSE: Timer types
*/
enum
{
NotificationTimer,
SynchronizationTimer,
};
/*
* PURPOSE: Some drivers use these
*/
#define IN
#define OUT
#define OPTIONAL
/*
* PURPOSE: Power IRP minor function numbers
*/
enum
{
IRP_MN_QUERY_POWER,
IRP_MN_SET_POWER,
IRP_MN_WAIT_WAKE,
IRP_MN_QUERY_CAPABILITIES,
IRP_MN_POWER_SEQUENCE,
};
/*
* FIXME: These are not in the correct order
*/
enum
{
IRP_MJ_CREATE,
IRP_MJ_CREATE_NAMED_PIPE,
IRP_MJ_CLOSE,
IRP_MJ_READ,
IRP_MJ_WRITE,
IRP_MJ_QUERY_INFORMATION,
IRP_MJ_SET_INFORMATION,
IRP_MJ_QUERY_EA,
IRP_MJ_SET_EA,
IRP_MJ_FLUSH_BUFFERS,
IRP_MJ_QUERY_VOLUME_INFORMATION,
IRP_MJ_SET_VOLUME_INFORMATION,
IRP_MJ_DIRECTORY_CONTROL,
IRP_MJ_FILE_SYSTEM_CONTROL,
IRP_MJ_DEVICE_CONTROL,
IRP_MJ_INTERNAL_DEVICE_CONTROL,
IRP_MJ_SHUTDOWN,
IRP_MJ_LOCK_CONTROL,
IRP_MJ_CLEANUP,
IRP_MJ_CREATE_MAILSLOT,
IRP_MJ_QUERY_SECURITY,
IRP_MJ_SET_SECURITY,
IRP_MJ_QUERY_POWER,
IRP_MJ_SET_POWER,
IRP_MJ_DEVICE_CHANGE,
IRP_MJ_QUERY_QUOTA,
IRP_MJ_SET_QUOTA,
IRP_MJ_PNP_POWER,
IRP_MJ_MAXIMUM_FUNCTION,
};
/*
* PURPOSE: Used all over
*/
enum
{
KernelMode,
UserMode,
};
/*
* PURPOSE: Arguments to MmProbeAndLockPages
*/
enum
{
IoReadAccess,
IoWriteAccess,
IoModifyAccess,
};
#define MAXIMUM_VOLUME_LABEL_LENGTH (32)
/*
* IRQ levels
*/
enum
{
PASSIVE_LEVEL,
/*
* Which order for these (only DISPATCH_LEVEL is important for now)
*/
APC_LEVEL,
DISPATCH_LEVEL,
/*
* Above here are device specific IRQ levels
*/
FIRST_DEVICE_SPECIFIC_LEVEL,
HIGH_LEVEL = FIRST_DEVICE_SPECIFIC_LEVEL + NR_DEVICE_SPECIFIC_LEVELS,
};

View file

@ -0,0 +1,35 @@
/* EXECUTIVE ROUTINES ******************************************************/
//VOID ExAcquireFastMutex(PFAST_MUTEX FastMutex);
/*
* FUNCTION: Releases previously allocated memory
* ARGUMENTS:
* block = block to free
*/
VOID ExFreePool(PVOID block);
/*
* FUNCTION: Allocates memory from the nonpaged pool
* ARGUMENTS:
* size = minimum size of the block to be allocated
* PoolType = the type of memory to use for the block (ignored)
* RETURNS:
* the address of the block if it succeeds
*/
PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG size);
VOID ExInterlockedRemoveEntryList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry,
PKSPIN_LOCK Lock);
VOID RemoveEntryFromList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
PLIST_ENTRY ExInterlockedRemoveHeadList(PLIST_ENTRY Head, PKSPIN_LOCK Lock);
PLIST_ENTRY ExInterlockedInsertTailList(PLIST_ENTRY ListHead,
PLIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
PLIST_ENTRY ExInterlockedInsertHeadList(PLIST_ENTRY ListHead,
PLIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);

View file

@ -0,0 +1,18 @@
typedef struct _ZONE_HEADER
{
SINGLE_LIST_ENTRY FreeList;
SINGLE_LIST_ENTRY SegmentList;
ULONG BlockSize;
ULONG TotalSegmentSize;
} ZONE_HEADER, *PZONE_HEADER;
typedef struct _ZONE_SEGMENT
{
SINGLE_LIST_ENTRY Entry;
ULONG size;
} ZONE_SEGMENT, *PZONE_SEGMENT;
typedef struct _ZONE_ENTRY
{
SINGLE_LIST_ENTRY Entry;
} ZONE_ENTRY, *PZONE_ENTRY;

View file

@ -0,0 +1,504 @@
/* IO MANAGER ***************************************************************/
/*
* FUNCTION: Registers the driver with WMI
* ARGUMENTS:
* DeviceObject = Device to register
* Action = Action to take
* RETURNS: Status (?)
*/
//NTSTATUS IoWMIRegistrationControl(DeviceObject, WMIREGACTION Action);
/*
* FUNCTION: Synchronizes cancelable-state transistions for IRPs in a
* multiprocessor-safe way
* ARGUMENTS:
* Irpl = Variable to store the current IRQ level
*/
VOID IoAcquireCancelSpinLock(PKIRQL Irpl);
typedef IO_ALLOCATION_ACTION (*PDRIVER_CONTROL)(PDEVICE_OBJECT DeviceObject,
PIRP irp,
PVOID MapRegisterBase,
PVOID Context);
/*
* FUNCTION: Allocates an adaptor object for a DMA operation on the target
* device
* ARGUMENTS:
* Adaptor = Adapter channel or busmaster adapter to be allocated
* DeviceObject = Target device for DMA
* NumberOfMapRegisters = Number of map registers
* ExecutionRoutine = Routine to be called when the adaptor is
* available
* Context = driver defined contex that will be passed to the
* execution routine
* RETURNS: Success or failure code
*/
NTSTATUS IoAllocateAdapterChannel(PADAPTER_OBJECT AdaperObject,
PDEVICE_OBJECT DeviceObject,
ULONG NumberOfMapRegisters,
PDRIVER_CONTROL ExecutionRoutine,
PVOID Context);
/*
* FUNCTION: Sets up a call to a driver supplied controller object as
* soon as it is available
* ARGUMENTS:
* ControllerObject = Driver created controller object
* DeviceObject = target device
* ExecutionObject = Routine to be called
* Context = Driver determined context to be based to the routine
*/
VOID IoAllocateController(PCONTROLLER_OBJECT ControllerObject,
PDEVICE_OBJECT DeviceObject,
PDRIVER_CONTROL ExecutionRoutine,
PVOID Context);
/*
* FUNCTION: Allocates an error log packet
* ARGUMENTS:
* IoObject = Object which found the error
* EntrySize = Size in bytes of the packet to be allocated
* RETURNS: On success a pointer to the allocated packet
* On failure returns NULL
*/
PVOID IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize);
/*
* FUNCTION: Allocates an IRP
* ARGUMENTS:
* StackSize = number of stack locations to allocate
* ChargeQuota = Who knows
* RETURNS: On success the allocated IRP
* On failure NULL
*/
PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota);
/*
* FUNCTION: Allocates an MDL large enough to map the supplied buffer
* ARGUMENTS:
* VirtualAddress = base virtual address of the buffer to be mapped
* Length = length of the buffer to be mapped
* SecondaryBuffer = Whether the buffer is primary or secondary
* ChargeQuota = Charge non-paged pool quota to current thread
* Irp = Optional irp to be associated with the MDL
* RETURNS: On the success the allocated MDL
* On failure NULL
*/
PMDL IoAllocateMdl(PVOID VirtualAddress, ULONG Length,
BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota,
PIRP Irp);
/*
* FUNCTION: Creates a symbolic link between the ARC name of a physical
* device and the name of the corresponding device object
* ARGUMENTS:
* ArcName = ARC name of the device
* DeviceName = Name of the device object
*/
VOID IoAssignArcName(PUNICODE_STRING ArcName, PUNICODE_STRING DeviceName);
enum
{
IO_NO_INCREMENT,
};
/*
* FUNCTION: Takes a list of requested hardware resources and allocates them
* ARGUMENTS:
* RegisterPath =
* DriverClassName =
* DriverObject = Driver object passed to the DriverEntry routine
* DeviceObject =
* RequestedResources = List of resources
* RETURNS:
*/
NTSTATUS IoAssignResources(PUNICODE_STRING RegistryPath,
PUNICODE_STRING DriverClassName,
PDRIVER_OBJECT DriverObject,
PDEVICE_OBJECT DeviceObject,
PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
PCM_RESOURCE_LIST* AllocatedResources);
/*
* FUNCTION: Attaches the callers device object to a named target device
* ARGUMENTS:
* SourceDevice = caller's device
* TargetDevice = Name of the target device
* AttachedDevice = Caller allocated storage. On return contains
* a pointer to the target device
* RETURNS: Success or failure code
*/
NTSTATUS IoAttachDevice(PDEVICE_OBJECT SourceDevice,
PUNICODE_STRING TargetDevice,
PDEVICE_OBJECT* AttachedDevice);
/*
* FUNCTION: Obsolete
* ARGUMENTS:
* SourceDevice = device to attach
* TargetDevice = device to be attached to
* RETURNS: Success or failure code
*/
NTSTATUS IoAttachDeviceByPointer(PDEVICE_OBJECT SourceDevice,
PDEVICE_OBJECT TargetDevice);
/*
* FUNCTION: Attaches the callers device to the highest device in the chain
* ARGUMENTS:
* SourceDevice = caller's device
* TargetDevice = Device to attach
* RETURNS: On success the previously highest device
* On failure NULL
*/
PDEVICE_OBJECT IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
PDEVICE_OBJECT TargetDevice);
/*
* FUNCTION: Builds a irp to be sent to lower level drivers
* ARGUMENTS:
* MajorFunction = Major function code to be set in the IRP
* DeviceObject = Next lower device object
* Buffer = Buffer (only required for some major function codes)
* Length = Length in bytes of the buffer
* StartingOffset = Starting offset on the target device
* IoStatusBlock = Storage for status about the operation (optional)
* RETURNS: On success the IRP allocated
* On failure NULL
*/
PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER StartingOffset,
PIO_STATUS_BLOCK IoStatusBlock);
/*
* FUNCTION: Allocates and sets up an IRP for a device control request
* ARGUMENTS:
* IoControlCode = Type of request
* DeviceObject = Target device
* InputBuffer = Optional input buffer to the driver
* InputBufferLength = Length of the input buffer
* OutputBuffer = Optional output buffer
* OutputBufferLength = Length of the output buffer
* InternalDeviceIoControl = TRUE if the request is internal
* Event = Initialized event for the caller to wait for the request
* to be completed
* IoStatusBlock = I/O status block to be set when the request is
* completed
* RETURNS: Returns the IRP created
*/
PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
PDEVICE_OBJECT DeviceObject,
PVOID InputBuffer,
ULONG InputBufferLength,
PVOID OutputBuffer,
ULONG OutputBufferLength,
BOOLEAN InternalDeviceIoControl,
PKEVENT Event,
PIO_STATUS_BLOCK IoStatusBlock);
VOID IoBuildPartialMdl(PMDL SourceMdl,
PMDL TargetMdl,
PVOID VirtualAddress,
ULONG Length);
PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER StartingOffset,
PKEVENT Event,
PIO_STATUS_BLOCK IoStatusBlock);
/*
* FUNCTION: Sends an irp to the next lower driver
*/
NTSTATUS IoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP irp);
BOOLEAN IoCancelIrp(PIRP Irp);
NTSTATUS IoCheckShareAccess(ACCESS_MASK DesiredAccess,
ULONG DesiredShareAccess,
PFILE_OBJECT FileObject,
// PSHARE_ACCESS ShareAccess,
BOOLEAN Update);
/*
* FUNCTION: Indicates the caller has finished all processing for a given
* I/O request and is returning the given IRP to the I/O manager
* ARGUMENTS:
* Irp = Irp to be cancelled
* PriorityBoost = Increment by which to boost the priority of the
* thread making the request
*/
VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost);
NTSTATUS IoConnectInterrupt(PKINTERRUPT* InterruptObject,
PKSERVICE_ROUTINE ServiceRoutine,
PVOID ServiceContext,
PKSPIN_LOCK SpinLock,
ULONG Vector,
KIRQL Irql,
KIRQL SynchronizeIrql,
KINTERRUPT_MODE InterruptMode,
BOOLEAN ShareVector,
KAFFINITY ProcessorEnableMask,
BOOLEAN FloatingSave);
PCONTROLLER_OBJECT IoCreateController(ULONG Size);
/*
* FUNCTION: Allocates memory for and intializes a device object for use for
* a driver
* ARGUMENTS:
* DriverObject : Driver object passed by iomgr when the driver was
* loaded
* DeviceExtensionSize : Number of bytes for the device extension
* DeviceName : Unicode name of device
* DeviceType : Device type
* DeviceCharacteristics : Bit mask of device characteristics
* Exclusive : True if only one thread can access the device at a
* time
* RETURNS:
* Success or failure
* DeviceObject : Contains a pointer to allocated device object
* if the call succeeded
* NOTES: See the DDK documentation for more information
*/
NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
ULONG DeviceExtensionSize,
PUNICODE_STRING DeviceName,
DEVICE_TYPE DeviceType,
ULONG DeviceCharacteristics,
BOOLEAN Exclusive,
PDEVICE_OBJECT* DeviceObject);
PKEVENT IoCreateNotificationEvent(PUNICODE_STRING EventName,
PHANDLE EventHandle);
NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName);
PKEVENT IoCreateSynchronizationEvent(PUNICODE_STRING EventName,
PHANDLE EventHandle);
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName);
VOID IoDeassignArcName(PUNICODE_STRING ArcName);
VOID IoDeleteController(PCONTROLLER_OBJECT ControllerObject);
VOID IoDeleteDevice(PDEVICE_OBJECT DeviceObject);
NTSTATUS IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName);
VOID IoDetachDevice(PDEVICE_OBJECT TargetDevice);
VOID IoDisconnectInterrupt(PKINTERRUPT InterruptObject);
BOOLEAN IoFlushAdapterBuffers(PADAPTER_OBJECT AdapterObject,
PMDL Mdl,
PVOID MapRegisterBase,
PVOID CurrentVa,
ULONG Length,
BOOLEAN WriteToDevice);
VOID IoFreeAdapterChannel(PADAPTER_OBJECT AdapterObject);
VOID IoFreeController(PCONTROLLER_OBJECT ControllerObject);
VOID IoFreeIrp(PIRP Irp);
VOID IoFreeMapRegisters(PADAPTER_OBJECT AdapterObject,
PVOID MapRegisterBase,
ULONG NumberOfMapRegisters);
VOID IoFreeMdl(PMDL Mdl);
PCONFIGURATION_INFORMATION IoGetConfigurationInformation(VOID);
/*
* FUNCTION: Returns a pointer to the callers stack location in the irp
*/
PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(IRP* irp);
PEPROCESS IoGetCurrentProcess(VOID);
NTSTATUS IoGetDeviceObjectPointer(PUNICODE_STRING ObjectName,
ACCESS_MASK DesiredAccess,
PFILE_OBJECT* FileObject,
PDEVICE_OBJECT* DeviceObject);
PDEVICE_OBJECT IoGetDeviceToVerify(PETHREAD Thread);
PGENERIC_MAPPING IoGetFileObjectGenericMapping(VOID);
ULONG IoGetFunctionCodeFromCtlCode(ULONG ControlCode);
PVOID IoGetInitialStack(VOID);
/*
* FUNCTION:
*/
PIO_STACK_LOCATION IoGetNextIrpStackLocation(IRP* irp);
PDEVICE_OBJECT IoGetRelatedDeviceObject(PFILE_OBJECT FileObject);
VOID IoInitializeDpcRequest(PDEVICE_OBJECT DeviceObject,
PIO_DPC_ROUTINE DpcRoutine);
/*
* FUNCTION: Initalizes an irp allocated by the caller
* ARGUMENTS:
* Irp = IRP to initalize
* PacketSize = Size in bytes of the IRP
* StackSize = Number of stack locations in the IRP
*/
VOID IoInitializeIrp(PIRP Irp, USHORT PacketSize, CCHAR StackSize);
NTSTATUS IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
PIO_TIMER_ROUTINE TimerRoutine,
PVOID Context);
BOOLEAN IoIsErrorUserInduced(NTSTATUS Status);
BOOLEAN IoIsTotalDeviceFailure(NTSTATUS Status);
PIRP IoMakeAssociatedIrp(PIRP Irp, CCHAR StackSize);
PHYSICAL_ADDRESS IoMapTransfer(PADAPTER_OBJECT AdapterObject,
PMDL Mdl,
PVOID MapRegisterBase,
PVOID CurrentVa,
PULONG Length,
BOOLEAN WriteToDevice);
/*
* FUNCTION: Marks an IRP as pending
* ARGUMENTS:
* Irp = Irp to mark
* NOTE: If a driver doesn't complete the irp in its dispatch routine it
* must mark it pending otherwise the I/O manager will complete it on
* return from the dispatch routine.
*/
VOID IoMarkIrpPending(PIRP Irp);
NTSTATUS IoQueryDeviceDescription(PINTERFACE_TYPE BusType,
PULONG BusNumber,
PCONFIGURATION_TYPE ControllerType,
PULONG ControllerNumber,
PCONFIGURATION_TYPE PeripheralType,
PULONG PeripheralNumber,
PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
PVOID Context);
VOID IoRaiseHardError(PIRP Irp, PVPB Vpb, PDEVICE_OBJECT RealDeviceObject);
BOOLEAN IoRaiseHardInformationalError(NTSTATUS ErrorStatus,
PUNICODE_STRING String,
PKTHREAD Thread);
NTSTATUS IoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
BOOLEAN ReturnedRecognizedPartitions,
struct _DRIVER_LAYOUT_INFORMATION** PBuffer);
VOID IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
PDRIVER_REINITIALIZE ReinitRoutine,
PVOID Context);
NTSTATUS IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject);
VOID IoReleaseCancelSpinLock(KIRQL Irql);
VOID IoRemoveShareAccess(PFILE_OBJECT FileObject,
PSHARE_ACCESS ShareAccess);
NTSTATUS IoReportResourceUsage(PUNICODE_STRING DriverClassName,
PDRIVER_OBJECT DriverObject,
PCM_RESOURCE_LIST DriverList,
ULONG DriverListSize,
PDEVICE_OBJECT DeviceObject,
PCM_RESOURCE_LIST DeviceList,
ULONG DeviceListSize,
BOOLEAN OverrideConflict,
PBOOLEAN ConflictDetected);
VOID IoRequestDpc(PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context);
PDRIVER_CANCEL IoSetCancelRoutine(PIRP Irp, PDRIVER_CANCEL CancelRoutine);
VOID IoSetCompletionRoutine(PIRP Irp,
PIO_COMPLETION_ROUTINE CompletionRoutine,
PVOID Context,
BOOLEAN InvokeOnSuccess,
BOOLEAN InvokeOnError,
BOOLEAN InvokeOnCancel);
VOID IoSetHardErrorOrVerifyDevice(PIRP Irp, PDEVICE_OBJECT DeviceObject);
VOID IoSetNextIrpStackLocation(PIRP Irp);
NTSTATUS IoSetPartitionInformation(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG PartitionNumber,
ULONG PartitionType);
VOID IoSetShareAccess(ACCESS_MASK DesiredAccess,
ULONG DesiredShareAccess,
PFILE_OBJECT FileObject,
PSHARE_ACCESS ShareAccess);
/*
* FUNCTION: Determines the size of an IRP
* ARGUMENTS:
* StackSize = number of stack locations in the IRP
* RETURNS: The size of the IRP in bytes
*/
USHORT IoSizeOfIrp(CCHAR StackSize);
/*
* FUNCTION: Dequeues the next IRP from the device's associated queue and
* calls its StartIo routine
* ARGUMENTS:
* DeviceObject = Device object
* Cancelable = True if IRPs in the queue can be cancelled
*/
VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable);
VOID IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject,
BOOLEAN Cancelable,
ULONG Key);
/*
* FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
* the device is busy
* ARGUMENTS:
* DeviceObject = Device to pass the IRP to
* Irp = Irp to be processed
* Key = Optional value for where to insert the IRP
* CancelFunction = Entry point for a driver supplied cancel function
*/
VOID IoStartPacket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PULONG Key,
PDRIVER_CANCEL CancelFunction);
VOID IoStartTimer(PDEVICE_OBJECT DeviceObject);
VOID IoStopTimer(PDEVICE_OBJECT DeviceObject);
VOID IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject);
VOID IoUpdateShareAccess(PFILE_OBJECT FileObject, PSHARE_ACCESS ShareAccess);
VOID IoWriteErrorLogEntry(PVOID ElEntry);
NTSTATUS IoWritePartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG SectorsPerTrack,
ULONG NumberOfHeads,
struct _DRIVE_LAYOUT_INFORMATION* PBuffer);

View file

@ -0,0 +1,393 @@
/*
*
*/
#ifndef __INCLUDE_DDK_IOTYPES_H
#define __INCLUDE_DDK_IOTYPES_H
/*
* These are referenced before they can be fully defined
*/
struct _DRIVER_OBJECT;
struct _FILE_OBJECT;
struct _DEVICE_OBJECT;
struct _IRP;
struct _IO_STATUS_BLOCK;
/* SIMPLE TYPES *************************************************************/
typedef ULONG INTERFACE_TYPE;
typedef INTERFACE_TYPE* PINTERFACE_TYPE;
typedef ULONG CONFIGURATION_TYPE;
typedef CONFIGURATION_TYPE* PCONFIGURATION_TYPE;
/*
* FIXME: Definition needed
*/
typedef struct _SHARE_ACCESS
{
} SHARE_ACCESS, *PSHARE_ACCESS;
/* FUNCTION TYPES ************************************************************/
typedef VOID (*PDRIVER_REINITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
PVOID Context,
ULONG Count);
typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
PUNICODE_STRING Pathname,
INTERFACE_TYPE BusType,
ULONG BusNumber,
PKEY_VALUE_FULL_INFORMATION* BI,
CONFIGURATION_TYPE ControllerType,
ULONG ControllerNumber,
PKEY_VALUE_FULL_INFORMATION* CI,
CONFIGURATION_TYPE PeripheralType,
ULONG PeripheralNumber,
PKEY_VALUE_FULL_INFORMATION* PI);
typedef NTSTATUS (*PIO_COMPLETION_ROUTINE)(struct _DEVICE_OBJECT* DeviceObject,
struct _IRP* Irp,
PVOID Context);
typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
struct _IO_STATUS_BLOCK* IoStatusBlock,
ULONG Reserved);
/* STRUCTURE TYPES ***********************************************************/
/*
* PURPOSE: Special timer associated with each device
*/
typedef struct _IO_TIMER
{
} IO_TIMER, PIO_TIMER;
/*
* PURPOSE: IRP stack location
*/
typedef struct _IO_STACK_LOCATION
{
/*
* Type of request
*/
UCHAR MajorFunction;
/*
* Further information about request type
*/
UCHAR MinorFunction;
/*
*
*/
UCHAR Flags;
/*
* FUNCTION: Various flags including for the io completion routine
*/
UCHAR Control;
/*
* Parameters for request
*/
union
{
struct
{
/*
* Number of bytes to be transferrred
*/
ULONG Length;
/*
* Possibly used to sort incoming request (to be documented)
*/
ULONG Key;
/*
* Optional starting offset for read
*/
LARGE_INTEGER ByteOffset;
} Read;
struct
{
ULONG Length;
ULONG Key;
LARGE_INTEGER ByteOffset;
} Write;
struct
{
ULONG OutputBufferLength;
ULONG InputBufferLength;
ULONG IoControlCode;
PVOID Type3InputBuffer;
} DeviceIoControl;
} Parameters;
/*
* PURPOSE: Completion routine
* NOTE: If this is the nth stack location (where the 1st is passed to the
* highest level driver) then this is the completion routine set by
* the (n-1)th driver
*/
PIO_COMPLETION_ROUTINE CompletionRoutine;
PVOID CompletionContext;
BOOLEAN InvokeOnSuccess;
BOOLEAN InvokeOnError;
BOOLEAN InvokeOnCancel;
/*
* Driver created device object representing the target device
*/
struct _DEVICE_OBJECT* DeviceObject;
/*
* File object (if any) associated with DeviceObject
*/
struct _FILE_OBJECT* FileObject;
} IO_STACK_LOCATION, *PIO_STACK_LOCATION;
typedef struct _IO_STATUS_BLOCK
{
/*
* Is the completion status
*/
NTSTATUS Status;
/*
* Is a request dependant value
*/
ULONG Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
/*
* Driver entry point declaration
*/
typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
PUNICODE_STRING RegistryPath);
/*
* Driver cancel declaration
*/
typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject,
PUNICODE_STRING RegistryPath);
typedef struct _IRP
{
PMDL MdlAddress;
ULONG Flags;
union
{
struct _IRP* MasterIrp;
LONG IrpCount;
PVOID SystemBuffer;
} AssociatedIrp;
LIST_ENTRY ThreadListEntry;
IO_STATUS_BLOCK IoStatus;
KPROCESSOR_MODE RequestorMode;
BOOLEAN PendingReturned;
BOOLEAN Cancel;
KIRQL CancelIrql;
PDRIVER_CANCEL CancelRoutine;
PVOID UserBuffer;
PVOID ApcEnvironment;
ULONG AllocationFlags;
PIO_STATUS_BLOCK UserIosb;
PKEVENT UserEvent;
union
{
struct
{
PIO_APC_ROUTINE UserApcRoutine;
PVOID UserApcContext;
} AsynchronousParameters;
LARGE_INTEGER AllocationSize;
} Overlay;
union
{
struct
{
KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
// PETHREAD Thread;
PVOID Thread;
PCHAR AuxiliaryBuffer;
LIST_ENTRY ListEntry;
struct _IO_STACK_LOCATION* CurrentStackLocation;
// PFILE_OBJECT OriginalFileObject;
PVOID OriginalFileObject;
} Overlay;
KAPC Apc;
ULONG CompletionKey;
} Tail;
ULONG CurrentLocation;
IO_STACK_LOCATION Stack[1];
} IRP, *PIRP;
typedef struct _VPB
{
CSHORT Type;
CSHORT Size;
USHORT Flags;
USHORT VolumeLabelLength;
struct _DEVICE_OBJECT* DeviceObject;
struct _DEVICE_OBJECT* RealDevice;
ULONG SerialNumber;
ULONG ReferenceCount;
WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
} VPB, *PVPB;
typedef struct _DEVICE_OBJECT
{
CSHORT Type;
CSHORT Size;
LONG ReferenceCount;
struct _DRIVER_OBJECT* DriverObject;
struct _DEVICE_OBJECT* NextDevice;
struct _DEVICE_OBJECT* AttachedDevice;
struct _IRP* CurrentIrp;
PIO_TIMER Timer;
ULONG Flags;
ULONG Characteristics;
PVPB Vpb;
PVOID DeviceExtension;
DEVICE_TYPE DeviceType;
CCHAR StackSize;
union
{
LIST_ENTRY ListHead;
WAIT_CONTEXT_BLOCK Wcb;
} Queue;
ULONG AlignmentRequirement;
KDEVICE_QUEUE DeviceQueue;
KDPC Dpc;
ULONG ActiveThreadCount;
PSECURITY_DESCRIPTOR SecurityDescriptor;
KEVENT DeviceLock;
USHORT SectorSize;
USHORT Spare1;
struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
PVOID Reserved;
} DEVICE_OBJECT, *PDEVICE_OBJECT;
/*
* Dispatch routine type declaration
*/
typedef NTSTATUS (*PDRIVER_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
/*
* Fast i/o routine type declaration
*/
typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
/*
* Dispatch routine type declaration
*/
typedef NTSTATUS (*PDRIVER_STARTIO)(struct _DEVICE_OBJECT*, IRP*);
/*
* Dispatch routine type declaration
*/
typedef NTSTATUS (*PDRIVER_UNLOAD)(struct _DRIVER_OBJECT*);
typedef struct _DRIVER_EXTENSION
{
struct _DRIVER_OBJECT* DriverObject;
PDRIVER_ADD_DEVICE AddDevice;
ULONG Count;
UNICODE_STRING ServiceKeyName;
} DRIVER_EXTENSION, *PDRIVER_EXTENSION;
typedef struct _DRIVER_OBJECT
{
/*
* PURPOSE: Magic values for debugging
*/
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;
ULONG Flags;
PVOID DriverStart;
ULONG DriverSize;
PVOID DriverSection;
PDRIVER_EXTENSION DriverExtension;
UNICODE_STRING DriverName;
PUNICODE_STRING HardwareDatabase;
PFAST_IO_DISPATCH FastIoDispatch;
PDRIVER_INITIALIZE DriverInit;
PDRIVER_STARTIO DriverStartIo;
PDRIVER_UNLOAD DriverUnload;
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
} DRIVER_OBJECT, *PDRIVER_OBJECT;
typedef struct _FILE_OBJECT
{
PDEVICE_OBJECT DeviceObject;
PVOID FsContext;
} FILE_OBJECT, *PFILE_OBJECT;
typedef struct _CONFIGURATION_INFORMATION
{
ULONG DiskCount;
ULONG FloppyCount;
ULONG CDRomCount;
ULONG TapeCount;
ULONG ScsiPortCount;
ULONG SerialCount;
ULONG ParallelCount;
BOOLEAN AtDiskPrimaryAddressClaimed;
BOOLEAN AtDiskSecondaryAddressClaimed;
} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
typedef VOID (*PIO_DPC_ROUTINE)(PKDPC Dpc,
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context);
typedef VOID (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
PVOID Context);
#if PKEY_VALUE_FULL_INFORMATION_DEFINED
typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
PUNICODE_STRING PathName,
INTERFACE_TYPE BusType,
ULONG BusNumber,
PKEY_VALUE_FULL_INFORMATION* BusKey,
CONFIGURATION_TYPE ControllerType,
ULONG ControllerNumber,
PKEY_VALUE_FULL_INFORMATION* CtrlKey,
CONFIGURATION_TYPE PeripheralType,
ULONG PeripheralNumber,
PKEY_VALUE_FULL_INFORMATION* PrphKey);
#endif
#if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
typedef struct _PARTITION_INFORMATION
{
LARGE_INTEGER StartingOffset;
LARGE_INTEGER PartitionLength;
ULONG HiddenSectors;
ULONG PartitionNumber;
UCHAR PartitionType;
BOOLEAN BootIndicator;
BOOLEAN RecognizedPartition;
BOOLEAN RewritePartition;
} PARTITION_INFORMATION, *PPARTITION_INFORMATION;
#endif
typedef struct _DRIVER_LAYOUT_INFORMATION
{
ULONG PartitionCount;
ULONG Signature;
PARTITION_INFORMATION PartitionEntry[1];
} DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
#endif __INCLUDE_DDK_IOTYPES_H

View file

@ -0,0 +1,124 @@
/* KERNEL FUNCTIONS ********************************************************/
VOID KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql);
VOID KeAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock);
BOOLEAN KeCancelTimer(PKTIMER Timer);
VOID KeClearEvent(PKEVENT Event);
NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable,
PLARGE_INTEGER Internal);
BOOLEAN KeDeregisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD
CallbackRecord);
VOID KeEnterCriticalRegion(VOID);
VOID KeFlushIoBuffers(PMDL Mdl, BOOLEAN ReadOperation, BOOLEAN DmaOperation);
KIRQL KeGetCurrentIrql(VOID);
ULONG KeGetCurrentProcessorNumber(VOID);
ULONG KeGetDcacheFillSize(VOID);
VOID KeInitializeCallbackRecord(PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
VOID KeInitializeDeviceQueue(PKDEVICE_QUEUE DeviceQueue);
VOID KeInitializeDpc(PKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine,
PVOID DeferredContext);
VOID KeInitializeEvent(PKEVENT Event, EVENT_TYPE Type, BOOLEAN State);
VOID KeInitializeMutex(PKMUTEX Mutex, ULONG Level);
VOID KeInitializeSemaphore(PKSEMAPHORE Semaphore, LONG Count, LONG Limit);
VOID KeInitializeTimer(PKTIMER Timer);
VOID KeInitializeTimerEx(PKTIMER Timer, TIMER_TYPE Type);
BOOLEAN KeInsertByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
PKDEVICE_QUEUE_ENTRY DeviceQueueEntry,
ULONG SortKey);
BOOLEAN KeInsertDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
BOOLEAN KeInsertQueueDpc(PKDPC Dpc, PVOID SystemArgument1,
PVOID SystemArgument2);
VOID KeLeaveCriticalRegion(VOID);
VOID KeLowerIrql(KIRQL NewIrql);
LARGE_INTEGER KeQueryPerformanceCounter(PLARGE_INTEGER PerformanceFrequency);
VOID KeQuerySystemTime(PLARGE_INTEGER CurrentTime);
VOID KeQueryTickCount(PLARGE_INTEGER TickCount);
ULONG KeQueryTimeIncrement(VOID);
VOID KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql);
LONG KeReadStateEvent(PKEVENT Event);
LONG KeReadStateMutex(PKMUTEX Mutex);
LONG KeReadStateSemaphore(PKSEMAPHORE Semaphore);
BOOLEAN KeReadStateTimer(PKTIMER Timer);
BOOLEAN KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
PVOID Buffer,
ULONG Length,
PUCHAR Component);
LONG KeReleaseMutex(PKMUTEX Mutex, BOOLEAN Wait);
LONG KeReleaseSemaphore(PKSEMAPHORE Semaphore, KPRIORITY Increment,
LONG Adjustment, BOOLEAN Wait);
VOID KeReleaseSpinLock(PKSPIN_LOCK Spinlock, KIRQL NewIrql);
VOID KeReleaseSpinLockFromDpcLevel(PKSPIN_LOCK Spinlock);
PKDEVICE_QUEUE_ENTRY KeRemoveByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
ULONG SortKey);
PKDEVICE_QUEUE_ENTRY KeRemoveDeviceQueue(PKDEVICE_QUEUE DeviceQueue);
BOOLEAN KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
BOOLEAN KeRemoveQueueDpc(PKDPC Dpc);
LONG KeResetEvent(PKEVENT Event);
LONG KeSetBasePriorityThread(PKTHREAD Thread, LONG Increment);
LONG KeSetEvent(PKEVENT Event, KPRIORITY Increment, BOOLEAN Wait);
KPRIORITY KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority);
BOOLEAN KeSetTimer(PKTIMER Timer, LARGE_INTEGER DueTime, PKDPC Dpc);
BOOLEAN KeSetTimerEx(PKTIMER Timer, LARGE_INTEGER DueTime, LONG Period,
PKDPC Dpc);
VOID KeStallExecutionProcessor(ULONG MicroSeconds);
BOOLEAN KeSynchronizeExecution(PKINTERRUPT Interrupt,
PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
PVOID SynchronizeContext);
NTSTATUS KeWaitForMultipleObjects(ULONG Count,
PVOID Object[],
WAIT_TYPE WaitType,
KWAIT_REASON WaitReason,
KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable,
PLARGE_INTEGER Timeout,
PKWAIT_BLOCK WaitBlockArray);
NTSTATUS KeWaitForMutexObject(PKMUTEX Mutex, KWAIT_REASON WaitReason,
KPROCESSOR_MODE WaitMode, BOOLEAN Alertable,
PLARGE_INTEGER Timeout);
NTSTATUS KeWaitForSingleObject(PVOID Object, KWAIT_REASON WaitReason,
KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable, PLARGE_INTEGER Timeout);
/*
* FUNCTION: Initializes a spinlock
* ARGUMENTS:
* SpinLock = Spinlock to initialize
*/
VOID KeInitializeSpinLock(PKSPIN_LOCK SpinLock);
/*
* FUNCTION: Sets the current irql without altering the current processor
* state
* ARGUMENTS:
* newlvl = IRQ level to set
* NOTE: This is for internal use only
*/
VOID KeSetCurrentIrql(KIRQL newlvl);
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
* ARGUMENTS:
* BugCheckCode = Specifies the reason for the bug check
* BugCheckParameter[1-4] = Additional information about bug
* RETURNS: Doesn't
*/
VOID KeBugCheckEx(ULONG BugCheckCode,
ULONG BugCheckParameter1,
ULONG BugCheckParameter2,
ULONG BugCheckParameter3,
ULONG BugCheckParameter4);
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
* ARGUMENTS:
* BugCheckCode = Specifies the reason for the bug check
* RETURNS: Doesn't
*/
VOID KeBugCheck(ULONG BugCheckCode);

View file

@ -0,0 +1,141 @@
typedef LONG KPRIORITY;
typedef VOID (*PKBUGCHECK_CALLBACK_ROUTINE)(PVOID Buffer, ULONG Length);
typedef BOOLEAN (*PKSYNCHRONIZE_ROUTINE)(PVOID SynchronizeContext);
typedef struct
{
} KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
typedef struct
{
} KMUTEX, *PKMUTEX;
typedef struct
{
} KSEMAPHORE, *PKSEMAPHORE;
typedef struct
{
} KTHREAD, *PKTHREAD;
/*
* PURPOSE: Included in every object that a thread can wait on
*/
typedef struct
{
/*
* PURPOSE: True if the object is signaling a change of state
*/
BOOLEAN signaled;
/*
* PURPOSE: Head of the queue of threads waiting on this object
*/
LIST_ENTRY wait_queue_head;
/*
* PURPOSE: True if all the threads waiting should be woken when the
* object changes state
*/
BOOLEAN wake_all;
} DISPATCHER_HEADER, *PDISPATCHER_HEADER;
/*
* PURPOSE: Describes an event
*/
typedef struct _KEVENT
{
/*
* PURPOSE: So we can use the general wait routine
*/
DISPATCHER_HEADER hdr;
/*
* PURPOSE: Type of event, notification or synchronization
*/
EVENT_TYPE type;
} KEVENT, *PKEVENT;
typedef struct _KSPIN_LOCK
{
KIRQL irql;
} KSPIN_LOCK, *PKSPIN_LOCK;
typedef struct
{
} KAPC;
typedef struct
{
} UNICODE_STRING;
typedef VOID (*PDRIVER_ADD_DEVICE)(VOID);
struct _KDPC;
/*
* PURPOSE: Defines a delayed procedure call routine
* NOTE:
* Dpc = The associated DPC object
* DeferredContext = Driver defined context for the DPC
* SystemArgument[1-2] = Undocumented.
*
*/
typedef VOID (*PKDEFERRED_ROUTINE)(struct _KDPC* Dpc, PVOID DeferredContext,
PVOID SystemArgument1, PVOID SystemArgument2);
typedef struct _KDPC
/*
* PURPOSE: Defines a delayed procedure call object
*/
{
/*
* PURPOSE: Magic value to check this is the current object type
*/
SHORT Type;
/*
* PURPOSE: Target processor or zero if untargetted
*/
UCHAR Number;
/*
* PURPOSE: Indication of desired latency before exection
*/
UCHAR Importance;
LIST_ENTRY DpcListEntry;
PKDEFERRED_ROUTINE DeferredRoutine;
PVOID DeferredContext;
PVOID SystemArgument1;
PVOID SystemArgument2;
/*
* PURPOSE: If non-zero then already in queue
*/
PULONG Lock;
} KDPC, *PKDPC;
typedef struct _KDEVICE_QUEUE
{
LIST_ENTRY ListHead;
BOOLEAN Busy;
KSPIN_LOCK Lock;
} KDEVICE_QUEUE, *PKDEVICE_QUEUE;
typedef struct _KDEVICE_QUEUE_ENTRY
{
LIST_ENTRY Entry;
ULONG Key;
} KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY;
typedef struct _WAIT_CONTEXT_BLOCK
{
} WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;

View file

@ -0,0 +1,285 @@
/* MEMORY MANAGMENT ******************************************************/
/*
* FUNCTION: Determines if the given virtual address is page aligned
*/
#define IS_PAGE_ALIGNED(Va) (((ULONG)Va)&0xfff)
/*
* PURPOSE: Returns the byte offset of a field within a structure
*/
#define FIELD_OFFSET(Type,Field) (LONG)(&(((Type *)(0))->Field))
/*
* PURPOSE: Returns the base address structure if the caller knows the
* address of a field within the structure
* ARGUMENTS:
* Address = address of the field
* Type = Type of the whole structure
* Field = Name of the field whose address is none
*/
#define CONTAINING_RECORD(Address,Type,Field) (Type *)(((LONG)Address) - FIELD_OFFSET(Type,Field))
/*
* FUNCTION: Returns the number of pages spanned by an address range
* ARGUMENTS:
* Va = start of range
* Size = Size of range
* RETURNS: The number of pages
*/
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va, Size)
/*
* FUNCTION: Returns FALSE is the pointer is NULL, TRUE otherwise
*/
#define ARGUMENT_PRESENT(arg) ((arg)!=NULL)
/*
* FUNCTION: Returns the byte offset of the address within its page
*/
#define BYTE_OFFSET(va) (((ULONG)va)%PAGESIZE)
/*
* FUNCTION: Takes a count in bytes and returns the number of pages
* required to hold it
*/
#define BYTES_TO_PAGES(size) (?)
/*
* FUNCTION: Allocates a range of physically contiguous cache aligned
* memory from the non-paged pool
* ARGUMENTS:
* NumberOfBytes = Size of the memory block to allocate
* HighestAcceptableAddress = Highest address valid for the caller
* RETURNS: The virtual address of the memory block on success
* NULL on error
*/
PVOID MmAllocateContiguousMemory(ULONG NumberOfBytes,
PHYSICAL_ADDRESS HighestAcceptableAddress);
/*
* FUNCTION: Allocates a virtual address range of noncached and cache
* aligned memory
* ARGUMENTS:
* NumberOfBytes = Size of region to allocate
* RETURNS: The base address of the range on success
* NULL on failure
*/
PVOID MmAllocateNonCachedMemory(ULONG NumberOfBytes);
/*
* FUNCTION: Fills in the corresponding physical page array for a given MDL
* for a buffer in nonpaged system space
* ARGUMENTS:
* MemoryDescriptorList = MDL to fill
*/
VOID MmBuildMdlForNonPagedPool(PMDL MemoryDescriptorList);
/*
* FUNCTION: Allocates and initializes an MDL
* ARGUMENTS:
* MemoryDescriptorList = Optional caller allocated MDL to initalize
* Base = Base virtual address for buffer
* Length = Length in bytes of the buffer
* RETURNS: A pointer to the initalized MDL
*/
PMDL MmCreateMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length);
/*
* FUNCTION: Releases a range of physically contiguous memory allocated
* with MmAllocateContiguousMemory
* ARGUMENTS:
* BaseAddress = Vritual address of the memory to be freed
*/
VOID MmFreeContiguousMemory(PVOID BaseAddress);
/*
* FUNCTION: Releases a range of noncached memory allocated with
* MmAllocateNonCachedMemory
* ARGUMENTS:
* BaseAddress = Virtual address to be freed
* NumberOfBytes = size of the region to be freed
*/
VOID MmFreeNonCachedMemory(PVOID BaseAddress, ULONG NumberOfBytes);
/*
* FUNCTION: Returns the length in bytes of a buffer described by an MDL
* ARGUMENTS:
* Mdl = the mdl
* RETURNS: Size of the buffer
*/
ULONG MmGetMdlByteCount(PMDL Mdl);
/*
* FUNCTION: Returns the byte offset within a page of the buffer described
* by an MDL
* ARGUMENTS:
* Mdl = the mdl
* RETURNS: The offset in bytes
*/
ULONG MmGetMdlByteOffset(PMDL Mdl);
/*
* FUNCTION: Returns the initial virtual address for a buffer described
* by an MDL
* ARGUMENTS:
* Mdl = the mdl
* RETURNS: The initial virtual address
*/
PVOID MmGetMdlVirtualAddress(PMDL Mdl);
/*
* FUNCTION: Returns the physical address corresponding to a given valid
* virtual address
* ARGUMENTS:
* BaseAddress = the virtual address
* RETURNS: The physical address
*/
PHYSICAL_ADDRESS MmGetPhysicalAddress(PVOID BaseAddress);
/*
* FUNCTION: Maps the physical pages described by an MDL into system space
* ARGUMENTS:
* Mdl = mdl
* RETURNS: The base system address for the mapped buffer
*/
PVOID MmGetSystemAddressForMdl(PMDL Mdl);
/*
* FUNCTION: Initalizes an mdl
* ARGUMENTS:
* MemoryDescriptorList = MDL to be initalized
* BaseVa = Base virtual address of the buffer
* Length = Length in bytes of the buffer
*/
VOID MmInitalizeMdl(PMDL MemoryDescriptorList, PVOID BaseVa, ULONG Length);
/*
* FUNCTION: Checks whether an address is valid for read/write
* ARGUMENTS:
* VirtualAddress = address to be check
* RETURNS: TRUE if an access would be valid
*/
BOOLEAN MmIsAddressValid(PVOID VirtualAddress);
/*
* FUNCTION: Checks if the current platform is a workstation or a server
* RETURNS: If the system is a server returns true
* NOTE: Drivers can use this as an estimate of the likely resources
* available
*/
BOOLEAN MmIsThisAnAsSystem(VOID);
/*
* FUNCTION: Locks a section of the driver's code into memory
* ARGUMENTS:
* AddressWithinSection = Any address in the region
* RETURNS: A handle to the region
*/
PVOID MmLockPagableCodeSection(PVOID AddressWithinSection);
/*
* FUNCTION: Locks a section of the driver's data into memory
* ARGUMENTS:
* AddressWithinSection = Any address in the region
* RETURNS: A handle to the region
*/
PVOID MmLockPagableDataSection(PVOID AddressWithinSection);
/*
* FUNCTION: Locks a section of memory
* ARGUMENTS:
* ImageSectionHandle = handle returned from MmLockPagableCodeSection
* or MmLockPagableDataSection
*/
VOID MmLockPagableSectionByHandle(PVOID ImageSectionHandle);
/*
* FUNCTION: Maps a physical memory range into system space
* ARGUMENTS:
* PhysicalAddress = First physical address to map
* NumberOfBytes = Number of bytes to map
* CacheEnable = TRUE if the range can be cached
* RETURNS: The base virtual address which maps the region
*/
PVOID MmMapIoSpace(PHYSICAL_ADDRESS PhysicalAddress, ULONG NumberOfBytes,
BOOLEAN CacheEnable);
/*
* FUNCTION: Maps the pages described by a given MDL
* ARGUMENTS:
* MemoryDescriptorList = MDL updated by MmProbeAndLockPages
* AccessMode = Access mode in which to map the MDL
* RETURNS: The base virtual address which maps the buffer
*/
PVOID MmMapLockedPages(PMDL MemoryDescriptorList, KPROCESSOR_MODE AccessMode);
/*
* FUNCTION: Makes the whole driver pageable
* ARGUMENTS:
* AddressWithinSection = Any address within the driver
*/
VOID MmPageEntireDriver(PVOID AddressWithinSection);
/*
* FUNCTION: Resets the pageable status of a driver's sections to their
* compile time settings
* ARGUMENTS:
* AddressWithinSection = Any address within the driver
*/
VOID MmResetDriverPaging(PVOID AddressWithinSection);
/*
* FUNCTION: Reinitializes a caller-allocated MDL
* ARGUMENTS:
* Mdl = Points to the MDL that will be reused
*/
VOID MmPrepareMdlForReuse(PMDL Mdl);
/*
* FUNCTION: Probes the specified pages, makes them resident and locks
* the physical pages mapped by the virtual address range
* ARGUMENTS:
* MemoryDescriptorList = MDL which supplies the virtual address,
* byte offset and length
* AccessMode = Access mode with which to probe the arguments
* Operation = Types of operation for which the pages should be
* probed
*/
VOID MmProbeAndLockPages(PMDL MemoryDescriptorList,
KPROCESSOR_MODE AccessMode,
LOCK_OPERATION Operation);
/*
* FUNCTION: Returns an estimate of the amount of memory in the system
* RETURNS: Either MmSmallSystem, MmMediumSystem or MmLargeSystem
*/
MM_SYSTEM_SIZE MmQuerySystemSize(VOID);
/*
* FUNCTION: Returns the number of bytes to allocate for an MDL
* describing a given address range
* ARGUMENTS:
* Base = Base virtual address for the region
* Length = size in bytes of the region
* RETURNS: The number of bytes required for the MDL
*/
ULONG MmSizeOfMdl(PVOID Base, ULONG Length);
/*
* FUNCTION: Unlocks the physical pages described by a given MDL
* ARGUMENTS:
* Mdl = Mdl to unlock
*/
VOID MmUnlockPages(PMDL Mdl);
/*
* FUNCTION: Releases a section of driver code or data previously locked into
* memory
* ARGUMENTS:
* ImageSectionHandle = Handle for the locked section
*/
VOID MmUnlockPagableImageSection(PVOID ImageSectionHandle);
VOID MmUnmapIoSpace(PVOID BaseAddress, ULONG NumberOfBytes);
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList);

View file

@ -0,0 +1,24 @@
typedef struct _MDL
/*
* PURPOSE: Describes a user buffer passed to a system API
*/
{
/*
* Base address of the buffer in user mode
*/
PVOID Base;
/*
* Length of the buffer in bytes
*/
ULONG Length;
/*
* System address of buffer or NULL if not mapped
*/
PVOID SysBase;
/*
* Below this is a variable length list of page physical address
*/
} MDL, *PMDL;

View file

@ -0,0 +1,41 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/ddk/ntddk.h
* PURPOSE: Interface definitions for drivers
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* 15/05/98: Created
*/
#ifndef __NTDDK_H
#define __NTDDK_H
#ifdef __cplusplus
extern "C"
{
#endif
/* INCLUDES ***************************************************************/
#include <windows.h>
#include <internal/hal/page.h>
#include <ddk/defines.h>
#include <ddk/types.h>
#include <ddk/structs.h>
#include <internal/hal/ddk.h>
#include <ddk/rtl.h>
#include <ddk/zw.h>
#include <ddk/exfuncs.h>
#include <ddk/mmfuncs.h>
#include <ddk/kefuncs.h>
#include <ddk/iofuncs.h>
#include <ddk/psfuncs.h>
#ifdef __cplusplus
};
#endif
#endif /* __NTDDK_H */

View file

@ -0,0 +1,44 @@
/* OBJECT MANAGER ************************************************************/
/*
* FUNCTION: Decrements the object's reference count and performs retention
* checks
* ARGUMENTS:
* Object = Object's body
*/
VOID ObDeferenceObject(PVOID Object);
/*
* FUNCTION: Performs access validation on an object handle and if access
* is granted returns a pointer to the object's body
* ARGUMENTS:
* Handle = Handle to the object
* DesiredAccess = Desired access to the object
* ObjectType (OPTIONAL) = Pointer to the object's type definition
* AccessMode = Access mode to use for the check
* Object (OUT) = Caller supplied storage for a pointer to the object's
* body
* HandleInformation (OUT) = Points to a structure which receives
* information about the handle
* RETURNS: Status
*/
NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode,
PVOID* Object,
POBJECT_HANDLE_INFORMATION HandleInfo);
/*
* FUNCTION: Increments the reference count for a given object
* ARGUMENTS:
* Object = Points to the body of the object
* AccessMode = Requested access to the object
* ObjectType = Pointer to the object's type definition
* AccessMode = Access mode to use for the security check
* RETURNS: Status
*/
NTSTATUS ObReferenceObjectByPointer(PVOID Object,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode);

View file

@ -0,0 +1,149 @@
struct _DIRECTORY_OBJECT;
typedef struct _OBJECT_HANDLE_INFORMATION {
ULONG HandleAttributes;
ACCESS_MASK GrantedAccess;
} OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
struct _OBJECT;
typedef struct _OBJECT_TYPE
{
/*
* PURPOSE: Name of the type
*/
LPCSTR TypeName;
/*
* PURPOSE: Total number of objects of this type
*/
ULONG TotalObjects;
/*
* PURPOSE: Total number of handles of this type
*/
ULONG TotalHandles;
/*
* PURPOSE: Maximum objects of this type
*/
ULONG MaxObjects;
/*
* PURPOSE: Maximum handles of this type
*/
ULONG MaxHandles;
/*
* PURPOSE: Paged pool charge
*/
ULONG PagedPoolCharge;
/*
* PURPOSE: Nonpaged pool charge
*/
ULONG NonpagedPoolCharge;
/*
* PURPOSE: Dumps the object
* NOTE: To be defined
*/
VOID (*Dump)(VOID);
/*
* PURPOSE: Opens the object
* NOTE: To be defined
*/
VOID (*Open)(VOID);
/*
* PURPOSE: Called to close an object if OkayToClose returns true
*/
VOID (*Close)(VOID);
/*
* PURPOSE: Called to close an object if OkayToClose returns true
*/
VOID (*Delete)(VOID);
/*
* PURPOSE: Called when an open attempts to open a file apparently
* residing within the object
*/
VOID (*Parse)(VOID);
/*
*/
VOID (*Security)(VOID);
/*
*/
VOID (*QueryName)(VOID);
/*
* PURPOSE: Called when a process asks to close the object
*/
VOID (*OkayToClose)(VOID);
} OBJECT_TYPE, *POBJECT_TYPE;
typedef struct _OBJECT
/*
* PURPOSE: Header for every object managed by the object manager
*/
{
/*
* PURPOSE: Name of this entry
*/
LPCSTR name;
/*
* PURPOSE: Our entry in our parents list of subdirectory
*/
LIST_ENTRY entry;
/*
* PURPOSE: Number of non-handle references to this object
*/
ULONG RefCount;
/*
* PURPOSE: Number of handles opened to this object
*/
ULONG HandleCount;
/*
* PURPOSE: Object type
* NOTE: This overlaps the first member of the object body
*/
CSHORT Type;
/*
* PURPOSE: Object size
* NOTE: This overlaps the second member of the object body
*/
CSHORT Size;
} OBJECT_HEADER, *POBJECT_HEADER;
/*
* PURPOSE: Defines an object
*/
typedef struct _OBJECT_ATTRIBUTES
{
ULONG Length;
/*
* PURPOSE: Attributes of the object
*/
ULONG Attributes;
//SECURITY_DESCRIPTOR SecurityDescriptor
//SecurityQualityOfService
struct _DIRECTORY_OBJECT* parent;
char* name;
char* path;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;

View file

@ -0,0 +1,27 @@
typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
/*
* FUNCTION: Creates a thread which executes in kernel mode
* ARGUMENTS:
* ThreadHandle (OUT) = Caller supplied storage for the returned thread
* handle
* DesiredAccess = Requested access to the thread
* ObjectAttributes = Object attributes (optional)
* ProcessHandle = Handle of process thread will run in
* NULL to use system process
* ClientId (OUT) = Caller supplied storage for the returned client id
* of the thread (optional)
* StartRoutine = Entry point for the thread
* StartContext = Argument supplied to the thread when it begins
* execution
* RETURNS: Success or failure status
*/
NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
HANDLE ProcessHandle,
PCLIENT_ID ClientId,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext);

View file

@ -0,0 +1,111 @@
#ifndef __INCLUDE_DDK_PSTYPES_H
#define __INCLUDE_DDK_PSTYPES_H
#include <kernel32/heap.h>
typedef struct _CLIENT_ID
{
HANDLE UniqueProcess;
HANDLE UniqueThread;
} CLIENT_ID, *PCLIENT_ID;
//typedef void* HEAP;
typedef void* HANDLE_TABLE;
typedef void* ATOMTABLE;
typedef struct _pPebInfo {
LPWSTR lpCommandLine;
DWORD cb;
HANDLE hStdInput; //18
HANDLE hStdput;
HANDLE hStdError;
LPWSTR lpEnvironment;
DWORD dwX;
DWORD dwY;
DWORD dwXSize;
DWORD dwYSize;
DWORD dwXCountChars;
DWORD dwYCountChars;
DWORD dwFillAttribute;
DWORD dwFlags;
DWORD wShowWindow;
LPTSTR lpTitle;
LPTSTR lpDesktop;
LPTSTR reserved;
DWORD cbReserved2;
LPTSTR lpReserved1;
} PEBINFO;
typedef struct _NT_PEB
{
LONG ImageBaseAddress;
DWORD nActiveStdHandle;
void *HeapIndex;
DWORD dwTlsBits[2]; // tls in use bits
WORD NumberOfProcessors;
WORD NtGlobalFlag;
DWORD dwCriticalSectionTime;
DWORD dwHeapReserve;
DWORD dwHeapCommit;
DWORD dwHeapDecommitFreeBlockThreshold;
DWORD dwNumberOfHeaps;
DWORD dwMaxiumNumberOfHeaps;
PEBINFO *pPebInfo;
HEAP *pProcessHeap;
HANDLE_TABLE htGDISharedHandleTable;
ATOMTABLE LocalAtomTable;
CRITICAL_SECTION *pCriticalSection;
WORD wMajorVersion;
WORD wMinorVersion;
WORD wBuildNumber;
WORD wPlatformId;
} NT_PEB;
typedef NT_PEB *PPEB;
typedef struct _NT_TIB {
struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
PVOID StackBase;
PVOID StackLimit;
PVOID SubSystemTib;
union {
PVOID FiberData;
ULONG Version;
} s;
PVOID ArbitraryUserPointer;
struct _NT_TIB *Self;
} NT_TIB, *PNT_TIB;
typedef struct _NT_TEB
{
NT_TIB Tib;
DWORD dwProcessId;
DWORD dwThreadId;
HANDLE hRPC;
NT_PEB *pPeb;
DWORD dwErrCode;
WORD nMutexCount;
LCID Locale;
//HQUEUE MessageQueue
DWORD dwTlsIndex ;
LPVOID TlsData[512];
} NT_TEB;
typedef NT_TEB *PINITIAL_TEB;
typedef struct _EPROCESS
{
} EPROCESS, *PEPROCESS;
typedef struct _ETHREAD
{
} ETHREAD, *PETHREAD;
#endif /* __INCLUDE_DDK_PSTYPES_H */

184
reactos/include/ddk/rtl.h Normal file
View file

@ -0,0 +1,184 @@
/*
*
*/
#ifndef __DDK_RTL_H
#define __DDK_RTL_H
typedef struct _TIME_FIELDS
{
CSHORT Year;
CSHORT Month;
CSHORT Day;
CSHORT Hour;
CSHORT Minute;
CSHORT Second;
CSHORT Milliseconds;
CSHORT Weekday;
} TIME_FIELDS, *PTIME_FIELDS;
/*
* PURPOSE: Flags for RtlQueryRegistryValues
*/
enum
{
RTL_QUERY_REGISTRY_SUBKEY,
RTL_QUERY_REGISTRY_TOPKEY,
RTL_QUERY_REGISTRY_REQUIRED,
RTL_QUERY_REGISTRY_NOVALUE,
RTL_QUERY_REGISTRY_NOEXPAND,
RTL_QUERY_REGISTRY_DIRECT,
RTL_QUERY_REGISTRY_DELETE,
};
typedef NTSTATUS (*PRTL_QUERY_REGISTRY_ROUTINE)(PWSTR ValueName,
ULONG ValueType,
PVOID ValueData,
ULONG ValueLength,
PVOID Context,
PVOID EntryContext);
typedef struct _RTL_QUERY_REGISTRY_TABLE
{
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
ULONG Flags;
PWSTR Name;
PVOID EntryContext;
ULONG DefaultType;
PVOID DefaultData;
ULONG DefaultLength;
} RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
/*
* PURPOSE: Used with RtlCheckRegistryKey, RtlCreateRegistryKey,
* RtlDeleteRegistryKey
*/
enum
{
RTL_REGISTRY_ABSOLUTE,
RTL_REGISTRY_SERVICES,
RTL_REGISTRY_CONTROL,
RTL_REGISTRY_WINDOWS_NT,
RTL_REGISTRY_DEVICEMAP,
RTL_REGISTRY_USER,
RTL_REGISTRY_OPTIONAL,
RTL_REGISTRY_VALUE,
};
/*
* FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a
* subsequent call to ZwCreateXXX or ZwOpenXXX
* ARGUMENTS:
* InitializedAttributes (OUT) = Caller supplied storage for the
* object attributes
* ObjectName = Full path name for object
* Attributes = Attributes for the object
* RootDirectory = Where the object should be placed or NULL
* SecurityDescriptor = Ignored
*/
VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
PUNICODE_STRING ObjectName,
ULONG Attributes,
HANDLE RootDirectory,
PSECURITY_DESCRIPTOR SecurityDescriptor);
VOID InitializeListHead(PLIST_ENTRY ListHead);
VOID InsertHeadList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
VOID InsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
BOOLEAN IsListEmpty(PLIST_ENTRY ListHead);
PSINGLE_LIST_ENTRY PopEntryList(PSINGLE_LIST_ENTRY ListHead);
VOID PushEntryList(PSINGLE_LIST_ENTRY ListHead, PSINGLE_LIST_ENTRY Entry);
VOID RemoveEntryList(PLIST_ENTRY Entry);
PLIST_ENTRY RemoveHeadList(PLIST_ENTRY ListHead);
PLIST_ENTRY RemoveTailList(PLIST_ENTRY ListHead);
ULONG RtlAnsiStringToUnicodeSize(PANSI_STRING AnsiString);
NTSTATUS RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString,
PANSI_STRING SourceString,
BOOLEAN AllocateDestinationString);
NTSTATUS RtlAppendUnicodeStringToString(PUNICODE_STRING Destination,
PUNICODE_STRING Source);
NTSTATUS RtlAppendUnicodeToString(PUNICODE_STRING Destination,
PWSTR Source);
NTSTATUS RtlCharToInteger(PCSZ String, ULONG Base, PULONG Value);
NTSTATUS RtlCheckRegistryKey(ULONG RelativeTo, PWSTR Path);
ULONG RtlCompareMemory(PVOID Source1, PVOID Source2, ULONG Length);
LONG RtlCompareString(PSTRING String1, PSTRING String2,
BOOLEAN CaseInsensitive);
LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
PUNICODE_STRING String2,
BOOLEAN BaseInsensitive);
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length);
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
VOID RtlCopyUnicodeString(PUNICODE_STRING DestinationString,
PUNICODE_STRING SourceString);
NTSTATUS RtlCreateRegistryKey(ULONG RelativeTo,
PWSTR Path);
NTSTATUS RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
ULONG Revision);
NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo,
PWSTR Path,
PWSTR ValueName);
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
LONG Multiplier);
ULONG RtlEnlargedUnsignedDivide(ULARGE_INTEGER Dividend,
ULONG Divisor,
PULONG Remainder);
LARGE_INTEGER RtlEnlargedUnsignedMultiply(ULONG Multiplicand,
ULONG Multiplier);
BOOLEAN RtlEqualString(PSTRING String1,
PSTRING String2,
BOOLEAN CaseInSensitive);
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1,
PUNICODE_STRING String2,
BOOLEAN CaseInSensitive);
LARGE_INTEGER RtlExtendedIntegerMultiply(LARGE_INTEGER Multiplicand,
LONG Multiplier);
LARGE_INTEGER RtlExtendedLargeIntegerDivide(LARGE_INTEGER Dividend,
ULONG Divisor,
PULONG Remainder);
LARGE_INTEGER RtlExtendedMagicDivide(LARGE_INTEGER Dividend,
LARGE_INTEGER MagicDivisor,
CCHAR ShiftCount);
VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill);
VOID RtlFreeAnsiString(PANSI_STRING AnsiString);
VOID RtlFreeUnicodeString(PUNICODE_STRING UnicodeString);
VOID RtlInitAnsiString(PANSI_STRING DestinationString,
PCSZ SourceString);
VOID RtlInitString(PSTRING DestinationString, PCSZ SourceString);
VOID RtlInitUnicodeString(PUNICODE_STRING DestinationString,
PCWSTR SourceString);
NTSTATUS RtlIntegerToUnicodeString(ULONG Value,
ULONG Base,
PUNICODE_STRING String);
LARGE_INTEGER RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
LARGE_INTEGER Addend2);
VOID RtlLargeIntegerAnd(PLARGE_INTEGER Result,
LARGE_INTEGER Source,
LARGE_INTEGER Mask);
/* MISSING FUNCTIONS GO HERE */
ULONG RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
VOID RtlMoveMemory(PVOID Destination, CONST VOID* Source, ULONG Length);
NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo,
PWSTR Path,
PRTL_QUERY_REGISTRY_TABLE QueryTable,
PVOID Context, PVOID Environment);
VOID RtlRetrieveUlong(PULONG DestinationAddress,
PULONG SourceAddress);
VOID RtlRetrieveUshort(PUSHORT DestinationAddress,
PUSHORT SourceAddress);
NTSTATUS RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
BOOLEAN DaclPresent,
PACL Dacl,
BOOLEAN DaclDefaulted);
VOID RtlStoreLong(PULONG Address, ULONG Value);
VOID RtlStoreUshort(PUSHORT Address, USHORT Value);
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS TimeFields, PLARGE_INTEGER Time);
VOID RtlTimeToTimeFields(PLARGE_INTEGER Time, PTIME_FIELDS TimeFields);
#endif /* __DDK_RTL_H */

View file

@ -0,0 +1,318 @@
/* SYSTEM STRUCTURES ******************************************************/
#include <internal/hal/hal.h>
#include <ddk/cfgtypes.h>
#include <ddk/ketypes.h>
#include <ddk/obtypes.h>
#include <ddk/mmtypes.h>
#include <ddk/iotypes.h>
#include <ddk/extypes.h>
#include <ddk/pstypes.h>
/*
* PURPOSE: Thread object
*/
typedef struct
{
CSHORT Type;
CSHORT Size;
/*
* PURPOSE: Entry in the linked list of threads
*/
LIST_ENTRY Entry;
/*
* PURPOSE: Current state of the thread
*/
ULONG State;
/*
* PURPOSE: Priority modifier of the thread
*/
ULONG Priority;
/*
* PURPOSE: Pointer to our parent process
*/
// PEPROCESS Parent;
/*
* PURPOSE: Handle of our parent process
*/
HANDLE ParentHandle;
/*
* PURPOSE: Not currently used
*/
ULONG AffinityMask;
/*
* PURPOSE: Saved thread context
*/
hal_thread_state context;
} THREAD_OBJECT, *PTHREAD_OBJECT;
/*
* PURPOSE: Object describing the wait a thread is currently performing
*/
typedef struct
{
/*
* PURPOSE: Pointer to the waiting thread
*/
PTHREAD_OBJECT thread;
/*
* PURPOSE: Entry in the wait queue for the object being waited on
*/
LIST_ENTRY Entry;
/*
* PURPOSE: Pointer to the object being waited on
*/
DISPATCHER_HEADER* wait_object;
} KWAIT_BLOCK, *PKWAIT_BLOCK;
typedef struct _ADAPTER_OBJECT
{
} ADAPTER_OBJECT, *PADAPTER_OBJECT;
typedef struct _CONTROLLER_OBJECT
{
PVOID ControllerExtension;
} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
typedef struct _STRING
{
/*
* Length in bytes of the string stored in buffer
*/
USHORT Length;
/*
* Maximum length of the string
*/
USHORT MaximumLength;
/*
* String
*/
PCHAR Buffer;
} STRING, *PSTRING;
typedef struct _ANSI_STRING
{
/*
* Length in bytes of the string stored in buffer
*/
USHORT Length;
/*
* Maximum length of the string
*/
USHORT MaximumLength;
/*
* String
*/
PCHAR Buffer;
} ANSI_STRING, *PANSI_STRING;
typedef struct _KTIMER
{
/*
* Pointers to maintain the linked list of activated timers
*/
LIST_ENTRY entry;
/*
* Absolute expiration time in system time units
*/
unsigned long long expire_time;
/*
* Optional dpc associated with the timer
*/
PKDPC dpc;
/*
* True if the timer is signaled
*/
BOOLEAN signaled;
/*
* True if the timer is in the system timer queue
*/
BOOLEAN running;
/*
* Type of the timer either Notification or Synchronization
*/
TIMER_TYPE type;
/*
* Period of the timer in milliseconds (zero if once-only)
*/
ULONG period;
} KTIMER, *PKTIMER;
typedef struct _IO_RESOURCE_DESCRIPTOR
{
UCHAR Option;
UCHAR Type;
UCHAR SharedDisposition;
/*
* Reserved for system use
*/
UCHAR Spare1;
USHORT Flags;
/*
* Reserved for system use
*/
UCHAR Spare2;
union
{
struct
{
ULONG Length;
ULONG Alignment;
PHYSICAL_ADDRESS MinimumAddress;
PHYSICAL_ADDRESS MaximumAddress;
} Port;
struct
{
ULONG Length;
ULONG Alignment;
PHYSICAL_ADDRESS MinimumAddress;
PHYSICAL_ADDRESS MaximumAddress;
} Memory;
struct
{
ULONG MinimumVector;
ULONG MaximumVector;
} Interrupt;
struct
{
ULONG MinimumChannel;
ULONG MaximumChannel;
} Dma;
} u;
} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
typedef struct _IO_RESOURCE_LIST
{
USHORT Version;
USHORT Revision;
ULONG Count;
IO_RESOURCE_DESCRIPTOR Descriptors[1];
} IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
typedef struct _IO_RESOURCES_REQUIREMENTS_LIST
{
/*
* List size in bytes
*/
ULONG ListSize;
/*
* System defined enum for the bus
*/
INTERFACE_TYPE InterfaceType;
ULONG BusNumber;
ULONG SlotNumber;
ULONG Reserved[3];
ULONG AlternativeLists;
IO_RESOURCE_LIST List[1];
} IO_RESOURCES_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
typedef struct
{
UCHAR Type;
UCHAR ShareDisposition;
USHORT Flags;
union
{
struct
{
PHYSICAL_ADDRESS Start;
ULONG Length;
} Port;
struct
{
ULONG Level;
ULONG Vector;
ULONG Affinity;
} Interrupt;
struct
{
PHYSICAL_ADDRESS Start;
ULONG Length;
} Memory;
struct
{
ULONG Channel;
ULONG Port;
ULONG Reserved1;
} Dma;
struct
{
ULONG DataSize;
ULONG Reserved1;
ULONG Reserved2;
} DeviceSpecificData;
} u;
} CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
typedef struct
{
USHORT Version;
USHORT Revision;
ULONG Count;
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
} CM_PARTIAL_RESOURCE_LIST;
typedef struct
{
INTERFACE_TYPE InterfaceType;
ULONG BusNumber;
CM_PARTIAL_RESOURCE_LIST PartialResourceList;
} CM_FULL_RESOURCE_DESCRIPTOR;
typedef struct
{
ULONG Count;
CM_FULL_RESOURCE_DESCRIPTOR List[1];
} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
struct _KINTERRUPT;
typedef BOOLEAN (*PKSERVICE_ROUTINE)(struct _KINTERRUPT* Interrupt,
PVOID ServiceContext);
typedef struct _KINTERRUPT
{
ULONG Vector;
KAFFINITY ProcessorEnableMask;
PKSPIN_LOCK IrqLock;
BOOLEAN Shareable;
BOOLEAN FloatingSave;
PKSERVICE_ROUTINE ServiceRoutine;
PVOID ServiceContext;
LIST_ENTRY Entry;
KIRQL SynchLevel;
} KINTERRUPT, *PKINTERRUPT;

View file

@ -0,0 +1,85 @@
#ifndef __DDK_TYPES_H
#define __DDK_TYPES_H
// these should be moved to a file like ntdef.h
typedef const int CINT;
typedef ULONG KAFFINITY;
typedef KAFFINITY *PKAFFINITY;
//typedef LONG KPRIORITY;
typedef LONG NTSTATUS;
typedef ULONG DEVICE_TYPE;
enum
{
DIRECTORY_QUERY,
DIRECTORY_TRAVERSE,
DIRECTORY_CREATE_OBJECT,
DIRECTORY_CREATE_SUBDIRECTORY,
DIRECTORY_ALL_ACCESS,
};
typedef unsigned long long ULONGLONG;
/*
* General type for status information
*/
//typedef LONG NTSTATUS;
/*
* Unicode string type
* FIXME: Real unicode please
*/
typedef char* PUNICODE_STRING;
#if REAL_UNICODE
typedef struct _UNICODE_STRING
{
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
#endif
typedef enum _SECTION_INHERIT {
ViewShare = 1,
ViewUnmap = 2
} SECTION_INHERIT;
/*
* Various other types (all quite pointless)
*/
//typedef ULONG DEVICE_TYPE;
typedef ULONG KPROCESSOR_MODE;
typedef ULONG KIRQL;
typedef KIRQL* PKIRQL;
typedef ULONG IO_ALLOCATION_ACTION;
//typedef ULONG INTERFACE_TYPE;
typedef ULONG POOL_TYPE;
typedef ULONG TIMER_TYPE;
typedef ULONG MM_SYSTEM_SIZE;
typedef ULONG LOCK_OPERATION;
typedef ULONG KEY_INFORMATION_CLASS;
typedef ULONG FILE_INFORMATION_CLASS;
typedef ULONG KEY_VALUE_INFORMATION_CLASS;
//typedef ULONG SECTION_INHERIT;
typedef ULONG EVENT_TYPE;
//typedef ULONG KAFFINITY;
//typedef KAFFINITY* PKAFFINITY;
typedef ULONG PHYSICAL_ADDRESS;
typedef PHYSICAL_ADDRESS* PPHYSICAL_ADDRESS;
typedef ULONG WAIT_TYPE;
typedef ULONG KWAIT_REASON;
typedef ULONG KINTERRUPT_MODE;
typedef USHORT CSHORT;
#endif

1537
reactos/include/ddk/zw.h Normal file

File diff suppressed because it is too large Load diff

5167
reactos/include/defines.h Normal file

File diff suppressed because it is too large Load diff

713
reactos/include/errors.h Normal file
View file

@ -0,0 +1,713 @@
/*
Errors.h
Windows32 API error codes
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
This file is part of the Windows32 API Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
If you are interested in a warranty or support for this source code,
contact Scott Christley <scottc@net-community.com> for more information.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNU_H_WINDOWS32_ERROR
#define _GNU_H_WINDOWS32_ERROR
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Numerical order */
#define LZERROR_UNKNOWNALG (-8)
#define LZERROR_BADVALUE (-7)
#define LZERROR_GLOBLOCK (-6)
#define LZERROR_GLOBALLOC (-5)
#define LZERROR_WRITE (-4)
#define LZERROR_READ (-3)
#define LZERROR_BADOUTHANDLE (-2)
#define LZERROR_BADINHANDLE (-1)
#define NO_ERROR 0L
#define ERROR_SUCCESS 0L
#define ERROR_INVALID_FUNCTION 1L
#define ERROR_FILE_NOT_FOUND 2L
#define ERROR_PATH_NOT_FOUND 3L
#define ERROR_TOO_MANY_OPEN_FILES 4L
#define ERROR_ACCESS_DENIED 5L
#define ERROR_INVALID_HANDLE 6L
#define ERROR_ARENA_TRASHED 7L
#define ERROR_NOT_ENOUGH_MEMORY 8L
#define ERROR_INVALID_BLOCK 9L
#define ERROR_BAD_ENVIRONMENT 10L
#define ERROR_BAD_FORMAT 11L
#define ERROR_INVALID_ACCESS 12L
#define ERROR_INVALID_DATA 13L
#define ERROR_OUTOFMEMORY 14L
#define ERROR_INVALID_DRIVE 15L
#define ERROR_CURRENT_DIRECTORY 16L
#define ERROR_NOT_SAME_DEVICE 17L
#define ERROR_NO_MORE_FILES 18L
#define ERROR_WRITE_PROTECT 19L
#define ERROR_BAD_UNIT 20L
#define ERROR_NOT_READY 21L
#define ERROR_BAD_COMMAND 22L
#define ERROR_CRC 23L
#define ERROR_BAD_LENGTH 24L
#define ERROR_SEEK 25L
#define ERROR_NOT_DOS_DISK 26L
#define ERROR_SECTOR_NOT_FOUND 27L
#define ERROR_OUT_OF_PAPER 28L
#define ERROR_WRITE_FAULT 29L
#define ERROR_READ_FAULT 30L
#define ERROR_GEN_FAILURE 31L
#define ERROR_SHARING_VIOLATION 32L
#define ERROR_LOCK_VIOLATION 33L
#define ERROR_WRONG_DISK 34L
#define ERROR_SHARING_BUFFER_EXCEEDED 36L
#define ERROR_HANDLE_EOF 38L
#define ERROR_HANDLE_DISK_FULL 39L
#define ERROR_NOT_SUPPORTED 50L
#define ERROR_REM_NOT_LIST 51L
#define ERROR_DUP_NAME 52L
#define ERROR_BAD_NETPATH 53L
#define ERROR_NETWORK_BUSY 54L
#define ERROR_DEV_NOT_EXIST 55L
#define ERROR_TOO_MANY_CMDS 56L
#define ERROR_ADAP_HDW_ERR 57L
#define ERROR_BAD_NET_RESP 58L
#define ERROR_UNEXP_NET_ERR 59L
#define ERROR_BAD_REM_ADAP 60L
#define ERROR_PRINTQ_FULL 61L
#define ERROR_NO_SPOOL_SPACE 62L
#define ERROR_PRINT_CANCELLED 63L
#define ERROR_NETNAME_DELETED 64L
#define ERROR_NETWORK_ACCESS_DENIED 65L
#define ERROR_BAD_DEV_TYPE 66L
#define ERROR_BAD_NET_NAME 67L
#define ERROR_TOO_MANY_NAMES 68L
#define ERROR_TOO_MANY_SESS 69L
#define ERROR_SHARING_PAUSED 70L
#define ERROR_REQ_NOT_ACCEP 71L
#define ERROR_REDIR_PAUSED 72L
#define ERROR_FILE_EXISTS 80L
#define ERROR_CANNOT_MAKE 82L
#define ERROR_FAIL_I24 83L
#define ERROR_OUT_OF_STRUCTURES 84L
#define ERROR_ALREADY_ASSIGNED 85L
#define ERROR_INVALID_PASSWORD 86L
#define ERROR_INVALID_PARAMETER 87L
#define ERROR_NET_WRITE_FAULT 88L
#define ERROR_NO_PROC_SLOTS 89L
#define ERROR_TOO_MANY_SEMAPHORES 100L
#define ERROR_EXCL_SEM_ALREADY_OWNED 101L
#define ERROR_SEM_IS_SET 102L
#define ERROR_TOO_MANY_SEM_REQUESTS 103L
#define ERROR_INVALID_AT_INTERRUPT_TIME 104L
#define ERROR_SEM_OWNER_DIED 105L
#define ERROR_SEM_USER_LIMIT 106L
#define ERROR_DISK_CHANGE 107L
#define ERROR_DRIVE_LOCKED 108L
#define ERROR_BROKEN_PIPE 109L
#define ERROR_OPEN_FAILED 110L
#define ERROR_BUFFER_OVERFLOW 111L
#define ERROR_DISK_FULL 112L
#define ERROR_NO_MORE_SEARCH_HANDLES 113L
#define ERROR_INVALID_TARGET_HANDLE 114L
#define ERROR_INVALID_CATEGORY 117L
#define ERROR_INVALID_VERIFY_SWITCH 118L
#define ERROR_BAD_DRIVER_LEVEL 119L
#define ERROR_CALL_NOT_IMPLEMENTED 120L
#define ERROR_SEM_TIMEOUT 121L
#define ERROR_INSUFFICIENT_BUFFER 122L
#define ERROR_INVALID_NAME 123L
#define ERROR_INVALID_LEVEL 124L
#define ERROR_NO_VOLUME_LABEL 125L
#define ERROR_MOD_NOT_FOUND 126L
#define ERROR_PROC_NOT_FOUND 127L
#define ERROR_WAIT_NO_CHILDREN 128L
#define ERROR_CHILD_NOT_COMPLETE 129L
#define ERROR_DIRECT_ACCESS_HANDLE 130L
#define ERROR_NEGATIVE_SEEK 131L
#define ERROR_SEEK_ON_DEVICE 132L
#define ERROR_IS_JOIN_TARGET 133L
#define ERROR_IS_JOINED 134L
#define ERROR_IS_SUBSTED 135L
#define ERROR_NOT_JOINED 136L
#define ERROR_NOT_SUBSTED 137L
#define ERROR_JOIN_TO_JOIN 138L
#define ERROR_SUBST_TO_SUBST 139L
#define ERROR_JOIN_TO_SUBST 140L
#define ERROR_SUBST_TO_JOIN 141L
#define ERROR_BUSY_DRIVE 142L
#define ERROR_SAME_DRIVE 143L
#define ERROR_DIR_NOT_ROOT 144L
#define ERROR_DIR_NOT_EMPTY 145L
#define ERROR_IS_SUBST_PATH 146L
#define ERROR_IS_JOIN_PATH 147L
#define ERROR_PATH_BUSY 148L
#define ERROR_IS_SUBST_TARGET 149L
#define ERROR_SYSTEM_TRACE 150L
#define ERROR_INVALID_EVENT_COUNT 151L
#define ERROR_TOO_MANY_MUXWAITERS 152L
#define ERROR_INVALID_LIST_FORMAT 153L
#define ERROR_LABEL_TOO_LONG 154L
#define ERROR_TOO_MANY_TCBS 155L
#define ERROR_SIGNAL_REFUSED 156L
#define ERROR_DISCARDED 157L
#define ERROR_NOT_LOCKED 158L
#define ERROR_BAD_THREADID_ADDR 159L
#define ERROR_BAD_ARGUMENTS 160L
#define ERROR_BAD_PATHNAME 161L
#define ERROR_SIGNAL_PENDING 162L
#define ERROR_MAX_THRDS_REACHED 164L
#define ERROR_LOCK_FAILED 167L
#define ERROR_BUSY 170L
#define ERROR_CANCEL_VIOLATION 173L
#define ERROR_ATOMIC_LOCKS_NOT_SUPPORTED 174L
#define ERROR_INVALID_SEGMENT_NUMBER 180L
#define ERROR_INVALID_ORDINAL 182L
#define ERROR_ALREADY_EXISTS 183L
#define ERROR_INVALID_FLAG_NUMBER 186L
#define ERROR_SEM_NOT_FOUND 187L
#define ERROR_INVALID_STARTING_CODESEG 188L
#define ERROR_INVALID_STACKSEG 189L
#define ERROR_INVALID_MODULETYPE 190L
#define ERROR_INVALID_EXE_SIGNATURE 191L
#define ERROR_EXE_MARKED_INVALID 192L
#define ERROR_BAD_EXE_FORMAT 193L
#define ERROR_ITERATED_DATA_EXCEEDS_64k 194L
#define ERROR_INVALID_MINALLOCSIZE 195L
#define ERROR_DYNLINK_FROM_INVALID_RING 196L
#define ERROR_IOPL_NOT_ENABLED 197L
#define ERROR_INVALID_SEGDPL 198L
#define ERROR_AUTODATASEG_EXCEEDS_64k 199L
#define ERROR_RING2SEG_MUST_BE_MOVABLE 200L
#define ERROR_RELOC_CHAIN_XEEDS_SEGLIM 201L
#define ERROR_INFLOOP_IN_RELOC_CHAIN 202L
#define ERROR_ENVVAR_NOT_FOUND 203L
#define ERROR_NO_SIGNAL_SENT 205L
#define ERROR_FILENAME_EXCED_RANGE 206L
#define ERROR_RING2_STACK_IN_USE 207L
#define ERROR_META_EXPANSION_TOO_LONG 208L
#define ERROR_INVALID_SIGNAL_NUMBER 209L
#define ERROR_THREAD_1_INACTIVE 210L
#define ERROR_LOCKED 212L
#define ERROR_TOO_MANY_MODULES 214L
#define ERROR_NESTING_NOT_ALLOWED 215L
#define ERROR_BAD_PIPE 230L
#define ERROR_PIPE_BUSY 231L
#define ERROR_NO_DATA 232L
#define ERROR_PIPE_NOT_CONNECTED 233L
#define ERROR_MORE_DATA 234L
#define ERROR_VC_DISCONNECTED 240L
#define ERROR_INVALID_EA_NAME 254L
#define ERROR_EA_LIST_INCONSISTENT 255L
#define ERROR_NO_MORE_ITEMS 259L
#define ERROR_CANNOT_COPY 266L
#define ERROR_DIRECTORY 267L
#define ERROR_EAS_DIDNT_FIT 275L
#define ERROR_EA_FILE_CORRUPT 276L
#define ERROR_EA_TABLE_FULL 277L
#define ERROR_INVALID_EA_HANDLE 278L
#define ERROR_EAS_NOT_SUPPORTED 282L
#define ERROR_NOT_OWNER 288L
#define ERROR_TOO_MANY_POSTS 298L
#define ERROR_PARTIAL_COPY 299L
#define ERROR_MR_MID_NOT_FOUND 317L
#define ERROR_INVALID_ADDRESS 487L
#define ERROR_ARITHMETIC_OVERFLOW 534L
#define ERROR_PIPE_CONNECTED 535L
#define ERROR_PIPE_LISTENING 536L
#define ERROR_EA_ACCESS_DENIED 994L
#define ERROR_OPERATION_ABORTED 995L
#define ERROR_IO_INCOMPLETE 996L
#define ERROR_IO_PENDING 997L
#define ERROR_NOACCESS 998L
#define ERROR_SWAPERROR 999L
#define ERROR_STACK_OVERFLOW 1001L
#define ERROR_INVALID_MESSAGE 1002L
#define ERROR_CAN_NOT_COMPLETE 1003L
#define ERROR_INVALID_FLAGS 1004L
#define ERROR_UNRECOGNIZED_VOLUME 1005L
#define ERROR_FILE_INVALID 1006L
#define ERROR_FULLSCREEN_MODE 1007L
#define ERROR_NO_TOKEN 1008L
#define ERROR_BADDB 1009L
#define ERROR_BADKEY 1010L
#define ERROR_CANTOPEN 1011L
#define ERROR_CANTREAD 1012L
#define ERROR_CANTWRITE 1013L
#define ERROR_REGISTRY_RECOVERED 1014L
#define ERROR_REGISTRY_CORRUPT 1015L
#define ERROR_REGISTRY_IO_FAILED 1016L
#define ERROR_NOT_REGISTRY_FILE 1017L
#define ERROR_KEY_DELETED 1018L
#define ERROR_NO_LOG_SPACE 1019L
#define ERROR_KEY_HAS_CHILDREN 1020L
#define ERROR_CHILD_MUST_BE_VOLATILE 1021L
#define ERROR_NOTIFY_ENUM_DIR 1022L
#define ERROR_DEPENDENT_SERVICES_RUNNING 1051L
#define ERROR_INVALID_SERVICE_CONTROL 1052L
#define ERROR_SERVICE_REQUEST_TIMEOUT 1053L
#define ERROR_SERVICE_NO_THREAD 1054L
#define ERROR_SERVICE_DATABASE_LOCKED 1055L
#define ERROR_SERVICE_ALREADY_RUNNING 1056L
#define ERROR_INVALID_SERVICE_ACCOUNT 1057L
#define ERROR_SERVICE_DISABLED 1058L
#define ERROR_CIRCULAR_DEPENDENCY 1059L
#define ERROR_SERVICE_DOES_NOT_EXIST 1060L
#define ERROR_SERVICE_CANNOT_ACCEPT_CTRL 1061L
#define ERROR_SERVICE_NOT_ACTIVE 1062L
#define ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 1063L
#define ERROR_EXCEPTION_IN_SERVICE 1064L
#define ERROR_DATABASE_DOES_NOT_EXIST 1065L
#define ERROR_SERVICE_SPECIFIC_ERROR 1066L
#define ERROR_PROCESS_ABORTED 1067L
#define ERROR_SERVICE_DEPENDENCY_FAIL 1068L
#define ERROR_SERVICE_LOGON_FAILED 1069L
#define ERROR_SERVICE_START_HANG 1070L
#define ERROR_INVALID_SERVICE_LOCK 1071L
#define ERROR_SERVICE_MARKED_FOR_DELETE 1072L
#define ERROR_SERVICE_EXISTS 1073L
#define ERROR_ALREADY_RUNNING_LKG 1074L
#define ERROR_SERVICE_DEPENDENCY_DELETED 1075L
#define ERROR_BOOT_ALREADY_ACCEPTED 1076L
#define ERROR_SERVICE_NEVER_STARTED 1077L
#define ERROR_DUPLICATE_SERVICE_NAME 1078L
#define ERROR_END_OF_MEDIA 1100L
#define ERROR_FILEMARK_DETECTED 1101L
#define ERROR_BEGINNING_OF_MEDIA 1102L
#define ERROR_SETMARK_DETECTED 1103L
#define ERROR_NO_DATA_DETECTED 1104L
#define ERROR_PARTITION_FAILURE 1105L
#define ERROR_INVALID_BLOCK_LENGTH 1106L
#define ERROR_DEVICE_NOT_PARTITIONED 1107L
#define ERROR_UNABLE_TO_LOCK_MEDIA 1108L
#define ERROR_UNABLE_TO_UNLOAD_MEDIA 1109L
#define ERROR_MEDIA_CHANGED 1110L
#define ERROR_BUS_RESET 1111L
#define ERROR_NO_MEDIA_IN_DRIVE 1112L
#define ERROR_NO_UNICODE_TRANSLATION 1113L
#define ERROR_DLL_INIT_FAILED 1114L
#define ERROR_SHUTDOWN_IN_PROGRESS 1115L
#define ERROR_NO_SHUTDOWN_IN_PROGRESS 1116L
#define ERROR_IO_DEVICE 1117L
#define ERROR_SERIAL_NO_DEVICE 1118L
#define ERROR_IRQ_BUSY 1119L
#define ERROR_MORE_WRITES 1120L
#define ERROR_COUNTER_TIMEOUT 1121L
#define ERROR_FLOPPY_ID_MARK_NOT_FOUND 1122L
#define ERROR_FLOPPY_WRONG_CYLINDER 1123L
#define ERROR_FLOPPY_UNKNOWN_ERROR 1124L
#define ERROR_FLOPPY_BAD_REGISTERS 1125L
#define ERROR_DISK_RECALIBRATE_FAILED 1126L
#define ERROR_DISK_OPERATION_FAILED 1127L
#define ERROR_DISK_RESET_FAILED 1128L
#define ERROR_EOM_OVERFLOW 1129L
#define ERROR_NOT_ENOUGH_SERVER_MEMORY 1130L
#define ERROR_POSSIBLE_DEADLOCK 1131L
#define ERROR_MAPPED_ALIGNMENT 1132L
#define ERROR_SET_POWER_STATE_VETOED 1140L
#define ERROR_SET_POWER_STATE_FAILED 1141L
#define ERROR_OLD_WIN_VERSION 1150L
#define ERROR_APP_WRONG_OS 1151L
#define ERROR_SINGLE_INSTANCE_APP 1152L
#define ERROR_RMODE_APP 1153L
#define ERROR_INVALID_DLL 1154L
#define ERROR_NO_ASSOCIATION 1155L
#define ERROR_DDE_FAIL 1156L
#define ERROR_DLL_NOT_FOUND 1157L
#define ERROR_BAD_USERNAME 2202L
#define ERROR_NOT_CONNECTED 2250L
#define ERROR_OPEN_FILES 2401L
#define ERROR_ACTIVE_CONNECTIONS 2402L
#define ERROR_DEVICE_IN_USE 2404L
#define ERROR_BAD_DEVICE 1200L
#define ERROR_CONNECTION_UNAVAIL 1201L
#define ERROR_DEVICE_ALREADY_REMEMBERED 1202L
#define ERROR_NO_NET_OR_BAD_PATH 1203L
#define ERROR_BAD_PROVIDER 1204L
#define ERROR_CANNOT_OPEN_PROFILE 1205L
#define ERROR_BAD_PROFILE 1206L
#define ERROR_NOT_CONTAINER 1207L
#define ERROR_EXTENDED_ERROR 1208L
#define ERROR_INVALID_GROUPNAME 1209L
#define ERROR_INVALID_COMPUTERNAME 1210L
#define ERROR_INVALID_EVENTNAME 1211L
#define ERROR_INVALID_DOMAINNAME 1212L
#define ERROR_INVALID_SERVICENAME 1213L
#define ERROR_INVALID_NETNAME 1214L
#define ERROR_INVALID_SHARENAME 1215L
#define ERROR_INVALID_PASSWORDNAME 1216L
#define ERROR_INVALID_MESSAGENAME 1217L
#define ERROR_INVALID_MESSAGEDEST 1218L
#define ERROR_SESSION_CREDENTIAL_CONFLICT 1219L
#define ERROR_REMOTE_SESSION_LIMIT_EXCEEDED 1220L
#define ERROR_DUP_DOMAINNAME 1221L
#define ERROR_NO_NETWORK 1222L
#define ERROR_CANCELLED 1223L
#define ERROR_USER_MAPPED_FILE 1224L
#define ERROR_CONNECTION_REFUSED 1225L
#define ERROR_GRACEFUL_DISCONNECT 1226L
#define ERROR_ADDRESS_ALREADY_ASSOCIATED 1227L
#define ERROR_ADDRESS_NOT_ASSOCIATED 1228L
#define ERROR_CONNECTION_INVALID 1229L
#define ERROR_CONNECTION_ACTIVE 1230L
#define ERROR_NETWORK_UNREACHABLE 1231L
#define ERROR_HOST_UNREACHABLE 1232L
#define ERROR_PROTOCOL_UNREACHABLE 1233L
#define ERROR_PORT_UNREACHABLE 1234L
#define ERROR_REQUEST_ABORTED 1235L
#define ERROR_CONNECTION_ABORTED 1236L
#define ERROR_RETRY 1237L
#define ERROR_CONNECTION_COUNT_LIMIT 1238L
#define ERROR_LOGIN_TIME_RESTRICTION 1239L
#define ERROR_LOGIN_WKSTA_RESTRICTION 1240L
#define ERROR_INCORRECT_ADDRESS 1241L
#define ERROR_ALREADY_REGISTERED 1242L
#define ERROR_SERVICE_NOT_FOUND 1243L
#define ERROR_NOT_AUTHENTICATED 1244L
#define ERROR_NOT_LOGGED_ON 1245L
#define ERROR_CONTINUE 1246L
#define ERROR_ALREADY_INITIALIZED 1247L
#define ERROR_NO_MORE_DEVICES 1248L
#define ERROR_NOT_ALL_ASSIGNED 1300L
#define ERROR_SOME_NOT_MAPPED 1301L
#define ERROR_NO_QUOTAS_FOR_ACCOUNT 1302L
#define ERROR_LOCAL_USER_SESSION_KEY 1303L
#define ERROR_NULL_LM_PASSWORD 1304L
#define ERROR_UNKNOWN_REVISION 1305L
#define ERROR_REVISION_MISMATCH 1306L
#define ERROR_INVALID_OWNER 1307L
#define ERROR_INVALID_PRIMARY_GROUP 1308L
#define ERROR_NO_IMPERSONATION_TOKEN 1309L
#define ERROR_CANT_DISABLE_MANDATORY 1310L
#define ERROR_NO_LOGON_SERVERS 1311L
#define ERROR_NO_SUCH_LOGON_SESSION 1312L
#define ERROR_NO_SUCH_PRIVILEGE 1313L
#define ERROR_PRIVILEGE_NOT_HELD 1314L
#define ERROR_INVALID_ACCOUNT_NAME 1315L
#define ERROR_USER_EXISTS 1316L
#define ERROR_NO_SUCH_USER 1317L
#define ERROR_GROUP_EXISTS 1318L
#define ERROR_NO_SUCH_GROUP 1319L
#define ERROR_MEMBER_IN_GROUP 1320L
#define ERROR_MEMBER_NOT_IN_GROUP 1321L
#define ERROR_LAST_ADMIN 1322L
#define ERROR_WRONG_PASSWORD 1323L
#define ERROR_ILL_FORMED_PASSWORD 1324L
#define ERROR_PASSWORD_RESTRICTION 1325L
#define ERROR_LOGON_FAILURE 1326L
#define ERROR_ACCOUNT_RESTRICTION 1327L
#define ERROR_INVALID_LOGON_HOURS 1328L
#define ERROR_INVALID_WORKSTATION 1329L
#define ERROR_PASSWORD_EXPIRED 1330L
#define ERROR_ACCOUNT_DISABLED 1331L
#define ERROR_NONE_MAPPED 1332L
#define ERROR_TOO_MANY_LUIDS_REQUESTED 1333L
#define ERROR_LUIDS_EXHAUSTED 1334L
#define ERROR_INVALID_SUB_AUTHORITY 1335L
#define ERROR_INVALID_ACL 1336L
#define ERROR_INVALID_SID 1337L
#define ERROR_INVALID_SECURITY_DESCR 1338L
#define ERROR_BAD_INHERITANCE_ACL 1340L
#define ERROR_SERVER_DISABLED 1341L
#define ERROR_SERVER_NOT_DISABLED 1342L
#define ERROR_INVALID_ID_AUTHORITY 1343L
#define ERROR_ALLOTTED_SPACE_EXCEEDED 1344L
#define ERROR_INVALID_GROUP_ATTRIBUTES 1345L
#define ERROR_BAD_IMPERSONATION_LEVEL 1346L
#define ERROR_CANT_OPEN_ANONYMOUS 1347L
#define ERROR_BAD_VALIDATION_CLASS 1348L
#define ERROR_BAD_TOKEN_TYPE 1349L
#define ERROR_NO_SECURITY_ON_OBJECT 1350L
#define ERROR_CANT_ACCESS_DOMAIN_INFO 1351L
#define ERROR_INVALID_SERVER_STATE 1352L
#define ERROR_INVALID_DOMAIN_STATE 1353L
#define ERROR_INVALID_DOMAIN_ROLE 1354L
#define ERROR_NO_SUCH_DOMAIN 1355L
#define ERROR_DOMAIN_EXISTS 1356L
#define ERROR_DOMAIN_LIMIT_EXCEEDED 1357L
#define ERROR_INTERNAL_DB_CORRUPTION 1358L
#define ERROR_INTERNAL_ERROR 1359L
#define ERROR_GENERIC_NOT_MAPPED 1360L
#define ERROR_BAD_DESCRIPTOR_FORMAT 1361L
#define ERROR_NOT_LOGON_PROCESS 1362L
#define ERROR_LOGON_SESSION_EXISTS 1363L
#define ERROR_NO_SUCH_PACKAGE 1364L
#define ERROR_BAD_LOGON_SESSION_STATE 1365L
#define ERROR_LOGON_SESSION_COLLISION 1366L
#define ERROR_INVALID_LOGON_TYPE 1367L
#define ERROR_CANNOT_IMPERSONATE 1368L
#define ERROR_RXACT_INVALID_STATE 1369L
#define ERROR_RXACT_COMMIT_FAILURE 1370L
#define ERROR_SPECIAL_ACCOUNT 1371L
#define ERROR_SPECIAL_GROUP 1372L
#define ERROR_SPECIAL_USER 1373L
#define ERROR_MEMBERS_PRIMARY_GROUP 1374L
#define ERROR_TOKEN_ALREADY_IN_USE 1375L
#define ERROR_NO_SUCH_ALIAS 1376L
#define ERROR_MEMBER_NOT_IN_ALIAS 1377L
#define ERROR_MEMBER_IN_ALIAS 1378L
#define ERROR_ALIAS_EXISTS 1379L
#define ERROR_LOGON_NOT_GRANTED 1380L
#define ERROR_TOO_MANY_SECRETS 1381L
#define ERROR_SECRET_TOO_LONG 1382L
#define ERROR_INTERNAL_DB_ERROR 1383L
#define ERROR_TOO_MANY_CONTEXT_IDS 1384L
#define ERROR_LOGON_TYPE_NOT_GRANTED 1385L
#define ERROR_NT_CROSS_ENCRYPTION_REQUIRED 1386L
#define ERROR_NO_SUCH_MEMBER 1387L
#define ERROR_INVALID_MEMBER 1388L
#define ERROR_TOO_MANY_SIDS 1389L
#define ERROR_LM_CROSS_ENCRYPTION_REQUIRED 1390L
#define ERROR_NO_INHERITANCE 1391L
#define ERROR_FILE_CORRUPT 1392L
#define ERROR_DISK_CORRUPT 1393L
#define ERROR_NO_USER_SESSION_KEY 1394L
#define ERROR_LICENSE_QUOTA_EXCEEDED 1395L
#define ERROR_INVALID_WINDOW_HANDLE 1400L
#define ERROR_INVALID_MENU_HANDLE 1401L
#define ERROR_INVALID_CURSOR_HANDLE 1402L
#define ERROR_INVALID_ACCEL_HANDLE 1403L
#define ERROR_INVALID_HOOK_HANDLE 1404L
#define ERROR_INVALID_DWP_HANDLE 1405L
#define ERROR_TLW_WITH_WSCHILD 1406L
#define ERROR_CANNOT_FIND_WND_CLASS 1407L
#define ERROR_WINDOW_OF_OTHER_THREAD 1408L
#define ERROR_HOTKEY_ALREADY_REGISTERED 1409L
#define ERROR_CLASS_ALREADY_EXISTS 1410L
#define ERROR_CLASS_DOES_NOT_EXIST 1411L
#define ERROR_CLASS_HAS_WINDOWS 1412L
#define ERROR_INVALID_INDEX 1413L
#define ERROR_INVALID_ICON_HANDLE 1414L
#define ERROR_PRIVATE_DIALOG_INDEX 1415L
#define ERROR_LISTBOX_ID_NOT_FOUND 1416L
#define ERROR_NO_WILDCARD_CHARACTERS 1417L
#define ERROR_CLIPBOARD_NOT_OPEN 1418L
#define ERROR_HOTKEY_NOT_REGISTERED 1419L
#define ERROR_WINDOW_NOT_DIALOG 1420L
#define ERROR_CONTROL_ID_NOT_FOUND 1421L
#define ERROR_INVALID_COMBOBOX_MESSAGE 1422L
#define ERROR_WINDOW_NOT_COMBOBOX 1423L
#define ERROR_INVALID_EDIT_HEIGHT 1424L
#define ERROR_DC_NOT_FOUND 1425L
#define ERROR_INVALID_HOOK_FILTER 1426L
#define ERROR_INVALID_FILTER_PROC 1427L
#define ERROR_HOOK_NEEDS_HMOD 1428L
#define ERROR_GLOBAL_ONLY_HOOK 1429L
#define ERROR_JOURNAL_HOOK_SET 1430L
#define ERROR_HOOK_NOT_INSTALLED 1431L
#define ERROR_INVALID_LB_MESSAGE 1432L
#define ERROR_SETCOUNT_ON_BAD_LB 1433L
#define ERROR_LB_WITHOUT_TABSTOPS 1434L
#define ERROR_DESTROY_OBJECT_OF_OTHER_THREAD 1435L
#define ERROR_CHILD_WINDOW_MENU 1436L
#define ERROR_NO_SYSTEM_MENU 1437L
#define ERROR_INVALID_MSGBOX_STYLE 1438L
#define ERROR_INVALID_SPI_VALUE 1439L
#define ERROR_SCREEN_ALREADY_LOCKED 1440L
#define ERROR_HWNDS_HAVE_DIFF_PARENT 1441L
#define ERROR_NOT_CHILD_WINDOW 1442L
#define ERROR_INVALID_GW_COMMAND 1443L
#define ERROR_INVALID_THREAD_ID 1444L
#define ERROR_NON_MDICHILD_WINDOW 1445L
#define ERROR_POPUP_ALREADY_ACTIVE 1446L
#define ERROR_NO_SCROLLBARS 1447L
#define ERROR_INVALID_SCROLLBAR_RANGE 1448L
#define ERROR_INVALID_SHOWWIN_COMMAND 1449L
#define ERROR_NO_SYSTEM_RESOURCES 1450L
#define ERROR_NONPAGED_SYSTEM_RESOURCES 1451L
#define ERROR_PAGED_SYSTEM_RESOURCES 1452L
#define ERROR_WORKING_SET_QUOTA 1453L
#define ERROR_PAGEFILE_QUOTA 1454L
#define ERROR_COMMITMENT_LIMIT 1455L
#define ERROR_MENU_ITEM_NOT_FOUND 1456L
#define ERROR_EVENTLOG_FILE_CORRUPT 1500L
#define ERROR_EVENTLOG_CANT_START 1501L
#define ERROR_LOG_FILE_FULL 1502L
#define ERROR_EVENTLOG_FILE_CHANGED 1503L
#define RPC_S_INVALID_STRING_BINDING 1700L
#define RPC_S_WRONG_KIND_OF_BINDING 1701L
#define RPC_S_INVALID_BINDING 1702L
#define RPC_S_PROTSEQ_NOT_SUPPORTED 1703L
#define RPC_S_INVALID_RPC_PROTSEQ 1704L
#define RPC_S_INVALID_STRING_UUID 1705L
#define RPC_S_INVALID_ENDPOINT_FORMAT 1706L
#define RPC_S_INVALID_NET_ADDR 1707L
#define RPC_S_NO_ENDPOINT_FOUND 1708L
#define RPC_S_INVALID_TIMEOUT 1709L
#define RPC_S_OBJECT_NOT_FOUND 1710L
#define RPC_S_ALREADY_REGISTERED 1711L
#define RPC_S_TYPE_ALREADY_REGISTERED 1712L
#define RPC_S_ALREADY_LISTENING 1713L
#define RPC_S_NO_PROTSEQS_REGISTERED 1714L
#define RPC_S_NOT_LISTENING 1715L
#define RPC_S_UNKNOWN_MGR_TYPE 1716L
#define RPC_S_UNKNOWN_IF 1717L
#define RPC_S_NO_BINDINGS 1718L
#define RPC_S_NO_PROTSEQS 1719L
#define RPC_S_CANT_CREATE_ENDPOINT 1720L
#define RPC_S_OUT_OF_RESOURCES 1721L
#define RPC_S_SERVER_UNAVAILABLE 1722L
#define RPC_S_SERVER_TOO_BUSY 1723L
#define RPC_S_INVALID_NETWORK_OPTIONS 1724L
#define RPC_S_NO_CALL_ACTIVE 1725L
#define RPC_S_CALL_FAILED 1726L
#define RPC_S_CALL_FAILED_DNE 1727L
#define RPC_S_PROTOCOL_ERROR 1728L
#define RPC_S_UNSUPPORTED_TRANS_SYN 1730L
#define RPC_S_UNSUPPORTED_TYPE 1732L
#define RPC_S_INVALID_TAG 1733L
#define RPC_S_INVALID_BOUND 1734L
#define RPC_S_NO_ENTRY_NAME 1735L
#define RPC_S_INVALID_NAME_SYNTAX 1736L
#define RPC_S_UNSUPPORTED_NAME_SYNTAX 1737L
#define RPC_S_UUID_NO_ADDRESS 1739L
#define RPC_S_DUPLICATE_ENDPOINT 1740L
#define RPC_S_UNKNOWN_AUTHN_TYPE 1741L
#define RPC_S_MAX_CALLS_TOO_SMALL 1742L
#define RPC_S_STRING_TOO_LONG 1743L
#define RPC_S_PROTSEQ_NOT_FOUND 1744L
#define RPC_S_PROCNUM_OUT_OF_RANGE 1745L
#define RPC_S_BINDING_HAS_NO_AUTH 1746L
#define RPC_S_UNKNOWN_AUTHN_SERVICE 1747L
#define RPC_S_UNKNOWN_AUTHN_LEVEL 1748L
#define RPC_S_INVALID_AUTH_IDENTITY 1749L
#define RPC_S_UNKNOWN_AUTHZ_SERVICE 1750L
#define EPT_S_INVALID_ENTRY 1751L
#define EPT_S_CANT_PERFORM_OP 1752L
#define EPT_S_NOT_REGISTERED 1753L
#define RPC_S_NOTHING_TO_EXPORT 1754L
#define RPC_S_INCOMPLETE_NAME 1755L
#define RPC_S_INVALID_VERS_OPTION 1756L
#define RPC_S_NO_MORE_MEMBERS 1757L
#define RPC_S_NOT_ALL_OBJS_UNEXPORTED 1758L
#define RPC_S_INTERFACE_NOT_FOUND 1759L
#define RPC_S_ENTRY_ALREADY_EXISTS 1760L
#define RPC_S_ENTRY_NOT_FOUND 1761L
#define RPC_S_NAME_SERVICE_UNAVAILABLE 1762L
#define RPC_S_INVALID_NAF_ID 1763L
#define RPC_S_CANNOT_SUPPORT 1764L
#define RPC_S_NO_CONTEXT_AVAILABLE 1765L
#define RPC_S_INTERNAL_ERROR 1766L
#define RPC_S_ZERO_DIVIDE 1767L
#define RPC_S_ADDRESS_ERROR 1768L
#define RPC_S_FP_DIV_ZERO 1769L
#define RPC_S_FP_UNDERFLOW 1770L
#define RPC_S_FP_OVERFLOW 1771L
#define RPC_X_NO_MORE_ENTRIES 1772L
#define RPC_X_SS_CHAR_TRANS_OPEN_FAIL 1773L
#define RPC_X_SS_CHAR_TRANS_SHORT_FILE 1774L
#define RPC_X_SS_IN_NULL_CONTEXT 1775L
#define RPC_X_SS_CONTEXT_DAMAGED 1777L
#define RPC_X_SS_HANDLES_MISMATCH 1778L
#define RPC_X_SS_CANNOT_GET_CALL_HANDLE 1779L
#define RPC_X_NULL_REF_POINTER 1780L
#define RPC_X_ENUM_VALUE_OUT_OF_RANGE 1781L
#define RPC_X_BYTE_COUNT_TOO_SMALL 1782L
#define RPC_X_BAD_STUB_DATA 1783L
#define ERROR_INVALID_USER_BUFFER 1784L
#define ERROR_UNRECOGNIZED_MEDIA 1785L
#define ERROR_NO_TRUST_LSA_SECRET 1786L
#define ERROR_NO_TRUST_SAM_ACCOUNT 1787L
#define ERROR_TRUSTED_DOMAIN_FAILURE 1788L
#define ERROR_TRUSTED_RELATIONSHIP_FAILURE 1789L
#define ERROR_TRUST_FAILURE 1790L
#define RPC_S_CALL_IN_PROGRESS 1791L
#define ERROR_NETLOGON_NOT_STARTED 1792L
#define ERROR_ACCOUNT_EXPIRED 1793L
#define ERROR_REDIRECTOR_HAS_OPEN_HANDLES 1794L
#define ERROR_PRINTER_DRIVER_ALREADY_INSTALLED 1795L
#define ERROR_UNKNOWN_PORT 1796L
#define ERROR_UNKNOWN_PRINTER_DRIVER 1797L
#define ERROR_UNKNOWN_PRINTPROCESSOR 1798L
#define ERROR_INVALID_SEPARATOR_FILE 1799L
#define ERROR_INVALID_PRIORITY 1800L
#define ERROR_INVALID_PRINTER_NAME 1801L
#define ERROR_PRINTER_ALREADY_EXISTS 1802L
#define ERROR_INVALID_PRINTER_COMMAND 1803L
#define ERROR_INVALID_DATATYPE 1804L
#define ERROR_INVALID_ENVIRONMENT 1805L
#define RPC_S_NO_MORE_BINDINGS 1806L
#define ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 1807L
#define ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT 1808L
#define ERROR_NOLOGON_SERVER_TRUST_ACCOUNT 1809L
#define ERROR_DOMAIN_TRUST_INCONSISTENT 1810L
#define ERROR_SERVER_HAS_OPEN_HANDLES 1811L
#define ERROR_RESOURCE_DATA_NOT_FOUND 1812L
#define ERROR_RESOURCE_TYPE_NOT_FOUND 1813L
#define ERROR_RESOURCE_NAME_NOT_FOUND 1814L
#define ERROR_RESOURCE_LANG_NOT_FOUND 1815L
#define ERROR_NOT_ENOUGH_QUOTA 1816L
#define RPC_S_NO_INTERFACES 1817L
#define RPC_S_CALL_CANCELLED 1818L
#define RPC_S_BINDING_INCOMPLETE 1819L
#define RPC_S_COMM_FAILURE 1820L
#define RPC_S_UNSUPPORTED_AUTHN_LEVEL 1821L
#define RPC_S_NO_PRINC_NAME 1822L
#define RPC_S_NOT_RPC_ERROR 1823L
#define RPC_S_UUID_LOCAL_ONLY 1824L
#define RPC_S_SEC_PKG_ERROR 1825L
#define RPC_S_NOT_CANCELLED 1826L
#define RPC_X_INVALID_ES_ACTION 1827L
#define RPC_X_WRONG_ES_VERSION 1828L
#define RPC_X_WRONG_STUB_VERSION 1829L
#define RPC_S_GROUP_MEMBER_NOT_FOUND 1898L
#define EPT_S_CANT_CREATE 1899L
#define RPC_S_INVALID_OBJECT 1900L
#define ERROR_INVALID_TIME 1901L
#define ERROR_INVALID_FORM_NAME 1902L
#define ERROR_INVALID_FORM_SIZE 1903L
#define ERROR_ALREADY_WAITING 1904L
#define ERROR_PRINTER_DELETED 1905L
#define ERROR_INVALID_PRINTER_STATE 1906L
#define ERROR_PASSWORD_MUST_CHANGE 1907L
#define ERROR_DOMAIN_CONTROLLER_NOT_FOUND 1908L
#define ERROR_ACCOUNT_LOCKED_OUT 1909L
#define ERROR_NO_BROWSER_SERVERS_FOUND 6118L
#define ERROR_INVALID_PIXEL_FORMAT 2000L
#define ERROR_BAD_DRIVER 2001L
#define ERROR_INVALID_WINDOW_STYLE 2002L
#define ERROR_METAFILE_NOT_SUPPORTED 2003L
#define ERROR_TRANSFORM_NOT_SUPPORTED 2004L
#define ERROR_CLIPPING_NOT_SUPPORTED 2005L
#define ERROR_UNKNOWN_PRINT_MONITOR 3000L
#define ERROR_PRINTER_DRIVER_IN_USE 3001L
#define ERROR_SPOOL_FILE_NOT_FOUND 3002L
#define ERROR_SPL_NO_STARTDOC 3003L
#define ERROR_SPL_NO_ADDJOB 3004L
#define ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED 3005L
#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED 3006L
#define ERROR_WINS_INTERNAL 4000L
#define ERROR_CAN_NOT_DEL_LOCAL_WINS 4001L
#define ERROR_STATIC_INIT 4002L
#define ERROR_INC_BACKUP 4003L
#define ERROR_FULL_BACKUP 4004L
#define ERROR_REC_NON_EXISTENT 4005L
#define ERROR_RPL_NOT_ALLOWED 4006L
#define ERROR_NO_BROWSER_SERVERS_FOUND 6118L
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GNU_H_WINDOWS32_ERROR */

7484
reactos/include/funcs.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,140 @@
#ifndef _I386_BITOPS_H
#define _I386_BITOPS_H
/*
* Copyright 1992, Linus Torvalds.
*/
/*
* Reused for the ReactOS kernel by David Welch (1998)
*/
/*
* These have to be done with inline assembly: that way the bit-setting
* is guaranteed to be atomic. All bit operations return 0 if the bit
* was cleared before the operation and != 0 if it was not.
*
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
*/
#ifdef __SMP__
#define LOCK_PREFIX "lock ; "
#define SMPVOL volatile
#else
#define LOCK_PREFIX ""
#define SMPVOL
#endif
/*
* Some hacks to defeat gcc over-optimizations..
*/
struct __dummy { unsigned long a[100]; };
#define ADDR (*(struct __dummy *) addr)
#define CONST_ADDR (*(const struct __dummy *) addr)
extern __inline__ int set_bit(int nr, SMPVOL void * addr)
{
int oldbit;
__asm__ __volatile__(LOCK_PREFIX
"btsl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" (ADDR)
:"ir" (nr));
return oldbit;
}
extern __inline__ int clear_bit(int nr, SMPVOL void * addr)
{
int oldbit;
__asm__ __volatile__(LOCK_PREFIX
"btrl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" (ADDR)
:"ir" (nr));
return oldbit;
}
extern __inline__ int change_bit(int nr, SMPVOL void * addr)
{
int oldbit;
__asm__ __volatile__(LOCK_PREFIX
"btcl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" (ADDR)
:"ir" (nr));
return oldbit;
}
/*
* This routine doesn't need to be atomic.
*/
extern __inline__ int test_bit(int nr, const SMPVOL void * addr)
{
return ((1UL << (nr & 31)) & (((const unsigned int *) addr)[nr >> 5])) != 0;
}
/*
* Find-bit routines..
*/
extern __inline__ int find_first_zero_bit(void * addr, unsigned size)
{
int res;
if (!size)
return 0;
__asm__("cld\n\t"
"movl $-1,%%eax\n\t"
"xorl %%edx,%%edx\n\t"
"repe; scasl\n\t"
"je 1f\n\t"
"xorl -4(%%edi),%%eax\n\t"
"subl $4,%%edi\n\t"
"bsfl %%eax,%%edx\n"
"1:\tsubl %%ebx,%%edi\n\t"
"shll $3,%%edi\n\t"
"addl %%edi,%%edx"
:"=d" (res)
:"c" ((size + 31) >> 5), "D" (addr), "b" (addr)
:"ax", "cx", "di");
return res;
}
extern __inline__ int find_next_zero_bit (void * addr, int size, int offset)
{
unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
int set = 0, bit = offset & 31, res;
if (bit) {
/*
* Look for zero in first byte
*/
__asm__("bsfl %1,%0\n\t"
"jne 1f\n\t"
"movl $32, %0\n"
"1:"
: "=r" (set)
: "r" (~(*p >> bit)));
if (set < (32 - bit))
return set + offset;
set = 32 - bit;
p++;
}
/*
* No zero yet, search remaining full bytes for a zero
*/
res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr));
return (offset + set + res);
}
/*
* ffz = Find First Zero in word. Undefined if no zero exists,
* so code should check against ~0UL first..
*/
extern __inline__ unsigned long ffz(unsigned long word)
{
__asm__("bsfl %1,%0"
:"=r" (word)
:"r" (~word));
return word;
}
#endif /* _I386_BITOPS_H */

View file

@ -0,0 +1,34 @@
#ifndef _LINUX_CTYPE_H
#define _LINUX_CTYPE_H
#define _U 0x01 /* upper */
#define _L 0x02 /* lower */
#define _D 0x04 /* digit */
#define _C 0x08 /* cntrl */
#define _P 0x10 /* punct */
#define _S 0x20 /* white space (space/lf/tab) */
#define _X 0x40 /* hex digit */
#define _SP 0x80 /* hard space (0x20) */
extern unsigned char _ctype[];
extern char _ctmp;
#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D))
#define isalpha(c) ((_ctype+1)[c]&(_U|_L))
#define iscntrl(c) ((_ctype+1)[c]&(_C))
#define isdigit(c) ((_ctype+1)[c]&(_D))
#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D))
#define islower(c) ((_ctype+1)[c]&(_L))
#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP))
#define ispunct(c) ((_ctype+1)[c]&(_P))
#define isspace(c) ((_ctype+1)[c]&(_S))
#define isupper(c) ((_ctype+1)[c]&(_U))
#define isxdigit(c) ((_ctype+1)[c]&(_D|_X))
#define isascii(c) (((unsigned) c)<=0x7f)
#define toascii(c) (((unsigned) c)&0x7f)
#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp)
#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
#endif

View file

@ -0,0 +1,70 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/debug.h
* PURPOSE: Useful debugging macros
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* 28/05/98: Created
*/
/*
* NOTE: Define NDEBUG before including this header to disable debugging
* macros
*/
#ifndef __INTERNAL_DEBUG
#define __INTERNAL_DEBUG
#ifndef NDEBUG
#define DPRINT(fmt,args...) do { printk("(%s:%d) ",__FILE__,__LINE__); printk(fmt,args); } while(0);
//#define assert(x) if (!(x)) {printk("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
#define assert(x) if (!(x)) {printk("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
#define CHECKPOINT printk("%s:%d\n",__FILE__,__LINE__)
#else
#define DPRINT(fmt,args...)
#define assert(x)
#define CHECKPOINT
#endif /* NDEBUG */
/*
* FUNCTION: Assert a maximum value for the current irql
* ARGUMENTS:
* x = Maximum irql
*/
#define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
#define HBP_EXECUTE (0)
#define HBP_WRITE (1)
#define HBP_READWRITE (3)
#define HBP_BYTE (0)
#define HBP_WORD (1)
#define HBP_DWORD (3)
/*
* FUNCTION: Sets a hardware breakpoint
* ARGUMENTS:
* i = breakpoint to set (0 to 3)
* addr = linear address to break on
* type = Type of access to break on
* len = length of the variable to watch
* NOTES:
* The variable to watch must be aligned to its length (i.e. a dword
* breakpoint must be aligned to a dword boundary)
*
* A fatal exception will be generated on the access to the variable.
* It is (at the moment) only really useful for catching undefined
* pointers if you know the variable effected but not the buggy
* routine.
*
* FIXME: Extend to call out to kernel debugger on breakpoint
* Add support for I/O breakpoints
* REFERENCES: See the i386 programmer manual for more details
*/
void set_breakpoint(unsigned int i, unsigned int addr, unsigned int type,
unsigned int len);
#endif /* __INTERNAL_DEBUG */

View file

@ -0,0 +1,267 @@
/* $Id: dma.h,v 1.1 1996/01/23 01:02:19 rosmgr Exp $
* linux/include/asm/dma.h: Defines for using and allocating dma channels.
* Written by Hennus Bergman, 1992.
* High DMA channel support & info by Hannu Savolainen
* and John Boyd, Nov. 1992.
*/
#ifndef _ASM_DMA_H
#define _ASM_DMA_H
#include "io.h" /* need byte IO */
#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
#define dma_outb outb_p
#else
#define dma_outb outb
#endif
#define dma_inb inb
/*
* NOTES about DMA transfers:
*
* controller 1: channels 0-3, byte operations, ports 00-1F
* controller 2: channels 4-7, word operations, ports C0-DF
*
* - ALL registers are 8 bits only, regardless of transfer size
* - channel 4 is not used - cascades 1 into 2.
* - channels 0-3 are byte - addresses/counts are for physical bytes
* - channels 5-7 are word - addresses/counts are for physical words
* - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
* - transfer count loaded to registers is 1 less than actual count
* - controller 2 offsets are all even (2x offsets for controller 1)
* - page registers for 5-7 don't use data bit 0, represent 128K pages
* - page registers for 0-3 use bit 0, represent 64K pages
*
* DMA transfers are limited to the lower 16MB of _physical_ memory.
* Note that addresses loaded into registers must be _physical_ addresses,
* not logical addresses (which may differ if paging is active).
*
* Address mapping for channels 0-3:
*
* A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
* | ... | | ... | | ... |
* | ... | | ... | | ... |
* | ... | | ... | | ... |
* P7 ... P0 A7 ... A0 A7 ... A0
* | Page | Addr MSB | Addr LSB | (DMA registers)
*
* Address mapping for channels 5-7:
*
* A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
* | ... | \ \ ... \ \ \ ... \ \
* | ... | \ \ ... \ \ \ ... \ (not used)
* | ... | \ \ ... \ \ \ ... \
* P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
* | Page | Addr MSB | Addr LSB | (DMA registers)
*
* Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
* and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
* the hardware level, so odd-byte transfers aren't possible).
*
* Transfer count (_not # bytes_) is limited to 64K, represented as actual
* count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
* and up to 128K bytes may be transferred on channels 5-7 in one operation.
*
*/
#define MAX_DMA_CHANNELS 8
/* The maximum address that we can perform a DMA transfer to on this platform */
#define MAX_DMA_ADDRESS 0x1000000
/* 8237 DMA controllers */
#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
/* DMA controller registers */
#define DMA1_CMD_REG 0x08 /* command register (w) */
#define DMA1_STAT_REG 0x08 /* status register (r) */
#define DMA1_REQ_REG 0x09 /* request register (w) */
#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
#define DMA1_MODE_REG 0x0B /* mode register (w) */
#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
#define DMA2_CMD_REG 0xD0 /* command register (w) */
#define DMA2_STAT_REG 0xD0 /* status register (r) */
#define DMA2_REQ_REG 0xD2 /* request register (w) */
#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
#define DMA2_MODE_REG 0xD6 /* mode register (w) */
#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
#define DMA_ADDR_0 0x00 /* DMA address registers */
#define DMA_ADDR_1 0x02
#define DMA_ADDR_2 0x04
#define DMA_ADDR_3 0x06
#define DMA_ADDR_4 0xC0
#define DMA_ADDR_5 0xC4
#define DMA_ADDR_6 0xC8
#define DMA_ADDR_7 0xCC
#define DMA_CNT_0 0x01 /* DMA count registers */
#define DMA_CNT_1 0x03
#define DMA_CNT_2 0x05
#define DMA_CNT_3 0x07
#define DMA_CNT_4 0xC2
#define DMA_CNT_5 0xC6
#define DMA_CNT_6 0xCA
#define DMA_CNT_7 0xCE
#define DMA_PAGE_0 0x87 /* DMA page registers */
#define DMA_PAGE_1 0x83
#define DMA_PAGE_2 0x81
#define DMA_PAGE_3 0x82
#define DMA_PAGE_5 0x8B
#define DMA_PAGE_6 0x89
#define DMA_PAGE_7 0x8A
#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
/* enable/disable a specific DMA channel */
static __inline__ void enable_dma(unsigned int dmanr)
{
if (dmanr<=3)
dma_outb(DMA1_MASK_REG, dmanr);
else
dma_outb(DMA2_MASK_REG, dmanr & 3);
}
static __inline__ void disable_dma(unsigned int dmanr)
{
if (dmanr<=3)
dma_outb(DMA1_MASK_REG, dmanr | 4);
else
dma_outb(DMA2_MASK_REG, (dmanr & 3) | 4);
}
/* Clear the 'DMA Pointer Flip Flop'.
* Write 0 for LSB/MSB, 1 for MSB/LSB access.
* Use this once to initialize the FF to a known state.
* After that, keep track of it. :-)
* --- In order to do that, the DMA routines below should ---
* --- only be used while interrupts are disabled! ---
*/
static __inline__ void clear_dma_ff(unsigned int dmanr)
{
if (dmanr<=3)
dma_outb(DMA1_CLEAR_FF_REG, 0);
else
dma_outb(DMA2_CLEAR_FF_REG, 0);
}
/* set mode (above) for a specific DMA channel */
static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
{
if (dmanr<=3)
dma_outb(DMA1_MODE_REG, mode | dmanr);
else
dma_outb(DMA2_MODE_REG, mode | (dmanr&3));
}
/* Set only the page register bits of the transfer address.
* This is used for successive transfers when we know the contents of
* the lower 16 bits of the DMA current address register, but a 64k boundary
* may have been crossed.
*/
static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
{
switch(dmanr) {
case 0:
dma_outb(DMA_PAGE_0, pagenr);
break;
case 1:
dma_outb(DMA_PAGE_1, pagenr);
break;
case 2:
dma_outb(DMA_PAGE_2, pagenr);
break;
case 3:
dma_outb(DMA_PAGE_3, pagenr);
break;
case 5:
dma_outb(DMA_PAGE_5, pagenr & 0xfe);
break;
case 6:
dma_outb(DMA_PAGE_6, pagenr & 0xfe);
break;
case 7:
dma_outb(DMA_PAGE_7, pagenr & 0xfe);
break;
}
}
/* Set transfer address & page bits for specific DMA channel.
* Assumes dma flipflop is clear.
*/
static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
{
set_dma_page(dmanr, a>>16);
if (dmanr <= 3) {
dma_outb(((dmanr&3)<<1) + IO_DMA1_BASE, a & 0xff);
dma_outb(((dmanr&3)<<1) + IO_DMA1_BASE, (a>>8) & 0xff );
} else {
dma_outb( ((dmanr&3)<<2) + IO_DMA2_BASE ,(a>>1) & 0xff );
dma_outb( ((dmanr&3)<<2) + IO_DMA2_BASE,(a>>9) & 0xff );
}
}
/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
* a specific DMA channel.
* You must ensure the parameters are valid.
* NOTE: from a manual: "the number of transfers is one more
* than the initial word count"! This is taken into account.
* Assumes dma flip-flop is clear.
* NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
*/
static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
{
count--;
if (dmanr <= 3) {
dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
} else {
dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
}
}
/* Get DMA residue count. After a DMA transfer, this
* should return zero. Reading this while a DMA transfer is
* still in progress will return unpredictable results.
* If called before the channel has been used, it may return 1.
* Otherwise, it returns the number of _bytes_ left to transfer.
*
* Assumes DMA flip-flop is clear.
*/
static __inline__ int get_dma_residue(unsigned int dmanr)
{
unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
: ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
/* using short to get 16-bit wrap around */
unsigned short count;
count = 1 + dma_inb(io_port);
count += dma_inb(io_port) << 8;
return (dmanr<=3)? count : (count<<1);
}
#endif /* _ASM_DMA_H */

View file

@ -0,0 +1,146 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/hal/ddk.h
* PURPOSE: HAL provided defintions for device drivers
* PROGRAMMER: David Welch (welch@mcmail.com)
* REVISION HISTORY:
* 23/06/98: Taken from linux system.h
*/
#ifndef __INCLUDE_INTERNAL_HAL_DDK_H
#define __INCLUDE_INTERNAL_HAL_DDK_H
enum
{
DEVICE_DESCRIPTION_VERSION,
DEVICE_DESCRIPTION_VERSION1,
};
typedef ULONG DMA_WIDTH;
typedef ULONG DMA_SPEED;
typedef ULONG BUS_DATA_TYPE;
/*
* PURPOSE: Types for HalGetBusData
*/
enum
{
Cmos,
EisaConfiguration,
Pos,
PCIConfiguration,
MaximumBusDataType,
};
typedef struct _DEVICE_DESCRIPTION
{
ULONG Version;
BOOLEAN Master;
BOOLEAN ScatterGather;
BOOLEAN DemandMode;
BOOLEAN AutoInitialize;
BOOLEAN Dma32BitAddress;
BOOLEAN IgnoreCount;
BOOLEAN Reserved1;
BOOLEAN Reserved2;
ULONG BusNumber;
ULONG DmaChannel;
INTERFACE_TYPE InterfaceType;
DMA_WIDTH DmaWidth;
DMA_SPEED DmaSpeed;
ULONG MaximumLength;
ULONG DmaPort;
} DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
PVOID HalAllocateCommonBuffer(PADAPTER_OBJECT AdapterObject,
ULONG Length,
PPHYSICAL_ADDRESS LogicalAddress,
BOOLEAN CacheEnabled);
NTSTATUS HalAssignSlotResources(PUNICODE_STRING RegistryPath,
PUNICODE_STRING DriverClassName,
PDRIVER_OBJECT DriverObject,
PDEVICE_OBJECT DeviceObject,
INTERFACE_TYPE BusType,
ULONG BusNumber,
ULONG SlotNumber,
PCM_RESOURCE_LIST* AllocatedResources);
VOID HalExamineMBR(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG MBRTypeIdentifier,
PVOID Buffer);
VOID HalFreeCommonBuffer(PADAPTER_OBJECT AdapterObject,
ULONG Length,
PHYSICAL_ADDRESS LogicalAddress,
PVOID VirtualAddress,
BOOLEAN CacheEnabled);
PADAPTER_OBJECT HalGetAdapter(PDEVICE_DESCRIPTION DeviceDescription,
PULONG NumberOfMapRegisters);
ULONG HalGetBusData(BUS_DATA_TYPE BusDataType,
ULONG BusNumber,
ULONG SlotNumber,
PVOID Buffer,
ULONG Length);
ULONG HalGetBusDataByOffset(BUS_DATA_TYPE BusDataType,
ULONG BusNumber,
ULONG SlotNumber,
PVOID Buffer,
ULONG Offset,
ULONG Length);
ULONG HalGetDmaAlignmentRequirement(VOID);
ULONG HalGetInterruptVector(INTERFACE_TYPE InterfaceType,
ULONG BusNumber,
ULONG BusInterruptLevel,
ULONG BusInterruptVector,
PKIRQL Irql,
PKAFFINITY Affinity);
VOID HalQuerySystemInformation(VOID);
ULONG HalReadDmaCounter(PADAPTER_OBJECT AdapterObject);
ULONG HalSetBusData(BUS_DATA_TYPE BusDataType,
ULONG BusNumber,
ULONG SlotNumber,
PVOID Buffer,
ULONG Length);
ULONG HalSetBusDataByOffset(BUS_DATA_TYPE BusDataType,
ULONG BusNumber,
ULONG SlotNumber,
PVOID Buffer,
ULONG Offset,
ULONG Length);
BOOLEAN HalTranslateBusAddress(INTERFACE_TYPE InterfaceType,
ULONG BusNumber,
PHYSICAL_ADDRESS BusAddress,
PULONG AddressSpace,
PPHYSICAL_ADDRESS TranslatedAddress);
struct __xchg_dummy { unsigned long a[100]; };
#define __xg(x) ((struct __xchg_dummy *)(x))
extern inline LONG InterlockedDecrement(PLONG Addend)
/*
* FUNCTION: Decrements a variable as an atomic operations
* ARGUMENTS:
* Addend = Value to be decremented
* RETURNS: The decremented value
*/
{
}
extern inline LONG InterlockedExchange(PLONG Target, LONG Value)
/*
* FUNCTION: Sets a variable as an atomic operation
* ARGUMENTS:
* Target = Variable to be set
* Value = Caller specified value to set
* RETURNS: The previous value of the target
*/
{
__asm__("xchgl %0,%1"
:"=r" (Value)
:"m" (*__xg(Target)), "0" (Value)
:"memory");
return(Value);
}
#endif /* __INCLUDE_INTERNAL_HAL_DDK_H */

View file

@ -0,0 +1,71 @@
/*
*
*/
#ifndef __INTERNAL_HAL_HAL_H
#define __INTERNAL_HAL_HAL_H
typedef struct
{
unsigned short previous_task;
unsigned short reserved1;
unsigned long esp0;
unsigned short ss0;
unsigned short reserved2;
unsigned long esp1;
unsigned short ss1;
unsigned short reserved3;
unsigned long esp2;
unsigned short ss2;
unsigned short reserved4;
unsigned long cr3;
unsigned long eip;
unsigned long eflags;
unsigned long eax;
unsigned long ecx;
unsigned long edx;
unsigned long ebx;
unsigned long esp;
unsigned long ebp;
unsigned long esi;
unsigned long edi;
unsigned short es;
unsigned short reserved5;
unsigned short cs;
unsigned short reserved6;
unsigned short ss;
unsigned short reserved7;
unsigned short ds;
unsigned short reserved8;
unsigned short fs;
unsigned short reserved9;
unsigned short gs;
unsigned short reserved10;
unsigned short ldt;
unsigned short reserved11;
unsigned short trap;
unsigned short iomap_base;
unsigned short nr;
unsigned char io_bitmap[1];
} hal_thread_state;
/*
* FUNCTION: Probes for a PCI bus
* RETURNS: True if found
*/
BOOL HalPciProbe(void);
/*
* FUNCTION: Probes for a BIOS32 extension
*/
VOID Hal_bios32_probe(VOID);
/*
* FUNCTION: Determines if a a bios32 service is present
*/
BOOLEAN Hal_bios32_is_service_present(ULONG service);
#endif /* __INTERNAL_HAL_HAL_H */

View file

@ -0,0 +1,167 @@
#ifndef _ASM_IO_H
#define _ASM_IO_H
/*
* This file contains the definitions for the x86 IO instructions
* inb/inw/inl/outb/outw/outl and the "string versions" of the same
* (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
* versions of the single-IO instructions (inb_p/inw_p/..).
*
* This file is not meant to be obfuscating: it's just complicated
* to (a) handle it all in a way that makes gcc able to optimize it
* as well as possible and (b) trying to avoid writing the same thing
* over and over again with slight variations and possibly making a
* mistake somewhere.
*/
/*
* Thanks to James van Artsdalen for a better timing-fix than
* the two short jumps: using outb's to a nonexistent port seems
* to guarantee better timings even on fast machines.
*
* On the other hand, I'd like to be sure of a non-existent port:
* I feel a bit unsafe about using 0x80 (should be safe, though)
*
* Linus
*/
#ifdef SLOW_IO_BY_JUMPING
#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
#else
#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
#endif
#ifdef REALLY_SLOW_IO
#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
#else
#define SLOW_DOWN_IO __SLOW_DOWN_IO
#endif
/*
* Talk about misusing macros..
*/
#define __OUT1(s,x) \
extern inline void __out##s(unsigned x value, unsigned short port) {
#define __OUT2(s,s1,s2) \
__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
#define __OUT(s,s1,x) \
__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
#define __IN1(s) \
extern inline RETURN_TYPE __in##s(unsigned short port) { RETURN_TYPE _v;
#define __IN2(s,s1,s2) \
__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
#define __IN(s,s1,i...) \
__IN1(s) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
__IN1(s##c) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
__IN1(s##_p) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
__IN1(s##c_p) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
#define __INS(s) \
extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
#define __OUTS(s) \
extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
#define RETURN_TYPE unsigned char
/* __IN(b,"b","0" (0)) */
__IN(b,"")
#undef RETURN_TYPE
#define RETURN_TYPE unsigned short
/* __IN(w,"w","0" (0)) */
__IN(w,"")
#undef RETURN_TYPE
#define RETURN_TYPE unsigned int
__IN(l,"")
#undef RETURN_TYPE
__OUT(b,"b",char)
__OUT(w,"w",short)
__OUT(l,,int)
__INS(b)
__INS(w)
__INS(l)
__OUTS(b)
__OUTS(w)
__OUTS(l)
/*
* Note that due to the way __builtin_constant_p() works, you
* - can't use it inside a inline function (it will never be true)
* - you don't have to worry about side effects within the __builtin..
*/
#define outb(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outbc((val),(port)) : \
__outb((val),(port)))
#define inb(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inbc(port) : \
__inb(port))
#define outb_p(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outbc_p((val),(port)) : \
__outb_p((val),(port)))
#define inb_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inbc_p(port) : \
__inb_p(port))
#define outw(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outwc((val),(port)) : \
__outw((val),(port)))
#define inw(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inwc(port) : \
__inw(port))
#define outw_p(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outwc_p((val),(port)) : \
__outw_p((val),(port)))
#define inw_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inwc_p(port) : \
__inw_p(port))
#define outl(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outlc((val),(port)) : \
__outl((val),(port)))
#define inl(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inlc(port) : \
__inl(port))
#define outl_p(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outlc_p((val),(port)) : \
__outl_p((val),(port)))
#define inl_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inlc_p(port) : \
__inl_p(port))
#endif

View file

@ -0,0 +1,7 @@
/*
* PURPOSE: The number of device specific level levels
*/
#define NR_DEVICE_SPECIFIC_LEVELS (16)

View file

@ -0,0 +1,76 @@
/*
* Lowlevel memory managment definitions
*/
#ifndef __INTERNAL_HAL_PAGE_H
#define __INTERNAL_HAL_PAGE_H
#include <internal/kernel.h>
#define PAGESIZE (4096)
/*
* Sets a page entry
* vaddr: The virtual address to set the page entry for
* attributes: The access attributes to give the page
* physaddr: The physical address the page should map to
*/
void set_page(unsigned int vaddr, unsigned int attributes,
unsigned int physaddr);
#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGESIZE) ? ((((ULONG)x)&(~0xfff))+0x1000) : ((ULONG)x) )
#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~0xfff))
/*
* Page access attributes (or these together)
*/
#define PA_READ (1<<0)
#define PA_WRITE ((1<<0)+(1<<1))
#define PA_EXECUTE PA_READ
/*
* Page attributes
*/
#define PA_USER (1<<2)
#define PA_SYSTEM (0)
#define KERNEL_BASE (0xc0000000)
#define IDMAP_BASE (0xd0000000)
/*
* Return a linear address which can be used to access the physical memory
* starting at x
*/
extern inline unsigned int physical_to_linear(unsigned int x)
{
return(x+IDMAP_BASE);
}
#define FLUSH_TLB __asm__("movl %cr3,%eax\n\tmovl %eax,%cr3\n\t")
extern inline unsigned int* get_page_directory(void)
{
unsigned int page_dir=0;
__asm__("movl %%cr3,%0\n\t"
: "=r" (page_dir));
// printk("page_dir %x %x\n",page_dir,physical_to_linear(page_dir));
return((unsigned int *)physical_to_linear(page_dir));
}
/*
* Amount of memory that can be mapped by a page table
*/
#define PAGE_TABLE_SIZE (4*1024*1024)
#define PAGE_MASK(x) (x&(~0xfff))
#define VADDR_TO_PT_OFFSET(x) (((x/1024)%4096))
#define VADDR_TO_PD_OFFSET(x) ((x)/(4*1024*1024))
unsigned int* get_page_entry(unsigned int vaddr);
BOOL is_page_present(unsigned int vaddr);
#endif /* __INTERNAL_HAL_PAGE_H */

View file

@ -0,0 +1,343 @@
#ifndef _ASM_SEGMENT_H
#define _ASM_SEGMENT_H
#define ZERO_DS 0x18
#define KERNEL_CS 0x20
#define KERNEL_DS 0x28
#ifndef __ASSEMBLY__
/*
* Uh, these should become the main single-value transfer routines..
* They automatically use the right size if we just have the right
* pointer type..
*/
#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
/*
* This is a silly but good way to make sure that
* the __put_user function is indeed always optimized,
* and that we use the correct sizes..
*/
extern int bad_user_access_length(void);
/*
* dummy pointer type structure.. gcc won't try to do something strange
* this way..
*/
struct __segment_dummy { unsigned long a[100]; };
#define __sd(x) ((struct __segment_dummy *) (x))
#define __const_sd(x) ((const struct __segment_dummy *) (x))
static inline void __put_user(unsigned long x, void * y, int size)
{
switch (size) {
case 1:
__asm__ ("movb %b1,%%fs:%0"
:"=m" (*__sd(y))
:"iq" ((unsigned char) x), "m" (*__sd(y)));
break;
case 2:
__asm__ ("movw %w1,%%fs:%0"
:"=m" (*__sd(y))
:"ir" ((unsigned short) x), "m" (*__sd(y)));
break;
case 4:
__asm__ ("movl %1,%%fs:%0"
:"=m" (*__sd(y))
:"ir" (x), "m" (*__sd(y)));
break;
default:
bad_user_access_length();
}
}
static inline unsigned long __get_user(const void * y, int size)
{
unsigned long result;
switch (size) {
case 1:
__asm__ ("movb %%fs:%1,%b0"
:"=q" (result)
:"m" (*__const_sd(y)));
return (unsigned char) result;
case 2:
__asm__ ("movw %%fs:%1,%w0"
:"=r" (result)
:"m" (*__const_sd(y)));
return (unsigned short) result;
case 4:
__asm__ ("movl %%fs:%1,%0"
:"=r" (result)
:"m" (*__const_sd(y)));
return result;
default:
return bad_user_access_length();
}
}
static inline void __generic_memcpy_tofs(void * to, const void * from, unsigned long n)
{
__asm__ volatile
(" cld
push %%es
push %%fs
cmpl $3,%0
pop %%es
jbe 1f
movl %%edi,%%ecx
negl %%ecx
andl $3,%%ecx
subl %%ecx,%0
rep; movsb
movl %0,%%ecx
shrl $2,%%ecx
rep; movsl
andl $3,%0
1: movl %0,%%ecx
rep; movsb
pop %%es"
:"=abd" (n)
:"0" (n),"D" ((long) to),"S" ((long) from)
:"cx","di","si");
}
static inline void __constant_memcpy_tofs(void * to, const void * from, unsigned long n)
{
switch (n) {
case 0:
return;
case 1:
__put_user(*(const char *) from, (char *) to, 1);
return;
case 2:
__put_user(*(const short *) from, (short *) to, 2);
return;
case 3:
__put_user(*(const short *) from, (short *) to, 2);
__put_user(*(2+(const char *) from), 2+(char *) to, 1);
return;
case 4:
__put_user(*(const int *) from, (int *) to, 4);
return;
case 8:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
return;
case 12:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
__put_user(*(2+(const int *) from), 2+(int *) to, 4);
return;
case 16:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
__put_user(*(2+(const int *) from), 2+(int *) to, 4);
__put_user(*(3+(const int *) from), 3+(int *) to, 4);
return;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"push %%es\n\t" \
"push %%fs\n\t" \
"pop %%es\n\t" \
"rep ; movsl\n\t" \
x \
"pop %%es" \
: /* no outputs */ \
:"c" (n/4),"D" ((long) to),"S" ((long) from) \
:"cx","di","si")
switch (n % 4) {
case 0:
COMMON("");
return;
case 1:
COMMON("movsb\n\t");
return;
case 2:
COMMON("movsw\n\t");
return;
case 3:
COMMON("movsw\n\tmovsb\n\t");
return;
}
#undef COMMON
}
static inline void __generic_memcpy_fromfs(void * to, const void * from, unsigned long n)
{
__asm__ volatile
(" cld
cmpl $3,%0
jbe 1f
movl %%edi,%%ecx
negl %%ecx
andl $3,%%ecx
subl %%ecx,%0
fs; rep; movsb
movl %0,%%ecx
shrl $2,%%ecx
fs; rep; movsl
andl $3,%0
1: movl %0,%%ecx
fs; rep; movsb"
:"=abd" (n)
:"0" (n),"D" ((long) to),"S" ((long) from)
:"cx","di","si", "memory");
}
static inline void __constant_memcpy_fromfs(void * to, const void * from, unsigned long n)
{
switch (n) {
case 0:
return;
case 1:
*(char *)to = __get_user((const char *) from, 1);
return;
case 2:
*(short *)to = __get_user((const short *) from, 2);
return;
case 3:
*(short *) to = __get_user((const short *) from, 2);
*((char *) to + 2) = __get_user(2+(const char *) from, 1);
return;
case 4:
*(int *) to = __get_user((const int *) from, 4);
return;
case 8:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
return;
case 12:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
*(2+(int *) to) = __get_user(2+(const int *) from, 4);
return;
case 16:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
*(2+(int *) to) = __get_user(2+(const int *) from, 4);
*(3+(int *) to) = __get_user(3+(const int *) from, 4);
return;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; fs ; movsl\n\t" \
x \
: /* no outputs */ \
:"c" (n/4),"D" ((long) to),"S" ((long) from) \
:"cx","di","si","memory")
switch (n % 4) {
case 0:
COMMON("");
return;
case 1:
COMMON("fs ; movsb");
return;
case 2:
COMMON("fs ; movsw");
return;
case 3:
COMMON("fs ; movsw\n\tfs ; movsb");
return;
}
#undef COMMON
}
#define memcpy_fromfs(to, from, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy_fromfs((to),(from),(n)) : \
__generic_memcpy_fromfs((to),(from),(n)))
#define memcpy_tofs(to, from, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy_tofs((to),(from),(n)) : \
__generic_memcpy_tofs((to),(from),(n)))
/*
* These are deprecated..
*
* Use "put_user()" and "get_user()" with the proper pointer types instead.
*/
#define get_fs_byte(addr) __get_user((const unsigned char *)(addr),1)
#define get_fs_word(addr) __get_user((const unsigned short *)(addr),2)
#define get_fs_long(addr) __get_user((const unsigned int *)(addr),4)
#define put_fs_byte(x,addr) __put_user((x),(unsigned char *)(addr),1)
#define put_fs_word(x,addr) __put_user((x),(unsigned short *)(addr),2)
#define put_fs_long(x,addr) __put_user((x),(unsigned int *)(addr),4)
#ifdef WE_REALLY_WANT_TO_USE_A_BROKEN_INTERFACE
static inline unsigned short get_user_word(const short *addr)
{
return __get_user(addr, 2);
}
static inline unsigned char get_user_byte(const char * addr)
{
return __get_user(addr,1);
}
static inline unsigned long get_user_long(const int *addr)
{
return __get_user(addr, 4);
}
static inline void put_user_byte(char val,char *addr)
{
__put_user(val, addr, 1);
}
static inline void put_user_word(short val,short * addr)
{
__put_user(val, addr, 2);
}
static inline void put_user_long(unsigned long val,int * addr)
{
__put_user(val, addr, 4);
}
#endif
/*
* Someone who knows GNU asm better than I should double check the following.
* It seems to work, but I don't know if I'm doing something subtly wrong.
* --- TYT, 11/24/91
* [ nothing wrong here, Linus: I just changed the ax to be any reg ]
*/
static inline unsigned long get_fs(void)
{
unsigned long _v;
__asm__("mov %%fs,%w0":"=r" (_v):"0" (0));
return _v;
}
static inline unsigned long get_ds(void)
{
unsigned long _v;
__asm__("mov %%ds,%w0":"=r" (_v):"0" (0));
return _v;
}
static inline void set_fs(unsigned long val)
{
__asm__ __volatile__("mov %w0,%%fs": /* no output */ :"r" (val));
}
static inline void set_ds(unsigned long val)
{
__asm__ __volatile__("mov %w0,%%ds": /* no output */ :"r" (val));
}
#endif /* __ASSEMBLY__ */
#endif /* _ASM_SEGMENT_H */

View file

@ -0,0 +1,6 @@
;
; Useful prototypes and definitions
;
%define KERNEL_DS 028h
%define KERNEL_CS 020h

View file

@ -0,0 +1,29 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/iomgr.h
* PURPOSE: Internal io manager declarations
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* 28/05/97: Created
*/
#ifndef __INTERNAL_IOMGR_H
#define __INTERNAL_IOMGR_H
#include <ddk/ntddk.h>
/*
* FUNCTION:
*/
NTSTATUS IoBeginIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp);
/*
* FUNCTION: Called to initalize a loaded driver
* ARGUMENTS:
* entry = pointer to the driver initialization routine
* RETURNS: Success or failure
*/
NTSTATUS InitalizeLoadedDriver(PDRIVER_INITIALIZE entry);
#endif

View file

@ -0,0 +1,93 @@
/*
* Various useful prototypes
*/
#ifndef __KERNEL_H
#define __KERNEL_H
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/linkage.h>
#include <stdarg.h>
VOID KiInterruptDispatch(unsigned int irq);
VOID KiDispatchInterrupt(unsigned int irq);
VOID KeTimerInterrupt(VOID);
/*
* Defines a descriptor as it appears in the processor tables
*/
typedef struct
{
unsigned int a;
unsigned int b;
} descriptor;
extern descriptor idt[256];
extern descriptor gdt[256];
/*
* printf style functions
*/
asmlinkage void printk(const char* fmt, ...);
int vsprintf(char *buf, const char *fmt, va_list args);
int sprintf(char* buf, const char* fmt, ...);
typedef struct
{
/*
* Magic value (useless really)
*/
unsigned int magic;
/*
* Cursor position
*/
unsigned int cursorx;
unsigned int cursory;
/*
* Number of files (including the kernel) loaded
*/
unsigned int nr_files;
/*
* Range of physical memory being used by the system
*/
unsigned int start_mem;
unsigned int end_mem;
/*
* List of module lengths (terminated by a 0)
*/
unsigned int module_length[64];
} boot_param;
/*
* Initalization functions (called once by main())
*/
void MmInitalize(boot_param* bp);
void InitalizeExceptions(void);
void InitalizeIRQ(void);
void InitializeTimer(void);
void InitConsole(boot_param* bp);
void KeInitDpc(void);
void HalInit(boot_param* bp);
void IoInit(void);
void ObjNamespcInit(void);
void PsMgrInit(void);
/*
* FUNCTION: Called to execute queued dpcs
*/
void KeDrainDpcQueue(void);
void KeExpireTimers(void);
typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
asmlinkage unsigned int ExHookException(exception_hook fn, UINT exp);
#endif

View file

@ -0,0 +1,5 @@
#ifdef __cplusplus
#define asmlinkage extern "C"
#else
#define asmlinkage
#endif

View file

@ -0,0 +1,146 @@
/*
* Higher level memory managment definitions
*/
#ifndef __MM_H
#define __MM_H
#define PAGE_SYSTEM (0x80000000)
#include <internal/linkage.h>
#include <internal/kernel.h>
#include <windows.h>
typedef struct _memory_area
/*
* PURPOSE: Describes an area of virtual memory
*/
{
/*
* Access protection
*/
unsigned int access;
/*
* Memory region base
*/
unsigned int base;
/*
* Memory region length
*/
unsigned int length;
/*
* Memory type (Mapped file, mapped from an executable or private)
*/
unsigned int type;
/*
* Memory region state (committed, reserved or free)
*/
unsigned int state;
/*
* Original access protection
*/
unsigned int initial_access;
/*
* Used to maintain the linked list of memory areas
*/
struct _memory_area* previous;
struct _memory_area* next;
/*
* True the region is locked
*/
BOOL lock;
/*
* FUNCTION: Decommits all the pages in the regions
*/
void (*free)(struct _memory_area* marea);
/*
* FUNCTION: Handles a page fault by loading the required page
* RECEIVES:
* marea = the memory area
* address = the relative address of the page to load
* RETURNS:
* TRUE = the access should be restarted
* FALSE = the access was illegal and an exception should
* be generated
* NOTES: This function is guarrented to be called within the context
* of the thread which required a page to be loaded
*/
BOOL (*load_page)(struct _memory_area* marea, unsigned int address);
} memory_area;
/*
* FUNCTION: Gets a page with a restricted max physical address (i.e.
* suitable for dma)
* RETURNS:
* The physical address of the page if it succeeds
* NULL if it fails.
* NOTES: This is very inefficent because the list isn't sorted. On the
* other hand sorting the list would be quite expensive especially if dma
* is only used infrequently. Perhaps a special cache of dma pages should
* be maintained?
*/
unsigned int get_dma_page(unsigned int max_address);
/*
* FUNCTION: Allocate a page and return its physical address
* RETURNS: The physical address of the page allocated
*/
asmlinkage unsigned int get_free_page(void);
/*
* FUNCTION: Adds pages to the free list
* ARGUMENTS:
* physical_base = Physical address of the base of the region to
* be freed
* nr = number of continuous pages to free
*/
asmlinkage void free_page(unsigned int physical_base, unsigned int nr);
/*
* FUNCTION: Returns the physical address mapped by a given virtual address
* ARGUMENTS:
* vaddr = virtual address to query
* RETURNS: The physical address if present in memory
* Zero if paged out or invalid
* NOTE: This doesn't do any synchronization
*/
unsigned int get_page_physical_address(unsigned int vaddr);
void mark_page_not_writable(unsigned int vaddr);
void VirtualInit(boot_param* bp);
/*
* FUNCTION: Returns the first memory area starting in the region or the last
* one before the start of the region
* ARGUMENTS:
* list_head = Head of the list of memory areas to search
* base = base address of the region
* length = length of the region
* RETURNS: A pointer to the area found or
* NULL if the region was before the first region on the list
*/
memory_area* find_first_marea(memory_area* list_head, unsigned int base,
unsigned int length);
/*
* Head of the list of system memory areas
*/
extern memory_area* system_memory_area_list_head;
/*
* Head of the list of user memory areas (this should be per process)
*/
extern memory_area* memory_area_list_head;
#endif

View file

@ -0,0 +1,34 @@
#ifndef __MODULE_H
#define __MODULE_H
#include <coff.h>
typedef struct
/*
*
*/
{
unsigned int text_base;
unsigned int data_base;
unsigned int bss_base;
SCNHDR* scn_list;
char* str_tab;
SYMENT* sym_list;
unsigned int size;
/*
* Base address of the module in memory
*/
unsigned int base;
/*
* Offset of the raw data in memory
*/
unsigned int raw_data_off;
} module;
int process_boot_module(unsigned int start);
#endif

View file

@ -0,0 +1,89 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/objmgr.h
* PURPOSE: Object manager definitions
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
#ifndef __INCLUDE_INTERNAL_OBJMGR_H
#define __INCLUDE_INTERNAL_OBJMGR_H
#include <ddk/types.h>
typedef struct
{
CSHORT Type;
CSHORT Size;
} COMMON_BODY_HEADER, *PCOMMON_BODY_HEADER;
typedef struct _DIRECTORY_OBJECT
{
CSHORT Type;
CSHORT Size;
/*
* PURPOSE: Head of the list of our subdirectories
*/
LIST_ENTRY head;
} DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
/*
* Enumeration of object types
*/
enum
{
OBJTYP_INVALID,
OBJTYP_TYPE,
OBJTYP_DIRECTORY,
OBJTYP_SYMLNK,
OBJTYP_DEVICE,
OBJTYP_THREAD,
OBJTYP_MAX,
};
BOOL ObjAddObjectToNameSpace(const char* path, POBJECT_HEADER Object);
VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type);
VOID ObInitializeObjectHeader(CSHORT id, LPCSTR name, POBJECT_HEADER obj);
/*
* FUNCTION: Get the size of an object
* ARGUMENTS:
* Type = Object type
* RETURNS: The size in bytes
*/
ULONG ObSizeOf(CSHORT Type);
HANDLE ObAddHandle(PVOID obj);
PVOID ObGetObjectByHandle(HANDLE h);
PVOID ObLookupObject(PDIRECTORY_OBJECT root, const char* _string);
PVOID ObGenericCreateObject(PHANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
CSHORT Type);
/*
* FUNCTION: Creates an entry within a directory
* ARGUMENTS:
* parent = Parent directory
* object = Header of the object to add
*/
VOID ObCreateEntry(PDIRECTORY_OBJECT parent, POBJECT_HEADER object);
extern inline POBJECT_HEADER BODY_TO_HEADER(PVOID body)
{
PCOMMON_BODY_HEADER chdr = (PCOMMON_BODY_HEADER)body;
return(CONTAINING_RECORD((&(chdr->Type)),OBJECT_HEADER,Type));
}
extern inline PVOID HEADER_TO_BODY(POBJECT_HEADER obj)
{
return(((void *)obj)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER));
}
#define OBJECT_ALLOC_SIZE(type) (ObSizeOf(type)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */

View file

@ -0,0 +1,19 @@
#ifndef __INTERNAL_POOL_H
#define __INTERNAL_POOL_H
#include <windows.h>
#include <internal/linkage.h>
/*
* Maximum size of the kmalloc area (this is totally arbitary)
*/
#define NONPAGED_POOL_SIZE (4*1024*1024)
/*
* Allocates an arbitary sized block at any alignment
*/
//asmlinkage void* ExAllocatePool(ULONG size);
//asmlinkage void ExFreePool(void* block);
#endif /* __INTERNAL_POOL_H */

View file

@ -0,0 +1,50 @@
#ifndef __INCLUDE_INTERNAL_PSMGR_H
#define __INCLUDE_INTERNAL_PSMGR_H
#include <internal/hal/hal.h>
void PsInitThreadManagment(void);
/*
* PURPOSE: Thread states
*/
enum
{
/*
* PURPOSE: Don't touch
*/
THREAD_STATE_INVALID,
/*
* PURPOSE: Waiting to be dispatched
*/
THREAD_STATE_RUNNABLE,
/*
* PURPOSE: Currently running
*/
THREAD_STATE_RUNNING,
/*
* PURPOSE: Doesn't want to run
*/
THREAD_STATE_SLEEPING,
/*
* Waiting to be freed
*/
THREAD_STATE_TERMINATED,
};
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus);
/*
* Functions the HAL must provide
*/
void HalInitFirstTask(PTHREAD_OBJECT thread);
void HalInitTask(PTHREAD_OBJECT thread, PKSTART_ROUTINE fn,
PVOID StartContext);
void HalTaskSwitch(PTHREAD_OBJECT thread);
#endif

View file

@ -0,0 +1,10 @@
/*
* Some useful things
*/
//#define NULL ((void*)0)
#ifndef NULL
#define NULL (0)
#endif

View file

@ -0,0 +1,680 @@
/*
* Adapted from linux for the reactos kernel, march 1998 -- David Welch
*/
#ifndef _LINUX_STRING_H_
#define _LINUX_STRING_H_
#include "types.h" /* for size_t */
#ifndef NULL
#define NULL ((void *) 0)
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern char * ___strtok;
extern char * strcpy(char *,const char *);
extern char * strncpy(char *,const char *, __kernel_size_t);
extern char * strcat(char *, const char *);
extern char * strncat(char *, const char *, __kernel_size_t);
extern char * strchr(const char *,int);
extern char * strrchr(const char *,int);
extern char * strpbrk(const char *,const char *);
extern char * strtok(char *,const char *);
extern char * strstr(const char *,const char *);
extern __kernel_size_t strlen(const char *);
extern __kernel_size_t strnlen(const char *,__kernel_size_t);
extern __kernel_size_t strspn(const char *,const char *);
extern int strcmp(const char *,const char *);
extern int strncmp(const char *,const char *,__kernel_size_t);
extern void * memset(void *,int,__kernel_size_t);
extern void * memcpy(void *,const void *,__kernel_size_t);
extern void * memmove(void *,const void *,__kernel_size_t);
extern void * memscan(void *,int,__kernel_size_t);
extern int memcmp(const void *,const void *,__kernel_size_t);
/*
* Include machine specific inline routines
*/
#ifndef _I386_STRING_H_
#define _I386_STRING_H_
/*
* On a 486 or Pentium, we are better off not using the
* byte string operations. But on a 386 or a PPro the
* byte string ops are faster than doing it by hand
* (MUCH faster on a Pentium).
*
* Also, the byte strings actually work correctly. Forget
* the i486 routines for now as they may be broken..
*/
#if FIXED_486_STRING && (CPU == 486 || CPU == 586)
#include <asm/string-486.h>
#else
/*
* This string-include defines all string functions as inline
* functions. Use gcc. It also assumes ds=es=data space, this should be
* normal. Most of the string-functions are rather heavily hand-optimized,
* see especially strtok,strstr,str[c]spn. They should work, but are not
* very easy to understand. Everything is done entirely within the register
* set, making the functions fast and clean. String instructions have been
* used through-out, making for "slightly" unclear code :-)
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
#define __HAVE_ARCH_STRCPY
extern inline char * strcpy(char * dest,const char *src)
{
__asm__ __volatile__(
"cld\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest):"si","di","ax","memory");
return dest;
}
#define __HAVE_ARCH_STRNCPY
extern inline char * strncpy(char * dest,const char *src,size_t count)
{
__asm__ __volatile__(
"cld\n"
"1:\tdecl %2\n\t"
"js 2f\n\t"
"lodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"rep\n\t"
"stosb\n"
"2:"
: /* no output */
:"S" (src),"D" (dest),"c" (count):"si","di","ax","cx","memory");
return dest;
}
#define __HAVE_ARCH_STRCAT
extern inline char * strcat(char * dest,const char * src)
{
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx");
return dest;
}
#define __HAVE_ARCH_STRNCAT
extern inline char * strncat(char * dest,const char * src,size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n\t"
"movl %4,%3\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n"
"2:\txorl %2,%2\n\t"
"stosb"
: /* no output */
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count)
:"si","di","ax","cx","memory");
return dest;
}
#define __HAVE_ARCH_STRCMP
extern inline int strcmp(const char * cs,const char * ct)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tlodsb\n\t"
"scasb\n\t"
"jne 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%eax\n"
"3:"
:"=a" (__res):"S" (cs),"D" (ct):"si","di");
return __res;
}
#define __HAVE_ARCH_STRNCMP
extern inline int strncmp(const char * cs,const char * ct,size_t count)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsb\n\t"
"scasb\n\t"
"jne 3f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n"
"2:\txorl %%eax,%%eax\n\t"
"jmp 4f\n"
"3:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%al\n"
"4:"
:"=a" (__res):"S" (cs),"D" (ct),"c" (count):"si","di","cx");
return __res;
}
#define __HAVE_ARCH_STRCHR
extern inline char * strchr(const char * s, int c)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
"je 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"movl $1,%1\n"
"2:\tmovl %1,%0\n\t"
"decl %0"
:"=a" (__res):"S" (s),"0" (c):"si");
return __res;
}
#define __HAVE_ARCH_STRRCHR
extern inline char * strrchr(const char * s, int c)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
"jne 2f\n\t"
"leal -1(%%esi),%0\n"
"2:\ttestb %%al,%%al\n\t"
"jne 1b"
:"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si");
return __res;
}
#define __HAVE_ARCH_STRSPN
extern inline size_t strspn(const char * cs, const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"je 1b\n"
"2:\tdecl %0"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res-cs;
}
#define __HAVE_ARCH_STRCSPN
extern inline size_t strcspn(const char * cs, const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 1b\n"
"2:\tdecl %0"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res-cs;
}
#define __HAVE_ARCH_STRPBRK
extern inline char * strpbrk(const char * cs,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 1b\n\t"
"decl %0\n\t"
"jmp 3f\n"
"2:\txorl %0,%0\n"
"3:"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res;
}
#define __HAVE_ARCH_STRSTR
extern inline char * strstr(const char * cs,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t" \
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
"movl %%ecx,%%edx\n"
"1:\tmovl %4,%%edi\n\t"
"movl %%esi,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"repe\n\t"
"cmpsb\n\t"
"je 2f\n\t" /* also works for empty string, see above */
"xchgl %%eax,%%esi\n\t"
"incl %%esi\n\t"
"cmpb $0,-1(%%eax)\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"2:"
:"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct)
:"cx","dx","di","si");
return __res;
}
#define __HAVE_ARCH_STRLEN
extern inline size_t strlen(const char * s)
{
register int __res;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"notl %0\n\t"
"decl %0"
:"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di");
return __res;
}
#define __HAVE_ARCH_STRTOK
extern inline char * strtok(char * s,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"testl %1,%1\n\t"
"jne 1f\n\t"
"testl %0,%0\n\t"
"je 8f\n\t"
"movl %0,%1\n"
"1:\txorl %0,%0\n\t"
"movl $-1,%%ecx\n\t"
"xorl %%eax,%%eax\n\t"
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"je 7f\n\t" /* empty delimiter-string */
"movl %%ecx,%%edx\n"
"2:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 7f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"je 2b\n\t"
"decl %1\n\t"
"cmpb $0,(%1)\n\t"
"je 7f\n\t"
"movl %1,%0\n"
"3:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 5f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 3b\n\t"
"decl %1\n\t"
"cmpb $0,(%1)\n\t"
"je 5f\n\t"
"movb $0,(%1)\n\t"
"incl %1\n\t"
"jmp 6f\n"
"5:\txorl %1,%1\n"
"6:\tcmpb $0,(%0)\n\t"
"jne 7f\n\t"
"xorl %0,%0\n"
"7:\ttestl %0,%0\n\t"
"jne 8f\n\t"
"movl %0,%1\n"
"8:"
:"=b" (__res),"=S" (___strtok)
:"0" (___strtok),"1" (s),"g" (ct)
:"ax","cx","dx","di","memory");
return __res;
}
extern inline void * __memcpy(void * to, const void * from, size_t n)
{
__asm__ __volatile__(
"cld\n\t"
"rep ; movsl\n\t"
"testb $2,%b1\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b1\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
: /* no output */
:"c" (n/4), "q" (n),"D" ((long) to),"S" ((long) from)
: "cx","di","si","memory");
return (to);
}
/*
* This looks horribly ugly, but the compiler can optimize it totally,
* as the count is constant.
*/
extern inline void * __constant_memcpy(void * to, const void * from, size_t n)
{
switch (n) {
case 0:
return to;
case 1:
*(unsigned char *)to = *(const unsigned char *)from;
return to;
case 2:
*(unsigned short *)to = *(const unsigned short *)from;
return to;
case 3:
*(unsigned short *)to = *(const unsigned short *)from;
*(2+(unsigned char *)to) = *(2+(const unsigned char *)from);
return to;
case 4:
*(unsigned long *)to = *(const unsigned long *)from;
return to;
case 8:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
return to;
case 12:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
return to;
case 16:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
return to;
case 20:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
*(4+(unsigned long *)to) = *(4+(const unsigned long *)from);
return to;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; movsl" \
x \
: /* no outputs */ \
: "c" (n/4),"D" ((long) to),"S" ((long) from) \
: "cx","di","si","memory");
switch (n % 4) {
case 0: COMMON(""); return to;
case 1: COMMON("\n\tmovsb"); return to;
case 2: COMMON("\n\tmovsw"); return to;
case 3: COMMON("\n\tmovsw\n\tmovsb"); return to;
}
#undef COMMON
}
#define __HAVE_ARCH_MEMCPY
#define memcpy(t, f, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy((t),(f),(n)) : \
__memcpy((t),(f),(n)))
#define __HAVE_ARCH_MEMMOVE
extern inline void * memmove(void * dest,const void * src, size_t n)
{
if (dest<src)
__asm__ __volatile__(
"cld\n\t"
"rep\n\t"
"movsb"
: /* no output */
:"c" (n),"S" (src),"D" (dest)
:"cx","si","di");
else
__asm__ __volatile__(
"std\n\t"
"rep\n\t"
"movsb\n\t"
"cld"
: /* no output */
:"c" (n),
"S" (n-1+(const char *)src),
"D" (n-1+(char *)dest)
:"cx","si","di","memory");
return dest;
}
#define memcmp __builtin_memcmp
#define __HAVE_ARCH_MEMCHR
extern inline void * memchr(const void * cs,int c,size_t count)
{
register void * __res;
if (!count)
return NULL;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"je 1f\n\t"
"movl $1,%0\n"
"1:\tdecl %0"
:"=D" (__res):"a" (c),"D" (cs),"c" (count)
:"cx");
return __res;
}
extern inline void * __memset_generic(void * s, char c,size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"rep\n\t"
"stosb"
: /* no output */
:"a" (c),"D" (s),"c" (count)
:"cx","di","memory");
return s;
}
/* we might want to write optimized versions of these later */
#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
/*
* memset(x,0,y) is a reasonably common thing to do, so we want to fill
* things 32 bits at a time even when we don't know the size of the
* area at compile-time..
*/
extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"rep ; stosl\n\t"
"testb $2,%b1\n\t"
"je 1f\n\t"
"stosw\n"
"1:\ttestb $1,%b1\n\t"
"je 2f\n\t"
"stosb\n"
"2:"
: /* no output */
:"a" (c), "q" (count), "c" (count/4), "D" ((long) s)
:"cx","di","memory");
return (s);
}
/* Added by Gertjan van Wingerde to make minix and sysv module work */
#define __HAVE_ARCH_STRNLEN
extern inline size_t strnlen(const char * s, size_t count)
{
register int __res;
__asm__ __volatile__(
"movl %1,%0\n\t"
"jmp 2f\n"
"1:\tcmpb $0,(%0)\n\t"
"je 3f\n\t"
"incl %0\n"
"2:\tdecl %2\n\t"
"cmpl $-1,%2\n\t"
"jne 1b\n"
"3:\tsubl %1,%0"
:"=a" (__res)
:"c" (s),"d" (count)
:"dx");
return __res;
}
/* end of additional stuff */
/*
* This looks horribly ugly, but the compiler can optimize it totally,
* as we by now know that both pattern and count is constant..
*/
extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count)
{
switch (count) {
case 0:
return s;
case 1:
*(unsigned char *)s = pattern;
return s;
case 2:
*(unsigned short *)s = pattern;
return s;
case 3:
*(unsigned short *)s = pattern;
*(2+(unsigned char *)s) = pattern;
return s;
case 4:
*(unsigned long *)s = pattern;
return s;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; stosl" \
x \
: /* no outputs */ \
: "a" (pattern),"c" (count/4),"D" ((long) s) \
: "cx","di","memory")
switch (count % 4) {
case 0: COMMON(""); return s;
case 1: COMMON("\n\tstosb"); return s;
case 2: COMMON("\n\tstosw"); return s;
case 3: COMMON("\n\tstosw\n\tstosb"); return s;
}
#undef COMMON
}
#define __constant_c_x_memset(s, c, count) \
(__builtin_constant_p(count) ? \
__constant_c_and_count_memset((s),(c),(count)) : \
__constant_c_memset((s),(c),(count)))
#define __memset(s, c, count) \
(__builtin_constant_p(count) ? \
__constant_count_memset((s),(c),(count)) : \
__memset_generic((s),(c),(count)))
#define __HAVE_ARCH_MEMSET
#define memset(s, c, count) \
(__builtin_constant_p(c) ? \
__constant_c_x_memset((s),(0x01010101UL*(unsigned char)c),(count)) : \
__memset((s),(c),(count)))
/*
* find the first occurrence of byte 'c', or 1 past the area if none
*/
#define __HAVE_ARCH_MEMSCAN
extern inline void * memscan(void * addr, int c, size_t size)
{
if (!size)
return addr;
__asm__("cld
repnz; scasb
jnz 1f
dec %%edi
1: "
: "=D" (addr), "=c" (size)
: "0" (addr), "1" (size), "a" (c));
return addr;
}
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LINUX_STRING_H_ */

View file

@ -0,0 +1,13 @@
/*
*
*/
#include "stddef.h"
typedef struct
{
char* name;
unsigned int value;
} export;
extern export symbol_table[];

View file

@ -0,0 +1,56 @@
#ifndef _LINUX_TYPES_H
#define _LINUX_TYPES_H
#ifndef NULL
# define NULL ((void *) 0)
#endif
#ifndef _I386_TYPES_H
#define _I386_TYPES_H
/*
* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
* header files exported to user space
*/
typedef __signed__ char __s8;
typedef unsigned char __u8;
typedef __signed__ short __s16;
typedef unsigned short __u16;
typedef __signed__ int __s32;
typedef unsigned int __u32;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
typedef signed char s8;
typedef unsigned char u8;
typedef signed short s16;
typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#endif /* __KERNEL__ */
#endif
typedef unsigned int size_t;
typedef size_t __kernel_size_t;
#endif /* _LINUX_TYPES_H */

View file

@ -0,0 +1,17 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/version.h
* PURPOSE: Defines the current version
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
#ifndef __VERSION_H
#define __VERSION_H
#define KERNEL_VERSION "0.0.7"
#define KERNEL_MAJOR_VERSION 0
#define KERNEL_MINOR_VERSION 0
#define KERNEL_PATCH_LEVEL 7
#endif

View file

@ -0,0 +1,57 @@
/********************************************************************
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.
********************************************************************/
#ifndef Atoms__h
#define Atoms__h
#include <windows.h>
#include <ctype.h>
//#include <types.h>
typedef unsigned long ATOMID;
typedef struct {
ATOMID q; /* what a string 'hashes' to */
long idx; /* index into data table */
long refcnt; /* how many clients have it */
long idsize; /* space used by this slot */
} ATOMENTRY;
typedef ATOMENTRY *LPATOMENTRY;
typedef struct {
ATOMENTRY *AtomTable; /* pointer to table data */
wchar_t *AtomData; /* pointer to name data */
unsigned long TableSize; /* number items in this table */
unsigned long DataSize; /* space used by string data */
LPVOID lpDrvData;
} ATOMTABLE;
typedef ATOMTABLE *LPATOMTABLE;
#endif /* Atoms__h */

View file

@ -0,0 +1,110 @@
/*
* kernel/heap.c
* Copyright (C) 1996, Onno Hovers, All rights reserved
* Adapted for the ReactOS system libraries by David Welch (welch@mcmail.com)
* todo: __processheap should be part of peb.
*/
#ifndef __INCLUDE_KERNEL32_HEAP_H
#define __INCLUDE_KERNEL32_HEAP_H
/* System wide includes ****************************************************/
#include <windows.h>
/* System library's private includes ***************************************/
#include <ntdll/pagesize.h>
/* definitions */
#define HEAP_ADMIN_SIZE 8
#define HEAP_FRAG_ADMIN_SIZE 8
#define HEAP_ROUNDVAL (2*(HEAP_ADMIN_SIZE)-1)
#define HEAP_FRAGMENT_THRESHOLD 256
#define SIZE_TOTAL(s) ROUNDUP((s)+HEAP_ADMIN_SIZE,8)
#define SIZE_ROUND(s) ROUNDUP((s),8)
#define HEAP_FRAG_MAGIC 0x10
#define HEAP_ALLOC_MASK 0xF0000000
#define HEAP_FREE_MASK 0x80000000
#define HEAP_SIZE_MASK 0x0FFFFFFF
#define HEAP_FREE_TAG 0x80000000 /* free region */
#define HEAP_NORMAL_TAG 0x30000000 /* normal allocation */
#define HEAP_MOVEABLE_TAG 0x50000000 /* moveable handle */
#define HEAP_SUB_TAG 0x70000000 /* suballocated for fragments */
#define HEAP_ISFREE(p) ((((PHEAP_BLOCK)p)->Size) & HEAP_FREE_MASK)
#define HEAP_ISALLOC(p) (((((PHEAP_BLOCK)p)->Size) & HEAP_FREE_MASK)==0)
#define HEAP_ISFRAG(p) ((((PHEAP_FRAGMENT)p)->Magic)==HEAP_FRAG_MAGIC)
#define HEAP_ISNORMAL(p) (((((PHEAP_BLOCK)p)->Size) & HEAP_ALLOC_MASK)\
==HEAP_NORMAL_TAG)
#define HEAP_ISSUB(p) (((((PHEAP_BLOCK)p)->Size) & HEAP_ALLOC_MASK)\
==HEAP_SUB_TAG)
#define HEAP_ISOLD(p) (((((PHEAP_BLOCK)p)->Size) & HEAP_ALLOC_MASK)\
==HEAP_MOVEABLE_TAG)
#define HEAP_SIZE(p) ((((PHEAP_BLOCK)p)->Size) & HEAP_SIZE_MASK )
#define HEAP_RSIZE(p) SIZE_ROUND(HEAP_SIZE(p))
#define HEAP_TSIZE(p) SIZE_TOTAL(HEAP_SIZE(p))
#define HEAP_PREVSIZE(p) ((((PHEAP_BLOCK)p)->PrevSize) & HEAP_SIZE_MASK )
#define HEAP_FRAG_SIZE(p) (((PHEAP_FRAGMENT)p)->Size)
#define HEAP_PREV(p) ((PHEAP_BLOCK)(((LPVOID)(p))-HEAP_PREVSIZE(p)))
#define HEAP_NEXT(p) ((PHEAP_BLOCK)(((LPVOID)(p))+HEAP_TSIZE(p)))
typedef struct __HEAP_BLOCK
{
ULONG Size; /* this is relative to Data */
ULONG PrevSize; /* p - p->PrevSize is the previous block */
} HEAP_BLOCK, *PHEAP_BLOCK;
struct __HEAP_SUBALLOC;
typedef struct __HEAP_FRAGMENT
{
UCHAR Magic;
UCHAR Number;
ULONG Size;
struct __HEAP_SUBALLOC *Sub;
/* this is only used in free blocks */
struct __HEAP_FRAGMENT *FreeNext;
struct __HEAP_FRAGMENT *FreePrev;
} HEAP_FRAGMENT, *PHEAP_FRAGMENT, *LPHEAP_FRAGMENT;
typedef struct __HEAP_SUBALLOC
{
ULONG Magic;
ULONG NumberFree;
struct __HEAP_SUBALLOC *Next;
struct __HEAP_SUBALLOC *Prev;
struct __HEAP_FRAGMENT *FirstFree;
struct __HEAP_BUCKET *Bucket;
ULONG Bitmap;
} HEAP_SUBALLOC, *PHEAP_SUBALLOC, *LPHEAP_SUBALLOC;
typedef struct __HEAP_BUCKET
{
struct __HEAP_SUBALLOC *FirstFree;
ULONG Size;
ULONG Number;
ULONG TotalSize;
} HEAP_BUCKET, *PHEAP_BUCKET, *LPHEAP_BUCKET;
typedef struct __HEAP
{
ULONG Magic;
LPVOID End;
ULONG Flags;
CRITICAL_SECTION Synchronize;
HEAP_BUCKET Bucket[8];
struct __HEAP *NextHeap;
LPVOID LastBlock;
/* this has to aligned on an 8 byte boundary */
HEAP_BLOCK Start __attribute__((aligned (8)));
} HEAP, *PHEAP;
PHEAP __ProcessHeap;
#endif /* __INCLUDE_KERNEL32_HEAP_H */

View file

@ -0,0 +1,63 @@
#ifndef __PEB_DEFINED
#define __PEB_DEFINED
#include "heap.h"
typedef void* HANDLE_TABLE;
typedef struct _pPebInfo {
LPWSTR lpCommandLine;
DWORD cb;
HANDLE hStdInput; //18
HANDLE hStdOutput;
HANDLE hStdError;
LPWSTR lpEnvironment;
DWORD dwX;
DWORD dwY;
DWORD dwXSize;
DWORD dwYSize;
DWORD dwXCountChars;
DWORD dwYCountChars;
DWORD dwFillAttribute;
DWORD dwFlags;
DWORD wShowWindow;
LPTSTR lpTitle;
LPTSTR lpDesktop;
LPTSTR reserved;
DWORD cbReserved2;
LPTSTR lpReserved1;
} PEBINFO;
typedef struct _NT_PEB
{
LONG ImageBaseAddress;
void *HeapIndex;
DWORD dwTlsBits[2]; // tls in use bits
WORD NumberOfProcessors;
WORD NtGlobalFlag;
DWORD dwCriticalSectionTimeout;
DWORD dwHeapReserve;
DWORD dwHeapCommit;
DWORD dwHeapDecommitFreeBlockThreshold;
DWORD dwNumberOfHeaps;
DWORD dwMaxiumNumberOfHeaps;
PEBINFO *pPebInfo;
HEAP *pProcessHeap;
HANDLE_TABLE htGDISharedHandleTable;
ATOMTABLE LocalAtomTable;
CRITICAL_SECTION *pCriticalSection;
WORD wMajorVersion;
WORD wMinorVersion;
WORD wBuildNumber;
WORD wPlatformId;
} NT_PEB;
NT_PEB *GetPeb()
{
return NULL;
}
#endif

View file

@ -0,0 +1,56 @@
/*
This file contains a proposal for Thread Environment Block.
*/
#ifndef __TEB_DEFINED
#define __TEB_DEFINED
typedef struct _NT_TIB {
struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
void *StackBase;
void *StackLimit;
void *SubSystemTib;
union {
void *FiberData;
DWORD Version;
};
void *ArbitraryUserPointer;
struct _NT_TIB *Self;
} NT_TIB;
typedef struct _NT_TEB
{
NT_TIB Tib;
DWORD dwProcessId;
DWORD dwThreadId;
HANDLE hRPC;
NT_PEB *pPeb;
DWORD dwErrCode;
WORD nMutexCount;
LCID Locale;
//HQUEUE MessageQueue
DWORD dwTlsIndex ;
LPVOID TlsData[512];
} NT_TEB;
// should be an inline asm macro
NT_TEB *GetTeb()
{
return NULL;
}
#endif

1095
reactos/include/messages.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
/*
*
*/
#ifdef i386
#define PAGESIZE (4096)
#endif

965
reactos/include/sockets.h Normal file
View file

@ -0,0 +1,965 @@
/*
Sockets.h
Windows Sockets specification version 1.1
Copyright (C) 1996 Free Software Foundation, Inc.
Thanks to Linux header files for supplying many needed definitions
Author: Scott Christley <scottc@net-community.com>
Date: 1996
This file is part of the Windows32 API Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
If you are interested in a warranty or support for this source code,
contact Scott Christley <scottc@net-community.com> for more information.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*-
* Portions Copyright (c) 1980, 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* Permission to use, copy, modify and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* -
* --Copyright--
*/
#ifndef _GNU_H_WINDOWS32_SOCKETS
#define _GNU_H_WINDOWS32_SOCKETS
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* BSD */
#ifndef _SYS_TYPES_H
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
#endif
/*
Default maximium number of sockets.
Define this before including Sockets.h to increase; this does not
mean that the underlying Windows Sockets implementation has to
support that many!
*/
#ifndef FD_SETSIZE
#define FD_SETSIZE 64
#endif /* !FD_SETSIZE */
/*
These macros are critical to the usage of Windows Sockets.
According to the documentation, a SOCKET is no longer represented
by a "small non-negative integer"; so all programs MUST use these
macros for setting, initializing, clearing and checking the
fd_set structures.
*/
typedef u_int SOCKET;
/* fd_set may have been defined by the newlib <sys/types.h>. */
#ifdef fd_set
#undef fd_set
#endif
typedef struct fd_set {
u_int fd_count;
SOCKET fd_array[FD_SETSIZE];
} fd_set;
/* Internal function, not documented except in winsock.h */
extern int PASCAL __WSAFDIsSet(SOCKET, fd_set*);
#ifdef FD_CLR
#undef FD_CLR
#endif
#define FD_CLR(fd, set) do { \
u_int __i; \
for (__i = 0; __i < ((fd_set*)(set))->fd_count ; __i++) { \
if (((fd_set*)(set))->fd_array[__i] == fd) { \
while (__i < ((fd_set*)(set))->fd_count-1) { \
((fd_set*)(set))->fd_array[__i] = \
((fd_set*)(set))->fd_array[__i+1]; \
__i++; \
} \
((fd_set*)(set))->fd_count--; \
break; \
} \
} \
} while(0)
#ifdef FD_SET
#undef FD_SET
#endif
#define FD_SET(fd, set) do { \
if (((fd_set*)(set))->fd_count < FD_SETSIZE) \
((fd_set*)(set))->fd_array[((fd_set*)(set))->fd_count++]=(fd);\
} while(0)
#ifdef FD_ZERO
#undef FD_ZERO
#endif
#define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
#ifdef FD_ISSET
#undef FD_ISSET
#endif
#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
/*
time structures
*/
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
/*
Operations on timevals.
NB: timercmp does not work for >= or <=.
*/
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
#define timercmp(tvp, uvp, cmp) \
(((tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) \
|| (tvp)->tv_sec cmp (uvp)->tv_sec)
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
/*
ioctl command encoding.
Some of this is different than what Linux has
*/
#define IOCPARM_MASK 0x7f
#define IOC_VOID 0x20000000
#define IOC_OUT 0x40000000
#define IOC_IN 0x80000000
#define IOC_INOUT (IOC_IN | IOC_OUT)
/* _IO(magic, subcode) */
#define _IO(c,d) (IOC_VOID | ((c)<<8) | (d))
/* _IOXX(magic, subcode, arg_t) */
#define _IOW(c,d,t) (IOC_IN | (((long)sizeof(t) & IOCPARM_MASK)<<16) | \
((c)<<8) | (d))
#define _IOR(c,d,t) (IOC_OUT | (((long)sizeof(t) & IOCPARM_MASK)<<16) | \
((c)<<8) | (d))
/*
This stuff is hard-coded on Linux
But winsock.h uses the macros defined above
*/
#define FIONREAD _IOR('f', 127, u_long)
#define FIONBIO _IOW('f', 126, u_long)
#define FIOASYNC _IOW('f', 125, u_long)
#define SIOCSHIWAT _IOW('s', 0, u_long)
#define SIOCGHIWAT _IOR('s', 1, u_long)
#define SIOCSLOWAT _IOW('s', 2, u_long)
#define SIOCGLOWAT _IOR('s', 3, u_long)
#define SIOCATMARK _IOR('s', 7, u_long)
/*
Structures returned by network data base library, taken from the
BSD file netdb.h. All addresses are supplied in host order, and
returned in network order (suitable for use in system calls).
Slight modifications for differences between Linux and winsock.h
*/
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
short h_addrtype; /* host address type */
short h_length; /* length of address */
char **h_addr_list; /* list of addresses */
#define h_addr h_addr_list[0] /* address, for backward compat */
};
/*
* Assumption here is that a network number
* fits in an unsigned long -- someday that won't be true!
*/
struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
short n_addrtype; /* net address type */
u_long n_net; /* network # */
};
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
short s_port; /* port # */
char *s_proto; /* protocol to use */
};
struct protoent {
char *p_name; /* official protocol name */
char **p_aliases; /* alias list */
short p_proto; /* protocol # */
};
/*
Standard well-known IP protocols.
For some reason there are differences between Linx and winsock.h
*/
enum {
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_GGP = 2, /* huh? */
IPPROTO_IPIP = 4,
IPPROTO_TCP = 6, /* Transmission Control Protocol */
IPPROTO_EGP = 8,
IPPROTO_PUP = 12,
IPPROTO_UDP = 17, /* User Datagram Protocol */
IPPROTO_IDP = 22,
IPPROTO_ND = 77, /* This one was in winsock.h */
IPPROTO_RAW = 255, /* raw IP packets */
IPPROTO_MAX
};
/* Standard well-known ports */
enum {
IPPORT_ECHO = 7,
IPPORT_DISCARD = 9,
IPPORT_SYSTAT = 11,
IPPORT_DAYTIME = 13,
IPPORT_NETSTAT = 15,
IPPORT_FTP = 21,
IPPORT_TELNET = 23,
IPPORT_SMTP = 25,
IPPORT_TIMESERVER = 37,
IPPORT_NAMESERVER = 42,
IPPORT_WHOIS = 43,
IPPORT_MTP = 57,
IPPORT_TFTP = 69,
IPPORT_RJE = 77,
IPPORT_FINGER = 79,
IPPORT_TTYLINK = 87,
IPPORT_SUPDUP = 95,
IPPORT_EXECSERVER = 512,
IPPORT_LOGINSERVER = 513,
IPPORT_CMDSERVER = 514,
IPPORT_EFSSERVER = 520,
/* UDP ports. */
IPPORT_BIFFUDP = 512,
IPPORT_WHOSERVER = 513,
IPPORT_ROUTESERVER = 520,
/* Ports less than this value are reservered for privileged processes. */
IPPORT_RESERVED = 1024,
/* Ports greater than this value are reserved for
(non-privileged) processes */
IPPORT_USERRESERVED = 5000
};
/* Link numbers. */
#define IMPLINK_IP 155
#define IMPLINK_LOWEXPER 156
#define IMPLINK_HIGHEXPER 158
/* Linux uses a simple unsigned long int, but winsock.h ... */
struct in_addr {
union {
struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
struct { u_short s_w1,s_w2; } S_un_w;
u_long S_addr;
} S_un;
#define s_addr S_un.S_addr
#define s_host S_un.S_un_b.s_b2
#define s_net S_un.S_un_b.s_b1
#define s_imp S_un.S_un_w.s_w2
#define s_impno S_un.S_un_b.s_b4
#define s_lh S_un.S_un_b.s_b3
};
/*
Definitions of bits in internet address integers.
On subnets, host and network parts are found according
to the subnet mask, not these masks.
*/
#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
#define IN_CLASSA_NET 0xff000000
#define IN_CLASSA_NSHIFT 24
#define IN_CLASSA_HOST 0x00ffffff
#define IN_CLASSA_MAX 128
#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
#define IN_CLASSB_NET 0xffff0000
#define IN_CLASSB_NSHIFT 16
#define IN_CLASSB_HOST 0x0000ffff
#define IN_CLASSB_MAX 65536
#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST 0x000000ff
#define INADDR_ANY (u_long)0x00000000
#define INADDR_LOOPBACK 0x7f000001
#define INADDR_BROADCAST (u_long)0xffffffff
#define INADDR_NONE 0xffffffff
/*
Structure describing an Internet (IP) socket address.
*/
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
/*
EVERYTHING FROM THIS POINT IS MAINLY SPECIFIC TO Win32
Structure which holds the detail for the underlying Window Sockets
implementation. Set when WSAStartup() is called.
*/
#define WSADESCRIPTION_LEN 256
#define WSASYS_STATUS_LEN 128
typedef struct WSAData {
WORD wVersion;
WORD wHighVersion;
char szDescription[WSADESCRIPTION_LEN+1];
char szSystemStatus[WSASYS_STATUS_LEN+1];
unsigned short iMaxSockets;
unsigned short iMaxUdpDg;
char *lpVendorInfo;
} WSADATA, *LPWSADATA;
#define IP_OPTIONS 1
#define IP_MULTICAST_IF 2
#define IP_MULTICAST_TTL 3
#define IP_MULTICAST_LOOP 4
#define IP_ADD_MEMBERSHIP 5
#define IP_DROP_MEMBERSHIP 6
#define IP_DEFAULT_MULTICAST_TTL 1
#define IP_DEFAULT_MULTICAST_LOOP 1
#define IP_MAX_MEMBERSHIPS 20
struct ip_mreq {
struct in_addr imr_multiaddr;
struct in_addr imr_interface;
};
/*
* Definitions related to sockets: types, address families, options,
* taken from the BSD file sys/socket.h.
*/
/*
* This is used instead of -1, since the
* SOCKET type is unsigned.
*/
#define INVALID_SOCKET (SOCKET)(~0)
#define SOCKET_ERROR (-1)
/* Socket types. */
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define SOCK_RAW 3
#define SOCK_RDM 4
#define SOCK_SEQPACKET 5
/* For setsockoptions(2) */
#define SO_DEBUG 0x0001
#define SO_ACCEPTCONN 0x0002
#define SO_REUSEADDR 0x0004
#define SO_KEEPALIVE 0x0008
#define SO_DONTROUTE 0x0010
#define SO_BROADCAST 0x0020
#define SO_USELOOPBACK 0x0040
#define SO_LINGER 0x0080
#define SO_OOBINLINE 0x0100
#define SO_DONTLINGER (u_int)(~SO_LINGER)
/*
* Additional options.
*/
#define SO_SNDBUF 0x1001 /* send buffer size */
#define SO_RCVBUF 0x1002 /* receive buffer size */
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
#define SO_SNDTIMEO 0x1005 /* send timeout */
#define SO_RCVTIMEO 0x1006 /* receive timeout */
#define SO_ERROR 0x1007 /* get error status and clear */
#define SO_TYPE 0x1008 /* get socket type */
/*
* Options for connect and disconnect data and options. Used only by
* non-TCP/IP transports such as DECNet, OSI TP4, etc.
*/
#define SO_CONNDATA 0x7000
#define SO_CONNOPT 0x7001
#define SO_DISCDATA 0x7002
#define SO_DISCOPT 0x7003
#define SO_CONNDATALEN 0x7004
#define SO_CONNOPTLEN 0x7005
#define SO_DISCDATALEN 0x7006
#define SO_DISCOPTLEN 0x7007
/*
* Option for opening sockets for synchronous access.
*/
#define SO_OPENTYPE 0x7008
#define SO_SYNCHRONOUS_ALERT 0x10
#define SO_SYNCHRONOUS_NONALERT 0x20
/*
* Other NT-specific options.
*/
#define SO_MAXDG 0x7009
#define SO_MAXPATHDG 0x700A
/*
* TCP options.
*/
#define TCP_NODELAY 0x0001
#define TCP_BSDURGENT 0x7000
/*
* Address families.
*/
#define AF_UNSPEC 0 /* unspecified */
#define AF_UNIX 1 /* local to host (pipes, portals) */
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
#define AF_IMPLINK 3 /* arpanet imp addresses */
#define AF_PUP 4 /* pup protocols: e.g. BSP */
#define AF_CHAOS 5 /* mit CHAOS protocols */
#define AF_IPX 6 /* IPX and SPX */
#define AF_NS 6 /* XEROX NS protocols */
#define AF_ISO 7 /* ISO protocols */
#define AF_OSI AF_ISO /* OSI is ISO */
#define AF_ECMA 8 /* european computer manufacturers */
#define AF_DATAKIT 9 /* datakit protocols */
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
#define AF_SNA 11 /* IBM SNA */
#define AF_DECnet 12 /* DECnet */
#define AF_DLI 13 /* Direct data link interface */
#define AF_LAT 14 /* LAT */
#define AF_HYLINK 15 /* NSC Hyperchannel */
#define AF_APPLETALK 16 /* AppleTalk */
#define AF_NETBIOS 17 /* NetBios-style addresses */
#define AF_MAX 18
/*
* Structure used by kernel to store most
* addresses.
*/
struct sockaddr {
u_short sa_family;
char sa_data[14];
};
/*
* Structure used by kernel to pass protocol
* information in raw sockets.
*/
struct sockproto {
u_short sp_family;
u_short sp_protocol;
};
/*
* Protocol families, same as address families for now.
*/
#define PF_UNSPEC AF_UNSPEC
#define PF_UNIX AF_UNIX
#define PF_INET AF_INET
#define PF_IMPLINK AF_IMPLINK
#define PF_PUP AF_PUP
#define PF_CHAOS AF_CHAOS
#define PF_NS AF_NS
#define PF_IPX AF_IPX
#define PF_ISO AF_ISO
#define PF_OSI AF_OSI
#define PF_ECMA AF_ECMA
#define PF_DATAKIT AF_DATAKIT
#define PF_CCITT AF_CCITT
#define PF_SNA AF_SNA
#define PF_DECnet AF_DECnet
#define PF_DLI AF_DLI
#define PF_LAT AF_LAT
#define PF_HYLINK AF_HYLINK
#define PF_APPLETALK AF_APPLETALK
#define PF_MAX AF_MAX
/*
* Structure used for manipulating linger option.
*/
struct linger {
u_short l_onoff;
u_short l_linger;
};
/*
* Level number for (get/set)sockopt() to apply to socket itself.
*/
#define SOL_SOCKET 0xffff /* options for socket level */
/*
* Maximum queue length specifiable by listen.
*/
#define SOMAXCONN 5
#define MSG_OOB 0x1 /* process out-of-band data */
#define MSG_PEEK 0x2 /* peek at incoming message */
#define MSG_DONTROUTE 0x4 /* send without using routing tables */
#define MSG_MAXIOVLEN 16
#define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
/*
* Define constant based on rfc883, used by gethostbyxxxx() calls.
*/
#define MAXGETHOSTSTRUCT 1024
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN MAXGETHOSTSTRUCT
#endif
/*
* Define flags to be used with the WSAAsyncSelect() call.
*/
#define FD_READ 0x01
#define FD_WRITE 0x02
#define FD_OOB 0x04
#define FD_ACCEPT 0x08
#define FD_CONNECT 0x10
#define FD_CLOSE 0x20
/*
* All Windows Sockets error constants are biased by WSABASEERR from
* the "normal"
*/
#define WSABASEERR 10000
/*
* Windows Sockets definitions of regular Microsoft C error constants
*/
#define WSAEINTR (WSABASEERR+4)
#define WSAEBADF (WSABASEERR+9)
#define WSAEACCES (WSABASEERR+13)
#define WSAEFAULT (WSABASEERR+14)
#define WSAEINVAL (WSABASEERR+22)
#define WSAEMFILE (WSABASEERR+24)
/*
* Windows Sockets definitions of regular Berkeley error constants
*/
#define WSAEWOULDBLOCK (WSABASEERR+35)
#define WSAEINPROGRESS (WSABASEERR+36)
#define WSAEALREADY (WSABASEERR+37)
#define WSAENOTSOCK (WSABASEERR+38)
#define WSAEDESTADDRREQ (WSABASEERR+39)
#define WSAEMSGSIZE (WSABASEERR+40)
#define WSAEPROTOTYPE (WSABASEERR+41)
#define WSAENOPROTOOPT (WSABASEERR+42)
#define WSAEPROTONOSUPPORT (WSABASEERR+43)
#define WSAESOCKTNOSUPPORT (WSABASEERR+44)
#define WSAEOPNOTSUPP (WSABASEERR+45)
#define WSAEPFNOSUPPORT (WSABASEERR+46)
#define WSAEAFNOSUPPORT (WSABASEERR+47)
#define WSAEADDRINUSE (WSABASEERR+48)
#define WSAEADDRNOTAVAIL (WSABASEERR+49)
#define WSAENETDOWN (WSABASEERR+50)
#define WSAENETUNREACH (WSABASEERR+51)
#define WSAENETRESET (WSABASEERR+52)
#define WSAECONNABORTED (WSABASEERR+53)
#define WSAECONNRESET (WSABASEERR+54)
#define WSAENOBUFS (WSABASEERR+55)
#define WSAEISCONN (WSABASEERR+56)
#define WSAENOTCONN (WSABASEERR+57)
#define WSAESHUTDOWN (WSABASEERR+58)
#define WSAETOOMANYREFS (WSABASEERR+59)
#define WSAETIMEDOUT (WSABASEERR+60)
#define WSAECONNREFUSED (WSABASEERR+61)
#define WSAELOOP (WSABASEERR+62)
#define WSAENAMETOOLONG (WSABASEERR+63)
#define WSAEHOSTDOWN (WSABASEERR+64)
#define WSAEHOSTUNREACH (WSABASEERR+65)
#define WSAENOTEMPTY (WSABASEERR+66)
#define WSAEPROCLIM (WSABASEERR+67)
#define WSAEUSERS (WSABASEERR+68)
#define WSAEDQUOT (WSABASEERR+69)
#define WSAESTALE (WSABASEERR+70)
#define WSAEREMOTE (WSABASEERR+71)
#define WSAEDISCON (WSABASEERR+101)
/*
* Extended Windows Sockets error constant definitions
*/
#define WSASYSNOTREADY (WSABASEERR+91)
#define WSAVERNOTSUPPORTED (WSABASEERR+92)
#define WSANOTINITIALISED (WSABASEERR+93)
/*
* Error return codes from gethostbyname() and gethostbyaddr()
* (when using the resolver). Note that these errors are
* retrieved via WSAGetLastError() and must therefore follow
* the rules for avoiding clashes with error numbers from
* specific implementations or language run-time systems.
* For this reason the codes are based at WSABASEERR+1001.
* Note also that [WSA]NO_ADDRESS is defined only for
* compatibility purposes.
*/
#define h_errno WSAGetLastError()
/* Authoritative Answer: Host not found */
#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
#define HOST_NOT_FOUND WSAHOST_NOT_FOUND
/* Non-Authoritative: Host not found, or SERVERFAIL */
#define WSATRY_AGAIN (WSABASEERR+1002)
#define TRY_AGAIN WSATRY_AGAIN
/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define WSANO_RECOVERY (WSABASEERR+1003)
#define NO_RECOVERY WSANO_RECOVERY
/* Valid name, no data record of requested type */
#define WSANO_DATA (WSABASEERR+1004)
#define NO_DATA WSANO_DATA
/* no address, look for MX record */
#define WSANO_ADDRESS WSANO_DATA
#define NO_ADDRESS WSANO_ADDRESS
/*
* Windows Sockets errors redefined as regular Berkeley error constants.
* These are commented out in Windows NT to avoid conflicts with errno.h.
* Use the WSA constants instead.
*/
#if 0
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define EALREADY WSAEALREADY
#define ENOTSOCK WSAENOTSOCK
#define EDESTADDRREQ WSAEDESTADDRREQ
#define EMSGSIZE WSAEMSGSIZE
#define EPROTOTYPE WSAEPROTOTYPE
#define ENOPROTOOPT WSAENOPROTOOPT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#define EOPNOTSUPP WSAEOPNOTSUPP
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#define EADDRINUSE WSAEADDRINUSE
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
#define ENETDOWN WSAENETDOWN
#define ENETUNREACH WSAENETUNREACH
#define ENETRESET WSAENETRESET
#define ECONNABORTED WSAECONNABORTED
#define ECONNRESET WSAECONNRESET
#define ENOBUFS WSAENOBUFS
#define EISCONN WSAEISCONN
#define ENOTCONN WSAENOTCONN
#define ESHUTDOWN WSAESHUTDOWN
#define ETOOMANYREFS WSAETOOMANYREFS
#define ETIMEDOUT WSAETIMEDOUT
#define ECONNREFUSED WSAECONNREFUSED
#define ELOOP WSAELOOP
#define ENAMETOOLONG WSAENAMETOOLONG
#define EHOSTDOWN WSAEHOSTDOWN
#define EHOSTUNREACH WSAEHOSTUNREACH
#define ENOTEMPTY WSAENOTEMPTY
#define EPROCLIM WSAEPROCLIM
#define EUSERS WSAEUSERS
#define EDQUOT WSAEDQUOT
#define ESTALE WSAESTALE
#define EREMOTE WSAEREMOTE
#endif
/* Socket function prototypes */
SOCKET PASCAL accept (SOCKET s, struct sockaddr *addr,
int *addrlen);
int PASCAL bind (SOCKET s, const struct sockaddr *addr, int namelen);
int PASCAL closesocket (SOCKET s);
int PASCAL connect (SOCKET s, const struct sockaddr *name, int namelen);
int PASCAL ioctlsocket (SOCKET s, long cmd, u_long *argp);
int PASCAL getpeername (SOCKET s, struct sockaddr *name,
int * namelen);
int PASCAL getsockname (SOCKET s, struct sockaddr *name,
int * namelen);
int PASCAL getsockopt (SOCKET s, int level, int optname,
char * optval, int *optlen);
u_long PASCAL htonl (u_long hostlong);
/* For some reason WSOCK.LIB has htons defined as a 4 byte paramter?! */
#ifdef _WIN32
u_short PASCAL htons (u_long hostshort);
#else
u_short PASCAL htons (u_short hostshort);
#endif /* _WIN32 */
unsigned long PASCAL inet_addr (const char * cp);
char * PASCAL inet_ntoa (struct in_addr in);
int PASCAL listen (SOCKET s, int backlog);
u_long PASCAL ntohl (u_long netlong);
/* For some reason WSOCK.LIB has ntohs defined as a 4 byte paramter?! */
#ifdef _WIN32
u_short PASCAL ntohs (u_long netshort);
#else
u_short PASCAL ntohs (u_short netshort);
#endif /* _WIN32 */
int PASCAL recv (SOCKET s, char * buf, int len, int flags);
int PASCAL recvfrom (SOCKET s, char * buf, int len, int flags,
struct sockaddr *from, int * fromlen);
int PASCAL select (int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, const struct timeval *timeout);
int PASCAL send (SOCKET s, const char * buf, int len, int flags);
int PASCAL sendto (SOCKET s, const char * buf, int len, int flags,
const struct sockaddr *to, int tolen);
int PASCAL setsockopt (SOCKET s, int level, int optname,
const char * optval, int optlen);
int PASCAL shutdown (SOCKET s, int how);
SOCKET PASCAL socket (int af, int type, int protocol);
/* Database function prototypes */
struct hostent * PASCAL gethostbyaddr(const char * addr,
int len, int type);
struct hostent * PASCAL gethostbyname(const char * name);
int PASCAL gethostname (char * name, int namelen);
struct servent * PASCAL getservbyport(int port, const char * proto);
struct servent * PASCAL getservbyname(const char * name,
const char * proto);
struct protoent * PASCAL getprotobynumber(int proto);
struct protoent * PASCAL getprotobyname(const char * name);
/* Microsoft Windows Extension function prototypes */
/* int PASCAL WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData); */
int PASCAL WSAStartup(int wVersionRequired, LPWSADATA lpWSAData);
int PASCAL WSACleanup(void);
void PASCAL WSASetLastError(int iError);
int PASCAL WSAGetLastError(void);
WINBOOL PASCAL WSAIsBlocking(void);
int PASCAL WSAUnhookBlockingHook(void);
FARPROC PASCAL WSASetBlockingHook(FARPROC lpBlockFunc);
int PASCAL WSACancelBlockingCall(void);
HANDLE PASCAL WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
const char * name,
const char * proto,
char * buf, int buflen);
HANDLE PASCAL WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
const char * proto, char * buf,
int buflen);
HANDLE PASCAL WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
const char * name, char * buf,
int buflen);
HANDLE PASCAL WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
int number, char * buf,
int buflen);
HANDLE PASCAL WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
const char * name, char * buf,
int buflen);
HANDLE PASCAL WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
const char * addr, int len, int type,
char * buf, int buflen);
int PASCAL WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
int PASCAL WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
long lEvent);
int PASCAL WSARecvEx (SOCKET s, char * buf, int len, int *flags);
/* Microsoft Windows Extended data types */
typedef struct sockaddr SOCKADDR;
typedef struct sockaddr *PSOCKADDR;
typedef struct sockaddr *LPSOCKADDR;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr_in *PSOCKADDR_IN;
typedef struct sockaddr_in *LPSOCKADDR_IN;
typedef struct linger LINGER;
typedef struct linger *PLINGER;
typedef struct linger *LPLINGER;
typedef struct in_addr IN_ADDR;
typedef struct in_addr *PIN_ADDR;
typedef struct in_addr *LPIN_ADDR;
typedef struct fd_set FD_SET;
typedef struct fd_set *PFD_SET;
typedef struct fd_set *LPFD_SET;
typedef struct hostent HOSTENT;
typedef struct hostent *PHOSTENT;
typedef struct hostent *LPHOSTENT;
typedef struct servent SERVENT;
typedef struct servent *PSERVENT;
typedef struct servent *LPSERVENT;
typedef struct protoent PROTOENT;
typedef struct protoent *PPROTOENT;
typedef struct protoent *LPPROTOENT;
typedef struct timeval TIMEVAL;
typedef struct timeval *PTIMEVAL;
typedef struct timeval *LPTIMEVAL;
/*
* Windows message parameter composition and decomposition
* macros.
*
* WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
* when constructing the response to a WSAAsyncGetXByY() routine.
*/
#define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
/*
* WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
* when constructing the response to WSAAsyncSelect().
*/
#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
/*
* WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
* to extract the buffer length from the lParam in the response
* to a WSAGetXByY().
*/
#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
/*
* WSAGETASYNCERROR is intended for use by the Windows Sockets application
* to extract the error code from the lParam in the response
* to a WSAGetXByY().
*/
#define WSAGETASYNCERROR(lParam) HIWORD(lParam)
/*
* WSAGETSELECTEVENT is intended for use by the Windows Sockets application
* to extract the event code from the lParam in the response
* to a WSAAsyncSelect().
*/
#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
/*
* WSAGETSELECTERROR is intended for use by the Windows Sockets application
* to extract the error code from the lParam in the response
* to a WSAAsyncSelect().
*/
#define WSAGETSELECTERROR(lParam) HIWORD(lParam)
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GNU_H_WINDOWS32_SOCKETS */

778
reactos/include/string.h Normal file
View file

@ -0,0 +1,778 @@
/*
* Adapted from linux for the reactos kernel, march 1998 -- David Welch
* Removed extern specifier from ___strtok and ___wcstok, june 1998 -- Boudewijn Dekker
* Added stricmp and strnicmp -- Boudewijn Dekker
*/
#ifndef _LINUX_STRING_H_
#define _LINUX_STRING_H_
#include <types.h> /* for size_t */
#ifndef NULL
#define NULL ((void *) 0)
#endif
#ifdef __cplusplus
extern "C" {
#endif
char * ___strtok; // removed extern specifier 02-06-98, BD
extern char * strcpy(char *,const char *);
extern char * strncpy(char *,const char *, __kernel_size_t);
extern char * strcat(char *, const char *);
extern char * strncat(char *, const char *, __kernel_size_t);
extern char * strchr(const char *,int);
extern char * strrchr(const char *,int);
extern char * strpbrk(const char *,const char *);
extern char * strtok(char *,const char *);
extern char * strstr(const char *,const char *);
extern __kernel_size_t strlen(const char *);
extern __kernel_size_t strnlen(const char *,__kernel_size_t);
extern __kernel_size_t strspn(const char *,const char *);
extern int strcmp(const char *,const char *);
extern int strncmp(const char *,const char *,__kernel_size_t);
extern int stricmp(const char* cs,const char * ct)
extern int strnicmp(const char* cs,const char * ct, size_t count);
extern void * memset(void *,int,__kernel_size_t);
extern void * memcpy(void *,const void *,__kernel_size_t);
extern void * memmove(void *,const void *,__kernel_size_t);
extern void * memscan(void *,int,__kernel_size_t);
extern int memcmp(const void *,const void *,__kernel_size_t);
/*
* Include machine specific inline routines
*/
#ifndef _I386_STRING_H_
#define _I386_STRING_H_
/*
* On a 486 or Pentium, we are better off not using the
* byte string operations. But on a 386 or a PPro the
* byte string ops are faster than doing it by hand
* (MUCH faster on a Pentium).
*
* Also, the byte strings actually work correctly. Forget
* the i486 routines for now as they may be broken..
*/
#if FIXED_486_STRING && (CPU == 486 || CPU == 586)
#include <asm/string-486.h>
#else
/*
* This string-include defines all string functions as inline
* functions. Use gcc. It also assumes ds=es=data space, this should be
* normal. Most of the string-functions are rather heavily hand-optimized,
* see especially strtok,strstr,str[c]spn. They should work, but are not
* very easy to understand. Everything is done entirely within the register
* set, making the functions fast and clean. String instructions have been
* used through-out, making for "slightly" unclear code :-)
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
#define __HAVE_ARCH_STRCPY
extern inline char * strcpy(char * dest,const char *src)
{
__asm__ __volatile__(
"cld\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest):"si","di","ax","memory");
return dest;
}
#define __HAVE_ARCH_STRNCPY
extern inline char * strncpy(char * dest,const char *src,size_t count)
{
__asm__ __volatile__(
"cld\n"
"1:\tdecl %2\n\t"
"js 2f\n\t"
"lodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"rep\n\t"
"stosb\n"
"2:"
: /* no output */
:"S" (src),"D" (dest),"c" (count):"si","di","ax","cx","memory");
return dest;
}
#define __HAVE_ARCH_STRCAT
extern inline char * strcat(char * dest,const char * src)
{
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx");
return dest;
}
#define __HAVE_ARCH_STRNCAT
extern inline char * strncat(char * dest,const char * src,size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n\t"
"movl %4,%3\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n"
"2:\txorl %2,%2\n\t"
"stosb"
: /* no output */
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count)
:"si","di","ax","cx","memory");
return dest;
}
#define __HAVE_ARCH_STRCMP
extern inline int strcmp(const char * cs,const char * ct)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tlodsb\n\t"
"scasb\n\t"
"jne 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%eax\n"
"3:"
:"=a" (__res):"S" (cs),"D" (ct):"si","di");
return __res;
}
#define __HAVE_ARCH_STRNCMP
extern inline int strncmp(const char * cs,const char * ct,size_t count)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsb\n\t"
"scasb\n\t"
"jne 3f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n"
"2:\txorl %%eax,%%eax\n\t"
"jmp 4f\n"
"3:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%al\n"
"4:"
:"=a" (__res):"S" (cs),"D" (ct),"c" (count):"si","di","cx");
return __res;
}
#define __HAVE_ARCH_STRCHR
extern inline char * strchr(const char * s, int c)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
"je 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"movl $1,%1\n"
"2:\tmovl %1,%0\n\t"
"decl %0"
:"=a" (__res):"S" (s),"0" (c):"si");
return __res;
}
#define __HAVE_ARCH_STRRCHR
extern inline char * strrchr(const char * s, int c)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
"jne 2f\n\t"
"leal -1(%%esi),%0\n"
"2:\ttestb %%al,%%al\n\t"
"jne 1b"
:"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si");
return __res;
}
#define __HAVE_ARCH_STRSPN
extern inline size_t strspn(const char * cs, const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"je 1b\n"
"2:\tdecl %0"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res-cs;
}
#define __HAVE_ARCH_STRCSPN
extern inline size_t strcspn(const char * cs, const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 1b\n"
"2:\tdecl %0"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res-cs;
}
#define __HAVE_ARCH_STRPBRK
extern inline char * strpbrk(const char * cs,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 1b\n\t"
"decl %0\n\t"
"jmp 3f\n"
"2:\txorl %0,%0\n"
"3:"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res;
}
#define __HAVE_ARCH_STRSTR
extern inline char * strstr(const char * cs,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t" \
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
"movl %%ecx,%%edx\n"
"1:\tmovl %4,%%edi\n\t"
"movl %%esi,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"repe\n\t"
"cmpsb\n\t"
"je 2f\n\t" /* also works for empty string, see above */
"xchgl %%eax,%%esi\n\t"
"incl %%esi\n\t"
"cmpb $0,-1(%%eax)\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"2:"
:"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct)
:"cx","dx","di","si");
return __res;
}
#define __HAVE_ARCH_STRLEN
extern inline size_t strlen(const char * s)
{
register int __res;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"notl %0\n\t"
"decl %0"
:"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di");
return __res;
}
#define __HAVE_ARCH_STRTOK
extern inline char * strtok(char * s,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"testl %1,%1\n\t"
"jne 1f\n\t"
"testl %0,%0\n\t"
"je 8f\n\t"
"movl %0,%1\n"
"1:\txorl %0,%0\n\t"
"movl $-1,%%ecx\n\t"
"xorl %%eax,%%eax\n\t"
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"je 7f\n\t" /* empty delimiter-string */
"movl %%ecx,%%edx\n"
"2:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 7f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"je 2b\n\t"
"decl %1\n\t"
"cmpb $0,(%1)\n\t"
"je 7f\n\t"
"movl %1,%0\n"
"3:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 5f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 3b\n\t"
"decl %1\n\t"
"cmpb $0,(%1)\n\t"
"je 5f\n\t"
"movb $0,(%1)\n\t"
"incl %1\n\t"
"jmp 6f\n"
"5:\txorl %1,%1\n"
"6:\tcmpb $0,(%0)\n\t"
"jne 7f\n\t"
"xorl %0,%0\n"
"7:\ttestl %0,%0\n\t"
"jne 8f\n\t"
"movl %0,%1\n"
"8:"
:"=b" (__res),"=S" (___strtok)
:"0" (___strtok),"1" (s),"g" (ct)
:"ax","cx","dx","di","memory");
return __res;
}
#define __HAVE_ARCH_STRICMP
extern inline int stricmp(const char* cs,const char * ct)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tmovb (%%esi), %%eax\n\t"
"movb (%%edi), %%dl \n\t"
"cmpb $0x5A, %%al\n\t"
"ja 2f\t\n"
"cmpb $0x40, %%al\t\n"
"jbe 2f\t\n"
"addb $0x20, %%al\t\n"
"2:\t cmpb $0x5A, %%dl\t\n"
"ja 3f\t\n"
"cmpb $0x40, %%dl\t\n"
"jbe 3f\t\n"
"addb $0x20, %%dl\t\n"
"3:\t inc %%esi\t\n"
"inc %%edi\t\n"
"cmpb %%al, %%dl\t\n"
"jne 4f\n\t"
"cmpb $00, %%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 5f\n"
"4:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%eax\n"
"5:"
:"=a" (__res):"S" (cs),"D" (ct):"si","di");
return __res;
}
#define __HAVE_ARCH_STRNICMP
extern inline int strnicmp(const char* cs,const char * ct, size_t count)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\t decl %3\n\t"
"js 6f\n\t"
"movb (%%esi), %%al\n\t"
"movb (%%edi), %%dl \n\t"
"cmpb $0x5A, %%al\n\t"
"ja 2f\t\n"
"cmpb $0x40, %%al\t\n"
"jbe 2f\t\n"
"addb $0x20, %%al\t\n"
"2:\t cmpb $0x5A, %%dl\t\n"
"ja 3f\t\n"
"cmpb $0x40, %%dl\t\n"
"jbe 3f\t\n"
"addb $0x20, %%dl\t\n"
"3:\t inc %%esi\t\n"
"inc %%edi\t\n"
"cmpb %%al, %%dl\t\n"
"jne 4f\n\t"
"cmpb $00, %%al\n\t"
"jne 1b\n\t"
"6:xorl %%eax,%%eax\n\t"
"jmp 5f\n"
"4:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%eax\n"
"5:"
:"=a" (__res):"S" (cs),"D" (ct), "c" (count):"si","di", "cx");
return __res;
}
extern inline void * __memcpy(void * to, const void * from, size_t n)
{
__asm__ __volatile__(
"cld\n\t"
"rep ; movsl\n\t"
"testb $2,%b1\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b1\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
: /* no output */
:"c" (n/4), "q" (n),"D" ((long) to),"S" ((long) from)
: "cx","di","si","memory");
return (to);
}
/*
* This looks horribly ugly, but the compiler can optimize it totally,
* as the count is constant.
*/
extern inline void * __constant_memcpy(void * to, const void * from, size_t n)
{
switch (n) {
case 0:
return to;
case 1:
*(unsigned char *)to = *(const unsigned char *)from;
return to;
case 2:
*(unsigned short *)to = *(const unsigned short *)from;
return to;
case 3:
*(unsigned short *)to = *(const unsigned short *)from;
*(2+(unsigned char *)to) = *(2+(const unsigned char *)from);
return to;
case 4:
*(unsigned long *)to = *(const unsigned long *)from;
return to;
case 8:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
return to;
case 12:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
return to;
case 16:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
return to;
case 20:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
*(4+(unsigned long *)to) = *(4+(const unsigned long *)from);
return to;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; movsl" \
x \
: /* no outputs */ \
: "c" (n/4),"D" ((long) to),"S" ((long) from) \
: "cx","di","si","memory");
switch (n % 4) {
case 0: COMMON(""); return to;
case 1: COMMON("\n\tmovsb"); return to;
case 2: COMMON("\n\tmovsw"); return to;
case 3: COMMON("\n\tmovsw\n\tmovsb"); return to;
}
#undef COMMON
}
#define __HAVE_ARCH_MEMCPY
#define memcpy(t, f, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy((t),(f),(n)) : \
__memcpy((t),(f),(n)))
#define __HAVE_ARCH_MEMMOVE
extern inline void * memmove(void * dest,const void * src, size_t n)
{
if (dest<src)
__asm__ __volatile__(
"cld\n\t"
"rep\n\t"
"movsb"
: /* no output */
:"c" (n),"S" (src),"D" (dest)
:"cx","si","di");
else
__asm__ __volatile__(
"std\n\t"
"rep\n\t"
"movsb\n\t"
"cld"
: /* no output */
:"c" (n),
"S" (n-1+(const char *)src),
"D" (n-1+(char *)dest)
:"cx","si","di","memory");
return dest;
}
#define memcmp __builtin_memcmp
#define __HAVE_ARCH_MEMCHR
extern inline void * memchr(const void * cs,int c,size_t count)
{
register void * __res;
if (!count)
return NULL;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"je 1f\n\t"
"movl $1,%0\n"
"1:\tdecl %0"
:"=D" (__res):"a" (c),"D" (cs),"c" (count)
:"cx");
return __res;
}
extern inline void * __memset_generic(void * s, char c,size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"rep\n\t"
"stosb"
: /* no output */
:"a" (c),"D" (s),"c" (count)
:"cx","di","memory");
return s;
}
/* we might want to write optimized versions of these later */
#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
/*
* memset(x,0,y) is a reasonably common thing to do, so we want to fill
* things 32 bits at a time even when we don't know the size of the
* area at compile-time..
*/
extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"rep ; stosl\n\t"
"testb $2,%b1\n\t"
"je 1f\n\t"
"stosw\n"
"1:\ttestb $1,%b1\n\t"
"je 2f\n\t"
"stosb\n"
"2:"
: /* no output */
:"a" (c), "q" (count), "c" (count/4), "D" ((long) s)
:"cx","di","memory");
return (s);
}
/* Added by Gertjan van Wingerde to make minix and sysv module work */
#define __HAVE_ARCH_STRNLEN
extern inline size_t strnlen(const char * s, size_t count)
{
register int __res;
__asm__ __volatile__(
"movl %1,%0\n\t"
"jmp 2f\n"
"1:\tcmpb $0,(%0)\n\t"
"je 3f\n\t"
"incl %0\n"
"2:\tdecl %2\n\t"
"cmpl $-1,%2\n\t"
"jne 1b\n"
"3:\tsubl %1,%0"
:"=a" (__res)
:"c" (s),"d" (count)
:"dx");
return __res;
}
/* end of additional stuff */
/*
* This looks horribly ugly, but the compiler can optimize it totally,
* as we by now know that both pattern and count is constant..
*/
extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count)
{
switch (count) {
case 0:
return s;
case 1:
*(unsigned char *)s = pattern;
return s;
case 2:
*(unsigned short *)s = pattern;
return s;
case 3:
*(unsigned short *)s = pattern;
*(2+(unsigned char *)s) = pattern;
return s;
case 4:
*(unsigned long *)s = pattern;
return s;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; stosl" \
x \
: /* no outputs */ \
: "a" (pattern),"c" (count/4),"D" ((long) s) \
: "cx","di","memory")
switch (count % 4) {
case 0: COMMON(""); return s;
case 1: COMMON("\n\tstosb"); return s;
case 2: COMMON("\n\tstosw"); return s;
case 3: COMMON("\n\tstosw\n\tstosb"); return s;
}
#undef COMMON
}
#define __constant_c_x_memset(s, c, count) \
(__builtin_constant_p(count) ? \
__constant_c_and_count_memset((s),(c),(count)) : \
__constant_c_memset((s),(c),(count)))
#define __memset(s, c, count) \
(__builtin_constant_p(count) ? \
__constant_count_memset((s),(c),(count)) : \
__memset_generic((s),(c),(count)))
#define __HAVE_ARCH_MEMSET
#define memset(s, c, count) \
(__builtin_constant_p(c) ? \
__constant_c_x_memset((s),(0x01010101UL*(unsigned char)c),(count)) : \
__memset((s),(c),(count)))
/*
* find the first occurrence of byte 'c', or 1 past the area if none
*/
#define __HAVE_ARCH_MEMSCAN
extern inline void * memscan(void * addr, int c, size_t size)
{
if (!size)
return addr;
__asm__("cld
repnz; scasb
jnz 1f
dec %%edi
1: "
: "=D" (addr), "=c" (size)
: "0" (addr), "1" (size), "a" (c));
return addr;
}
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LINUX_STRING_H_ */

4559
reactos/include/structs.h Normal file

File diff suppressed because it is too large Load diff

61
reactos/include/types.h Normal file
View file

@ -0,0 +1,61 @@
/*
* Added wide character type wchar_t, june 1998 -- Boudewijn Dekker
*/
#ifndef _LINUX_TYPES_H
#define _LINUX_TYPES_H
#ifndef NULL
# define NULL ((void *) 0)
#endif
#ifndef _I386_TYPES_H
#define _I386_TYPES_H
/*
* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
* header files exported to user space
*/
typedef __signed__ char __s8;
typedef unsigned char __u8;
typedef __signed__ short __s16;
typedef unsigned short __u16;
typedef __signed__ int __s32;
typedef unsigned int __u32;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
typedef signed char s8;
typedef unsigned char u8;
typedef signed short s16;
typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#endif /* __KERNEL__ */
#endif
typedef unsigned int size_t;
typedef size_t __kernel_size_t;
typedef unsigned short wchar_t;
#endif /* _LINUX_TYPES_H */

3000
reactos/include/unicode.h Normal file

File diff suppressed because it is too large Load diff

86
reactos/include/windows.h Normal file
View file

@ -0,0 +1,86 @@
/*
windows.h
Include this file if you wish to use the Windows32 API Library
Copyright (C) 1996 Free Software Foundation
Author: Scott Christley <scottc@net-community.com>
Date: 1996
This file is part of the Windows32 API Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
If you are interested in a warranty or support for this source code,
contact Scott Christley <scottc@net-community.com> for more information.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNU_H_WINDOWS_H
#define _GNU_H_WINDOWS_H
#ifndef RC_INVOKED
#include <limits.h>
#include <stdarg.h>
#endif
/* Base definitions */
#include <base.h>
/* WIN32 messages */
#include <messages.h>
/* WIN32 definitions */
#include <defines.h>
#ifndef RC_INVOKED
/* WIN32 structures */
#include <structs.h>
/* WIN32 functions */
#include <funcs.h>
#endif /* ! defined (RC_INVOKED) */
/* WIN32 error codes */
#include <errors.h>
#ifndef RC_INVOKED
/* Windows sockets specification version 1.1 */
#ifdef Win32_Winsock
#include <sockets.h>
#endif
/* There is a conflict with BOOL between Objective-C and Win32,
so the Windows32 API Library defines and uses WINBOOL.
However, if we are not using Objective-C then define the normal
windows BOOL so Win32 programs compile normally. If you are
using Objective-C then you must use WINBOOL for Win32 operations.
*/
#ifndef __OBJC__
typedef WINBOOL BOOL;
#endif /* !__OBJC__ */
/* How do we get the VM page size on NT? */
#ifndef vm_page_size
#define vm_page_size 4096
#endif
#endif /* ! defined (RC_INVOKED) */
#endif /* _GNU_H_WINDOWS_H */

535
reactos/include/wstring.h Normal file
View file

@ -0,0 +1,535 @@
/*
* Adapted from linux for the reactos kernel, march 1998 -- David Welch
* Added wide character string functions, june 1998 -- Boudewijn Dekker
* Removed extern specifier from ___wcstok, june 1998 -- Boudewijn Dekker
* Added wcsicmp and wcsnicmp -- Boudewijn Dekker
*/
#ifndef _LINUX_WSTRING_H_
#define _LINUX_WSTRING_H_
#include <types.h> /* for size_t */
#ifndef NULL
#define NULL ((void *) 0)
#endif
#ifdef __cplusplus
extern "C" {
#endif
wchar_t * ___wcstok;
extern wchar_t * wcscpy(wchar_t *,const wchar_t *);
extern wchar_t * wcsncpy(wchar_t *,const wchar_t *, __kernel_size_t);
extern wchar_t * wcscat(wchar_t *, const wchar_t *);
extern wchar_t * wcsncat(wchar_t *, const wchar_t *, __kernel_size_t);
extern int wcscmp(const wchar_t *,const wchar_t *);
extern int wcsncmp(const wchar_t *,const wchar_t *,__kernel_size_t);
extern wchar_t * wcschr(const wchar_t *,int);
extern wchar_t * wcsrchr(const wchar_t *,int);
extern wchar_t * wcspbrk(const wchar_t *,const wchar_t *);
extern wchar_t * wcstok(wchar_t *,const wchar_t *);
extern wchar_t * wcsstr(const wchar_t *,const wchar_t *);
extern size_t wcsnlen(const wchar_t * s, size_t count);
extern int wcsicmp(const wchar_t* cs,const wchar_t * ct);
extern int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
/*
* Include machine specific inline routines
*/
#ifndef _I386_STRING_H_
#define _I386_STRING_H_
/*
* On a 486 or Pentium, we are better off not using the
* byte string operations. But on a 386 or a PPro the
* byte string ops are faster than doing it by hand
* (MUCH faster on a Pentium).
*
* Also, the byte strings actually work correctly. Forget
* the i486 routines for now as they may be broken..
*/
#if FIXED_486_STRING && (CPU == 486 || CPU == 586)
#include <asm/string-486.h>
#else
/*
* This string-include defines all string functions as inline
* functions. Use gcc. It also assumes ds=es=data space, this should be
* normal. Most of the string-functions are rather heavily hand-optimized,
* see especially wcstok,wcsstr,wcs[c]spn. They should work, but are not
* very easy to understand. Everything is done entirely within the register
* set, making the functions fast and clean. String instructions have been
* used through-out, making for "slightly" unclear code :-)
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
#define __HAVE_ARCH_WCSCPY
inline wchar_t * wcscpy(wchar_t * dest,const wchar_t *src)
{
__asm__ __volatile__(
"cld\n"
"1:\tlodsw\n\t"
"stosw\n\t"
"testw %%eax,%%eax\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest):"esi","edi","eax","memory");
return dest;
}
#define __HAVE_ARCH_WCSNCPY
inline wchar_t * wcsncpy(wchar_t * dest,const wchar_t *src,size_t count)
{
__asm__ __volatile__(
"cld\n"
"1:\tdecl %2\n\t"
"js 2f\n\t"
"lodsw\n\t"
"stosw\n\t"
"testw %%eax,%%eax\n\t"
"jne 1b\n\t"
"rep\n\t"
"stosw\n"
"2:"
: /* no output */
:"S" (src),"D" (dest),"c" (count):"esi","edi","eax","ecx","memory");
return dest;
}
#define __HAVE_ARCH_WCSCAT
inline wchar_t * wcscat(wchar_t * dest,const wchar_t * src)
{
__asm__ __volatile__(
"cld\n\t"
"repnz\n\t"
"scasw\n\t"
"decl %1\n"
"decl %1\n\t"
"1:\tlodsw\n\t"
"stosw\n\t"
"testw %%eax,%%eax\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"esi","edi","eax","ecx");
return dest;
}
#define __HAVE_ARCH_WCSNCAT
inline wchar_t * wcsncat(wchar_t * dest,const wchar_t * src,size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"repnz\n\t"
"scasw\n\t"
"decl %1\n\t"
"movl %4,%3\n"
"decl %1\n\t"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsw\n\t"
"stosw\n\t"
"testw %%eax,%%eax\n\t"
"jne 1b\n"
"2:\txorl %2,%2\n\t"
"stosw"
: /* no output */
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count)
:"esi","edi","eax","ecx","memory");
return dest;
}
#define __HAVE_ARCH_WCSCMP
inline int wcscmp(const wchar_t* cs,const wchar_t * ct)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tlodsw\n\t"
"scasw\n\t"
"jne 2f\n\t"
"testw %%eax,%%eax\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tsbbl %%eax,%%eax\n\t"
"orw $1,%%eax\n"
"3:"
:"=a" (__res):"S" (cs),"D" (ct):"esi","edi");
return __res;
}
#define __HAVE_ARCH_WCSNCMP
inline int wcsncmp(const wchar_t * cs,const wchar_t * ct,size_t count)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsw\n\t"
"scasw\n\t"
"jne 3f\n\t"
"testw %%eax,%%eax\n\t"
"jne 1b\n"
"2:\txorl %%eax,%%eax\n\t"
"jmp 4f\n"
"3:\tsbbl %%eax,%%eax\n\t"
"orw $1,%%eax\n"
"4:"
:"=a" (__res):"S" (cs),"D" (ct),"c" (count):"esi","edi","ecx");
return __res;
}
#define __HAVE_ARCH_WCSCHR
inline wchar_t * wcschr(const wchar_t * s, int c)
{
register wchar_t * __res;
__asm__ __volatile__(
"cld\n\t"
"movw %%eax,%%edx\n"
"1:\tlodsw\n\t"
"cmpw %%edx,%%eax\n\t"
"je 2f\n\t"
"testw %%eax,%%eax\n\t"
"jne 1b\n\t"
"movl $1,%1\n"
"2:\tmovl %1,%0\n\t"
"decl %0\n\t"
"decl %0\n\t"
:"=a" (__res):"S" (s),"0" (c):"esi");
return __res;
}
#define __HAVE_ARCH_WCSRCHR
inline wchar_t * wcsrchr(const wchar_t * s, int c)
{
register wchar_t * __res;
__asm__ __volatile__(
"cld\n\t"
"movw %%eax,%%edx\n"
"1:\tlodsw\n\t"
"cmpw %%edx,%%eax\n\t"
"jne 2f\n\t"
"leal -2(%%esi),%0\n"
"2:\ttestw %%eax,%%eax\n\t"
"jne 1b"
:"=d" (__res):"0" (0),"S" (s),"a" (c):"eax","esi");
return __res;
}
#define __HAVE_ARCH_WCSSPN
inline size_t wcsspn(const wchar_t * cs, const wchar_t * ct)
{
register wchar_t * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasw\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsw\n\t"
"testw %%eax,%%eax\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"je 1b\n"
"2:\tdecl %0"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"eax","ecx","edx","edi");
return __res-cs;
}
#define __HAVE_ARCH_WCSCSPN
inline size_t wcscspn(const wchar_t * cs, const wchar_t * ct)
{
register wchar_t * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasw\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsw\n\t"
"testw %%eax,%%eax\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasw\n\t"
"jne 1b\n"
"2:\tdecl %0"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"eax","ecx","edx","edi");
return __res-cs;
}
#define __HAVE_ARCH_STRPBRK
inline wchar_t * wcspbrk(const wchar_t * cs,const wchar_t * ct)
{
register wchar_t * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasw\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsw\n\t"
"testw %%eax,%%eax\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasw\n\t"
"jne 1b\n\t"
"decl %0\n\t"
"jmp 3f\n"
"2:\txorl %0,%0\n"
"3:"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"eax","ecx","edx","edi");
return __res;
}
#define __HAVE_ARCH_WCSSTR
inline wchar_t * wcsstr(const wchar_t * cs,const wchar_t * ct)
{
register wchar_t * __res;
__asm__ __volatile__(
"cld\n\t" \
"movl %4,%%edi\n\t"
"repne\n\t"
"scasw\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
"movl %%ecx,%%edx\n"
"1:\tmovl %4,%%edi\n\t"
"movl %%esi,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"repe\n\t"
"cmpsw\n\t"
"je 2f\n\t" /* also works for empty string, see above */
"xchgl %%eax,%%esi\n\t"
"incl %%esi\n\t"
"cmpw $0,-1(%%eax)\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"2:"
:"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct)
:"ecx","edx","edi","esi");
return __res;
}
#define __HAVE_ARCH_WCSLEN
inline size_t wcslen(const wchar_t * s)
{
register int __res;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasw\n\t"
"notl %0\n\t"
"decl %0"
:"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"edi");
return __res;
}
#define __HAVE_ARCH_WCSTOK
inline wchar_t * wcstok(wchar_t * s,const wchar_t * ct)
{
register wchar_t * __res;
__asm__ __volatile__(
"testl %1,%1\n\t"
"jne 1f\n\t"
"testl %0,%0\n\t"
"je 8f\n\t"
"movl %0,%1\n"
"1:\txorl %0,%0\n\t"
"movl $-1,%%ecx\n\t"
"xorl %%eax,%%eax\n\t"
"cld\n\t"
"movl %4,%%edi\n\t"
"repnz\n\t"
"scasw\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"decl %%ecx\n\t"
"je 7f\n\t" /* empty delimiter-string */
"movl %%ecx,%%edx\n"
"2:\tlodsw\n\t"
"testw %%eax,%%eax\n\t"
"je 7f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasw\n\t"
"je 2b\n\t"
"decl %1\n\t"
"decl %1\n\t"
"cmpw $0,(%1)\n\t"
"je 7f\n\t"
"movl %1,%0\n"
"3:\tlodsw\n\t"
"testw %%eax,%%eax\n\t"
"je 5f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasw\n\t"
"jne 3b\n\t"
"decl %1\n\t"
"decl %1\n\t"
"decl %1\n\t"
"decl %1\n\t"
"cmpw $0,(%1)\n\t"
"je 5f\n\t"
"movw $0,(%1)\n\t"
"incl %1\n\t"
"incl %1\n\t"
"jmp 6f\n"
"5:\txorl %1,%1\n"
"6:\tcmpw $0,(%0)\n\t"
"jne 7f\n\t"
"xorl %0,%0\n"
"7:\ttestl %0,%0\n\t"
"jne 8f\n\t"
"movl %0,%1\n"
"8:"
:"=b" (__res),"=S" (___wcstok)
:"0" (___wcstok),"1" (s),"g" (ct)
:"eax","ecx","edx","edi","memory");
return __res;
}
#define __HAVE_ARCH_WCSNNLEN
inline size_t wcsnlen(const wchar_t * s, size_t count)
{
register int __res;
__asm__ __volatile__(
"movl %1,%0\n\t"
"jmp 2f\n"
"1:\tcmpw $0,(%0)\n\t"
"je 3f\n\t"
"incl %0\n"
"2:\tdecl %2\n\t"
"cmpl $-1,%2\n\t"
"jne 1b\n"
"3:\tsubl %1,%0"
:"=a" (__res)
:"c" (s),"d" (count)
:"edx");
return __res;
}
#define __HAVE_ARCH_WCSICMP
inline int wcsicmp(const wchar_t* cs,const wchar_t * ct)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tmovw (%%esi), %%eax\n\t"
"movw (%%edi), %%edx \n\t"
"cmpw $0x5A, %%eax\n\t"
"ja 2f\t\n"
"cmpw $0x40, %%eax\t\n"
"jbe 2f\t\n"
"addw $0x20, %%eax\t\n"
"2:\t cmpw $0x5A, %%edx\t\n"
"ja 3f\t\n"
"cmpw $0x40, %%edx\t\n"
"jbe 3f\t\n"
"addw $0x20, %%edx\t\n"
"3:\t inc %%esi\t\n"
"inc %%esi\t\n"
"inc %%edi\t\n"
"inc %%edi\t\n"
"cmpw %%eax, %%edx\t\n"
"jne 4f\n\t"
"cmpw $00, %%eax\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 5f\n"
"4:\tsbbl %%eax,%%eax\n\t"
"orw $1,%%eax\n"
"5:"
:"=a" (__res):"S" (cs),"D" (ct):"esi","edi");
return __res;
}
#define __HAVE_ARCH_WCSNICMP
inline int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\t decl %3\n\t"
"js 6f\n\t"
"movw (%%esi), %%eax\n\t"
"movw (%%edi), %%edx \n\t"
"cmpw $0x5A, %%eax\n\t"
"ja 2f\t\n"
"cmpw $0x40, %%eax\t\n"
"jbe 2f\t\n"
"addw $0x20, %%eax\t\n"
"2:\t cmpw $0x5A, %%edx\t\n"
"ja 3f\t\n"
"cmpw $0x40, %%edx\t\n"
"jbe 3f\t\n"
"addw $0x20, %%edx\t\n"
"3:\t inc %%esi\t\n"
"inc %%esi\t\n"
"inc %%edi\t\n"
"inc %%edi\t\n"
"cmpw %%eax, %%edx\t\n"
"jne 4f\n\t"
"cmpw $00, %%eax\n\t"
"jne 1b\n\t"
"6:xorl %%eax,%%eax\n\t"
"jmp 5f\n"
"4:\tsbbl %%eax,%%eax\n\t"
"orw $1,%%eax\n"
"5:"
:"=a" (__res):"S" (cs),"D" (ct), "c" (count):"esi","edi", "ecx");
return __res;
}
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,58 @@
/*
* Win32 File Api functions
* Author: Boudewijn Dekker
* to do: many more to add ..
*/
#include <windows.h>
// AnsiOrOemtoUnicode
// pupose: internal procedure used in file api
NTSTATUS AnsiOrOemtoUnicode(PUNICODE_STRING DestinationString,PANSI_STRING SourceString, BOOLEAN AllocateDestinationString);
BOOLEAN bIsFileApiAnsi; // set the file api to ansi or oem
NTSTATUS AnsiOrOemtoUnicode(PUNICODE_STRING DestinationString,PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
{
if ( bIsFileApiAnsi ) {
return __AnsiStringToUnicodeString(DestinationString, SourceString, AllocateDestinationString);
else
return __OemStringToUnicodeString(DestinationString, SourceString, AllocateDestinationString);
}
WINBASEAPI
VOID
WINAPI
SetFileApisToOEM(VOID)
{
bIsFileApiAnsi = FALSE;
return;
}
WINBASEAPI
VOID
WINAPI
SetFileApisToANSI(VOID)
{
bIsFileApiAnsi = TRUE;
return;
}
WINBASEAPI
BOOLEAN
WINAPI
AreFileApisANSI(VOID)
{
return bIsFileApiAnsi;
}

View file

@ -0,0 +1,138 @@
/*
* created: Boudewijn Dekker
* org. source: WINE
* date: june 1998
* todo: check the _lopen for correctness
*/
#include <windows.h>
#include <string.h>
#include <wstring.h>
long _hread(
HFILE hFile,
LPVOID lpBuffer,
long lBytes
)
{
DWORD NumberOfBytesRead;
if ( ReadFile((HANDLE)hFile,(LPCVOID)lpBuffer,(DWORD)lBytes,&NumberOfBytesRead, NULL) == FALSE )
return -1;
else
return NumberOfBytesRead;
}
long
_lread(HFILE fd,LPVOID buffer,long count)
{
return _hread(fd,buffer, count);
}
long _hwrite(
HFILE hFile,
LPCSTR lpBuffer,
long lBytes
)
{
DWORD NumberOfBytesWritten;
if ( lBytes == 0 ) {
if ( SetEndOfFile((HANDLE) hFile ) == FALSE )
return -1;
else
return 0;
}
if ( WriteFile((HANDLE)hFile,(LPCVOID)lpBuffer,(DWORD)lBytes, &NumberOfBytesWritten,NULL) == FALSE )
return -1;
else
return NumberOfBytesWritten;
}
long _lwrite(
HFILE hFile,
LPCSTR lpBuffer,
long lBytes
)
{
return _hwrite(hFile,lpBuffer,lBytes);
}
#define OF_OPENMASK (OF_READ|OF_READWRITE|OF_WRITE|OF_CREATE)
#define OF_FILEMASK (OF_DELETE|OF_PARSE)
#define OF_MASK (OF_OPENMASK|OF_FILEMASK)
HFILE _open( LPCSTR lpPathName, int iReadWrite )
{
HFILE fd;
int nFunction;
/* Don't assume a 1:1 relationship between OF_* modes and O_* modes */
/* Here we translate the read/write permission bits (which had better */
/* be the low 2 bits. If not, we're in trouble. Other bits are */
/* passed through unchanged */
nFunction = wFunction & 3;
switch (wFunction & 3) {
case OF_READ:
nFunction |= O_RDONLY;
break;
case OF_READWRITE:
nFunction |= O_RDWR;
break;
case OF_WRITE:
nFunction |= O_WRONLY;
break;
default:
//ERRSTR((LF_ERROR, "_lopen: bad file open mode %x\n", wFunction));
return HFILE_ERROR;
}
SetLastError(0);
fd = CreateFileA( filename,nFunction,OPEN_EXISTING,
NULL,OPEN_EXISTING,NULL,NULL);
if (fd == INVALID_HANDLE_VALUE )
return HFILE_ERROR;
return fd;
}
int _creat(const char *filename, int pmode)
{
SetLastError(0);
return CreateFileA( filename,GENERIC_READ & GENERIC_WRITE,FILE_SHARE_WRITE,
NULL,CREATE_ALWAYS,pmode & 0x00003FB7,NULL);
}
int _lclose(
HFILE hFile
)
{
if ( CloseHandle((HANDLE)hFile) )
return 0;
else
rerturn -1;
}
LONG _llseek(
HFILE hFile,
LONG lOffset,
int iOrigin
)
{
return SetFilePointer((HANDLE) hFile, lOffset, NULL,(DWORD)iOrigin );
}

View file

@ -0,0 +1,10 @@
all: dummy
OBJECTS = file/file.o file/lfile.o mem/virtual.o mem/local.o mem/global.o
kernel32_lib: $(OBJECTS)
$(LD) --oformat=coff-go32 -Ttext b0000000 $(LDFLAGS) $(OBJECTS) -o kernel32.dll
dummy:
include ../../rules.mak

View file

@ -0,0 +1,320 @@
/*
* Win32 Global/Local heap functions (GlobalXXX, LocalXXX).
* These functions included in Win32 for compatibility with 16 bit Windows
* Especially the moveable blocks and handles are oldish.
* But the ability to directly allocate memory with GPTR and LPTR is widely
* used.
*/
#include <windows.h>
#define MAGIC_GLOBAL_USED 0x5342BEEF
#define GLOBAL_LOCK_MAX 0xFF
typedef struct __GLOBAL_LOCAL_HANDLE
{
ULONG Magic;
LPVOID Pointer;
BYTE Flags;
BYTE LockCount;
} GLOBAL_HANDLE, LOCAL_HANDLE, *PGLOBAL_HANDLE, *PLOCAL_HANDLE;
/*********************************************************************
* GlobalAlloc -- KERNEL32 *
*********************************************************************/
HGLOBAL WINAPI GlobalAlloc(UINT flags, DWORD size)
{
PGLOBAL_HANDLE phandle;
LPVOID palloc;
aprintf("GlobalAlloc( 0x%X, 0x%lX )\n", flags, size );
if((flags & GMEM_MOVEABLE)==0) /* POINTER */
{
palloc=HeapAlloc(__ProcessHeap, 0, size);
return (HGLOBAL) palloc;
}
else /* HANDLE */
{
HeapLock(__ProcessHeap);
phandle=__HeapAllocFragment(__ProcessHeap, 0, sizeof(GLOBAL_HANDLE));
if(size)
{
palloc=HeapAlloc(__ProcessHeap, 0, size+sizeof(HANDLE));
*(PHANDLE)palloc=(HANDLE) &(phandle->Pointer);
phandle->Pointer=palloc+sizeof(HANDLE);
}
else
phandle->Pointer=NULL;
phandle->Magic=MAGIC_GLOBAL_USED;
phandle->Flags=flags>>8;
phandle->LockCount=0;
HeapUnlock(__ProcessHeap);
return (HGLOBAL) &(phandle->Pointer);
}
}
/*********************************************************************
* GlobalLock -- KERNEL32 *
*********************************************************************/
LPVOID WINAPI GlobalLock(HGLOBAL hmem)
{
PGLOBAL_HANDLE phandle;
LPVOID palloc;
aprintf("GlobalLock( 0x%lX )\n", (ULONG) hmem );
if(((ULONG)hmem%8)==0)
return (LPVOID) hmem;
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
if(phandle->LockCount<GLOBAL_LOCK_MAX)
phandle->LockCount++;
palloc=phandle->Pointer;
}
else
{
dprintf("GlobalLock: invalid handle\n");
palloc=(LPVOID) hmem;
}
HeapUnlock(__ProcessHeap);
return palloc;
}
/*********************************************************************
* GlobalUnlock -- KERNEL32 *
*********************************************************************/
BOOL WINAPI GlobalUnlock(HGLOBAL hmem)
{
PGLOBAL_HANDLE phandle;
BOOL locked;
aprintf("GlobalUnlock( 0x%lX )\n", (ULONG) hmem );
if(((ULONG)hmem%8)==0)
return FALSE;
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
if((phandle->LockCount<GLOBAL_LOCK_MAX)&&(phandle->LockCount>0))
phandle->LockCount--;
locked=(phandle->LockCount==0) ? TRUE : FALSE;
}
else
{
dprintf("GlobalUnlock: invalid handle\n");
locked=FALSE;
}
HeapUnlock(__ProcessHeap);
return locked;
}
/*********************************************************************
* GlobalHandle -- KERNEL32 *
*********************************************************************/
HGLOBAL WINAPI GlobalHandle(LPCVOID pmem)
{
aprintf("GlobalHandle( 0x%lX )\n", (ULONG) pmem );
if(((ULONG)pmem%8)==0) /* FIXED */
return (HGLOBAL) pmem;
else /* MOVEABLE */
return (HGLOBAL) *(LPVOID *)(pmem-sizeof(HANDLE));
}
/*********************************************************************
* GlobalReAlloc -- KERNEL32 *
*********************************************************************/
HGLOBAL WINAPI GlobalReAlloc(HGLOBAL hmem, DWORD size, UINT flags)
{
LPVOID palloc;
HGLOBAL hnew;
PGLOBAL_HANDLE phandle;
aprintf("GlobalReAlloc( 0x%lX, 0x%lX, 0x%X )\n", (ULONG) hmem, size, flags );
hnew=NULL;
HeapLock(__ProcessHeap);
if(flags & GMEM_MODIFY) /* modify flags */
{
if( (((ULONG)hmem%8)==0) && (flags & GMEM_MOVEABLE))
{
/* make a fixed block moveable
* actually only NT is able to do this. And it's soo simple
*/
size=HeapSize(__ProcessHeap, 0, (LPVOID) hmem);
hnew=GlobalAlloc( flags, size);
palloc=GlobalLock(hnew);
memcpy(palloc, (LPVOID) hmem, size);
GlobalUnlock(hnew);
GlobalFree(hmem);
}
else if((((ULONG)hmem%8) != 0)&&(flags & GMEM_DISCARDABLE))
{
/* change the flags to make our block "discardable" */
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
phandle->Flags = phandle->Flags | (GMEM_DISCARDABLE >> 8);
hnew=hmem;
}
else
{
SetLastError(ERROR_INVALID_PARAMETER);
hnew=NULL;
}
}
else
{
if(((ULONG)hmem%8)!=0)
{
/* reallocate fixed memory */
hnew=(HANDLE)HeapReAlloc(__ProcessHeap, 0, (LPVOID) hmem, size);
}
else
{
/* reallocate a moveable block */
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->LockCount!=0)
SetLastError(ERROR_INVALID_HANDLE);
else if(size!=0)
{
hnew=hmem;
if(phandle->Pointer)
{
palloc=HeapReAlloc(__ProcessHeap, 0,
phandle->Pointer-sizeof(HANDLE),
size+sizeof(HANDLE) );
phandle->Pointer=palloc+sizeof(HANDLE);
}
else
{
palloc=HeapAlloc(__ProcessHeap, 0, size+sizeof(HANDLE));
*(PHANDLE)palloc=hmem;
phandle->Pointer=palloc+sizeof(HANDLE);
}
}
else
{
if(phandle->Pointer)
{
HeapFree(__ProcessHeap, 0, phandle->Pointer-sizeof(HANDLE));
phandle->Pointer=NULL;
}
}
}
}
HeapUnlock(__ProcessHeap);
return hnew;
}
/*********************************************************************
* GlobalFree -- KERNEL32 *
*********************************************************************/
HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
{
PGLOBAL_HANDLE phandle;
aprintf("GlobalFree( 0x%lX )\n", (ULONG) hmem );
if(((ULONG)hmem%4)==0) /* POINTER */
{
HeapFree(__ProcessHeap, 0, (LPVOID) hmem);
}
else /* HANDLE */
{
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
HeapLock(__ProcessHeap);
if(phandle->LockCount!=0)
SetLastError(ERROR_INVALID_HANDLE);
if(phandle->Pointer)
HeapFree(__ProcessHeap, 0, phandle->Pointer-sizeof(HANDLE));
__HeapFreeFragment(__ProcessHeap, 0, phandle);
}
HeapUnlock(__ProcessHeap);
}
return hmem;
}
/*********************************************************************
* GlobalSize -- KERNEL32 *
*********************************************************************/
DWORD WINAPI GlobalSize(HGLOBAL hmem)
{
DWORD retval;
PGLOBAL_HANDLE phandle;
aprintf("GlobalSize( 0x%lX )\n", (ULONG) hmem );
if(((ULONG)hmem%8)==0)
{
retval=HeapSize(__ProcessHeap, 0, hmem);
}
else
{
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
retval=HeapSize(__ProcessHeap, 0, (phandle->Pointer)-sizeof(HANDLE))-4;
}
else
{
dprintf("GlobalSize: invalid handle\n");
retval=0;
}
HeapUnlock(__ProcessHeap);
}
return retval;
}
/*********************************************************************
* GlobalWire -- KERNEL32 *
*********************************************************************/
LPVOID WINAPI GlobalWire(HGLOBAL hmem)
{
return GlobalLock( hmem );
}
/*********************************************************************
* GlobalUnWire -- KERNEL32 *
*********************************************************************/
BOOL WINAPI GlobalUnWire(HGLOBAL hmem)
{
return GlobalUnlock( hmem);
}
/*********************************************************************
* GlobalFix -- KERNEL32 *
*********************************************************************/
VOID WINAPI GlobalFix(HGLOBAL hmem)
{
GlobalLock( hmem );
}
/*********************************************************************
* GlobalUnfix -- KERNEL32 *
*********************************************************************/
VOID WINAPI GlobalUnfix(HGLOBAL hmem)
{
GlobalUnlock( hmem);
}
/*********************************************************************
* GlobalFlags -- KERNEL32 *
*********************************************************************/
UINT WINAPI GlobalFlags(HGLOBAL hmem)
{
return LocalFlags( (HLOCAL) hmem);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,123 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1996, Onno Hovers, All rights reserved
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/mem/local.cc
* PURPOSE: Manages the local heap
* PROGRAMER: Onno Hovers (original wfc version)
* David Welch (adapted for ReactOS)
* UPDATE HISTORY:
* 9/4/98: Adapted from the wfc project
*/
/* NOTES
*
* The local heap is the same as the global heap for win32 and both are only
* required for legacy apps
*
*/
/* INCLUDES ****************************************************************/
#include <windows.h>
#include <kernel32/heap.h>
/* FUNCTIONS ***************************************************************/
/*********************************************************************
* LocalFlags -- KERNEL32 *
*********************************************************************/
UINT WINAPI LocalFlags(HLOCAL hmem)
{
DWORD retval;
PGLOBAL_HANDLE phandle;
if(((ULONG)hmem%8)==0)
{
retval=0;
}
else
{
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
retval=phandle->LockCount + (phandle->Flags<<8);
if(phandle->Pointer==0)
retval|= LMEM_DISCARDED;
}
else
{
dprintf("GlobalSize: invalid handle\n");
retval=0;
}
HeapUnlock(__ProcessHeap);
}
return retval;
}
/*********************************************************************
* LocalAlloc -- KERNEL32 *
*********************************************************************/
HLOCAL WINAPI LocalAlloc(UINT flags, UINT size)
{
return (HLOCAL) GlobalAlloc( flags, size );
}
/*********************************************************************
* LocalLock -- KERNEL32 *
*********************************************************************/
LPVOID WINAPI LocalLock(HLOCAL hmem)
{
return GlobalLock( (HGLOBAL) hmem );
}
/*********************************************************************
* LocalUnlock -- KERNEL32 *
*********************************************************************/
BOOL WINAPI LocalUnlock(HLOCAL hmem)
{
return GlobalUnlock( (HGLOBAL) hmem);
}
/*********************************************************************
* LocalHandle -- KERNEL32 *
*********************************************************************/
HLOCAL WINAPI LocalHandle(LPCVOID pmem)
{
return (HLOCAL) GlobalHandle(pmem);
}
/*********************************************************************
* LocalReAlloc -- KERNEL32 *
*********************************************************************/
HLOCAL WINAPI LocalReAlloc(HLOCAL hmem, UINT size, UINT flags)
{
return (HLOCAL) GlobalReAlloc( (HGLOBAL) hmem, size, flags);
}
/*********************************************************************
* LocalFree -- KERNEL32 *
*********************************************************************/
HLOCAL WINAPI LocalFree(HLOCAL hmem)
{
return (HLOCAL) GlobalFree( (HGLOBAL) hmem );
}
/*********************************************************************
* LocalSize -- KERNEL32 *
*********************************************************************/
UINT WINAPI LocalSize(HLOCAL hmem)
{
return GlobalSize( (HGLOBAL) hmem );
}
/*********************************************************************
* LocalShrink -- KERNEL32 *
*********************************************************************/
UINT WINAPI LocalShrink(HLOCAL hmem, UINT newsize)
{
return (__ProcessHeap->End - (LPVOID) __ProcessHeap);
}

View file

@ -0,0 +1,23 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user mode libraries
* FILE: kernel32/mem/utils.cc
* PURPOSE: Various simple memory initalizations functions
*/
#include <windows.h>
VOID ZeroMemory(PVOID Destination, DWORD Length)
{
#ifdef __i386__
#endif /* __i386__ */
}
VOID CopyMemory(PVOID Destination, CONST VOID* Source, DWORD Length)
{
#ifdef __i386__
#endif /* __i386__ */
}

View file

@ -0,0 +1,19 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/kernel32/mem/virtual.c
* PURPOSE: Passing the Virtualxxx functions onto the kernel
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
/* INCLUDES ******************************************************************/
#include <windows.h>
/* FUNCTIONS *****************************************************************/
WINBOOL STDCALL VirtualFree(LPVOID lpAddress, DWORD dwSize, DWORD dwFreeType)
{
return(VirtualFreeEx(GetCurrentProcess(),lpAddress,dwSize,dwFreeType));
}

View file

@ -0,0 +1,527 @@
#include <Atom.h>
#include <process.h>
#include <thread.h>
#include <wstring.h>
/*
title: atom.c
author: Boudewijn Dekker
hsitory:copied from twin wine source
modified: -- add wide char support
-- removed ex functions
-- use a per process local atom table
todo :
check initatomtable
check if not calling down to ntdll conflicts with anything
check anis2unicode procedure
*/
/* system global and local atom tables */
static ATOMTABLE GlobalAtomTable;
/* internal functions */
ATOM GLDeleteAtom(ATOMTABLE *at, ATOM nAtom);
ATOM AWGLAddAtom( ATOMTABLE *at, const wchar_t *lpString);
ATOM AWGLFindAtom(ATOMTABLE *at, const wchar_t *lpString);
UINT AWGLGetAtomName(ATOMTABLE *at,ATOM atom, wchar_t *lpString, int nSize);
static ATOMENTRY *GetAtomPointer(ATOMTABLE *,int);
static ATOMID AtomHashString(const wchar_t *,int *);
#define ATOMBASE 0xcc00
ATOM
STDCALL
GlobalDeleteAtom(
ATOM nAtom
)
{
return GLDeleteAtom(&GlobalAtomTable, nAtom);
}
BOOL
STDCALL
InitAtomTable(
DWORD nSize
)
{
// nSize should be a prime number
if ( nSize < 4 || nSize >= 512 ) {
nSize = 37;
}
/*
if ( GetTeb()->pPeb->LocalAtomTable == NULL ) {
GetTeb()->pPeb->LocalAtomTable = (ATOMTABLE *)malloc(nSize*sizeof(ATOMTABLE));
}
GetTeb()->pPeb->LocalAtomTable->TableSize = nSize;
*/
return TRUE;
}
ATOM
STDCALL
DeleteAtom(
ATOM nAtom
)
{
return GLDeleteAtom(&GetTeb()->pPeb->LocalAtomTable, nAtom);
}
ATOM
STDCALL
GlobalAddAtomA(
const char *lpString
)
{
UINT BufLen = strlen(lpString);
wchar_t *lpBuffer = (wchar_t *)malloc(BufLen*sizeof(wchar_t));
ATOM atom;
ansi2unicode(lpBuffer, lpString,BufLen);
atom = AWGLAddAtom(&GlobalAtomTable,lpBuffer );
free(lpBuffer);
return atom;
}
ATOM
STDCALL
GlobalAddAtomW(
const wchar_t *lpString
)
{
return AWGLAddAtom(&GlobalAtomTable, lpString);
}
ATOM
STDCALL
GlobalFindAtomA(
const char *lpString
)
{
ATOM a;
UINT BufLen = strlen(lpString);
wchar_t *lpBuffer = (wchar_t *)malloc(BufLen*sizeof(wchar_t));
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLFindAtom(&GlobalAtomTable, lpBuffer);
free(lpBuffer);
return a;
}
ATOM
STDCALL
GlobalFindAtomW(
const wchar_t *lpString
)
{
return AWGLFindAtom(&GlobalAtomTable, lpString);
}
UINT
STDCALL
GlobalGetAtomNameA(
ATOM nAtom,
char *lpBuffer,
int nSize
)
{
wchar_t *lpUnicode = (wchar_t *)malloc(nSize *sizeof(wchar_t));
UINT x = AWGLGetAtomName(&GlobalAtomTable,nAtom, lpUnicode,nSize);
unicode2ansi(lpBuffer,lpUnicode,nSize);
free(lpUnicode);
return x;
}
UINT
STDCALL
GlobalGetAtomNameW(
ATOM nAtom,
wchar_t * lpBuffer,
int nSize
)
{
return AWGLGetAtomName(&GlobalAtomTable, nAtom, lpBuffer, nSize);
}
ATOM
STDCALL
AddAtomA(
const char *lpString
)
{
UINT BufLen = strlen(lpString);
wchar_t *lpBuffer = (wchar_t*)malloc(BufLen*2);
ATOM a;
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLAddAtom(&GetTeb()->pPeb->LocalAtomTable, lpBuffer);
free(lpBuffer);
return a;
}
ATOM
STDCALL
AddAtomW(
const wchar_t * lpString
)
{
return AWGLAddAtom(&GetTeb()->pPeb->LocalAtomTable, lpString);
}
ATOM
STDCALL
FindAtomA(
const char *lpString
)
{
UINT BufLen = strlen(lpString);
wchar_t *lpBuffer = (wchar_t *)malloc(BufLen*2);
ATOM a;
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLFindAtom(&GetTeb()->pPeb->LocalAtomTable, lpBuffer);
free(lpBuffer);
return a;
}
ATOM
STDCALL
FindAtomW(
const wchar_t * lpString
)
{
return AWGLFindAtom(&GetTeb()->pPeb->LocalAtomTable, lpString);
}
UINT
STDCALL
GetAtomNameA(
ATOM nAtom,
char *lpBuffer,
int nSize
)
{
LPWSTR lpUnicode = (wchar_t *)malloc(nSize *2);
UINT x = AWGLGetAtomName(&GlobalAtomTable, nAtom,lpUnicode,nSize);
unicode2ansi(lpBuffer,lpUnicode,nSize);
free(lpUnicode);
return x;
}
UINT
STDCALL
GetAtomNameW(
ATOM nAtom,
wchar_t * lpBuffer,
int nSize
)
{
return AWGLGetAtomName(&GetTeb()->pPeb->LocalAtomTable,nAtom,lpBuffer, nSize);
}
ATOM
GLDeleteAtom(
ATOMTABLE *at, ATOM nAtom
)
{
ATOMENTRY *lp;
/* a free slot has q == 0 && refcnt == 0 */
if((lp = GetAtomPointer(at,nAtom - ATOMBASE))) {
if(lp->idsize)
lp->refcnt--;
if(lp->refcnt == 0) {
free(at->AtomTable);
at->AtomTable = NULL;
free(at->AtomData);
at->AtomData = NULL;
return lp->q = 0;
}
}
return nAtom;
}
ATOM
AWGLAddAtom(
ATOMTABLE *at, const wchar_t *lpString
)
{
ATOM atom;
ATOMID q;
LPATOMENTRY lp,lpfree;
int index,freeindex;
int atomlen;
int newlen;
/* if we already have it, bump refcnt */
if((atom = AWGLFindAtom(at, lpString ))) {
lp = GetAtomPointer(at,atom - ATOMBASE);
if(lp->idsize) lp->refcnt++;
return atom;
}
/* add to a free slot */
q = AtomHashString(lpString,&atomlen);
lpfree = 0;
freeindex = 0;
for(index = 0;(lp = GetAtomPointer(at,index));index++) {
if(lp->q == 0 && lp->refcnt == 0) {
if(lp->idsize > atomlen) {
if ((lpfree == 0) ||
(lpfree->idsize > lp->idsize)) {
lpfree = lp;
freeindex = index;
}
}
}
}
/* intatoms do not take space in data, but do get new entries */
/* an INTATOM will have length of 0 */
if(lpfree && atomlen) {
lpfree->q = q;
lpfree->refcnt = 1;
wcsncpy(&at->AtomData[lpfree->idx],lpString,atomlen);
return freeindex + ATOMBASE;
}
/* no space was available, or we have an INTATOM */
/* so expand or create the table */
if(at->AtomTable == 0) {
at->AtomTable = (ATOMENTRY *) malloc(sizeof(ATOMENTRY));
at->TableSize = 1;
lp = at->AtomTable;
index = 0;
} else {
at->TableSize++;
at->AtomTable = (ATOMENTRY *) realloc(
(LPVOID) at->AtomTable,
at->TableSize * sizeof(ATOMENTRY));
lp = &at->AtomTable[at->TableSize - 1];
}
/* set in the entry */
lp->refcnt = 1;
lp->q = q;
lp->idsize = atomlen;
lp->idx = 0;
/* add an entry if not intatom... */
if(atomlen) {
newlen = at->DataSize + atomlen;
if(at->AtomData == 0) {
at->AtomData = (wchar_t *) malloc(newlen*2);
lp->idx = 0;
} else {
at->AtomData = (wchar_t *) realloc(at->AtomData,newlen*2);
lp->idx = at->DataSize;
}
wcscpy(&at->AtomData[lp->idx],lpString);
at->DataSize = newlen;
}
return index + ATOMBASE;
}
ATOM
AWGLFindAtom(
ATOMTABLE *at, const wchar_t *lpString
)
{
ATOMID q;
LPATOMENTRY lp;
int index;
int atomlen;
/* convert string to 'q', and get length */
q = AtomHashString(lpString,&atomlen);
/* find the q value, note: this could be INTATOM */
/* if q matches, then do case insensitive compare*/
for(index = 0;(lp = GetAtomPointer(at,index));index++) {
if(lp->q == q) {
if(HIWORD(lpString) == 0)
return ATOMBASE + index;
if(wcsicmp(&at->AtomData[lp->idx],lpString) == 0)
return ATOMBASE + index;
}
}
return 0;
}
UINT
AWGLGetAtomName(ATOMTABLE *at, ATOM atom, wchar_t *lpString,int len)
{
ATOMENTRY *lp;
wchar_t *atomstr;
int atomlen;
/* return the atom name, or create the INTATOM */
if((lp = GetAtomPointer(at,atom - ATOMBASE))) {
if(lp->idsize) {
atomlen = wcslen(atomstr = &at->AtomData[lp->idx]);
if (atomlen < len)
wcscpy(lpString,atomstr);
else {
wcsncpy(lpString,atomstr,len-1);
lpString[len-1] = '\0';
}
return (UINT)wcslen(lpString);
} else {
//wsprintf((wchar *)lpString,"#%d",lp->q);
return (UINT)wcslen(lpString);
}
}
return 0;
}
/********************************************************/
/* convert alphanumeric string to a 'q' value. */
/* 'q' values do not need to be unique, they just limit */
/* the search we need to make to find a string */
/********************************************************/
static ATOMID
AtomHashString(const wchar_t * lp,int *lplen)
{
ATOMID q;
wchar_t *p,ch;
int len;
/* if we have an intatom... */
if(HIWORD(lp) == 0) {
if(lplen) *lplen = 0;
return (ATOMID)lp;
}
/* convert the string to an internal representation */
for(p=(wchar_t *)lp,q=0,len=0;(p++,ch=*p++);len++)
q = (q<<1) + iswlower(ch)?towupper(ch):ch;
/* 0 is reserved for empty slots */
if(q == 0)
q++;
/* avoid strlen later */
/* check out with unicode */
if(lplen) {
*lplen = ++len;
}
return q;
}
/********************************************************/
/* convert an atom index into a pointer into an */
/* atom table. This validates the pointer is in */
/* range, and that the data is accessible */
/********************************************************/
static ATOMENTRY *
GetAtomPointer(ATOMTABLE *at,int index)
{
ATOMENTRY *lp;
/* if no table, then no pointers */
if(at->AtomTable == 0)
return 0;
/* bad index */
if((index < 0) || (index >= at->TableSize))
return 0;
/* we have a pointer */
lp = &at->AtomTable[index];
/* is the index past stored data, validity check */
/* LATER: is the size of the entry within the available space */
if(lp->idx > at->DataSize)
return 0;
return lp;
}
int ansi2unicode( wchar_t *uni, char *ansi, int s)
{
register int i;
for(i=0;i<=s;i++)
uni[i] = (wchar_t)ansi[i];
return;
}
int unicode2ansi( char *ansi, wchar_t *uni, int s)
{
register int i;
for(i=0;i<=s;i++)
ansi[i] = (char)uni[i];
return;
}

View file

@ -0,0 +1,137 @@
#include <process.h>
/*
* Win32 Process Api functions
* Author: Boudewijn Dekker
* to do: many more to add ..
* open matters: ProcessInformation should be per process
and part of larger structure.
*/
#define NT_CURRENT_PROCESS 0xFFFFFFFF
#define NT_CURRENT_THREAD 0xFFFFFFFE
WINBASEAPI
HANDLE
WINAPI
GetCurrentProcess()
{
return NT_CURRENT_PROCESS;
}
WINBASEAPI
DWORD
WINAPI
GetCurrentProcessId()
{
return GetTeb()->dwProcessId;
}
WINBASEAPI
HANDLE
WINAPI
GetCurrentThread()
{
return NT_CURRENT_PROCESS;
}
WINBASEAPI
DWORD
WINAPI
GetCurrentThreadId()
{
return GetTeb()->dwThreadId;
}
UINT WinExec ( LPCSTR lpCmdLine, UINT uCmdShow )
{
STARTUPINFO StartUpInfo;
StartupInfo.wShowWindow = uCmdShow ;
PROCESS_INFORMATION ProcessInformation;
StartupInfo.cb = sizeof(STARTUPINFO);
StartupInfo.dwFlags = 0;
HINSTANCE hInst = CreateProcess(NULL,lpCmdLine,NULL,NULL,FALSE,NULL,NULL,NULL,&StartupInfo, &ProcessInformation);
if ( hInst == NULL ) {
dosErr = GetLastError();
if ( dosErr == 0x000000C1 )
return 0; // out of resources
else
return dosErr;
}
if ( lpfuncGlobalRegisterWaitForInputIdle != NULL )
lpfuncGlobalRegisterWaitForInputIdle(0x00007530,ProcessInformation->hProcess);
NtClose(ProcessInformation->hProcess);
NtClose(ProcessInformation->hThread);
return;
}
VOID RegisterWaitForInputIdle(lpfuncRegisterWaitForInputIdle)
{
lpfuncGlobalRegisterWaitForInputIdle = lpfuncRegisterWaitForInputIdle; //77F450C8
}
#define STARTF_IO 0x00000700
VOID
STDCALL
GetStartupInfoW(
LPSTARTUPINFO lpStartupInfo
)
{
NT_PEB *pPeb = GetTeb()->pPeb;
if (lpStartupInfo == NULL ) {
SetLastError(-1);
return;
}
lpStartupInfo->cb = pPeb->pPebInfo->cb;
lpStartupInfo->lpReserved = pPeb->pPebInfo->lpReserved1;
lpStartupInfo->lpDesktop = pPeb->pPebInfo->lpDesktop;
lpStartupInfo->lpTitle = pPeb->pPebInfo->lpTitle;
lpStartupInfo->dwX = pPeb->pPebInfo->dwX;
lpStartupInfo->dwY = pPeb->pPebInfo->dwY;
lpStartupInfo->dwXSize = pPeb->pPebInfo->dwXSize;
lpStartupInfo->dwYSize = pPeb->pPebInfo->dwYSize;
lpStartupInfo->dwXCountChars = pPeb->pPebInfo->dwXCountChars;
lpStartupInfo->dwYCountChars = pPeb->pPebInfo->dwYCountChars;
lpStartupInfo->dwFillAttribute = pPeb->pPebInfo->dwFillAttribute;
lpStartupInfo->dwFlags = pPeb->pPebInfo->dwFlags;
lpStartupInfo->wShowWindow = pPeb->pPebInfo->wShowWindow;
lpStartupInfo->cbReserved2 = pPeb->pPebInfo->cbReserved;
lpStartupInfo->lpReserved2 = pPeb->pPebInfo->lpReserved2;
if ( lpStartupInfo.dwFlags == STARTF_IO ) {
lpStartupInfo->hStdInput = pPeb->pPebInfo->hStdInput;
lpStartupInfo->hStdOutput = pPeb->pPebInfo->hStdOutput;
lpStartupInfo->hStdError = pPeb->pPebInfo->hStdError;
}
}
BOOL FlushInstructionCache(
HANDLE hProcess,
LPCVOID lpBaseAddress,
DWORD dwSize
)
{
errCode = NtFlushInstructionCache(hProcess,lpBaseAddress,dwSize);
if ( errCode < 0 ) {
CompatibleError(errCode);
return FALSE;
}
}

View file

@ -0,0 +1,123 @@
#include <windows.h>
#include <string.h>
#include <wstring.h>
int
STDCALL
lstrcmpA(
LPCSTR lpString1,
LPCSTR lpString2
)
{
return strcmp(lpString1,lpString2);
}
int
STDCALL
lstrcmpiA(
LPCSTR lpString1,
LPCSTR lpString2
)
{
return stricmp(lpString1,lpString2);
}
LPSTR
STDCALL
lstrcpynA(
LPSTR lpString1,
LPCSTR lpString2,
int iMaxLength
)
{
return strncpy(lpString1,lpString2,iMaxLength);
}
LPSTR
STDCALL
lstrcpyA(
LPSTR lpString1,
LPCSTR lpString2
)
{
return strcpy(lpString1,lpString2);
}
LPSTR
STDCALL
lstrcatA(
LPSTR lpString1,
LPCSTR lpString2
)
{
return strcat(lpString1,lpString2);
}
int
STDCALL
lstrlenA(
LPCSTR lpString
)
{
return strlen(lpString);
}
int
STDCALL
lstrcmpW(
LPCWSTR lpString1,
LPCWSTR lpString2
)
{
return wcscmp(lpString1,lpString2);
}
int
STDCALL
lstrcmpiW(
LPCWSTR lpString1,
LPCWSTR lpString2
)
{
return wcsicmp(lpString1,lpString2);
}
LPWSTR
STDCALL
lstrcpynW(
LPWSTR lpString1,
LPCWSTR lpString2,
int iMaxLength
)
{
return wcsncpy(lpString1,lpString2,iMaxLength);
}
LPWSTR
STDCALL
lstrcpyW(
LPWSTR lpString1,
LPCWSTR lpString2
)
{
return wcscpy(lpString1,lpString2);
}
LPWSTR
STDCALL
lstrcatW(
LPWSTR lpString1,
LPCWSTR lpString2
)
{
return wcscat(lpString1,lpString2);
}
int
STDCALL
lstrlenW(
LPCWSTR lpString
)
{
return wcslen(lpString);
}

View file

@ -0,0 +1,83 @@
/*
author: Boudewijn Dekker
original source : wine
todo: improve debug info
*/
#include <thread.h>
WINBASEAPI
BOOL
WINAPI
SwitchToThread(
VOID
)
{
return NtYieldExecution();
}
/* (WIN32) Thread Local Storage ******************************************** */
DWORD WINAPI
TlsAlloc(VOID)
{
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
void **TlsData = GetTeb()->TlsData;
APISTR((LF_API, "TlsAlloc: (API)\n"));
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
{
TlsData[dwTlsIndex] = NULL;
return (dwTlsIndex++);
}
return (0xFFFFFFFFUL);
}
BOOL WINAPI
TlsFree(DWORD dwTlsIndex)
{
APISTR((LF_APISTUB, "TlsFree(DWORD=%ld)\n", dwTlsIndex));
return (TRUE);
}
LPVOID WINAPI
TlsGetValue(DWORD dwTlsIndex)
{
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
void **TlsData = GetTeb()->TlsData;
APISTR((LF_API, "TlsGetValue: (API) dwTlsIndex %ld\n", dwTlsIndex));
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
{
LOGSTR((LF_LOG, "TlsGetValue: (LOG) [%ld] = %p\n",
dwTlsIndex, TlsData[dwTlsIndex]));
SetLastError(NO_ERROR);
return (TlsData[dwTlsIndex]);
}
SetLastErrorEx(1, 0);
return (NULL);
}
BOOL WINAPI
TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
{
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
void **TlsData = GetTeb()->TlsData;
APISTR((LF_API, "TlsSetValue: (API) dwTlsIndex %ld lpTlsValue %p\n",
dwTlsIndex, lpTlsValue));
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
{
LOGSTR((LF_LOG, "TlsSetValue: (LOG) [%ld] = %p\n",
dwTlsIndex, lpTlsValue));
TlsData[dwTlsIndex] = lpTlsValue;
return (TRUE);
}
return (FALSE);
}
/*************************************************************/

12
reactos/lib/makefile Normal file
View file

@ -0,0 +1,12 @@
LIBRARIES = ntdll kernel32
all: $(LIBRARIES)
ntdll: dummy
make -C ntdll
kernel32: dummy
make -C kernel32
dummy:

BIN
reactos/lib/ntdll/genntdll Normal file

Binary file not shown.

View file

@ -0,0 +1,87 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS version of ntdll
* FILE: lib/ntdll/genntdll.c
* PURPOSE: Generates the system call stubs in ntdll
* PROGRAMMER: David Welch (welch@welch)
*/
/* INCLUDE ******************************************************************/
#include <stdio.h>
#include <stdlib.h>
/* FUNCTIONS ****************************************************************/
int process(FILE* in, FILE* out)
{
char line[255];
char* s;
char* name;
char* value;
fprintf(out,"/*\n");
fprintf(out," * Machine generated, don't edit\n");
fprintf(out," */\n\n");
fprintf(out,"#include <ntdll/napi.h>\n\n");
while (!feof(in) && fgets(line,255,in)!=NULL)
{
fgets(line,255,in);
if ((s=strchr(line,'\n'))!=NULL)
{
*s=0;
}
s=&line[0];
if ((*s)!='#')
{
name = strtok(s," \t");
value = strtok(NULL," \t");
printf("name %s value %s\n",name,value);
fprintf(out,"NTSTATUS %s(UCHAR first_arg)\n",name);
fprintf(out,"{\n");
fprintf(out,"\tMAKE_NTAPI_CALL(%s,first_arg);\n",value);
fprintf(out,"}\n");
}
}
}
void usage(void)
{
printf("Usage: genntdll infile.cll outfile.c\n");
}
int main(int argc, char* argv[])
{
FILE* in;
FILE* out;
int ret;
if (argc!=3)
{
usage();
return(1);
}
in = fopen(argv[1],"rb");
if (in==NULL)
{
perror("Failed to open input file");
return(1);
}
out = fopen(argv[2],"wb");
if (out==NULL)
{
perror("Failed to open output file");
return(1);
}
ret = process(in,out);
fclose(in);
fclose(out);
return(ret);
}

View file

@ -0,0 +1,7 @@
all: genntdll$(EXE_POSTFIX)
genntdll$(EXE_POSTFIX): genntdll.c
$(NATIVE_CC) -g genntdll.c -o genntdll$(EXE_POSTFIX)
dummy:
include ../../rules.mak

10
reactos/lib/ntdll/ntdll.c Normal file
View file

@ -0,0 +1,10 @@
/*
* Machine generated, don't edit
*/
#include <ntdll/napi.h>
NTSTATUS NtAlertThread(UCHAR first_arg)
{
MAKE_NTAPI_CALL(4,first_arg);
}

View file

@ -0,0 +1,4 @@
#
# This defines the kernel entry points used by ntdll
#
NtAlertThread 4

22
reactos/lib/ntdll/ntdll.s Normal file
View file

@ -0,0 +1,22 @@
.file "ntdll.c"
.version "01.01"
gcc2_compiled.:
.text
.align 16
.globl NtAlertThread
.type NtAlertThread,@function
NtAlertThread:
subl $4,%esp
movb 8(%esp),%al
movb %al,3(%esp)
leal 3(%esp),%edx
movl $4,%eax
#APP
int $0x2e
#NO_APP
addl $4,%esp
ret
.Lfe1:
.size NtAlertThread,.Lfe1-NtAlertThread
.ident "GCC: (GNU) 2.7.2.3"

View file

@ -0,0 +1,291 @@
;
; File:
; boot.asm
; Description:
; DOS-C boot
;
; Copyright (c) 1997;
; Svante Frey
; All Rights Reserved
;
; This file is part of DOS-C.
;
; DOS-C 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, or (at your option) any later version.
;
; DOS-C 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 DOS-C; see the file COPYING. If not,
; write to the Free Software Foundation, 675 Mass Ave,
; Cambridge, MA 02139, USA.
;
; $Logfile: C:/dos-c/src/boot/boot.asv $
;
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.asm,v 1.1 1996/01/23 01:02:19 rosmgr Exp $
;
; $Log: boot.asm,v $
; Revision 1.1 1996/01/23 01:02:19 rosmgr
; Initial revision
;
;
; Rev 1.5 10 Jan 1997 4:58:06 patv
; Corrected copyright
;
; Rev 1.4 10 Jan 1997 4:52:50 patv
; Re-written to support C drive and eliminate restrictions on IPL.SYS
;
; Rev 1.3 29 Aug 1996 13:06:50 patv
; Bug fixes for v0.91b
;
; Rev 1.2 01 Sep 1995 17:56:44 patv
; First GPL release.
;
; Rev 1.1 30 Jul 1995 20:37:38 patv
; Initialized stack before use.
;
; Rev 1.0 02 Jul 1995 10:57:52 patv
; Initial revision.
;
section .text
org 0
Entry: jmp real_start
; bp is initialized to 7c00h
%define oem [bp+3]
%define bytesPerSector [bp+0bh]
%define sectPerCluster [bp+0dh]
%define resSectors [bp+0eh]
%define nFats [bp+10h]
%define nRootDir [bp+11h]
%define nSectors [bp+13h]
%define MID [bp+15h]
%define sectPerFat [bp+16h]
%define sectPerTrack [bp+18h]
%define nHeads [bp+1ah]
%define nHidden [bp+1ch]
%define nHidden_hi [bp+1eh]
%define nSectorHuge [bp+20h]
%define drive [bp+24h]
%define extBoot [bp+26h]
%define volid [bp+27h]
%define vollabel [bp+2bh]
%define filesys 36h
LOADSEG equ 2000h
FATBUF equ 4000h ; offset of temporary buffer for FAT
; chain
RETRYCOUNT equ 5 ; number of retries on disk errors
; Some extra variables that are created on the stack frame
%define fat_start [bp-4] ; first FAT sector
%define fat_start_hi [bp-2]
%define root_dir_start [bp-8] ; first root directory sector
%define root_dir_start_hi [bp-6]
%define data_start [bp-12] ; first data sector
%define data_start_hi [bp-10]
;
; Include macros for filesystem access
;
%include "boot.inc"
;
;
;
TIMES 3eh-($-$$) DB 0
%define tempbuf [bp+3eh]
load_seg dw LOADSEG
real_start: cli
cld
mov ax, cs
mov ss, ax ; initialize stack
mov bp, 7c00h
lea sp, [bp-20h]
sti
mov es, ax
mov ds, ax
mov drive, dl ; BIOS passes drive number in DL
GETDRIVEPARMS
FINDFILE ; locate file in root directory
jc boot_error ; fail if not found
GETFATCHAIN ; read FAT chain
LOADFILE ; load file (jumps to boot_sucess if successful)
boot_error: mov cx, ERRMSGLEN
mov si, errmsg+7c00h
next_char: lodsb ; print error message
mov ah, 0eh
xor bh, bh
int 10h
loop next_char
xor ah, ah
int 16h ; wait for keystroke
int 19h ; invoke bootstrap loader
boot_success: mov dl, drive
db 0eah ; far jump to LOADSEG:0000
dw 0
dw LOADSEG
; readDisk: Reads a number of sectors into memory.
;
; Call with: DX:AX = 32-bit DOS sector number
; DI = number of sectors to read
; ES:BX = destination buffer
; ES must be 64k aligned (1000h, 2000h etc).
;
; Returns: CF set on error
; ES:BX points one byte after the last byte read.
readDisk:
push si
read_next: push dx
push ax
;
; translate sector number to BIOS parameters
;
;
; abs = sector offset in track
; + head * sectPerTrack offset in cylinder
; + track * sectPerTrack * nHeads offset in platter
;
; t1 = abs / sectPerTrack (ax has t1)
; sector = abs mod sectPerTrack (cx has sector)
;
div word sectPerTrack
mov cx, dx
;
; t1 = head + track * nHeads
;
; track = t1 / nHeads (ax has track)
; head = t1 mod nHeads (dl has head)
;
xor dx, dx
div word nHeads
; the following manipulations are necessary in order to
; properly place parameters into registers.
; ch = cylinder number low 8 bits
; cl = 7-6: cylinder high two bits
; 5-0: sector
mov dh, dl ; save head into dh for bios
ror ah, 1 ; move track high bits into
ror ah, 1 ; bits 7-6 (assumes top = 0)
xchg al, ah ; swap for later
mov dl, byte sectPerTrack
sub dl, cl
inc cl ; sector offset from 1
or cx, ax ; merge cylinder into sector
mov al, dl ; al has # of sectors left
; Calculate how many sectors can be transfered in this read
; due to dma boundary conditions.
push dx
mov si, di ; temp register save
; this computes remaining bytes because of modulo 65536
; nature of dma boundary condition
mov ax, bx ; get offset pointer
neg ax ; and convert to bytes
jz ax_min_1 ; started at seg:0, skip ahead
xor dx, dx ; convert to sectors
div word bytesPerSector
cmp ax, di ; check remainder vs. asked
jb ax_min_1 ; less, skip ahead
mov si, ax ; transfer only what we can
ax_min_1: pop dx
; Check that request sectors do not exceed track boundary
mov si, sectPerTrack
inc si
mov ax, cx ; get the sector/cyl byte
and ax, 03fh ; and mask out sector
sub si, ax ; si has how many we can read
mov ax, di
cmp si, di ; see if asked <= available
jge ax_min_2
mov ax, si ; get what can be xfered
ax_min_2: mov si, RETRYCOUNT
mov ah, 2
mov dl, drive
retry: push ax
int 13h
pop ax
jnc read_ok
push ax
xor ax, ax ; reset the drive
int 13h
pop ax
dec si
jnz retry
stc
pop ax
pop dx
pop si
ret
read_next_jmp: jmp short read_next
read_ok: xor ah, ah
mov si, ax ; AX = SI = number of sectors read
mul word bytesPerSector ; AX = number of bytes read
add bx, ax ; add number of bytes read to BX
jnc no_incr_es ; if overflow...
mov ax, es
add ah, 10h ; ...add 1000h to ES
mov es, ax
no_incr_es: pop ax
pop dx ; DX:AX = last sector number
add ax, si
adc dx, 0 ; DX:AX = next sector to read
sub di, si ; if there is anything left to read,
jg read_next_jmp ; continue
clc
pop si
ret
errmsg db "Boot error"
ERRMSGLEN equ $ - errmsg
;filename db "OSLDR BIN"
filename db "KERNEL BIN"
TIMES 510-($-$$) DB 0
sign dw 0aa55h

Binary file not shown.

View file

@ -0,0 +1,196 @@
; To save space, functions that are just called once are
; implemented as macros instead. Four bytes are saved by
; avoiding the call / ret instructions.
; FINDFILE: Searches for the file in the root directory.
;
; Returns:
;
; If file not found: CF set
;
; If file found: CF clear
; AX = first cluster of file
%macro FINDFILE 0
; First, read the whole root directory
; into the temporary buffer.
mov ax, word root_dir_start
mov dx, word root_dir_start_hi
mov di, nRootDir
xor bx, bx
mov es, tempbuf
call readDisk
jc ffDone
xor di, di
next_entry: mov cx, 11
mov si, filename+7c00h
push di
repe cmpsb
pop di
mov ax, [es:di+1ah] ; get cluster number from directory entry
clc
je ffDone
add di, 20h ; go to next directory entry
cmp byte [es:di], 0 ; if the first byte of the name is 0,
jnz next_entry ; there is no more files in the directory
stc
ffDone:
%endmacro
; GETDRIVEPARMS: Calculate start of some disk areas.
%macro GETDRIVEPARMS 0
mov si, word nHidden
mov di, word nHidden_hi
add si, word resSectors
adc di, 0 ; DI:SI = first FAT sector
mov word fat_start, si
mov word fat_start_hi, di
mov al, nFats
xor ah, ah
mul word sectPerFat ; DX:AX = total number of FAT sectors
add si, ax
adc di, dx ; DI:SI = first root directory sector
mov word root_dir_start, si
mov word root_dir_start_hi, di
; Calculate how many sectors the root directory occupies.
mov bx, bytesPerSector
mov cl, 5 ; divide BX by 32
shr bx, cl ; BX = directory entries per sector
mov ax, nRootDir
xor dx, dx
div bx
mov nRootDir, ax ; AX = sectors per root directory
add si, ax
adc di, 0 ; DI:SI = first data sector
mov data_start, si
mov data_start_hi, di
%endmacro
; GETFATCHAIN:
;
; Reads the FAT chain and stores it in a temporary buffer in the first
; 64 kb. The FAT chain is stored an array of 16-bit cluster numbers,
; ending with 0.
;
; The file must fit in conventional memory, so it can't be larger than
; 640 kb. The sector size must be at least 512 bytes, so the FAT chain
; can't be larger than around 3 kb.
;
; Call with: AX = first cluster in chain
;
; Returns: CF clear on success, set on error
%macro GETFATCHAIN 0
push ax ; store first cluster number
; Load the complete FAT into memory. The FAT can't be larger
; than 128 kb, so it should fit in the temporary buffer.
mov es, tempbuf
xor bx, bx
mov di, sectPerFat
mov ax, word fat_start
mov dx, word fat_start_hi
call readDisk
pop ax ; restore first cluster number
jc boot_error
; Set ES:DI to the temporary storage for the FAT chain.
push ds
push es
pop ds
pop es
mov di, FATBUF
next_clust: stosw ; store cluster number
mov si, ax ; SI = cluster number
cmp byte extBoot, 29h
jne fat_12
cmp byte [bp+filesys+4], '6' ; check for FAT-16 system
je fat_16
; This is a FAT-12 disk.
fat_12: add si, si ; multiply cluster number by 3...
add si, ax
shr si, 1 ; ...and divide by 2
lodsw
; If the cluster number was even, the cluster value is now in
; bits 0-11 of AX. If the cluster number was odd, the cluster
; value is in bits 4-15, and must be shifted right 4 bits. If
; the number was odd, CF was set in the last shift instruction.
jnc fat_even
mov cl, 4
shr ax, cl ; shift the cluster number
fat_even: and ah, 0fh ; mask off the highest 4 bits
cmp ax, 0fffh ; check for EOF
jmp short next_test
; This is a FAT-16 disk. The maximal size of a 16-bit FAT
; is 128 kb, so it may not fit within a single 64 kb segment.
fat_16: mov dx, tempbuf
add si, si ; multiply cluster number by two
jnc first_half ; if overflow...
add dh, 10h ; ...add 64 kb to segment value
first_half: mov ds, dx ; DS:SI = pointer to next cluster
lodsw ; AX = next cluster
cmp ax, 0fff8h ; >= FFF8 = 16-bit EOF
next_test: jb next_clust ; continue if not EOF
finished: ; Mark end of FAT chain with 0, so we have a single
; EOF marker for both FAT-12 and FAT-16 systems.
xor ax, ax
stosw
fatError:
%endmacro
; loadFile: Loads the file into memory, one cluster at a time.
%macro LOADFILE 0
mov es, tempbuf ; set ES:BX to load address
xor bx, bx
mov si, FATBUF ; set DS:SI to the FAT chain
push cs
pop ds
next_cluster: lodsw ; AX = next cluster to read
or ax, ax ; if EOF...
je boot_success ; ...boot was successful
dec ax ; cluster numbers start with 2
dec ax
mov di, word sectPerCluster
and di, 0ffh ; DI = sectors per cluster
mul di
add ax, data_start
adc dx, data_start_hi ; DX:AX = first sector to read
call readDisk
jnc next_cluster
%endmacro

View file

@ -0,0 +1,640 @@
1 ;
2 ; File:
3 ; boot.asm
4 ; Description:
5 ; DOS-C boot
6 ;
7 ; Copyright (c) 1997;
8 ; Svante Frey
9 ; All Rights Reserved
10 ;
11 ; This file is part of DOS-C.
12 ;
13 ; DOS-C is free software; you can redistribute it and/or
14 ; modify it under the terms of the GNU General Public License
15 ; as published by the Free Software Foundation; either version
16 ; 2, or (at your option) any later version.
17 ;
18 ; DOS-C is distributed in the hope that it will be useful, but
19 ; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
21 ; the GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public
24 ; License along with DOS-C; see the file COPYING. If not,
25 ; write to the Free Software Foundation, 675 Mass Ave,
26 ; Cambridge, MA 02139, USA.
27 ;
28 ; $Logfile: C:/dos-c/src/boot/boot.asv $
29 ;
30 ; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.lst,v 1.1 1996/01/23 01:02:19 rosmgr Exp $
31 ;
32 ; $Log: boot.lst,v $
32 ; Revision 1.1 1996/01/23 01:02:19 rosmgr
32 ; Initial revision
32 ;
33 ;
34 ; Rev 1.5 10 Jan 1997 4:58:06 patv
35 ; Corrected copyright
36 ;
37 ; Rev 1.4 10 Jan 1997 4:52:50 patv
38 ; Re-written to support C drive and eliminate restrictions on IPL.SYS
39 ;
40 ; Rev 1.3 29 Aug 1996 13:06:50 patv
41 ; Bug fixes for v0.91b
42 ;
43 ; Rev 1.2 01 Sep 1995 17:56:44 patv
44 ; First GPL release.
45 ;
46 ; Rev 1.1 30 Jul 1995 20:37:38 patv
47 ; Initialized stack before use.
48 ;
49 ; Rev 1.0 02 Jul 1995 10:57:52 patv
50 ; Initial revision.
51 ;
52
53 section .text
54
55 org 0
56 00000000 E93D00 Entry: jmp real_start
57
58 ; bp is initialized to 7c00h
59 %define oem [bp+3]
60 %define bytesPerSector [bp+0bh]
61 %define sectPerCluster [bp+0dh]
62 %define resSectors [bp+0eh]
63 %define nFats [bp+10h]
64 %define nRootDir [bp+11h]
65 %define nSectors [bp+13h]
66 %define MID [bp+15h]
67 %define sectPerFat [bp+16h]
68 %define sectPerTrack [bp+18h]
69 %define nHeads [bp+1ah]
70 %define nHidden [bp+1ch]
71 %define nHidden_hi [bp+1eh]
72 %define nSectorHuge [bp+20h]
73 %define drive [bp+24h]
74 %define extBoot [bp+26h]
75 %define volid [bp+27h]
76 %define vollabel [bp+2bh]
77 %define filesys 36h
78
79 LOADSEG equ 2000h
80
81 FATBUF equ 4000h ; offset of temporary buffer for FAT
82 ; chain
83 RETRYCOUNT equ 5 ; number of retries on disk errors
84
85 ; Some extra variables that are created on the stack frame
86
87 %define fat_start [bp-4] ; first FAT sector
88 %define fat_start_hi [bp-2]
89 %define root_dir_start [bp-8] ; first root directory sector
90 %define root_dir_start_hi [bp-6]
91 %define data_start [bp-12] ; first data sector
92 %define data_start_hi [bp-10]
93
94 ;
95 ; Include macros for filesystem access
96 ;
97 %include "boot.inc"
98 <1> ; To save space, functions that are just called once are
99 <1> ; implemented as macros instead. Four bytes are saved by
100 <1> ; avoiding the call / ret instructions.
101 <1>
102 <1>
103 <1> ; FINDFILE: Searches for the file in the root directory.
104 <1> ;
105 <1> ; Returns:
106 <1> ;
107 <1> ; If file not found: CF set
108 <1> ;
109 <1> ; If file found: CF clear
110 <1> ; AX = first cluster of file
111 <1>
112 <1>
113 <1> %macro FINDFILE 0
114 <1> ; First, read the whole root directory
115 <1> ; into the temporary buffer.
116 <1>
117 <1> mov ax, word root_dir_start
118 <1> mov dx, word root_dir_start_hi
119 <1> mov di, nRootDir
120 <1> xor bx, bx
121 <1> mov es, tempbuf
122 <1> call readDisk
123 <1> jc ffDone
124 <1>
125 <1> xor di, di
126 <1>
127 <1> next_entry: mov cx, 11
128 <1> mov si, filename+7c00h
129 <1> push di
130 <1> repe cmpsb
131 <1> pop di
132 <1> mov ax, [es:di+1ah] ; get cluster number from directory entry
133 <1> clc
134 <1> je ffDone
135 <1>
136 <1> add di, 20h ; go to next directory entry
137 <1> cmp byte [es:di], 0 ; if the first byte of the name is 0,
138 <1> jnz next_entry ; there is no more files in the directory
139 <1>
140 <1> stc
141 <1> ffDone:
142 <1> %endmacro
143 <1>
144 <1> ; GETDRIVEPARMS: Calculate start of some disk areas.
145 <1>
146 <1> %macro GETDRIVEPARMS 0
147 <1> mov si, word nHidden
148 <1> mov di, word nHidden_hi
149 <1> add si, word resSectors
150 <1> adc di, 0 ; DI:SI = first FAT sector
151 <1>
152 <1> mov word fat_start, si
153 <1> mov word fat_start_hi, di
154 <1>
155 <1> mov al, nFats
156 <1> xor ah, ah
157 <1> mul word sectPerFat ; DX:AX = total number of FAT sectors
158 <1>
159 <1> add si, ax
160 <1> adc di, dx ; DI:SI = first root directory sector
161 <1> mov word root_dir_start, si
162 <1> mov word root_dir_start_hi, di
163 <1>
164 <1> ; Calculate how many sectors the root directory occupies.
165 <1> mov bx, bytesPerSector
166 <1> mov cl, 5 ; divide BX by 32
167 <1> shr bx, cl ; BX = directory entries per sector
168 <1>
169 <1> mov ax, nRootDir
170 <1> xor dx, dx
171 <1> div bx
172 <1>
173 <1> mov nRootDir, ax ; AX = sectors per root directory
174 <1>
175 <1> add si, ax
176 <1> adc di, 0 ; DI:SI = first data sector
177 <1>
178 <1> mov data_start, si
179 <1> mov data_start_hi, di
180 <1> %endmacro
181 <1>
182 <1> ; GETFATCHAIN:
183 <1> ;
184 <1> ; Reads the FAT chain and stores it in a temporary buffer in the first
185 <1> ; 64 kb. The FAT chain is stored an array of 16-bit cluster numbers,
186 <1> ; ending with 0.
187 <1> ;
188 <1> ; The file must fit in conventional memory, so it can't be larger than
189 <1> ; 640 kb. The sector size must be at least 512 bytes, so the FAT chain
190 <1> ; can't be larger than around 3 kb.
191 <1> ;
192 <1> ; Call with: AX = first cluster in chain
193 <1> ;
194 <1> ; Returns: CF clear on success, set on error
195 <1>
196 <1> %macro GETFATCHAIN 0
197 <1> push ax ; store first cluster number
198 <1>
199 <1> ; Load the complete FAT into memory. The FAT can't be larger
200 <1> ; than 128 kb, so it should fit in the temporary buffer.
201 <1>
202 <1> mov es, tempbuf
203 <1> xor bx, bx
204 <1> mov di, sectPerFat
205 <1> mov ax, word fat_start
206 <1> mov dx, word fat_start_hi
207 <1> call readDisk
208 <1> pop ax ; restore first cluster number
209 <1> jc boot_error
210 <1>
211 <1> ; Set ES:DI to the temporary storage for the FAT chain.
212 <1> push ds
213 <1> push es
214 <1> pop ds
215 <1> pop es
216 <1> mov di, FATBUF
217 <1>
218 <1> next_clust: stosw ; store cluster number
219 <1> mov si, ax ; SI = cluster number
220 <1> cmp byte extBoot, 29h
221 <1> jne fat_12
222 <1> cmp byte [bp+filesys+4], '6' ; check for FAT-16 system
223 <1> je fat_16
224 <1>
225 <1> ; This is a FAT-12 disk.
226 <1>
227 <1> fat_12: add si, si ; multiply cluster number by 3...
228 <1> add si, ax
229 <1> shr si, 1 ; ...and divide by 2
230 <1> lodsw
231 <1>
232 <1> ; If the cluster number was even, the cluster value is now in
233 <1> ; bits 0-11 of AX. If the cluster number was odd, the cluster
234 <1> ; value is in bits 4-15, and must be shifted right 4 bits. If
235 <1> ; the number was odd, CF was set in the last shift instruction.
236 <1>
237 <1> jnc fat_even
238 <1> mov cl, 4
239 <1> shr ax, cl ; shift the cluster number
240 <1>
241 <1> fat_even: and ah, 0fh ; mask off the highest 4 bits
242 <1> cmp ax, 0fffh ; check for EOF
243 <1> jmp short next_test
244 <1>
245 <1> ; This is a FAT-16 disk. The maximal size of a 16-bit FAT
246 <1> ; is 128 kb, so it may not fit within a single 64 kb segment.
247 <1>
248 <1> fat_16: mov dx, tempbuf
249 <1> add si, si ; multiply cluster number by two
250 <1> jnc first_half ; if overflow...
251 <1> add dh, 10h ; ...add 64 kb to segment value
252 <1>
253 <1> first_half: mov ds, dx ; DS:SI = pointer to next cluster
254 <1> lodsw ; AX = next cluster
255 <1>
256 <1> cmp ax, 0fff8h ; >= FFF8 = 16-bit EOF
257 <1> next_test: jb next_clust ; continue if not EOF
258 <1>
259 <1> finished: ; Mark end of FAT chain with 0, so we have a single
260 <1> ; EOF marker for both FAT-12 and FAT-16 systems.
261 <1>
262 <1> xor ax, ax
263 <1> stosw
264 <1> fatError:
265 <1> %endmacro
266 <1>
267 <1>
268 <1> ; loadFile: Loads the file into memory, one cluster at a time.
269 <1>
270 <1> %macro LOADFILE 0
271 <1> mov es, tempbuf ; set ES:BX to load address
272 <1> xor bx, bx
273 <1>
274 <1> mov si, FATBUF ; set DS:SI to the FAT chain
275 <1> push cs
276 <1> pop ds
277 <1>
278 <1> next_cluster: lodsw ; AX = next cluster to read
279 <1> or ax, ax ; if EOF...
280 <1> je boot_success ; ...boot was successful
281 <1>
282 <1> dec ax ; cluster numbers start with 2
283 <1> dec ax
284 <1>
285 <1> mov di, word sectPerCluster
286 <1> and di, 0ffh ; DI = sectors per cluster
287 <1> mul di
288 <1> add ax, data_start
289 <1> adc dx, data_start_hi ; DX:AX = first sector to read
290 <1> call readDisk
291 <1> jnc next_cluster
292 <1>
293 <1> %endmacro
294
295 ;
296 ;
297 ;
298 00000003 00<rept> TIMES 3eh-($-$$) DB 0
299
300 %define tempbuf [bp+3eh]
301 0000003E 0020 load_seg dw LOADSEG
302
303 00000040 FA real_start: cli
304 00000041 FC cld
305 00000042 8CC8 mov ax, cs
306 00000044 8ED0 mov ss, ax ; initialize stack
307 00000046 BD007C mov bp, 7c00h
308 00000049 8D66E0 lea sp, [bp-20h]
309 0000004C FB sti
310
311 0000004D 8EC0 mov es, ax
312 0000004F 8ED8 mov ds, ax
313 00000051 885624 mov drive, dl ; BIOS passes drive number in DL
314
315 GETDRIVEPARMS
316 00000054 8B761C <1> mov si, word nHidden
317 00000057 8B7E1E <1> mov di, word nHidden_hi
318 0000005A 03760E <1> add si, word resSectors
319 0000005D 81D70000 <1> adc di, 0
320 <1>
321 00000061 8976FC <1> mov word fat_start, si
322 00000064 897EFE <1> mov word fat_start_hi, di
323 <1>
324 00000067 8A4610 <1> mov al, nFats
325 0000006A 30E4 <1> xor ah, ah
326 0000006C F76616 <1> mul word sectPerFat
327 <1>
328 0000006F 01C6 <1> add si, ax
329 00000071 11D7 <1> adc di, dx
330 00000073 8976F8 <1> mov word root_dir_start, si
331 00000076 897EFA <1> mov word root_dir_start_hi, di
332 <1>
333 <1>
334 00000079 8B5E0B <1> mov bx, bytesPerSector
335 0000007C B105 <1> mov cl, 5
336 0000007E D3EB <1> shr bx, cl
337 <1>
338 00000080 8B4611 <1> mov ax, nRootDir
339 00000083 31D2 <1> xor dx, dx
340 00000085 F7F3 <1> div bx
341 <1>
342 00000087 894611 <1> mov nRootDir, ax
343 <1>
344 0000008A 01C6 <1> add si, ax
345 0000008C 81D70000 <1> adc di, 0
346 <1>
347 00000090 8976F4 <1> mov data_start, si
348 00000093 897EF6 <1> mov data_start_hi, di
349
350 FINDFILE ; locate file in root directory
351 <1>
352 <1>
353 <1>
354 00000096 8B46F8 <1> mov ax, word root_dir_start
355 00000099 8B56FA <1> mov dx, word root_dir_start_hi
356 0000009C 8B7E11 <1> mov di, nRootDir
357 0000009F 31DB <1> xor bx, bx
358 000000A1 8E463E <1> mov es, tempbuf
359 000000A4 E8B900 <1> call readDisk
360 000000A7 721E <1> jc ffDone
361 <1>
362 000000A9 31FF <1> xor di, di
363 <1>
364 000000AB B90B00 <1> next_entry: mov cx, 11
365 000000AE BE[F17D] <1> mov si, filename+7c00h
366 000000B1 57 <1> push di
367 000000B2 F3A6 <1> repe cmpsb
368 000000B4 5F <1> pop di
369 000000B5 268B451A <1> mov ax, [es:di+1ah]
370 000000B9 F8 <1> clc
371 000000BA 740B <1> je ffDone
372 <1>
373 000000BC 81C72000 <1> add di, 20h
374 000000C0 26803D00 <1> cmp byte [es:di], 0
375 000000C4 75E5 <1> jnz next_entry
376 <1>
377 000000C6 F9 <1> stc
378 <1> ffDone:
379 000000C7 727A jc boot_error ; fail if not found
380
381 GETFATCHAIN ; read FAT chain
382 000000C9 50 <1> push ax
383 <1>
384 <1>
385 <1>
386 <1>
387 000000CA 8E463E <1> mov es, tempbuf
388 000000CD 31DB <1> xor bx, bx
389 000000CF 8B7E16 <1> mov di, sectPerFat
390 000000D2 8B46FC <1> mov ax, word fat_start
391 000000D5 8B56FE <1> mov dx, word fat_start_hi
392 000000D8 E88500 <1> call readDisk
393 000000DB 58 <1> pop ax
394 000000DC 7265 <1> jc boot_error
395 <1>
396 <1>
397 000000DE 1E <1> push ds
398 000000DF 06 <1> push es
399 000000E0 1F <1> pop ds
400 000000E1 07 <1> pop es
401 000000E2 BF0040 <1> mov di, FATBUF
402 <1>
403 000000E5 AB <1> next_clust: stosw
404 000000E6 89C6 <1> mov si, ax
405 000000E8 807E2629 <1> cmp byte extBoot, 29h
406 000000EC 7506 <1> jne fat_12
407 000000EE 807E3A36 <1> cmp byte [bp+filesys+4], '6'
408 000000F2 7415 <1> je fat_16
409 <1>
410 <1>
411 <1>
412 000000F4 01F6 <1> fat_12: add si, si
413 000000F6 01C6 <1> add si, ax
414 000000F8 D1EE <1> shr si, 1
415 000000FA AD <1> lodsw
416 <1>
417 <1>
418 <1>
419 <1>
420 <1>
421 <1>
422 000000FB 7304 <1> jnc fat_even
423 000000FD B104 <1> mov cl, 4
424 000000FF D3E8 <1> shr ax, cl
425 <1>
426 00000101 80E40F <1> fat_even: and ah, 0fh
427 00000104 3DFF0F <1> cmp ax, 0fffh
428 00000107 EB10 <1> jmp short next_test
429 <1>
430 <1>
431 <1>
432 <1>
433 00000109 8B563E <1> fat_16: mov dx, tempbuf
434 0000010C 01F6 <1> add si, si
435 0000010E 7303 <1> jnc first_half
436 00000110 80C610 <1> add dh, 10h
437 <1>
438 00000113 8EDA <1> first_half: mov ds, dx
439 00000115 AD <1> lodsw
440 <1>
441 00000116 3DF8FF <1> cmp ax, 0fff8h
442 00000119 72CA <1> next_test: jb next_clust
443 <1>
444 <1> finished:
445 <1>
446 <1>
447 0000011B 31C0 <1> xor ax, ax
448 0000011D AB <1> stosw
449 <1> fatError:
450 LOADFILE ; load file (jumps to boot_sucess if successful)
451 0000011E 8E463E <1> mov es, tempbuf
452 00000121 31DB <1> xor bx, bx
453 <1>
454 00000123 BE0040 <1> mov si, FATBUF
455 00000126 0E <1> push cs
456 00000127 1F <1> pop ds
457 <1>
458 00000128 AD <1> next_cluster: lodsw
459 00000129 09C0 <1> or ax, ax
460 0000012B 742B <1> je boot_success
461 <1>
462 0000012D 48 <1> dec ax
463 0000012E 48 <1> dec ax
464 <1>
465 0000012F 8B7E0D <1> mov di, word sectPerCluster
466 00000132 81E7FF00 <1> and di, 0ffh
467 00000136 F7E7 <1> mul di
468 00000138 0346F4 <1> add ax, data_start
469 0000013B 1356F6 <1> adc dx, data_start_hi
470 0000013E E81F00 <1> call readDisk
471 00000141 73E5 <1> jnc next_cluster
472 <1>
473
474 00000143 B90A00 boot_error: mov cx, ERRMSGLEN
475 00000146 BE[E77D] mov si, errmsg+7c00h
476
477 00000149 AC next_char: lodsb ; print error message
478 0000014A B40E mov ah, 0eh
479 0000014C 30FF xor bh, bh
480 0000014E CD10 int 10h
481 00000150 E2F7 loop next_char
482
483 00000152 30E4 xor ah, ah
484 00000154 CD16 int 16h ; wait for keystroke
485 00000156 CD19 int 19h ; invoke bootstrap loader
486
487 00000158 8A5624 boot_success: mov dl, drive
488
489 0000015B EA db 0eah ; far jump to LOADSEG:0000
490 0000015C 0000 dw 0
491 0000015E 0020 dw LOADSEG
492
493
494 ; readDisk: Reads a number of sectors into memory.
495 ;
496 ; Call with: DX:AX = 32-bit DOS sector number
497 ; DI = number of sectors to read
498 ; ES:BX = destination buffer
499 ; ES must be 64k aligned (1000h, 2000h etc).
500 ;
501 ; Returns: CF set on error
502 ; ES:BX points one byte after the last byte read.
503
504 readDisk:
505 00000160 56 push si
506 00000161 52 read_next: push dx
507 00000162 50 push ax
508
509 ;
510 ; translate sector number to BIOS parameters
511 ;
512
513 ;
514 ; abs = sector offset in track
515 ; + head * sectPerTrack offset in cylinder
516 ; + track * sectPerTrack * nHeads offset in platter
517 ;
518 ; t1 = abs / sectPerTrack (ax has t1)
519 ; sector = abs mod sectPerTrack (cx has sector)
520 ;
521 00000163 F77618 div word sectPerTrack
522 00000166 89D1 mov cx, dx
523
524 ;
525 ; t1 = head + track * nHeads
526 ;
527 ; track = t1 / nHeads (ax has track)
528 ; head = t1 mod nHeads (dl has head)
529 ;
530 00000168 31D2 xor dx, dx
531 0000016A F7761A div word nHeads
532
533 ; the following manipulations are necessary in order to
534 ; properly place parameters into registers.
535 ; ch = cylinder number low 8 bits
536 ; cl = 7-6: cylinder high two bits
537 ; 5-0: sector
538 0000016D 88D6 mov dh, dl ; save head into dh for bios
539 0000016F D0CC ror ah, 1 ; move track high bits into
540 00000171 D0CC ror ah, 1 ; bits 7-6 (assumes top = 0)
541 00000173 86C4 xchg al, ah ; swap for later
542 00000175 8A5618 mov dl, byte sectPerTrack
543 00000178 28CA sub dl, cl
544 0000017A FEC1 inc cl ; sector offset from 1
545 0000017C 09C1 or cx, ax ; merge cylinder into sector
546 0000017E 88D0 mov al, dl ; al has # of sectors left
547
548 ; Calculate how many sectors can be transfered in this read
549 ; due to dma boundary conditions.
550 00000180 52 push dx
551
552 00000181 89FE mov si, di ; temp register save
553 ; this computes remaining bytes because of modulo 65536
554 ; nature of dma boundary condition
555 00000183 89D8 mov ax, bx ; get offset pointer
556 00000185 F7D8 neg ax ; and convert to bytes
557 00000187 740B jz ax_min_1 ; started at seg:0, skip ahead
558
559 00000189 31D2 xor dx, dx ; convert to sectors
560 0000018B F7760B div word bytesPerSector
561
562 0000018E 39F8 cmp ax, di ; check remainder vs. asked
563 00000190 7202 jb ax_min_1 ; less, skip ahead
564 00000192 89C6 mov si, ax ; transfer only what we can
565
566 00000194 5A ax_min_1: pop dx
567
568 ; Check that request sectors do not exceed track boundary
569 00000195 8B7618 mov si, sectPerTrack
570 00000198 46 inc si
571 00000199 89C8 mov ax, cx ; get the sector/cyl byte
572 0000019B 253F00 and ax, 03fh ; and mask out sector
573 0000019E 29C6 sub si, ax ; si has how many we can read
574 000001A0 89F8 mov ax, di
575 000001A2 39FE cmp si, di ; see if asked <= available
576 000001A4 7D02 jge ax_min_2
577 000001A6 89F0 mov ax, si ; get what can be xfered
578
579 000001A8 BE0500 ax_min_2: mov si, RETRYCOUNT
580 000001AB B402 mov ah, 2
581 000001AD 8A5624 mov dl, drive
582
583 000001B0 50 retry: push ax
584 000001B1 CD13 int 13h
585 000001B3 58 pop ax
586 000001B4 7310 jnc read_ok
587 000001B6 50 push ax
588 000001B7 31C0 xor ax, ax ; reset the drive
589 000001B9 CD13 int 13h
590 000001BB 58 pop ax
591 000001BC 4E dec si
592 000001BD 75F1 jnz retry
593 000001BF F9 stc
594 000001C0 58 pop ax
595 000001C1 5A pop dx
596 000001C2 5E pop si
597 000001C3 C3 ret
598
599 000001C4 EB9B read_next_jmp: jmp short read_next
600 000001C6 30E4 read_ok: xor ah, ah
601 000001C8 89C6 mov si, ax ; AX = SI = number of sectors read
602 000001CA F7660B mul word bytesPerSector ; AX = number of bytes read
603 000001CD 01C3 add bx, ax ; add number of bytes read to BX
604 000001CF 7307 jnc no_incr_es ; if overflow...
605
606 000001D1 8CC0 mov ax, es
607 000001D3 80C410 add ah, 10h ; ...add 1000h to ES
608 000001D6 8EC0 mov es, ax
609
610 000001D8 58 no_incr_es: pop ax
611 000001D9 5A pop dx ; DX:AX = last sector number
612
613 000001DA 01F0 add ax, si
614 000001DC 81D20000 adc dx, 0 ; DX:AX = next sector to read
615 000001E0 29F7 sub di, si ; if there is anything left to read,
616 000001E2 7FE0 jg read_next_jmp ; continue
617
618 000001E4 F8 clc
619 000001E5 5E pop si
620 000001E6 C3 ret
621
622 000001E7 426F6F74206572726F- errmsg db "Boot error"
623 000001F0 72
624 ERRMSGLEN equ $ - errmsg
625
626
627 ;filename db "OSLDR BIN"
628 000001F1 4B45524E454C202042- filename db "KERNEL BIN"
629 000001FA 494E
630
631 000001FC 00<rept> TIMES 510-($-$$) DB 0
632 000001FE 55AA sign dw 0aa55h
633
634
635
636
637

View file

@ -0,0 +1,56 @@
#
# makefile for DOS-C boot
#
# $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.mak,v 1.1 1996/01/23 01:02:19 rosmgr Exp $
#
# $Log: boot.mak,v $
# Revision 1.1 1996/01/23 01:02:19 rosmgr
# Initial revision
#
#
# Rev 1.3 10 Jan 1997 4:51:54 patv
#Changed to use FreeDOS exe2bin and support new boot code
#
# Rev 1.2 17 Dec 1996 12:52:32 patv
#Converted to FreeDOS exe2bin.
#.
#d
#
# Rev 1.1 29 Aug 1996 13:06:50 patv
#Bug fixes for v0.91b
#
# Rev 1.0 02 Jul 1995 9:11:26 patv
#Initial revision.
#
#
# Uncomment the following for a debug version
#
#AFLAGS = /zi /DDEBUG
#LFLAGS = /v
PRODUCT = boot.bin
all: $(PRODUCT)
production: all
copy boot.bin ..\..\dist\boot.bin
del *.bin
del *.map
boot.bin: boot.asm
tasm $(AFLAGS) boot,,
tlink $(LFLAGS) boot
..\utils\exe2bin boot boot.bin
del boot.obj
del boot.exe
clean:
del *.lst
del *.map
del *.bin
del *.bak
del *.las
del *.obj
del *.exe


View file

@ -0,0 +1,8 @@
Start Stop Length Name Class
00000H 001FFH 00200H TEXT TEXT
Program entry point at 0000:0000
Warning: No stack

Some files were not shown because too many files have changed in this diff Show more