ReactOS 0.4.15-dev-5893-g1bb4167
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
23VOID
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
66VOID
70{
72
73 /* Halt the CPU */
74 __halt();
75
76 while (TRUE); /* 'noreturn' function */
77}
78
79/* PUBLIC FUNCTIONS **********************************************************/
80
81/*
82 * @implemented
83 */
84VOID
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 }
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);
111 }
112 }
113}
114
115/* EOF */
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
#define TRUE
Definition: types.h:120
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:22
VOID NTAPI SMBusWriteByte(UCHAR Address, UCHAR Register, UCHAR Data)
Definition: reboot.c:25
VOID DECLSPEC_NORETURN NTAPI HalpXboxPowerAction(IN UCHAR Action)
Definition: reboot.c:69
#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
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1714
#define b
Definition: ke_i.h:79
enum _FIRMWARE_REENTRY FIRMWARE_REENTRY
@ HalRestartRoutine
Definition: haltypes.h:36
@ HalPowerDownRoutine
Definition: haltypes.h:35
@ HalRebootRoutine
Definition: haltypes.h:37
#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
#define IN
Definition: typedefs.h:39
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