; ; Copyright 2010 Stefan Lankes, Chair for Operating Systems, ; RWTH Aachen University ; ; 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. ; ; This file is part of MetalSVM. ; This is the kernel's entry point. We switch to the protected mode ; and jump to our kernel. [BITS 16] SECTION .text GLOBAL _start ORG 0x90200 _start: jmp _realstart msg db "?ello from MetalSVM bootloader!!",0 _realstart: ; IRQs are already disabled by reset_vector ; cli lgdt [gdtr] ; switch to protected mode by setting PE bit mov eax, cr0 or al, 1 mov cr0, eax ; modify msg to see the startup mov BYTE [msg], '0' + codesel ; far jump to the 32bit code jmp dword codesel:_pmstart [BITS 32] _pmstart: ; MetalSVM supports the Multiboot specification ; => Therefore, we switch to the same machine state. Afterwards, we jump to our kernel xor eax, eax mov ax, datasel mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax mov eax, 0x2BAD002 xor ebx, ebx ; => it exists no valid multiboot information structure ; modify msg to see the startup mov BYTE [msg], 'H' jmp codesel:0x100000 ; absolute jmp hang: jmp hang ALIGN 8 gdtr: ; descritor table dw gdt_end-gdt-1 ; limit dd gdt ; base adresse gdt: dd 0,0 ; null descriptor codesel equ $-gdt dw 0xFFFF ; segment size 0..15 dw 0x0000 ; segment address 0..15 db 0x00 ; segment address 16..23 db 0x9A ; access permissions und type db 0xCF ; additional information and segment size 16...19 db 0x00 ; segment address 24..31 datasel equ $-gdt dw 0xFFFF ; segment size 0..15 dw 0x0000 ; segment address 0..15 db 0x00 ; segment address 16..23 db 0x92 ; access permissions and type db 0xCF ; additional informationen and degment size 16...19 db 0x00 ; segment address 24..31 gdt_end: gap: TIMES 4096-($-$$) DB 0