mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:43:00 +00:00
[FREELDR]
- Allow to specify in freeldr.ini the debugging port parameters, similarly to what NTLDR allows to do: http://naesten.blogspot.fr/2010/07/undocumented-debug-section-in-bootini.html - Update the FREELDR.INI example file to reflect these changes. - Because some FreeLdr components, that need to be initialized before the debugging port parameters can be read from freeldr.ini, use debugging features, we still need to choose some default parameters. For serial ports, we select the possible port starting from COM4 down to COM1. CORE-9023 #comment Revision 70403: Allow to specify a debugging port in freeldr.ini . svn path=/trunk/; revision=70403
This commit is contained in:
parent
46c7cd186e
commit
7642306ded
9 changed files with 273 additions and 111 deletions
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
; [FREELOADER] Section Commands:
|
; [FREELOADER] Section Commands:
|
||||||
;
|
;
|
||||||
|
; Debug - FreeLoader debugging port parameters, e.g. /DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200
|
||||||
; MessageBox - displays the specified text in a message box upon bootup
|
; MessageBox - displays the specified text in a message box upon bootup
|
||||||
; MessageLine - adds a new line of text to a message box (must come before MessageBox command)
|
; MessageLine - adds a new line of text to a message box (must come before MessageBox command)
|
||||||
; TitleText - text that is displayed in the title box
|
; TitleText - text that is displayed in the title box
|
||||||
|
@ -50,15 +51,15 @@
|
||||||
|
|
||||||
; [OS-General] Section Commands:
|
; [OS-General] Section Commands:
|
||||||
;
|
;
|
||||||
; BootType - sets the boot type: ReactOS, Linux, BootSector, Partition, Drive
|
; BootType - sets the boot type: Windows, WindowsNT40, Windows2003, Linux, BootSector, Partition, Drive, ReactOSSetup
|
||||||
; BootPath - ARC path e.g. multi(0)disk(0)rdisk(x)partition(y)
|
; BootPath - ARC path, e.g. multi(0)disk(0)rdisk(x)partition(y)
|
||||||
; DriveMap - maps a BIOS drive number to another (i.e. DriveMap=hd1,hd0 maps harddisk1 to harddisk0 or DriveMap=fd1,fd0)
|
; DriveMap - maps a BIOS drive number to another (i.e. DriveMap=hd1,hd0 maps harddisk1 to harddisk0 or DriveMap=fd1,fd0)
|
||||||
|
|
||||||
; [BootSector OSType] Section Commands:
|
; [BootSector OSType] Section Commands:
|
||||||
;
|
;
|
||||||
; BootSector - sets the filename of the bootsector to be loaded
|
; BootSector - sets the filename of the bootsector to be loaded
|
||||||
|
|
||||||
; [ReactOS OSType] Section Commands:
|
; [Windows(NT40|2003) OSType] Section Commands:
|
||||||
;
|
;
|
||||||
; SystemPath - sets the system root path (must be a valid ARC - Path):
|
; SystemPath - sets the system root path (must be a valid ARC - Path):
|
||||||
; multi(0)disk(0)rdisk(0)partition(1)\reactos
|
; multi(0)disk(0)rdisk(0)partition(1)\reactos
|
||||||
|
@ -110,7 +111,7 @@ DriveD="Drive D:"
|
||||||
|
|
||||||
; Load ReactOS from harddisk (drive C:)
|
; Load ReactOS from harddisk (drive C:)
|
||||||
[ReactOSHD]
|
[ReactOSHD]
|
||||||
BootType=ReactOS
|
BootType=Windows2003
|
||||||
SystemPath=multi(0)disk(0)rdisk(0)partition(1)\reactos
|
SystemPath=multi(0)disk(0)rdisk(0)partition(1)\reactos
|
||||||
Options=/DEBUGPORT=SCREEN
|
Options=/DEBUGPORT=SCREEN
|
||||||
Kernel=\REACTOS\SYSTEM32\NTOSKRNL.EXE
|
Kernel=\REACTOS\SYSTEM32\NTOSKRNL.EXE
|
||||||
|
@ -118,14 +119,14 @@ Hal=\REACTOS\SYSTEM32\HAL.DLL
|
||||||
|
|
||||||
; Load ReactOS from floppy (drive A:)
|
; Load ReactOS from floppy (drive A:)
|
||||||
[ReactOSFloppy]
|
[ReactOSFloppy]
|
||||||
BootType=ReactOS
|
BootType=Windows2003
|
||||||
SystemPath=multi(0)disk(0)fdisk(0)
|
SystemPath=multi(0)disk(0)fdisk(0)
|
||||||
Options=/DEBUGPORT=SCREEN
|
Options=/DEBUGPORT=SCREEN
|
||||||
Kernel=\reactos\NTOSKRNL.EXE
|
Kernel=\reactos\NTOSKRNL.EXE
|
||||||
Hal=\reactos\HAL.DLL
|
Hal=\reactos\HAL.DLL
|
||||||
|
|
||||||
;[ReactOS (Debug)]
|
;[ReactOS (Debug)]
|
||||||
;BootType=ReactOS
|
;BootType=Windows2003
|
||||||
;SystemPath=multi(0)disk(0)rdisk(0)partition(1)\reactos
|
;SystemPath=multi(0)disk(0)rdisk(0)partition(1)\reactos
|
||||||
;Options=/DEBUG /DEBUGPORT=COM1 /BAUDRATE=19200
|
;Options=/DEBUG /DEBUGPORT=COM1 /BAUDRATE=19200
|
||||||
;Kernel=\NTOSKRNL.EXE
|
;Kernel=\NTOSKRNL.EXE
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
/* INCLUDES *******************************************************************/
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
/* GLOBALS ********************************************************************/
|
/* GLOBALS ********************************************************************/
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ ULONG GetDefaultOperatingSystem(OperatingSystemItem* OperatingSystemList, ULONG
|
||||||
|
|
||||||
if (DefaultOSName != NULL)
|
if (DefaultOSName != NULL)
|
||||||
{
|
{
|
||||||
for (Idx = 0; Idx<OperatingSystemCount; Idx++)
|
for (Idx = 0; Idx < OperatingSystemCount; Idx++)
|
||||||
{
|
{
|
||||||
if (_stricmp(DefaultOSName, OperatingSystemList[Idx].SystemPartition) == 0)
|
if (_stricmp(DefaultOSName, OperatingSystemList[Idx].SystemPartition) == 0)
|
||||||
{
|
{
|
||||||
|
@ -208,6 +209,9 @@ VOID RunLoader(VOID)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Debugger main initialization */
|
||||||
|
DebugInit(TRUE);
|
||||||
|
|
||||||
if (!IniOpenSection("FreeLoader", &SectionId))
|
if (!IniOpenSection("FreeLoader", &SectionId))
|
||||||
{
|
{
|
||||||
UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
|
UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
|
||||||
|
@ -216,6 +220,7 @@ VOID RunLoader(VOID)
|
||||||
|
|
||||||
TimeOut = GetTimeOut();
|
TimeOut = GetTimeOut();
|
||||||
|
|
||||||
|
/* UI main initialization */
|
||||||
if (!UiInitialize(TRUE))
|
if (!UiInitialize(TRUE))
|
||||||
{
|
{
|
||||||
UiMessageBoxCritical("Unable to initialize UI.");
|
UiMessageBoxCritical("Unable to initialize UI.");
|
||||||
|
|
|
@ -14,25 +14,61 @@
|
||||||
|
|
||||||
typedef struct tagCMDLINEINFO
|
typedef struct tagCMDLINEINFO
|
||||||
{
|
{
|
||||||
const char *DefaultOperatingSystem;
|
PCCH DebugString;
|
||||||
|
PCCH DefaultOperatingSystem;
|
||||||
LONG TimeOut;
|
LONG TimeOut;
|
||||||
} CMDLINEINFO, *PCMDLINEINFO;
|
} CMDLINEINFO, *PCMDLINEINFO;
|
||||||
|
|
||||||
|
CCHAR DebugString[256];
|
||||||
CCHAR DefaultOs[256];
|
CCHAR DefaultOs[256];
|
||||||
CMDLINEINFO CmdLineInfo;
|
CMDLINEINFO CmdLineInfo;
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
CmdLineParse(IN PCHAR CmdLine)
|
CmdLineParse(IN PCCH CmdLine)
|
||||||
{
|
{
|
||||||
PCHAR End, Setting;
|
PCHAR End, Setting;
|
||||||
ULONG_PTR Length, Offset = 0;
|
ULONG_PTR Length, Offset = 0;
|
||||||
|
|
||||||
/* Set defaults */
|
/* Set defaults */
|
||||||
|
CmdLineInfo.DebugString = NULL;
|
||||||
CmdLineInfo.DefaultOperatingSystem = NULL;
|
CmdLineInfo.DefaultOperatingSystem = NULL;
|
||||||
CmdLineInfo.TimeOut = -1;
|
CmdLineInfo.TimeOut = -1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get debug string, in the following format:
|
||||||
|
* "debug=option1=XXX;option2=YYY;..."
|
||||||
|
* and translate it into the format:
|
||||||
|
* "OPTION1=XXX OPTION2=YYY ..."
|
||||||
|
*/
|
||||||
|
Setting = strstr(CmdLine, "debug=");
|
||||||
|
if (Setting)
|
||||||
|
{
|
||||||
|
/* Check if there are more command-line parameters following */
|
||||||
|
Setting += sizeof("debug=") + sizeof(ANSI_NULL);
|
||||||
|
End = strstr(Setting, " ");
|
||||||
|
if (End)
|
||||||
|
Length = End - Setting;
|
||||||
|
else
|
||||||
|
Length = sizeof(DebugString);
|
||||||
|
|
||||||
|
/* Copy the debug string and upcase it */
|
||||||
|
strncpy(DebugString, Setting, Length);
|
||||||
|
DebugString[Length - 1] = ANSI_NULL;
|
||||||
|
_strupr(DebugString);
|
||||||
|
|
||||||
|
/* Replace all separators ';' by spaces */
|
||||||
|
Setting = DebugString;
|
||||||
|
while (*Setting)
|
||||||
|
{
|
||||||
|
if (*Setting == ';') *Setting = ' ';
|
||||||
|
Setting++;
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdLineInfo.DebugString = DebugString;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get timeout */
|
/* Get timeout */
|
||||||
Setting = strstr(CmdLine, "timeout=");
|
Setting = strstr(CmdLine, "timeout=");
|
||||||
if (Setting) CmdLineInfo.TimeOut = atoi(Setting +
|
if (Setting) CmdLineInfo.TimeOut = atoi(Setting +
|
||||||
|
@ -43,7 +79,7 @@ CmdLineParse(IN PCHAR CmdLine)
|
||||||
Setting = strstr(CmdLine, "defaultos=");
|
Setting = strstr(CmdLine, "defaultos=");
|
||||||
if (Setting)
|
if (Setting)
|
||||||
{
|
{
|
||||||
/* Check if there's more command-line parameters following */
|
/* Check if there are more command-line parameters following */
|
||||||
Setting += sizeof("defaultos=") + sizeof(ANSI_NULL);
|
Setting += sizeof("defaultos=") + sizeof(ANSI_NULL);
|
||||||
End = strstr(Setting, " ");
|
End = strstr(Setting, " ");
|
||||||
if (End)
|
if (End)
|
||||||
|
@ -53,6 +89,7 @@ CmdLineParse(IN PCHAR CmdLine)
|
||||||
|
|
||||||
/* Copy the default OS */
|
/* Copy the default OS */
|
||||||
strncpy(DefaultOs, Setting, Length);
|
strncpy(DefaultOs, Setting, Length);
|
||||||
|
DefaultOs[Length - 1] = ANSI_NULL;
|
||||||
CmdLineInfo.DefaultOperatingSystem = DefaultOs;
|
CmdLineInfo.DefaultOperatingSystem = DefaultOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +121,12 @@ CmdLineParse(IN PCHAR CmdLine)
|
||||||
gRamDiskBase = (PVOID)((ULONG_PTR)gRamDiskBase + Offset);
|
gRamDiskBase = (PVOID)((ULONG_PTR)gRamDiskBase + Offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PCCH
|
||||||
|
CmdLineGetDebugString(VOID)
|
||||||
|
{
|
||||||
|
return CmdLineInfo.DebugString;
|
||||||
|
}
|
||||||
|
|
||||||
PCCH
|
PCCH
|
||||||
CmdLineGetDefaultOS(VOID)
|
CmdLineGetDefaultOS(VOID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,26 +21,36 @@
|
||||||
|
|
||||||
#ifndef _M_ARM
|
#ifndef _M_ARM
|
||||||
|
|
||||||
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
#include <cportlib/cportlib.h>
|
#include <cportlib/cportlib.h>
|
||||||
|
|
||||||
/* MACROS *******************************************************************/
|
|
||||||
|
|
||||||
#if DBG
|
#if DBG
|
||||||
|
|
||||||
|
/* STATIC VARIABLES ***********************************************************/
|
||||||
|
|
||||||
#define DEFAULT_BAUD_RATE 19200
|
#define DEFAULT_BAUD_RATE 19200
|
||||||
|
|
||||||
|
#if defined(_M_IX86) || defined(_M_AMD64)
|
||||||
|
static const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
|
||||||
|
#elif defined(_M_PPC)
|
||||||
|
static const ULONG BaseArray[] = {0, 0x800003F8};
|
||||||
|
#elif defined(_M_MIPS)
|
||||||
|
static const ULONG BaseArray[] = {0, 0x80006000, 0x80007000};
|
||||||
|
#elif defined(_M_ARM)
|
||||||
|
static const ULONG BaseArray[] = {0, 0xF1012000};
|
||||||
|
#else
|
||||||
|
#error Unknown architecture
|
||||||
|
#endif
|
||||||
|
|
||||||
/* STATIC VARIABLES *********************************************************/
|
#define MAX_COM_PORTS (sizeof(BaseArray) / sizeof(BaseArray[0]) - 1)
|
||||||
|
|
||||||
static ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
|
|
||||||
|
|
||||||
/* The COM port must only be initialized once! */
|
/* The COM port must only be initialized once! */
|
||||||
static CPPORT Rs232ComPort;
|
static ULONG Rs232ComPort = 0;
|
||||||
static BOOLEAN PortInitialized = FALSE;
|
static CPPORT Rs232ComPortInfo;
|
||||||
|
|
||||||
|
/* FUNCTIONS ******************************************************************/
|
||||||
/* FUNCTIONS *********************************************************/
|
|
||||||
|
|
||||||
BOOLEAN Rs232PortInitialize(IN ULONG ComPort,
|
BOOLEAN Rs232PortInitialize(IN ULONG ComPort,
|
||||||
IN ULONG BaudRate)
|
IN ULONG BaudRate)
|
||||||
|
@ -48,77 +58,73 @@ BOOLEAN Rs232PortInitialize(IN ULONG ComPort,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PUCHAR Address;
|
PUCHAR Address;
|
||||||
|
|
||||||
if (PortInitialized == FALSE)
|
/*
|
||||||
{
|
* Check whether it's the first time we initialize a COM port.
|
||||||
if (BaudRate == 0)
|
* If not, check whether the specified one was already initialized.
|
||||||
{
|
*/
|
||||||
BaudRate = DEFAULT_BAUD_RATE;
|
if ((Rs232ComPort != 0) && (Rs232ComPort == ComPort))
|
||||||
}
|
return TRUE;
|
||||||
|
|
||||||
if (ComPort == 0)
|
if (BaudRate == 0)
|
||||||
{
|
BaudRate = DEFAULT_BAUD_RATE;
|
||||||
if (CpDoesPortExist(UlongToPtr(BaseArray[2])))
|
|
||||||
{
|
if (ComPort == 0)
|
||||||
Address = UlongToPtr(BaseArray[2]);
|
{
|
||||||
}
|
/*
|
||||||
else if (CpDoesPortExist(UlongToPtr(BaseArray[1])))
|
* Start enumerating COM ports from the last one to the first one,
|
||||||
{
|
* and break when we find a valid port.
|
||||||
Address = UlongToPtr(BaseArray[1]);
|
* If we reach the first element of the list, the invalid COM port,
|
||||||
}
|
* then it means that no valid port was found.
|
||||||
else
|
*/
|
||||||
{
|
for (ComPort = MAX_COM_PORTS; ComPort > 0; ComPort--)
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (ComPort <= 4) // 4 == MAX_COM_PORTS
|
|
||||||
{
|
{
|
||||||
if (CpDoesPortExist(UlongToPtr(BaseArray[ComPort])))
|
if (CpDoesPortExist(UlongToPtr(BaseArray[ComPort])))
|
||||||
{
|
{
|
||||||
Address = UlongToPtr(BaseArray[ComPort]);
|
Address = UlongToPtr(BaseArray[ComPort]);
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
if (ComPort == 0)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
Status = CpInitialize(&Rs232ComPort, Address, BaudRate);
|
|
||||||
if (!NT_SUCCESS(Status)) return FALSE;
|
|
||||||
|
|
||||||
PortInitialized = TRUE;
|
|
||||||
}
|
}
|
||||||
|
else if (ComPort <= MAX_COM_PORTS)
|
||||||
|
{
|
||||||
|
if (CpDoesPortExist(UlongToPtr(BaseArray[ComPort])))
|
||||||
|
Address = UlongToPtr(BaseArray[ComPort]);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = CpInitialize(&Rs232ComPortInfo, Address, BaudRate);
|
||||||
|
if (!NT_SUCCESS(Status)) return FALSE;
|
||||||
|
|
||||||
|
Rs232ComPort = ComPort;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN Rs232PortGetByte(PUCHAR ByteReceived)
|
BOOLEAN Rs232PortGetByte(PUCHAR ByteReceived)
|
||||||
{
|
{
|
||||||
if (PortInitialized == FALSE)
|
if (Rs232ComPort == 0) return FALSE;
|
||||||
return FALSE;
|
return (CpGetByte(&Rs232ComPortInfo, ByteReceived, TRUE, FALSE) == CP_GET_SUCCESS);
|
||||||
|
|
||||||
return (CpGetByte(&Rs232ComPort, ByteReceived, TRUE, FALSE) == CP_GET_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BOOLEAN Rs232PortPollByte(PUCHAR ByteReceived)
|
BOOLEAN Rs232PortPollByte(PUCHAR ByteReceived)
|
||||||
{
|
{
|
||||||
if (PortInitialized == FALSE)
|
if (Rs232ComPort == 0) return FALSE;
|
||||||
return FALSE;
|
return (CpGetByte(&Rs232ComPortInfo, ByteReceived, FALSE, FALSE) == CP_GET_SUCCESS);
|
||||||
|
|
||||||
return (CpGetByte(&Rs232ComPort, ByteReceived, FALSE, FALSE) == CP_GET_SUCCESS);
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID Rs232PortPutByte(UCHAR ByteToSend)
|
VOID Rs232PortPutByte(UCHAR ByteToSend)
|
||||||
{
|
{
|
||||||
if (PortInitialized == FALSE)
|
if (Rs232ComPort == 0) return;
|
||||||
return;
|
CpPutByte(&Rs232ComPortInfo, ByteToSend);
|
||||||
|
|
||||||
CpPutByte(&Rs232ComPort, ByteToSend);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* DBG */
|
#endif /* DBG */
|
||||||
|
@ -126,7 +132,7 @@ VOID Rs232PortPutByte(UCHAR ByteToSend)
|
||||||
BOOLEAN Rs232PortInUse(PUCHAR Base)
|
BOOLEAN Rs232PortInUse(PUCHAR Base)
|
||||||
{
|
{
|
||||||
#if DBG
|
#if DBG
|
||||||
return ( (PortInitialized && (Rs232ComPort.Address == Base)) ? TRUE : FALSE );
|
return ( ((Rs232ComPort != 0) && (Rs232ComPortInfo.Address == Base)) ? TRUE : FALSE );
|
||||||
#else
|
#else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#if DBG && !defined(_M_ARM)
|
#if DBG && !defined(_M_ARM)
|
||||||
|
@ -33,36 +32,31 @@
|
||||||
|
|
||||||
#define DBG_DEFAULT_LEVELS (ERR_LEVEL|FIXME_LEVEL)
|
#define DBG_DEFAULT_LEVELS (ERR_LEVEL|FIXME_LEVEL)
|
||||||
|
|
||||||
|
static UCHAR DbgChannels[DBG_CHANNELS_COUNT];
|
||||||
|
|
||||||
#define SCREEN 1
|
#define SCREEN 1
|
||||||
#define RS232 2
|
#define RS232 2
|
||||||
#define BOCHS 4
|
#define BOCHS 4
|
||||||
|
|
||||||
#define COM1 1
|
#define BOCHS_OUTPUT_PORT 0xE9
|
||||||
#define COM2 2
|
|
||||||
#define COM3 3
|
|
||||||
#define COM4 4
|
|
||||||
|
|
||||||
#define BOCHS_OUTPUT_PORT 0xe9
|
|
||||||
|
|
||||||
static UCHAR DbgChannels[DBG_CHANNELS_COUNT];
|
|
||||||
|
|
||||||
ULONG DebugPort = RS232;
|
ULONG DebugPort = RS232;
|
||||||
// ULONG DebugPort = SCREEN;
|
|
||||||
// ULONG DebugPort = BOCHS;
|
/* Serial debug connection */
|
||||||
// ULONG DebugPort = SCREEN|BOCHS;
|
ULONG ComPort = 0; // The COM port initializer chooses the first available port starting from COM4 down to COM1.
|
||||||
#ifdef _WINKD_
|
|
||||||
/* COM1 is the WinDbg port */
|
|
||||||
ULONG ComPort = COM2;
|
|
||||||
#else
|
|
||||||
ULONG ComPort = COM1;
|
|
||||||
#endif
|
|
||||||
// ULONG BaudRate = 19200;
|
|
||||||
ULONG BaudRate = 115200;
|
ULONG BaudRate = 115200;
|
||||||
|
ULONG PortIrq = 0; // Not used at the moment.
|
||||||
|
|
||||||
BOOLEAN DebugStartOfLine = TRUE;
|
BOOLEAN DebugStartOfLine = TRUE;
|
||||||
|
|
||||||
VOID DebugInit(VOID)
|
VOID DebugInit(BOOLEAN MainInit)
|
||||||
{
|
{
|
||||||
|
PCHAR CommandLine, PortString, BaudString, IrqString;
|
||||||
|
ULONG Value;
|
||||||
|
CHAR DebugString[256];
|
||||||
|
|
||||||
|
/* Always reset the debugging channels */
|
||||||
|
|
||||||
#if defined (DEBUG_ALL)
|
#if defined (DEBUG_ALL)
|
||||||
memset(DbgChannels, MAX_LEVEL, DBG_CHANNELS_COUNT);
|
memset(DbgChannels, MAX_LEVEL, DBG_CHANNELS_COUNT);
|
||||||
#elif defined (DEBUG_WARN)
|
#elif defined (DEBUG_WARN)
|
||||||
|
@ -83,9 +77,121 @@ VOID DebugInit(VOID)
|
||||||
DbgChannels[DPRINT_WINDOWS] = MAX_LEVEL;
|
DbgChannels[DPRINT_WINDOWS] = MAX_LEVEL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Check for pre- or main initialization phase */
|
||||||
|
if (!MainInit)
|
||||||
|
{
|
||||||
|
/* Pre-initialization phase: use the FreeLdr command-line debugging string */
|
||||||
|
CommandLine = (PCHAR)CmdLineGetDebugString();
|
||||||
|
|
||||||
|
/* If no command-line is provided, initialize the debug port with default settings */
|
||||||
|
if (CommandLine == NULL)
|
||||||
|
goto Done;
|
||||||
|
|
||||||
|
strcpy(DebugString, CommandLine);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Main initialization phase: use the FreeLdr INI debugging string */
|
||||||
|
|
||||||
|
ULONG_PTR SectionId;
|
||||||
|
|
||||||
|
if (!IniOpenSection("FreeLoader", &SectionId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!IniReadSettingByName(SectionId, "Debug", DebugString, sizeof(DebugString)))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the Command Line */
|
||||||
|
CommandLine = DebugString;
|
||||||
|
|
||||||
|
/* Upcase it */
|
||||||
|
_strupr(CommandLine);
|
||||||
|
|
||||||
|
/* Get the port and baud rate */
|
||||||
|
PortString = strstr(CommandLine, "DEBUGPORT");
|
||||||
|
BaudString = strstr(CommandLine, "BAUDRATE");
|
||||||
|
IrqString = strstr(CommandLine, "IRQ");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if we got /DEBUGPORT parameters.
|
||||||
|
* NOTE: Inspired by reactos/ntoskrnl/kd/kdinit.c, KdInitSystem(...)
|
||||||
|
*/
|
||||||
|
while (PortString)
|
||||||
|
{
|
||||||
|
/* Move past the actual string, to reach the port*/
|
||||||
|
PortString += strlen("DEBUGPORT");
|
||||||
|
|
||||||
|
/* Now get past any spaces and skip the equal sign */
|
||||||
|
while (*PortString == ' ') PortString++;
|
||||||
|
PortString++;
|
||||||
|
|
||||||
|
/* Check for possible ports and set the port to use */
|
||||||
|
if (strncmp(PortString, "SCREEN", 6) == 0)
|
||||||
|
{
|
||||||
|
PortString += 6;
|
||||||
|
DebugPort |= SCREEN;
|
||||||
|
}
|
||||||
|
else if (strncmp(PortString, "BOCHS", 5) == 0)
|
||||||
|
{
|
||||||
|
PortString += 5;
|
||||||
|
DebugPort |= BOCHS;
|
||||||
|
}
|
||||||
|
else if (strncmp(PortString, "COM", 3) == 0)
|
||||||
|
{
|
||||||
|
PortString += 3;
|
||||||
|
DebugPort |= RS232;
|
||||||
|
|
||||||
|
/* Set the port to use */
|
||||||
|
Value = atol(PortString);
|
||||||
|
if (Value) ComPort = Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortString = strstr(PortString, "DEBUGPORT");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we got a baud rate */
|
||||||
|
if (BaudString)
|
||||||
|
{
|
||||||
|
/* Move past the actual string, to reach the rate */
|
||||||
|
BaudString += strlen("BAUDRATE");
|
||||||
|
|
||||||
|
/* Now get past any spaces */
|
||||||
|
while (*BaudString == ' ') BaudString++;
|
||||||
|
|
||||||
|
/* And make sure we have a rate */
|
||||||
|
if (*BaudString)
|
||||||
|
{
|
||||||
|
/* Read and set it */
|
||||||
|
Value = atol(BaudString + 1);
|
||||||
|
if (Value) BaudRate = Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check Serial Port Settings [IRQ] */
|
||||||
|
if (IrqString)
|
||||||
|
{
|
||||||
|
/* Move past the actual string, to reach the rate */
|
||||||
|
IrqString += strlen("IRQ");
|
||||||
|
|
||||||
|
/* Now get past any spaces */
|
||||||
|
while (*IrqString == ' ') IrqString++;
|
||||||
|
|
||||||
|
/* And make sure we have an IRQ */
|
||||||
|
if (*IrqString)
|
||||||
|
{
|
||||||
|
/* Read and set it */
|
||||||
|
Value = atol(IrqString + 1);
|
||||||
|
if (Value) PortIrq = Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Done:
|
||||||
|
/* Try to initialize the port; if it fails, remove the corresponding flag */
|
||||||
if (DebugPort & RS232)
|
if (DebugPort & RS232)
|
||||||
{
|
{
|
||||||
Rs232PortInitialize(ComPort, BaudRate);
|
if (!Rs232PortInitialize(ComPort, BaudRate))
|
||||||
|
DebugPort &= ~RS232;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +220,9 @@ VOID DebugPrintChar(UCHAR Character)
|
||||||
ULONG
|
ULONG
|
||||||
DbgPrint(const char *Format, ...)
|
DbgPrint(const char *Format, ...)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int Length;
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
int Length;
|
||||||
|
char* ptr;
|
||||||
CHAR Buffer[512];
|
CHAR Buffer[512];
|
||||||
|
|
||||||
va_start(ap, Format);
|
va_start(ap, Format);
|
||||||
|
@ -133,10 +239,9 @@ DbgPrint(const char *Format, ...)
|
||||||
Length = sizeof(Buffer);
|
Length = sizeof(Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < Length; i++)
|
ptr = Buffer;
|
||||||
{
|
while (Length--)
|
||||||
DebugPrintChar(Buffer[i]);
|
DebugPrintChar(*ptr++);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +254,7 @@ DbgPrint2(ULONG Mask, ULONG Level, const char *File, ULONG Line, char *Format, .
|
||||||
char *ptr = Buffer;
|
char *ptr = Buffer;
|
||||||
|
|
||||||
/* Mask out unwanted debug messages */
|
/* Mask out unwanted debug messages */
|
||||||
if (!(DbgChannels[Mask] & Level) && !(Level & DBG_DEFAULT_LEVELS ))
|
if (!(DbgChannels[Mask] & Level) && !(Level & DBG_DEFAULT_LEVELS))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -191,9 +296,8 @@ DbgPrint2(ULONG Mask, ULONG Level, const char *File, ULONG Line, char *Format, .
|
||||||
VOID
|
VOID
|
||||||
DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
|
DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
|
||||||
{
|
{
|
||||||
PUCHAR BufPtr = (PUCHAR)Buffer;
|
PUCHAR BufPtr = (PUCHAR)Buffer;
|
||||||
ULONG Idx;
|
ULONG Idx, Idx2;
|
||||||
ULONG Idx2;
|
|
||||||
|
|
||||||
/* Mask out unwanted debug messages */
|
/* Mask out unwanted debug messages */
|
||||||
if (!(DbgChannels[Mask] & TRACE_LEVEL))
|
if (!(DbgChannels[Mask] & TRACE_LEVEL))
|
||||||
|
@ -202,7 +306,7 @@ DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
|
||||||
DebugStartOfLine = FALSE; // We don't want line headers
|
DebugStartOfLine = FALSE; // We don't want line headers
|
||||||
DbgPrint("Dumping buffer at %p with length of %lu bytes:\n", Buffer, Length);
|
DbgPrint("Dumping buffer at %p with length of %lu bytes:\n", Buffer, Length);
|
||||||
|
|
||||||
for (Idx=0; Idx<Length; )
|
for (Idx = 0; Idx < Length; )
|
||||||
{
|
{
|
||||||
DebugStartOfLine = FALSE; // We don't want line headers
|
DebugStartOfLine = FALSE; // We don't want line headers
|
||||||
|
|
||||||
|
@ -215,7 +319,7 @@ DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
|
||||||
else
|
else
|
||||||
DbgPrint("%x:\t", Idx);
|
DbgPrint("%x:\t", Idx);
|
||||||
|
|
||||||
for (Idx2=0; Idx2<16; Idx2++,Idx++)
|
for (Idx2 = 0; Idx2 < 16; Idx2++, Idx++)
|
||||||
{
|
{
|
||||||
if (BufPtr[Idx] < 0x10)
|
if (BufPtr[Idx] < 0x10)
|
||||||
{
|
{
|
||||||
|
@ -236,7 +340,7 @@ DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
|
||||||
Idx -= 16;
|
Idx -= 16;
|
||||||
DbgPrint(" ");
|
DbgPrint(" ");
|
||||||
|
|
||||||
for (Idx2=0; Idx2<16; Idx2++,Idx++)
|
for (Idx2 = 0; Idx2 < 16; Idx2++, Idx++)
|
||||||
{
|
{
|
||||||
if ((BufPtr[Idx] > 20) && (BufPtr[Idx] < 0x80))
|
if ((BufPtr[Idx] > 20) && (BufPtr[Idx] < 0x80))
|
||||||
{
|
{
|
||||||
|
@ -257,10 +361,10 @@ DbgAddDebugChannel(CHAR* channel, CHAR* level, CHAR op)
|
||||||
{
|
{
|
||||||
int iLevel, iChannel;
|
int iLevel, iChannel;
|
||||||
|
|
||||||
if (channel == NULL || *channel == L'\0' || strlen(channel) == 0 )
|
if (channel == NULL || *channel == '\0' || strlen(channel) == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (level == NULL || *level == L'\0' || strlen(level) == 0 )
|
if (level == NULL || *level == '\0' || strlen(level) == 0)
|
||||||
iLevel = MAX_LEVEL;
|
iLevel = MAX_LEVEL;
|
||||||
else if (strcmp(level, "err") == 0)
|
else if (strcmp(level, "err") == 0)
|
||||||
iLevel = ERR_LEVEL;
|
iLevel = ERR_LEVEL;
|
||||||
|
@ -290,9 +394,9 @@ DbgAddDebugChannel(CHAR* channel, CHAR* level, CHAR op)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i= 0 ; i < DBG_CHANNELS_COUNT; i++)
|
for (i = 0; i < DBG_CHANNELS_COUNT; i++)
|
||||||
{
|
{
|
||||||
if(op==L'+')
|
if (op == '+')
|
||||||
DbgChannels[i] |= iLevel;
|
DbgChannels[i] |= iLevel;
|
||||||
else
|
else
|
||||||
DbgChannels[i] &= ~iLevel;
|
DbgChannels[i] &= ~iLevel;
|
||||||
|
@ -302,7 +406,7 @@ DbgAddDebugChannel(CHAR* channel, CHAR* level, CHAR op)
|
||||||
}
|
}
|
||||||
else return FALSE;
|
else return FALSE;
|
||||||
|
|
||||||
if (op == L'+')
|
if (op == '+')
|
||||||
DbgChannels[iChannel] |= iLevel;
|
DbgChannels[iChannel] |= iLevel;
|
||||||
else
|
else
|
||||||
DbgChannels[iChannel] &= ~iLevel;
|
DbgChannels[iChannel] &= ~iLevel;
|
||||||
|
|
|
@ -26,19 +26,21 @@ DBG_DEFAULT_CHANNEL(WARNING);
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
VOID __cdecl BootMain(LPSTR CmdLine)
|
VOID __cdecl BootMain(IN PCCH CmdLine)
|
||||||
{
|
{
|
||||||
CmdLineParse(CmdLine);
|
CmdLineParse(CmdLine);
|
||||||
MachInit(CmdLine);
|
MachInit(CmdLine);
|
||||||
FsInit();
|
FsInit();
|
||||||
|
|
||||||
DebugInit();
|
/* Debugger pre-initialization */
|
||||||
|
DebugInit(FALSE);
|
||||||
|
|
||||||
TRACE("BootMain() called.\n");
|
TRACE("BootMain() called.\n");
|
||||||
|
|
||||||
/* Check if the CPU is new enough */
|
/* Check if the CPU is new enough */
|
||||||
FrLdrCheckCpuCompatiblity();
|
FrLdrCheckCpuCompatiblity();
|
||||||
|
|
||||||
|
/* UI pre-initialization */
|
||||||
if (!UiInitialize(FALSE))
|
if (!UiInitialize(FALSE))
|
||||||
{
|
{
|
||||||
UiMessageBoxCritical("Unable to initialize UI.");
|
UiMessageBoxCritical("Unable to initialize UI.");
|
||||||
|
|
|
@ -19,8 +19,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
VOID CmdLineParse(IN PCHAR CmdLine);
|
VOID CmdLineParse(IN PCCH CmdLine);
|
||||||
|
|
||||||
|
PCCH CmdLineGetDebugString(VOID);
|
||||||
PCCH CmdLineGetDefaultOS(VOID);
|
PCCH CmdLineGetDefaultOS(VOID);
|
||||||
LONG CmdLineGetTimeOut(VOID);
|
LONG CmdLineGetTimeOut(VOID);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
#if DBG && !defined(_M_ARM)
|
#if DBG && !defined(_M_ARM)
|
||||||
|
|
||||||
VOID DebugInit(VOID);
|
VOID DebugInit(BOOLEAN MainInit);
|
||||||
ULONG DbgPrint(const char *Format, ...);
|
ULONG DbgPrint(const char *Format, ...);
|
||||||
VOID DbgPrint2(ULONG Mask, ULONG Level, const char *File, ULONG Line, char *Format, ...);
|
VOID DbgPrint2(ULONG Mask, ULONG Level, const char *File, ULONG Line, char *Format, ...);
|
||||||
VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length);
|
VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length);
|
||||||
|
@ -113,7 +113,7 @@ void MEMORY_WRITE_BREAKPOINT4(unsigned long addr);
|
||||||
|
|
||||||
#define UNIMPLEMENTED
|
#define UNIMPLEMENTED
|
||||||
|
|
||||||
#define DebugInit()
|
#define DebugInit(init)
|
||||||
#define BugCheck(fmt, ...)
|
#define BugCheck(fmt, ...)
|
||||||
#define DbgDumpBuffer(mask, buf, len)
|
#define DbgDumpBuffer(mask, buf, len)
|
||||||
#define DbgParseDebugChannels(val)
|
#define DbgParseDebugChannels(val)
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
#include <arch/mips/arcbios.h>
|
#include <arch/mips/arcbios.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VOID __cdecl BootMain(LPSTR CmdLine);
|
VOID __cdecl BootMain(IN PCCH CmdLine);
|
||||||
VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem);
|
VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem);
|
||||||
VOID RunLoader(VOID);
|
VOID RunLoader(VOID);
|
||||||
VOID FrLdrCheckCpuCompatiblity(VOID);
|
VOID FrLdrCheckCpuCompatiblity(VOID);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue