Code Monkey home page Code Monkey logo

mkernel's Introduction

mkernel-msys2-mingw64

A fork of arjun024/mkernel for MSYS2 MinGW 64-bit

This is a minimalist kernel which prints "my first kernel" on the screen and then hangs.

  • The kernel is multi-boot compliant and loads with GRUB.

Blog post

Kernel 101 – Let’s write a Kernel

Prerequisites

  1. Install MSYS2 x86_64
  2. Open MSYS2 MinGW 64-bit terminal
  3. Install dependencies (nasm, gcc, binutils, qemu):
pacman -S mingw-w64-x86_64-nasm mingw-w64-x86_64-gcc mingw-w64-x86_64-binutils mingw-w64-x86_64-qemu

(Note: You may or may not have to install other missing dependencies. In addition to the ones listed above, I also have base-devel and mingw-w64-x86_64-toolchain installed.)

Build commands

nasm -f elf32 kernel.asm -o kasm.o
gcc -m32 -c kernel.c -o kc.o
ld -m i386pe -T link.ld -o kernel kasm.o kc.o
objcopy -O elf32-i386 kernel kernel.elf

(Note: The commands ld and qemu-system-i386 slightly differ from those of the original mkernel. The standard MinGW/64 LD linker doesn't output ELF binaries. Because of this, the objcopy command is added to convert from PEI-I386 to ELF.)

Test on emulator

qemu-system-i386 -kernel kernel.elf

Get to boot

GRUB requires your kernel executable to be of the pattern kernel-<version>.

So, rename the kernel:

mv kernel.elf kernel-701

Copy it to your boot partition (assuming you are superuser):

cp kernel-701 /boot/kernel-701

Configure your grub/grub2 similar to what is given in _grub_grub2_config folder.

Reboot.

Voila!

kernel screenshot

The next step

See mkeykernel repo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.