GithubHelp home page GithubHelp logo

00mjk / sos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sonald/sos

0.0 0.0 0.0 371 KB

Sian's Operating System

License: Other

Shell 0.01% C++ 76.17% Python 0.92% C 19.95% Assembly 1.67% Makefile 1.27%

sos's Introduction

logo

sos

Sian's experimenting Operating System written in C++. it's a 32bit os kernel and runs on uniprocessor.

screenshot

BUILD

Like makefile indicated, this is a x86 kernel, and you need a i686 gcc cross compiler for building and running it. see here for the information. I think it also works under a 32bit GNU/Linux distribution. you may need to specify -Wl,--build-id=none for successful compiling. The kernel follows multiboot protocol and need a hd img with grub2 preinstalled. Here is a premade image for testing.

Refs

xv6 is a great reference implementation of a unix style kernel. linux 0.11 is also worth reading, and I learned a lot from these projects. You can find a lot of info about writing an small os kernel here.

Notes

One of the hardest as far as I can tell is memory management. I do implement my own kmalloc/kfree based on a simple algorithm. The way I choose to manage memory (both physical and virtual) makes some thing hard to implement, i.e shared memory region.

Another thing is task switch. There are many ways to do this, xv6's way or old linux way or your own method.

When design other parts of the kernel, you can stick to the unix tradition or just go bold and invent your own.

How to make a hd.img

This works under modern GNU/Linux (tested on Deepin 15). make disk image, then use parted (or fdisk to format as msdos)

dd if=/dev/zero of=hd.img bs=1M count=500
sudo parted hd.img mklabel msdos
sudo parted hd.img mkpart primary fat32 0% 100%

bind loop device (fat32 partition will be /dev/loop0p1) and mkfs

sudo losetup -f -P -v hd.img
sudo mkfs.vfat -F 32 /dev/loop0p1

then mount fat32 partition and install grub2:

sudo mount /dev/loop0p1 /mnt
sudo grub-install --modules="fat biosdisk normal part_msdos ext2 multiboot" --root-directory=/mnt /dev/loop0

TODOs

  • tty and io partially works
  • enough syscalls for sh
  • write support of vfs & block io layers
  • signal handling (partially)
  • simple GUI and software renderer (may port mesa if possible)
  • port newlib as userland libc

ISSUSE

  • physical mm is not good enough, and it's impossible to do va->pa & pa->va convertion.
  • userspace alloc will make some virtual address in kernel space can not be mapped (by adding KERNEL_VIRTUAL_BASE). which in turn may cause kernel has no mem to alloc.
  • sos use trap gate for syscalls, which leaves IF as it was(not cleared). must be very careful.
  • spinlock can not used in irq context in uniprocess system.
  • take care of the IF state, sleep can only happen with IF enabled context and wakeup from irq context leave IF disabled.
  • about spinlock: busy-waiting isn't enough when access syscall is a trap gate (IF enabled). we need to make sure cli'ed so fork / exec will not be preempted before finished.

sos's People

Contributors

sonald 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.