Compare commits

...

3 Commits

Author SHA1 Message Date
The ReactOS Team
8ccc625ffb This commit was manufactured by cvs2svn to create tag 'krnl0008'.
svn path=/tags/krnl0008/; revision=12
1998-08-25 04:27:41 +00:00
Rex Jolliff
94c8483b04 A much Needed Update
svn path=/branches/ros/; revision=10
1998-08-25 04:27:41 +00:00
The ReactOS Team
fc7e59ce74 This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=9
1998-08-25 04:27:41 +00:00
66 changed files with 18376 additions and 16203 deletions

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -1,521 +1,399 @@
/* GENERAL DEFINITIONS ****************************************************/ /* GENERAL DEFINITIONS ****************************************************/
#include <internal/hal/irq.h> #include <internal/hal/irq.h>
#include <ddk/kedef.h>
#include <ddk/iodef.h>
/*
* PURPOSE: Number of a thread priority levels /*
*/ * PURPOSE: Number of a thread priority levels
#define NR_PRIORITY_LEVELS (32) */
#define NR_PRIORITY_LEVELS (32)
/*
* PURPOSE: Type of queue to insert a work item in /*
*/ * PURPOSE: Type of queue to insert a work item in
enum */
{ enum
CriticalWorkQueue, {
DelayedWorkQueue, CriticalWorkQueue,
HyperCriticalWorkQueue, DelayedWorkQueue,
}; HyperCriticalWorkQueue,
};
/*
* Types of memory to allocate /*
*/ * Types of memory to allocate
enum */
{ enum
NonPagedPool, {
NonPagedPoolMustSucceed, NonPagedPool,
NonPagedPoolCacheAligned, NonPagedPoolMustSucceed,
NonPagedPoolCacheAlignedMustS, NonPagedPoolCacheAligned,
PagedPool, NonPagedPoolCacheAlignedMustS,
PagedPoolCacheAligned, PagedPool,
}; PagedPoolCacheAligned,
};
/*
* PURPOSE: Irp flags /*
*/ * Possible status codes
enum * FIXME: These may not be the actual values used by NT
{ */
/* enum
* Read any data from the actual backing media {
*/ STATUS_SUCCESS,
IRP_NOCACHE, STATUS_INSUFFICIENT_RESOURCES,
STATUS_OBJECT_NAME_EXISTS,
/* STATUS_OBJECT_NAME_COLLISION,
* The I/O operation is performing paging // STATUS_DATATYPE_MISALIGNMENT,
*/ STATUS_CTL_FILE_NOT_SUPPORTED,
IRP_PAGING_IO, // STATUS_ACCESS_VIOLATION,
STATUS_PORT_ALREADY_SET,
/* STATUS_SECTION_NOT_IMAGE,
* The IRP is for a mount operation STATUS_BAD_WORKING_SET_LIMIT,
*/ STATUS_INCOMPATIBLE_FILE_MAP,
IRP_MOUNT_COMPLETION, STATUS_HANDLE_NOT_WAITABLE,
STATUS_PORT_DISCONNECTED,
/* STATUS_NOT_LOCKED,
* The API expects synchronous behaviour STATUS_NOT_MAPPED_VIEW,
*/ STATUS_UNABLE_TO_FREE_VM,
IRP_SYNCHRONOUS_API, STATUS_UNABLE_TO_DELETE_SECTION,
STATUS_MORE_PROCESSING_REQUIRED,
/* STATUS_INVALID_CID,
* The IRP is associated with a larger operation STATUS_BAD_INITIAL_STACK,
*/ STATUS_INVALID_VOLUME_LABEL,
IRP_ASSOCIATED_IRP, STATUS_SECTION_NOT_EXTENDED,
STATUS_NOT_MAPPED_DATA,
/* STATUS_INFO_LENGTH_MISMATCH,
* The AssociatedIrp.SystemBuffer field is valid STATUS_INVALID_INFO_CLASS,
*/ STATUS_SUSPEND_COUNT_EXCEEDED,
IRP_BUFFERED_IO, STATUS_NOTIFY_ENUM_DIR,
STATUS_REGISTRY_RECOVERED,
/* STATUS_REGISTRY_IO_FAILED,
* The system buffer was allocated from pool and should be deallocated STATUS_KEY_DELETED,
* by the I/O manager STATUS_NO_LOG_SPACE,
*/ STATUS_KEY_HAS_CHILDREN,
IRP_DEALLOCATE_BUFFER, STATUS_CHILD_MUST_BE_VOLATILE,
STATUS_REGISTRY_CORRUPT,
/* STATUS_DLL_NOT_FOUND,
* The IRP is for an input operation STATUS_DLL_INIT_FAILED,
*/ STATUS_ORDINAL_NOT_FOUND,
IRP_INPUT_OPERATION, STATUS_ENTRYPOINT_NOT_FOUND,
// STATUS_PENDING,
/* STATUS_MORE_ENTRIES,
* The paging operation should complete synchronously // STATUS_INTEGER_OVERFLOW,
*/ STATUS_BUFFER_OVERFLOW,
IRP_SYNCHRONOUS_PAGING_IO, STATUS_NO_MORE_FILES,
STATUS_NO_INHERITANCE,
/* STATUS_NO_MORE_EAS,
* The IRP represents a filesystem create operation STATUS_NO_MORE_ENTRIES,
*/ STATUS_GUIDS_EXHAUSTED,
IRP_CREATE_OPERATION, STATUS_AGENTS_EXHAUSTED,
STATUS_UNSUCCESSFUL,
/* STATUS_NOT_IMPLEMENTED,
* The IRP represents a filesystem read operation STATUS_ILLEGAL_FUNCTION,
*/ // STATUS_IN_PAGE_ERROR,
IRP_READ_OPERATION, STATUS_PAGEFILE_QUOTA,
STATUS_COMMITMENT_LIMIT,
/* STATUS_SECTION_TOO_BIG,
* The IRP represents a filesystem write operation RPC_NT_SS_IN_NULL_CONTEXT,
*/ RPC_NT_INVALID_BINDING,
IRP_WRITE_OPERATION, // STATUS_INVALID_HANDLE,
STATUS_OBJECT_FILE_MISMATCH,
/* STATUS_FILE_CLOSED,
* The IRP represents a filesystem close operation STATUS_INVALID_PORT_HANDLE,
*/ STATUS_NOT_COMMITTED,
IRP_CLOSE_OPERATION, STATUS_INVALID_PARAMETER,
STATUS_INVALID_PARAMETER_1,
/* STATUS_INVALID_PARAMETER_2,
* Asynchronous behavior is advised but not required STATUS_INVALID_PARAMETER_3,
*/ STATUS_INVALID_PARAMETER_4,
IRP_DEFER_IO_COMPLETION, STATUS_INVALID_PARAMETER_5,
}; STATUS_INVALID_PARAMETER_6,
STATUS_INVALID_PARAMETER_7,
/* STATUS_INVALID_PARAMETER_8,
* I/O operation flags STATUS_INVALID_PARAMETER_9,
*/ STATUS_INVALID_PARAMETER_10,
enum STATUS_INVALID_PARAMETER_11,
{ STATUS_INVALID_PARAMETER_12,
/* STATUS_INVALID_PARAMETER_MAX,
* Force an access check even if opened in kernel mode STATUS_INVALID_PAGE_PROTECTION,
*/ STATUS_RESOURCE_DATA_NOT_FOUND,
SL_FORCE_ACCESS_CHECK, STATUS_RESOURCE_TYPE_NOT_FOUND,
STATUS_RESOURCE_NAME_NOT_FOUND,
/* STATUS_RESOURCE_LANG_NOT_FOUND,
* The file being opened is a paging file STATUS_NO_SUCH_DEVICE,
*/ STATUS_NO_SUCH_FILE,
SL_OPEN_PAGING_FILE, STATUS_INVALID_DEVICE_REQUEST,
STATUS_END_OF_FILE,
SL_OPEN_TARGET_DIRECTORY, STATUS_FILE_FORCED_CLOSED,
STATUS_WRONG_VOLUME,
SL_CASE_SENSITIVE, STATUS_NO_MEDIA,
STATUS_NO_MEDIA_IN_DEVICE,
SL_KEY_SPECIFIED, STATUS_NONEXISTENT_SECTOR,
STATUS_WORKING_SET_QUOTA,
SL_OVERRIDE_VERIFY_VOLUME, // STATUS_NO_MEMORY,
STATUS_CONFLICTING_ADDRESS,
SL_WRITE_THROUGH, STATUS_INVALID_SYSTEM_SERVICE,
STATUS_THREAD_IS_TERMINATING,
SL_FT_SEQUENTIAL_WRITE, STATUS_PROCESS_IS_TERMINATING,
STATUS_INVALID_LOCK_SEQUENCE,
SL_FAIL_IMMEDIATELY, STATUS_INVALID_VIEW_SIZE,
STATUS_ALREADY_COMMITTED,
SL_EXCLUSIVE_LOCK, STATUS_ACCESS_DENIED,
STATUS_FILE_IS_A_DIRECTORY,
SL_RESTART_SCAN, STATUS_CANNOT_DELETE,
STATUS_INVALID_COMPUTER_NAME,
SL_RETURN_SINGLE_ENTRY, STATUS_FILE_DELETED,
STATUS_DELETE_PENDING,
SL_INDEX_SPECIFIED, STATUS_PORT_CONNECTION_REFUSED,
STATUS_NO_SUCH_PRIVILEGE,
SL_WATCH_TREE, STATUS_PRIVILEGE_NOT_HELD,
STATUS_CANNOT_IMPERSONATE,
SL_ALLOW_RAW_MOUNT, STATUS_LOGON_FAILURE,
}; STATUS_ACCOUNT_RESTRICTION,
STATUS_INVALID_LOGON_HOURS,
/* STATUS_INVALID_WORKSTATION,
* Possible flags for the device object flags STATUS_BUFFER_TOO_SMALL,
*/ STATUS_UNABLE_TO_DECOMMIT_VM,
enum STATUS_DISK_CORRUPT_ERROR,
{ STATUS_OBJECT_NAME_INVALID,
DO_BUFFERED_IO = 0x1, STATUS_OBJECT_NAME_NOT_FOUND,
DO_DIRECT_IO = 0x2, // STATUS_OBJECT_NAME_COLLISION,
}; STATUS_OBJECT_PATH_INVALID,
STATUS_OBJECT_PATH_NOT_FOUND,
/* STATUS_DFS_EXIT_PATH_FOUND,
* Possible status codes STATUS_OBJECT_PATH_SYNTAX_BAD,
* FIXME: These may not be the actual values used by NT STATUS_DATA_OVERRUN,
*/ STATUS_DATA_LATE_ERROR,
enum STATUS_DATA_ERROR,
{ STATUS_CRC_ERROR,
STATUS_SUCCESS, STATUS_SHARING_VIOLATION,
STATUS_INSUFFICIENT_RESOURCES, STATUS_QUOTA_EXCEEDED,
STATUS_OBJECT_NAME_EXISTS, STATUS_MUTANT_NOT_OWNED,
STATUS_OBJECT_NAME_COLLISION, STATUS_SEMAPHORE_LIMIT_EXCEEDED,
// STATUS_DATATYPE_MISALIGNMENT, STATUS_DISK_FULL,
STATUS_CTL_FILE_NOT_SUPPORTED, STATUS_LOCK_NOT_GRANTED,
// STATUS_ACCESS_VIOLATION,
STATUS_PORT_ALREADY_SET, STATUS_DEVICE_NOT_READY,
STATUS_SECTION_NOT_IMAGE, STATUS_IO_TIMEOUT,
STATUS_BAD_WORKING_SET_LIMIT, STATUS_MEDIA_WRITE_PROTECTED,
STATUS_INCOMPATIBLE_FILE_MAP, STATUS_NO_MEDIA_IN_DRIVE,
STATUS_HANDLE_NOT_WAITABLE, STATUS_VERIFY_REQUIRED,
STATUS_PORT_DISCONNECTED, STATUS_UNRECOGNIZED_MEDIA,
STATUS_NOT_LOCKED, // STATUS_WRONG_VOLUME,
STATUS_NOT_MAPPED_VIEW, };
STATUS_UNABLE_TO_FREE_VM,
STATUS_UNABLE_TO_DELETE_SECTION, /*
STATUS_MORE_PROCESSING_REQUIRED, * This is a list of bug check types (not MS's)
STATUS_INVALID_CID, */
STATUS_BAD_INITIAL_STACK, enum
STATUS_INVALID_VOLUME_LABEL, {
STATUS_SECTION_NOT_EXTENDED, APC_INDEX_MISMATCH = 1,
STATUS_NOT_MAPPED_DATA, DEVICE_QUEUE_NOT_BUSY,
STATUS_INFO_LENGTH_MISMATCH, INVALID_AFFINITY_SET,
STATUS_INVALID_INFO_CLASS, INVALID_DATA_ACCESS_TRAP,
STATUS_SUSPEND_COUNT_EXCEEDED, INVALID_PROCESS_ATTACH_ATTEMPT,
STATUS_NOTIFY_ENUM_DIR, INVALID_PROCESS_DEATTACH_ATTEMPT,
STATUS_REGISTRY_RECOVERED, INVALID_SOFTWARE_INTERRUPT,
STATUS_REGISTRY_IO_FAILED, IRQL_NOT_DISPATCH_LEVEL,
STATUS_KEY_DELETED, IRQL_NOT_GREATER_OR_EQUAL,
STATUS_NO_LOG_SPACE, NO_EXCEPTION_HANDLING_SUPPORT,
STATUS_KEY_HAS_CHILDREN, MAXIMUM_WAIT_OBJECTS_EXCEEDED,
STATUS_CHILD_MUST_BE_VOLATILE, MUTEX_LEVEL_NUMBER_VIOLATION,
STATUS_REGISTRY_CORRUPT, NO_USER_MODE_CONTEXT,
STATUS_DLL_NOT_FOUND, SPIN_LOCK_ALREADY_OWNED,
STATUS_DLL_INIT_FAILED, SPIN_LOCK_NOT_OWNED,
STATUS_ORDINAL_NOT_FOUND, THREAD_NOT_MUTEX_OWNER,
STATUS_ENTRYPOINT_NOT_FOUND, TRAP_CAUSE_UNKNOWN,
// STATUS_PENDING, EMPTY_THREAD_REAPER_LIST,
STATUS_MORE_ENTRIES, CREATE_DELETE_LOCK_NOT_LOCKED,
// STATUS_INTEGER_OVERFLOW, LAST_CHANCE_CALLED_FROM_KMODE,
STATUS_BUFFER_OVERFLOW, CID_HANDLE_CREATION,
STATUS_NO_MORE_FILES, CID_HANDLE_DELETION,
STATUS_NO_INHERITANCE, REFERENCE_BY_POINTER,
STATUS_NO_MORE_EAS, BAD_POOL_HEADER,
STATUS_NO_MORE_ENTRIES, MEMORY_MANAGMENT,
STATUS_GUIDS_EXHAUSTED, PFN_SHARE_COUNT,
STATUS_AGENTS_EXHAUSTED, PFN_REFERENCE_COUNT,
STATUS_UNSUCCESSFUL, NO_SPIN_LOCK_AVAILABLE,
STATUS_NOT_IMPLEMENTED, KMODE_EXCEPTION_NOT_HANDLED,
STATUS_ILLEGAL_FUNCTION, SHARED_RESOURCE_CONV_ERROR,
// STATUS_IN_PAGE_ERROR, KERNEL_APC_PENDING_DURING_EXIT,
STATUS_PAGEFILE_QUOTA, QUOTA_UNDERFLOW,
STATUS_COMMITMENT_LIMIT, FILE_SYSTEM,
STATUS_SECTION_TOO_BIG, FAT_FILE_SYSTEM,
RPC_NT_SS_IN_NULL_CONTEXT, NTFS_FILE_SYSTEM,
RPC_NT_INVALID_BINDING, NPFS_FILE_SYSTEM,
// STATUS_INVALID_HANDLE, CDFS_FILE_SYSTEM,
STATUS_OBJECT_FILE_MISMATCH, RDR_FILE_SYSTEM,
STATUS_FILE_CLOSED, CORRUPT_ACCESS_TOKEN,
STATUS_INVALID_PORT_HANDLE, SECURITY_SYSTEM,
STATUS_NOT_COMMITTED, INCONSISTENT_IRP,
STATUS_INVALID_PARAMETER, PANIC_STACK_SWITCH,
STATUS_INVALID_PARAMETER_1, PORT_DRIVER_INTERNAL,
STATUS_INVALID_PARAMETER_2, SCSI_DISK_DRIVER_INTERNAL,
STATUS_INVALID_PARAMETER_3, INSTRUCTION_BUS_ERROR,
STATUS_INVALID_PARAMETER_4, SET_OF_INVALID_CONTEXT,
STATUS_INVALID_PARAMETER_5, PHASE0_INITIALIZATION_FAILED,
STATUS_INVALID_PARAMETER_6, PHASE1_INITIALIZATION_FAILED,
STATUS_INVALID_PARAMETER_7, UNEXPECTED_INITIALIZATION_CALL,
STATUS_INVALID_PARAMETER_8, CACHE_MANAGER,
STATUS_INVALID_PARAMETER_9, NO_MORE_IRP_STACK_LOCATIONS,
STATUS_INVALID_PARAMETER_10, DEVICE_REFERENCE_COUNT_NOT_ZERO,
STATUS_INVALID_PARAMETER_11, FLOPPY_INTERNAL_ERROR,
STATUS_INVALID_PARAMETER_12, SERIAL_DRIVER_INTERNAL,
STATUS_INVALID_PARAMETER_MAX, SYSTEM_EXIT_OWNED_MUTEX,
STATUS_INVALID_PAGE_PROTECTION, SYSTEM_UNWIND_PREVIOUS_USER,
STATUS_RESOURCE_DATA_NOT_FOUND, SYSTEN_SERVICE_EXCEPTION,
STATUS_RESOURCE_TYPE_NOT_FOUND, INTERRUPT_UNWIND_ATTEMPTED,
STATUS_RESOURCE_NAME_NOT_FOUND, INTERRUPT_EXCEPTION_NOT_HANDLED,
STATUS_RESOURCE_LANG_NOT_FOUND, MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED,
STATUS_NO_SUCH_DEVICE, NO_MORE_SYSTEM_PTES,
STATUS_NO_SUCH_FILE, TARGET_MDL_TOO_SMALL,
STATUS_INVALID_DEVICE_REQUEST, MUST_SUCCEED_POOL_EMPTY,
STATUS_END_OF_FILE, ATDISK_DRIVER_INTERNAL,
STATUS_FILE_FORCED_CLOSED, NO_SUCH_PARTITION,
STATUS_WRONG_VOLUME, MULTIPLE_IRP_COMPLETE_REQUESTS,
STATUS_NO_MEDIA, INSUFFICENT_SYSTEM_MAP_PAGES,
STATUS_NO_MEDIA_IN_DEVICE, DEREF_UNKNOWN_LOGON_SERVICE,
STATUS_NONEXISTENT_SECTOR, REF_UNKNOWN_LOGON_SERVICE,
STATUS_WORKING_SET_QUOTA, CANCEL_STATE_IN_COMPLETED_IRP,
// STATUS_NO_MEMORY, PAGE_FAULT_WITH_INTERRUPTS_OFF,
STATUS_CONFLICTING_ADDRESS, IRQL_GT_ZERO_AT_SYSTEM_SERVICE,
STATUS_INVALID_SYSTEM_SERVICE, STREAMS_INTERNAL_ERROR,
STATUS_THREAD_IS_TERMINATING, FATAL_UNHANDLED_HARD_ERROR,
STATUS_PROCESS_IS_TERMINATING, NO_PAGES_AVAILABLE,
STATUS_INVALID_LOCK_SEQUENCE, PFN_LIST_CORRUPT,
STATUS_INVALID_VIEW_SIZE, NDIS_INTERNAL_ERROR,
STATUS_ALREADY_COMMITTED, PAGE_FAULT_IN_NONPAGED_AREA,
STATUS_ACCESS_DENIED, REGISTRY_ERROR,
STATUS_FILE_IS_A_DIRECTORY, MAILSLOT_FILE_SYSTEM,
STATUS_CANNOT_DELETE, NO_BOOT_DEVICE,
STATUS_INVALID_COMPUTER_NAME, LM_SERVER_INTERNAL_ERROR,
STATUS_FILE_DELETED, DATA_COHERENCY_EXCEPTION,
STATUS_DELETE_PENDING, INSTRUCTION_COHERENCY_EXCEPTION,
STATUS_PORT_CONNECTION_REFUSED, XNS_INTERNAL_ERROR,
STATUS_NO_SUCH_PRIVILEGE, FTDISK_INTERNAL_ERROR,
STATUS_PRIVILEGE_NOT_HELD, PINBALL_FILE_SYSTEM,
STATUS_CANNOT_IMPERSONATE, CRITICAL_SERVICE_FAILED,
STATUS_LOGON_FAILURE, SET_ENV_VAR_FAILED,
STATUS_ACCOUNT_RESTRICTION, HAL_INITIALIZED_FAILED,
STATUS_INVALID_LOGON_HOURS, UNSUPPORTED_PROCESSOR,
STATUS_INVALID_WORKSTATION, OBJECT_INITIALIZATION_FAILED,
STATUS_BUFFER_TOO_SMALL, SECURITY_INITIALIZATION_FAILED,
STATUS_UNABLE_TO_DECOMMIT_VM, PROCESS_INITIALIZATION_FAILED,
STATUS_DISK_CORRUPT_ERROR, HAL1_INITIALIZATION_FAILED,
STATUS_OBJECT_NAME_INVALID, };
STATUS_OBJECT_NAME_NOT_FOUND, enum
// STATUS_OBJECT_NAME_COLLISION, {
STATUS_OBJECT_PATH_INVALID, KBUG_NONE,
STATUS_OBJECT_PATH_NOT_FOUND, KBUG_ORPHANED_IRP,
STATUS_DFS_EXIT_PATH_FOUND, KBUG_IO_STACK_OVERFLOW,
STATUS_OBJECT_PATH_SYNTAX_BAD, KBUG_OUT_OF_MEMORY,
STATUS_DATA_OVERRUN, KBUG_POOL_FREE_LIST_CORRUPT,
STATUS_DATA_LATE_ERROR,
STATUS_DATA_ERROR, /*
STATUS_CRC_ERROR, * These are well known but the actual value is unknown
STATUS_SHARING_VIOLATION, */
STATUS_QUOTA_EXCEEDED, // NO_PAGES_AVAILABLE,
STATUS_MUTANT_NOT_OWNED,
STATUS_SEMAPHORE_LIMIT_EXCEEDED, /*
STATUS_DISK_FULL, * These are well known (MS) bug types
STATUS_LOCK_NOT_GRANTED, * (Reference: NT Insider 1997 - http://www.osr.com)
}; */
IRQL_NOT_LESS_OR_EQUAL = 0xa,
/* // KMODE_EXCEPTION_NOT_HANDLED = 0x1e,
* Possible device types UNEXPECTED_KERNEL_MODE_TRAP = 0x7f,
*/ PAGE_FAULT_IN_NON_PAGED_AREA = 0x50,
enum };
{
/* /*
* Standard define types * PURPOSE: Object attributes
*/ */
FILE_DEVICE_BEEP, enum
FILE_DEVICE_CDROM, {
FILE_DEVICE_CONTROLLER, OBJ_INHERIT = 0x1,
FILE_DEVICE_DISK, OBJ_PERMANENT = 0x2,
FILE_DEVICE_INPORT_PORT, OBJ_EXCLUSIVE = 0x4,
FILE_DEVICE_KEYBOARD, OBJ_CASE_INSENSITIVE = 0x8,
FILE_DEVICE_MIDI_IN, OBJ_OPENIF = 0x10,
FILE_DEVICE_MIDI_OUT, };
FILE_DEVICE_MOUSE,
FILE_DEVICE_NULL, /*
FILE_DEVICE_PARALLEL_PORT, * PURPOSE: DPC priorities
FILE_DEVICE_PRINTER, */
FILE_DEVICE_SCANNER, enum
FILE_DEVICE_SERIAL_MOUSE_PORT, {
FILE_DEVICE_SERIAL_PORT, High,
FILE_DEVICE_SCREEN, Medium,
FILE_DEVICE_TAPE, Low,
FILE_DEVICE_UNKNOWN, };
FILE_DEVICE_VIDEO,
FILE_DEVICE_VIRTUAL_DISK, /*
FILE_DEVICE_WAVE_IN, * PURPOSE: Timer types
FILE_DEVICE_WAVE_OUT, */
FILE_DEVICE_8042_PORT, enum
{
/* NotificationTimer,
* Values beyond this are reserved for ISVs SynchronizationTimer,
*/ };
FILE_DEVICE_FIRST_FREE = 32768
}; /*
* PURPOSE: Some drivers use these
*/
#define IN
/* #define OUT
* Possible device characteristics #define OPTIONAL
*/
enum /*
{ * PURPOSE: Power IRP minor function numbers
FILE_REMOVABLE_MEDIA = 0x1, */
FILE_READ_ONLY_DEVICE = 0x2, enum
FILE_FLOPPY_DISKETTE = 0x4, {
FILE_WRITE_ONCE_MEDIA = 0x8, IRP_MN_QUERY_POWER,
FILE_REMOTE_DEVICE = 0x10, IRP_MN_SET_POWER,
}; IRP_MN_WAIT_WAKE,
IRP_MN_QUERY_CAPABILITIES,
/* IRP_MN_POWER_SEQUENCE,
* PURPOSE: Bus types };
*/
enum /*
{ * PURPOSE: Used all over
Internal, */
Isa, enum
MicroChannel, {
TurboChannel, KernelMode,
PCIBus, UserMode,
MaximumInterfaceType, };
};
/*
/* * PURPOSE: Arguments to MmProbeAndLockPages
* This is a list of bug check types (not MS's) */
*/ enum
enum {
{ IoReadAccess,
KBUG_NONE, IoWriteAccess,
KBUG_ORPHANED_IRP, IoModifyAccess,
KBUG_IO_STACK_OVERFLOW, };
KBUG_OUT_OF_MEMORY,
KBUG_POOL_FREE_LIST_CORRUPT, #define MAXIMUM_VOLUME_LABEL_LENGTH (32)
/* /*
* These are well known but the actual value is unknown * IRQ levels
*/ */
NO_PAGES_AVAILABLE, enum
{
/* PASSIVE_LEVEL,
* These are well known (MS) bug types
* (Reference: NT Insider 1997 - http://www.osr.com) /*
*/ * Which order for these (only DISPATCH_LEVEL is important for now)
IRQL_NOT_LESS_OR_EQUAL = 0xa, */
KMODE_EXCEPTION_NOT_HANDLED = 0x1e, APC_LEVEL,
UNEXPECTED_KERNEL_MODE_TRAP = 0x7f, DISPATCH_LEVEL,
PAGE_FAULT_IN_NON_PAGED_AREA = 0x50,
}; /*
* Above here are device specific IRQ levels
/* */
* PURPOSE: Object attributes FIRST_DEVICE_SPECIFIC_LEVEL,
*/ HIGH_LEVEL = FIRST_DEVICE_SPECIFIC_LEVEL + NR_DEVICE_SPECIFIC_LEVELS,
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

@@ -1,15 +1,17 @@
/* EXECUTIVE ROUTINES ******************************************************/ /* EXECUTIVE ROUTINES ******************************************************/
//VOID ExAcquireFastMutex(PFAST_MUTEX FastMutex); VOID ExAcquireFastMutex(PFAST_MUTEX FastMutex);
VOID ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex);
BOOLEAN ExAcquireResourceExclusive(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireResourceExclusiveLite(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireResourceSharedLite(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireSharedStarveExclusive(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireSharedWaitForExclusive(PERESOURCE Resource, BOOLEAN Wait);
PVOID ExAllocateFromNPagedLookasideList(PNPAGED_LOOKASIDE_LIST LookSide);
PVOID ExAllocateFromPagedLookasideList(PPAGED_LOOKASIDE_LIST LookSide);
PVOID ExAllocateFromZone(PZONE_HEADER Zone);
/*
* FUNCTION: Releases previously allocated memory
* ARGUMENTS:
* block = block to free
*/
VOID ExFreePool(PVOID block);
/* /*
* FUNCTION: Allocates memory from the nonpaged pool * FUNCTION: Allocates memory from the nonpaged pool
* ARGUMENTS: * ARGUMENTS:
@@ -20,6 +22,63 @@ VOID ExFreePool(PVOID block);
*/ */
PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG size); PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG size);
PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes);
PVOID ExAllocatePoolWithQuotaTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
ULONG Tag);
PVOID ExAllocatePoolWithTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
ULONG Tag);
VOID ExConvertExclusiveToSharedLite(PERESOURCE Resource);
VOID ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside);
VOID ExDeletePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside);
NTSTATUS ExDeleteResource(PERESOURCE Resource);
NTSTATUS ExDeleteResourceLite(PERESOURCE Resource);
NTSTATUS ExExtendZone(PZONE_HEADER Zone, PVOID Segment, ULONG SegmentSize);
/*
* FUNCTION: Releases previously allocated memory
* ARGUMENTS:
* block = block to free
*/
VOID ExFreePool(PVOID block);
VOID ExFreeToNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry);
VOID ExFreeToPagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry);
PVOID ExFreeToZone(PZONE_HEADER Zone, PVOID Block);
ERESOURCE_THREAD ExGetCurrentResourceThread(VOID);
ULONG ExGetExclusiveWaiterCount(PERESOURCE Resource);
ULONG ExGetSharedWaiterCount(PERESOURCE Resource);
VOID ExInitializeFastMutex(PFAST_MUTEX FastMutex);
VOID ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
PALLOCATE_FUNCTION Allocate,
PFREE_FUNCTION Free,
ULONG Flags,
ULONG Size,
ULONG Tag,
USHORT Depth);
VOID ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
PALLOCATE_FUNCTION Allocate,
PFREE_FUNCTION Free,
ULONG Flags,
ULONG Size,
ULONG Tag,
USHORT Depth);
NTSTATUS ExInitializeResource(PERESOURCE Resource);
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource);
VOID ExInitializeSListHead(PSLIST_HEADER SListHead);
VOID ExInitializeWorkItem(PWORK_QUEUE_ITEM Item,
PWORKER_THREAD_ROUTINE Routine,
PVOID Context);
NTSTATUS ExInitializeZone(PZONE_HEADER Zone,
ULONG BlockSize,
PVOID InitialSegment,
ULONG InitialSegmentSize);
LARGE_INTEGER ExInterlockedAddLargeInteger(PLARGE_INTEGER Addend,
LARGE_INTEGER Increment,
PKSPIN_LOCK Lock);
ULONG ExInterlockedAddUlong(PULONG Addend, ULONG Increment, PKSPIN_LOCK Lock);
VOID ExInterlockedRemoveEntryList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry, VOID ExInterlockedRemoveEntryList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry,
PKSPIN_LOCK Lock); PKSPIN_LOCK Lock);
VOID RemoveEntryFromList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry); VOID RemoveEntryFromList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
@@ -33,3 +92,5 @@ PLIST_ENTRY ExInterlockedInsertHeadList(PLIST_ENTRY ListHead,
PLIST_ENTRY ListEntry, PLIST_ENTRY ListEntry,
PKSPIN_LOCK Lock); PKSPIN_LOCK Lock);
VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
WORK_QUEUE_TYPE QueueType);

