; Copyright 2015 Philipp Oppermann ; ; Licensed under the Apache License, Version 2.0 (the "License"); ; you may not use this file except in compliance with the License. ; You may obtain a copy of the License at ; ; http://www.apache.org/licenses/LICENSE-2.0 ; ; Unless required by applicable law or agreed to in writing, software ; distributed under the License is distributed on an "AS IS" BASIS, ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; See the License for the specific language governing permissions and ; limitations under the License. global long_mode_start extern main section .text bits 64 long_mode_start: call setup_SSE ; call rust main call main ; print `OKAY` to screen mov rax, 0x2f592f412f4b2f4f mov qword [0xb8000], rax hlt ; Check for SSE and enable it. If it's not supported throw error "a". setup_SSE: ; check for SSE mov rax, 0x1 cpuid test edx, 1<<25 jz .no_SSE ; enable SSE mov rax, cr0 and ax, 0xFFFB ; clear coprocessor emulation CR0.EM or ax, 0x2 ; set coprocessor monitoring CR0.MP mov cr0, rax mov rax, cr4 or ax, 3 << 9 ; set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time mov cr4, rax ret .no_SSE: mov al, "a" jmp error ; Prints `ERROR: ` and the given error code to screen and hangs. ; parameter: error code (in ascii) in al error: mov rbx, 0x4f4f4f524f524f45 mov [0xb8000], rbx mov rbx, 0x4f204f204f3a4f52 mov [0xb8008], rbx mov byte [0xb800e], al hlt jmp error