GithubHelp home page GithubHelp logo

shadowdevz / nk-os Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 852 KB

Simple x64 based kernel.

License: GNU General Public License v2.0

Makefile 5.63% C 82.07% Assembly 10.63% GDB 0.21% Shell 0.27% Python 1.18%

nk-os's Introduction

nk-os

Hobyist x64 kernel Requirements: elf compatible x64 cross compiler without libgcc redzone support. For building the cross compiler use this script. limine bootloader v5.x is pulled and builded as dependency automatically.

In the future the os is going to use custom linear framebuffer

Build is currently only supported on linux (the script requires /dev/null device and forward slashes as path separator, will make it compatible for windows in future) !!!Bochs may not work properly if it was not compiled with graphics option!!!

  • xorriso
  • bash
  • nm
  • od
  • nasm
  • CC and LD (for dependencies)
  • qemu or any emulator which is able to handle x64 iso and graphics mode
  • objdump
  • awk
  • git
  • gdb
  • git
  • python3 (pathlib, os, sys)
  • VT100 compatible terminal that supports ANSI escape sequence for colored output

Building

If running for the first time and you do not have separate x86_64-elf cross compiler set check configk/config.mk and run make first_setup. This will download the whole GNU toolhcian and set the symlink inside the source directory for building. If you already got working toolchain don't forget to set it inside config/config.mk.

Building from clean source tree

make clean && make. After build the ISO and ELF files alongside symbols (if requested) are located inside the build directory.

Downloading dependencies

If the Makefile doesn't automatically pull all build dependencies (limine and flanterm) run make bootstrap command.

Building with more debugging symbols

make debug. This creates external symbols inside file and disassembled source.

Running

To run the target inside QEMU use make run. Settings and parameters can be adjusted inside config/config.mk

Debugging with QEMU/GDB

To debug the kernel run make run_dbg and navigate in second terminal to the same source directory and run GDB. This will automatically hook the target and set up the symbols. If you get a warning about safe execution you might have to add the init script as trusted inside your ~/.gdbinit config.

Kernel runtime dependeincies

  • X64 compatible emulator
  • SMBIOS3 only (for now)
  • i8259A PIC with cascaded second PIC wired through IRQ2
  • MBR and BIOS
  • Limine bootloader (for now)

TODOLIST:

  • ☑ Basic printing
  • ☐ Better framebuffer interface
  • ☑ GDT
  • ☑ IDT
  • ☑ ISR
  • ☑ Kernel symbols
  • ☑ Versioning scheme
  • ☑ Limine bootloader
  • ☑ SMBIOS Version 3
  • ☐ SMBIOS Version 2
  • ☐ HAL
  • ☑ IRQ
  • ☐ Better build system (CMake)
  • ☐ TSS (partially implemented)
  • ☑ PIT
  • ☑ PIC
  • ☑ PS2 keyboard
  • ☑ Debugging support
  • ☐ Paging
  • ☐ VMM
  • ☐ PMM
  • ☐ SMP
  • ☐ Threads
  • ☐ Custom remote debugger using unix socket via qemu
  • ☐ Usermode
  • ☐ ACPI
  • ☐ Kernel driver interface
  • ☑ Kernel main
  • ☐ Kconfig like customization
  • ☐ µGUI port
  • ☐ More user friendly toolchain builder
  • ☐ C++ support
  • ☐ Device manager
  • ☐ ATA support
  • ☐ AHCI support
  • ☐ Fat32 file system
  • ☐ Virtual filesystem
  • ☑ Logging
  • ☐ Network
  • ☐ Serial debugging
  • ☐ Processes
  • ☐ Kernel libc
  • ☐ libc
  • ☐ libsys
  • ☐ PCI driver
  • ☐ APIC
  • ☐ HPET
  • ☐ Syscalls
  • ☑ FPU
  • ☑ SSE
  • ☑ kernel error reporting

External used libraries and assets

printf library MIT license
limine bootloader BSD-2-Clause license
framebuffer BSD-2- Clause license

nk-os's People

Contributors

shadowdevz avatar

Watchers

 avatar

nk-os's Issues

GDT fatal crash

GDT is not setup correctly, in a debugger upon running i receive that the GDT gate descriptor entry is invalid

Not all fields inside registers_t are filled inside irq stub

The isrnumber (and possibly errorcode too) is not pushed onto the stack inside the irqhandler. This causes wrong registers to be written to the wrong place. Other fields (if not zeroed by assembler) may be left in undefined state and accessing them may cause ISR exception.

Possible fix: push dummy isr number (and possibly errorcode) to the stack and realign stack by 16 bytes.

PIT not working always in QEMU

The kusleep() function matched with PIT_SetFrequency() function works only half the time ? The other time it works. I was only able to reproduce this bug on the qemu-system-x86_64 emulator. The Virtualbox and Bochs work always as they are supposed to.

PIT ticks not behaving correctly

The PIT ticks variable is not incremented correctly upon exiting the timer callback variable. (It gets resetted back to the default value) and causes out of memory error. This needs to be fixed in order to get system uptime in ticks and use the sleep function

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.