View File

@@ -1,3 +1,50 @@
typedef ULONG INTERLOCKED_RESULT;
typedef ULONG WORK_QUEUE_TYPE;
typedef ULONG ERESOURCE_THREAD, *PERESOURCE_THREAD;
typedef struct _OWNER_ENTRY
{
ERESOURCE_THREAD OwnerThread;
union
{
LONG OwnerCount;
ULONG TableSize;
} a;
} OWNER_ENTRY, *POWNER_ENTRY;
typedef struct _ERESOURCE
{
LIST_ENTRY SystemResourcesList;
POWNER_ENTRY OwnerTable;
SHORT ActiveCount;
USHORT Flag;
PKSEMAPHORE SharedWaiters;
PKEVENT ExclusiveWaiters;
OWNER_ENTRY OwnerThreads[2];
ULONG ContentionCount;
USHORT NumberOfSharedWaiters;
USHORT NumberOfExclusiveWaiters;
union
{
PVOID Address;
ULONG CreatorBackTraceIndex;
} a;
KSPIN_LOCK SpinLock;
} ERESOURCE, *PERESOURCE;
typedef struct
{
LONG Count;
PKTHREAD Owner;
ULONG Contention;
KEVENT Event;
ULONG OldIrql;
} FAST_MUTEX, *PFAST_MUTEX;
typedef struct _ZONE_HEADER typedef struct _ZONE_HEADER
{ {
SINGLE_LIST_ENTRY FreeList; SINGLE_LIST_ENTRY FreeList;
@@ -16,3 +63,65 @@ typedef struct _ZONE_ENTRY
{ {
SINGLE_LIST_ENTRY Entry; SINGLE_LIST_ENTRY Entry;
} ZONE_ENTRY, *PZONE_ENTRY; } ZONE_ENTRY, *PZONE_ENTRY;
typedef VOID (*PWORKER_THREAD_ROUTINE)(PVOID Parameter);
typedef struct _WORK_QUEUE_ITEM
{
LIST_ENTRY Entry;
PWORKER_THREAD_ROUTINE Routine;
PVOID Context;
} WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
typedef PVOID (*PALLOCATE_FUNCTION)(POOL_TYPE PoolType,
ULONG NumberOfBytes,
ULONG Tag);
typedef VOID (*PFREE_FUNCTION)(PVOID Buffer);
typedef union _SLIST_HEADER
{
ULONGLONG Alignment;
struct
{
SINGLE_LIST_ENTRY Next;
USHORT Depth;
USHORT Sequence;
} s;
} SLIST_HEADER, *PSLIST_HEADER;
typedef struct
{
SLIST_HEADER ListHead;
USHORT Depth;
USHORT Pad;
ULONG TotalAllocates;
ULONG AllocateMisses;
ULONG TotalFrees;
ULONG TotalMisses;
POOL_TYPE Type;
ULONG Tag;
ULONG Size;
PALLOCATE_FUNCTION Allocate;
PFREE_FUNCTION Free;
LIST_ENTRY ListEntry;
KSPIN_LOCK Lock;
} NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
typedef struct
{
SLIST_HEADER ListHead;
USHORT Depth;
USHORT Pad;
ULONG TotalAllocates;
ULONG AllocateMisses;
ULONG TotalFrees;
ULONG TotalMisses;
POOL_TYPE Type;
ULONG Tag;
ULONG Size;
PALLOCATE_FUNCTION Allocate;
PFREE_FUNCTION Free;
LIST_ENTRY ListEntry;
FAST_MUTEX Lock;
} PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;

View File

@@ -224,7 +224,7 @@ BOOLEAN IoCancelIrp(PIRP Irp);
NTSTATUS IoCheckShareAccess(ACCESS_MASK DesiredAccess, NTSTATUS IoCheckShareAccess(ACCESS_MASK DesiredAccess,
ULONG DesiredShareAccess, ULONG DesiredShareAccess,
PFILE_OBJECT FileObject, PFILE_OBJECT FileObject,
// PSHARE_ACCESS ShareAccess, PSHARE_ACCESS ShareAccess,
BOOLEAN Update); BOOLEAN Update);
/* /*
@@ -404,7 +404,7 @@ BOOLEAN IoRaiseHardInformationalError(NTSTATUS ErrorStatus,
NTSTATUS IoReadPartitionTable(PDEVICE_OBJECT DeviceObject, NTSTATUS IoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize, ULONG SectorSize,
BOOLEAN ReturnedRecognizedPartitions, BOOLEAN ReturnedRecognizedPartitions,
struct _DRIVER_LAYOUT_INFORMATION** PBuffer); struct _DRIVE_LAYOUT_INFORMATION** PBuffer);
VOID IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject, VOID IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
PDRIVER_REINITIALIZE ReinitRoutine, PDRIVER_REINITIALIZE ReinitRoutine,
@@ -502,3 +502,22 @@ NTSTATUS IoWritePartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorsPerTrack, ULONG SectorsPerTrack,
ULONG NumberOfHeads, ULONG NumberOfHeads,
struct _DRIVE_LAYOUT_INFORMATION* PBuffer); struct _DRIVE_LAYOUT_INFORMATION* PBuffer);
typedef ULONG FS_INFORMATION_CLASS;
// Preliminary guess
NTKERNELAPI NTSTATUS IoQueryFileVolumeInformation(IN PFILE_OBJECT FileObject,
IN FS_INFORMATION_CLASS FsInformationClass,
IN ULONG Length,
OUT PVOID FsInformation,
OUT PULONG ReturnedLength);
NTKERNELAPI // confirmed - Undocumented because it does not require a valid file handle
NTSTATUS
IoQueryFileInformation(
IN PFILE_OBJECT FileObject,
IN FILE_INFORMATION_CLASS FileInformationClass,
IN ULONG Length,
OUT PVOID FileInformation,
OUT PULONG ReturnedLength
);

View File

@@ -16,10 +16,14 @@ struct _IO_STATUS_BLOCK;
/* SIMPLE TYPES *************************************************************/ /* SIMPLE TYPES *************************************************************/
enum
{
DeallocateObject,
KeepObject,
};
typedef ULONG INTERFACE_TYPE; typedef ULONG INTERFACE_TYPE;
typedef INTERFACE_TYPE* PINTERFACE_TYPE; typedef INTERFACE_TYPE* PINTERFACE_TYPE;
typedef ULONG CONFIGURATION_TYPE;
typedef CONFIGURATION_TYPE* PCONFIGURATION_TYPE;
/* /*
* FIXME: Definition needed * FIXME: Definition needed
@@ -62,8 +66,9 @@ typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
*/ */
typedef struct _IO_TIMER typedef struct _IO_TIMER
{ {
} IO_TIMER, PIO_TIMER; KTIMER timer;
KDPC dpc;
} IO_TIMER, *PIO_TIMER;
/* /*
* PURPOSE: IRP stack location * PURPOSE: IRP stack location
@@ -136,9 +141,6 @@ typedef struct _IO_STACK_LOCATION
*/ */
PIO_COMPLETION_ROUTINE CompletionRoutine; PIO_COMPLETION_ROUTINE CompletionRoutine;
PVOID CompletionContext; PVOID CompletionContext;
BOOLEAN InvokeOnSuccess;
BOOLEAN InvokeOnError;
BOOLEAN InvokeOnCancel;
/* /*
* Driver created device object representing the target device * Driver created device object representing the target device
@@ -176,6 +178,52 @@ typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject, typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject,
PUNICODE_STRING RegistryPath); PUNICODE_STRING RegistryPath);
typedef struct _SECTION_OBJECT_POINTERS
{
PVOID DataSectionObject;
PVOID SharedCacheMap;
PVOID ImageSectionObject;
} SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
typedef struct _IO_COMPLETION_CONTEXT
{
PVOID Port;
ULONG Key;
} IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
typedef struct _FILE_OBJECT
{
CSHORT Type;
CSHORT Size;
struct _DEVICE_OBJECT* DeviceObject;
struct _VPB* Vpb;
PVOID FsContext;
PVOID FsContext2;
PSECTION_OBJECT_POINTERS SectionObjectPointers;
PVOID PrivateCacheMap;
NTSTATUS FinalStatus;
struct _FILE_OBJECT* RelatedFileObject;
BOOLEAN LockOperation;
BOOLEAN DeletePending;
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
ULONG Flags;
UNICODE_STRING FileName;
LARGE_INTEGER CurrentByteOffset;
ULONG Waiters;
ULONG Busy;
PVOID LastLock;
KEVENT Lock;
KEVENT Event;
PIO_COMPLETION_CONTEXT CompletionContext;
} FILE_OBJECT, *PFILE_OBJECT;
typedef struct _IRP typedef struct _IRP
{ {
PMDL MdlAddress; PMDL MdlAddress;
@@ -212,13 +260,11 @@ typedef struct _IRP
struct struct
{ {
KDEVICE_QUEUE_ENTRY DeviceQueueEntry; KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
// PETHREAD Thread; PETHREAD Thread;
PVOID Thread;
PCHAR AuxiliaryBuffer; PCHAR AuxiliaryBuffer;
LIST_ENTRY ListEntry; LIST_ENTRY ListEntry;
struct _IO_STACK_LOCATION* CurrentStackLocation; struct _IO_STACK_LOCATION* CurrentStackLocation;
// PFILE_OBJECT OriginalFileObject; PFILE_OBJECT OriginalFileObject;
PVOID OriginalFileObject;
} Overlay; } Overlay;
KAPC Apc; KAPC Apc;
ULONG CompletionKey; ULONG CompletionKey;
@@ -288,7 +334,7 @@ typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
/* /*
* Dispatch routine type declaration * Dispatch routine type declaration
*/ */
typedef NTSTATUS (*PDRIVER_STARTIO)(struct _DEVICE_OBJECT*, IRP*); typedef VOID (*PDRIVER_STARTIO)(struct _DEVICE_OBJECT*, IRP*);
/* /*
* Dispatch routine type declaration * Dispatch routine type declaration
@@ -326,14 +372,6 @@ typedef struct _DRIVER_OBJECT
} DRIVER_OBJECT, *PDRIVER_OBJECT; } DRIVER_OBJECT, *PDRIVER_OBJECT;
typedef struct _FILE_OBJECT
{
PDEVICE_OBJECT DeviceObject;
PVOID FsContext;
} FILE_OBJECT, *PFILE_OBJECT;
typedef struct _CONFIGURATION_INFORMATION typedef struct _CONFIGURATION_INFORMATION
{ {
ULONG DiskCount; ULONG DiskCount;
@@ -355,20 +393,6 @@ typedef VOID (*PIO_DPC_ROUTINE)(PKDPC Dpc,
typedef VOID (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject, typedef VOID (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
PVOID Context); 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 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
typedef struct _PARTITION_INFORMATION typedef struct _PARTITION_INFORMATION
{ {
@@ -390,4 +414,142 @@ typedef struct _DRIVER_LAYOUT_INFORMATION
PARTITION_INFORMATION PartitionEntry[1]; PARTITION_INFORMATION PartitionEntry[1];
} DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION; } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
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;
#endif __INCLUDE_DDK_IOTYPES_H #endif __INCLUDE_DDK_IOTYPES_H

View File

@@ -1,6 +1,17 @@
#ifndef __INCLUDE_DDK_KEFUNCS_H
#define __INCLUDE_DDK_KEFUNCS_H
/* KERNEL FUNCTIONS ********************************************************/ /* KERNEL FUNCTIONS ********************************************************/
/*
* FUNCTION: Acquires a spinlock so the caller can synchronize access to
* data
* ARGUMENTS:
* SpinLock = Initialized spinlock
* OldIrql (OUT) = Set the previous irql on return
*/
VOID KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql); VOID KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql);
VOID KeAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock); VOID KeAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock);
BOOLEAN KeCancelTimer(PKTIMER Timer); BOOLEAN KeCancelTimer(PKTIMER Timer);
VOID KeClearEvent(PKEVENT Event); VOID KeClearEvent(PKEVENT Event);
@@ -14,6 +25,7 @@ VOID KeFlushIoBuffers(PMDL Mdl, BOOLEAN ReadOperation, BOOLEAN DmaOperation);
KIRQL KeGetCurrentIrql(VOID); KIRQL KeGetCurrentIrql(VOID);
ULONG KeGetCurrentProcessorNumber(VOID); ULONG KeGetCurrentProcessorNumber(VOID);
ULONG KeGetDcacheFillSize(VOID); ULONG KeGetDcacheFillSize(VOID);
PKTHREAD KeGetCurrentThread(VOID);
VOID KeInitializeCallbackRecord(PKBUGCHECK_CALLBACK_RECORD CallbackRecord); VOID KeInitializeCallbackRecord(PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
VOID KeInitializeDeviceQueue(PKDEVICE_QUEUE DeviceQueue); VOID KeInitializeDeviceQueue(PKDEVICE_QUEUE DeviceQueue);
VOID KeInitializeDpc(PKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine, VOID KeInitializeDpc(PKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine,
@@ -122,3 +134,5 @@ VOID KeBugCheckEx(ULONG BugCheckCode,
* RETURNS: Doesn't * RETURNS: Doesn't
*/ */
VOID KeBugCheck(ULONG BugCheckCode); VOID KeBugCheck(ULONG BugCheckCode);
#endif /* __INCLUDE_DDK_KEFUNCS_H */

View File

@@ -1,63 +1,154 @@
/* KERNEL TYPES **************************************************************/
#ifndef __INCLUDE_DDK_KETYPES_H
#define __INCLUDE_DDK_KETYPES_H
typedef LONG KPRIORITY; typedef LONG KPRIORITY;
typedef VOID (*PKBUGCHECK_CALLBACK_ROUTINE)(PVOID Buffer, ULONG Length); typedef VOID (*PKBUGCHECK_CALLBACK_ROUTINE)(PVOID Buffer, ULONG Length);
typedef BOOLEAN (*PKSYNCHRONIZE_ROUTINE)(PVOID SynchronizeContext); typedef BOOLEAN (*PKSYNCHRONIZE_ROUTINE)(PVOID SynchronizeContext);
struct _KAPC;
typedef VOID (*PKNORMAL_ROUTINE)(PVOID NormalContext,
PVOID SystemArgument1,
PVOID SystemArgument2);
typedef VOID (*PKKERNEL_ROUTINE)(struct _KAPC* Apc,
PKNORMAL_ROUTINE* NormalRoutine,
PVOID* NormalContext,
PVOID* SystemArgument1,
PVOID* SystemArgument2);
typedef VOID (*PKRUNDOWN_ROUTINE)(struct _KAPC* Apc);
typedef struct
/*
* PURPOSE: Object describing the wait a thread is currently performing
*/
{
LIST_ENTRY WaitListEntry;
struct _KTHREAD* Thread;
PVOID Object;
struct _KWAIT_BLOCK* NextWaitBlock;
USHORT WaitKey;
USHORT WaitType;
} KWAIT_BLOCK, *PKWAIT_BLOCK;
typedef struct _ETHREAD
/*
* PURPOSE: Describes a thread of execution
*/
{
CSHORT Type;
CSHORT Size;
/*
* PURPOSE: Head of the queue of apcs
*/
LIST_ENTRY apc_queue_head;
/*
* 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 process
*/
struct _EPROCESS* Process;
/*
* PURPOSE: Handle of our process
*/
HANDLE ProcessHandle;
/*
* PURPOSE: Thread affinity mask
*/
ULONG AffinityMask;
/*
* PURPOSE: Saved thread context
*/
hal_thread_state context;
} KTHREAD, *PKTHREAD, *PETHREAD;
typedef struct _DISPATCHER_HEADER
{
UCHAR Type;
UCHAR Absolute;
UCHAR Size;
UCHAR Inserted;
LONG SignalState;
LIST_ENTRY WaitListHead;
} DISPATCHER_HEADER;
typedef struct _KAPC
{
CSHORT Type;
CSHORT Size;
ULONG Spare0;
struct _KTHREAD* Thread;
LIST_ENTRY ApcListEntry;
PKKERNEL_ROUTINE KernelRoutine;
PKRUNDOWN_ROUTINE RundownRoutine;
PKNORMAL_ROUTINE NormalRoutine;
PVOID NormalContext;
PVOID SystemArgument1;
PVOID SystemArgument2;
CCHAR ApcStateIndex;
KPROCESSOR_MODE ApcMode;
BOOLEAN Inserted;
} KAPC, *PKAPC;
typedef struct typedef struct
{ {
LIST_ENTRY Entry;
PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
PVOID Buffer;
ULONG Length;
PUCHAR Component;
ULONG Checksum;
UCHAR State;
} KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
typedef struct typedef struct
{ {
DISPATCHER_HEADER Header;
LIST_ENTRY MutantListEntry;
struct _KTHREAD* OwnerThread;
BOOLEAN Abandoned;
UCHAR ApcDisable;
} KMUTEX, *PKMUTEX; } KMUTEX, *PKMUTEX;
typedef struct typedef struct
{ {
DISPATCHER_HEADER Header;
LONG Limit;
} KSEMAPHORE, *PKSEMAPHORE; } KSEMAPHORE, *PKSEMAPHORE;
typedef struct typedef struct _KEVENT
{
} 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 * PURPOSE: Describes an event
*/ */
typedef struct _KEVENT
{ {
/* /*
* PURPOSE: So we can use the general wait routine * PURPOSE: So we can use the general wait routine
*/ */
DISPATCHER_HEADER hdr; DISPATCHER_HEADER Header;
/*
* PURPOSE: Type of event, notification or synchronization
*/
EVENT_TYPE type;
} KEVENT, *PKEVENT; } KEVENT, *PKEVENT;
@@ -66,14 +157,6 @@ typedef struct _KSPIN_LOCK
KIRQL irql; KIRQL irql;
} KSPIN_LOCK, *PKSPIN_LOCK; } KSPIN_LOCK, *PKSPIN_LOCK;
typedef struct
{
} KAPC;
typedef struct
{
} UNICODE_STRING;
typedef VOID (*PDRIVER_ADD_DEVICE)(VOID); typedef VOID (*PDRIVER_ADD_DEVICE)(VOID);
struct _KDPC; struct _KDPC;
@@ -139,3 +222,63 @@ typedef struct _KDEVICE_QUEUE_ENTRY
typedef struct _WAIT_CONTEXT_BLOCK typedef struct _WAIT_CONTEXT_BLOCK
{ {
} WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK; } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
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;
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;
#endif /* __INCLUDE_DDK_KETYPES_H */

View File

@@ -152,7 +152,7 @@ PVOID MmGetSystemAddressForMdl(PMDL Mdl);
* BaseVa = Base virtual address of the buffer * BaseVa = Base virtual address of the buffer
* Length = Length in bytes of the buffer * Length = Length in bytes of the buffer
*/ */
VOID MmInitalizeMdl(PMDL MemoryDescriptorList, PVOID BaseVa, ULONG Length); VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID BaseVa, ULONG Length);
/* /*
* FUNCTION: Checks whether an address is valid for read/write * FUNCTION: Checks whether an address is valid for read/write

View File

@@ -1,24 +1,14 @@
typedef struct _MDL typedef struct _MDL
/* /*
* PURPOSE: Describes a user buffer passed to a system API * PURPOSE: Describes a user buffer passed to a system API
*/ */
{ {
/* struct _MDL* Next;
* Base address of the buffer in user mode CSHORT Size;
*/ CSHORT MdlFlags;
PVOID Base; struct _EPROCESS* Process;
PVOID MappedSystemVa;
/* PVOID StartVa;
* Length of the buffer in bytes ULONG ByteCount;
*/ ULONG ByteOffset;
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; } MDL, *PMDL;

View File

@@ -1,41 +1,75 @@
/* /*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: include/ddk/ntddk.h * FILE: include/ddk/ntddk.h
* PURPOSE: Interface definitions for drivers * PURPOSE: Interface definitions for drivers
* PROGRAMMER: David Welch (welch@mcmail.com) * PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY: * UPDATE HISTORY:
* 15/05/98: Created * 15/05/98: Created
*/ */
#ifndef __NTDDK_H #ifndef __NTDDK_H
#define __NTDDK_H #define __NTDDK_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
/* INCLUDES ***************************************************************/ /* INCLUDES ***************************************************************/
#include <windows.h> #include <windows.h>
#include <internal/hal/page.h>
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
#include <ddk/defines.h> #define NTKERNELAPI
#include <ddk/types.h>
#include <ddk/structs.h> #define CTL_CODE(Dev, Func, Meth, Acc) ( ((Dev)<<16) | ((Acc)<<14) | ((Func)<<2) | (Meth))
#include <internal/hal/ddk.h>
#include <ddk/rtl.h> // IOCTL Parameter buffering methods
#include <ddk/zw.h> #define METHOD_BUFFERED 0
#include <ddk/exfuncs.h> #define METHOD_IN_DIRECT 1
#include <ddk/mmfuncs.h> #define METHOD_OUT_DIRECT 2
#include <ddk/kefuncs.h> #define METHOD_NEITHER 3
#include <ddk/iofuncs.h>
#include <ddk/psfuncs.h> // IOCTL File access type
#define FILE_ANY_ACCESS 0
#ifdef __cplusplus #define FILE_READ_ACCESS 1
}; #define FILE_WRITE_ACCESS 2
#endif
#define QUAD_PART(LI) (*(LONGLONG *)(&LI))
#endif /* __NTDDK_H */
enum {
STATUS_NOT_SUPPORTED = 9999,
STATUS_DISK_OPERATION_FAILED
};
#define IO_DISK_INCREMENT 4
#define FILE_WORD_ALIGNMENT 0x0001
#define FILE_OPENED 0x0001
#include <ddk/defines.h>
#include <ddk/types.h>
#include <ddk/structs.h>
#include <ddk/setypes.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>
#include <ddk/obfuncs.h>
ULONG DbgPrint(PCH Format,...);
#ifdef __cplusplus
};
#endif
#endif /* __NTDDK_H */

View File

@@ -12,7 +12,7 @@ typedef struct _OBJECT_TYPE
/* /*
* PURPOSE: Name of the type * PURPOSE: Name of the type
*/ */
LPCSTR TypeName; UNICODE_STRING TypeName;
/* /*
* PURPOSE: Total number of objects of this type * PURPOSE: Total number of objects of this type
@@ -96,7 +96,7 @@ typedef struct _OBJECT
/* /*
* PURPOSE: Name of this entry * PURPOSE: Name of this entry
*/ */
LPCSTR name; UNICODE_STRING name;
/* /*
* PURPOSE: Our entry in our parents list of subdirectory * PURPOSE: Our entry in our parents list of subdirectory
@@ -139,11 +139,11 @@ typedef struct _OBJECT_ATTRIBUTES
*/ */
ULONG Attributes; ULONG Attributes;
//SECURITY_DESCRIPTOR SecurityDescriptor SECURITY_DESCRIPTOR SecurityDescriptor;
//SecurityQualityOfService // SecurityQualityOfService
struct _DIRECTORY_OBJECT* parent; struct _DIRECTORY_OBJECT* parent;
char* name; UNICODE_STRING name;
char* path; UNICODE_STRING path;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES; } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;

