Files
mop3/kernel/platform/i386_pc/boot/_start.S

93 lines
2.4 KiB
ArmAsm

/*
Copyright 2025 Kamil Kowalczyk
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define FLAGS ((1<<0) | (1<<1))
#define MAGIC (0x1BADB002)
#define CHECKSUM (-(MAGIC + FLAGS))
#define VIRT_BASE 0xC0000000
.section .multiboot, "aw"
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
.section .bss
.align 16
__stack_bottom:
.skip 8192
__stack_top:
.section .boot, "ax"
.global _start
_start:
movl $(__init_pd - VIRT_BASE), %ecx
movl %ecx, %cr3
movl %cr4, %ecx
orl $0x10, %ecx
movl %ecx, %cr4
movl %cr0, %ecx
orl $0x80000000, %ecx
movl %ecx, %cr0
movl $__kernel_higherhalf, %ecx
jmp *%ecx
.section .text, "ax"
__kernel_higherhalf:
mov $__stack_top, %esp
push %ebx
xorl %ebp, %ebp
call bootmain
1:
hlt
jmp 1b
.section .data
.align 4096
.global __init_pd
__init_pd:
.long 0b10000011
.rept 768-1
.long 0
.endr
.long (0 << 22) | 0b10000011
.long (1 << 22) | 0b10000011
.long (2 << 22) | 0b10000011
.long (3 << 22) | 0b10000011
.rept 256-4
.long 0
.endr