ReactOS 0.4.16-dev-329-g9223134
reboot.c
Go to the documentation of this file.
1/*
2 * PROJECT: Xbox HAL
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Xbox reboot functions
5 * COPYRIGHT: Copyright 2004 Lehner Franz (franz@caos.at)
6 * Copyright 2019 Stanislav Motylkov (x86corez@gmail.com)
7 *
8 * REFERENCES: https://xboxdevwiki.net/SMBus
9 * https://github.com/XboxDev/cromwell/blob/master/drivers/pci/i2cio.c
10 * https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-amd756.c
11 * https://github.com/xqemu/xqemu/blob/master/hw/xbox/smbus_xbox_smc.c
12 */
13
14/* INCLUDES ******************************************************************/
15
16#include "halxbox.h"
17
18/* PRIVATE FUNCTIONS *********************************************************/
19
20static VOID
25{
26 INT Retries = 50;
27
28 /* Wait while bus is busy with any master traffic */
30 {
31 NOTHING;
32 }
33
34 while (Retries--)
35 {
36 UCHAR b;
37
40
42
43 /* Clear down all preexisting errors */
45
46 /* Let I2C SMBus know we're sending a single byte here */
48
49 b = 0;
50
51 while (!(b & 0x36))
52 {
54 }
55
56 if (b & 0x10)
57 {
58 return;
59 }
60
62 }
63}
64
66VOID
69{
70 /* Disable interrupts */
71 _disable();
72
73 /* Send the command */
75
76 /* Halt the CPU */
77 __halt();
79}
80
82VOID
84{
86}
87
88/* PUBLIC FUNCTIONS **********************************************************/
89
90#ifndef _MINIHAL_
91/*
92 * @implemented
93 */
94VOID
98{
99 /* Check what kind of action this is */
100 switch (Action)
101 {
102 /* All recognized actions: call the internal power function */
103 case HalHaltRoutine:
105 {
107 }
109 {
111 }
112 case HalRebootRoutine:
113 {
115 }
116
117 /* Anything else */
118 default:
119 {
120 /* Print message and break */
121 DbgPrint("HalReturnToFirmware(%d) called!\n", Action);
123 }
124 }
125}
126#endif // _MINIHAL_
127
128/* EOF */
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115
USHORT NTAPI READ_PORT_USHORT(IN PUSHORT Port)
Definition: portio.c:63
#define DbgPrint
Definition: hal.h:12
VOID NTAPI HalReturnToFirmware(_In_ FIRMWARE_REENTRY Action)
Definition: reboot.c:21
DECLSPEC_NORETURN VOID HalpReboot(VOID)
Definition: reboot.c:25
static DECLSPEC_NORETURN VOID HalpXboxPowerAction(_In_ UCHAR Action)
Definition: reboot.c:67
static VOID SMBusWriteByte(_In_ UCHAR Address, _In_ UCHAR Register, _In_ UCHAR Data)
Definition: reboot.c:21
#define SMB_HOST_COMMAND
Definition: halxbox.h:28
#define SMC_REG_POWER_CYCLE
Definition: halxbox.h:34
#define SMC_REG_POWER_RESET
Definition: halxbox.h:33
#define SMB_GLOBAL_ENABLE
Definition: halxbox.h:25
#define SMB_GLOBAL_STATUS
Definition: halxbox.h:24
#define SMC_REG_POWER_SHUTDOWN
Definition: halxbox.h:35
#define SMB_DEVICE_SMC_PIC16LC
Definition: halxbox.h:30
#define SMC_REG_POWER
Definition: halxbox.h:32
#define SMB_HOST_ADDRESS
Definition: halxbox.h:26
#define SMB_HOST_DATA
Definition: halxbox.h:27
NTSYSAPI void WINAPI DbgBreakPoint(void)
#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
#define b
Definition: ke_i.h:79
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27
enum _FIRMWARE_REENTRY FIRMWARE_REENTRY
@ HalRestartRoutine
Definition: haltypes.h:36
@ HalHaltRoutine
Definition: haltypes.h:34
@ HalPowerDownRoutine
Definition: haltypes.h:35
@ HalRebootRoutine
Definition: haltypes.h:37
#define _In_
Definition: no_sal2.h:158
#define UNREACHABLE
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
static WCHAR Address[46]
Definition: ping.c:68
#define NTAPI
Definition: typedefs.h:36
int32_t INT
Definition: typedefs.h:58
uint16_t * PUSHORT
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
unsigned char UCHAR
Definition: xmlstorage.h:181