Skip to content

Kernel for a student from Peter the Great St. Petersburg Polytechnic University

Notifications You must be signed in to change notification settings

shashinma/minimal-kernel-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

minimal-kernel-implementation

Kernel for a student from Peter the Great St. Petersburg Polytechnic University

Building:

g++ -ffreestanding -m32 -o kernel.o -c kernel.cpp
ld --oformat binary -Ttext 0x10000 -o kernel.bin - -entry=kmain -m elf_i386 kernel.o

Launch:

qemu –fda bootsect.bin –fdb kernel.bin
(if compiling in a 64-bit Linux environment, the gcc-multilib, binutils, g++,g++-multilib packages must be installed on the system)
The C code can be built using the Microsoft C Compiler using the following instructions (if no environment variables are specified, then the build must be done from the Visual Studio Command Prompt):
cl.exe /GS- /c kernel.cpp
link.exe /OUT:kernel.bin /BASE:0x10000 /FIXED /FILEALIGN:512 /MERGE:.rdata=.data /IGNORE:4254 /NODEFAULTLIB /ENTRY:kmain /SUBSYSTEM:NATIVE kernel.obj
dumpbin /headers kernel.bin
qemu –fda bootsect.bin –fdb kernel.bin
For successful compilation, assembler inserts in the program code in C must be written using Intel syntax:
// Beginning of kernel.cpp
extern "C" int kmain();
__declspec(naked) void startup()
{
      __asm {
            call kmain;
} }
      // Endless kernel loop
      while(1)
      {
__asm hlt;
}

About

Kernel for a student from Peter the Great St. Petersburg Polytechnic University

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published