This repository has been archived on 2024-06-25. You can view files and clone it, but cannot push or open issues or pull requests.
rockOS/kernel/arch/i386/boot/boot.S

62 lines
1.8 KiB
ArmAsm
Raw Permalink Normal View History

2022-07-21 21:59:23 +03:00
/**
* Boot section of rockOS
* Copyright (C) 2022 Furkan Mudanyali
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, _either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2022-07-18 09:59:04 +03:00
# Declare constants for multiboot header
.set ALIGN, 1<<0 # align loaded modules on page boundaries
.set MEMINFO, 1<<1 # provide memory map
.set FLAGS, ALIGN | MEMINFO # multiboot flag field
.set MAGIC, 0x1BADB002 # magic number for bootloader to find header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above
# Declare header in multiboot standard
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
# Reserve a stack for initial thread
.section .bss
.align 16
stack_bottom:
.skip 32768 # 32 KiB
2022-07-18 09:59:04 +03:00
stack_top:
# kernel entry point
.section .text
.global _start
.type _start, @function
_start:
push %eax
push %ebx
call bootloader_init
2022-07-18 18:14:20 +03:00
cli
2022-07-18 22:37:43 +03:00
call gdt_init # initialize the GDT
movl $stack_top, %esp
call terminal_initialize
2022-07-18 22:37:43 +03:00
call idt_init # initialize the IDT
call PIC_remap
sti
2022-07-20 02:23:23 +03:00
call paging_init
2022-07-18 22:37:43 +03:00
call kernel_main # transfer control to main kernel
2022-07-18 09:59:04 +03:00
# Hang if kernel_main unexpectedly returns
1: hlt
jmp 1b
2022-07-18 18:14:20 +03:00
2022-07-18 09:59:04 +03:00
.size _start, . - _start