[FREELDR] Minor code improvements

- Add missing allocation check in DetectApmBios()
- Check 'PM' signature in FindApmBios()
- Properly set machine type in hardware detection
- Set Component->Key value for hard drives
- Get rid of the unused XboxBeep()
- Cast Xbox LPC I/O ports to PUCHAR
- Improve shadow rendering with VGA font
- Include ntoskrnl.h in the proper order
This commit is contained in:
Dmitry Borisov 2020-03-06 01:48:00 +06:00 committed by Hermès BÉLUSCA - MAÏTO
parent c14cc22bfd
commit 97eacb9fb4
11 changed files with 62 additions and 91 deletions

View file

@ -1,21 +1,8 @@
/*
* FreeLoader
*
* Copyright (C) 2004 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* PROJECT: FreeLoader
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: APM BIOS detection routines
* COPYRIGHT: Copyright 2004 Eric Kohl (eric.kohl@reactos.org)
*/
#include <freeldr.h>
@ -26,9 +13,9 @@ DBG_DEFAULT_CHANNEL(HWDETECT);
static BOOLEAN
FindApmBios(VOID)
{
REGS RegsIn;
REGS RegsOut;
REGS RegsIn, RegsOut;
/* APM BIOS - Installation check */
#if defined(SARCH_PC98)
RegsIn.w.ax = 0x9A00;
RegsIn.w.bx = 0x0000;
@ -38,7 +25,7 @@ FindApmBios(VOID)
RegsIn.w.bx = 0x0000;
Int386(0x15, &RegsIn, &RegsOut);
#endif
if (INT386_SUCCESS(RegsOut))
if (INT386_SUCCESS(RegsOut) && RegsOut.w.bx == 'PM')
{
TRACE("Found APM BIOS\n");
TRACE("AH: %x\n", RegsOut.b.ah);
@ -55,7 +42,6 @@ FindApmBios(VOID)
return FALSE;
}
VOID
DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
{
@ -63,35 +49,40 @@ DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
ULONG Size;
if (!FindApmBios())
return;
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
if (FindApmBios())
/* Set 'Configuration Data' value */
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
if (PartialResourceList == NULL)
{
/* Create 'Configuration Data' value */
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
memset(PartialResourceList, 0, Size);
PartialResourceList->Version = 0;
PartialResourceList->Revision = 0;
PartialResourceList->Count = 0;
/* Create new bus key */
FldrCreateComponentKey(SystemKey,
AdapterClass,
MultiFunctionAdapter,
0x0,
0x0,
0xFFFFFFFF,
"APM",
PartialResourceList,
Size,
&BiosKey);
/* Increment bus number */
(*BusNumber)++;
ERR("Failed to allocate resource descriptor\n");
return;
}
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 0;
PartialResourceList->Revision = 0;
PartialResourceList->Count = 0;
/* FIXME: Add configuration data */
/* Create new bus key */
FldrCreateComponentKey(SystemKey,
AdapterClass,
MultiFunctionAdapter,
0x0,
0,
0xFFFFFFFF,
"APM",
PartialResourceList,
Size,
&BiosKey);
/* Increment bus number */
(*BusNumber)++;
}
/* EOF */

View file

@ -8,8 +8,8 @@
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#include <freeldr.h>
#include <ntoskrnl.h>
/* FUNCTIONS *****************************************************************/

View file

@ -1373,7 +1373,8 @@ PcHwDetect(VOID)
/* Create the 'System' key */
FldrCreateSystemKey(&SystemKey);
// TODO: Discover and set the machine type as the Component->Identifier
// TODO: Discover and set the other machine types
FldrSetIdentifier(SystemKey, "AT/AT COMPATIBLE");
GetHarddiskConfigurationData = PcGetHarddiskConfigurationData;
FindPciBios = PcFindPciBios;

View file

@ -426,7 +426,7 @@ DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
PeripheralClass,
DiskPeripheral,
Output | Input,
0x0,
i,
0xFFFFFFFF,
Identifier,
PartialResourceList,

View file

@ -10,7 +10,7 @@
#include <freeldr.h>
#include <drivers/pc98/video.h>
extern UCHAR XboxFont8x16[];
extern UCHAR BitmapFont8x16[];
extern BOOLEAN HiResoMachine;
/* GLOBALS ********************************************************************/
@ -241,7 +241,7 @@ Pc98VideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
UCHAR R = (Attr & 0x40) ? 0xFF : 0;
UCHAR I = (Attr & 0x80) ? 0xFF : 0;
ULONG VramOffset = X + (Y * CHAR_HEIGHT) * BYTES_PER_SCANLINE;
PUCHAR FontPtr = XboxFont8x16 + Ch * 16;
PUCHAR FontPtr = BitmapFont8x16 + Ch * 16;
for (Line = 0; Line < CHAR_HEIGHT; Line++)
{

View file

@ -50,29 +50,29 @@ XboxGetSerialPort(ULONG Index, PULONG Irq)
ULONG ComBase = 0;
// Enter Configuration
WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_ENTER_CONFIG_KEY);
WRITE_PORT_UCHAR((PUCHAR)LPC_IO_BASE, LPC_ENTER_CONFIG_KEY);
// Select serial device
WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_NUMBER);
WRITE_PORT_UCHAR(LPC_IO_BASE + 1, Device[Index]);
WRITE_PORT_UCHAR((PUCHAR)LPC_IO_BASE, LPC_CONFIG_DEVICE_NUMBER);
WRITE_PORT_UCHAR((PUCHAR)(LPC_IO_BASE + 1), Device[Index]);
// Check if selected device is active
WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_ACTIVATE);
if (READ_PORT_UCHAR(LPC_IO_BASE + 1) == 1)
WRITE_PORT_UCHAR((PUCHAR)LPC_IO_BASE, LPC_CONFIG_DEVICE_ACTIVATE);
if (READ_PORT_UCHAR((PUCHAR)(LPC_IO_BASE + 1)) == 1)
{
// Read LSB
WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_BASE_ADDRESS_LOW);
ComBase = READ_PORT_UCHAR(LPC_IO_BASE + 1);
WRITE_PORT_UCHAR((PUCHAR)LPC_IO_BASE, LPC_CONFIG_DEVICE_BASE_ADDRESS_LOW);
ComBase = READ_PORT_UCHAR((PUCHAR)(LPC_IO_BASE + 1));
// Read MSB
WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_BASE_ADDRESS_HIGH);
ComBase |= (READ_PORT_UCHAR(LPC_IO_BASE + 1) << 8);
WRITE_PORT_UCHAR((PUCHAR)LPC_IO_BASE, LPC_CONFIG_DEVICE_BASE_ADDRESS_HIGH);
ComBase |= (READ_PORT_UCHAR((PUCHAR)(LPC_IO_BASE + 1)) << 8);
// Read IRQ
WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_INTERRUPT);
*Irq = READ_PORT_UCHAR(LPC_IO_BASE + 1);
WRITE_PORT_UCHAR((PUCHAR)LPC_IO_BASE, LPC_CONFIG_DEVICE_INTERRUPT);
*Irq = READ_PORT_UCHAR((PUCHAR)(LPC_IO_BASE + 1));
}
// Exit Configuration
WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_EXIT_CONFIG_KEY);
WRITE_PORT_UCHAR((PUCHAR)LPC_IO_BASE, LPC_EXIT_CONFIG_KEY);
return ComBase;
}

