ReactOS  0.4.15-dev-499-g1f31905
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>
13 DBG_DEFAULT_CHANNEL(HWDETECT);
14 
15 /* GLOBALS ********************************************************************/
16 
18 
19 /* FUNCTIONS ******************************************************************/
20 
21 VOID
23 {
26 }
27 
28 VOID
30 {
31  /* Unimplemented */
32 }
33 
34 VOID
36 {
40  DebugDisableScreenPort();
41 }
42 
43 ULONG
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 
102 static 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 
116 VOID
117 MachInit(const char *CmdLine)
118 {
119  if (!Pc98ArchTest())
120  {
121  _disable();
122  __halt();
123 
124  while (TRUE)
125  NOTHING;
126  }
127 
128  /* Setup vtbl */
129  RtlZeroMemory(&MachVtbl, sizeof(MACHVTBL));
158 
160 
162  Pc98VideoInit();
163 }
VOID Pc98VideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: pc98video.c:266
VOID MachInit(const char *CmdLine)
Definition: machpc98.c:117
VOID Pc98VideoSync(VOID)
Definition: pc98video.c:318
#define MEM_EXTENDED_NORMAL
Definition: machpc98.h:55
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:63
#define ExtendedBIOSDataSize
Definition: winldr.c:421
#define IN
Definition: typedefs.h:39
VOID Pc98VideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: pc98video.c:186
#define TRUE
Definition: types.h:120
BOOLEAN Pc98ConsKbHit(VOID)
Definition: pc98cons.c:64
#define COLOR_BLACK
Definition: ui.h:204
#define __cdecl
Definition: accygwin.h:79
VOID Pc98DiskPrepareForReactOS(VOID)
Definition: pc98disk.c:135
#define MEM_BIOS_FLAG1
Definition: machpc98.h:35
VOID(* GetExtendedBIOSData)(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machine.h:64
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN Pc98VideoIsPaletteFixed(VOID)
Definition: pc98video.c:282
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1595
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(VOID)
Definition: machine.h:77
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
unsigned short es
Definition: pcbios.h:115
UCHAR Pc98GetFloppyCount(VOID)
Definition: pc98hw.c:1223
VOID Pc98VideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: pc98video.c:206
VOID Pc98VideoInit(VOID)
Definition: pc98video.c:60
VOID Pc98VideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: pc98video.c:288
BOOLEAN(* VideoIsPaletteFixed)(VOID)
Definition: machine.h:54
UCHAR(* GetFloppyCount)(VOID)
Definition: machine.h:66
int __cdecl Int386(int ivec, REGS *in, REGS *out)
VOID Pc98PrepareForReactOS(VOID)
Definition: machpc98.c:35
VOID Pc98VideoHideShowTextCursor(BOOLEAN Show)
Definition: pc98video.c:219
VOID Pc98VideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: pc98video.c:200
VOID(* VideoGetFontsFromFirmware)(PULONG RomFontPointers)
Definition: machine.h:49
DBG_DEFAULT_CHANNEL(HWDETECT)
VOID Pc98VideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: pc98video.c:236
#define ATTR(cFore, cBack)
Definition: ui.h:192
unsigned char BOOLEAN
BOOLEAN(* DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry)
Definition: machine.h:68
VOID(* VideoSetTextCursorPosition)(UCHAR X, UCHAR Y)
Definition: machine.h:50
PCONFIGURATION_COMPONENT_DATA Pc98HwDetect(VOID)
Definition: pc98hw.c:1192
VOID Pc98HwIdle(VOID)
Definition: machpc98.c:29
VOID Pc98VideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: pc98video.c:300
TIMEINFO *(* GetTime)(VOID)
Definition: machine.h:72
VOID Pc98Beep(VOID)
Definition: pc98beep.c:10
BOOLEAN(* InitializeBootDevices)(VOID)
Definition: machine.h:76
BOOLEAN Pc98DiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pc98disk.c:870
#define ExtendedBIOSDataArea
Definition: winldr.c:420
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:56
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1244
#define DRIVE_FDD
Definition: machpc98.h:116
PFREELDR_MEMORY_DESCRIPTOR Pc98MemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pc98mem.c:48
BOOLEAN HiResoMachine
Definition: machpc98.c:17
BOOLEAN Pc98DiskReadLogicalSectors(IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: pc98disk.c:837
VOID __cdecl ChainLoadBiosBootSectorCode(IN UCHAR BootDrive OPTIONAL, IN ULONG BootPartition OPTIONAL)
Definition: machpc98.c:69
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:67
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
int Pc98ConsGetCh(VOID)
Definition: pc98cons.c:85
CHAR CmdLine[MAX_PATH]
Definition: mach.c:34
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID(* VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: machine.h:52
TIMEINFO * Pc98GetTime(VOID)
Definition: pc98rtc.c:13
#define NOTHING
Definition: env_spec_w32.h:461
#define HIGH_RESOLUTION_FLAG
Definition: machpc98.h:37
UCHAR FrldrBootDrive
#define COLOR_WHITE
Definition: ui.h:220
VOID(* VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: machine.h:55
VOID Pc98ConsPutChar(int Ch)
Definition: pc98cons.c:25
#define MEM_DISK_BOOT
Definition: machpc98.h:44
VOID(* PrepareForReactOS)(VOID)
Definition: machine.h:59
ULONG(* VideoGetBufferSize)(VOID)
Definition: machine.h:48
static BOOLEAN Pc98ArchTest(VOID)
Definition: machpc98.c:103
PPC98_DISK_DRIVE Pc98DiskDriveNumberToDrive(IN UCHAR DriveNumber)
Definition: pc98disk.c:141
int(* ConsGetCh)(VOID)
Definition: machine.h:43
#define ERR(fmt,...)
Definition: debug.h:110
ULONG(* DiskGetCacheableBlockCount)(UCHAR DriveNumber)
Definition: machine.h:69
ULONG Pc98DiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: pc98disk.c:886
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41
MACHVTBL MachVtbl
Definition: arcemul.c:21
BOOLEAN Pc98InitializeBootDevices(VOID)
Definition: pc98disk.c:720
#define MEM_EXTENDED_HIGH_RESO
Definition: machpc98.h:56
unsigned short USHORT
Definition: pedump.c:61
VOID(* HwIdle)(VOID)
Definition: machine.h:78
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 int * PULONG
Definition: retypes.h:1
VOID Pc98VideoPrepareForReactOS(VOID)
Definition: pc98video.c:328
unsigned short ax
Definition: pcbios.h:105
unsigned short si
Definition: pcbios.h:110
VOID Pc98GetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc98.c:22
VOID(* VideoSync)(VOID)
Definition: machine.h:57
void __cdecl _disable(void)
Definition: intrin_arm.h:365
unsigned int ULONG
Definition: retypes.h:1
ULONG Pc98VideoGetBufferSize(VOID)
Definition: pc98video.c:194
Definition: pcbios.h:152
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID(* VideoCopyOffScreenBufferToVRAM)(PVOID Buffer)
Definition: machine.h:53
VIDEODISPLAYMODE(* VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init)
Definition: machine.h:46
VIDEODISPLAYMODE Pc98VideoSetDisplayMode(char *DisplayModeName, BOOLEAN Init)
Definition: pc98video.c:179
VOID(* Beep)(VOID)
Definition: machine.h:58
WORDREGS w
Definition: pcbios.h:156
VOID(* VideoHideShowTextCursor)(BOOLEAN Show)
Definition: machine.h:51
ULONG Pc98GetBootSectorLoadAddress(IN UCHAR DriveNumber)
Definition: machpc98.c:44
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
VOID Pc98VideoClearScreen(UCHAR Attr)
Definition: pc98video.c:158