Refactoring assembly entry point
This commit is contained in:
parent
dc3803491e
commit
1b207add8c
@ -1,5 +1,6 @@
|
||||
OBJS = kernel_loader.asm.o ports.asm.o \
|
||||
gdt.asm.o idt.asm.o interrupts.asm.o
|
||||
OBJS = main.asm.o ports.asm.o \
|
||||
gdt.asm.o idt.asm.o \
|
||||
interrupts.asm.o header.asm.o
|
||||
|
||||
ASM = nasm
|
||||
ASMFLAGS = -f elf32
|
||||
|
@ -1,10 +1,10 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/iceOS ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/vulcanos ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
global gdt_flush ; for drivers/gdt.c
|
||||
|
||||
section .text
|
||||
|
19
kernel/cpu/header.asm
Normal file
19
kernel/cpu/header.asm
Normal file
@ -0,0 +1,19 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/vulcanos ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
section .multiboot_header
|
||||
header_s:
|
||||
dd 0xE85250D6 ; Magic number for multiboot
|
||||
dd 0 ; Protected mode flag
|
||||
dd header_e - header_s ; Header length
|
||||
dd 0x100000000 - (0xE85250D6 + 0 + (header_e - header_s)) ; Checksum
|
||||
|
||||
; Other flags
|
||||
dw 0 ; Type
|
||||
dw 0 ; Flags
|
||||
dw 0 ; Size
|
||||
header_e:
|
@ -1,10 +1,10 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/iceOS ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/vulcanos ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
global idt_flush ; for drivers/idt.c
|
||||
|
||||
section .text
|
||||
|
@ -1,10 +1,10 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/iceOS ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/vulcanos ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
extern isr_handler ; Defined in drivers/isr.h
|
||||
extern irq_handler ; Defined in drivers/isr.h
|
||||
|
@ -1,43 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/iceOS ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
[BITS 32] ; We should be in protected mode
|
||||
section .multiboot
|
||||
|
||||
head_s:
|
||||
dd 0xE85250D6 ; Multiboot header magic number
|
||||
dd 0 ; Protected mode flag
|
||||
dd head_e - head_s ; Header length
|
||||
dd 0x100000000 - (0xE85250D6 + 0 + (head_e - head_s)) ; Checksum of above
|
||||
|
||||
; Other flags
|
||||
dw 0 ; type
|
||||
dw 0 ; flags
|
||||
dd 0 ; size
|
||||
|
||||
head_e:
|
||||
|
||||
GLOBAL kernel_loader
|
||||
EXTERN kernel_main
|
||||
|
||||
section .text
|
||||
kernel_loader:
|
||||
mov esp, kernel_stack + KERNEL_STACK_SZ ; Define stack pointer
|
||||
push eax ; Set multiboot header
|
||||
call kernel_main ; Jump into kernel's main function
|
||||
.loop:
|
||||
jmp .loop ; If the kernel returns, go into an infinite loop.
|
||||
; This will prevent the CPU to run non-kernel instructions
|
||||
; from the memory
|
||||
|
||||
KERNEL_STACK_SZ equ 4096 ; Stack size(4KiB)
|
||||
|
||||
section .bss
|
||||
align 4
|
||||
kernel_stack:
|
||||
resb KERNEL_STACK_SZ ; Reserve 4 KiB
|
27
kernel/cpu/main.asm
Normal file
27
kernel/cpu/main.asm
Normal file
@ -0,0 +1,27 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/vulcanos ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
GLOBAL kernel_loader
|
||||
EXTERN kernel_main
|
||||
[BITS 32] ; Ensure we are in protected mode
|
||||
|
||||
section .text
|
||||
kernel_loader:
|
||||
mov esp, kernel_stack + KERNEL_STACK_SZ ; Define stack pointer
|
||||
push eax ; Set multiboot header register
|
||||
call kernel_main ; Call kernel's main function
|
||||
.loop:
|
||||
jmp .loop ; If the kernel returns, go into an endless loop
|
||||
; This will prevent the CPU to execure any non-kernel
|
||||
; instructions.
|
||||
|
||||
KERNEL_STACK_SZ equ 4096 ; Stack size(4KiB)
|
||||
|
||||
section .bss
|
||||
align 4
|
||||
kernel_stack:
|
||||
resb KERNEL_STACK_SZ ; Reserver 4KiB for kernel's stack
|
@ -1,10 +1,10 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/iceOS ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vulcanOS Kernel ;
|
||||
; Developed by Marco 'icebit' Cetica ;
|
||||
; (c) 2019-2021 ;
|
||||
; Released under GPLv3 ;
|
||||
; https://github.com/ice-bit/vulcanos ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
global outb ; Output from port
|
||||
global inb ; Input to port
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef CPUID_H
|
||||
#define CPUID_H
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef FS_H
|
||||
#define FS_H
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _GDT_H_
|
||||
#define _GDT_H_
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _IDT_H_
|
||||
#define _IDT_H_
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef INITRD_H
|
||||
#define INITRD_H
|
||||
/* Ramdisk is a file system that is loaded along with the kernel
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _ISR_H_
|
||||
#define _ISR_H_
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _KEYBOARD_H_
|
||||
#define _KEYBOARD_H_
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _PORTS_H
|
||||
#define _PORTS_H
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _TIMER_H_
|
||||
#define _TIMER_H_
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _TTY_H_
|
||||
#define _TTY_H_
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#include "drivers/tty.h"
|
||||
#include "drivers/gdt.h"
|
||||
#include "drivers/idt.h"
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef PANIC_H
|
||||
#define PANIC_H
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _STDIO_H_
|
||||
#define _STDIO_H_
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef _STRING_H_
|
||||
#define _STRING_H_
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
/* Get time reading the RTC(real time clock) CMOS on the motherboard */
|
||||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
|
||||
/*** Heap implementation from James Molloy's tutorial:
|
||||
http://www.jamesmolloy.co.uk/tutorial_html/7.-The%20Heap.html ***/
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef ORDERED_ARRAY_H
|
||||
#define ORDERED_ARRAY_H
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
/*****************************************
|
||||
* VulcanOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019-2021 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/vulcanos *
|
||||
*****************************************/
|
||||
#ifndef PAGING_H
|
||||
#define PAGING_H
|
||||
|
||||
|
11
link.ld
11
link.ld
@ -1,17 +1,17 @@
|
||||
ENTRY(kernel_loader)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 1M;
|
||||
|
||||
.text 0x100000 :
|
||||
.boot :
|
||||
{
|
||||
code = .; _code = .; __code = .;
|
||||
*(.text)
|
||||
KEEP(*(.multiboot_header))
|
||||
. = ALIGN(4096);
|
||||
}
|
||||
|
||||
.data :
|
||||
.text :
|
||||
{
|
||||
data = .; _data = .; __data = .;
|
||||
*(.data)
|
||||
*(.rodata)
|
||||
. = ALIGN(4096);
|
||||
@ -19,7 +19,6 @@ SECTIONS
|
||||
|
||||
.bss :
|
||||
{
|
||||
bss = .; _bss = .; __bss = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4096);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user