View File

@@ -25,3 +25,8 @@ NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
PCLIENT_ID ClientId, PCLIENT_ID ClientId,
PKSTART_ROUTINE StartRoutine, PKSTART_ROUTINE StartRoutine,
PVOID StartContext); PVOID StartContext);
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus);
NTSTATUS PsSuspendThread(VOID);
NTSTATUS PsWakeThread(PETHREAD Thread);
PETHREAD PsGetCurrentThread(VOID);
PEPROCESS PsGetCurrentProcess(VOID);

View File

@@ -3,6 +3,8 @@
#include <kernel32/heap.h> #include <kernel32/heap.h>
typedef ULONG THREADINFOCLASS;
typedef struct _CLIENT_ID typedef struct _CLIENT_ID
{ {
HANDLE UniqueProcess; HANDLE UniqueProcess;
@@ -60,10 +62,7 @@ typedef struct _NT_PEB
WORD wMinorVersion; WORD wMinorVersion;
WORD wBuildNumber; WORD wBuildNumber;
WORD wPlatformId; WORD wPlatformId;
} NT_PEB; } NT_PEB, *PPEB;
typedef NT_PEB *PPEB;
typedef struct _NT_TIB { typedef struct _NT_TIB {
@@ -104,8 +103,58 @@ typedef struct _EPROCESS
{ {
} EPROCESS, *PEPROCESS; } EPROCESS, *PEPROCESS;
//typedef KTHREAD ETHREAD, *PETHREAD;
#if ETHREAD_NOT_THE_SAME_AS_KTHREAD
typedef struct _ETHREAD typedef struct _ETHREAD
{ {
EPROCESS* Process;
} ETHREAD, *PETHREAD; } ETHREAD, *PETHREAD;
/*
* 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;
#endif
#endif /* __INCLUDE_DDK_PSTYPES_H */ #endif /* __INCLUDE_DDK_PSTYPES_H */

View File

@@ -5,6 +5,52 @@
#ifndef __DDK_RTL_H #ifndef __DDK_RTL_H
#define __DDK_RTL_H #define __DDK_RTL_H
typedef struct _CONTROLLER_OBJECT
{
CSHORT Type;
CSHORT Size;
PVOID ControllerExtension;
KDEVICE_QUEUE DeviceWaitQueue;
ULONG Spare1;
LARGE_INTEGER Spare2;
} 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 _TIME_FIELDS typedef struct _TIME_FIELDS
{ {
CSHORT Year; CSHORT Year;
@@ -179,6 +225,43 @@ VOID RtlStoreLong(PULONG Address, ULONG Value);
VOID RtlStoreUshort(PUSHORT Address, USHORT Value); VOID RtlStoreUshort(PUSHORT Address, USHORT Value);
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS TimeFields, PLARGE_INTEGER Time); BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS TimeFields, PLARGE_INTEGER Time);
VOID RtlTimeToTimeFields(PLARGE_INTEGER Time, PTIME_FIELDS TimeFields); VOID RtlTimeToTimeFields(PLARGE_INTEGER Time, PTIME_FIELDS TimeFields);
PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep, PWSTR* temp);
typedef struct {
ULONG Length;
ULONG Unknown[11];
} RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
// Heap creation routine
HANDLE
STDCALL
RtlCreateHeap(
ULONG Flags,
PVOID BaseAddress,
ULONG SizeToReserve,
ULONG SizeToCommit,
PVOID Unknown,
PRTL_HEAP_DEFINITION Definition
);
PVOID
STDCALL
RtlAllocateHeap(
HANDLE Heap,
ULONG Flags,
ULONG Size
);
BOOLEAN
STDCALL
RtlFreeHeap(
HANDLE Heap,
ULONG Flags,
PVOID Address
);
#endif /* __DDK_RTL_H */ #endif /* __DDK_RTL_H */

View File

@@ -1,318 +1,14 @@
/* SYSTEM STRUCTURES ******************************************************/ /* SYSTEM STRUCTURES ******************************************************/
#include <internal/hal/hal.h> #include <internal/hal/hal.h>
#include <ddk/cfgtypes.h> #include <ddk/cfgtypes.h>
#include <ddk/ketypes.h> #include <ddk/ketypes.h>
#include <ddk/obtypes.h> #include <ddk/obtypes.h>
#include <ddk/mmtypes.h> #include <ddk/mmtypes.h>
#include <ddk/iotypes.h> #include <ddk/iotypes.h>
#include <ddk/extypes.h> #include <ddk/extypes.h>
#include <ddk/pstypes.h> #include <ddk/pstypes.h>
/* typedef struct _ADAPTER_OBJECT
* PURPOSE: Thread object {
*/ } ADAPTER_OBJECT, *PADAPTER_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

