Begin transition to UEFI.
The current system of separating x86 and x86_64 is no longer feasible with UEFI implementation. UEFI must have its own entry point. To this end, some optimisations have been implemented in the ASM files. Everything related to setup has been removed, leaving only the IDT and GDT utility functions. The linker may be required for the other files, though.
This commit is contained in:
parent
d4e6dd4da8
commit
8f0de18b37
|
@ -1,94 +0,0 @@
|
||||||
[BITS 32] ;... somehow.
|
|
||||||
|
|
||||||
[GLOBAL start]
|
|
||||||
start:
|
|
||||||
mov esp, _sys_stack ; Stack pointer!
|
|
||||||
jmp stublet ; This has a purpse. I don't know what it is, but there is one.
|
|
||||||
|
|
||||||
ALIGN 4 ; 4KB alignment, required by GRUB.
|
|
||||||
mboot: ; This is all magic, and all of it required for GRUB to see our stuff.
|
|
||||||
MULTIBOOT_ALIGN equ 1<<0
|
|
||||||
MULTIBOOT_MEM equ 1<<1
|
|
||||||
MULTIBOOT_AOUT equ 1<<16
|
|
||||||
MULTIBOOT_MAGIC equ 0x1BADB002
|
|
||||||
MULTIBOOT_FLAGS equ MULTIBOOT_ALIGN | MULTIBOOT_MEM | MULTIBOOT_AOUT
|
|
||||||
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
|
|
||||||
EXTERN code, bss, end
|
|
||||||
|
|
||||||
dd MULTIBOOT_MAGIC
|
|
||||||
dd MULTIBOOT_FLAGS
|
|
||||||
dd MULTIBOOT_CHECKSUM
|
|
||||||
|
|
||||||
dd mboot
|
|
||||||
dd code
|
|
||||||
dd bss
|
|
||||||
dd end
|
|
||||||
dd start
|
|
||||||
|
|
||||||
stublet: ; Where the kernel stuff goes.
|
|
||||||
|
|
||||||
;=====================================
|
|
||||||
;===Priority: 32 bit Protected Mode===
|
|
||||||
;=====================================
|
|
||||||
|
|
||||||
cli ; Interrupts be gone!
|
|
||||||
|
|
||||||
xor cx, cx ; CX - GP, useful here.
|
|
||||||
kbempty:
|
|
||||||
in al, 64h ; Read keyboard status
|
|
||||||
test al, 02h ; Check if the buffer is full
|
|
||||||
loopnz kbempty ; Wait until it is
|
|
||||||
mov al, 0d1h ; Prepare a message
|
|
||||||
out 64h, al ; And then send it to the keyboard (controller)
|
|
||||||
kbempty2:
|
|
||||||
in al, 64h ; Read the status again
|
|
||||||
test al, 02h ; Check if it's processed our message
|
|
||||||
loopnz kbempty2 ; And wait until it has
|
|
||||||
mov al, 0dfh ; Prepare a different message, telling it to enable A20
|
|
||||||
out 60h, al ; Send the message
|
|
||||||
mov cx, 14h ; Restore the value of CX
|
|
||||||
wait_kb: ; Insinuate a 25uS delay to allow the processor to catch up
|
|
||||||
out 0edh, ax
|
|
||||||
loop wait_kb
|
|
||||||
|
|
||||||
mov eax, cr0 ; Read the control register
|
|
||||||
or al, 1 ; Set bit 1: protected mode
|
|
||||||
mov cr0, eax ; Set the control register back
|
|
||||||
jmp $+2 ; Clear the queue
|
|
||||||
nop ; (jump straight to kernel)
|
|
||||||
nop
|
|
||||||
|
|
||||||
;==================================
|
|
||||||
;===32-bit Protected Mode active===
|
|
||||||
;==================================
|
|
||||||
; Call the kernel
|
|
||||||
|
|
||||||
EXTERN kernel_main
|
|
||||||
call kernel_main
|
|
||||||
jmp $
|
|
||||||
|
|
||||||
[GLOBAL load_gdt]
|
|
||||||
[EXTERN gp]
|
|
||||||
load_gdt:
|
|
||||||
lgdt [gp] ; Load the new GDT pointer
|
|
||||||
|
|
||||||
mov ax, 0x10
|
|
||||||
mov ds, ax
|
|
||||||
mov es, ax
|
|
||||||
mov fs, ax
|
|
||||||
mov gs, ax
|
|
||||||
mov ss, ax
|
|
||||||
jmp 0x08:flush
|
|
||||||
flush:
|
|
||||||
ret
|
|
||||||
|
|
||||||
[GLOBAL idt_load]
|
|
||||||
[EXTERN idtp]
|
|
||||||
idt_load:
|
|
||||||
lidt [idtp]
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
SECTION .bss
|
|
||||||
resb 8192
|
|
||||||
_sys_stack:
|
|
28
arch/uefi/boot.s
Normal file
28
arch/uefi/boot.s
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
[BITS 32] ;... somehow.
|
||||||
|
|
||||||
|
|
||||||
|
[GLOBAL load_gdt]
|
||||||
|
[EXTERN gp]
|
||||||
|
load_gdt:
|
||||||
|
lgdt [gp]
|
||||||
|
|
||||||
|
mov ax, 0x10
|
||||||
|
mov ds, ax
|
||||||
|
mov es, ax
|
||||||
|
mov fs, ax
|
||||||
|
mov gs, ax
|
||||||
|
mov ss, ax
|
||||||
|
jmp 0x08:flush ; Far jump and load the new CSD into the processor
|
||||||
|
flush:
|
||||||
|
ret
|
||||||
|
|
||||||
|
[GLOBAL load_idt]
|
||||||
|
[EXTERN idtp]
|
||||||
|
load_idt:
|
||||||
|
lidt [idtp]
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
SECTION .bss
|
||||||
|
resb 8192
|
||||||
|
_sys_stack:
|
0
arch/uefi/entry.c
Normal file
0
arch/uefi/entry.c
Normal file
50
arch/i386/linker.ld → arch/uefi/linker.ld
Executable file → Normal file
50
arch/i386/linker.ld → arch/uefi/linker.ld
Executable file → Normal file
|
@ -1,25 +1,25 @@
|
||||||
OUTPUT_FORMAT("elf32-i386")
|
OUTPUT_FORMAT("elf32-i386")
|
||||||
ENTRY(start)
|
ENTRY(start)
|
||||||
phys = 0x00100000;
|
phys = 0x00100000;
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
.text phys : AT(phys) {
|
.text phys : AT(phys) {
|
||||||
code = .;
|
code = .;
|
||||||
*(.text)
|
*(.text)
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
. = ALIGN(4096);
|
. = ALIGN(4096);
|
||||||
}
|
}
|
||||||
.data : AT(phys + (data - code))
|
.data : AT(phys + (data - code))
|
||||||
{
|
{
|
||||||
data = .;
|
data = .;
|
||||||
*(.data)
|
*(.data)
|
||||||
. = ALIGN(4096);
|
. = ALIGN(4096);
|
||||||
}
|
}
|
||||||
.bss : AT(phys + (bss - code))
|
.bss : AT(phys + (bss - code))
|
||||||
{
|
{
|
||||||
bss = .;
|
bss = .;
|
||||||
*(.bss)
|
*(.bss)
|
||||||
. = ALIGN(4096);
|
. = ALIGN(4096);
|
||||||
}
|
}
|
||||||
end = .;
|
end = .;
|
||||||
}
|
}
|
18
arch/i386/make.config → arch/uefi/make.config
Executable file → Normal file
18
arch/i386/make.config → arch/uefi/make.config
Executable file → Normal file
|
@ -1,9 +1,9 @@
|
||||||
KERNEL_ARCH_CFLAGS=
|
KERNEL_ARCH_CFLAGS=
|
||||||
KERNEL_ARCH_CPPFLAGS=
|
KERNEL_ARCH_CPPFLAGS=
|
||||||
KERNEL_ARCH_LDFLAGS=
|
KERNEL_ARCH_LDFLAGS=
|
||||||
KERNEL_ARCH_LIBS=
|
KERNEL_ARCH_LIBS=
|
||||||
|
|
||||||
KERNEL_ARCH_OBJS= \
|
KERNEL_ARCH_OBJS= \
|
||||||
$(ARCHDIR)/boot.o \
|
$(ARCHDIR)/boot.o \
|
||||||
$(ARCHDIR)/sys_clock.o \
|
$(ARCHDIR)/sys_clock.o \
|
||||||
$(ARCHDIR)/tty.o
|
$(ARCHDIR)/tty.o
|
68
arch/i386/sys_clock.c → arch/uefi/sys_clock.c
Executable file → Normal file
68
arch/i386/sys_clock.c → arch/uefi/sys_clock.c
Executable file → Normal file
|
@ -1,35 +1,35 @@
|
||||||
/************************
|
/************************
|
||||||
*** Team Kitty, 2019 ***
|
*** Team Kitty, 2019 ***
|
||||||
*** Sync ***
|
*** Sync ***
|
||||||
***********************/
|
***********************/
|
||||||
|
|
||||||
/* This file provides an interface to
|
/* This file provides an interface to
|
||||||
* the hardware timer / RTC. Not much
|
* the hardware timer / RTC. Not much
|
||||||
* more to be said about it. */
|
* more to be said about it. */
|
||||||
|
|
||||||
#include <kernel/utils.h>
|
#include <kernel/utils.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <kernel/serial.h>
|
#include <kernel/serial.h>
|
||||||
#include <kernel/descriptor_tables.h>
|
#include <kernel/descriptor_tables.h>
|
||||||
|
|
||||||
size_t timer_ticks = 0;
|
size_t timer_ticks = 0;
|
||||||
size_t flag = 0;
|
size_t flag = 0;
|
||||||
void timer_handler(struct int_frame* r) {
|
void timer_handler(struct int_frame* r) {
|
||||||
gdb_end();
|
gdb_end();
|
||||||
timer_ticks++;
|
timer_ticks++;
|
||||||
|
|
||||||
if(timer_ticks % 18 == 0) {
|
if(timer_ticks % 18 == 0) {
|
||||||
if(++flag % 2 == 0) {
|
if(++flag % 2 == 0) {
|
||||||
serial_print(0x3F8, "Tick.");
|
serial_print(0x3F8, "Tick.");
|
||||||
} else {
|
} else {
|
||||||
serial_print(0x3F8, "Tock.");
|
serial_print(0x3F8, "Tock.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(timer_ticks > 18)
|
if(timer_ticks > 18)
|
||||||
timer_ticks = 0;
|
timer_ticks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_install() {
|
void timer_install() {
|
||||||
irq_install_handler(0, &timer_handler);
|
irq_install_handler(0, &timer_handler);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user