ReactOS  0.4.14-dev-854-gb9426a3
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 #define NDEBUG
19 #include <debug.h>
20 
21 /* PRIVATE FUNCTIONS *********************************************************/
22 
23 VOID
24 NTAPI
26 {
27  INT Retries = 50;
28 
29  /* Wait while bus is busy with any master traffic */
31  {
32  NOTHING;
33  }
34 
35  while (Retries--)
36  {
37  UCHAR b;
38 
41 
43 
44  /* Clear down all preexisting errors */
46 
47  /* Let I2C SMBus know we're sending a single byte here */
49 
50  b = 0;
51 
52  while (!(b & 0x36))
53  {
55  }
56 
57  if (b & 0x10)
58  {
59  return;
60  }
61 
63  }
64 }
65 
66 VOID
68 NTAPI
70 {
72 
73  /* Halt the CPU */
74  __halt();
75 
76  while (TRUE); /* 'noreturn' function */
77 }
78 
79 /* PUBLIC FUNCTIONS **********************************************************/
80 
81 /*
82  * @implemented
83  */
84 VOID
85 NTAPI
87 {
88  /* Check what kind of action this is */
89  switch (Action)
90  {
91  /* All recognized actions */
93  {
94  /* Call the internal power function */
96  }
97  case HalRestartRoutine:
98  {
100  }
101  case HalRebootRoutine:
102  {
104  }
105  /* Anything else */
106  default:
107  {
108  /* Print message and break */
109  DbgPrint("HalReturnToFirmware(%d) called!\n", Action);
110  DbgBreakPoint();
111  }
112  }
113 }
114 
115 /* EOF */
#define SMC_REG_POWER_SHUTDOWN
Definition: halxbox.h:35
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115
#define DbgPrint
Definition: loader.c:25
#define SMC_REG_POWER_CYCLE
Definition: halxbox.h:34
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:528
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1595
#define SMC_REG_POWER_RESET
Definition: halxbox.h:33
void DbgBreakPoint()
Definition: mach.c:553
int32_t INT
Definition: typedefs.h:56
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
VOID NTAPI SMBusWriteByte(UCHAR Address, UCHAR Register, UCHAR Data)
Definition: reboot.c:25
#define SMB_GLOBAL_STATUS
Definition: halxbox.h:24
static WCHAR Address[46]
Definition: ping.c:68
#define SMB_DEVICE_SMC_PIC16LC
Definition: halxbox.h:30
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define SMB_HOST_ADDRESS
Definition: halxbox.h:26
enum _FIRMWARE_REENTRY FIRMWARE_REENTRY
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
VOID NTAPI HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
Definition: reboot.c:22
#define SMC_REG_POWER
Definition: halxbox.h:32
#define SMB_HOST_DATA
Definition: halxbox.h:27
unsigned char UCHAR
Definition: xmlstorage.h:181
#define NOTHING
Definition: env_spec_w32.h:461
#define SMB_HOST_COMMAND
Definition: halxbox.h:28
#define SMB_GLOBAL_ENABLE
Definition: halxbox.h:25
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:532
USHORT NTAPI READ_PORT_USHORT(IN PUSHORT Port)
Definition: portio.c:63
VOID DECLSPEC_NORETURN NTAPI HalpXboxPowerAction(IN UCHAR Action)
Definition: reboot.c:69
unsigned short * PUSHORT
Definition: retypes.h:2
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99