@@ -6,12 +6,9 @@
typedef const int CINT; typedef const int CINT;
typedef ULONG KAFFINITY; typedef ULONG KAFFINITY, *PKAFFINITY;
typedef KAFFINITY *PKAFFINITY;
//typedef LONG KPRIORITY; typedef LONG NTSTATUS, *PNTSTATUS;
typedef LONG NTSTATUS;
typedef ULONG DEVICE_TYPE; typedef ULONG DEVICE_TYPE;
@@ -35,20 +32,12 @@ typedef unsigned long long ULONGLONG;
*/ */
//typedef LONG NTSTATUS; //typedef LONG NTSTATUS;
/*
* Unicode string type
* FIXME: Real unicode please
*/
typedef char* PUNICODE_STRING;
#if REAL_UNICODE
typedef struct _UNICODE_STRING typedef struct _UNICODE_STRING
{ {
USHORT Length; USHORT Length;
USHORT MaximumLength; USHORT MaximumLength;
PWSTR Buffer; PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING; } UNICODE_STRING, *PUNICODE_STRING;
#endif
typedef enum _SECTION_INHERIT { typedef enum _SECTION_INHERIT {
ViewShare = 1, ViewShare = 1,
@@ -58,12 +47,10 @@ typedef enum _SECTION_INHERIT {
/* /*
* Various other types (all quite pointless) * Various other types (all quite pointless)
*/ */
//typedef ULONG DEVICE_TYPE;
typedef ULONG KPROCESSOR_MODE; typedef ULONG KPROCESSOR_MODE;
typedef ULONG KIRQL; typedef UCHAR KIRQL;
typedef KIRQL* PKIRQL; typedef KIRQL* PKIRQL;
typedef ULONG IO_ALLOCATION_ACTION; typedef ULONG IO_ALLOCATION_ACTION;
//typedef ULONG INTERFACE_TYPE;
typedef ULONG POOL_TYPE; typedef ULONG POOL_TYPE;
typedef ULONG TIMER_TYPE; typedef ULONG TIMER_TYPE;
typedef ULONG MM_SYSTEM_SIZE; typedef ULONG MM_SYSTEM_SIZE;
@@ -71,15 +58,10 @@ typedef ULONG LOCK_OPERATION;
typedef ULONG KEY_INFORMATION_CLASS; typedef ULONG KEY_INFORMATION_CLASS;
typedef ULONG FILE_INFORMATION_CLASS; typedef ULONG FILE_INFORMATION_CLASS;
typedef ULONG KEY_VALUE_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 ULONG PHYSICAL_ADDRESS;
typedef PHYSICAL_ADDRESS* PPHYSICAL_ADDRESS; typedef PHYSICAL_ADDRESS* PPHYSICAL_ADDRESS;
typedef ULONG WAIT_TYPE; typedef ULONG WAIT_TYPE;
typedef ULONG KWAIT_REASON; //typedef ULONG KINTERRUPT_MODE;
typedef ULONG KINTERRUPT_MODE;
typedef USHORT CSHORT; typedef USHORT CSHORT;
#endif #endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,9 @@
#ifndef _LINUX_CTYPE_H #ifndef _LINUX_CTYPE_H
#define _LINUX_CTYPE_H #define _LINUX_CTYPE_H
#ifdef USE_OLD_CTYPE_IMPLEMENTATION
#define _U 0x01 /* upper */ #define _U 0x01 /* upper */
#define _L 0x02 /* lower */ #define _L 0x02 /* lower */
#define _D 0x04 /* digit */ #define _D 0x04 /* digit */
@@ -31,4 +34,38 @@ extern char _ctmp;
#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp) #define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp)
#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp) #define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
#else
#define upalpha ('A' - 'a')
extern inline char toupper(char c)
{
if ((c>='a') && (c<='z')) return (c+upalpha);
return(c);
}
extern inline int islower(char c)
{
if ((c>='a') && (c<='z')) return 1;
return 0;
}
extern inline int isdigit(char c)
{
if ((c>='0') && (c<='9')) return 1;
return 0;
}
extern inline int isxdigit(char c)
{
if (((c>='0') && (c<='9')) || ((toupper(c)>='A') && (toupper(c)<='Z')))
{
return 1;
}
return 0;
}
#endif
#endif #endif

View File

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

View File

@@ -1,4 +1,4 @@
/* $Id: dma.h,v 1.2 1998/08/12 22:43:24 rosmgr Exp $ /* $Id: dma.h,v 1.1.1.2 1998/08/25 04:27:32 rex Exp $
* linux/include/asm/dma.h: Defines for using and allocating dma channels. * linux/include/asm/dma.h: Defines for using and allocating dma channels.
* Written by Hennus Bergman, 1992. * Written by Hennus Bergman, 1992.
* High DMA channel support & info by Hannu Savolainen * High DMA channel support & info by Hannu Savolainen
@@ -8,7 +8,7 @@
#ifndef _ASM_DMA_H #ifndef _ASM_DMA_H
#define _ASM_DMA_H #define _ASM_DMA_H
#include "io.h" /* need byte IO */ #include <internal/hal/io.h> /* need byte IO */
#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER #ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER

View File

@@ -114,33 +114,4 @@ BOOLEAN HalTranslateBusAddress(INTERFACE_TYPE InterfaceType,
PULONG AddressSpace, PULONG AddressSpace,
PPHYSICAL_ADDRESS TranslatedAddress); 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 */ #endif /* __INCLUDE_INTERNAL_HAL_DDK_H */

View File

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

View File

@@ -48,6 +48,11 @@ extern inline unsigned int physical_to_linear(unsigned int x)
return(x+IDMAP_BASE); return(x+IDMAP_BASE);
} }
extern inline unsigned int linear_to_physical(unsigned int x)
{
return(x-IDMAP_BASE);
}
#define FLUSH_TLB __asm__("movl %cr3,%eax\n\tmovl %eax,%cr3\n\t") #define FLUSH_TLB __asm__("movl %cr3,%eax\n\tmovl %eax,%cr3\n\t")
extern inline unsigned int* get_page_directory(void) extern inline unsigned int* get_page_directory(void)

View File

@@ -8,16 +8,11 @@
* 28/05/97: Created * 28/05/97: Created
*/ */
#ifndef __INTERNAL_IOMGR_H #ifndef __INCLUDE_INTERNAL_IOMGR_H
#define __INTERNAL_IOMGR_H #define __INCLUDE_INTERNAL_IOMGR_H
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
/*
* FUNCTION:
*/
NTSTATUS IoBeginIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp);
/* /*
* FUNCTION: Called to initalize a loaded driver * FUNCTION: Called to initalize a loaded driver
* ARGUMENTS: * ARGUMENTS:
@@ -26,4 +21,7 @@ NTSTATUS IoBeginIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp);
*/ */
NTSTATUS InitalizeLoadedDriver(PDRIVER_INITIALIZE entry); NTSTATUS InitalizeLoadedDriver(PDRIVER_INITIALIZE entry);
VOID IoInitCancelHandling(VOID);
#endif #endif

View File

@@ -1,93 +1,109 @@
/* /*
* Various useful prototypes * Various useful prototypes
*/ */
#ifndef __KERNEL_H #ifndef __KERNEL_H
#define __KERNEL_H #define __KERNEL_H
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/linkage.h> #include <internal/linkage.h>
#include <stdarg.h> #include <stdarg.h>
VOID KiInterruptDispatch(unsigned int irq); /*
VOID KiDispatchInterrupt(unsigned int irq); * Use these to place a function in a specific section of the executable
VOID KeTimerInterrupt(VOID); */
#define PLACE_IN_SECTION(s) __attribute__((section (s)))
/* #define INIT_FUNCTION (PLACE_IN_SECTION("init"))
* Defines a descriptor as it appears in the processor tables #define PAGE_LOCKED_FUNCTION (PLACE_IN_SECTION("pagelk"))
*/ #define PAGE_UNLOCKED_FUNCTION (PLACE_IN_SECTION("pagepo"))
typedef struct
{ /*
unsigned int a; * Maximum size of the kmalloc area (this is totally arbitary)
unsigned int b; */
} descriptor; #define NONPAGED_POOL_SIZE (4*1024*1024)
extern descriptor idt[256]; VOID KiInterruptDispatch(unsigned int irq);
extern descriptor gdt[256]; VOID KiDispatchInterrupt(unsigned int irq);
VOID KeTimerInterrupt(VOID);
/*
* printf style functions /*
*/ * Defines a descriptor as it appears in the processor tables
asmlinkage void printk(const char* fmt, ...); */
int vsprintf(char *buf, const char *fmt, va_list args); typedef struct
int sprintf(char* buf, const char* fmt, ...); {
unsigned int a;
typedef struct unsigned int b;
{ } descriptor;
/*
* Magic value (useless really) extern descriptor idt[256];
*/ extern descriptor gdt[256];
unsigned int magic;
/*
/* * printf style functions
* Cursor position */
*/ asmlinkage void printk(const char* fmt, ...);
unsigned int cursorx; int vsprintf(char *buf, const char *fmt, va_list args);
unsigned int cursory; int sprintf(char* buf, const char* fmt, ...);
/* typedef struct
* Number of files (including the kernel) loaded {
*/ /*
unsigned int nr_files; * Magic value (useless really)
*/
/* unsigned int magic;
* Range of physical memory being used by the system
*/ /*
unsigned int start_mem; * Cursor position
unsigned int end_mem; */
unsigned int cursorx;
/* unsigned int cursory;
* List of module lengths (terminated by a 0)
*/ /*
unsigned int module_length[64]; * Number of files (including the kernel) loaded
} boot_param; */
unsigned int nr_files;
/* /*
* Initalization functions (called once by main()) * Range of physical memory being used by the system
*/ */
void MmInitalize(boot_param* bp); unsigned int start_mem;
void InitalizeExceptions(void); unsigned int end_mem;
void InitalizeIRQ(void);
void InitializeTimer(void); /*
void InitConsole(boot_param* bp); * List of module lengths (terminated by a 0)
void KeInitDpc(void); */
void HalInit(boot_param* bp); unsigned int module_length[64];
void IoInit(void); } boot_param;
void ObjNamespcInit(void);
void PsMgrInit(void);
/*
* Initalization functions (called once by main())
/* */
* FUNCTION: Called to execute queued dpcs void MmInitalize(boot_param* bp);
*/ void InitalizeExceptions(void);
void KeDrainDpcQueue(void); void InitalizeIRQ(void);
void InitializeTimer(void);
void KeExpireTimers(void); void InitConsole(boot_param* bp);
void KeInitDpc(void);
typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp); void HalInit(boot_param* bp);
asmlinkage unsigned int ExHookException(exception_hook fn, UINT exp); void IoInit(void);
void ObjNamespcInit(void);
#endif void PsMgrInit(void);
void KeInitializeBugCheck(void);
VOID KeInitializeDispatcher(VOID);
void TstBegin(void);
void KeCalibrateTimerLoop(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

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

View File

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

View File

@@ -43,11 +43,12 @@ enum
OBJTYP_MAX, OBJTYP_MAX,
}; };
BOOL ObjAddObjectToNameSpace(const char* path, POBJECT_HEADER Object); BOOL ObAddObjectToNameSpace(PUNICODE_STRING path, POBJECT_HEADER Object);
VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type); VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type);
VOID ObInitializeObjectHeader(CSHORT id, LPCSTR name, POBJECT_HEADER obj); VOID ObInitializeObjectHeader(CSHORT id, PUNICODE_STRING name,
POBJECT_HEADER obj);
/* /*
* FUNCTION: Get the size of an object * FUNCTION: Get the size of an object
@@ -59,7 +60,7 @@ ULONG ObSizeOf(CSHORT Type);
HANDLE ObAddHandle(PVOID obj); HANDLE ObAddHandle(PVOID obj);
PVOID ObGetObjectByHandle(HANDLE h); PVOID ObGetObjectByHandle(HANDLE h);
PVOID ObLookupObject(PDIRECTORY_OBJECT root, const char* _string); PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string);
PVOID ObGenericCreateObject(PHANDLE Handle, PVOID ObGenericCreateObject(PHANDLE Handle,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_ATTRIBUTES ObjectAttributes,

View File

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

View File

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

View File

@@ -9,9 +9,9 @@
#ifndef __VERSION_H #ifndef __VERSION_H
#define __VERSION_H #define __VERSION_H
#define KERNEL_VERSION "0.0.7" #define KERNEL_VERSION "0.0.8"
#define KERNEL_MAJOR_VERSION 0 #define KERNEL_MAJOR_VERSION 0
#define KERNEL_MINOR_VERSION 0 #define KERNEL_MINOR_VERSION 0
#define KERNEL_PATCH_LEVEL 7 #define KERNEL_PATCH_LEVEL 8
#endif #endif

View File

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

View File

@@ -55,7 +55,7 @@ typedef unsigned long long u64;
typedef unsigned int size_t; typedef unsigned int size_t;
typedef size_t __kernel_size_t; typedef size_t __kernel_size_t;
typedef unsigned short wchar_t; //typedef unsigned short wchar_t;
#endif /* _LINUX_TYPES_H */ #endif /* _LINUX_TYPES_H */

