[FREELDR] Simplify code by using a AddReactOSArcDiskInfo() helper, and few extra...
[reactos.git] / boot / freeldr / freeldr / include / machine.h
1 /*
2 * FreeLoader
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #pragma once
20
21 #ifndef __DISK_H
22 #include "disk.h"
23 #endif
24
25 #ifndef __MEMORY_H
26 #include "mm.h"
27 #endif
28
29 #ifndef __FS_H
30 #include "fs.h"
31 #endif
32
33 typedef enum tagVIDEODISPLAYMODE
34 {
35 VideoTextMode,
36 VideoGraphicsMode
37 } VIDEODISPLAYMODE, *PVIDEODISPLAYMODE;
38
39 typedef struct tagMACHVTBL
40 {
41 VOID (*ConsPutChar)(int Ch);
42 BOOLEAN (*ConsKbHit)(VOID);
43 int (*ConsGetCh)(VOID);
44
45 VOID (*VideoClearScreen)(UCHAR Attr);
46 VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init);
47 VOID (*VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth);
48 ULONG (*VideoGetBufferSize)(VOID);
49 VOID (*VideoSetTextCursorPosition)(UCHAR X, UCHAR Y);
50 VOID (*VideoHideShowTextCursor)(BOOLEAN Show);
51 VOID (*VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y);
52 VOID (*VideoCopyOffScreenBufferToVRAM)(PVOID Buffer);
53 BOOLEAN (*VideoIsPaletteFixed)(VOID);
54 VOID (*VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue);
55 VOID (*VideoGetPaletteColor)(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue);
56 VOID (*VideoSync)(VOID);
57 VOID (*Beep)(VOID);
58 VOID (*PrepareForReactOS)(IN BOOLEAN Setup);
59
60 // NOTE: Not in the machine.c ...
61 FREELDR_MEMORY_DESCRIPTOR* (*GetMemoryDescriptor)(FREELDR_MEMORY_DESCRIPTOR* Current);
62 PFREELDR_MEMORY_DESCRIPTOR (*GetMemoryMap)(PULONG MaxMemoryMapSize);
63
64 BOOLEAN (*DiskGetBootPath)(PCHAR BootPath, ULONG Size);
65 BOOLEAN (*DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
66 BOOLEAN (*DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry);
67 ULONG (*DiskGetCacheableBlockCount)(UCHAR DriveNumber);
68
69 // NOTE: In the machine.c under the name of "ArcGetXXXTime"
70 TIMEINFO* (*GetTime)(VOID);
71 ULONG (*GetRelativeTime)(VOID);
72
73 // NOTE: Not in the machine.c ...
74 BOOLEAN (*InitializeBootDevices)(VOID);
75 PCONFIGURATION_COMPONENT_DATA (*HwDetect)(VOID);
76 VOID (*HwIdle)(VOID);
77 } MACHVTBL, *PMACHVTBL;
78
79 extern MACHVTBL MachVtbl;
80
81 /* NOTE: Implemented by each architecture */
82 VOID MachInit(const char *CmdLine);
83
84 #define MachConsPutChar(Ch) \
85 MachVtbl.ConsPutChar(Ch)
86 #define MachConsKbHit() \
87 MachVtbl.ConsKbHit()
88 #define MachConsGetCh() \
89 MachVtbl.ConsGetCh()
90 #define MachVideoClearScreen(Attr) \
91 MachVtbl.VideoClearScreen(Attr)
92 #define MachVideoSetDisplayMode(Mode, Init) \
93 MachVtbl.VideoSetDisplayMode((Mode), (Init))
94 #define MachVideoGetDisplaySize(W, H, D) \
95 MachVtbl.VideoGetDisplaySize((W), (H), (D))
96 #define MachVideoGetBufferSize() \
97 MachVtbl.VideoGetBufferSize()
98 #define MachVideoSetTextCursorPosition(X, Y) \
99 MachVtbl.VideoSetTextCursorPosition((X), (Y))
100 #define MachVideoHideShowTextCursor(Show) \
101 MachVtbl.VideoHideShowTextCursor(Show)
102 #define MachVideoPutChar(Ch, Attr, X, Y) \
103 MachVtbl.VideoPutChar((Ch), (Attr), (X), (Y))
104 #define MachVideoCopyOffScreenBufferToVRAM(Buf) \
105 MachVtbl.VideoCopyOffScreenBufferToVRAM(Buf)
106 #define MachVideoIsPaletteFixed() \
107 MachVtbl.VideoIsPaletteFixed()
108 #define MachVideoSetPaletteColor(Col, R, G, B) \
109 MachVtbl.VideoSetPaletteColor((Col), (R), (G), (B))
110 #define MachVideoGetPaletteColor(Col, R, G, B) \
111 MachVtbl.VideoGetPaletteColor((Col), (R), (G), (B))
112 #define MachVideoSync() \
113 MachVtbl.VideoSync()
114 #define MachBeep() \
115 MachVtbl.Beep()
116 #define MachPrepareForReactOS(Setup) \
117 MachVtbl.PrepareForReactOS(Setup)
118 #define MachDiskGetBootPath(Path, Size) \
119 MachVtbl.DiskGetBootPath((Path), (Size))
120 #define MachDiskReadLogicalSectors(Drive, Start, Count, Buf) \
121 MachVtbl.DiskReadLogicalSectors((Drive), (Start), (Count), (Buf))
122 #define MachDiskGetDriveGeometry(Drive, Geom) \
123 MachVtbl.DiskGetDriveGeometry((Drive), (Geom))
124 #define MachDiskGetCacheableBlockCount(Drive) \
125 MachVtbl.DiskGetCacheableBlockCount(Drive)
126
127 #define MachInitializeBootDevices() \
128 MachVtbl.InitializeBootDevices()
129
130 #define MachHwDetect() MachVtbl.HwDetect()
131 #define MachHwIdle() MachVtbl.HwIdle()
132
133 /* ARC FUNCTIONS **************************************************************/
134
135 TIMEINFO* ArcGetTime(VOID);
136 ULONG ArcGetRelativeTime(VOID);
137
138 /* EOF */