Git Product home page Git Product logo

vlang / vinix Goto Github PK

View Code? Open in Web Editor NEW
1.8K 64.0 116.0 12.38 MB

Vinix is an effort to write a modern, fast, and useful operating system in the V programming language

Home Page: https://vlang.io

License: GNU General Public License v2.0

V 92.37% C 1.37% Makefile 2.02% Verilog 0.83% Shell 1.46% AMPL 0.21% Assembly 0.42% C++ 0.02% Python 1.30%
os operating-system vlang v hacktoberfest

vinix's Introduction

Vinix

Vinix is an effort to write a modern, fast, and useful operating system in the V programming language.

Join the Discord chat.

What is Vinix all about?

  • Keeping the code as simple and easy to understand as possible, while not sacrificing performance and prioritising code correctness.
  • Making a usable OS which can run on real hardware, not just on emulators or virtual machines.
  • Targeting modern 64-bit architectures, CPU features, and multi-core computing.
  • Maintaining good source-level compatibility with Linux to allow to easily port programs over.
  • Exploring V capabilities in bare metal programming and improving the compiler in response to the uncommon needs of bare metal programming.
  • Having fun.

Note: Vinix is still pre-alpha software not meant for daily or production usage!

Screenshot 0 Screenshot 1

Photo by Hubblesite.org: https://hubblesite.org/files/live/sites/hubble/files/home/science/stars-and-nebulae/_images/STScI-H-stars-nebulae-0411a-2400x1200.jpg

Download latest nightly image

You can grab a pre-built nightly Vinix image at https://github.com/vlang/vinix/releases

Make sure to boot the ISO with enough memory (8+GiB) as, for now, Vinix loads its entire root filesystem in a ramdisk in order to be able to more easily boot on real hardware.

Roadmap

  • mlibc
  • bash
  • gcc/g++
  • V
  • nano
  • storage drivers
  • ext2
  • X.org
  • Networking
  • Wayland
  • Hypervisor
  • X window manager
  • V-UI
  • Intel HD graphics driver (Linux port)

Build instructions

Distro-agnostic build prerequisites

The following is a distro-agnostic list of packages needed to build Vinix.

Skip to a paragraph for your host distro if there is any.

GNU make, diffutils, curl, git, bsdtar, rsync, xorriso, and qemu to test it.

Build prerequisites for Ubuntu, Debian, and derivatives

sudo apt install -y make diffutils curl git libarchive-tools rsync xorriso qemu-system-x86

Build prerequisites for Arch Linux and derivatives

sudo pacman -S --needed make diffutils curl git libarchive rsync xorriso qemu

Build prerequisites for Red Hat Linux and derivatives

sudo yum install -y make diffutils curl git bsdtar rsync xorriso qemu

Building the distro

To build the distro, which includes the cross toolchain necessary to build kernel and ports, as well as the kernel itself, run:

make distro-base # Build the base distribution.
make all         # Make filesystem and ISO.

This will build a minimal distro image. The make distro-full target is also avaliable to build the full distro; this step will take a while.

To test

In Linux, if KVM is available, run with

make run-kvm

In macOS, if hvf is available, run with

make run-hvf

To run without any acceleration, run with

make run

vinix'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  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  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

vinix's Issues

Panic when executing specially-crafted file

If you create a file called /bin/loop with the following contents:

#!/bin/loop

The VINIX kernel will infinitely recurse in the userland.start_program function, until it eventually runs out of stack space and panics.

