Skip to content

shoily/xis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XIS operating system.

It supports boot loader, kernel with protected mode, paging, E820 enumeration, interrupt and exception handling, system calls, user mode, local APIC, ACPI and multiprocessor.

Instructions for building kernel -
cat krnlconst.hdr | awk 'BEGIN{print "#ifndef _KERNEL_CONST_H"}; { if(substr($1, 0, 1) != "#") {print "#define " $1 " " $2}; } END{print "#endif";}' > krnlconst.h
cat krnlconst.hdr | awk '{ if(substr($1, 0, 1) != "#") {print ".equ " $1 ", " $2}; }' > krnlconst.S

as --32 um.S -o um.o
ld --static -T um.ld -m elf_i386 -nostdlib --nmagic -o um.elf um.o
objcopy -O binary um.elf um.bin

as --32 mpinit.S -o mpinit.o
ld -static -T mpinit.ld -m elf_i386 -nostdlib --nmagic -o mpinit.elf mpinit.o
objcopy -O binary mpinit.elf mpinit.bin

as --32 boot32.S -o boot32.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c util.c -o util.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c system.c -o system.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c apic.c -o apic.o
as --32 handlr32.S -o handlr32.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c smp.c -o smp.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c setup32.c -o setup32.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c start.c -o start.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c memory.c -o memory.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c page32.c -o page32.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c usermode.c -o usermode.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c lock.c -o lock.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c debug.c -o debug.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c acpi.c -o acpi.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c interrupt.c -o interrupt.o
gcc -m32 -std=gnu99 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding -fno-pic -Wall -Wextra -Werror -c keyboard.c -o keyboard.o

ld -static -T kernel32.ld -m elf_i386 -nostdlib --nmagic boot32.o util.o system.o apic.o smp.o setup32.o handlr32.o memory.o page32.o usermode.o lock.o acpi.o debug.o interrupt.o keyboard.o start.o -o xiskernel.elf

objdump -x xiskernel.elf | grep _end_kernel_initial_pg_table | awk -Wposix '{cmd="printf %d 0x" $1; cmd | getline decimal; close(cmd); if (decimal > 4294963200) print "STOP: Not enough memory to map pagetables. Upgrade to 64bit kernel.";}'
objcopy -O binary xiskernel.elf xiskernel.bin

Instructions for building boot loader -
cat krnlconst.hdr | awk '{ if(substr($1, 0, 1) != "#") {print ".equ " $1 ", " $2}; }' > krnlconst.S
echo ".equ KERNEL_SIZE, `ls -l xiskernel.bin | cut -f5 -d\ `" > krnlsize.h
awk '/KERNEL_SIZE/{var=$3; cmd="objdump -x xiskernel.elf | grep INITIAL_KMAPPED_MEMORY | cut -f1 -d\ "; cmd | getline hex;close(cmd); cmd="printf %d 0x" hex; cmd | getline decimal; if ((var-4096) > decimal) printf("STOP: Map atleast 0x%x bytes in boot32.S. Currently mapped 0x%x bytes", var, decimal);}' krnlsize.S

as --32 bootldr.S -o bootldr.o
ld -static -T bootldr.ld -m elf_i386 -nostdlib --nmagic -o bootldr.elf bootldr.o
objcopy -O binary bootldr.elf bootldr.bin

Creating QEMU image -
dd if=bootldr.bin of=hda.raw
dd if=xiskernel.bin of=hda.raw seek=1
qemu-img convert -O qcow2 hda.raw hda.qcow2

Running using QEMU -
sudo qemu-system-i386 -smp 2 -hda hda.qcow2 -m 2 --enable-kvm -cpu host

Contact -

shoily@gmail.com