3c30cad41ce6ab8ab2afd622dec711860ea859e4
[reactos.git] / boot / freeldr / freeldr / arch / i386 / ntoskrnl.c
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: boot/freeldr/freeldr/arch/i386/ntoskrnl.c
5 * PURPOSE: NTOS glue routines for the MINIHAL library
6 * PROGRAMMERS: Hervé Poussineau <hpoussin@reactos.org>
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include <ntoskrnl.h>
12
13 /* For KeStallExecutionProcessor */
14 #if defined(_M_IX86) || defined(_M_AMD64)
15 #include <arch/pc/pcbios.h>
16 #endif
17
18 /* FUNCTIONS *****************************************************************/
19
20 VOID
21 NTAPI
22 KeInitializeEvent(
23 IN PRKEVENT Event,
24 IN EVENT_TYPE Type,
25 IN BOOLEAN State)
26 {
27 memset(Event, 0, sizeof(*Event));
28 }
29
30 VOID
31 FASTCALL
32 KiAcquireSpinLock(
33 IN PKSPIN_LOCK SpinLock)
34 {
35 }
36
37 VOID
38 FASTCALL
39 KiReleaseSpinLock(
40 IN PKSPIN_LOCK SpinLock)
41 {
42 }
43
44 VOID
45 NTAPI
46 KeSetTimeIncrement(
47 IN ULONG MaxIncrement,
48 IN ULONG MinIncrement)
49 {
50 }
51
52 VOID
53 FASTCALL
54 IoAssignDriveLetters(
55 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
56 IN PSTRING NtDeviceName,
57 OUT PUCHAR NtSystemPath,
58 OUT PSTRING NtSystemPathString)
59 {
60 }
61
62 NTSTATUS
63 FASTCALL
64 IoSetPartitionInformation(
65 IN PDEVICE_OBJECT DeviceObject,
66 IN ULONG SectorSize,
67 IN ULONG PartitionNumber,
68 IN ULONG PartitionType)
69 {
70 return STATUS_NOT_IMPLEMENTED;
71 }
72
73 /*
74 * NTSTATUS
75 * FASTCALL
76 * IoReadPartitionTable(
77 * IN PDEVICE_OBJECT DeviceObject,
78 * IN ULONG SectorSize,
79 * IN BOOLEAN ReturnRecognizedPartitions,
80 * OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer);
81 *
82 * See boot/freeldr/freeldr/disk/partition.c
83 */
84
85 NTSTATUS
86 FASTCALL
87 IoWritePartitionTable(
88 IN PDEVICE_OBJECT DeviceObject,
89 IN ULONG SectorSize,
90 IN ULONG SectorsPerTrack,
91 IN ULONG NumberOfHeads,
92 IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer)
93 {
94 return STATUS_NOT_IMPLEMENTED;
95 }
96
97 VOID
98 NTAPI
99 KeStallExecutionProcessor(
100 IN ULONG MicroSeconds)
101 {
102 #if defined(_M_IX86) || defined(_M_AMD64)
103 REGS Regs;
104 ULONG usec_this;
105
106 // Int 15h AH=86h
107 // BIOS - WAIT (AT,PS)
108 //
109 // AH = 86h
110 // CX:DX = interval in microseconds
111 // Return:
112 // CF clear if successful (wait interval elapsed)
113 // CF set on error or AH=83h wait already in progress
114 // AH = status (see #00496)
115
116 // Note: The resolution of the wait period is 977 microseconds on
117 // many systems because many BIOSes use the 1/1024 second fast
118 // interrupt from the AT real-time clock chip which is available on INT 70;
119 // because newer BIOSes may have much more precise timers available, it is
120 // not possible to use this function accurately for very short delays unless
121 // the precise behavior of the BIOS is known (or found through testing)
122
123 while (MicroSeconds)
124 {
125 usec_this = MicroSeconds;
126
127 if (usec_this > 4000000)
128 {
129 usec_this = 4000000;
130 }
131
132 Regs.b.ah = 0x86;
133 Regs.w.cx = usec_this >> 16;
134 Regs.w.dx = usec_this & 0xffff;
135 Int386(0x15, &Regs, &Regs);
136
137 MicroSeconds -= usec_this;
138 }
139 #else
140 #error unimplemented
141 #endif
142 }