1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- #![ feature( asm ) ]
15+ #![ feature( global_asm ) ]
1616#![ cfg_attr( not( test) , no_std) ]
1717#![ cfg_attr( not( test) , no_main) ]
1818#![ cfg_attr( test, allow( unused_imports) ) ]
@@ -38,28 +38,16 @@ mod pci;
3838mod pe;
3939mod virtio;
4040
41- fn halt ( ) -> ! {
42- loop {
43- unsafe { asm ! ( "hlt" ) } ;
44- }
41+ global_asm ! ( include_str! ( "asm/ram64.s" ) ) ;
42+
43+ extern "C" {
44+ fn halt_loop ( ) -> ! ;
4545}
4646
4747#[ cfg_attr( not( test) , panic_handler) ]
4848fn panic ( info : & PanicInfo ) -> ! {
4949 log ! ( "PANIC: {}" , info) ;
50- halt ( )
51- }
52-
53- /// Enable SSE2 for XMM registers (needed for EFI calling)
54- fn enable_sse2 ( ) {
55- unsafe {
56- asm ! ( "movq %cr0, %rax" ) ;
57- asm ! ( "or $$0x2, %ax" ) ;
58- asm ! ( "movq %rax, %cr0" ) ;
59- asm ! ( "movq %cr4, %rax" ) ;
60- asm ! ( "or $$0x600, %ax" ) ;
61- asm ! ( "movq %rax, %cr4" ) ;
62- }
50+ unsafe { halt_loop ( ) }
6351}
6452
6553/// Setup page tables to provide an identity mapping over the full 4GiB range
@@ -167,14 +155,8 @@ fn boot_from_device(device: &mut block::VirtioBlockDevice) -> bool {
167155}
168156
169157#[ cfg_attr( not( test) , no_mangle) ]
170- pub extern "C" fn _start ( ) -> ! {
171- unsafe {
172- asm ! ( "movq $$0x180000, %rsp" ) ;
173- }
174-
175- log ! ( "Starting.." ) ;
176-
177- enable_sse2 ( ) ;
158+ pub extern "C" fn rust64_start ( ) -> ! {
159+ log ! ( "\n Starting.." ) ;
178160 setup_pagetables ( ) ;
179161
180162 pci:: print_bus ( ) ;
@@ -194,5 +176,5 @@ pub extern "C" fn _start() -> ! {
194176 let mut device = block:: VirtioBlockDevice :: new ( & mut mmio_transport) ;
195177 boot_from_device ( & mut device) ;
196178
197- halt ( )
179+ unsafe { halt_loop ( ) }
198180}
0 commit comments