ReactOS 0.4.16-dev-336-gb667d82
machpc98.c
Go to the documentation of this file.
1/*
2 * PROJECT: FreeLoader
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Hardware-specific routines for NEC PC-98 series
5 * COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
6 */
7
8/* INCLUDES *******************************************************************/
9
10#include <freeldr.h>
11
12#include <debug.h>
14
15/* GLOBALS ********************************************************************/
16
18
19/* FUNCTIONS ******************************************************************/
20
21VOID
23{
26}
27
28VOID
30{
31 /* Unimplemented */
32}
33
34VOID
36{
41}
42
45{
46 PPC98_DISK_DRIVE DiskDrive;
47
48 DiskDrive = Pc98DiskDriveNumberToDrive(DriveNumber);
49 if (!DiskDrive)
50 {
51 ERR("Failed to get drive 0x%x\n", DriveNumber);
52 return 0x1FC00;
53 }
54
55 if (((DiskDrive->DaUa & 0xF0) == 0x30) ||
56 ((DiskDrive->DaUa & 0xF0) == 0xB0))
57 {
58 /* 1.44 MB floppy */
59 return 0x1FE00;
60 }
61 else if (DiskDrive->Type & DRIVE_FDD)
62 {
63 return 0x1FC00;
64 }
65
66 return 0x1F800;
67}
68
70 IN UCHAR BootDrive OPTIONAL,
71 IN ULONG BootPartition OPTIONAL)
72{
73 REGS Regs;
74 PPC98_DISK_DRIVE DiskDrive;
75 USHORT LoadAddress;
76 UCHAR DriveNumber = BootDrive ? BootDrive : FrldrBootDrive;
77
78 DiskDrive = Pc98DiskDriveNumberToDrive(DriveNumber);
79 if (!DiskDrive)
80 {
81 ERR("Failed to get drive 0x%x\n", DriveNumber);
82 return;
83 }
84
85 LoadAddress = (USHORT)(Pc98GetBootSectorLoadAddress(DriveNumber) >> 4);
86
87 RtlZeroMemory(&Regs, sizeof(Regs));
88 Regs.w.ax = DiskDrive->DaUa;
89 Regs.w.si = LoadAddress;
90 Regs.w.es = LoadAddress;
91 *(PUCHAR)MEM_DISK_BOOT = DiskDrive->DaUa;
92
94
95 Relocator16Boot(&Regs,
96 /* Stack segment:pointer */
97 0x0020, 0x00FF,
98 /* Code segment:pointer */
99 LoadAddress, 0x0000);
100}
101
102static BOOLEAN
104{
105 REGS RegsIn, RegsOut;
106
107 /* Int 1Ah AX=1000h
108 * NEC PC-9800 series - Installation check
109 */
110 RegsIn.w.ax = 0x1000;
111 Int386(0x1A, &RegsIn, &RegsOut);
112
113 return RegsOut.w.ax != 0x1000;
114}
115
116VOID
117MachInit(const char *CmdLine)
118{
119 if (!Pc98ArchTest())
120 {
121 ERR("This is not a supported PC98!\n");
122
123 /* Disable and halt the CPU */
124 _disable();
125 __halt();
126
127 while (TRUE)
128 NOTHING;
129 }
130
131 /* Setup vtbl */
161
163
166}
unsigned char BOOLEAN
#define __cdecl
Definition: accygwin.h:79
MACHVTBL MachVtbl
Definition: arcemul.c:21
#define ExtendedBIOSDataArea
Definition: winldr.c:346
#define ExtendedBIOSDataSize
Definition: winldr.c:347
#define ERR(fmt,...)
Definition: precomp.h:57
#define DebugDisableScreenPort()
Definition: debug.h:123
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
#define ATTR(cFore, cBack)
Definition: ui.h:317
#define COLOR_WHITE
Definition: ui.h:338
#define COLOR_BLACK
Definition: ui.h:322
#define TRUE
Definition: types.h:120
static const WCHAR CmdLine[]
Definition: install.c:48
#define NOTHING
Definition: input_list.c:10
void __cdecl _disable(void)
Definition: intrin_arm.h:365
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1714
VOID Pc98HwIdle(VOID)
Definition: machpc98.c:29
VOID Pc98GetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc98.c:22
VOID MachInit(const char *CmdLine)
Definition: machpc98.c:117
VOID __cdecl ChainLoadBiosBootSectorCode(IN UCHAR BootDrive OPTIONAL, IN ULONG BootPartition OPTIONAL)
Definition: machpc98.c:69
static BOOLEAN Pc98ArchTest(VOID)
Definition: machpc98.c:103
ULONG Pc98GetBootSectorLoadAddress(IN UCHAR DriveNumber)
Definition: machpc98.c:44
BOOLEAN HiResoMachine
Definition: machpc98.c:17
VOID Pc98PrepareForReactOS(VOID)
Definition: machpc98.c:35
#define MEM_EXTENDED_HIGH_RESO
Definition: machpc98.h:56
#define HIGH_RESOLUTION_FLAG
Definition: machpc98.h:37
#define MEM_DISK_BOOT
Definition: machpc98.h:44
#define MEM_BIOS_FLAG1
Definition: machpc98.h:35
#define MEM_EXTENDED_NORMAL
Definition: machpc98.h:55
#define DRIVE_FDD
Definition: machpc98.h:120
VOID Pc98Beep(VOID)
Definition: pc98beep.c:10
BOOLEAN Pc98ConsKbHit(VOID)
Definition: pc98cons.c:64
VOID Pc98ConsPutChar(int Ch)
Definition: pc98cons.c:25
int Pc98ConsGetCh(VOID)
Definition: pc98cons.c:85
ULONG Pc98DiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: pc98disk.c:887
PPC98_DISK_DRIVE Pc98DiskDriveNumberToDrive(IN UCHAR DriveNumber)
Definition: pc98disk.c:141
VOID Pc98DiskPrepareForReactOS(VOID)
Definition: pc98disk.c:135
BOOLEAN Pc98InitializeBootDevices(VOID)
Definition: pc98disk.c:721
BOOLEAN Pc98DiskReadLogicalSectors(IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: pc98disk.c:838
BOOLEAN Pc98DiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pc98disk.c:871
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1235
PCONFIGURATION_COMPONENT_DATA Pc98HwDetect(_In_opt_ PCSTR Options)
Definition: pc98hw.c:1183
UCHAR Pc98GetFloppyCount(VOID)
Definition: pc98hw.c:1214
PFREELDR_MEMORY_DESCRIPTOR Pc98MemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pc98mem.c:48
TIMEINFO * Pc98GetTime(VOID)
Definition: pc98rtc.c:13
VOID Pc98VideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: pc98video.c:195
BOOLEAN Pc98VideoIsPaletteFixed(VOID)
Definition: pc98video.c:399
VOID Pc98VideoClearScreen(UCHAR Attr)
Definition: pc98video.c:167
ULONG Pc98VideoGetBufferSize(VOID)
Definition: pc98video.c:203
VOID Pc98VideoInit(VOID)
Definition: pc98video.c:69
VOID Pc98VideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: pc98video.c:209
VOID Pc98VideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: pc98video.c:215
VOID Pc98VideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: pc98video.c:316
VIDEODISPLAYMODE Pc98VideoSetDisplayMode(char *DisplayModeName, BOOLEAN Init)
Definition: pc98video.c:188
VOID Pc98VideoHideShowTextCursor(BOOLEAN Show)
Definition: pc98video.c:228
VOID Pc98VideoPrepareForReactOS(VOID)
Definition: pc98video.c:445
VOID Pc98VideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: pc98video.c:417
VOID Pc98VideoSync(VOID)
Definition: pc98video.c:435
VOID Pc98VideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: pc98video.c:383
VOID Pc98VideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: pc98video.c:405
int __cdecl Int386(int ivec, REGS *in, REGS *out)
VOID __cdecl Relocator16Boot(IN REGS *In, IN USHORT StackSegment, IN USHORT StackPointer, IN USHORT CodeSegment, IN USHORT CodePointer)
VOID HalpCalibrateStallExecution(VOID)
Definition: pchw.c:105
unsigned short USHORT
Definition: pedump.c:61
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
unsigned short si
Definition: pcbios.h:116
unsigned short es
Definition: pcbios.h:121
unsigned short ax
Definition: pcbios.h:111
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:56
VOID(* GetExtendedBIOSData)(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machine.h:64
int(* ConsGetCh)(VOID)
Definition: machine.h:43
VOID(* PrepareForReactOS)(VOID)
Definition: machine.h:59
VOID(* VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: machine.h:55
BOOLEAN(* InitializeBootDevices)(VOID)
Definition: machine.h:76
VOID(* VideoCopyOffScreenBufferToVRAM)(PVOID Buffer)
Definition: machine.h:53
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
VOID(* VideoHideShowTextCursor)(BOOLEAN Show)
Definition: machine.h:51
TIMEINFO *(* GetTime)(VOID)
Definition: machine.h:72
UCHAR(* GetFloppyCount)(VOID)
Definition: machine.h:66
BOOLEAN(* DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry)
Definition: machine.h:68
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:67
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:63
VOID(* VideoGetFontsFromFirmware)(PULONG RomFontPointers)
Definition: machine.h:49
VOID(* Beep)(VOID)
Definition: machine.h:58
VOID(* VideoSetTextCursorPosition)(UCHAR X, UCHAR Y)
Definition: machine.h:50
ULONG(* VideoGetBufferSize)(VOID)
Definition: machine.h:48
VOID(* VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: machine.h:52
ULONG(* DiskGetCacheableBlockCount)(UCHAR DriveNumber)
Definition: machine.h:69
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
VOID(* HwIdle)(VOID)
Definition: machine.h:78
VOID(* VideoSync)(VOID)
Definition: machine.h:57
VIDEODISPLAYMODE(* VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init)
Definition: machine.h:46
BOOLEAN(* VideoIsPaletteFixed)(VOID)
Definition: machine.h:54
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(_In_opt_ PCSTR Options)
Definition: machine.h:77
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
UCHAR FrldrBootDrive
Definition: uefidisk.c:47
Definition: pcbios.h:159
WORDREGS w
Definition: pcbios.h:162
unsigned char UCHAR
Definition: xmlstorage.h:181