The way Linux deals with this case is by keeping track of the recursion depth, and setting errno = ELOOP and returning if the arbitrary max depth is reached (I believe the depth is 4 on linux, but don't quote me on that).

Vinix halts when pressed keys '(' and ')' in vim or nano

Description

The system simply stops when pressed keys like '(', ')', '.', ',', TAB, BACKSPACE in nano or vim

Info

Emulator: qemu-system-x86_64
Host Memory: 8 GiB
Guest Memory: 4 GiB
Command: qemu-system-x86_64 -cdrom vinix.iso -m 4096

Reproduction

  • OPEN vim test.c
  • TYPE int main()
  • THE SYSTEM HALTS

Debug Info

0xffffffff800280f6: f4         hlt
0xffffffff800280f7: f4         jmp 0xffffffff800280f6
0xffffffff800280f8: eb fd      popq %rbp

Add more than one keyboard layout

I already mentioned it in the discord, but it would be nice to add more than one keyboard layout (Something like the loadkeys command in Linux).
As far as I know @streaksu is already working on it, but I wanted to make an issue in case someone wants to comment something.

make distro can't build dependency libxcb

I am trying to build vinix using make distro and it keeps failing. I have been able to successfully build vinix using make. Here is a screenshot of the error that I get when I run make distro

vinix build error

Kernel Panic without raising memory for qemu that also causes the console to appear frozen during boot

I'm not sure if this is something specific to my system or not, but I had to bump the qemu memory limit in the Makefile to 4G but after that it booted (though bash is complaining about no job control). I run a somewhat out of date void linux install, if that makes any difference.

There's also an issue that the OS's console doesn't show any sign of the panic - I had to check the terminal I ran make run-kvm in to find out it was panicked. I managed to trigger another panic later (I hit up in bash to get the last entered line. Error was: array.get: index out of range (i == 72, a.len == 58)) which did show the panic info, so this might be some edge-case or something.

Also, I just want to say, this is the first OS I've found written in one of these newer languages that actually builds and runs. Best of all I didn't have to deal with the whole "build your own cross-compilation setup by hand because it needs a specific version of GCC" task only to be greeted with cryptic compile errors that wind up being broken code due to their compiler/stdlib internals changing. I cannot begin to convey my awe at this. Extremely well done.

OsDev Tutorial

This system is very cool but I still don't know how it works from the ground up. Do you foresee the creation of some tutorial on this topic. Something like https://os.phil-opp.com/ only in V ?
I look forward to your reply ๐Ÿ˜Š

Out of bounds handling for non-US keyboards

For the most part a UK layout keyboard works on Vinix, but certain keys will trigger a panic. For example, when typing a pipe character:

V panic: array.get: index out of range (i == 86, a.len == 58)
v hash: bfcf5b1

I suggest for all keys that cannot be mapped, that U+FFFD ๏ฟฝ REPLACEMENT CHARACTER is emitted.

Make distro not working

I just pulled the repo today (upgrade mlibc - d6bd129) and tried to build on an Arch based distro of Linux. I had the same errors in the wget subdir when trying to build with both clang-12.0.1 and gcc-11.1.0:

/home/wilsonk/Downloads/vinix/build/../3rdparty/wget/lib/c-strcasecmp.c: In function 'c_strcasecmp':
/home/wilsonk/Downloads/vinix/build/../3rdparty/wget/lib/c-strcasecmp.c:49:7: error: 'UCHAR_MAX' undeclared (first use in this function)
   49 |   if (UCHAR_MAX <= INT_MAX)
      |       ^~~~~~~
/home/wilsonk/Downloads/vinix/build/../3rdparty/wget/lib/c-strcasecmp.c:25:1: note: 'UCHAR_MAX' is defined in header '<limits.h>'; did you forget to '#include <limits.h>'?
   24 | #include "c-ctype.h"
  +++ |+#include <limits.h>
   25 | 
/home/wilsonk/Downloads/vinix/build/../3rdparty/wget/lib/c-strcasecmp.c:49:7: note: each undeclared identifier is reported only once for each function it appears in
   49 |   if (UCHAR_MAX <= INT_MAX)
      |       ^~~~~~~~~
/home/wilsonk/Downloads/vinix/build/../3rdparty/wget/lib/c-strcasecmp.c:49:20: error: 'INT_MAX' undeclared (first use in this function)
   49 |   if (UCHAR_MAX <= INT_MAX)
      |                    ^~~~~~~
/home/wilsonk/Downloads/vinix/build/../3rdparty/wget/lib/c-strcasecmp.c:49:20: note: 'INT_MAX' is defined in header '<limits.h>'; did you forget to '#include <limits.h>'?

I tried to just remove the wget directory and maybe get things built that way, but I ran into some similar errors with another package. Not sure why this is happening, but it is a bit of a show stopper :)