View File

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

View File

@@ -10,6 +10,8 @@
#include <types.h> /* for size_t */ #include <types.h> /* for size_t */
typedef unsigned short wchar_t;
#ifndef NULL #ifndef NULL
#define NULL ((void *) 0) #define NULL ((void *) 0)
#endif #endif
@@ -38,8 +40,8 @@ extern int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
/* /*
* Include machine specific inline routines * Include machine specific inline routines
*/ */
#ifndef _I386_STRING_H_ //#ifndef _I386_STRING_H_
#define _I386_STRING_H_ //#define _I386_STRING_H_
/* /*
* On a 486 or Pentium, we are better off not using the * On a 486 or Pentium, we are better off not using the
@@ -70,7 +72,7 @@ extern int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
#define __HAVE_ARCH_WCSCPY #define __HAVE_ARCH_WCSCPY
inline wchar_t * wcscpy(wchar_t * dest,const wchar_t *src) extern inline wchar_t * wcscpy(wchar_t * dest,const wchar_t *src)
{ {
__asm__ __volatile__( __asm__ __volatile__(
"cld\n" "cld\n"
@@ -524,7 +526,7 @@ __asm__ __volatile__(
return __res; return __res;
} }
#endif //#endif
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

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

View File

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

View File

@@ -8,12 +8,7 @@ todo: improve debug info
#include <thread.h> #include <thread.h>
WINBASEAPI WINBASEAPI BOOL WINAPI SwitchToThread(VOID )
BOOL
WINAPI
SwitchToThread(
VOID
)
{ {
return NtYieldExecution(); return NtYieldExecution();
} }
@@ -80,4 +75,4 @@ TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
return (FALSE); return (FALSE);
} }
/*************************************************************/ /*************************************************************/

Binary file not shown.

View File

@@ -3,7 +3,7 @@
* PROJECT: ReactOS version of ntdll * PROJECT: ReactOS version of ntdll
* FILE: lib/ntdll/genntdll.c * FILE: lib/ntdll/genntdll.c
* PURPOSE: Generates the system call stubs in ntdll * PURPOSE: Generates the system call stubs in ntdll
* PROGRAMMER: David Welch (welch@welch) * PROGRAMMER: David Welch (welch@mcmail.com)
*/ */
/* INCLUDE ******************************************************************/ /* INCLUDE ******************************************************************/
@@ -19,12 +19,11 @@ int process(FILE* in, FILE* out)
char* s; char* s;
char* name; char* name;
char* value; char* value;
char* nr_args;
fprintf(out,"; Machine generated, don't edit\n");
fprintf(out,"\n\n");
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) while (!feof(in) && fgets(line,255,in)!=NULL)
{ {
fgets(line,255,in); fgets(line,255,in);
@@ -37,12 +36,15 @@ int process(FILE* in, FILE* out)
{ {
name = strtok(s," \t"); name = strtok(s," \t");
value = strtok(NULL," \t"); value = strtok(NULL," \t");
printf("name %s value %s\n",name,value); nr_args = strtok(NULL," \t");
fprintf(out,"NTSTATUS %s(UCHAR first_arg)\n",name); // printf("name %s value %s\n",name,value);
fprintf(out,"{\n");
fprintf(out,"\tMAKE_NTAPI_CALL(%s,first_arg);\n",value); fprintf(out,"%s:\n",name);
fprintf(out,"}\n"); fprintf(out,"\tmov\teax,%s\n",value);
fprintf(out,"\tlea\tedx,[esp+4]\n");
fprintf(out,"\tint\t2Eh\n");
fprintf(out,"\tret\t%s\n\n",nr_args);
} }
} }
} }

