summaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/head.s
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-09-28 22:54:29 +0000
committerJoursoir <chat@joursoir.net>2021-09-28 22:54:29 +0000
commit6e52d3e6ae1d1612884d8d1533007e1d46f0c4eb (patch)
treeaadb2e38da1ffdcf7cf9853c9b0e3dfc5ab42c64 /arch/x86/boot/head.s
parent894e61508a09841f9b4a8e81fdd265b2a9eef1fc (diff)
downloadmfsos-6e52d3e6ae1d1612884d8d1533007e1d46f0c4eb.tar.gz
mfsos-6e52d3e6ae1d1612884d8d1533007e1d46f0c4eb.tar.bz2
mfsos-6e52d3e6ae1d1612884d8d1533007e1d46f0c4eb.zip
x86/boot: add 32bit startup code
Diffstat (limited to 'arch/x86/boot/head.s')
-rw-r--r--arch/x86/boot/head.s27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/x86/boot/head.s b/arch/x86/boot/head.s
new file mode 100644
index 0000000..a1bc6d1
--- /dev/null
+++ b/arch/x86/boot/head.s
@@ -0,0 +1,27 @@
+/*
+ head.s is loaded at 0x1000 (by second stage), its main goal
+ is run 32-bit startup code.
+
+ After that manipulations it jumps to kernel written by C
+*/
+
+.code32 # Tell GAS to generate 32 bit code
+.extern kernel_main
+
+.set CODESEG, 0x08
+.set DATASEG, 0x10
+
+.global _start
+_start:
+ mov $DATASEG, %ax # Point segment registers to the
+ mov %ax, %ds # data selector we defined in our GDT
+ mov %ax, %es
+ mov %ax, %ss
+ mov %ax, %fs
+ mov %ax, %gs
+
+ mov $0x90000, %ebp # Update stack position so it is right
+ mov %ebp, %esp # at the top of the free space.
+
+ call kernel_main
+ jmp . # infinite loop