Any suggestions?

Add CI

For this, we need to have a pre-built x86_64-vos-gcc, to prevent timing out the CIs (and also make it a lot faster). One CI will build x86_64-vos-gcc, and then publish it in releases (if the commit has a tag).

List of things we should test:

  • Formatting (v fmt -verify)
  • Distro (make distro, and then publish ./build/tools/host-gcc/bin/x86_64-vos-gcc for use by subsequent jobs)
  • Building (make)
  • Running (make run)

error when running make distro

when i try make distro it gives me this error ../../../3rdparty/glib/subprojects/libffi/src/meson.build:71:2: ERROR: Problem encountered: Unsupported pair: system "vinix", cpu family "x86_64"

C.event__trigger call in modules/time/time.v

Hi there! I'm using VINIX to learn how to write an operating system, and in the process of porting the event subsystem into my own OS I spotted a bit of a strange calling convention in the event.v file.

On line 79, there's a C function declared called event__trigger, which is then called on line 94. I believe this is actually calling the V function event.trigger from the event module, however it is doing it using the calling conventions used for calling into C code for some reason. It gets away with it because of the way Vlang clobbers function names (module.function -> module__function) making it actually a "valid" call, but this exposure of V's internals is potentially unstable so I thought I'd bring it to your attention.

If there's an actual reason behind this, or if I'm misunderstanding something, I'm happy to be corrected!

Win kernel

How to write a windows kernel driver hook ssdt table with vt-x ept page hide use vlang

