Code Monkey home page Code Monkey logo

cos's Introduction

Hobby operating system

  • Mainly developped in C.
  • Boots with UEFI.
  • Does not do anything meaningful.

This repository

Source code structure

  • arch/*: architecture-specific code
    • boot: early boot (after firmware, before kernel_main)
    • *: same as non-arch
  • dev: device drivers
  • include
  • kernel: core kernel components (task management, core functions)
  • lib: hardware independant code (ELF, string manipulation, generic structures)
  • mm: memory management

Other directories

  • build: directory generated by ./boot script for QEMU
  • scripts: helper scripts
  • third_party: external libraries dependencies

Utilities

  • ./boot: script to boot the kernel
    • ./boot efi ARGS: starts kernel with QEMU (ARGS are passed to QEMU)
    • ./boot egdb ARGS: starts GDB and use the uefi.py lib to debug kernel
  • uefi.py: GDB library to load kernel symbols during boot
    • GDB command efi: automatically called by ./boot egdb:
      • load kernel symbols to 2 positions:
        • the address where EFI has loaded the kernel
        • the address where the kernel relocates
      • read the auto.gdb file
    • GDB command qq: kill kernel and quit
    • GDB command rbreakif: like rbreak but supports a condition
  • auto.gdb: commands to run automatically by uefi.py
    • lines starting with # are ignored
    • lines starting with @ don't produce output to GDB console
    • lines starting with * are executed on when breakpoint is reached (last created breakpoint)
    • other lines are executed normally

Build

Dependencies

  • Linux kernel Kconfig: conf and mconf executables must be in PATH

Compilation

  • Configure with make menuconfig
  • Build with make

Run

Boot with GDB in a single terminal:

Run the following boot shell function:

boot() { ./boot efi ${QEMU_ARGS} & ./boot egdb "$@" ; kill -0 $! 1>/dev/null 2>&1 && kill $! ; killall qemu-system-x86_64; }

Extra args are passed to GDB. QEMU_ARGS environment variable is passed to QEMU as extra args.

Boot with GDB in 2 terminal (for GDB and QEMU console):

  • Terminal 1: ./boot efi -monitor stdio -display none
  • Terminal 2: ./boot egdb

Build system

Each directory has:

  • A Kconfig file
  • A Makefile which lists needed object files:
    • all files in the obj-y variable will be built in the final kernel
    • all files in the bootloader-y variable will be built in the bootloader (stage 1 kernel)
    • Makefile structure (in order):
      • include Makefile.flags
      • define variables (obj-y, ...)
      • include Makefile.rules
      • define build rules specific to this directory

Compilation generates in each directory:

  • *.o files for the final kernel
  • *.bootloader.o for the bootloader
  • modules.o: all *.o files merged
  • bootloader.o: all *.bootloader.o files merged
  • *.d files corresponding to their *.o counterpart

cos's People

Contributors

teapot9 avatar

Watchers

 avatar

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.