GithubHelp home page GithubHelp logo

arjun024 / mkeykernel Goto Github PK

View Code? Open in Web Editor NEW
655.0 29.0 92.0 21 KB

A kernel that can read from keyboard and print on-screen

Home Page: https://arjunsreedharan.org/post/99370248137/kernels-201-lets-write-a-kernel-with-keyboard

License: GNU General Public License v2.0

Assembly 16.81% C 83.19%

mkeykernel's Introduction

mkeykernel

This is a kernel that can read the characters a-z and 0-9 from the keyboard and print them on screen.

See the repo mkernel which is a minimal kernel that prints a string on the screen. mkeykernel just extends this to include keyboard support.

Blog post

Kernel 201 - Let’s write a Kernel with keyboard and screen support

Build commands

nasm -f elf32 kernel.asm -o kasm.o
gcc -m32 -c kernel.c -o kc.o
ld -m elf_i386 -T link.ld -o kernel kasm.o kc.o

If you get the following error message:

kc.o: In function `idt_init':
kernel.c:(.text+0x129): undefined reference to `__stack_chk_fail'

compile with the -fno-stack-protector option:

gcc -fno-stack-protector -m32 -c kernel.c -o bin/kc.o

Test on emulator

qemu-system-i386 -kernel kernel

Get to boot

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

So, rename the kernel:

mv kernel 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 of mkernel repo.

Reboot.

Voila!

kernel screenshot

mkeykernel's People

Contributors

arjun024 avatar bryant1410 avatar johnlunney avatar photonoli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mkeykernel's Issues

qemu: fatal: Trying to execute code outside RAM or ROM at 0x0e0a0000

qemu: fatal: Trying to execute code outside RAM or ROM at 0x0e0a0000

EAX=00006f04 EBX=00009500 ECX=000b80a0 EDX=00006f04
ESI=00000000 EDI=00102000 EBP=00000000 ESP=00006f24
EIP=0e0a0000 EFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000cca10 00000027
IDT= 001004e0 00000800
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000020 CCD=00000010 CCO=SARL
EFER=0000000000000000
FCW=037f FSW=0000 [ST=0] FTW=00 MXCSR=00001f80
FPR0=0000000000000000 0000 FPR1=0000000000000000 0000
FPR2=0000000000000000 0000 FPR3=0000000000000000 0000
FPR4=0000000000000000 0000 FPR5=0000000000000000 0000
FPR6=0000000000000000 0000 FPR7=0000000000000000 0000
XMM00=00000000000000000000000000000000 XMM01=00000000000000000000000000000000
XMM02=00000000000000000000000000000000 XMM03=00000000000000000000000000000000
XMM04=00000000000000000000000000000000 XMM05=00000000000000000000000000000000
XMM06=00000000000000000000000000000000 XMM07=00000000000000000000000000000000
./debug_debian.sh: line 5: 3842 Aborted qemu-system-i386 -kernel kernel-101

yup

error ld

ld: warning: cannot find entry symbol entry; defaulting to 0000000000100000
ld: kc.o:kernel.c:(.text+0x8f): undefined reference to keyboard_handler' ld: kc.o:kernel.c:(.text+0xcf): undefined reference to write_port'
ld: kc.o:kernel.c:(.text+0xe3): undefined reference to write_port' ld: kc.o:kernel.c:(.text+0xf7): undefined reference to write_port'
ld: kc.o:kernel.c:(.text+0x10b): undefined reference to write_port' ld: kc.o:kernel.c:(.text+0x11f): undefined reference to write_port'
ld: kc.o:kernel.c:(.text+0x133): more undefined references to write_port' follow ld: kc.o:kernel.c:(.text+0x1ac): undefined reference to load_idt'
ld: kc.o:kernel.c:(.text+0x1c9): undefined reference to write_port' ld: kc.o:kernel.c:(.text+0x1e7): undefined reference to write_port'
ld: kc.o:kernel.c:(.text+0x1f3): undefined reference to read_port' ld: kc.o:kernel.c:(.text+0x20d): undefined reference to read_port'

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.