Recent changes causing `git pull` conflict`

I started seeing this recently, whenever I do a git pull:

error: Your local changes to the following files would be overwritten by merge:
        kernel/blob.patch
Please commit your changes or stash them before you merge.

I have not modified that file, myself, so it must be happening during make distro or make operations.
I have to do a git restore on the file before git pull works.

all compilers hang and ^C causes page fault on cpu 2

I was using GCC, V, and G++ and they all hang when trying to compile the scripts that are on the system already. I tried canceling them and GCC and G++ cause a page fault on CPU 2, but V just hangs and shows the ^C as many times as you type it.

building with v creates weird file

I was messing around and found this weird bug.
Snip20210831_3
The file 000000 is a bug caused by v and I don't know if this is a v or vinix problem.

Failure in `make all`

Been a while since I tried to build vinix, and now on a new machine, so I started from scratch... cloned the source, installed necessary packages, typed make distro-base (which took a while, but finished successfully), then typed make all, which ended quickly with

* building package: kernel
* building host package: v
curl: (3) URL using bad/illegal format or missing URL
make: *** [GNUmakefile:9: all] Error 3

There are only 2 curl commands in the GNUmakefile, one to download jinx, and one to grab OVMF files. Since it didn't create an ovmf dir for the 2nd, it seems like it would have failed on the jinx curl... but I have jinx locally, and it just got created. So what is it complaining about?

mlibc patch step failing

With git commit be9c8a5, I am seeing this error when I try to run make distro:

xbstrap: patch mlibc [3/68]
Applying: Vinix specific changes
Using index info to reconstruct a base tree...
M       abis/mlibc/signal.h
M       meson.build
M       options/ansi/include/mlibc/ansi-sysdeps.hpp
M       options/internal/include/mlibc/internal-sysdeps.hpp
M       options/linux/include/asm/ioctls.h
M       options/posix/generic/unistd-stubs.cpp
.git/rebase-apply/patch:78: space before tab in indent.
        void (*sa_handler)(int);
.git/rebase-apply/patch:288: new blank line at EOF.
+
.git/rebase-apply/patch:1162: new blank line at EOF.
+
warning: 3 lines add whitespace errors.
Falling back to patching base and 3-way merge...
CONFLICT (add/add): Merge conflict in sysdeps/vinix/generic/generic.cpp
Auto-merging sysdeps/vinix/generic/generic.cpp
error: Failed to merge in the changes.
Patch failed at 0001 Vinix specific changes
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
xbstrap: Action patch of source mlibc failed
make: *** [Makefile:29: distro] Error 1

error: No checksum method specified for autoconf

Hi!
I am trying to build Vinix and i get this error:

$ make distro-base
./jinx build bash coreutils
* building package: bash
* building host package: automake
* building host package: autoconf
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1882k  100 1882k    0     0   656k      0  0:00:02  0:00:02 --:--:--  656k
* error: No checksum method specified for autoconf
make: *** [GNUmakefile:26: distro-base] Error 1

System is Arch Linux with Kernel 6.0
All packages specified were installed.

Logo suggestion

I like the idea of a V based OS. For branding, why don't you use a fox (inspired) logo? My reason for saying this is that "vos" is the dutch word for Fox.

I might not be the best person to contribute a logo, but maybe someone else can run with this idea and make something cool.

Switch to true Free Open Source license

Hi, respectfully i suggest to consider fully distribute the project under non-gpl licenses as it's demonstrated in project's like tensor flow (almost 3/4 AI projects are licensed in MIT-like licenses) it attract coders looking to get rid off viral clauses (as did tensorflow with R-based ML), while choosing for some license in Open Source community driven projects is seen with ideology or fear, other faces it with the practical issues derived from each license conditions, GPL is often considered as opesource savior as it prevents the IP being "stolen" by an commercial or rival actor, but actually it also kick off developers which just want some building blocks for his project's, mature developers understand how important it's for code life cycle to return to the community the improvements or corrections privately made, original developers will ever keep the advantage of the original know how and of being the community hub, while newcomers doesn't get discouraged to build a commercial product on top. Un mature developers will try to steal the code anyway with an fork (from gpl) or with an more elaborate "full" re-write with "own" IP.

Please don't see it ideologically, watch a what license has dominated most popular opensouce projects from last 10 years: non-gpl sound success: tensorflow, python, pytorch, node.js it's quite unusual seeing an new GitHub project based on python,node.js,swift even kotlin using gpl-like licenses.

I see big enthusiasm around V lang, but GPL IMHO kicked away more adopters than enthusiast it drives into.

j.a.

Variable name shadowing import symbol

From vlang/v#17173 and vlang/v#17197, variable should not shadow import symbol, there are several potential errors found in vinix:

  • modules/memory/mmap/mmap.v:268:6
  266 | pub fn mmap(_pagemap &memory.Pagemap, addr voidptr, _length u64, prot int, flags int, _resource &resource.Resource, offset i64) ?voidptr {
  267 |     mut pagemap := unsafe { _pagemap }
  268 |     mut resource := unsafe { _resource }
      |         ~~~~~~~~
  269 | 
  270 |     if _length == 0 {
  • modules/file/epoll.v:209:7
  207 |         }
  208 | 
  209 |         mut event := unsafe { &ret_events[i] }
      |             ~~~~~
  210 | 
  211 |         mut fd := fd_from_fdnum(unsafe { nil }, fdnum) or {
  • modules/file/epoll.v:218:7
  216 |         }
  217 | 
  218 |         mut resource := fd.handle.resource
      |             ~~~~~~~~
  219 | 
  220 |         status := resource.status
  • modules/file/epoll.v:244:7
  242 | 
  243 |         mut epoll_event := unsafe { &epoll_events[which] }
  244 |         mut event := unsafe { &ret_events[0] }
      |             ~~~~~
  245 | 
  246 |         if u32(status) & epoll_event.events != 0 {
  • modules/file/file.v:118:7
  116 |         }
  117 | 
  118 |         mut resource := fd.handle.resource
      |             ~~~~~~~~
  119 | 
  120 |         status := resource.status
  • modules/file/file.v:449:6
  447 |     }
  448 | 
  449 |     mut resource := &resource.Resource(unsafe { nil })
      |         ~~~~~~~~
  450 |     mut fd := &FD(0)
  451 |

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.