Giter Site home page Giter Site logo

klika-os's Introduction

KlikaOS

KlikaOS is a hobbyist and educational operating system written in C (and some small parts are written in assembly).

Features

  • x86_64 OS
  • Grub2 as boot loader
  • Kernel @ 0xFFFF800000000000
  • Paging
    • 2MB pages
    • Userspace mapped at 0x0000000000000000
    • Kernel max 512MB
    • Userspace max 512MB
    • sbrk to extend userspace memory
  • Kernel heap (malloc/calloc/free)
  • Multi thread
    • Kernelspace
    • Userspace (ring3)
  • Drivers
    • Serial
    • Mouse
    • Keyboard
    • Vesa
    • Ata PIO
  • System calls (int 0x80)
    • File, memory, messaging, windows, processes
  • Graphics
    • Window manager in Kernel space
    • Double buffered
  • FAT 12/16/32 support
    • Using DOSFS 1.02
    • Read only
    • HD must be on Master, ISO CD on Slave
    • Mounted Disk.img to qemu
  • GUI library
    • In userspace
    • Based on kernel messaging: get_message/dispatch_message
    • get_message blocks process (WAIT state)
    • Window look'n'feel logic in userspace
    • Fixed font 8x8
  • BMP file support :(

Build

You can build KLIKAOS using Vagrant Dev Environment or on your local machine.

Build using Vagrant

Vagrantfile already contains all dependencies needed to build KLIKAOS. To use Vagrant as development environment following dependencies must be installed on your host machine:

  • VirtualBox
  • Vagrant
  • QEMU (for MacOS use brew: brew install qemu)

Run following:

vagrant up
vagrant ssh
cd /vagrant
make all run

This will create bootable ISO image and HD image in images folder. To run it, you will need qemu on your local machine. You can run it (FROM YOUR LOCAL MACHINE):

qemu-system-x86_64 -cdrom images/klika-os-x86_64.iso -m 128 -drive file=images/disk.img,format=raw,index=0,media=disk -boot order=d -serial stdio

Build on your local machine

Most effective way to build and run KLIKAOS is to install GCC cross compiler for your platform. GCC tools must be named using x86_64-elf prefix like:

x86_64-elf-gcc
x86_64-elf-ld
x86_64-elf-as
x86_64-elf-nm
x86_64-elf-objdump
x86_64-elf-objcopy
...

Dependencies:

  • qemu (4.0.0)
  • mtools (MUST BE 4.0.23)
  • gcc crosscompile
    • x86_64-elf-gcc (8.3.0)
    • x86_64-elf-ld (binutils 2.32)
    • x86_64-elf-as (binutils 2.32)
    • x86_64-elf-nm (binutils 2.32)
    • x86_64-elf-objdump (binutils 2.32)
    • x86_64-elf-objcopy (binutils 2.32)
    • nasm (2.14.02)
    • grub-mkrescue (2.05)

Easiest way is to look into Vagrantfile and see what needs to be installed.

To build and run with qemu:

make all run

Run

Repostiory already contains pre-built ISO and HD images. Fastest way to run it will be using qemu:

Using qemu

qemu-system-x86_64 -cdrom images/klikaos-x86_64.iso -m 128 -drive file=images/disk.img,format=raw,index=0,media=disk -boot order=d -serial stdio

Using VBox

Convert raw qemu image to .vdi image:

qemu-img convert -O vdi images/disk.img images/disk.vdi

Mount disk.vdi (master) and klikaos-x86_64.iso (slave). Start machine.

Creating KLIKAOS apps

Best way to create new app is just to copy simple_win from apps folder. Example for GUI app:

// See ./apps/simple_win
#include <klikaos.h>
#include <windows.h>
#include <stdlib.h>

#define MSG_USER_WIN		(WINDOW_USER_MESSAGE + 1)
#define MSG_USER_BTN1 	(WINDOW_USER_MESSAGE + 2)
#define MSG_USER_BTN2 	(WINDOW_USER_MESSAGE + 3)
#define MSG_USER_LABEL 	(WINDOW_USER_MESSAGE + 4)

message_t msg;
window_t  *window;
window_t  *label;
long counter = 0;

void increment_counter(int add) {
	char buff[123];

	counter += add;
	sprintf(buff, "Count: %i", counter);
	label_set_text(label, buff);
}

int main() {
	int layout_y = WINDOW_BAR_HEIGHT + 10;
	window = window_create(100, 100, 300, 300, "Simple Window", MSG_USER_WIN, WINDOW_ATTR_NONE, WINDOW_FRAME_DEFAULT);
	button_create(window, 10, layout_y, 100, 30, "Click me +", MSG_USER_BTN1);
	button_create(window, 120, layout_y, 100, 30, "Click me -", MSG_USER_BTN2);
	label = label_create(window, 10, layout_y + 40, 200, 20, "Number of clicks", MSG_USER_LABEL);

	while(window_get_message(window, &msg)) { 
		switch(msg.message) {
			case MSG_USER_BTN1:
				increment_counter(1);
				break;
			case MSG_USER_BTN2:
				increment_counter(-1);
				break;
		}
		window_dispatch(window, &msg);
	}
	return 0;
}

Kernel TODO

  • ATA Write Sector
  • FAT 12/16/32 Write
  • Time : kernel and syscall
  • Kill process (partially done : extend to remove win)
  • Load ELF larger than 2MB
  • Optimise graphics functions (asm or 64bit)
  • Child threads in user space
  • Scalable fonts (https://gitlab.com/bztsrc/scalable-font)
  • Full screen Exclusive mode (for game loops)
  • Transaprent pixels

Apps TODO

  • Desktop - discover apps from /apps folder
  • exit()
  • More components (button, text, radio, checkbox, ...)
  • Calculator
  • Sudoku

Images

Screenshot

Contributors ✨

Thanks goes to these wonderful people (emoji key):


SamirH

💻

Ensar Sarajčić

💻

Almir Hamza

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

klika-os's People

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

Watchers

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

klika-os's Issues

Licensing

I have noticed that there is no LICENSE.md file present. What is the license in use, if any?

Create new app to show basic system info.

Create simple app to show basic system metrics:

  • OS name & version
  • Free memory (there is already syscall syscall_memory_stats)
  • User memory (there is already syscall syscall_memory_stats)
  • List of all running processes (if possible ability to select process and show more info) - new syscall to return list of all processes.

ATA Write and FAT 12/16/32 Write file

  • Extend ATA driver with ata_write_one (ability to write single sector).
  • Implement DFS_WriteSector method in FAT driver.
  • Implement syscall_file_write (syscall_file.c) to expose write functionality to user apps.

could Klika OS fit on a floppy?

Even today the floppies are still being used, for example - as virtual floppies inside the coreboot open source BIOS. Just imagine: your wonderful OS could be a part of someone's BIOS build! (for coreboot supported motherboard, maybe you have or could get one - see https://www.coreboot.org/Supported_Motherboards )

@zpasal , If you already have a coreboot-supported motherboard, or a real chance to get one, - wouldn't it be cool to be able to launch your own OS straight from the BIOS chip? ;) With one simple command its possible to add any floppy to coreboot BIOS build - and then you see it as a boot entry! Multiple floppies could be added this way (as long as you have enough space left inside the BIOS flash chip, luckily LZMA compression could be used for the stored floppies to reduce their occupied size)

Desktop app

Extend current Desktop application ./apps/desktop with following features:

  1. App always on bottom (disable bring to front using create_window attributes)
  2. Disable window dragging (using create_window attributes)
  3. Full screen app without standard window theme
  4. Ability to have wallpaper
  5. Enumerate all apps in HD /apps folder and show them as icons
  6. Clicking on app spawn new user process (example code can be found in current version of desktop app)
  7. Add icon.kv file to each app folder to describe name and icon name for the app

icon.kv should look like:

icon=example.bmp
name=Sample app
executable=/apps/simplewin/simplewin

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.