View file

@ -1,28 +1,17 @@
/*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Note: Converted from the XFree vga.bdf font
* PROJECT: FreeLoader
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: VGA font 8x16
* COPYRIGHT: Copyright 2004 van Geldorp (gvg@reactos.org)
*/
/* Note: Converted from the XFree vga.bdf font */
#include <freeldr.h>
UCHAR XboxFont8x16[256 * 16] =
UCHAR BitmapFont8x16[256 * 16] =
{
0x00,0x00,0x00,0x7c,0xc6,0xc6,0xde,0xde,0xde,0xdc,0xc0,0x7c,0x00,0x00,0x00,0x00, /* 0x00 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x00 */
0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xa5,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, /* 0x01 */
0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xdb,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00, /* 0x02 */
0x00,0x00,0x00,0x00,0x6c,0xfe,0xfe,0xfe,0xfe,0x7c,0x38,0x10,0x00,0x00,0x00,0x00, /* 0x03 */
@ -281,4 +270,3 @@ UCHAR XboxFont8x16[256 * 16] =
};
/* EOF */

View file

@ -50,7 +50,7 @@ XboxVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgC
unsigned Line;
unsigned Col;
FontPtr = XboxFont8x16 + Char * 16;
FontPtr = BitmapFont8x16 + Char * 16;
Pixel = (PULONG) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
+ X * CHAR_WIDTH * BytesPerPixel);
for (Line = 0; Line < CHAR_HEIGHT; Line++)
@ -290,13 +290,6 @@ XboxVideoSync(VOID)
/* Not supported */
}
VOID
XboxBeep(VOID)
{
/* Call PC version */
PcBeep();
}
VOID
XboxVideoPrepareForReactOS(VOID)
{

View file

@ -46,7 +46,7 @@
#define NV2A_RAMDAC_FP_HVALID_END (0x838 + NV2A_RAMDAC_OFFSET)
#define NV2A_RAMDAC_FP_VVALID_END (0x818 + NV2A_RAMDAC_OFFSET)
extern UCHAR XboxFont8x16[256 * 16];
extern UCHAR BitmapFont8x16[256 * 16];
VOID XboxConsPutChar(int Ch);
BOOLEAN XboxConsKbHit(VOID);

View file

@ -19,7 +19,6 @@
#pragma once
#define TUI_SCREEN_MEM 0xB8000
#define TITLE_BOX_CHAR_HEIGHT 5
///////////////////////////////////////////////////////////////////////////////////////

View file

@ -19,7 +19,6 @@
#pragma once
#define TUI_SCREEN_MEM 0xB8000
#define TUI_TITLE_BOX_CHAR_HEIGHT 5
///////////////////////////////////////////////////////////////////////////////////////