ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
March 2005
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
26 participants
609 discussions
Start a n
N
ew thread
[hbirr] 14305: Added a missing unlock.
by hbirr@svn.reactos.com
Added a missing unlock. Modified: trunk/reactos/ntoskrnl/mm/RPoolMgr.h _____ Modified: trunk/reactos/ntoskrnl/mm/RPoolMgr.h --- trunk/reactos/ntoskrnl/mm/RPoolMgr.h 2005-03-25 08:31:43 UTC (rev 14304) +++ trunk/reactos/ntoskrnl/mm/RPoolMgr.h 2005-03-25 11:05:10 UTC (rev 14305) @@ -805,8 +805,9 @@ que_reclaimed = 1; goto try_again; } - /*DPRINT1("Trying to allocate %lu bytes from paged pool - nothing suitable found, returning NULL\n", - queBytes );*/ + DPRINT1("Trying to allocate %lu bytes from paged pool - nothing suitable found, returning NULL\n", + queBytes ); + R_RELEASE_MUTEX(pool); return NULL; } /*
19 years, 9 months
1
0
0
0
[gvg] 14304: Get rid of linker warnings
by gvg@svn.reactos.com
Get rid of linker warnings Modified: branches/xen/reactos/boot/freeldr/freeldr/include/multiboot.h _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/include/multiboot.h --- branches/xen/reactos/boot/freeldr/freeldr/include/multiboot.h 2005-03-25 08:26:11 UTC (rev 14303) +++ branches/xen/reactos/boot/freeldr/freeldr/include/multiboot.h 2005-03-25 08:31:43 UTC (rev 14304) @@ -137,8 +137,8 @@ char multiboot_kernel_cmdline[255]; // Command line passed to kernel FRLDR_MODULE multiboot_modules[64]; // Array to hold boot module info loaded for the kernel char multiboot_module_strings[64][256]; // Array to hold module names -unsigned long multiboot_memory_map_descriptor_size; -memory_map_t multiboot_memory_map[32]; // Memory map +extern unsigned long multiboot_memory_map_descriptor_size; +extern memory_map_t multiboot_memory_map[32]; // Memory map void boot_reactos(void);
19 years, 9 months
1
0
0
0
[gvg] 14303: Filip pointed out we can change a compiler option instead of messing around
by gvg@svn.reactos.com
Filip pointed out we can change a compiler option instead of messing around with the source Modified: branches/xen/reactos/boot/freeldr/freeldr/Makefile Modified: branches/xen/reactos/boot/freeldr/freeldr/fs/ntfs.c _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/Makefile --- branches/xen/reactos/boot/freeldr/freeldr/Makefile 2005-03-24 15:53:13 UTC (rev 14302) +++ branches/xen/reactos/boot/freeldr/freeldr/Makefile 2005-03-25 08:26:11 UTC (rev 14303) @@ -86,8 +86,9 @@ $(CP) setupldr.sys $(BOOTCD_DIR)/disk/loader/setupldr.sys +COMPILER_ELF_OPTIONS = -fshort-wchar COMPILER_OPTIONS = -Wall -Werror -nostdlib -ffreestanding -fno-builtin -fno-inline \ - -fno-zero-initialized-in-bss -O1 -MD + -fno-zero-initialized-in-bss -O1 -MD $(COMPILER_ELF_OPTIONS) # FreeLoader does not use any of the standard libraries, includes, or built-in functions ifeq ($(DEBUG),yes) _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/fs/ntfs.c --- branches/xen/reactos/boot/freeldr/freeldr/fs/ntfs.c 2005-03-24 15:53:13 UTC (rev 14302) +++ branches/xen/reactos/boot/freeldr/freeldr/fs/ntfs.c 2005-03-25 08:26:11 UTC (rev 14303) @@ -417,7 +417,6 @@ PNTFS_INDEX_ENTRY IndexEntry, IndexEntryEnd; ULONG RecordOffset; ULONG IndexBlockSize; - static WCHAR wI30[] = {'$','I','3','0',0}; MftRecord = MmAllocateMemory(NtfsMftRecordSize); if (MftRecord == NULL) @@ -429,7 +428,7 @@ { Magic = MftRecord->Magic; - if (!NtfsFindAttribute(&IndexRootCtx, MftRecord, NTFS_ATTR_TYPE_INDEX_ROOT, wI30)) + if (!NtfsFindAttribute(&IndexRootCtx, MftRecord, NTFS_ATTR_TYPE_INDEX_ROOT, L"$I30")) { MmFreeMemory(MftRecord); return FALSE; @@ -469,7 +468,7 @@ IndexBlockSize = IndexRoot->IndexBlockSize; - if (!NtfsFindAttribute(&IndexBitmapCtx, MftRecord, NTFS_ATTR_TYPE_BITMAP, wI30)) + if (!NtfsFindAttribute(&IndexBitmapCtx, MftRecord, NTFS_ATTR_TYPE_BITMAP, L"$I30")) { DbgPrint((DPRINT_FILESYSTEM, "Corrupted filesystem!\n")); MmFreeMemory(MftRecord); @@ -489,7 +488,7 @@ } NtfsReadAttribute(&IndexBitmapCtx, 0, BitmapData, BitmapDataSize); - if (!NtfsFindAttribute(&IndexAllocationCtx, MftRecord, NTFS_ATTR_TYPE_INDEX_ALLOCATION, wI30)) + if (!NtfsFindAttribute(&IndexAllocationCtx, MftRecord, NTFS_ATTR_TYPE_INDEX_ALLOCATION, L"$I30")) { DbgPrint((DPRINT_FILESYSTEM, "Corrupted filesystem!\n")); MmFreeMemory(BitmapData); @@ -570,7 +569,6 @@ UCHAR PathPart[261]; ULONG CurrentMFTIndex; UCHAR i; - static WCHAR wEmpty[] = {0}; DbgPrint((DPRINT_FILESYSTEM, "NtfsLookupFile() FileName = %s\n", FileName)); @@ -599,7 +597,7 @@ return FALSE; } - if (!NtfsFindAttribute(DataContext, MftRecord, NTFS_ATTR_TYPE_DATA, wEmpty)) + if (!NtfsFindAttribute(DataContext, MftRecord, NTFS_ATTR_TYPE_DATA, L"")) { DbgPrint((DPRINT_FILESYSTEM, "NtfsLookupFile: Can't find data attribute\n")); return FALSE; @@ -610,8 +608,6 @@ BOOL NtfsOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector) { - static WCHAR wEmpty[] = {0}; - NtfsBootSector = (PNTFS_BOOTSECTOR)DISKREADBUFFER; DbgPrint((DPRINT_FILESYSTEM, "NtfsOpenVolume() DriveNumber = 0x%x VolumeStartSector = 0x%x\n", DriveNumber, VolumeStartSector)); @@ -675,7 +671,7 @@ RtlCopyMemory(NtfsMasterFileTable, (PCHAR)DISKREADBUFFER, NtfsMftRecordSize); DbgPrint((DPRINT_FILESYSTEM, "Searching for DATA attribute...\n")); - if (!NtfsFindAttribute(&NtfsMFTContext, NtfsMasterFileTable, NTFS_ATTR_TYPE_DATA, wEmpty)) + if (!NtfsFindAttribute(&NtfsMFTContext, NtfsMasterFileTable, NTFS_ATTR_TYPE_DATA, L"")) { FileSystemError("Can't find data attribute for Master File Table."); return FALSE;
19 years, 9 months
1
0
0
0
[gvg] 14302: Build freeldr as elf executable, initial Xen support
by gvg@svn.reactos.com
Build freeldr as elf executable, initial Xen support Modified: branches/xen/reactos/boot/freeldr/freeldr/Makefile Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/arch.S Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/archmach.c Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/boot.S Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/drvmap.S Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386cpu.S Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386pnp.S Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386trap.S Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/int386.S Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/linux.S Added: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c Added: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/mb.S Added: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xencons.c Modified: branches/xen/reactos/boot/freeldr/freeldr/fs/ntfs.c Modified: branches/xen/reactos/boot/freeldr/freeldr/include/rtl.h Modified: branches/xen/reactos/boot/freeldr/freeldr/reactos/reactos.c Added: branches/xen/reactos/include/xen3/ Added: branches/xen/reactos/include/xen3/private/ Added: branches/xen/reactos/include/xen3/private/ctrl_if.h Added: branches/xen/reactos/include/xen3/private/evtchn.h Added: branches/xen/reactos/include/xen3/private/hypervisor.h Added: branches/xen/reactos/include/xen3/private/page.h Added: branches/xen/reactos/include/xen3/private/pgtable.h Added: branches/xen/reactos/include/xen3/public/ Added: branches/xen/reactos/include/xen3/public/COPYING Added: branches/xen/reactos/include/xen3/public/arch-ia64.h Added: branches/xen/reactos/include/xen3/public/arch-x86_32.h Added: branches/xen/reactos/include/xen3/public/arch-x86_64.h Added: branches/xen/reactos/include/xen3/public/dom0_ops.h Added: branches/xen/reactos/include/xen3/public/event_channel.h Added: branches/xen/reactos/include/xen3/public/grant_table.h Added: branches/xen/reactos/include/xen3/public/io/ Added: branches/xen/reactos/include/xen3/public/io/blkif.h Added: branches/xen/reactos/include/xen3/public/io/domain_controller.h Added: branches/xen/reactos/include/xen3/public/io/ioreq.h Added: branches/xen/reactos/include/xen3/public/io/netif.h Added: branches/xen/reactos/include/xen3/public/io/ring.h Added: branches/xen/reactos/include/xen3/public/io/usbif.h Added: branches/xen/reactos/include/xen3/public/physdev.h Added: branches/xen/reactos/include/xen3/public/sched_ctl.h Added: branches/xen/reactos/include/xen3/public/trace.h Added: branches/xen/reactos/include/xen3/public/xen.h Added: branches/xen/reactos/include/xen3/rosxen.h _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/Makefile --- branches/xen/reactos/boot/freeldr/freeldr/Makefile 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/Makefile 2005-03-24 15:53:13 UTC (rev 14302) @@ -21,6 +21,9 @@ include ../rules.mak +CC = gcc +LD = ld + TARGET = i386 ifeq ($(DEBUG),) # Debugging information on (bigger binary) @@ -95,7 +98,13 @@ COMPILER_DEFINES = -D__$(TARGET)__ $(COMPILER_DEBUG_DEFINES) -COMPILER_INCLUDES = -I$(SRCDIR)/include -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include -I$(PATH_TO_TOP)/ntoskrnl/include +COMPILER_INCLUDES = -I$(SRCDIR)/include \ + -I$(PATH_TO_TOP)/w32api/include \ + -I$(PATH_TO_TOP)/include \ + -I$(PATH_TO_TOP)/ntoskrnl/include \ + -I$(PATH_TO_TOP)/include/xen3 \ + -I$(PATH_TO_TOP)/include/xen3/public \ + -I$(PATH_TO_TOP)/include/xen3/private CFLAGS = $(COMPILER_OPTIONS) \ $(COMPILER_DEFINES) \ @@ -106,7 +115,7 @@ LFLAGS = $(LINKER_OPTIONS) ifeq ($(HOST),mingw32-linux) - NASMFLAGS = -f win32 + NASMFLAGS = -f elf else NASMFLAGS = -f elf endif @@ -136,6 +145,7 @@ archmach.o \ machpc.o \ machxbox.o \ + machxen.o \ pccons.o \ pcdisk.o \ pcmem.o \ @@ -148,6 +158,7 @@ xboxmem.o \ xboxrtc.o \ xboxvideo.o \ + xencons.o \ _alloca.o # For Mingw32 builds ARCH_OBJS = $(addprefix i386/,$(ARCH_I386_OBJS)) @@ -264,13 +275,13 @@ freeldr.sys : $(ALL_OBJS) $(PATH_TO_TOP)/dk/w32/lib/librossym.a @echo freeldr: LINKING $@ - @$(LD) $(LFLAGS) -o freeldr.exe $(F_OBJS) $(PATH_TO_TOP)/dk/w32/lib/librossym.a + @$(LD) $(LFLAGS) -o freeldr.elf $(F_OBJS) $(PATH_TO_TOP)/dk/w32/lib/librossym.a ifeq ($(FULL_MAP),yes) - @$(OBJDUMP) -d -S freeldr.exe > freeldr.map + @$(OBJDUMP) -d -S freeldr.elf > freeldr.map else - @$(NM) --numeric-sort freeldr.exe > freeldr.map + @$(NM) --numeric-sort freeldr.elf > freeldr.map endif - @$(OBJCOPY) -O binary freeldr.exe freeldr.sys + @$(OBJCOPY) -O binary freeldr.elf freeldr.sys setupldr.sys : $(ALL_OBJS) _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/arch.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/arch.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/arch.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -47,15 +47,15 @@ .code32 /* Store the boot drive */ - movb %dl,(_BootDrive) + movb %dl,(BootDrive) /* Store the boot partition */ - movb %dh,(_BootPartition) + movb %dh,(BootPartition) /* GO! */ xorl %eax,%eax pushl %eax - call _BootMain + call BootMain call switch_to_real .code16 @@ -222,7 +222,7 @@ /* * Enable the A20 address line (to allow access to over 1mb) */ -EXTERN(_EnableA20) +EXTERN(EnableA20) .code32 pushal @@ -247,7 +247,7 @@ /* * Disable the A20 address line */ -EXTERN(_DisableA20) +EXTERN(DisableA20) .code32 pushal @@ -304,12 +304,14 @@ .long INITIAL_BASE + MultibootHeader - FREELDR_BASE /* load_addr */ .long INITIAL_BASE +#ifdef TODO /* load_end_addr */ .long INITIAL_BASE + __bss_start__ - FREELDR_BASE /* bss_end_addr */ .long INITIAL_BASE + __bss_end__ - FREELDR_BASE /* entry_addr */ .long INITIAL_BASE + MultibootEntry - FREELDR_BASE +#endif MultibootEntry: cli /* Even after setting up the our IDT below we are @@ -331,7 +333,9 @@ /* Copy to low mem */ movl $INITIAL_BASE,%esi movl $FREELDR_BASE,%edi +#ifdef TODO movl $(__bss_end__ - FREELDR_BASE),%ecx +#endif addl $3,%ecx shrl $2,%ecx rep movsl @@ -365,12 +369,12 @@ movl MB_INFO_BOOT_DEVICE_OFFSET(%ebx),%eax shrl $16,%eax incb %al - movb %al,_BootPartition - movb %ah,_BootDrive + movb %al,BootPartition + movb %ah,BootDrive jmp mb4 mb3: /* No boot device known, assume first partition of first harddisk */ - movb $0x80,_BootDrive - movb $1,_BootPartition + movb $0x80,BootDrive + movb $1,BootPartition mb4: /* Check for a command line */ @@ -389,7 +393,7 @@ /* GO! */ pushl %eax - call _BootMain + call BootMain mbfail: call switch_to_real .code16 @@ -462,8 +466,8 @@ .word 0x3ff /* Limit */ .long 0 /* Base Address */ -EXTERN(_BootDrive) +EXTERN(BootDrive) .long 0 -EXTERN(_BootPartition) +EXTERN(BootPartition) .long 0 _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/archmach.c --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/archmach.c 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/archmach.c 2005-03-24 15:53:13 UTC (rev 14302) @@ -22,6 +22,7 @@ #include "machine.h" #include "machpc.h" #include "machxbox.h" +#include "machxen.h" #include "portio.h" #include "hardware.h" #include "rtl.h" @@ -33,20 +34,28 @@ memset(&MachVtbl, 0, sizeof(MACHVTBL)); - /* Check for Xbox by identifying device at PCI 0:0:0, if it's - * 0x10de/0x02a5 then we're running on an Xbox */ - WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0)); - PciId = READ_PORT_ULONG((ULONG*) 0xcfc); - if (0x02a510de == PciId) + /* First check if we were launched by Xen */ + if (XenActive) { - XboxMachInit(); + XenMachInit(); } else { - PcMachInit(); + /* Check for Xbox by identifying device at PCI 0:0:0, if it's + * 0x10de/0x02a5 then we're running on an Xbox */ + WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0)); + PciId = READ_PORT_ULONG((ULONG*) 0xcfc); + if (0x02a510de == PciId) + { + XboxMachInit(); + } + else + { + PcMachInit(); + } } - HalpCalibrateStallExecution(); +// HalpCalibrateStallExecution(); } /* EOF */ _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/boot.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/boot.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/boot.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -24,14 +24,14 @@ #include <arch.h> -EXTERN(_ChainLoadBiosBootSectorCode) +EXTERN(ChainLoadBiosBootSectorCode) .code32 call switch_to_real .code16 /* Set the boot drive */ - movb (_BootDrive),%dl + movb (BootDrive),%dl /* Load segment registers */ cli @@ -45,7 +45,7 @@ ljmpl $0x0000,$0x7C00 -EXTERN(_SoftReboot) +EXTERN(SoftReboot) .code32 call switch_to_real _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/drvmap.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/drvmap.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/drvmap.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -24,7 +24,7 @@ #include <arch.h> -EXTERN(_DriveMapInt13HandlerStart) +EXTERN(DriveMapInt13HandlerStart) Int13Handler: pushw %bp @@ -82,7 +82,7 @@ /* Call old int 13h handler with new drive number */ .byte 0x9a /* lcall */ -EXTERN(_DriveMapOldInt13HandlerAddress) +EXTERN(DriveMapOldInt13HandlerAddress) .word 0 .word 0 @@ -105,7 +105,7 @@ PassedInDriveNumber: .byte 0 -EXTERN(_DriveMapInt13HandlerMapList) +EXTERN(DriveMapInt13HandlerMapList) Int13HandlerMapCount: .byte 0 @@ -129,4 +129,4 @@ Int13HandlerDriveNew4: .byte 0 -EXTERN(_DriveMapInt13HandlerEnd) +EXTERN(DriveMapInt13HandlerEnd) _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386cpu.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386cpu.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386cpu.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -33,7 +33,7 @@ * 0x00000400: Found 80486 CPU without CPUID support */ -EXTERN(_CpuidSupported) +EXTERN(CpuidSupported) .code32 pushl %ecx /* save ECX */ @@ -80,7 +80,7 @@ * VOID GetCpuid(U32 Level, U32 *eax, U32 *ebx, U32 *ecx, U32 *edx); */ -EXTERN(_GetCpuid) +EXTERN(GetCpuid) .code32 pushl %ebp @@ -123,7 +123,7 @@ * U64 RDTSC(VOID); */ -EXTERN(_RDTSC) +EXTERN(RDTSC) .code32 rdtsc ret _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386pnp.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386pnp.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386pnp.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -35,7 +35,7 @@ _pnp_bios_data_segment: .word 0 -EXTERN(_PnpBiosSupported) +EXTERN(PnpBiosSupported) .code32 pushl %edi @@ -113,7 +113,7 @@ _pnp_node_count: .word 0 -EXTERN(_PnpBiosGetDeviceNodeCount) +EXTERN(PnpBiosGetDeviceNodeCount) .code32 pushl %ebp @@ -182,7 +182,7 @@ _pnp_node_number: .byte 0 -EXTERN(_PnpBiosGetDeviceNode) +EXTERN(PnpBiosGetDeviceNode) .code32 pushl %ebp _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386trap.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386trap.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/i386trap.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -273,7 +273,7 @@ SAVE_CPU_REGS pushl $SCREEN_ATTR - call _MachVideoClearScreen + call MachVideoClearScreen add $4,%esp movl $i386ExceptionHandlerText,%esi @@ -485,7 +485,7 @@ pushl $SCREEN_ATTR andl $0xff,%eax pushl %eax - call _MachVideoPutChar + call MachVideoPutChar addl $16,%esp ret @@ -737,7 +737,7 @@ /*********************************************************************** * * DEBUGGING SUPPORT FUNCTIONS ************************************************************************ / -EXTERN(_INSTRUCTION_BREAKPOINT1) +EXTERN(INSTRUCTION_BREAKPOINT1) .code32 pushl %eax @@ -754,7 +754,7 @@ ret -EXTERN(_MEMORY_READWRITE_BREAKPOINT1) +EXTERN(MEMORY_READWRITE_BREAKPOINT1) .code32 pushl %eax @@ -771,7 +771,7 @@ ret -EXTERN(_MEMORY_WRITE_BREAKPOINT1) +EXTERN(MEMORY_WRITE_BREAKPOINT1) .code32 pushl %eax @@ -788,7 +788,7 @@ ret -EXTERN(_INSTRUCTION_BREAKPOINT2) +EXTERN(INSTRUCTION_BREAKPOINT2) .code32 pushl %eax @@ -805,7 +805,7 @@ ret -EXTERN(_MEMORY_READWRITE_BREAKPOINT2) +EXTERN(MEMORY_READWRITE_BREAKPOINT2) .code32 pushl %eax @@ -822,7 +822,7 @@ ret -EXTERN(_MEMORY_WRITE_BREAKPOINT2) +EXTERN(MEMORY_WRITE_BREAKPOINT2) .code32 pushl %eax @@ -839,7 +839,7 @@ ret -EXTERN(_INSTRUCTION_BREAKPOINT3) +EXTERN(INSTRUCTION_BREAKPOINT3) .code32 pushl %eax @@ -856,7 +856,7 @@ ret -EXTERN(_MEMORY_READWRITE_BREAKPOINT3) +EXTERN(MEMORY_READWRITE_BREAKPOINT3) .code32 pushl %eax @@ -873,7 +873,7 @@ ret -EXTERN(_MEMORY_WRITE_BREAKPOINT3) +EXTERN(MEMORY_WRITE_BREAKPOINT3) .code32 pushl %eax @@ -890,7 +890,7 @@ ret -EXTERN(_INSTRUCTION_BREAKPOINT4) +EXTERN(INSTRUCTION_BREAKPOINT4) .code32 pushl %eax @@ -907,7 +907,7 @@ ret -EXTERN(_MEMORY_READWRITE_BREAKPOINT4) +EXTERN(MEMORY_READWRITE_BREAKPOINT4) .code32 pushl %eax @@ -924,7 +924,7 @@ ret -EXTERN(_MEMORY_WRITE_BREAKPOINT4) +EXTERN(MEMORY_WRITE_BREAKPOINT4) .code32 pushl %eax _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/int386.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/int386.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/int386.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -62,7 +62,7 @@ /* * int Int386(int ivec, REGS* in, REGS* out); */ -EXTERN(_Int386) +EXTERN(Int386) .code32 /* Get the function parameters */ _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/linux.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/linux.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/linux.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -25,12 +25,12 @@ .code32 -EXTERN(_BootNewLinuxKernel) +EXTERN(BootNewLinuxKernel) call switch_to_real .code16 /* Set the boot drive */ - movb (_BootDrive),%dl + movb (BootDrive),%dl /* Load segment registers */ cli @@ -49,7 +49,7 @@ /* * VOID BootOldLinuxKernel(ULONG KernelSize); */ -EXTERN(_BootOldLinuxKernel) +EXTERN(BootOldLinuxKernel) /* First we have to copy the kernel down from 0x100000 to 0x10000 */ /* The reason we can overwrite low memory is because this code */ @@ -66,7 +66,7 @@ .code16 /* Set the boot drive */ - movb (_BootDrive),%dl + movb (BootDrive),%dl /* Load segment registers */ cli _____ Added: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c 2005-03-24 15:53:13 UTC (rev 14302) @@ -0,0 +1,296 @@ +/* $Id: machpc.c 12672 2005-01-01 00:42:18Z chorns $ + * + * FreeLoader + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Based on code posted by David Becker <becker(a)cs.duke.edu> to the + * xen-devel mailing list. + */ + +#include "freeldr.h" +#include "machxen.h" + +#include <rosxen.h> +#include <xen.h> +#include <hypervisor.h> +#include <page.h> +#include <pgtable.h> + +BOOL XenActive = FALSE; +ctrl_front_ring_t XenCtrlIfTxRing; +ctrl_back_ring_t XenCtrlIfRxRing; +int XenCtrlIfEvtchn; + +VOID +XenMachInit(VOID) +{ + /* Setup vtbl */ + MachVtbl.ConsPutChar = XenConsPutChar; + MachVtbl.ConsKbHit = XenConsKbHit; + MachVtbl.ConsGetCh = XenConsGetCh; + MachVtbl.VideoClearScreen = XenVideoClearScreen; + MachVtbl.VideoSetDisplayMode = XenVideoSetDisplayMode; + MachVtbl.VideoGetDisplaySize = XenVideoGetDisplaySize; + MachVtbl.VideoGetBufferSize = XenVideoGetBufferSize; + MachVtbl.VideoSetTextCursorPosition = XenVideoSetTextCursorPosition; + MachVtbl.VideoSetTextCursorPosition = XenVideoSetTextCursorPosition; + MachVtbl.VideoHideShowTextCursor = XenVideoHideShowTextCursor; + MachVtbl.VideoPutChar = XenVideoPutChar; + MachVtbl.VideoCopyOffScreenBufferToVRAM = XenVideoCopyOffScreenBufferToVRAM; + MachVtbl.VideoIsPaletteFixed = XenVideoIsPaletteFixed; + MachVtbl.VideoSetPaletteColor = XenVideoSetPaletteColor; + MachVtbl.VideoGetPaletteColor = XenVideoGetPaletteColor; + MachVtbl.VideoSync = XenVideoSync; + MachVtbl.VideoPrepareForReactOS = XenVideoPrepareForReactOS; + MachVtbl.GetMemoryMap = XenMemGetMemoryMap; + MachVtbl.DiskReadLogicalSectors = XenDiskReadLogicalSectors; + MachVtbl.DiskGetPartitionEntry = XenDiskGetPartitionEntry; + MachVtbl.DiskGetDriveGeometry = XenDiskGetDriveGeometry; + MachVtbl.DiskGetCacheableBlockCount = XenDiskGetCacheableBlockCount; + MachVtbl.RTCGetCurrentDateTime = XenRTCGetCurrentDateTime; + MachVtbl.HwDetect = XenHwDetect; +} + +start_info_t *HYPERVISOR_start_info; +extern char shared_info[PAGE_SIZE]; + +/* _start is the default name ld will use as the entry point. When xen + * loads the domain, it will start execution at the elf entry point. */ + +void _start() +{ + pgd_t *pgd; + int ptetab_ma; + int idx; + int pte_ma; + mmu_update_t req; + control_if_t *CtrlIf; + + /* + * Grab start_info + */ + /* The linux build setup_guest() put a start_info_t* into %esi. + * =S is inline asm code for get output from reg %esi. + */ + asm("":"=S" (HYPERVISOR_start_info)); + + /* To write to the xen virtual console, we need to map in the + * shared page used by the the domain controller interface. The + * HYPERVISOR_start_info struct identifies the page table and + * shared_info pages. + * + * The following code maps the shared_info mfn (machine frame number) + * into this domains address space over the shared_info[] page. + */ + + + /* + * map shared_info page + */ + /* The pgd page (page global directory - level 2 page table) is + * constructed by setup_guest() in tools/libxc/xc_linux_build.c + * Lookup the machine address of ptetab in pgd to construct the + * machine address of the pte entry for shared_info, + * and then call mmu_update to change mapping. + */ + pgd = (pgd_t*)HYPERVISOR_start_info->pt_base; + ptetab_ma = pgd_val(pgd[pgd_index((unsigned long)shared_info)]) + & (PAGE_MASK); + idx = pte_index((unsigned long)shared_info); + pte_ma = ptetab_ma + (idx*sizeof(pte_t)); + + req.ptr = pte_ma; + req.val = HYPERVISOR_start_info->shared_info|7; + HYPERVISOR_mmu_update(&req, 1, NULL); + + /* + * Setup control interface + */ + XenCtrlIfEvtchn = HYPERVISOR_start_info->domain_controller_evtchn; + CtrlIf = ((control_if_t *)((char *)shared_info + 2048)); + + /* Sync up with shared indexes. */ + FRONT_RING_ATTACH(&XenCtrlIfTxRing, &CtrlIf->tx_ring); + BACK_RING_ATTACH(&XenCtrlIfRxRing, &CtrlIf->rx_ring); + + /* Start freeldr */ + XenActive = TRUE; + BootMain(NULL); +} + +#define XEN_UNIMPLEMENTED(routine) \ + printf(routine " unimplemented. Shutting down\n"); \ + HYPERVISOR_shutdown() + +BOOL +XenConsKbHit() + { + XEN_UNIMPLEMENTED("XenConsKbHit"); + return FALSE; + } + +int +XenConsGetCh() + { + XEN_UNIMPLEMENTED("XenConsGetCh"); + return 0; + } + +VOID +XenVideoClearScreen(UCHAR Attr) + { + XEN_UNIMPLEMENTED("XenVideoClearScreen"); + } + +VIDEODISPLAYMODE +XenVideoSetDisplayMode(char *DisplayMode, BOOL Init) + { + XEN_UNIMPLEMENTED("XenVideoSetDisplayMode"); + return VideoTextMode; + } + +VOID +XenVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth) + { + XEN_UNIMPLEMENTED("XenVideoGetDisplaySize"); + } + +ULONG +XenVideoGetBufferSize(VOID) + { + XEN_UNIMPLEMENTED("XenVideoGetBufferSize"); + return 0; + } + +VOID +XenVideoSetTextCursorPosition(ULONG X, ULONG Y) + { + XEN_UNIMPLEMENTED("XenVideoSetTextCursorPosition"); + } + +VOID +XenVideoHideShowTextCursor(BOOL Show) + { + XEN_UNIMPLEMENTED("XenVideoHideShowTextCursor"); + } + +VOID +XenVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y) + { + XEN_UNIMPLEMENTED("XenVideoPutChar"); + } + +VOID +XenVideoCopyOffScreenBufferToVRAM(PVOID Buffer) + { + XEN_UNIMPLEMENTED("XenVideoCopyOffScreenBufferToVRAM"); + } + +BOOL +XenVideoIsPaletteFixed(VOID) + { + XEN_UNIMPLEMENTED("XenVideoIsPaletteFixed"); + return TRUE; + } + +VOID +XenVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue) + { + XEN_UNIMPLEMENTED("XenVideoSetPaletteColor"); + } + +VOID +XenVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue) + { + XEN_UNIMPLEMENTED("XenVideoGetPaletteColor"); + } + +VOID +XenVideoSync(VOID) + { + XEN_UNIMPLEMENTED("XenVideoSync"); + } + +VOID +XenVideoPrepareForReactOS(VOID) + { + XEN_UNIMPLEMENTED("XenVideoPrepareForReactOS"); + } + +ULONG +XenMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize) + { + XEN_UNIMPLEMENTED("XenMemGetMemoryMap"); + return 0; + } + +BOOL +XenDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, + ULONG SectorCount, PVOID Buffer) + { + XEN_UNIMPLEMENTED("XenDiskReadLogicalSectors"); + return FALSE; + } + +BOOL +XenDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, + PPARTITION_TABLE_ENTRY PartitionTableEntry) + { + XEN_UNIMPLEMENTED("XenDiskGetPartitionEntry"); + return FALSE; + } + +BOOL +XenDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry) + { + XEN_UNIMPLEMENTED("XenDiskGetDriveGeometry"); + return FALSE; + } + +ULONG +XenDiskGetCacheableBlockCount(ULONG DriveNumber) + { + XEN_UNIMPLEMENTED("XenDiskGetCacheableBlockCount"); + return FALSE; + } + +VOID +XenRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, + PULONG Hour, PULONG Minute, PULONG Second) + { + XEN_UNIMPLEMENTED("XenRTCGetCurrentDateTime"); + } + +VOID +XenHwDetect(VOID) + { + XEN_UNIMPLEMENTED("XenHwDetect"); + } + +/* Create shared_info page. This page is mapped over by the real shared + * info page + */ +asm(".align 0x1000; shared_info:;.skip 0x1000;"); + + +/* emit the elf segment Xen builder expects in kernel image */ asm(".section __xen_guest;" + ".ascii \"GUEST_OS=linux,GUEST_VER=2.6,XEN_VER=3.0,VIRT_BASE=0x00008000\";" + ".ascii \",LOADER=generic\";" + ".ascii \",PT_MODE_WRITABLE\";" + ".byte 0;" + ); + +/* EOF */ Property changes on: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.c ___________________________________________________________________ Name: svn:eol-style + native _____ Added: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h 2005-03-24 15:53:13 UTC (rev 14302) @@ -0,0 +1,70 @@ +/* + * FreeLoader + * + * Copyright (C) 2003 Eric Kohl + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __I386_MACHXEN_H_ +#define __I386_MACHXEN_H_ + +#ifndef __MEMORY_H +#include "mm.h" +#endif + +#include <rosxen.h> +#include <xen.h> +#include <io/domain_controller.h> + +extern BOOL XenActive; +extern ctrl_front_ring_t XenCtrlIfTxRing; +extern ctrl_back_ring_t XenCtrlIfRxRing; +extern int XenCtrlIfEvtchn; + +VOID XenMachInit(VOID); + +VOID XenConsPutChar(int Ch); +BOOL XenConsKbHit(); +int XenConsGetCh(); + +VOID XenVideoClearScreen(UCHAR Attr); +VIDEODISPLAYMODE XenVideoSetDisplayMode(char *DisplayMode, BOOL Init); +VOID XenVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth); +ULONG XenVideoGetBufferSize(VOID); +VOID XenVideoSetTextCursorPosition(ULONG X, ULONG Y); +VOID XenVideoHideShowTextCursor(BOOL Show); +VOID XenVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y); +VOID XenVideoCopyOffScreenBufferToVRAM(PVOID Buffer); +BOOL XenVideoIsPaletteFixed(VOID); +VOID XenVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue); +VOID XenVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue); +VOID XenVideoSync(VOID); +VOID XenVideoPrepareForReactOS(VOID); + +ULONG XenMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize); + +BOOL XenDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); +BOOL XenDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); +BOOL XenDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry); +ULONG XenDiskGetCacheableBlockCount(ULONG DriveNumber); + +VOID XenRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second); + +VOID XenHwDetect(VOID); + +#endif /* __I386_MACHPC_H_ */ + +/* EOF */ Property changes on: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/machxen.h ___________________________________________________________________ Name: svn:eol-style + native _____ Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/mb.S --- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/mb.S 2005-03-24 15:41:06 UTC (rev 14301) +++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/mb.S 2005-03-24 15:53:13 UTC (rev 14302) @@ -29,75 +29,75 @@ * This boots the kernel */ .code32 - .globl _PageDirectoryStart + .globl PageDirectoryStart - .globl _startup_pagedirectory - .globl _lowmem_pagetable - .globl _kernel_pagetable - .globl _hyperspace_pagetable - .globl _apic_pagetable - .globl _kpcr_pagetable + .globl startup_pagedirectory + .globl lowmem_pagetable + .globl kernel_pagetable + .globl hyperspace_pagetable + .globl apic_pagetable + .globl kpcr_pagetable - .globl _startup_pagedirectorytable_pae - .globl _startup_pagedirectory_pae - .globl _lowmem_pagetable_pae - .globl _kernel_pagetable_pae - .globl _hyperspace_pagetable_pae - .globl _apic_pagetable_pae - .globl _kpcr_pagetable_pae + .globl startup_pagedirectorytable_pae + .globl startup_pagedirectory_pae + .globl lowmem_pagetable_pae + .globl kernel_pagetable_pae + .globl hyperspace_pagetable_pae + .globl apic_pagetable_pae + .globl kpcr_pagetable_pae - .globl _PageDirectoryEnd + .globl PageDirectoryEnd // // Boot information structure // -EXTERN(_multiboot_memory_map_descriptor_size) +EXTERN(multiboot_memory_map_descriptor_size) .long 0 -EXTERN(_multiboot_memory_map) +EXTERN(multiboot_memory_map) .rept (32 * /*sizeof(memory_map_t)*/24) .byte 0 .endr .bss -_PageDirectoryStart: -_startup_pagedirectory: +PageDirectoryStart: +startup_pagedirectory: .fill 4096, 1, 0 -_lowmem_pagetable: +lowmem_pagetable: .fill 4096, 1, 0 -_kernel_pagetable: +kernel_pagetable: .fill 2*4096, 1, 0 -_hyperspace_pagetable: +hyperspace_pagetable: .fill 4096, 1, 0 -_apic_pagetable: +apic_pagetable: .fill 4096, 1, 0 -_kpcr_pagetable: +kpcr_pagetable: .fill 4096, 1, 0 [truncated at 1000 lines; 4635 more skipped]
19 years, 9 months
1
0
0
0
[gvg] 14301: Import trunk
by gvg@svn.reactos.com
Import trunk Added: branches/xen/reactos/ _____ Copied: branches/xen/reactos (from rev 14300, trunk/reactos)
19 years, 9 months
1
0
0
0
[gvg] 14300: Start Xen branch
by gvg@svn.reactos.com
Start Xen branch Added: branches/xen/
19 years, 9 months
1
0
0
0
[navaraf] 14299: Fix compilation.
by navaraf@svn.reactos.com
Fix compilation. Modified: trunk/reactos/drivers/net/tcpip/tcpip/iinfo.c _____ Modified: trunk/reactos/drivers/net/tcpip/tcpip/iinfo.c --- trunk/reactos/drivers/net/tcpip/tcpip/iinfo.c 2005-03-24 10:46:52 UTC (rev 14298) +++ trunk/reactos/drivers/net/tcpip/tcpip/iinfo.c 2005-03-24 13:17:23 UTC (rev 14299) @@ -104,7 +104,7 @@ TDIEntityID *id, PCHAR Buffer, UINT BufferSize ) { - TI_DbgPrint("Got Request: Class %x Type %x Id %x, EntityID %x:%x\n", - InfoClass, InfoId, id->tei_entity, id->tei_instance); + TI_DbgPrint(MAX_TRACE, ("Got Request: Class %x Type %x Id %x, EntityID %x:%x\n", + InfoClass, InfoId, id->tei_entity, id->tei_instance)); return TDI_INVALID_REQUEST; }
19 years, 9 months
1
0
0
0
[arty] 14298: This is change 1 of 2.
by arty@svn.reactos.com
This is change 1 of 2. AddIPAddress and DeleteIPAddress are now implemented all the way down. Next we need the dhcp service live enough to assign the address from userland, then we can remove the IP address setting from the kernel. Modified: trunk/reactos/drivers/lib/ip/network/ip.c Modified: trunk/reactos/drivers/net/tcpip/include/dispatch.h Modified: trunk/reactos/drivers/net/tcpip/include/ip.h Modified: trunk/reactos/drivers/net/tcpip/include/ticonsts.h Modified: trunk/reactos/drivers/net/tcpip/tcpip/dispatch.c Modified: trunk/reactos/drivers/net/tcpip/tcpip/iinfo.c Modified: trunk/reactos/drivers/net/tcpip/tcpip/main.c Modified: trunk/reactos/include/tcpioctl.h Modified: trunk/reactos/lib/iphlpapi/ifenum_reactos.c Modified: trunk/reactos/lib/iphlpapi/iphlpapi_main.c Modified: trunk/reactos/lib/iphlpapi/iphlpapi_private.h _____ Modified: trunk/reactos/drivers/lib/ip/network/ip.c --- trunk/reactos/drivers/lib/ip/network/ip.c 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/drivers/lib/ip/network/ip.c 2005-03-24 10:46:52 UTC (rev 14298) @@ -244,13 +244,29 @@ */ { KIRQL OldIrql; + UINT ChosenIndex = 1; + BOOLEAN IndexHasBeenChosen; IP_ADDRESS NetworkAddress; PNEIGHBOR_CACHE_ENTRY NCE; + IF_LIST_ITER(Interface); TI_DbgPrint(MID_TRACE, ("Called. IF (0x%X).\n", IF)); TcpipAcquireSpinLock(&IF->Lock, &OldIrql); + /* Choose an index */ + do { + IndexHasBeenChosen = TRUE; + ForEachInterface(Interface) { + if( Interface->Index == ChosenIndex ) { + ChosenIndex++; + IndexHasBeenChosen = FALSE; + } + } EndFor(Interface); + } while( !IndexHasBeenChosen ); + + IF->Index = ChosenIndex; + /* Add a permanent neighbor for this NTE */ NCE = NBAddNeighbor(IF, &IF->Unicast, IF->Address, IF->AddressLength, _____ Modified: trunk/reactos/drivers/net/tcpip/include/dispatch.h --- trunk/reactos/drivers/net/tcpip/include/dispatch.h 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/drivers/net/tcpip/include/dispatch.h 2005-03-24 10:46:52 UTC (rev 14298) @@ -56,6 +56,14 @@ PIRP Irp, PIO_STACK_LOCATION IrpSp); +NTSTATUS DispTdiSetIPAddress( + PIRP Irp, + PIO_STACK_LOCATION IrpSp); + +NTSTATUS DispTdiDeleteIPAddress( + PIRP Irp, + PIO_STACK_LOCATION IrpSp); + #endif /* __DISPATCH_H */ /* EOF */ _____ Modified: trunk/reactos/drivers/net/tcpip/include/ip.h --- trunk/reactos/drivers/net/tcpip/include/ip.h 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/drivers/net/tcpip/include/ip.h 2005-03-24 10:46:52 UTC (rev 14298) @@ -153,10 +153,16 @@ UNICODE_STRING Name; /* Adapter name */ PUCHAR Address; /* Pointer to interface address */ UINT AddressLength; /* Length of address in bytes */ + UINT Index; /* Index of adapter (used to add ip addr) */ LL_TRANSMIT_ROUTINE Transmit; /* Pointer to transmit function */ PVOID TCPContext; /* TCP Content for this interface */ } IP_INTERFACE, *PIP_INTERFACE; +typedef struct _IP_SET_ADDRESS { + ULONG NteIndex; + IPv4_RAW_ADDRESS Address; + IPv4_RAW_ADDRESS Netmask; +} IP_SET_ADDRESS, *PIP_SET_ADDRESS; #define IP_PROTOCOL_TABLE_SIZE 0x100 _____ Modified: trunk/reactos/drivers/net/tcpip/include/ticonsts.h --- trunk/reactos/drivers/net/tcpip/include/ticonsts.h 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/drivers/net/tcpip/include/ticonsts.h 2005-03-24 10:46:52 UTC (rev 14298) @@ -45,6 +45,12 @@ #define IOCTL_TCP_SET_INFORMATION_EX \ _TCP_CTL_CODE(1, METHOD_BUFFERED, FILE_WRITE_ACCESS) +#define IOCTL_SET_IP_ADDRESS \ + _TCP_CTL_CODE(14, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define IOCTL_DELETE_IP_ADDRESS \ + _TCP_CTL_CODE(16, METHOD_BUFFERED, FILE_WRITE_ACCESS) + /* Unique error values for log entries */ #define TI_ERROR_DRIVERENTRY 0 _____ Modified: trunk/reactos/drivers/net/tcpip/tcpip/dispatch.c --- trunk/reactos/drivers/net/tcpip/tcpip/dispatch.c 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/drivers/net/tcpip/tcpip/dispatch.c 2005-03-24 10:46:52 UTC (rev 14298) @@ -1465,4 +1465,56 @@ return Status; } +/* TODO: Support multiple addresses per interface. + * For now just set the nte context to the interface index. + * + * Later on, create an NTE context and NTE instance + */ + +NTSTATUS DispTdiSetIPAddress( PIRP Irp, PIO_STACK_LOCATION IrpSp ) { + NTSTATUS Status = STATUS_DEVICE_DOES_NOT_EXIST; + PIP_SET_ADDRESS IpAddrChange = + (PIP_SET_ADDRESS)Irp->AssociatedIrp.SystemBuffer; + IF_LIST_ITER(IF); + + ForEachInterface(IF) { + if( IF->Unicast.Address.IPv4Address == IpAddrChange->Address ) { + Status = STATUS_DUPLICATE_OBJECTID; + break; + } + if( IF->Index == IpAddrChange->NteIndex ) { + IF->Unicast.Type = IP_ADDRESS_V4; + IF->Unicast.Address.IPv4Address = IpAddrChange->Address; + IF->Netmask.Type = IP_ADDRESS_V4; + IF->Netmask.Address.IPv4Address = IpAddrChange->Netmask; + IpAddrChange->Address = IF->Index; + Status = STATUS_SUCCESS; + Irp->IoStatus.Information = IF->Index; + break; + } + } EndFor(IF); + + Irp->IoStatus.Status = Status; + return Status; +} + +NTSTATUS DispTdiDeleteIPAddress( PIRP Irp, PIO_STACK_LOCATION IrpSp ) { + NTSTATUS Status = STATUS_UNSUCCESSFUL; + PUSHORT NteIndex = Irp->AssociatedIrp.SystemBuffer; + IF_LIST_ITER(IF); + + ForEachInterface(IF) { + if( IF->Index == *NteIndex ) { + IF->Unicast.Type = IP_ADDRESS_V4; + IF->Unicast.Address.IPv4Address = 0; + IF->Netmask.Type = IP_ADDRESS_V4; + IF->Netmask.Address.IPv4Address = 0; + Status = STATUS_SUCCESS; + } + } EndFor(IF); + + Irp->IoStatus.Status = Status; + return Status; +} + /* EOF */ _____ Modified: trunk/reactos/drivers/net/tcpip/tcpip/iinfo.c --- trunk/reactos/drivers/net/tcpip/tcpip/iinfo.c 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/drivers/net/tcpip/tcpip/iinfo.c 2005-03-24 10:46:52 UTC (rev 14298) @@ -33,7 +33,7 @@ RtlZeroMemory( OutData, sizeof(IFENTRY) + MAX_IFDESCR_LEN ); - OutData->Index = ID->tei_instance + 1; + OutData->Index = Interface->Index; /* viz: tcpip keeps those indices */ OutData->Type = Interface == Loopback ? MIB_IF_TYPE_LOOPBACK : MIB_IF_TYPE_ETHERNET; @@ -104,5 +104,7 @@ TDIEntityID *id, PCHAR Buffer, UINT BufferSize ) { + TI_DbgPrint("Got Request: Class %x Type %x Id %x, EntityID %x:%x\n", + InfoClass, InfoId, id->tei_entity, id->tei_instance); return TDI_INVALID_REQUEST; } _____ Modified: trunk/reactos/drivers/net/tcpip/tcpip/main.c --- trunk/reactos/drivers/net/tcpip/tcpip/main.c 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/drivers/net/tcpip/tcpip/main.c 2005-03-24 10:46:52 UTC (rev 14298) @@ -9,7 +9,7 @@ */ #include "precomp.h" -#define NDEBUG +//#define NDEBUG #ifndef NDEBUG DWORD DebugTraceLevel = DEBUG_ULTRA & ~(DEBUG_LOCK | DEBUG_PBUFFER); @@ -578,6 +578,16 @@ Status = DispTdiSetInformationEx(Irp, IrpSp); break; + case IOCTL_SET_IP_ADDRESS: + TI_DbgPrint(MIN_TRACE, ("SET_IP_ADDRESS\n")); + Status = DispTdiSetIPAddress(Irp, IrpSp); + break; + + case IOCTL_DELETE_IP_ADDRESS: + TI_DbgPrint(MIN_TRACE, ("DELETE_IP_ADDRESS\n")); + Status = DispTdiDeleteIPAddress(Irp, IrpSp); + break; + default: TI_DbgPrint(MIN_TRACE, ("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode)); _____ Modified: trunk/reactos/include/tcpioctl.h --- trunk/reactos/include/tcpioctl.h 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/include/tcpioctl.h 2005-03-24 10:46:52 UTC (rev 14298) @@ -37,4 +37,10 @@ #define IOCTL_TCP_SET_INFORMATION_EX \ _TCP_CTL_CODE(1, METHOD_BUFFERED, FILE_WRITE_ACCESS) +#define IOCTL_SET_IP_ADDRESS \ + _TCP_CTL_CODE(14, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define IOCTL_DELETE_IP_ADDRESS \ + _TCP_CTL_CODE(16, METHOD_BUFFERED, FILE_WRITE_ACCESS) + #endif/*_TCPIOCTL_H*/ _____ Modified: trunk/reactos/lib/iphlpapi/ifenum_reactos.c --- trunk/reactos/lib/iphlpapi/ifenum_reactos.c 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/lib/iphlpapi/ifenum_reactos.c 2005-03-24 10:46:52 UTC (rev 14298) @@ -754,6 +754,8 @@ sizeof(info.if_info) ); } + DPRINT1("entry->bDescr = %s\n", entry->bDescr); + closeTcpFile( tcpFile ); } @@ -795,3 +797,72 @@ } return string; } + +NTSTATUS addIPAddress( IPAddr Address, IPMask Mask, DWORD IfIndex, + PULONG NteContext, PULONG NteInstance ) +{ + HANDLE tcpFile; + NTSTATUS status = openTcpFile( &tcpFile ); + IP_SET_DATA Data; + IO_STATUS_BLOCK Iosb; + + DPRINT("Called.\n"); + + if( !NT_SUCCESS(status) ) return status; + + Data.NteContext = IfIndex; + Data.NewAddress = Address; + Data.NewNetmask = Mask; + + status = NtDeviceIoControlFile( tcpFile, + NULL, + NULL, + NULL, + &Iosb, + IOCTL_SET_IP_ADDRESS, + &Data, + sizeof(Data), + &Data, + sizeof(Data) ); + + closeTcpFile( tcpFile ); + + if( NT_SUCCESS(status) ) { + *NteContext = Iosb.Information; + *NteInstance = Data.NewAddress; + } + + switch( status ) { + case STATUS_SUCCESS: return ERROR_SUCCESS; + case STATUS_DEVICE_DOES_NOT_EXIST: return ERROR_DEV_NOT_EXIST; + default: return status; + } +} + +NTSTATUS deleteIpAddress( ULONG NteContext ) +{ + HANDLE tcpFile; + NTSTATUS status = openTcpFile( &tcpFile ); + USHORT TheNteContext = NteContext; + IO_STATUS_BLOCK Iosb; + + DPRINT("Called.\n"); + + if( !NT_SUCCESS(status) ) return status; + + status = NtDeviceIoControlFile( tcpFile, + NULL, + NULL, + NULL, + &Iosb, + IOCTL_DELETE_IP_ADDRESS, + &NteContext, + sizeof(USHORT), + NULL, + 0 ); + + closeTcpFile( tcpFile ); + + if( NT_SUCCESS(status) ) return ERROR_SUCCESS; + else return ERROR_GEN_FAILURE; +} _____ Modified: trunk/reactos/lib/iphlpapi/iphlpapi_main.c --- trunk/reactos/lib/iphlpapi/iphlpapi_main.c 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/lib/iphlpapi/iphlpapi_main.c 2005-03-24 10:46:52 UTC (rev 14298) @@ -82,11 +82,9 @@ * DWORD * */ -DWORD WINAPI AddIPAddress(IPAddr Address, IPMask IpMask, DWORD IfIndex, PULONG NTEContext, PULONG NTEInstance) +DWORD WINAPI AddIPAddress(IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance) { - FIXME(":stub\n"); - /* marking Win2K+ functions not supported */ - return ERROR_NOT_SUPPORTED; + return addIPAddress( Address, Netmask, IfIndex, NteContext, NteInstance ); } @@ -404,9 +402,7 @@ DWORD WINAPI DeleteIPAddress(ULONG NTEContext) { TRACE("NTEContext %ld\n", NTEContext); - FIXME(":stub\n"); - /* marking Win2K+ functions not supported */ - return ERROR_NOT_SUPPORTED; + return deleteIpAddress( NTEContext ); } _____ Modified: trunk/reactos/lib/iphlpapi/iphlpapi_private.h --- trunk/reactos/lib/iphlpapi/iphlpapi_private.h 2005-03-24 07:50:41 UTC (rev 14297) +++ trunk/reactos/lib/iphlpapi/iphlpapi_private.h 2005-03-24 10:46:52 UTC (rev 14298) @@ -82,6 +82,12 @@ IPAddrEntry ip_addr; } IFInfo; +typedef struct _IP_SET_DATA { + ULONG NteContext; + ULONG NewAddress; + ULONG NewNetmask; +} IP_SET_DATA, *PIP_SET_DATA; + typedef enum _IPHLPAddrType { IPAAddr, IPABcast, IPAMask, IFMtu, IFStatus } IPHLPAddrType;
19 years, 9 months
1
0
0
0
[hpoussin] 14297: - Add synchronization on input and output buffers
by hpoussin@svn.reactos.com
- Add synchronization on input and output buffers - Respect timeouts on IRP_MJ_READ - Get right buffer in read/write routines Modified: trunk/reactos/drivers/dd/serial/devctrl.c Modified: trunk/reactos/drivers/dd/serial/misc.c Modified: trunk/reactos/drivers/dd/serial/pnp.c Modified: trunk/reactos/drivers/dd/serial/rw.c Modified: trunk/reactos/drivers/dd/serial/serial.h _____ Modified: trunk/reactos/drivers/dd/serial/devctrl.c --- trunk/reactos/drivers/dd/serial/devctrl.c 2005-03-23 22:11:20 UTC (rev 14296) +++ trunk/reactos/drivers/dd/serial/devctrl.c 2005-03-24 07:50:41 UTC (rev 14297) @@ -215,14 +215,23 @@ OUT PSERIAL_STATUS pSerialStatus, IN PSERIAL_DEVICE_EXTENSION DeviceExtension) { + KIRQL Irql; + RtlZeroMemory(pSerialStatus, sizeof(SERIAL_STATUS)); pSerialStatus->Errors = 0; /* FIXME */ pSerialStatus->HoldReasons = 0; /* FIXME */ + + KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql); pSerialStatus->AmountInInQueue = (DeviceExtension->InputBuffer.WritePosition + DeviceExtension->InputBuffer.Length - DeviceExtension->InputBuffer.ReadPosition) % DeviceExtension->InputBuffer.Length; + KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql); + + KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql); pSerialStatus->AmountInOutQueue = (DeviceExtension->OutputBuffer.WritePosition + DeviceExtension->OutputBuffer.Length - DeviceExtension->OutputBuffer.ReadPosition) % DeviceExtension->OutputBuffer.Length; + KeReleaseSpinLock(&DeviceExtension->OutputBufferLock, Irql); + pSerialStatus->EofReceived = FALSE; /* FIXME */ pSerialStatus->WaitForImmediate = FALSE; /* FIXME */ @@ -497,8 +506,10 @@ } case IOCTL_SERIAL_PURGE: { + KIRQL Irql1, Irql2; DPRINT("Serial: IOCTL_SERIAL_PURGE\n"); - /* FIXME: lock input and output queues */ + KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql1); + KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql2); DeviceExtension->InputBuffer.ReadPosition = DeviceExtension->InputBuffer.WritePosition = 0; DeviceExtension->OutputBuffer.ReadPosition = DeviceExtension->OutputBuffer.WritePosition = 0; /* Clear receive/transmit buffers */ @@ -507,7 +518,8 @@ WRITE_PORT_UCHAR(SER_FCR(ComPortBase), SR_FCR_CLEAR_RCVR | SR_FCR_CLEAR_XMIT); } - /* FIXME: unlock input and output queues */ + KeReleaseSpinLock(&DeviceExtension->OutputBufferLock, Irql2); + KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql1); Status = STATUS_SUCCESS; break; } @@ -618,18 +630,19 @@ return STATUS_INVALID_PARAMETER; else { + KIRQL Irql; Status = STATUS_SUCCESS; if (((PSERIAL_QUEUE_SIZE)Buffer)->InSize > DeviceExtension->InputBuffer.Length) { - /* FIXME: lock input queue */ + KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql); Status = IncreaseCircularBufferSize(&DeviceExtension->InputBuffer, ((PSERIAL_QUEUE_SIZE)Buffer)->InSize); - /* FIXME: unlock input queue */ + KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql); } if (NT_SUCCESS(Status) && ((PSERIAL_QUEUE_SIZE)Buffer)->OutSize > DeviceExtension->OutputBuffer.Length) { - /* FIXME: lock output queue */ + KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql); Status = IncreaseCircularBufferSize(&DeviceExtension->OutputBuffer, ((PSERIAL_QUEUE_SIZE)Buffer)->OutSize); - /* FIXME: unlock output queue */ + KeReleaseSpinLock(&DeviceExtension->OutputBufferLock, Irql); } } break; _____ Modified: trunk/reactos/drivers/dd/serial/misc.c --- trunk/reactos/drivers/dd/serial/misc.c 2005-03-23 22:11:20 UTC (rev 14296) +++ trunk/reactos/drivers/dd/serial/misc.c 2005-03-24 07:50:41 UTC (rev 14297) @@ -60,6 +60,67 @@ return IoCallDriver(LowerDevice, Irp); } +VOID STDCALL +SerialReceiveByte( + IN PKDPC Dpc, + IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION + IN PVOID pByte, // real type UCHAR + IN PVOID Unused) +{ + PSERIAL_DEVICE_EXTENSION DeviceExtension; + UCHAR Byte; + KIRQL Irql; + NTSTATUS Status; + + DeviceExtension = (PSERIAL_DEVICE_EXTENSION)pDeviceExtension; + Byte = (UCHAR)(ULONG_PTR)pByte; + DPRINT1("Serial: received byte on COM%lu: 0x%02x (%c)\n", + DeviceExtension->ComPort, Byte, Byte); + + KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql); + Status = PushCircularBufferEntry(&DeviceExtension->InputBuffer, Byte); + if (!NT_SUCCESS(Status)) + { + /* FIXME: count buffer overflow */ + return; + } + DPRINT1("Serial: push to buffer done\n"); + KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql); + InterlockedIncrement(&DeviceExtension->SerialPerfStats.ReceivedCount); +} + +VOID STDCALL +SerialSendByte( + IN PKDPC Dpc, + IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION + IN PVOID Unused1, + IN PVOID Unused2) +{ + PSERIAL_DEVICE_EXTENSION DeviceExtension; + PUCHAR ComPortBase; + UCHAR Byte; + KIRQL Irql; + NTSTATUS Status; + + DeviceExtension = (PSERIAL_DEVICE_EXTENSION)pDeviceExtension; + ComPortBase = (PUCHAR)DeviceExtension->BaseAddress; + + DPRINT1("Serial: sending bytes (if any) on COM%lu\n", + DeviceExtension->ComPort); + + KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql); + while (!IsCircularBufferEmpty(&DeviceExtension->OutputBuffer) + && READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_TBE) + { + Status = PopCircularBufferEntry(&DeviceExtension->OutputBuffer, &Byte); + if (!NT_SUCCESS(Status)) + break; + WRITE_PORT_UCHAR(SER_THR(ComPortBase), Byte); + DeviceExtension->SerialPerfStats.TransmittedCount++; + } + KeReleaseSpinLock(&DeviceExtension->OutputBufferLock, Irql); +} + BOOLEAN STDCALL SerialInterruptService( IN PKINTERRUPT Interrupt, @@ -70,7 +131,6 @@ UCHAR Byte; PUCHAR ComPortBase; UCHAR Iir; - NTSTATUS Status; DeviceObject = (PDEVICE_OBJECT)ServiceContext; DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension; @@ -96,18 +156,7 @@ case SR_IIR_THR_EMPTY: { DPRINT("Serial: SR_IIR_THR_EMPTY\n"); - /* FIXME: lock OutputBuffer */ - while (!IsCircularBufferEmpty(&DeviceExtension->OutputBuffer) - && READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_TBE) - { - Status = PopCircularBufferEntry(&DeviceExtension->OutputBuffer, &Byte); - if (!NT_SUCCESS(Status)) - break; - WRITE_PORT_UCHAR(SER_THR(ComPortBase), Byte); - DeviceExtension->SerialPerfStats.TransmittedCount++; - } - /* FIXME: unlock OutputBuffer */ - return TRUE; + return KeInsertQueueDpc(&DeviceExtension->SendByteDpc, NULL, NULL); } case SR_IIR_DATA_RECEIVED: { @@ -116,19 +165,10 @@ { Byte = READ_PORT_UCHAR(SER_RBR(ComPortBase)); DPRINT1("Serial: Byte received: 0x%02x (%c)\n", Byte, Byte); - /* FIXME: lock InputBuffer */ - Status = PushCircularBufferEntry(&DeviceExtension->InputBuffer, Byte); - if (!NT_SUCCESS(Status)) - { - /* FIXME: count buffer overflow */ + if (!KeInsertQueueDpc(&DeviceExtension->ReceivedByteDpc, (PVOID)(ULONG_PTR)Byte, NULL)) break; - } - DPRINT1("Serial: push to buffer done\n"); - /* FIXME: unlock InputBuffer */ - DeviceExtension->SerialPerfStats.ReceivedCount++; } return TRUE; - break; } case SR_IIR_ERROR: { _____ Modified: trunk/reactos/drivers/dd/serial/pnp.c --- trunk/reactos/drivers/dd/serial/pnp.c 2005-03-23 22:11:20 UTC (rev 14296) +++ trunk/reactos/drivers/dd/serial/pnp.c 2005-03-24 07:50:41 UTC (rev 14297) @@ -76,6 +76,10 @@ Status = InitializeCircularBuffer(&DeviceExtension->OutputBuffer, 16); if (!NT_SUCCESS(Status)) goto ByeBye; IoInitializeRemoveLock(&DeviceExtension->RemoveLock, SERIAL_TAG, 0, 0); + KeInitializeSpinLock(&DeviceExtension->InputBufferLock); + KeInitializeSpinLock(&DeviceExtension->OutputBufferLock); + KeInitializeDpc(&DeviceExtension->ReceivedByteDpc, SerialReceiveByte, DeviceExtension); + KeInitializeDpc(&DeviceExtension->SendByteDpc, SerialSendByte, DeviceExtension); //Fdo->Flags |= DO_POWER_PAGEABLE (or DO_POWER_INRUSH?) Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice); if (!NT_SUCCESS(Status)) @@ -152,13 +156,7 @@ DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - /* FIXME: actually, IRP_MN_START_DEVICE is sent twice to each serial device: - * - one when loading serial.sys - * - one when loading attached upper filter serenum.sys - * This behaviour MUST NOT exist. - * As PnP handling isn't right anyway, I didn't search how to correct this. - */ - if (DeviceExtension->PnpState == dsStarted) return STATUS_SUCCESS; + ASSERT(DeviceExtension->PnpState == dsStopped); DeviceExtension->ComPort = DeviceExtension->SerialPortNumber + 1; DeviceExtension->BaudRate = 19200 | SERIAL_BAUD_USER; _____ Modified: trunk/reactos/drivers/dd/serial/rw.c --- trunk/reactos/drivers/dd/serial/rw.c 2005-03-23 22:11:20 UTC (rev 14296) +++ trunk/reactos/drivers/dd/serial/rw.c 2005-03-24 07:50:41 UTC (rev 14297) @@ -16,12 +16,8 @@ SerialGetUserBuffer(IN PIRP Irp) { ASSERT(Irp); - - if (Irp->MdlAddress) - return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority); - else - /* FIXME: try buffer */ - return Irp->UserBuffer; + + return Irp->AssociatedIrp.SystemBuffer; } NTSTATUS STDCALL @@ -36,6 +32,7 @@ PUCHAR Buffer; PUCHAR ComPortBase; UCHAR ReceivedByte; + KIRQL Irql; NTSTATUS Status = STATUS_SUCCESS; DPRINT("Serial: IRP_MJ_READ\n"); @@ -64,8 +61,8 @@ if (!NT_SUCCESS(Status)) goto ByeBye; - /* FIXME: lock InputBuffer */ - while (Length-- > 0 && !IsCircularBufferEmpty(&DeviceExtension->InputBuffer)) + KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql); + while (Length-- > 0) { Status = PopCircularBufferEntry(&DeviceExtension->InputBuffer, &ReceivedByte); if (!NT_SUCCESS(Status)) @@ -73,54 +70,117 @@ DPRINT("Serial: read from buffer 0x%x (%c)\n", ReceivedByte, ReceivedByte); Buffer[Information++] = ReceivedByte; } + KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql); if (Length > 0 && !(DeviceExtension->SerialTimeOuts.ReadIntervalTimeout == INFINITE && DeviceExtension->SerialTimeOuts.ReadTotalTimeoutConstant == 0 && DeviceExtension->SerialTimeOuts.ReadTotalTimeoutMultiplier == 0)) { - if (DeviceExtension->SerialTimeOuts.ReadIntervalTimeout == 0 - || DeviceExtension->SerialTimeOuts.ReadTotalTimeoutMultiplier == 0) + ULONG IntervalTimeout; + ULONG TotalTimeout; + BOOLEAN UseIntervalTimeout = FALSE; + BOOLEAN UseTotalTimeout = FALSE; + ULONG ThisByteTimeout; + BOOLEAN IsByteReceived; + ULONG i; + /* Extract timeouts informations */ + if (DeviceExtension->SerialTimeOuts.ReadIntervalTimeout == INFINITE && + DeviceExtension->SerialTimeOuts.ReadTotalTimeoutMultiplier == INFINITE && + DeviceExtension->SerialTimeOuts.ReadTotalTimeoutConstant > 0 && + DeviceExtension->SerialTimeOuts.ReadTotalTimeoutConstant < INFINITE) { - DPRINT("Serial: we must wait for %lu characters!\n", Length); -#if 1 - /* Disable interrupts */ - WRITE_PORT_UCHAR(SER_IER((PUCHAR)DeviceExtension->BaseAddress), DeviceExtension->IER & ~1); - - /* Polling code */ - while (Length > 0) + if (Information > 0) { - while ((READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_DR) == 0) - ; - ReceivedByte = READ_PORT_UCHAR(SER_RBR(ComPortBase)); - Buffer[Information++] = ReceivedByte; - Length--; + /* don't read mode bytes */ + Length = 0; } - /* Enable interrupts */ - WRITE_PORT_UCHAR(SER_IER((PUCHAR)DeviceExtension->BaseAddress), DeviceExtension->IER); -#else - while (Length > 0) + else { - if (!IsCircularBufferEmpty(&DeviceExtension->InputBuffer)) + /* read only one byte */ + UseTotalTimeout = TRUE; + TotalTimeout = DeviceExtension->SerialTimeOuts.ReadTotalTimeoutConstant; + Length = 1; + } + } + else + { + if (DeviceExtension->SerialTimeOuts.ReadIntervalTimeout != 0) + { + UseIntervalTimeout = TRUE; + IntervalTimeout = DeviceExtension->SerialTimeOuts.ReadIntervalTimeout; + } + if (DeviceExtension->SerialTimeOuts.ReadTotalTimeoutConstant != 0 || + DeviceExtension->SerialTimeOuts.ReadTotalTimeoutMultiplier != 0) + { + UseTotalTimeout = TRUE; + TotalTimeout = DeviceExtension->SerialTimeOuts.ReadTotalTimeoutConstant + + DeviceExtension->SerialTimeOuts.ReadTotalTimeoutMultiplier * Length; + } + } + DPRINT("Serial: UseIntervalTimeout = %ws, IntervalTimeout = %lu\n", + UseIntervalTimeout ? L"YES" : L"NO", + UseIntervalTimeout ? IntervalTimeout : 0); + DPRINT("Serial: UseTotalTimeout = %ws, TotalTimeout = %lu\n", + UseTotalTimeout ? L"YES" : L"NO", + UseTotalTimeout ? TotalTimeout : 0); + + /* FIXME: it should be better to use input buffer instead of + * disabling interrupts, and try to directly read for port! */ + + /* FIXME: NtQueryPerformanceCounter gives a more accurate + * timer, but it is not available on all computers. First try + * NtQueryPerformanceCounter, and current method if it is not + * implemented. */ + + /* FIXME: remove disabling interrupts */ + WRITE_PORT_UCHAR(SER_IER(ComPortBase), DeviceExtension->IER & ~1); + while (Length > 0) + { + ThisByteTimeout = IntervalTimeout; + IsByteReceived = FALSE; + while (TRUE) + { + for (i = 0; i < 1000; i++) { - Status = PopCircularBufferEntry(&DeviceExtension->InputBuffer, &ReceivedByte); - if (!NT_SUCCESS(Status)) +#if 1 + if ((READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_DR) != 0) + { + ReceivedByte = READ_PORT_UCHAR(ComPortBase); + DPRINT("Serial: received byte 0x%02x (%c)\n", ReceivedByte, ReceivedByte); + IsByteReceived = TRUE; break; - DPRINT1("Serial: read from buffer 0x%x (%c)\n", ReceivedByte, ReceivedByte); - Buffer[Information++] = ReceivedByte; - Length--; + } +#else + KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql); + if (!IsCircularBufferEmpty(&DeviceExtension->InputBuffer)) + { + PopCircularBufferEntry(&DeviceExtension->InputBuffer, &ReceivedByte); + KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql); + DPRINT("Serial: reading byte from buffer 0x%02x (%c)\n", ReceivedByte, ReceivedByte); + IsByteReceived = TRUE; + break; + } + KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql); +#endif + KeStallExecutionProcessor(1); } + if (IsByteReceived) break; + if (UseIntervalTimeout) + { + if (ThisByteTimeout == 0) break; else ThisByteTimeout--; + } + if (UseTotalTimeout) + { + if (TotalTimeout == 0) break; else TotalTimeout--; + } } -#endif + if (!IsByteReceived) break; + Buffer[Information++] = ReceivedByte; + Length--; } - else - { - /* FIXME: use ReadTotalTimeoutMultiplier and ReadTotalTimeoutConstant */ - DPRINT1("Serial: we must wait for %lu characters at maximum within %lu milliseconds! UNIMPLEMENTED\n", - Length, - Stack->Parameters.Read.Length * DeviceExtension->SerialTimeOuts.ReadTotalTimeoutMultiplier + DeviceExtension->SerialTimeOuts.ReadTotalTimeoutConstant); - } + /* FIXME: remove enabling interrupts */ + WRITE_PORT_UCHAR(SER_IER(ComPortBase), DeviceExtension->IER); } - /* FIXME: unlock InputBuffer */ Status = STATUS_SUCCESS; IoReleaseRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort); @@ -143,6 +203,7 @@ ULONG Information = 0; PUCHAR Buffer; PUCHAR ComPortBase; + KIRQL Irql; NTSTATUS Status = STATUS_SUCCESS; DPRINT("Serial: IRP_MJ_WRITE\n"); @@ -166,7 +227,7 @@ if (!NT_SUCCESS(Status)) goto ByeBye; - /* FIXME: lock OutputBuffer */ + KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql); if (IsCircularBufferEmpty(&DeviceExtension->OutputBuffer)) { /* Put the maximum amount of data in UART output buffer */ @@ -197,7 +258,7 @@ DPRINT1("Serial: write to buffer 0x%02x\n", Buffer[Information]); Information++; } - /* FIXME: unlock OutputBuffer */ + KeReleaseSpinLock(&DeviceExtension->OutputBufferLock, Irql); IoReleaseRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort); ByeBye: _____ Modified: trunk/reactos/drivers/dd/serial/serial.h --- trunk/reactos/drivers/dd/serial/serial.h 2005-03-23 22:11:20 UTC (rev 14296) +++ trunk/reactos/drivers/dd/serial/serial.h 2005-03-24 07:50:41 UTC (rev 14297) @@ -81,6 +81,8 @@ ULONG BaudRate; ULONG BaseAddress; PKINTERRUPT Interrupt; + KDPC ReceivedByteDpc; + KDPC SendByteDpc; SERIAL_LINE_CONTROL SerialLineControl; UART_TYPE UartType; @@ -90,7 +92,9 @@ SERIAL_TIMEOUTS SerialTimeOuts; BOOLEAN IsOpened; CIRCULAR_BUFFER InputBuffer; + KSPIN_LOCK InputBufferLock; CIRCULAR_BUFFER OutputBuffer; + KSPIN_LOCK OutputBufferLock; /* Current values */ UCHAR IER; /* Base+1, Interrupt Enable Register */ @@ -250,6 +254,20 @@ IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); +VOID STDCALL +SerialReceiveByte( + IN PKDPC Dpc, + IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION + IN PVOID pByte, // real type UCHAR + IN PVOID Unused); + +VOID STDCALL +SerialSendByte( + IN PKDPC Dpc, + IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION + IN PVOID Unused1, + IN PVOID Unused2); + BOOLEAN STDCALL SerialInterruptService( IN PKINTERRUPT Interrupt,
19 years, 9 months
1
0
0
0
[hbirr] 14296: - Guarded the calls to IoSetCancelRoutine with IoAcquireCancelSpinLock/IoReleaseCancelSpinLock.
by hbirr@svn.reactos.com
- Guarded the calls to IoSetCancelRoutine with IoAcquireCancelSpinLock/IoReleaseCancelSpinLock. - Used a fastmutex as lock for the data queue. - Used paged pool for the data buffers. - Allowed the server to read (and to wait) on a listening pipe. - Implemented the non blocking read operations. Modified: trunk/reactos/drivers/fs/np/create.c Modified: trunk/reactos/drivers/fs/np/fsctrl.c Modified: trunk/reactos/drivers/fs/np/npfs.c Modified: trunk/reactos/drivers/fs/np/npfs.h Modified: trunk/reactos/drivers/fs/np/rw.c _____ Modified: trunk/reactos/drivers/fs/np/create.c --- trunk/reactos/drivers/fs/np/create.c 2005-03-23 21:51:40 UTC (rev 14295) +++ trunk/reactos/drivers/fs/np/create.c 2005-03-23 22:11:20 UTC (rev 14296) @@ -49,6 +49,7 @@ { PLIST_ENTRY CurrentEntry; PNPFS_WAITER_ENTRY Waiter; + KIRQL oldIrql; CurrentEntry = Pipe->WaiterListHead.Flink; while (CurrentEntry != &Pipe->WaiterListHead) @@ -58,11 +59,15 @@ !Waiter->Irp->Cancel) { DPRINT("Server found! Fcb %p\n", Waiter->Fcb); - - if (IoSetCancelRoutine(Waiter->Irp, NULL) != NULL) - { + + IoAcquireCancelSpinLock(&oldIrql); + if (!Waiter->Irp->Cancel) + { + IoSetCancelRoutine(Waiter->Irp, NULL); + IoReleaseCancelSpinLock(oldIrql); return Waiter->Fcb; } + IoReleaseCancelSpinLock(oldIrql); } CurrentEntry = CurrentEntry->Flink; @@ -174,7 +179,7 @@ /* Initialize data list. */ if (Pipe->OutboundQuota) { - ClientFcb->Data = ExAllocatePool(NonPagedPool, Pipe->OutboundQuota); + ClientFcb->Data = ExAllocatePool(PagedPool, Pipe->OutboundQuota); if (ClientFcb->Data == NULL) { DPRINT("No memory!\n"); @@ -195,7 +200,7 @@ ClientFcb->ReadDataAvailable = 0; ClientFcb->WriteQuotaAvailable = Pipe->OutboundQuota; ClientFcb->MaxDataLength = Pipe->OutboundQuota; - KeInitializeSpinLock(&ClientFcb->DataListLock); + ExInitializeFastMutex(&ClientFcb->DataListLock); KeInitializeEvent(&ClientFcb->ConnectEvent, SynchronizationEvent, FALSE); KeInitializeEvent(&ClientFcb->Event, SynchronizationEvent, FALSE); @@ -455,13 +460,17 @@ if (Pipe->InboundQuota) { - Fcb->Data = ExAllocatePool(NonPagedPool, Pipe->InboundQuota); + Fcb->Data = ExAllocatePool(PagedPool, Pipe->InboundQuota); if (Fcb->Data == NULL) { ExFreePool(Fcb); if (NewPipe) { + /* + * FIXME: + * Lock the pipelist and remove the pipe from the list. + */ RtlFreeUnicodeString(&Pipe->PipeName); ExFreePool(Pipe); } @@ -481,7 +490,7 @@ Fcb->ReadDataAvailable = 0; Fcb->WriteQuotaAvailable = Pipe->InboundQuota; Fcb->MaxDataLength = Pipe->InboundQuota; - KeInitializeSpinLock(&Fcb->DataListLock); + ExInitializeFastMutex(&Fcb->DataListLock); Pipe->CurrentInstances++; _____ Modified: trunk/reactos/drivers/fs/np/fsctrl.c --- trunk/reactos/drivers/fs/np/fsctrl.c 2005-03-23 21:51:40 UTC (rev 14295) +++ trunk/reactos/drivers/fs/np/fsctrl.c 2005-03-23 22:11:20 UTC (rev 14296) @@ -46,6 +46,7 @@ PNPFS_FCB Fcb) { PNPFS_WAITER_ENTRY Entry; + KIRQL oldIrql; Entry = ExAllocatePool(NonPagedPool, sizeof(NPFS_WAITER_ENTRY)); if (Entry == NULL) @@ -61,13 +62,15 @@ Irp->Tail.Overlay.DriverContext[0] = Entry; InsertTailList(&Fcb->Pipe->WaiterListHead, &Entry->Entry); - IoSetCancelRoutine(Irp, NpfsListeningCancelRoutine); - + IoAcquireCancelSpinLock(&oldIrql); if (!Irp->Cancel) { + IoSetCancelRoutine(Irp, NpfsListeningCancelRoutine); + IoReleaseCancelSpinLock(oldIrql); KeUnlockMutex(&Fcb->Pipe->FcbListLock); return STATUS_PENDING; } + IoReleaseCancelSpinLock(oldIrql); RemoveEntryList(&Entry->Entry); _____ Modified: trunk/reactos/drivers/fs/np/npfs.c --- trunk/reactos/drivers/fs/np/npfs.c 2005-03-23 21:51:40 UTC (rev 14295) +++ trunk/reactos/drivers/fs/np/npfs.c 2005-03-23 22:11:20 UTC (rev 14296) @@ -73,8 +73,10 @@ /* initialize the device extension */ DeviceExtension = DeviceObject->DeviceExtension; InitializeListHead(&DeviceExtension->PipeListHead); + InitializeListHead(&DeviceExtension->ThreadListHead); KeInitializeMutex(&DeviceExtension->PipeListLock, 0); + DeviceExtension->EmptyWaiterCount = 0; /* set the size quotas */ DeviceExtension->MinQuota = PAGE_SIZE; _____ Modified: trunk/reactos/drivers/fs/np/npfs.h --- trunk/reactos/drivers/fs/np/npfs.h 2005-03-23 21:51:40 UTC (rev 14295) +++ trunk/reactos/drivers/fs/np/npfs.h 2005-03-23 22:11:20 UTC (rev 14296) @@ -6,7 +6,9 @@ typedef struct _NPFS_DEVICE_EXTENSION { LIST_ENTRY PipeListHead; + LIST_ENTRY ThreadListHead; KMUTEX PipeListLock; + ULONG EmptyWaiterCount; ULONG MinQuota; ULONG DefaultQuota; ULONG MaxQuota; @@ -20,6 +22,7 @@ LIST_ENTRY ServerFcbListHead; LIST_ENTRY ClientFcbListHead; LIST_ENTRY WaiterListHead; + LIST_ENTRY EmptyBufferListHead; ULONG PipeType; ULONG ReadMode; ULONG WriteMode; @@ -50,9 +53,29 @@ PVOID WritePtr; ULONG MaxDataLength; - KSPIN_LOCK DataListLock; /* Data queue lock */ + FAST_MUTEX DataListLock; /* Data queue lock */ } NPFS_FCB, *PNPFS_FCB; +typedef struct _NPFS_CONTEXT +{ + PDEVICE_OBJECT DeviceObject; + PIRP Irp; + PNPFS_FCB Fcb; + UCHAR MajorFunction; + BOOLEAN AllocatedFromPool; +} NPFS_CONTEXT, *PNPFS_CONTEXT; + +typedef struct _NPFS_THREAD_CONTEXT +{ + ULONG Count; + KEVENT Event; + PNPFS_DEVICE_EXTENSION DeviceExt; + LIST_ENTRY ListEntry; + PVOID WaitObjectArray[MAXIMUM_WAIT_OBJECTS]; + KWAIT_BLOCK WaitBlockArray[MAXIMUM_WAIT_OBJECTS]; + PNPFS_CONTEXT WaitContextArray[MAXIMUM_WAIT_OBJECTS]; +} NPFS_THREAD_CONTEXT, *PNPFS_THREAD_CONTEXT; + typedef struct _NPFS_WAITER_ENTRY { LIST_ENTRY Entry; _____ Modified: trunk/reactos/drivers/fs/np/rw.c --- trunk/reactos/drivers/fs/np/rw.c 2005-03-23 21:51:40 UTC (rev 14295) +++ trunk/reactos/drivers/fs/np/rw.c 2005-03-23 22:11:20 UTC (rev 14296) @@ -46,16 +46,197 @@ } #endif +static NTSTATUS +NpfsReadFromPipe(PNPFS_CONTEXT Context); -NTSTATUS STDCALL -NpfsRead(PDEVICE_OBJECT DeviceObject, - PIRP Irp) +static VOID STDCALL +NpfsWaitingCancelRoutine(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) { + PNPFS_CONTEXT Context; + PNPFS_DEVICE_EXTENSION DeviceExt; + + DPRINT1("NpfsWaitingCancelRoutine() called\n"); + + IoReleaseCancelSpinLock(Irp->CancelIrql); + + Context = Irp->Tail.Overlay.DriverContext[0]; + DeviceExt = Context->DeviceObject->DeviceExtension; + + KeLockMutex(&DeviceExt->PipeListLock); + KeSetEvent(&Context->Fcb->Event, IO_NO_INCREMENT, FALSE); + KeUnlockMutex(&DeviceExt->PipeListLock); +} + +static VOID STDCALL +NpfsWaiterThread(PVOID Context) +{ + PNPFS_THREAD_CONTEXT ThreadContext = (PNPFS_THREAD_CONTEXT) Context; + ULONG CurrentCount, Count = 0; + PNPFS_CONTEXT WaitContext = NULL; + NTSTATUS Status; + BOOLEAN Terminate = FALSE; + BOOLEAN Cancel = FALSE; + KIRQL oldIrql; + + KeLockMutex(&ThreadContext->DeviceExt->PipeListLock); + + while (1) + { + CurrentCount = ThreadContext->Count; + KeResetEvent(&ThreadContext->Event); + KeUnlockMutex(&ThreadContext->DeviceExt->PipeListLock); + if (WaitContext) + { + if (Cancel) + { + WaitContext->Irp->IoStatus.Status = STATUS_CANCELLED; + WaitContext->Irp->IoStatus.Information = 0; + IoCompleteRequest(WaitContext->Irp, IO_NO_INCREMENT); + ExFreePool(WaitContext); + } + else + { + switch (WaitContext->MajorFunction) + { + case IRP_MJ_READ: + NpfsReadFromPipe(WaitContext); + break; + default: + KEBUGCHECK(0); + } + } + } + if (Terminate) + { + break; + } + Status = KeWaitForMultipleObjects(CurrentCount, + ThreadContext->WaitObjectArray, + WaitAny, + Executive, + KernelMode, + FALSE, + NULL, + ThreadContext->WaitBlockArray); + KeLockMutex(&ThreadContext->DeviceExt->PipeListLock); + if (!NT_SUCCESS(Status)) + { + KEBUGCHECK(0); + } + Count = Status - STATUS_SUCCESS; + ASSERT (Count <= CurrentCount); + if (Count > 0) + { + WaitContext = ThreadContext->WaitContextArray[Count]; + ThreadContext->Count--; + ThreadContext->DeviceExt->EmptyWaiterCount++; + ThreadContext->WaitObjectArray[Count] = ThreadContext->WaitObjectArray[ThreadContext->Count]; + ThreadContext->WaitContextArray[Count] = ThreadContext->WaitContextArray[ThreadContext->Count]; + IoAcquireCancelSpinLock(&oldIrql); + Cancel = NULL == IoSetCancelRoutine(WaitContext->Irp, NULL); + IoReleaseCancelSpinLock(oldIrql); + } + else + { + /* someone has add a new wait request */ + WaitContext = NULL; + } + if (ThreadContext->Count == 1 && ThreadContext->DeviceExt->EmptyWaiterCount >= MAXIMUM_WAIT_OBJECTS) + { + /* it exist an other thread with empty wait slots, we can remove our thread from the list */ + RemoveEntryList(&ThreadContext->ListEntry); + ThreadContext->DeviceExt->EmptyWaiterCount -= MAXIMUM_WAIT_OBJECTS - 1; + Terminate = TRUE; + } + } + KeUnlockMutex(&ThreadContext->DeviceExt->PipeListLock); + ExFreePool(ThreadContext); +} + +static NTSTATUS +NpfsAddWaitingReader(PNPFS_DEVICE_EXTENSION DeviceExt, PNPFS_CONTEXT Context, PNPFS_FCB Fcb) +{ + PLIST_ENTRY ListEntry; + PNPFS_THREAD_CONTEXT ThreadContext; + NTSTATUS Status; + HANDLE hThread; + KIRQL oldIrql; + + KeLockMutex(&DeviceExt->PipeListLock); + + ListEntry = DeviceExt->ThreadListHead.Flink; + while (ListEntry != &DeviceExt->ThreadListHead) + { + ThreadContext = CONTAINING_RECORD(ListEntry, NPFS_THREAD_CONTEXT, ListEntry); + if (ThreadContext->Count < MAXIMUM_WAIT_OBJECTS) + { + break; + } + ListEntry = ListEntry->Flink; + } + if (ListEntry == &DeviceExt->ThreadListHead) + { + ThreadContext = ExAllocatePool(NonPagedPool, sizeof(NPFS_THREAD_CONTEXT)); + if (ThreadContext == NULL) + { + KeUnlockMutex(&DeviceExt->PipeListLock); + return STATUS_NO_MEMORY; + } + ThreadContext->DeviceExt = DeviceExt; + KeInitializeEvent(&ThreadContext->Event, NotificationEvent, FALSE); + ThreadContext->Count = 1; + ThreadContext->WaitObjectArray[0] = &ThreadContext->Event; + + + DPRINT("Creating a new system thread for waiting read requests\n"); + + Status = PsCreateSystemThread(&hThread, + THREAD_ALL_ACCESS, + NULL, + NULL, + NULL, + NpfsWaiterThread, + (PVOID)ThreadContext); + if (!NT_SUCCESS(Status)) + { + ExFreePool(ThreadContext); + KeUnlockMutex(&DeviceExt->PipeListLock); + return Status; + } + InsertHeadList(&DeviceExt->ThreadListHead, &ThreadContext->ListEntry); + DeviceExt->EmptyWaiterCount += MAXIMUM_WAIT_OBJECTS - 1; + } + IoMarkIrpPending(Context->Irp); + Context->Irp->Tail.Overlay.DriverContext[0] = Context; + + IoAcquireCancelSpinLock(&oldIrql); + if (Context->Irp->Cancel) + { + IoReleaseCancelSpinLock(oldIrql); + Status = STATUS_CANCELLED; + } + else + { + IoSetCancelRoutine(Context->Irp, NpfsWaitingCancelRoutine); + IoReleaseCancelSpinLock(oldIrql); + ThreadContext->WaitObjectArray[ThreadContext->Count] = &Fcb->Event; + ThreadContext->WaitContextArray[ThreadContext->Count] = Context; + ThreadContext->Count++; + DeviceExt->EmptyWaiterCount--; + KeSetEvent(&ThreadContext->Event, IO_NO_INCREMENT, FALSE); + Status = STATUS_SUCCESS; + } + KeUnlockMutex(&DeviceExt->PipeListLock); + return Status; +} + +static NTSTATUS +NpfsReadFromPipe(PNPFS_CONTEXT Context) +{ PIO_STACK_LOCATION IoStack; PFILE_OBJECT FileObject; NTSTATUS Status; - PNPFS_DEVICE_EXTENSION DeviceExt; - KIRQL OldIrql; ULONG Information; PNPFS_FCB Fcb; PNPFS_FCB WriterFcb; @@ -65,23 +246,14 @@ ULONG CopyLength; ULONG TempLength; - DPRINT("NpfsRead(DeviceObject %p Irp %p)\n", DeviceObject, Irp); + DPRINT("NpfsReadFromPipe(Context %p)\n", Context); - DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - IoStack = IoGetCurrentIrpStackLocation(Irp); + IoStack = IoGetCurrentIrpStackLocation(Context->Irp); FileObject = IoStack->FileObject; Fcb = FileObject->FsContext; Pipe = Fcb->Pipe; WriterFcb = Fcb->OtherSide; - if (Irp->MdlAddress == NULL) - { - DPRINT("Irp->MdlAddress == NULL\n"); - Status = STATUS_UNSUCCESSFUL; - Information = 0; - goto done; - } - if (Fcb->Data == NULL) { DPRINT("Pipe is NOT readable!\n"); @@ -94,41 +266,71 @@ Length = IoStack->Parameters.Read.Length; Information = 0; - Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); - KeAcquireSpinLock(&Fcb->DataListLock, &OldIrql); + Buffer = MmGetSystemAddressForMdl(Context->Irp->MdlAddress); + ExAcquireFastMutex(&Fcb->DataListLock); while (1) { - /* FIXME: check if in blocking mode */ if (Fcb->ReadDataAvailable == 0) { if (Fcb->PipeState == FILE_PIPE_CONNECTED_STATE) { KeSetEvent(&WriterFcb->Event, IO_NO_INCREMENT, FALSE); } - KeReleaseSpinLock(&Fcb->DataListLock, OldIrql); + ExReleaseFastMutex(&Fcb->DataListLock); if (Information > 0) { Status = STATUS_SUCCESS; goto done; } - if (Fcb->PipeState != FILE_PIPE_CONNECTED_STATE) + if (Fcb->PipeState != FILE_PIPE_CONNECTED_STATE && + !(Fcb->PipeState == FILE_PIPE_LISTENING_STATE && Fcb->PipeEnd == FILE_PIPE_SERVER_END)) { DPRINT("PipeState: %x\n", Fcb->PipeState); Status = STATUS_PIPE_BROKEN; goto done; } - /* Wait for ReadEvent to become signaled */ - DPRINT("Waiting for readable data (%S)\n", Pipe->PipeName.Buffer); - Status = KeWaitForSingleObject(&Fcb->Event, - UserRequest, - KernelMode, - FALSE, - NULL); - DPRINT("Finished waiting (%S)! Status: %x\n", Pipe->PipeName.Buffer, Status); + if (IoIsOperationSynchronous(Context->Irp)) + { + /* Wait for ReadEvent to become signaled */ + DPRINT("Waiting for readable data (%S)\n", Pipe->PipeName.Buffer); + Status = KeWaitForSingleObject(&Fcb->Event, + UserRequest, + KernelMode, + FALSE, + NULL); + DPRINT("Finished waiting (%S)! Status: %x\n", Pipe->PipeName.Buffer, Status); + } + else + { + PNPFS_CONTEXT NewContext; - KeAcquireSpinLock(&Fcb->DataListLock, &OldIrql); + NewContext = ExAllocatePool(NonPagedPool, sizeof(NPFS_CONTEXT)); + if (NewContext == NULL) + { + Status = STATUS_NO_MEMORY; + goto done; + } + memcpy(NewContext, Context, sizeof(NPFS_CONTEXT)); + NewContext->AllocatedFromPool = TRUE; + NewContext->Fcb = Fcb; + NewContext->MajorFunction = IRP_MJ_READ; + + Status = NpfsAddWaitingReader(Context->DeviceObject->DeviceExtension, NewContext, Fcb); + + if (NT_SUCCESS(Status)) + { + Status = STATUS_PENDING; + } + else + { + ExFreePool(NewContext); + } + goto done; + } + + ExAcquireFastMutex(&Fcb->DataListLock); } if (Pipe->ReadMode == FILE_PIPE_BYTE_STREAM_MODE) @@ -217,20 +419,48 @@ } } - KeReleaseSpinLock(&Fcb->DataListLock, OldIrql); + ExReleaseFastMutex(&Fcb->DataListLock); done: - Irp->IoStatus.Status = Status; - Irp->IoStatus.Information = Information; + Context->Irp->IoStatus.Status = Status; + Context->Irp->IoStatus.Information = Information; - IoCompleteRequest(Irp, IO_NO_INCREMENT); + if (Status != STATUS_PENDING) + { + IoCompleteRequest(Context->Irp, IO_NO_INCREMENT); + } + if (Context->AllocatedFromPool) + { + ExFreePool(Context); + } DPRINT("NpfsRead done (Status %lx)\n", Status); return Status; } +NTSTATUS STDCALL +NpfsRead(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + NPFS_CONTEXT Context; + Context.AllocatedFromPool = FALSE; + Context.DeviceObject = DeviceObject; + Context.Irp = Irp; + + if (Irp->MdlAddress == NULL) + { + DPRINT("Irp->MdlAddress == NULL\n"); + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_UNSUCCESSFUL; + } + + return NpfsReadFromPipe(&Context); +} + NTSTATUS STDCALL NpfsWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp) @@ -244,7 +474,6 @@ NTSTATUS Status = STATUS_SUCCESS; ULONG Length; ULONG Offset; - KIRQL OldIrql; ULONG Information; ULONG CopyLength; ULONG TempLength; @@ -296,7 +525,7 @@ Status = STATUS_SUCCESS; Buffer = MmGetSystemAddressForMdl (Irp->MdlAddress); - KeAcquireSpinLock(&ReaderFcb->DataListLock, &OldIrql); + ExAcquireFastMutex(&ReaderFcb->DataListLock); #ifndef NDEBUG DPRINT("Length %d Buffer %x Offset %x\n",Length,Buffer,Offset); HexDump(Buffer, Length); @@ -307,7 +536,7 @@ if (ReaderFcb->WriteQuotaAvailable == 0) { KeSetEvent(&ReaderFcb->Event, IO_NO_INCREMENT, FALSE); - KeReleaseSpinLock(&ReaderFcb->DataListLock, OldIrql); + ExReleaseFastMutex(&ReaderFcb->DataListLock); if (Fcb->PipeState != FILE_PIPE_CONNECTED_STATE) { Status = STATUS_PIPE_BROKEN; @@ -332,7 +561,7 @@ Status = STATUS_PIPE_BROKEN; goto done; } - KeAcquireSpinLock(&ReaderFcb->DataListLock, &OldIrql); + ExAcquireFastMutex(&ReaderFcb->DataListLock); } if (Pipe->WriteMode == FILE_PIPE_BYTE_STREAM_MODE) @@ -395,7 +624,7 @@ } } - KeReleaseSpinLock(&ReaderFcb->DataListLock, OldIrql); + ExReleaseFastMutex(&ReaderFcb->DataListLock); done: Irp->IoStatus.Status = Status;
19 years, 9 months
1
0
0
0
← Newer
1
...
7
8
9
10
11
12
13
...
61
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Results per page:
10
25
50
100
200