https://github.com/shashinma/minimal-kernel-implementation
Kernel for a student from Peter the Great St. Petersburg Polytechnic University
https://github.com/shashinma/minimal-kernel-implementation
asm assembly bootloader cpp kernel
Last synced: 3 months ago
JSON representation
Kernel for a student from Peter the Great St. Petersburg Polytechnic University
- Host: GitHub
- URL: https://github.com/shashinma/minimal-kernel-implementation
- Owner: shashinma
- Created: 2023-01-16T08:53:16.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-16T09:32:10.000Z (over 2 years ago)
- Last Synced: 2025-03-17T09:04:35.260Z (3 months ago)
- Topics: asm, assembly, bootloader, cpp, kernel
- Language: C++
- Homepage:
- Size: 15.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# minimal-kernel-implementation
Kernel for a student from Peter the Great St. Petersburg Polytechnic University#### Building:
```md
g++ -ffreestanding -m32 -o kernel.o -c kernel.cpp
``````md
ld --oformat binary -Ttext 0x10000 -o kernel.bin - -entry=kmain -m elf_i386 kernel.o
```#### Launch:
```md
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):
```md
cl.exe /GS- /c kernel.cpp
``````md
link.exe /OUT:kernel.bin /BASE:0x10000 /FIXED /FILEALIGN:512 /MERGE:.rdata=.data /IGNORE:4254 /NODEFAULTLIB /ENTRY:kmain /SUBSYSTEM:NATIVE kernel.obj
``````md
dumpbin /headers kernel.bin
``````md
qemu –fda bootsect.bin –fdb kernel.bin
```##### For successful compilation, assembler inserts in the program code in C must be written using Intel syntax:
```md
// Beginning of kernel.cpp
extern "C" int kmain();
__declspec(naked) void startup()
{
__asm {
call kmain;
} }
// Endless kernel loop
while(1)
{
__asm hlt;
}
```