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

View file

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

View file

@ -1373,7 +1373,8 @@ PcHwDetect(VOID)
/* Create the 'System' key */ /* Create the 'System' key */
FldrCreateSystemKey(&SystemKey); 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; GetHarddiskConfigurationData = PcGetHarddiskConfigurationData;
FindPciBios = PcFindPciBios; FindPciBios = PcFindPciBios;

View file

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

View file

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

View file

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

View file

@ -1,28 +1,17 @@
/* /*
* FreeLoader * PROJECT: FreeLoader
* * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* This program is free software; you can redistribute it and/or modify * PURPOSE: VGA font 8x16
* it under the terms of the GNU General Public License as published by * COPYRIGHT: Copyright 2004 van Geldorp (gvg@reactos.org)
* 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
*/ */
/* Note: Converted from the XFree vga.bdf font */
#include <freeldr.h> #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,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,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 */ 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 */ /* EOF */

View file

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

View file

@ -46,7 +46,7 @@
#define NV2A_RAMDAC_FP_HVALID_END (0x838 + NV2A_RAMDAC_OFFSET) #define NV2A_RAMDAC_FP_HVALID_END (0x838 + NV2A_RAMDAC_OFFSET)
#define NV2A_RAMDAC_FP_VVALID_END (0x818 + 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); VOID XboxConsPutChar(int Ch);
BOOLEAN XboxConsKbHit(VOID); BOOLEAN XboxConsKbHit(VOID);

View file

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

View file

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