From 79eff41abbee7c1b732b7492b59e0bdb99b61cb4 Mon Sep 17 00:00:00 2001 From: David Welch Date: Fri, 24 Mar 2000 22:25:39 +0000 Subject: [PATCH] Connected standard input/output to the console Removed from superfluous assertions Changed the ide read and write commands to work with bochs Corrected bug in the csrss server svn path=/trunk/; revision=1089 --- reactos/drivers/dd/ide/ide.c | 8 ++- reactos/install.bochs | 2 + reactos/lib/kernel32/misc/console.c | 25 ++++---- reactos/lib/kernel32/process/create.c | 11 +++- reactos/ntoskrnl/io/create.c | 2 +- reactos/ntoskrnl/kd/kdebug.c | 91 +++++++++++++-------------- reactos/ntoskrnl/makefile_rex | 51 ++++++++++++++- reactos/ntoskrnl/mm/marea.c | 7 ++- reactos/subsys/csrss/api/handle.c | 7 ++- 9 files changed, 129 insertions(+), 75 deletions(-) diff --git a/reactos/drivers/dd/ide/ide.c b/reactos/drivers/dd/ide/ide.c index a07209acb15..63d2cbca284 100644 --- a/reactos/drivers/dd/ide/ide.c +++ b/reactos/drivers/dd/ide/ide.c @@ -1,4 +1,4 @@ -/* $Id: ide.c,v 1.26 2000/01/06 00:26:16 dwelch Exp $ +/* $Id: ide.c,v 1.27 2000/03/24 22:25:39 dwelch Exp $ * * IDE.C - IDE Disk driver * written by Rex Jolliff @@ -826,7 +826,8 @@ IDEGetPartitionTable(IN int CommandPort, CylinderLow, CylinderHigh, DrvHead, - IDE_CMD_READ_RETRY, +// IDE_CMD_READ_RETRY, + IDE_CMD_READ, SectorBuf); if (RC != 0) { @@ -1456,7 +1457,8 @@ IDEStartController(IN OUT PVOID Context) CylinderHigh = StartingSector >> 8; } Command = DeviceExtension->Operation == IRP_MJ_READ ? - IDE_CMD_READ_RETRY : IDE_CMD_WRITE_RETRY; +// IDE_CMD_READ_RETRY : IDE_CMD_WRITE_RETRY; + IDE_CMD_READ : IDE_CMD_WRITE; if (DrvHead & IDE_DH_LBA) { DPRINT("%s:DRV=%d:LBA=1:BLK=%08d:SC=%02x:CM=%02x\n", diff --git a/reactos/install.bochs b/reactos/install.bochs index ddb05d04d9c..20d51262ba0 100644 --- a/reactos/install.bochs +++ b/reactos/install.bochs @@ -1,7 +1,9 @@ #!/bin/sh +echo "Installing to floppy." mount -t vfat /bochs/1.44a /mnt/floppy -o loop,rw ./install-system.sh /mnt/floppy umount /mnt/floppy +echo "Installing to disk." mount -t vfat /bochs/10M.vga /mnt/floppy -o loop,rw ./install.sh /mnt/floppy umount /mnt/floppy diff --git a/reactos/lib/kernel32/misc/console.c b/reactos/lib/kernel32/misc/console.c index 282333a8f93..18f4c7d6287 100644 --- a/reactos/lib/kernel32/misc/console.c +++ b/reactos/lib/kernel32/misc/console.c @@ -24,12 +24,6 @@ #define NDEBUG #include -/* GLOBALS ******************************************************************/ - -static HANDLE StdInput = INVALID_HANDLE_VALUE; -static HANDLE StdOutput = INVALID_HANDLE_VALUE; -static HANDLE StdError = INVALID_HANDLE_VALUE; - /* FUNCTIONS *****************************************************************/ WINBOOL STDCALL CloseConsoleHandle(HANDLE Handle) @@ -51,14 +45,17 @@ BOOLEAN IsConsoleHandle(HANDLE Handle) */ HANDLE STDCALL GetStdHandle(DWORD nStdHandle) { + PRTL_USER_PROCESS_PARAMETERS Ppb; + DPRINT("GetStdHandle(nStdHandle %d)\n",nStdHandle); SetLastError(ERROR_SUCCESS); /* OK */ + Ppb = NtCurrentPeb()->ProcessParameters; switch (nStdHandle) { - case STD_INPUT_HANDLE: return StdInput; - case STD_OUTPUT_HANDLE: return StdOutput; - case STD_ERROR_HANDLE: return StdError; + case STD_INPUT_HANDLE: return Ppb->InputHandle; + case STD_OUTPUT_HANDLE: return Ppb->OutputHandle; + case STD_ERROR_HANDLE: return Ppb->ErrorHandle; } SetLastError(0); /* FIXME: What error code? */ return INVALID_HANDLE_VALUE; @@ -71,6 +68,10 @@ HANDLE STDCALL GetStdHandle(DWORD nStdHandle) WINBASEAPI BOOL WINAPI SetStdHandle(DWORD nStdHandle, HANDLE hHandle) { + PRTL_USER_PROCESS_PARAMETERS Ppb; + + Ppb = NtCurrentPeb()->ProcessParameters; + /* More checking needed? */ if (hHandle == INVALID_HANDLE_VALUE) { @@ -82,13 +83,13 @@ WINBASEAPI BOOL WINAPI SetStdHandle(DWORD nStdHandle, switch (nStdHandle) { case STD_INPUT_HANDLE: - StdInput = hHandle; + Ppb->InputHandle = hHandle; return TRUE; case STD_OUTPUT_HANDLE: - StdOutput = hHandle; + Ppb->OutputHandle = hHandle; return TRUE; case STD_ERROR_HANDLE: - StdError = hHandle; + Ppb->ErrorHandle = hHandle; return TRUE; } SetLastError(0); /* FIXME: What error code? */ diff --git a/reactos/lib/kernel32/process/create.c b/reactos/lib/kernel32/process/create.c index 6fe13d4ee5e..4740a0a6e2d 100644 --- a/reactos/lib/kernel32/process/create.c +++ b/reactos/lib/kernel32/process/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.25 2000/03/22 18:35:48 dwelch Exp $ +/* $Id: create.c,v 1.26 2000/03/24 22:25:37 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -246,6 +246,7 @@ HANDLE KlMapFile(LPCWSTR lpApplicationName, if (!NT_SUCCESS(Status)) { + DPRINT("Failed to open file\n"); SetLastError(RtlNtStatusToDosError(Status)); return(NULL); } @@ -261,6 +262,7 @@ HANDLE KlMapFile(LPCWSTR lpApplicationName, if (!NT_SUCCESS(Status)) { + DPRINT("Failed to create section\n"); SetLastError(RtlNtStatusToDosError(Status)); return(NULL); } @@ -419,7 +421,7 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName, } if (e != NULL) { - *e = 0; + *e = '.'; } /* @@ -515,7 +517,10 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName, */ DPRINT("Creating peb\n"); - Ppb->ConsoleHandle = ConsoleHandle; + Ppb->ConsoleHandle = ConsoleHandle; + Ppb->InputHandle = ConsoleHandle; + Ppb->OutputHandle = ConsoleHandle; + Ppb->ErrorHandle = ConsoleHandle; KlInitPeb(hProcess, Ppb); RtlDestroyProcessParameters (Ppb); diff --git a/reactos/ntoskrnl/io/create.c b/reactos/ntoskrnl/io/create.c index a31ee49f429..e6a29f933ba 100644 --- a/reactos/ntoskrnl/io/create.c +++ b/reactos/ntoskrnl/io/create.c @@ -208,7 +208,7 @@ NtCreateFile ( KEVENT Event; PIO_STACK_LOCATION StackLoc; - DPRINT("NtCreateFile(FileHandle %x, DesiredAccess %x, " + DPRINT1("NtCreateFile(FileHandle %x, DesiredAccess %x, " "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n", FileHandle,DesiredAccess,ObjectAttributes, ObjectAttributes->ObjectName->Buffer); diff --git a/reactos/ntoskrnl/kd/kdebug.c b/reactos/ntoskrnl/kd/kdebug.c index 61326d89481..e8e45727983 100644 --- a/reactos/ntoskrnl/kd/kdebug.c +++ b/reactos/ntoskrnl/kd/kdebug.c @@ -1,4 +1,4 @@ -/* $Id: kdebug.c,v 1.8 2000/03/04 22:02:13 ekohl Exp $ +/* $Id: kdebug.c,v 1.9 2000/03/24 22:25:38 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -26,13 +26,9 @@ /* TYPEDEFS ****************************************************************/ -typedef enum -{ - ScreenDebug, - SerialDebug, - BochsDebug -} DEBUGTYPE; - +#define ScreenDebug (0x1) +#define SerialDebug (0x2) +#define BochsDebug (0x4) /* VARIABLES ***************************************************************/ @@ -47,7 +43,7 @@ KdDebuggerNotPresent = TRUE; /* EXPORTED */ static BOOLEAN KdpBreakPending = FALSE; static BOOLEAN KdpBreakRecieved = FALSE; -static DEBUGTYPE KdpDebugType = ScreenDebug; +static ULONG KdpDebugType = ScreenDebug | BochsDebug; /* PRIVATE FUNCTIONS ********************************************************/ @@ -99,13 +95,13 @@ KdInitSystem ( { p2 += 6; KdDebuggerEnabled = TRUE; - KdpDebugType = ScreenDebug; + KdpDebugType |= ScreenDebug; } else if (!_strnicmp (p2, "BOCHS", 5)) { p2 += 5; KdDebuggerEnabled = TRUE; - KdpDebugType = BochsDebug; + KdpDebugType |= BochsDebug; } else if (!_strnicmp (p2, "COM", 3)) { @@ -114,7 +110,7 @@ KdInitSystem ( if (Value > 0 && Value < 5) { KdDebuggerEnabled = TRUE; - KdpDebugType = SerialDebug; + KdpDebugType |= SerialDebug; PortInfo.ComPort = Value; } } @@ -208,15 +204,15 @@ KdInitSystem ( /* print some information */ if (KdDebuggerEnabled == TRUE) { - if (KdpDebugType == ScreenDebug) + if (KdpDebugType & ScreenDebug) { PrintString ("\n Screen debugging enabled\n\n"); } - else if (KdpDebugType == BochsDebug) + if (KdpDebugType & BochsDebug) { PrintString ("\n Bochs debugging enabled\n\n"); } - else if (KdpDebugType == SerialDebug) + if (KdpDebugType & SerialDebug) { PrintString ("\n Serial debugging enabled: COM%ld %ld Baud\n\n", PortInfo.ComPort, PortInfo.BaudRate); @@ -236,41 +232,40 @@ KdInitSystem ( } -ULONG -KdpPrintString (PANSI_STRING String) +ULONG KdpPrintString (PANSI_STRING String) { - PCH pch = String->Buffer; - - if (KdpDebugType == ScreenDebug) - { - HalDisplayString (String->Buffer); + PCH pch = String->Buffer; + + if (KdpDebugType & ScreenDebug) + { + HalDisplayString (String->Buffer); + } + if (KdpDebugType & SerialDebug) + { + while (*pch != 0) + { + if (*pch == '\n') + { + KdPortPutByte ('\r'); + } + KdPortPutByte (*pch); + pch++; + } } - else if (KdpDebugType == SerialDebug) - { - while (*pch != 0) - { - if (*pch == '\n') - { - KdPortPutByte ('\r'); - } - KdPortPutByte (*pch); - pch++; - } - } - else if (KdpDebugType == BochsDebug) - { - while (*pch != 0) - { - if (*pch == '\n') - { - WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, '\r'); - } - WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, *pch); - pch++; - } - } - - return (ULONG)String->Length; + if (KdpDebugType & BochsDebug) + { + while (*pch != 0) + { + if (*pch == '\n') + { + WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, '\r'); + } + WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, *pch); + pch++; + } + } + + return (ULONG)String->Length; } /* PUBLIC FUNCTIONS *********************************************************/ diff --git a/reactos/ntoskrnl/makefile_rex b/reactos/ntoskrnl/makefile_rex index f5059490dba..e48ff36633f 100644 --- a/reactos/ntoskrnl/makefile_rex +++ b/reactos/ntoskrnl/makefile_rex @@ -1,4 +1,4 @@ -# $Id: makefile_rex,v 1.62 2000/03/19 09:14:49 ea Exp $ +# $Id: makefile_rex,v 1.63 2000/03/24 22:25:37 dwelch Exp $ # # ReactOS Operating System # @@ -8,7 +8,7 @@ TARGET=ntoskrnl BASE_CFLAGS = -I../include -D__NTOSKRNL__ -all: objects $(TARGET).exe +all: objects $(TARGET).exe $(TARGET).nostrip.exe # # Defines $(HAL_OBJECTS) @@ -168,10 +168,54 @@ CLEAN_FILES = objects/*.o cc/*.o cm/*.o dbg/*.o ex/*.o hal/x86/*.o io/*.o \ endif +$(TARGET).nostrip.exe: $(OBJECTS) $(TARGET).def + $(LD) \ + -r $(OBJECTS) \ + -o $(TARGET).o + $(DLLTOOL) \ + --dllname $(TARGET).exe \ + --def $(TARGET).def \ + --kill-at \ + --output-lib $(TARGET).a + $(CC) \ + $(TARGET).o \ + -Wl,-d -specs=../specs \ + -mdll \ + -o junk.tmp \ + -Wl,--image-base,0xc0000000 \ + -Wl,--file-alignment,0x1000 \ + -Wl,--section-alignment,0x1000 \ + -Wl,--defsym,_edata=__data_end__ \ + -Wl,--defsym,_end=__bss_end__ \ + -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp + - $(RM) junk.tmp + $(DLLTOOL) \ + --dllname $(TARGET).exe \ + --base-file base.tmp \ + --output-exp temp.exp \ + --def $(TARGET).edf \ + --kill-at + - $(RM) base.tmp + $(CC) \ + $(TARGET).o \ + -Wl,-d -specs=../specs \ + -mdll \ + -o $(TARGET).nostrip.exe \ + -Wl,--image-base,0xc0000000 \ + -Wl,--file-alignment,0x1000 \ + -Wl,--section-alignment,0x1000 \ + -Wl,--defsym,_end=__bss_end__ \ + -Wl,--defsym,_edata=__data_end__ \ + -Wl,--defsym,_etext=etext \ + -Wl,temp.exp + - $(RM) temp.exp + $(TARGET).exe: $(OBJECTS) $(TARGET).def $(LD) \ -r $(OBJECTS) \ -o $(TARGET).o + $(STRIP) --strip-debug $(TARGET).o $(DLLTOOL) \ --dllname $(TARGET).exe \ --def $(TARGET).def \ @@ -212,6 +256,7 @@ $(TARGET).exe: $(OBJECTS) $(TARGET).def - $(RM) temp.exp $(NM) --numeric-sort $(TARGET).exe > $(TARGET).sym + $(TARGET).o: $(OBJECTS) $(LD) \ -r $(OBJECTS) \ @@ -256,7 +301,7 @@ ex/napi.o: ex/napi.c ../include/ntdll/napi.h ke/main.o: ke/main.c ../include/reactos/buildno.h -#WITH_DEBUGGING = yes +WITH_DEBUGGING = yes WIN32_LEAN_AND_MEAN = yes WARNINGS_ARE_ERRORS = yes include ../rules.mak diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index bf413f16074..a953193eecb 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -295,6 +295,9 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process, DPRINT("marea->Length %x\n",marea->Length); ListHead=MmGetRelatedListHead(Process,marea->BaseAddress); + +// MmDumpMemoryAreas(ListHead); + current_entry = ListHead->Flink; CHECKPOINT; if (IsListEmpty(ListHead)) @@ -322,8 +325,8 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process, // CHECKPOINT; current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry); next = CONTAINING_RECORD(current_entry->Flink,MEMORY_AREA,Entry); - assert(current->BaseAddress != marea->BaseAddress); - assert(next->BaseAddress != marea->BaseAddress); +// assert(current->BaseAddress != marea->BaseAddress); +// assert(next->BaseAddress != marea->BaseAddress); if (current->BaseAddress < marea->BaseAddress && current->Entry.Flink==ListHead) { diff --git a/reactos/subsys/csrss/api/handle.c b/reactos/subsys/csrss/api/handle.c index 30f90950a6d..023c79ea44d 100644 --- a/reactos/subsys/csrss/api/handle.c +++ b/reactos/subsys/csrss/api/handle.c @@ -1,4 +1,4 @@ -/* $Id: handle.c,v 1.3 2000/03/22 18:36:00 dwelch Exp $ +/* $Id: handle.c,v 1.4 2000/03/24 22:25:39 dwelch Exp $ * * reactos/subsys/csrss/api/handle.c * @@ -20,7 +20,7 @@ NTSTATUS CsrGetObject(PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, PVOID* Object) { - *Object = ProcessData->HandleTable[(ULONG)Handle]; + *Object = ProcessData->HandleTable[((ULONG)Handle) - 1]; return(STATUS_SUCCESS); } @@ -56,8 +56,9 @@ NTSTATUS CsrInsertObject(PCSRSS_PROCESS_DATA ProcessData, RtlCopyMemory(NewBlock, ProcessData->HandleTable, ProcessData->HandleTableSize * sizeof(HANDLE)); + ProcessData->HandleTable = NewBlock; ProcessData->HandleTable[i] = Object; - *Handle = (HANDLE)((i << 8) | 0x3); + *Handle = (HANDLE)(((i + 1) << 8) | 0x3); ProcessData->HandleTableSize = ProcessData->HandleTableSize + 64; return(STATUS_SUCCESS);