View File

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

View File

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

View File

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

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

Binary file not shown.

View File

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

File diff suppressed because it is too large Load Diff

View File

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


View File

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

View File

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

View File

@@ -1,340 +1,340 @@
; ;
; Loads the kernel and any required modules ; Loads the kernel and any required modules
; ;
org 0 org 0
; ;
; Segment where we are loaded ; Segment where we are loaded
; ;
LOADSEG equ 02000h LOADSEG equ 02000h
; ;
; Segment used for temporay storage ; Segment used for temporay storage
; ;
WORKSEG equ 01000h WORKSEG equ 01000h
KERNELBASE equ 05000h KERNELBASE equ 05000h
; ;
; Offsets of work areas ; Offsets of work areas
; ;
FAT_CHAIN equ 0h FAT_CHAIN equ 0h
DIR_BUFFER equ 4000h DIR_BUFFER equ 4000h
END_DIR_BUFFER equ 0ffe0h END_DIR_BUFFER equ 0ffe0h
FAT_SEG equ 03000h FAT_SEG equ 03000h
; ;
; These are all on the stack ; These are all on the stack
; ;
%define oem [bp+3] %define oem [bp+3]
%define bytesPerSector [bp+0bh] %define bytesPerSector [bp+0bh]
%define sectPerCluster [bp+0dh] %define sectPerCluster [bp+0dh]
%define resSectors [bp+0eh] %define resSectors [bp+0eh]
%define nFats [bp+10h] %define nFats [bp+10h]
%define nRootDir [bp+11h] %define nRootDir [bp+11h]
%define nSectors [bp+13h] %define nSectors [bp+13h]
%define MID [bp+15h] %define MID [bp+15h]
%define sectPerFat [bp+16h] %define sectPerFat [bp+16h]
%define sectPerTrack [bp+18h] %define sectPerTrack [bp+18h]
%define nHeads [bp+1ah] %define nHeads [bp+1ah]
%define nHidden [bp+1ch] %define nHidden [bp+1ch]
%define nHidden_hi [bp+1eh] %define nHidden_hi [bp+1eh]
%define nSectorHuge [bp+20h] %define nSectorHuge [bp+20h]
%define drive [bp+24h] %define drive [bp+24h]
%define extBoot [bp+26h] %define extBoot [bp+26h]
%define volid [bp+27h] %define volid [bp+27h]
%define vollabel [bp+2bh] %define vollabel [bp+2bh]
%define filesys 36h %define filesys 36h
RETRYCOUNT equ 5 RETRYCOUNT equ 5
%define fat_start [bp-4] ; first FAT sector %define fat_start [bp-4] ; first FAT sector
%define fat_start_hi [bp-2] %define fat_start_hi [bp-2]
%define root_dir_start [bp-8] ; first root directory sector %define root_dir_start [bp-8] ; first root directory sector
%define root_dir_start_hi [bp-6] %define root_dir_start_hi [bp-6]
%define data_start [bp-12] ; first data sector %define data_start [bp-12] ; first data sector
%define data_start_hi [bp-10] %define data_start_hi [bp-10]
entry: entry:
mov drive,dl mov drive,dl
mov ax,LOADSEG mov ax,LOADSEG
mov ds,ax mov ds,ax
; ;
; Print out a message ; Print out a message
; ;
mov di,loadmsg mov di,loadmsg
call printmsg call printmsg
; ;
; Check here for shift pressed and if so display boot menu ; Check here for shift pressed and if so display boot menu
; ;
; ;
; Load the entire fat ; Load the entire fat
; ;
; mov ax,fat_start ; mov ax,fat_start
; mov dx,fat_start_hi ; mov dx,fat_start_hi
; mov di,sectPerFat ; mov di,sectPerFat
; mov ax,FAT_SEG ; mov ax,FAT_SEG
; mov es,ax ; mov es,ax
; mov bx,0 ; mov bx,0
; call readDisk ; call readDisk
; ;
; Load root directory ; Load root directory
; ;
mov ax,WORKSEG mov ax,WORKSEG
mov es,ax mov es,ax
mov dx,root_dir_start_hi mov dx,root_dir_start_hi
mov ax,root_dir_start mov ax,root_dir_start
mov bx,DIR_BUFFER mov bx,DIR_BUFFER
mov di,nRootDir mov di,nRootDir
shr di,4 shr di,4
mov di,1 mov di,1
call readDisk call readDisk
jc disk_error jc disk_error
; ;
; Look for a directory called boot ; Look for a directory called boot
; ;
mov di,DIR_BUFFER mov di,DIR_BUFFER
cld cld
mov cx,4 mov cx,4
l1: l1:
mov si,boot_dir_name mov si,boot_dir_name
; cmp byte [di],0 ; cmp byte [di],0
; je boot_error ; je boot_error
repe cmpsb repe cmpsb
je found_it je found_it
or di,31 or di,31
inc di inc di
cmp di,END_DIR_BUFFER cmp di,END_DIR_BUFFER
jge boot_error jge boot_error
jmp l1 jmp l1
boot_error: boot_error:
mov di,errormsg mov di,errormsg
call printmsg call printmsg
l3: l3:
jmp l3 jmp l3
disk_error: disk_error:
mov di,errormsg1 mov di,errormsg1
call printmsg call printmsg
jmp l3 jmp l3
found_it: found_it:
mov di,msg1 mov di,msg1
call printmsg call printmsg
; ;
; Load the boot directory found above ; Load the boot directory found above
; ;
sub di,4 sub di,4
call readFile call readFile
l2: l2:
jmp l2 jmp l2
; ;
; readFile ; readFile
; ;
%define file_length [di+01ch] %define file_length [di+01ch]
%define start_cluster [di+01ah] %define start_cluster [di+01ah]
readFile: readFile:
cmp byte extBoot, 29h cmp byte extBoot, 29h
jne fat_12 jne fat_12
cmp byte [bp+filesys+4], '6' ; check for FAT-16 system cmp byte [bp+filesys+4], '6' ; check for FAT-16 system
je fat_16 je fat_16
fat_12: fat_12:
mov di,msg2 mov di,msg2
call printmsg call printmsg
l4: l4:
jmp l4 jmp l4
fat_16: fat_16:
mov di,msg3 mov di,msg3
call printmsg call printmsg
jmp l4 jmp l4
; readDisk: Reads a number of sectors into memory. ; readDisk: Reads a number of sectors into memory.
; ;
; Call with: DX:AX = 32-bit DOS sector number ; Call with: DX:AX = 32-bit DOS sector number
; DI = number of sectors to read ; DI = number of sectors to read
; ES:BX = destination buffer ; ES:BX = destination buffer
; ES must be 64k aligned (1000h, 2000h etc). ; ES must be 64k aligned (1000h, 2000h etc).
; ;
; Returns: CF set on error ; Returns: CF set on error
; ES:BX points one byte after the last byte read. ; ES:BX points one byte after the last byte read.
readDisk: readDisk:
push bp push bp
push si push si
read_next: push dx read_next: push dx
push ax push ax
; ;
; translate sector number to BIOS parameters ; translate sector number to BIOS parameters
; ;
; ;
; abs = sector offset in track ; abs = sector offset in track
; + head * sectPerTrack offset in cylinder ; + head * sectPerTrack offset in cylinder
; + track * sectPerTrack * nHeads offset in platter ; + track * sectPerTrack * nHeads offset in platter
; ;
; t1 = abs / sectPerTrack (ax has t1) ; t1 = abs / sectPerTrack (ax has t1)
; sector = abs mod sectPerTrack (cx has sector) ; sector = abs mod sectPerTrack (cx has sector)
; ;
div word sectPerTrack div word sectPerTrack
mov cx, dx mov cx, dx
; ;
; t1 = head + track * nHeads ; t1 = head + track * nHeads
; ;
; track = t1 / nHeads (ax has track) ; track = t1 / nHeads (ax has track)
; head = t1 mod nHeads (dl has head) ; head = t1 mod nHeads (dl has head)
; ;
xor dx, dx xor dx, dx
div word nHeads div word nHeads
; the following manipulations are necessary in order to ; the following manipulations are necessary in order to
; properly place parameters into registers. ; properly place parameters into registers.
; ch = cylinder number low 8 bits ; ch = cylinder number low 8 bits
; cl = 7-6: cylinder high two bits ; cl = 7-6: cylinder high two bits
; 5-0: sector ; 5-0: sector
mov dh, dl ; save head into dh for bios mov dh, dl ; save head into dh for bios
ror ah, 1 ; move track high bits into ror ah, 1 ; move track high bits into
ror ah, 1 ; bits 7-6 (assumes top = 0) ror ah, 1 ; bits 7-6 (assumes top = 0)
xchg al, ah ; swap for later xchg al, ah ; swap for later
mov dl, byte sectPerTrack mov dl, byte sectPerTrack
sub dl, cl sub dl, cl
inc cl ; sector offset from 1 inc cl ; sector offset from 1
or cx, ax ; merge cylinder into sector or cx, ax ; merge cylinder into sector
mov al, dl ; al has # of sectors left mov al, dl ; al has # of sectors left
; Calculate how many sectors can be transfered in this read ; Calculate how many sectors can be transfered in this read
; due to dma boundary conditions. ; due to dma boundary conditions.
push dx push dx
mov si, di ; temp register save mov si, di ; temp register save
; this computes remaining bytes because of modulo 65536 ; this computes remaining bytes because of modulo 65536
; nature of dma boundary condition ; nature of dma boundary condition
mov ax, bx ; get offset pointer mov ax, bx ; get offset pointer
neg ax ; and convert to bytes neg ax ; and convert to bytes
jz ax_min_1 ; started at seg:0, skip ahead jz ax_min_1 ; started at seg:0, skip ahead
xor dx, dx ; convert to sectors xor dx, dx ; convert to sectors
div word bytesPerSector div word bytesPerSector
cmp ax, di ; check remainder vs. asked cmp ax, di ; check remainder vs. asked
jb ax_min_1 ; less, skip ahead jb ax_min_1 ; less, skip ahead
mov si, ax ; transfer only what we can mov si, ax ; transfer only what we can
ax_min_1: pop dx ax_min_1: pop dx
; Check that request sectors do not exceed track boundary ; Check that request sectors do not exceed track boundary
mov si, sectPerTrack mov si, sectPerTrack
inc si inc si
mov ax, cx ; get the sector/cyl byte mov ax, cx ; get the sector/cyl byte
and ax, 03fh ; and mask out sector and ax, 03fh ; and mask out sector
sub si, ax ; si has how many we can read sub si, ax ; si has how many we can read
mov ax, di mov ax, di
cmp si, di ; see if asked <= available cmp si, di ; see if asked <= available
jge ax_min_2 jge ax_min_2
mov ax, si ; get what can be xfered mov ax, si ; get what can be xfered
ax_min_2: mov si, RETRYCOUNT ax_min_2: mov si, RETRYCOUNT
mov ah, 2 mov ah, 2
mov dl, drive mov dl, drive
retry: push ax retry: push ax
int 13h int 13h
pop ax pop ax
jnc read_ok jnc read_ok
push ax push ax
xor ax, ax ; reset the drive xor ax, ax ; reset the drive
int 13h int 13h
pop ax pop ax
dec si dec si
jnz retry jnz retry
stc stc
pop ax pop ax
pop dx pop dx
pop si pop si
pop bp pop bp
ret ret
read_next_jmp: jmp short read_next read_next_jmp: jmp short read_next
read_ok: xor ah, ah read_ok: xor ah, ah
mov si, ax ; AX = SI = number of sectors read mov si, ax ; AX = SI = number of sectors read
mul word bytesPerSector ; AX = number of bytes read mul word bytesPerSector ; AX = number of bytes read
add bx, ax ; add number of bytes read to BX add bx, ax ; add number of bytes read to BX
jnc no_incr_es ; if overflow... jnc no_incr_es ; if overflow...
mov ax, es mov ax, es
add ah, 10h ; ...add 1000h to ES add ah, 10h ; ...add 1000h to ES
mov es, ax mov es, ax
no_incr_es: pop ax no_incr_es: pop ax
pop dx ; DX:AX = last sector number pop dx ; DX:AX = last sector number
add ax, si add ax, si
adc dx, 0 ; DX:AX = next sector to read adc dx, 0 ; DX:AX = next sector to read
sub di, si ; if there is anything left to read, sub di, si ; if there is anything left to read,
jg read_next_jmp ; continue jg read_next_jmp ; continue
clc clc
pop si pop si
pop bp pop bp
ret ret
; ;
; Print string (DI = start) ; Print string (DI = start)
; ;
printmsg: printmsg:
push ax push ax
push bx push bx
push di push di
mov ah,0eh mov ah,0eh
mov bh,0 mov bh,0
mov bl,07h mov bl,07h
.l1 .l1
mov al,[di] mov al,[di]
cmp al,0 cmp al,0
je .l2 je .l2
inc di inc di
int 10h int 10h
jmp .l1 jmp .l1
.l2 .l2
pop di pop di
pop bx pop bx
pop ax pop ax
ret ret
loadmsg db "Starting ReactOS...",0xd,0xa,0 loadmsg db "Starting ReactOS...",0xd,0xa,0
boot_dir_name db 'BOOT' boot_dir_name db 'BOOT'
errormsg db "Files missing on boot disk",0 errormsg db "Files missing on boot disk",0
errormsg1 db "Disk read error",0 errormsg1 db "Disk read error",0
msg1 db "Found boot directory",0xd,0xa,0 msg1 db "Found boot directory",0xd,0xa,0
msg2 db 'FAT12',0 msg2 db 'FAT12',0
msg3 db 'FAT16',0 msg3 db 'FAT16',0

