File tree Expand file tree Collapse file tree 5 files changed +31
-1
lines changed Expand file tree Collapse file tree 5 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -11,3 +11,7 @@ pub fn id() -> usize {
11
11
pub unsafe fn exit_in_qemu ( _error_code : u8 ) -> ! {
12
12
unimplemented ! ( )
13
13
}
14
+
15
+ pub unsafe fn reboot ( ) -> ! {
16
+ unimplemented ! ( )
17
+ }
Original file line number Diff line number Diff line change @@ -31,3 +31,8 @@ pub unsafe fn exit_in_qemu(error_code: u8) -> ! {
31
31
/* nothing to do */
32
32
loop { }
33
33
}
34
+
35
+ pub unsafe fn reboot ( ) -> ! {
36
+ /* nothing to do */
37
+ loop { }
38
+ }
Original file line number Diff line number Diff line change @@ -21,3 +21,7 @@ pub fn halt() {
21
21
pub unsafe fn exit_in_qemu ( error_code : u8 ) -> ! {
22
22
super :: sbi:: shutdown ( )
23
23
}
24
+
25
+ pub unsafe fn reboot ( ) -> ! {
26
+ super :: sbi:: shutdown ( )
27
+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ pub unsafe fn exit_in_qemu(error_code: u8) -> ! {
14
14
unreachable ! ( )
15
15
}
16
16
17
+ pub unsafe fn reboot ( ) -> ! {
18
+ use x86_64:: instructions:: port:: Port ;
19
+ Port :: new ( 0x64 ) . write ( 0xfeu8 ) ;
20
+ unreachable ! ( )
21
+ }
22
+
17
23
pub fn id ( ) -> usize {
18
24
CpuId :: new ( )
19
25
. get_feature_info ( )
Original file line number Diff line number Diff line change @@ -122,6 +122,10 @@ impl Syscall<'_> {
122
122
unsafe {
123
123
cpu:: exit_in_qemu ( 1 ) ;
124
124
}
125
+ } else if cmd == LINUX_REBOOT_CMD_RESTART {
126
+ unsafe {
127
+ cpu:: reboot ( ) ;
128
+ }
125
129
}
126
130
Ok ( 0 )
127
131
}
@@ -188,7 +192,14 @@ impl Syscall<'_> {
188
192
}
189
193
}
190
194
191
- const LINUX_REBOOT_CMD_HALT : u32 = 0xcdef0123 ;
195
+ const LINUX_REBOOT_CMD_RESTART : u32 = 0x01234567 ;
196
+ const LINUX_REBOOT_CMD_HALT : u32 = 0xCDEF0123 ;
197
+ const LINUX_REBOOT_CMD_CAD_ON : u32 = 0x89ABCDEF ;
198
+ const LINUX_REBOOT_CMD_CAD_OFF : u32 = 0x00000000 ;
199
+ const LINUX_REBOOT_CMD_POWER_OFF : u32 = 0x4321FEDC ;
200
+ const LINUX_REBOOT_CMD_RESTART2 : u32 = 0xA1B2C3D4 ;
201
+ const LINUX_REBOOT_CMD_SW_SUSPEND : u32 = 0xD000FCE2 ;
202
+ const LINUX_REBOOT_CMD_KEXEC : u32 = 0x45584543 ;
192
203
193
204
#[ repr( C ) ]
194
205
#[ derive( Debug , Default ) ]
You can’t perform that action at this time.
0 commit comments