Binary file not shown.

View File

@@ -1,12 +1,12 @@
Mem layout for osldr Mem layout for osldr
0000 - 07C0 = BIOS data and stack 0000 - 07C0 = BIOS data and stack
07C0 - 1000 = Boot sector 07C0 - 1000 = Boot sector
1000 - 1400 = Tempory storage for fat chains 1000 - 1400 = Tempory storage for fat chains
1400 - 2000 = Tempory storage for directory entries 1400 - 2000 = Tempory storage for directory entries
2000 - 3000 = OSLDR 2000 - 3000 = OSLDR
3000 - 5000 = FAT 3000 - 5000 = FAT
5000 - a000 = Kernel and modules load area 5000 - a000 = Kernel and modules load area

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -1,62 +1,62 @@
# #
# Global makefile # Global makefile
# #
# #
# Select your host # Select your host
# #
#HOST = djgpp-linux #HOST = djgpp-linux
#HOST = mingw32-linux #HOST = mingw32-linux
HOST = djgpp-msdos HOST = djgpp-msdos
#HOST = mingw32-windows #HOST = mingw32-windows
include rules.mak include rules.mak
# #
# Required to run the system # Required to run the system
# #
COMPONENTS = kernel lib COMPONENTS = kernel lib
# #
# Select the loader(s) you want to build # Select the loader(s) you want to build
# #
LOADERS = dos LOADERS = dos
# #
# Select the modules you want # Select the modules you want
# #
MODULES = parallel keyboard MODULES = parallel keyboard
all: $(COMPONENTS) $(LOADERS) $(MODULES) all: $(COMPONENTS) $(LOADERS) $(MODULES)
# #
# Device driver rules # Device driver rules
# #
parallel: dummy parallel: dummy
make -C modules/parallel make -C services/parallel
keyboard: dummy keyboard: dummy
make -C modules/keyboard make -C services/keyboard
mouse: dummy mouse: dummy
make -C modules/mouse make -C services/mouse
# #
# Kernel loaders # Kernel loaders
# #
dos: dummy dos: dummy
make -C loaders/dos make -C loaders/dos
# #
# Required system components # Required system components
# #
kernel: dummy kernel: dummy
make -C kernel make -C ntoskrnl
lib: dummy lib: dummy
make -C lib make -C lib
dummy: dummy:

View File

@@ -5,9 +5,9 @@
# #
# Select your host # Select your host
# #
#HOST = djgpp-linux HOST = djgpp-linux
#HOST = mingw32-linux #HOST = mingw32-linux
HOST = djgpp-msdos #HOST = djgpp-msdos
#HOST = mingw32-windows #HOST = mingw32-windows
include rules.mak include rules.mak
@@ -17,30 +17,46 @@ include rules.mak
# #
COMPONENTS = kernel lib COMPONENTS = kernel lib
#
# Select the server(s) you want to build
#
SERVERS = win32 posix linux os2
# #
# Select the loader(s) you want to build # Select the loader(s) you want to build
# #
LOADERS = dos LOADERS = dos
# #
# Select the modules you want # Select the device drivers and filesystems you want
# #
MODULES = parallel keyboard KERNEL_SERVICES = parallel keyboard null mouse serial sound ide
all: $(COMPONENTS) $(LOADERS) $(MODULES) all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES)
# #
# Device driver rules # Device driver rules
# #
ide: dummy
make -C services/ide
null: dummy
make -C services/null
parallel: dummy parallel: dummy
make -C modules/parallel make -C services/parallel
keyboard: dummy keyboard: dummy
make -C modules/keyboard make -C services/keyboard
mouse: dummy mouse: dummy
make -C modules/mouse make -C services/mouse
serial: dummy
make -C services/serial
sound: dummy
make -C services/sound
# #
# Kernel loaders # Kernel loaders
@@ -54,7 +70,7 @@ dos: dummy
# #
kernel: dummy kernel: dummy
make -C kernel make -C ntoskrnl
lib: dummy lib: dummy
make -C lib make -C lib

View File

@@ -1,20 +1,21 @@
DIRECTORIES DIRECTORIES
system : compiled versions of the various system components and system : compiled versions of the various system components and
libraries libraries
mkernel : microkernel source ntoskrnl : microkernel source
mkernel/hal : hardware abstraction layer source ntoskrnl/hal : hardware abstraction layer source
mkernel/mm : memory managment subsystem source ntoskrnl/mm : memory managment subsystem source
mkernel/iomgr : IO manager subsystem source ntoskrnl/io : IO manager subsystem source
include : win32 headers include : win32 headers
include/internal : kernel private header files include/internal : kernel private header files
include/ntdll : system library private header files include/ntdll : system library private header files
include/kernel32 : system library private header files include/kernel32 : system library private header files
include/user32 : user interface private header files include/user32 : user interface private header files
include/gdi32 : graphics interface private header files include/gdi32 : graphics interface private header files
include/ddk : header files for modules include/ddk : header files for modules
lib/ntdll : NT dll source lib/ntdll : NT dll source
lib/kernel32 : kernel32 source lib/kernel32 : kernel32 source
doc : documentation doc : documentation
loaders/dos : DOS based loader loaders/dos : DOS based loader
loaders/boot : boot loader loaders/boot : boot loader
services : various services (device drivers, filesystems etc)

View File

@@ -42,9 +42,10 @@ endif
# #
# Create variables for all the compiler tools # Create variables for all the compiler tools
# #
DEFINES = -DCHECKED_BUILD -DWIN32_LEAN_AND_MEAN -DDBG
CC = $(PREFIX)gcc CC = $(PREFIX)gcc
NATIVE_CC = gcc NATIVE_CC = gcc
CFLAGS = -O2 -I../../include -I../include -fno-builtin -DCHECKED_BUILD $(DEFINES) -Wall -Wstrict-prototypes CFLAGS = -O2 -I../../include -I../include -fno-builtin $(DEFINES) -Wall -Wstrict-prototypes
CXXFLAGS = $(CFLAGS) CXXFLAGS = $(CFLAGS)
NASM = nasm NASM = nasm
NFLAGS = -i../include/ -f$(NASM_FORMAT) NFLAGS = -i../include/ -f$(NASM_FORMAT)